linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: linux-nvdimm@ml01.01.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 2/8] dax: add region 'id', 'size', and 'align' attributes
Date: Sat, 10 Dec 2016 22:28:35 -0800	[thread overview]
Message-ID: <148143771566.10950.14259879317434171984.stgit@dwillia2-desk3.amr.corp.intel.com> (raw)
In-Reply-To: <148143770485.10950.13227732273892953675.stgit@dwillia2-desk3.amr.corp.intel.com>

While this information is available by looking at the nvdimm parent
device that may not always be the case when/if we add support for other
memory regions. Tooling should not depend on walking a given ancestor
topology that is not guaranteed by the device's class. For example, a
device-dax instance will always have a dax_region parent, but it may not
always have a libnvdimm "dax" device as a grandparent.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 drivers/dax/dax.c |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/drivers/dax/dax.c b/drivers/dax/dax.c
index cc7c4aa4bcc2..da2962b6f8de 100644
--- a/drivers/dax/dax.c
+++ b/drivers/dax/dax.c
@@ -111,8 +111,61 @@ static ssize_t available_size_show(struct device *dev,
 }
 static DEVICE_ATTR_RO(available_size);
 
+static ssize_t id_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct dax_region *dax_region;
+	ssize_t rc = -ENXIO;
+
+	device_lock(dev);
+	dax_region = dev_get_drvdata(dev);
+	if (dax_region)
+		rc = sprintf(buf, "%d\n", dax_region->id);
+	device_unlock(dev);
+
+	return rc;
+}
+static DEVICE_ATTR_RO(id);
+
+static ssize_t region_size_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct dax_region *dax_region;
+	ssize_t rc = -ENXIO;
+
+	device_lock(dev);
+	dax_region = dev_get_drvdata(dev);
+	if (dax_region)
+		rc = sprintf(buf, "%llu\n", (unsigned long long)
+				resource_size(&dax_region->res));
+	device_unlock(dev);
+
+	return rc;
+}
+static struct device_attribute dev_attr_region_size = __ATTR(size, 0444,
+		region_size_show, NULL);
+
+static ssize_t align_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct dax_region *dax_region;
+	ssize_t rc = -ENXIO;
+
+	device_lock(dev);
+	dax_region = dev_get_drvdata(dev);
+	if (dax_region)
+		rc = sprintf(buf, "%u\n", dax_region->align);
+	device_unlock(dev);
+
+	return rc;
+}
+static DEVICE_ATTR_RO(align);
+
 static struct attribute *dax_region_attributes[] = {
 	&dev_attr_available_size.attr,
+	&dev_attr_region_size.attr,
+	&dev_attr_align.attr,
+	&dev_attr_id.attr,
 	NULL,
 };
 

  parent reply	other threads:[~2016-12-11  6:32 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-11  6:28 [PATCH 0/8] device-dax: sub-division support Dan Williams
2016-12-11  6:28 ` [PATCH 1/8] dax: add region-available-size attribute Dan Williams
2016-12-14 14:38   ` Johannes Thumshirn
2016-12-14 15:53     ` Dan Williams
2016-12-15  6:47       ` Dan Williams
2016-12-11  6:28 ` Dan Williams [this message]
2016-12-11  6:28 ` [PATCH 3/8] dax: register seed device Dan Williams
2016-12-11  6:28 ` [PATCH 4/8] dax: use multi-order radix for resource lookup Dan Williams
2016-12-11  6:28 ` [PATCH 5/8] dax: refactor locking out of size calculation routines Dan Williams
2016-12-14 15:01   ` Johannes Thumshirn
2016-12-14 15:55     ` Dan Williams
2016-12-11  6:28 ` [PATCH 6/8] dax: sub-division support Dan Williams
2016-12-11  6:29 ` [PATCH 7/8] dax: add / remove dax devices after provisioning Dan Williams
2016-12-11  6:29 ` [PATCH 8/8] dax: add debug for region available_size Dan Williams
2016-12-12 17:15 ` [PATCH 0/8] device-dax: sub-division support Jeff Moyer
2016-12-12 18:46   ` Dan Williams
2016-12-13 23:46     ` Jeff Moyer
2016-12-14  1:17       ` Dan Williams
2016-12-15 16:50         ` Jeff Moyer
2016-12-15 23:48           ` Dan Williams
2016-12-16  2:33             ` Dan Williams

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=148143771566.10950.14259879317434171984.stgit@dwillia2-desk3.amr.corp.intel.com \
    --to=dan.j.williams@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvdimm@ml01.01.org \
    /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;
as well as URLs for NNTP newsgroup(s).