Blob Blame History Raw
From ea6a5735d2a61b938a302eb3629272342a9e7c46 Mon Sep 17 00:00:00 2001
From: Dave Jiang <dave.jiang@intel.com>
Date: Mon, 22 Mar 2021 16:37:29 -0700
Subject: [PATCH] dmaengine: idxd: fix opcap sysfs attribute output
Git-commit: ea6a5735d2a61b938a302eb3629272342a9e7c46
Patch-mainline: v5.12
References: git-fixes

[ backport note: use scnprintf() instead of sysfs_emit*() that doesn't
  exist on SLE15-SP3 kernel (yet) -- tiwai ]

The operation capability register is 256bits. The current output only
prints out the first 64bits. Fix to output the entire 256bits. The current
code omits operation caps from IAX devices.

Fixes: c52ca478233c ("dmaengine: idxd: add configuration component of driver")
Reported-by: Lucas Van <lucas.van@intel.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/161645624963.2003736.829798666998490151.stgit@djiang5-desk3.ch.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Acked-by: Takashi Iwai <tiwai@suse.de>

---
 drivers/dma/idxd/sysfs.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

--- a/drivers/dma/idxd/sysfs.c
+++ b/drivers/dma/idxd/sysfs.c
@@ -1449,8 +1449,14 @@ static ssize_t op_cap_show(struct device
 {
 	struct idxd_device *idxd =
 		container_of(dev, struct idxd_device, conf_dev);
+	int i, rc = 0;
 
-	return sprintf(buf, "%#llx\n", idxd->hw.opcap.bits[0]);
+	for (i = 0; i < 4; i++)
+		rc += scnprintf(buf + rc, PAGE_SIZE - rc, "%#llx ", idxd->hw.opcap.bits[i]);
+
+	rc--;
+	rc += scnprintf(buf + rc, PAGE_SIZE - rc, "\n");
+	return rc;
 }
 static DEVICE_ATTR_RO(op_cap);