* [PATCH 1/2] dmaengine: idxd: Simplify WQ attribute visibility checks
@ 2023-07-12 17:44 Fenghua Yu
2023-07-12 17:44 ` [PATCH 2/2] dmaengine: idxd: Expose ATS disable knob only when WQ ATS is supported Fenghua Yu
2023-08-01 18:45 ` [PATCH 1/2] dmaengine: idxd: Simplify WQ attribute visibility checks Vinod Koul
0 siblings, 2 replies; 3+ messages in thread
From: Fenghua Yu @ 2023-07-12 17:44 UTC (permalink / raw)
To: Vinod Koul, Dave Jiang; +Cc: dmaengine, linux-kernel, Fenghua Yu
The functions that check if WQ attributes are invisible are almost
duplicate. Define a helper to simplify these functions and future
WQ attribute visibility checks as well.
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
---
drivers/dma/idxd/sysfs.c | 20 +++++---------------
1 file changed, 5 insertions(+), 15 deletions(-)
diff --git a/drivers/dma/idxd/sysfs.c b/drivers/dma/idxd/sysfs.c
index 293739ac5596..388fba7c85f8 100644
--- a/drivers/dma/idxd/sysfs.c
+++ b/drivers/dma/idxd/sysfs.c
@@ -1288,12 +1288,9 @@ static struct attribute *idxd_wq_attributes[] = {
NULL,
};
-static bool idxd_wq_attr_op_config_invisible(struct attribute *attr,
- struct idxd_device *idxd)
-{
- return attr == &dev_attr_wq_op_config.attr &&
- !idxd->hw.wq_cap.op_config;
-}
+/* A WQ attr is invisible if the feature is not supported in WQCAP. */
+#define idxd_wq_attr_invisible(name, cap_field, a, idxd) \
+ ((a) == &dev_attr_wq_##name.attr && !(idxd)->hw.wq_cap.cap_field)
static bool idxd_wq_attr_max_batch_size_invisible(struct attribute *attr,
struct idxd_device *idxd)
@@ -1303,13 +1300,6 @@ static bool idxd_wq_attr_max_batch_size_invisible(struct attribute *attr,
idxd->data->type == IDXD_TYPE_IAX;
}
-static bool idxd_wq_attr_wq_prs_disable_invisible(struct attribute *attr,
- struct idxd_device *idxd)
-{
- return attr == &dev_attr_wq_prs_disable.attr &&
- !idxd->hw.wq_cap.wq_prs_support;
-}
-
static umode_t idxd_wq_attr_visible(struct kobject *kobj,
struct attribute *attr, int n)
{
@@ -1317,13 +1307,13 @@ static umode_t idxd_wq_attr_visible(struct kobject *kobj,
struct idxd_wq *wq = confdev_to_wq(dev);
struct idxd_device *idxd = wq->idxd;
- if (idxd_wq_attr_op_config_invisible(attr, idxd))
+ if (idxd_wq_attr_invisible(op_config, op_config, attr, idxd))
return 0;
if (idxd_wq_attr_max_batch_size_invisible(attr, idxd))
return 0;
- if (idxd_wq_attr_wq_prs_disable_invisible(attr, idxd))
+ if (idxd_wq_attr_invisible(prs_disable, wq_prs_support, attr, idxd))
return 0;
return attr->mode;
--
2.37.1
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH 2/2] dmaengine: idxd: Expose ATS disable knob only when WQ ATS is supported
2023-07-12 17:44 [PATCH 1/2] dmaengine: idxd: Simplify WQ attribute visibility checks Fenghua Yu
@ 2023-07-12 17:44 ` Fenghua Yu
2023-08-01 18:45 ` [PATCH 1/2] dmaengine: idxd: Simplify WQ attribute visibility checks Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Fenghua Yu @ 2023-07-12 17:44 UTC (permalink / raw)
To: Vinod Koul, Dave Jiang; +Cc: dmaengine, linux-kernel, Fenghua Yu
WQ Advanced Translation Service (ATS) can be controlled only when
WQ ATS is supported. The sysfs ATS disable knob should be visible only
when the features is supported.
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
---
drivers/dma/idxd/sysfs.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/dma/idxd/sysfs.c b/drivers/dma/idxd/sysfs.c
index 388fba7c85f8..7c317367226d 100644
--- a/drivers/dma/idxd/sysfs.c
+++ b/drivers/dma/idxd/sysfs.c
@@ -1088,16 +1088,12 @@ static ssize_t wq_ats_disable_store(struct device *dev, struct device_attribute
const char *buf, size_t count)
{
struct idxd_wq *wq = confdev_to_wq(dev);
- struct idxd_device *idxd = wq->idxd;
bool ats_dis;
int rc;
if (wq->state != IDXD_WQ_DISABLED)
return -EPERM;
- if (!idxd->hw.wq_cap.wq_ats_support)
- return -EOPNOTSUPP;
-
rc = kstrtobool(buf, &ats_dis);
if (rc < 0)
return rc;
@@ -1316,6 +1312,9 @@ static umode_t idxd_wq_attr_visible(struct kobject *kobj,
if (idxd_wq_attr_invisible(prs_disable, wq_prs_support, attr, idxd))
return 0;
+ if (idxd_wq_attr_invisible(ats_disable, wq_ats_support, attr, idxd))
+ return 0;
+
return attr->mode;
}
--
2.37.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH 1/2] dmaengine: idxd: Simplify WQ attribute visibility checks
2023-07-12 17:44 [PATCH 1/2] dmaengine: idxd: Simplify WQ attribute visibility checks Fenghua Yu
2023-07-12 17:44 ` [PATCH 2/2] dmaengine: idxd: Expose ATS disable knob only when WQ ATS is supported Fenghua Yu
@ 2023-08-01 18:45 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2023-08-01 18:45 UTC (permalink / raw)
To: Dave Jiang, Fenghua Yu; +Cc: dmaengine, linux-kernel
On Wed, 12 Jul 2023 10:44:35 -0700, Fenghua Yu wrote:
> The functions that check if WQ attributes are invisible are almost
> duplicate. Define a helper to simplify these functions and future
> WQ attribute visibility checks as well.
>
>
Applied, thanks!
[1/2] dmaengine: idxd: Simplify WQ attribute visibility checks
commit: 97b1185fe54c8ce94104e3c7fa4ee0bbedd85920
[2/2] dmaengine: idxd: Expose ATS disable knob only when WQ ATS is supported
commit: 62b41b656666d2d35890124df5ef0881fe6d6769
Best regards,
--
~Vinod
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-01 18:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-12 17:44 [PATCH 1/2] dmaengine: idxd: Simplify WQ attribute visibility checks Fenghua Yu
2023-07-12 17:44 ` [PATCH 2/2] dmaengine: idxd: Expose ATS disable knob only when WQ ATS is supported Fenghua Yu
2023-08-01 18:45 ` [PATCH 1/2] dmaengine: idxd: Simplify WQ attribute visibility checks Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®