DMA Engine development
 help / color / mirror / Atom feed
From: Xiaochen Shen <xiaochen.shen@intel.com>
To: vkoul@kernel.org, fenghua.yu@intel.com, dave.jiang@intel.com,
	dmaengine@vger.kernel.org
Cc: ramesh.thomas@intel.com, tony.luck@intel.com, tony.zhu@intel.com,
	pei.p.jia@intel.com, xiaochen.shen@intel.com
Subject: [PATCH 2/2] dmaengine: idxd: Make max batch size attributes in sysfs invisible for Intel IAA
Date: Mon,  8 Aug 2022 11:19:22 +0800	[thread overview]
Message-ID: <20220808031922.29751-3-xiaochen.shen@intel.com> (raw)
In-Reply-To: <20220808031922.29751-1-xiaochen.shen@intel.com>

In current code, dev.max_batch_size and wq.max_batch_size attributes in
sysfs are exposed to user to show or update the values.

From Intel IAA spec [1], Intel IAA does not support batch processing. So
these sysfs attributes should not be supported on IAA device.

Fix this issue by making the attributes of max_batch_size invisible in
sysfs through is_visible() filter when the device is IAA.

Add description in the ABI documentation to mention that the attributes
are not visible when the device does not support batch.

[1]: https://cdrdv2.intel.com/v1/dl/getContent/721858

Fixes: e7184b159dd3 ("dmaengine: idxd: add support for configurable max wq batch size")
Fixes: c52ca478233c ("dmaengine: idxd: add configuration component of driver")
Signed-off-by: Xiaochen Shen <xiaochen.shen@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Fenghua Yu <fenghua.yu@intel.com>
---
 .../ABI/stable/sysfs-driver-dma-idxd          |  2 ++
 drivers/dma/idxd/sysfs.c                      | 30 +++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/Documentation/ABI/stable/sysfs-driver-dma-idxd b/Documentation/ABI/stable/sysfs-driver-dma-idxd
index 0c2b613f2373..da3f6d01e0bd 100644
--- a/Documentation/ABI/stable/sysfs-driver-dma-idxd
+++ b/Documentation/ABI/stable/sysfs-driver-dma-idxd
@@ -22,6 +22,7 @@ Date:           Oct 25, 2019
 KernelVersion:  5.6.0
 Contact:        dmaengine@vger.kernel.org
 Description:    The largest number of work descriptors in a batch.
+		It's not visible when the device does not support batch.
 
 What:           /sys/bus/dsa/devices/dsa<m>/max_work_queues_size
 Date:           Oct 25, 2019
@@ -205,6 +206,7 @@ KernelVersion:	5.10.0
 Contact:	dmaengine@vger.kernel.org
 Description:	The max batch size for this workqueue. Cannot exceed device
 		max batch size. Configurable parameter.
+		It's not visible when the device does not support batch.
 
 What:		/sys/bus/dsa/devices/wq<m>.<n>/ats_disable
 Date:		Nov 13, 2020
diff --git a/drivers/dma/idxd/sysfs.c b/drivers/dma/idxd/sysfs.c
index fa729fac4b97..b13a8cc4d24f 100644
--- a/drivers/dma/idxd/sysfs.c
+++ b/drivers/dma/idxd/sysfs.c
@@ -1055,6 +1055,20 @@ static ssize_t wq_enqcmds_retries_store(struct device *dev, struct device_attrib
 static struct device_attribute dev_attr_wq_enqcmds_retries =
 		__ATTR(enqcmds_retries, 0644, wq_enqcmds_retries_show, wq_enqcmds_retries_store);
 
+static umode_t idxd_wq_visible(struct kobject *kobj,
+			       struct attribute *attr, int n)
+{
+	struct device *dev = container_of(kobj, struct device, kobj);
+	struct idxd_wq *wq = confdev_to_wq(dev);
+
+	/* Intel IAA does not support batch processing, make it invisible */
+	if (attr == &dev_attr_wq_max_batch_size.attr &&
+			wq->idxd->data->type == IDXD_TYPE_IAX)
+		return 0;
+
+	return attr->mode;
+}
+
 static struct attribute *idxd_wq_attributes[] = {
 	&dev_attr_wq_clients.attr,
 	&dev_attr_wq_state.attr,
@@ -1077,6 +1091,7 @@ static struct attribute *idxd_wq_attributes[] = {
 
 static const struct attribute_group idxd_wq_attribute_group = {
 	.attrs = idxd_wq_attributes,
+	.is_visible = idxd_wq_visible,
 };
 
 static const struct attribute_group *idxd_wq_attribute_groups[] = {
@@ -1366,6 +1381,20 @@ static ssize_t cmd_status_store(struct device *dev, struct device_attribute *att
 }
 static DEVICE_ATTR_RW(cmd_status);
 
+static umode_t idxd_device_visible(struct kobject *kobj,
+				   struct attribute *attr, int n)
+{
+	struct device *dev = container_of(kobj, struct device, kobj);
+	struct idxd_device *idxd = confdev_to_idxd(dev);
+
+	/* Intel IAA does not support batch processing, make it invisible */
+	if (attr == &dev_attr_max_batch_size.attr &&
+			idxd->data->type == IDXD_TYPE_IAX)
+		return 0;
+
+	return attr->mode;
+}
+
 static struct attribute *idxd_device_attributes[] = {
 	&dev_attr_version.attr,
 	&dev_attr_max_groups.attr,
@@ -1393,6 +1422,7 @@ static struct attribute *idxd_device_attributes[] = {
 
 static const struct attribute_group idxd_device_attribute_group = {
 	.attrs = idxd_device_attributes,
+	.is_visible = idxd_device_visible,
 };
 
 static const struct attribute_group *idxd_attribute_groups[] = {
-- 
2.18.4


  parent reply	other threads:[~2022-08-08  2:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-08  3:19 [PATCH 0/2] dmaengine: idxd: Fix max batch size issues for Intel IAA Xiaochen Shen
2022-08-08  3:19 ` [PATCH 1/2] dmaengine: idxd: Fix max batch size " Xiaochen Shen
2022-08-08  3:19 ` Xiaochen Shen [this message]
2022-09-15 16:21 ` [PATCH 0/2] dmaengine: idxd: Fix max batch size issues " Yu, Fenghua
2022-09-29 16:46   ` Vinod Koul
2022-09-29 17:20     ` Yu, Fenghua
2022-09-30  3:18     ` Xiaochen Shen
2022-09-30 16:18       ` Vinod Koul
2022-10-01  1:31         ` Xiaochen Shen

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=20220808031922.29751-3-xiaochen.shen@intel.com \
    --to=xiaochen.shen@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=fenghua.yu@intel.com \
    --cc=pei.p.jia@intel.com \
    --cc=ramesh.thomas@intel.com \
    --cc=tony.luck@intel.com \
    --cc=tony.zhu@intel.com \
    --cc=vkoul@kernel.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