linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Alan Adamson <alan.adamson@oracle.com>
To: linux-nvme@lists.infradead.org
Cc: alan.adamson@oracle.com, kbusch@kernel.org, axboe@fb.com,
	hch@lst.de, sagi@grimberg.me
Subject: [PATCH 1/1] nvme: Export CSTS register via sysfs
Date: Wed, 17 Mar 2021 16:46:15 -0400	[thread overview]
Message-ID: <20210317204615.13971-2-alan.adamson@oracle.com> (raw)
In-Reply-To: <20210317204615.13971-1-alan.adamson@oracle.com>

This exposes a sysfs method a user can invoke to request read-only
access to a NVMe Controller's CSTS (Controller Status) Register.

Signed-off-by: Alan Adamson <alan.adamson@oracle.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
---
 drivers/nvme/host/core.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index e68a8c4ac5a6..7736b8b0891c 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3683,9 +3683,24 @@ static ssize_t nvme_ctrl_reconnect_delay_store(struct device *dev,
 	ctrl->opts->reconnect_delay = v;
 	return count;
 }
+
+static ssize_t nvme_ctrl_csts_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
+	u32 csts;
+
+	ctrl->ops->reg_read32(ctrl, NVME_REG_CSTS, &csts);
+
+	return sprintf(buf, "%d\n", csts);
+}
+
 static DEVICE_ATTR(reconnect_delay, S_IRUGO | S_IWUSR,
 	nvme_ctrl_reconnect_delay_show, nvme_ctrl_reconnect_delay_store);
 
+static DEVICE_ATTR(csts, S_IRUGO | S_IWUSR,
+	nvme_ctrl_csts_show, NULL);
+
 static struct attribute *nvme_dev_attrs[] = {
 	&dev_attr_reset_controller.attr,
 	&dev_attr_rescan_controller.attr,
@@ -3705,6 +3720,7 @@ static struct attribute *nvme_dev_attrs[] = {
 	&dev_attr_hostid.attr,
 	&dev_attr_ctrl_loss_tmo.attr,
 	&dev_attr_reconnect_delay.attr,
+	&dev_attr_csts.attr,
 	NULL
 };
 
-- 
2.18.4


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

  reply	other threads:[~2021-03-17 20:51 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-17 20:46 [PATCH 0/1] nvme: Export CSTS register via sysfs Alan Adamson
2021-03-17 20:46 ` Alan Adamson [this message]
2021-03-18  1:06 ` Chaitanya Kulkarni
2021-03-18  4:38 ` Christoph Hellwig
2021-03-18 14:19   ` Keith Busch
2021-03-18 16:28   ` Alan Adamson
2021-03-18 16:52     ` Keith Busch
2021-03-18 18:39       ` Alan Adamson
2021-03-18 19:46         ` Keith Busch
2021-03-19  6:51           ` Christoph Hellwig
2021-03-19 15:22             ` Keith Busch
2021-03-19 15:30               ` Christoph Hellwig
2021-03-19 17:21                 ` Alan Adamson
2021-03-19 17:30                   ` Keith Busch
2021-03-19 17:33                     ` Alan Adamson
2021-05-05 18:40                     ` Alan Adamson
2021-05-05 20:11                       ` Keith Busch
2021-05-05 20:23                         ` Alan Adamson
2021-05-05 20:35                           ` Keith Busch
2021-03-18 19:15       ` Chaitanya Kulkarni

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=20210317204615.13971-2-alan.adamson@oracle.com \
    --to=alan.adamson@oracle.com \
    --cc=axboe@fb.com \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /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).