Linux CXL
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: <ira.weiny@intel.com>
Cc: Dan Williams <dan.j.williams@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: Re: [PATCH 3/3] cxl/mem: Add partition information to sysfs
Date: Fri, 11 Jun 2021 12:05:29 +0100	[thread overview]
Message-ID: <20210611120529.000001fe@Huawei.com> (raw)
In-Reply-To: <20210611002224.1594913-4-ira.weiny@intel.com>

On Thu, 10 Jun 2021 17:22:24 -0700
<ira.weiny@intel.com> wrote:

> 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);

With a bit of tweaking could we use DEVICE_ATTR_RO for these and have even less
boilerplate? 


> +
> +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,
>  };
>  


  reply	other threads:[~2021-06-11 11:05 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 ` [PATCH 3/3] cxl/mem: Add partition information to sysfs ira.weiny
2021-06-11 11:05   ` Jonathan Cameron [this message]
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=20210611120529.000001fe@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=alison.schofield@intel.com \
    --cc=ben.widawsky@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=ira.weiny@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