summaryrefslogtreecommitdiffstats
path: root/drivers/cxl
diff options
context:
space:
mode:
authorVishal Verma <vishal.l.verma@intel.com>2021-05-20 13:47:45 -0600
committerDan Williams <dan.j.williams@intel.com>2021-05-26 11:20:17 -0700
commit199cf8c3feec2947015da84643312790b21531cb (patch)
tree423f8a0f2517fc3a4a78b1463a88986b4ed0d383 /drivers/cxl
parent21e9f76733a8c152b794cba5463ff9bf2db919d4 (diff)
downloadlinux-199cf8c3feec2947015da84643312790b21531cb.tar.bz2
cxl/pci.c: Add a 'label_storage_size' attribute to the memdev
The 'Identify Device' mailbox command returns an 'lsa_size', which is the size of the label storage area on the device. Export it as a sysfs attribute so that userspace tooling to read/write the LSA can determine the size without having to run an 'Identify Device' on their own. Cc: Ben Widawsky <ben.widawsky@intel.com> Cc: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com> Reviewed-by: Dan Williams <dan.j.williams@intel.com> Link: https://lore.kernel.org/r/20210520194745.1095517-1-vishal.l.verma@intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/cxl')
-rw-r--r--drivers/cxl/mem.h3
-rw-r--r--drivers/cxl/pci.c12
2 files changed, 15 insertions, 0 deletions
diff --git a/drivers/cxl/mem.h b/drivers/cxl/mem.h
index 0a3f70316872..23fc40dde27e 100644
--- a/drivers/cxl/mem.h
+++ b/drivers/cxl/mem.h
@@ -54,6 +54,8 @@ struct cxl_memdev {
* @regs: Parsed register blocks
* @payload_size: Size of space for payload
* (CXL 2.0 8.2.8.4.3 Mailbox Capabilities Register)
+ * @lsa_size: Size of Label Storage Area
+ * (CXL 2.0 8.2.9.5.1.1 Identify Memory Device)
* @mbox_mutex: Mutex to synchronize mailbox access.
* @firmware_version: Firmware version for the memory device.
* @enabled_cmds: Hardware commands found enabled in CEL.
@@ -68,6 +70,7 @@ struct cxl_mem {
struct cxl_regs regs;
size_t payload_size;
+ size_t lsa_size;
struct mutex mbox_mutex; /* Protects device mailbox and firmware */
char firmware_version[0x10];
unsigned long *enabled_cmds;
diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
index c7996c2a2054..606c88ca902b 100644
--- a/drivers/cxl/pci.c
+++ b/drivers/cxl/pci.c
@@ -1036,6 +1036,16 @@ static ssize_t payload_max_show(struct device *dev,
}
static DEVICE_ATTR_RO(payload_max);
+static ssize_t label_storage_size_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
+ struct cxl_mem *cxlm = cxlmd->cxlm;
+
+ return sysfs_emit(buf, "%zu\n", cxlm->lsa_size);
+}
+static DEVICE_ATTR_RO(label_storage_size);
+
static ssize_t ram_size_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
@@ -1065,6 +1075,7 @@ static struct device_attribute dev_attr_pmem_size =
static struct attribute *cxl_memdev_attributes[] = {
&dev_attr_firmware_version.attr,
&dev_attr_payload_max.attr,
+ &dev_attr_label_storage_size.attr,
NULL,
};
@@ -1397,6 +1408,7 @@ static int cxl_mem_identify(struct cxl_mem *cxlm)
cxlm->pmem_range.end =
le64_to_cpu(id.persistent_capacity) * SZ_256M - 1;
+ cxlm->lsa_size = le32_to_cpu(id.lsa_size);
memcpy(cxlm->firmware_version, id.fw_revision, sizeof(id.fw_revision));
return 0;