dmaengine: idxd: Fix max batch size issues for Intel IAA
Subsystems (2)
v2 cover dmaengine: idxd: Fix max batch size issues for Intel IAA
Fix max batch size related issues for Intel IAA:
1. Fix max batch size default values.
2. Make max batch size attributes in sysfs invisible.
Changelog:
v2:
- Rebase on -next branch (Vinod).
- Use wrapper function idxd_{device|wq}_attr_max_batch_size_invisible() to make the code more readable.
Xiaochen Shen (2):
dmaengine: idxd: Fix max batch size for Intel IAA
dmaengine: idxd: Make max batch size attributes in sysfs invisible for
Intel IAA
.../ABI/stable/sysfs-driver-dma-idxd | 2 ++ drivers/dma/idxd/device.c | 6 ++-- drivers/dma/idxd/idxd.h | 32 +++++++++++++++++ drivers/dma/idxd/init.c | 4 +-- drivers/dma/idxd/sysfs.c | 34 ++++++++++++++++++- 5 files changed, 72 insertions(+), 6 deletions(-)
Signature · 1 line
2.18.4
PATCH v2 1/2 dmaengine: idxd: Fix max batch size for Intel IAA
From Intel IAA spec [1], Intel IAA does not support batch processing.
Two batch related default values for IAA are incorrect in current code:
(1) The max batch size of device is set during device initialization, that indicates batch is supported. It should be always 0 on IAA.
(2) The max batch size of work queue is set to WQ_DEFAULT_MAX_BATCH (32) as the default value regardless of Intel DSA or IAA device during work queue setup and cleanup. It should be always 0 on IAA.
Fix the issues by setting the max batch size of device and max batch size of work queue to 0 on IAA device, that means batch is not supported.
[1]: https://cdrdv2.intel.com/v1/dl/getContent/721858
--- drivers/dma/idxd/device.c | 6 +++--- drivers/dma/idxd/idxd.h | 32 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/init.c | 4 ++-- drivers/dma/idxd/sysfs.c | 2 +- 4 files changed, 38 insertions(+), 6 deletions(-)
drivers/dma/idxd/device.c +3 -3
@@ -390,7 +390,7 @@ static void idxd_wq_disable_cleanup(struct idxd_wq *wq)clear_bit (WQ_FLAG_ATS_DISABLE , &wq->flags);memset (wq->name,0 ,WQ_NAME_SIZE ); wq->max_xfer_bytes =WQ_DEFAULT_MAX_XFER ; - wq->max_batch_size =WQ_DEFAULT_MAX_BATCH ; +idxd_wq_set_max_batch_size (idxd->data->type, wq,WQ_DEFAULT_MAX_BATCH );if (wq->opcap_bmap)bitmap_copy (wq->opcap_bmap, idxd->opcap_bmap,IDXD_MAX_OPCAP_BITS ); }
@@ -869,7 +869,7 @@ static int idxd_wq_config_write(struct idxd_wq *wq)/* bytes 12-15 */ wq->wqcfg->max_xfer_shift =ilog2 (wq->max_xfer_bytes); - wq->wqcfg->max_batch_shift =ilog2 (wq->max_batch_size); +idxd_wqcfg_set_max_batch_shift (idxd->data->type, wq->wqcfg,ilog2 (wq->max_batch_size));/* bytes 32-63 */ if (idxd->hw.wq_cap.op_config && wq->opcap_bmap) {
@@ -1051,7 +1051,7 @@ static int idxd_wq_load_config(struct idxd_wq *wq) wq->priority = wq->wqcfg->priority; wq->max_xfer_bytes =1ULL << wq->wqcfg->max_xfer_shift; - wq->max_batch_size =1ULL << wq->wqcfg->max_batch_shift; +idxd_wq_set_max_batch_size (idxd->data->type, wq,1U << wq->wqcfg->max_batch_shift);for (i =0 ; i <WQCFG_STRIDES (idxd); i++) { wqcfg_offset =WQCFG_OFFSET (idxd, wq->id, i);
drivers/dma/idxd/idxd.h +32 -0
@@ -548,6 +548,38 @@ static inline int idxd_wq_refcount(struct idxd_wq *wq)return wq->client_count; }; +/* +* Intel IAA does not support batch processing. +* The max batch size of device, max batch size of wq and +* max batch shift of wqcfg should be always 0 on IAA. +*/ +static inline void idxd_set_max_batch_size (int idxd_type,struct idxd_device *idxd, +u32 max_batch_size) +{ +if (idxd_type ==IDXD_TYPE_IAX ) + idxd->max_batch_size =0 ; +else + idxd->max_batch_size = max_batch_size; +} + +static inline void idxd_wq_set_max_batch_size (int idxd_type,struct idxd_wq *wq, +u32 max_batch_size) +{ +if (idxd_type ==IDXD_TYPE_IAX ) + wq->max_batch_size =0 ; +else + wq->max_batch_size = max_batch_size; +} + +static inline void idxd_wqcfg_set_max_batch_shift (int idxd_type,union wqcfg *wqcfg, +u32 max_batch_shift) +{ +if (idxd_type ==IDXD_TYPE_IAX ) + wqcfg->max_batch_shift =0 ; +else + wqcfg->max_batch_shift = max_batch_shift; +} +int __must_check __idxd_driver_register (struct idxd_device_driver *idxd_drv,struct module *module,const char *mod_name);#define idxd_driver_register (driver) \
drivers/dma/idxd/init.c +2 -2
@@ -183,7 +183,7 @@ static int idxd_setup_wqs(struct idxd_device *idxd)init_completion (&wq->wq_dead);init_completion (&wq->wq_resurrect); wq->max_xfer_bytes =WQ_DEFAULT_MAX_XFER ; - wq->max_batch_size =WQ_DEFAULT_MAX_BATCH ; +idxd_wq_set_max_batch_size (idxd->data->type, wq,WQ_DEFAULT_MAX_BATCH ); wq->enqcmds_retries =IDXD_ENQCMDS_RETRIES ; wq->wqcfg =kzalloc_node (idxd->wqcfg_size,GFP_KERNEL ,dev_to_node (dev));if (!wq->wqcfg) {
@@ -418,7 +418,7 @@ static void idxd_read_caps(struct idxd_device *idxd) idxd->max_xfer_bytes =1ULL << idxd->hw.gen_cap.max_xfer_shift;dev_dbg (dev,"max xfer size: %llu bytes\n" , idxd->max_xfer_bytes); - idxd->max_batch_size =1U << idxd->hw.gen_cap.max_batch_shift; +idxd_set_max_batch_size (idxd->data->type, idxd,1U << idxd->hw.gen_cap.max_batch_shift);dev_dbg (dev,"max batch size: %u\n" , idxd->max_batch_size);if (idxd->hw.gen_cap.config_en)set_bit (IDXD_FLAG_CONFIGURABLE , &idxd->flags);
drivers/dma/idxd/sysfs.c +1 -1
@@ -1046,7 +1046,7 @@ static ssize_t wq_max_batch_size_store(struct device *dev, struct device_attribuif (batch_size > idxd->max_batch_size)return -EINVAL ; - wq->max_batch_size = (u32 )batch_size; +idxd_wq_set_max_batch_size (idxd->data->type, wq, (u32 )batch_size);return count; }
Signature · 1 line
2.18.4
PATCH v2 2/2 dmaengine: idxd: Make max batch size attributes in sysfs invisible for Intel IAA
In reply to Xiaochen ShenIn 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
--- .../ABI/stable/sysfs-driver-dma-idxd | 2 ++ drivers/dma/idxd/sysfs.c | 32 +++++++++++++++++++ 2 files changed, 34 insertions(+)
Documentation/ABI/stable/sysfs-driver-dma-idxd +2 -0
@@ -22,6 +22,7 @@ Date: Oct 25, 2019 KernelVersion: 5.6.0 Contact: [email protected] 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: [email protected] 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
drivers/dma/idxd/sysfs.c +32 -0
@@ -1233,6 +1233,14 @@ static bool idxd_wq_attr_op_config_invisible(struct attribute *attr, !idxd->hw.wq_cap.op_config; } +static bool idxd_wq_attr_max_batch_size_invisible (struct attribute *attr, +struct idxd_device *idxd) +{ +/* Intel IAA does not support batch processing, make it invisible */ +return attr == &dev_attr_wq_max_batch_size.attr && + idxd->data->type ==IDXD_TYPE_IAX ; +} +static umode_t idxd_wq_attr_visible (struct kobject *kobj,struct attribute *attr,int n) {
@@ -1243,6 +1251,9 @@ static umode_t idxd_wq_attr_visible(struct kobject *kobj,if (idxd_wq_attr_op_config_invisible (attr, idxd))return 0 ; +if (idxd_wq_attr_max_batch_size_invisible (attr, idxd)) +return 0 ; +return attr->mode; }
@@ -1533,6 +1544,26 @@ static ssize_t cmd_status_store(struct device *dev, struct device_attribute *att }static DEVICE_ATTR_RW (cmd_status); +static bool idxd_device_attr_max_batch_size_invisible (struct attribute *attr, +struct idxd_device *idxd) +{ +/* Intel IAA does not support batch processing, make it invisible */ +return attr == &dev_attr_max_batch_size.attr && + idxd->data->type ==IDXD_TYPE_IAX ; +} + +static umode_t idxd_device_attr_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); + +if (idxd_device_attr_max_batch_size_invisible (attr, idxd)) +return 0 ; + +return attr->mode; +} +static struct attribute *idxd_device_attributes[] = { &dev_attr_version.attr, &dev_attr_max_groups.attr,
@@ -1560,6 +1591,7 @@ static struct attribute *idxd_device_attributes[] = {static const struct attribute_group idxd_device_attribute_group = { .attrs = idxd_device_attributes, + .is_visible = idxd_device_attr_visible, };static const struct attribute_group *idxd_attribute_groups[] = {
Signature · 1 line
2.18.4
Hi Vinod,
Quoted 10 lines · Xiaochen Shen
Fix max batch size related issues for Intel IAA:
1. Fix max batch size default values.
2. Make max batch size attributes in sysfs invisible.Changelog:
v2:
- Rebase on -next branch (Vinod).
- Use wrapper function idxd_{device|wq}_attr_max_batch_size_invisible() to make the code more readable.
Quoted 4 lines
Xiaochen Shen (2):
dmaengine: idxd: Fix max batch size for Intel IAA
dmaengine: idxd: Make max batch size attributes in sysfs invisible for
Intel IAA
Do you have any comment on this rebased patch set?
After rebase, this patch set could be applied against both dmaengine -next branch and mainline -master branch now.
Thank you very much for code review!
Best regards,
Xiaochen
Quoted 3 lines · Xiaochen Shen
Fix max batch size related issues for Intel IAA:
1. Fix max batch size default values.
2. Make max batch size attributes in sysfs invisible.
Applied, thanks
Signature · 1 line
~Vinod