diff mbox series

[v2] dmaengine: idxd: export hw version through sysfs

Message ID 158696714008.39484.13401950732606906479.stgit@djiang5-desk3.ch.intel.com (mailing list archive)
State Accepted
Headers show
Series [v2] dmaengine: idxd: export hw version through sysfs | expand

Commit Message

Dave Jiang April 15, 2020, 4:13 p.m. UTC
Some user apps would like to know the hardware version in order to
determine the variation of the hardware. Export the hardware version number
to userspace via sysfs.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---

v2: Add sysfs ABI documentation (Vinod)

 Documentation/ABI/stable/sysfs-driver-dma-idxd |    6 ++++++
 drivers/dma/idxd/sysfs.c                       |   11 +++++++++++
 2 files changed, 17 insertions(+)

Comments

Vinod Koul April 15, 2020, 4:24 p.m. UTC | #1
On 15-04-20, 09:13, Dave Jiang wrote:
> Some user apps would like to know the hardware version in order to
> determine the variation of the hardware. Export the hardware version number
> to userspace via sysfs.

Applied, thanks
diff mbox series

Patch

diff --git a/Documentation/ABI/stable/sysfs-driver-dma-idxd b/Documentation/ABI/stable/sysfs-driver-dma-idxd
index 7c89bfa00477..a6e77a5fbb97 100644
--- a/Documentation/ABI/stable/sysfs-driver-dma-idxd
+++ b/Documentation/ABI/stable/sysfs-driver-dma-idxd
@@ -1,3 +1,9 @@ 
+What:		sys/bus/dsa/devices/dsa<m>/version
+Date:		Apr 15, 2020
+KernelVersion:	5.8.0
+Contact:	dmaengine@vger.kernel.org
+Description:	The hardware version number.
+
 What:           sys/bus/dsa/devices/dsa<m>/cdev_major
 Date:           Oct 25, 2019
 KernelVersion: 	5.6.0
diff --git a/drivers/dma/idxd/sysfs.c b/drivers/dma/idxd/sysfs.c
index 5fb6b5cafb55..bd05a04d3aa3 100644
--- a/drivers/dma/idxd/sysfs.c
+++ b/drivers/dma/idxd/sysfs.c
@@ -1377,6 +1377,16 @@  static const struct attribute_group *idxd_wq_attribute_groups[] = {
 };
 
 /* IDXD device attribs */
+static ssize_t version_show(struct device *dev, struct device_attribute *attr,
+			    char *buf)
+{
+	struct idxd_device *idxd =
+		container_of(dev, struct idxd_device, conf_dev);
+
+	return sprintf(buf, "%#x\n", idxd->hw.version);
+}
+static DEVICE_ATTR_RO(version);
+
 static ssize_t max_work_queues_size_show(struct device *dev,
 					 struct device_attribute *attr,
 					 char *buf)
@@ -1618,6 +1628,7 @@  static ssize_t cdev_major_show(struct device *dev,
 static DEVICE_ATTR_RO(cdev_major);
 
 static struct attribute *idxd_device_attributes[] = {
+	&dev_attr_version.attr,
 	&dev_attr_max_groups.attr,
 	&dev_attr_max_work_queues.attr,
 	&dev_attr_max_work_queues_size.attr,