From: ira.weiny@intel.com
To: Dan Williams <dan.j.williams@intel.com>
Cc: Ira Weiny <ira.weiny@intel.com>,
Alison Schofield <alison.schofield@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Ben Widawsky <ben.widawsky@intel.com>,
linux-cxl@vger.kernel.org
Subject: [PATCH 3/3] cxl/mem: Add partition information to sysfs
Date: Thu, 10 Jun 2021 17:22:24 -0700 [thread overview]
Message-ID: <20210611002224.1594913-4-ira.weiny@intel.com> (raw)
In-Reply-To: <20210611002224.1594913-1-ira.weiny@intel.com>
From: Ira Weiny <ira.weiny@intel.com>
Partitionable space is added to the ram and pmem size sysfs attributes
but this does not show the entire story.
Add full partition information about the device under <sysfs>/partition.
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
drivers/cxl/pci.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
index bcc2829e4475..7e4e9605e4ed 100644
--- a/drivers/cxl/pci.c
+++ b/drivers/cxl/pci.c
@@ -1226,6 +1226,42 @@ static ssize_t pmem_size_show(struct device *dev, struct device_attribute *attr,
static struct device_attribute dev_attr_pmem_size =
__ATTR(size, 0444, pmem_size_show, NULL);
+static ssize_t part_vo_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, "%#llx\n", cxlm->volatile_cap_bytes);
+}
+
+static struct device_attribute dev_attr_part_vo =
+ __ATTR(volatile_only, 0444, part_vo_show, NULL);
+
+static ssize_t part_po_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, "%#llx\n", cxlm->persistent_cap_bytes);
+}
+
+static struct device_attribute dev_attr_part_po =
+ __ATTR(persistent_only, 0444, part_po_show, NULL);
+
+static ssize_t part_total_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, "%#llx\n", cxlm->total_cap_bytes);
+}
+
+static struct device_attribute dev_attr_part_total =
+ __ATTR(total, 0444, part_total_show, NULL);
+
static struct attribute *cxl_memdev_attributes[] = {
&dev_attr_firmware_version.attr,
&dev_attr_payload_max.attr,
@@ -1243,6 +1279,13 @@ static struct attribute *cxl_memdev_ram_attributes[] = {
NULL,
};
+static struct attribute *cxl_memdev_part_attributes[] = {
+ &dev_attr_part_vo.attr,
+ &dev_attr_part_po.attr,
+ &dev_attr_part_total.attr,
+ NULL,
+};
+
static struct attribute_group cxl_memdev_attribute_group = {
.attrs = cxl_memdev_attributes,
};
@@ -1257,10 +1300,16 @@ static struct attribute_group cxl_memdev_pmem_attribute_group = {
.attrs = cxl_memdev_pmem_attributes,
};
+static struct attribute_group cxl_memdev_part_attribute_group = {
+ .name = "partition",
+ .attrs = cxl_memdev_part_attributes,
+};
+
static const struct attribute_group *cxl_memdev_attribute_groups[] = {
&cxl_memdev_attribute_group,
&cxl_memdev_ram_attribute_group,
&cxl_memdev_pmem_attribute_group,
+ &cxl_memdev_part_attribute_group,
NULL,
};
--
2.28.0.rc0.12.gb6a658bd00c9
next prev parent reply other threads:[~2021-06-11 0:22 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-11 0:22 [PATCH 0/3] Query and use Partition Info ira.weiny
2021-06-11 0:22 ` [PATCH 1/3] cxl/pci: Store memory capacity values ira.weiny
2021-06-11 17:18 ` Ben Widawsky
2021-06-11 17:26 ` Dan Williams
2021-06-11 17:50 ` Ben Widawsky
2021-06-11 19:58 ` Ira Weiny
2021-06-11 0:22 ` [PATCH 2/3] cxl/mem: Report correct ram/pmem size in sysfs ira.weiny
2021-06-11 11:00 ` Jonathan Cameron
2021-06-11 15:59 ` Ira Weiny
2021-06-11 17:14 ` Dan Williams
2021-06-11 19:59 ` Ira Weiny
2021-06-11 0:22 ` ira.weiny [this message]
2021-06-11 11:05 ` [PATCH 3/3] cxl/mem: Add partition information to sysfs Jonathan Cameron
2021-06-11 17:26 ` Ben Widawsky
2021-06-11 20:09 ` Ira Weiny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210611002224.1594913-4-ira.weiny@intel.com \
--to=ira.weiny@intel.com \
--cc=alison.schofield@intel.com \
--cc=ben.widawsky@intel.com \
--cc=dan.j.williams@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=vishal.l.verma@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox