[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250205151950.25268-10-alucerop@amd.com>
Date: Wed, 5 Feb 2025 15:19:33 +0000
From: <alucerop@....com>
To: <linux-cxl@...r.kernel.org>, <netdev@...r.kernel.org>,
<dan.j.williams@...el.com>, <edward.cree@....com>, <davem@...emloft.net>,
<kuba@...nel.org>, <pabeni@...hat.com>, <edumazet@...gle.com>,
<dave.jiang@...el.com>
CC: Alejandro Lucero <alucerop@....com>
Subject: [PATCH v10 09/26] cxl: support device identification without mailbox
From: Alejandro Lucero <alucerop@....com>
Type3 relies on mailbox CXL_MBOX_OP_IDENTIFY command for initializing
memdev state params.
Allow a Type2 driver to initialize same params using an info struct and
assume partition alignment not required by now.
Signed-off-by: Alejandro Lucero <alucerop@....com>
---
drivers/cxl/core/memdev.c | 12 ++++++++++++
include/cxl/cxl.h | 11 +++++++++++
2 files changed, 23 insertions(+)
diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c
index 456d505f1bc8..7113a51b3a93 100644
--- a/drivers/cxl/core/memdev.c
+++ b/drivers/cxl/core/memdev.c
@@ -655,6 +655,18 @@ struct cxl_memdev_state *cxl_memdev_state_create(struct device *dev, u64 serial,
}
EXPORT_SYMBOL_NS_GPL(cxl_memdev_state_create, "CXL");
+void cxl_dev_state_setup(struct cxl_memdev_state *mds, struct mds_info *info)
+{
+ if (!mds->cxlds.media_ready)
+ return;
+
+ mds->total_bytes = info->total_bytes;
+ mds->volatile_only_bytes = info->volatile_only_bytes;
+ mds->persistent_only_bytes = info->persistent_only_bytes;
+ mds->partition_align_bytes = 0;
+}
+EXPORT_SYMBOL_NS_GPL(cxl_dev_state_setup, "CXL");
+
static struct cxl_memdev *cxl_memdev_alloc(struct cxl_dev_state *cxlds,
const struct file_operations *fops)
{
diff --git a/include/cxl/cxl.h b/include/cxl/cxl.h
index 955e58103df6..1b2224ee1d5b 100644
--- a/include/cxl/cxl.h
+++ b/include/cxl/cxl.h
@@ -39,6 +39,16 @@ enum cxl_devtype {
CXL_DEVTYPE_CLASSMEM,
};
+/*
+ * struct for an accel driver giving partition data when Type2 device without a
+ * mailbox.
+ */
+struct mds_info {
+ u64 total_bytes;
+ u64 volatile_only_bytes;
+ u64 persistent_only_bytes;
+};
+
struct device;
struct cxl_memdev_state *cxl_memdev_state_create(struct device *dev, u64 serial,
u16 dvsec, enum cxl_devtype type);
@@ -48,4 +58,5 @@ int cxl_pci_accel_setup_regs(struct pci_dev *pdev, struct cxl_memdev_state *cxlm
unsigned long *caps);
int cxl_await_media_ready(struct cxl_memdev_state *mds);
void cxl_set_media_ready(struct cxl_memdev_state *mds);
+void cxl_dev_state_setup(struct cxl_memdev_state *mds, struct mds_info *info);
#endif
--
2.17.1
Powered by blists - more mailing lists