Enable a few DSA 2.0 features
Subsystems (2)
cover Enable a few DSA 2.0 features
Data Streaming Accelerator (DSA) 2.0 [1] introduces a few new features. This series enables the new features:
- Work Queue (WQ) operation cap restriction: patch 3 with patch 1 and 2 as preparation.
- Configuration for concurrent work descriptor: patch 4.
- Configuration for concurrent batch descriptor: patch 5.
Dave Jiang (5):
dmaengine: idxd: convert ats_dis to a wq flag
dmanegine: idxd: reformat opcap output to match bitmap_parse() input
dmaengine: idxd: add WQ operation cap restriction support
dmaengine: idxd: add configuration for concurrent work descriptor
processing
dmaengine: idxd: add configuration for concurrent batch descriptor
processing
.../ABI/stable/sysfs-driver-dma-idxd | 35 ++++ drivers/dma/idxd/device.c | 34 +++- drivers/dma/idxd/idxd.h | 8 +- drivers/dma/idxd/init.c | 30 +++ drivers/dma/idxd/registers.h | 35 ++-- drivers/dma/idxd/sysfs.c | 186 +++++++++++++++++- 6 files changed, 298 insertions(+), 30 deletions(-)
Signature · 1 line
2.32.0
PATCH 1/5 dmaengine: idxd: convert ats_dis to a wq flag
From: Dave Jiang <[email protected]>
Make wq attributes access consistent. Convert ats_dis to wq flag WQ_FLAG_ATS_DISABLE.
--- drivers/dma/idxd/device.c | 4 ++-- drivers/dma/idxd/idxd.h | 2 +- drivers/dma/idxd/sysfs.c | 7 +++++-- 3 files changed, 8 insertions(+), 5 deletions(-)
drivers/dma/idxd/device.c +2 -2
@@ -382,10 +382,10 @@ static void idxd_wq_disable_cleanup(struct idxd_wq *wq) wq->type =IDXD_WQT_NONE ; wq->threshold =0 ; wq->priority =0 ; - wq->ats_dis =0 ; wq->enqcmds_retries =IDXD_ENQCMDS_RETRIES ;clear_bit (WQ_FLAG_DEDICATED , &wq->flags);clear_bit (WQ_FLAG_BLOCK_ON_FAULT , &wq->flags); +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 ;
@@ -859,7 +859,7 @@ static int idxd_wq_config_write(struct idxd_wq *wq) wq->wqcfg->bof =1 ;if (idxd->hw.wq_cap.wq_ats_support) - wq->wqcfg->wq_ats_disable = wq->ats_dis; + wq->wqcfg->wq_ats_disable =test_bit (WQ_FLAG_ATS_DISABLE , &wq->flags);/* bytes 12-15 */ wq->wqcfg->max_xfer_shift =ilog2 (wq->max_xfer_bytes);
drivers/dma/idxd/idxd.h +1 -1
@@ -132,6 +132,7 @@ enum idxd_wq_state {enum idxd_wq_flag {WQ_FLAG_DEDICATED =0 ,WQ_FLAG_BLOCK_ON_FAULT , +WQ_FLAG_ATS_DISABLE , };enum idxd_wq_type {
@@ -208,7 +209,6 @@ struct idxd_wq {char name[WQ_NAME_SIZE +1 ];u64 max_xfer_bytes;u32 max_batch_size; -bool ats_dis; };struct idxd_engine {
drivers/dma/idxd/sysfs.c +5 -2
@@ -973,7 +973,7 @@ static ssize_t wq_ats_disable_show(struct device *dev, struct device_attribute * {struct idxd_wq *wq =confdev_to_wq (dev); -return sysfs_emit (buf,"%u\n" , wq->ats_dis); +return sysfs_emit (buf,"%u\n" ,test_bit (WQ_FLAG_ATS_DISABLE , &wq->flags)); } static ssize_t wq_ats_disable_store(struct device *dev, struct device_attribute *attr,
@@ -994,7 +994,10 @@ static ssize_t wq_ats_disable_store(struct device *dev, struct device_attributeif (rc <0 )return rc; - wq->ats_dis = ats_dis; +if (ats_dis) +set_bit (WQ_FLAG_ATS_DISABLE , &wq->flags); +else +clear_bit (WQ_FLAG_ATS_DISABLE , &wq->flags);return count; }
Signature · 1 line
2.32.0
PATCH 2/5 dmanegine: idxd: reformat opcap output to match bitmap_parse() input
In reply to Fenghua YuFrom: Dave Jiang <[email protected]>
To make input and output consistent and prepping for the per WQ operation configuration support, change the output of opcap display to match the input that is expected by bitmap_parse() helper function. The output will be a bitmap with field width as the number of bits using the %*pb format specifier for printk() family.
--- drivers/dma/idxd/idxd.h | 2 ++ drivers/dma/idxd/init.c | 20 ++++++++++++++++++++ drivers/dma/idxd/registers.h | 2 ++ drivers/dma/idxd/sysfs.c | 9 ++------- 4 files changed, 26 insertions(+), 7 deletions(-)
drivers/dma/idxd/idxd.h +2 -0
@@ -308,6 +308,8 @@ struct idxd_device {struct work_struct work;struct idxd_pmu *idxd_pmu; + +unsigned long *opcap_bmap; };/* IDXD software descriptor */
drivers/dma/idxd/init.c +20 -0
@@ -369,6 +369,19 @@ static void idxd_read_table_offsets(struct idxd_device *idxd)dev_dbg (dev,"IDXD Perfmon Offset: %#x\n" , idxd->perfmon_offset); } +static void multi_u64_to_bmap (unsigned long *bmap,u64 *val,int count) +{ +int i, j, nr; + +for (i =0 , nr =0 ; i < count; i++) { +for (j =0 ; j <BITS_PER_LONG_LONG ; j++) { +if (val[i] &BIT (j)) +set_bit (nr, bmap); + nr++; + } + } +} +static void idxd_read_caps (struct idxd_device *idxd) {struct device *dev = &idxd->pdev->dev;
@@ -427,6 +440,7 @@ static void idxd_read_caps(struct idxd_device *idxd) IDXD_OPCAP_OFFSET + i * sizeof(u64));dev_dbg (dev,"opcap[%d]: %#llx\n" , i, idxd->hw.opcap.bits[i]); } +multi_u64_to_bmap (idxd->opcap_bmap, &idxd->hw.opcap.bits[0 ],4 ); }static struct idxd_device *idxd_alloc (struct pci_dev *pdev,struct idxd_driver_data *data)
@@ -448,6 +462,12 @@ static struct idxd_device *idxd_alloc(struct pci_dev *pdev, struct idxd_driver_dif (idxd->id <0 )return NULL ; + idxd->opcap_bmap =bitmap_zalloc_node (IDXD_MAX_OPCAP_BITS ,GFP_KERNEL ,dev_to_node (dev)); +if (!idxd->opcap_bmap) { +ida_free (&idxd_ida, idxd->id); +return NULL ; + } +device_initialize (conf_dev); conf_dev->parent = dev; conf_dev->bus = &dsa_bus_type;
drivers/dma/idxd/registers.h +2 -0
@@ -90,6 +90,8 @@ struct opcap {u64 bits[4 ]; }; +#define IDXD_MAX_OPCAP_BITS 256U +#define IDXD_OPCAP_OFFSET 0x40#define IDXD_TABLE_OFFSET 0x60
drivers/dma/idxd/sysfs.c +2 -7
@@ -1180,14 +1180,8 @@ static ssize_t op_cap_show(struct device *dev, struct device_attribute *attr, char *buf) { struct idxd_device *idxd = confdev_to_idxd(dev); -int i, rc =0 ; - -for (i =0 ; i <4 ; i++) - rc +=sysfs_emit_at (buf, rc,"%#llx " , idxd->hw.opcap.bits[i]); - rc--; - rc +=sysfs_emit_at (buf, rc,"\n" ); -return rc; +return sysfs_emit (buf,"%*pb\n" ,IDXD_MAX_OPCAP_BITS , idxd->opcap_bmap); }static DEVICE_ATTR_RO (op_cap);
@@ -1411,6 +1405,7 @@ static void idxd_conf_device_release(struct device *dev)kfree (idxd->wqs);kfree (idxd->engines);ida_free (&idxd_ida, idxd->id); +bitmap_free (idxd->opcap_bmap);kfree (idxd); }
Signature · 1 line
2.32.0
PATCH 3/5 dmaengine: idxd: add WQ operation cap restriction support
In reply to Fenghua YuFrom: Dave Jiang <[email protected]>
DSA 2.0 add the capability of configuring DMA ops on a per workqueue basis. This means that certain ops can be disabled by the system administrator for certain wq. By default, all ops are available. A bitmap is used to store the ops due to total op size of 256 bits and it is more convenient to use a range list to specify which bits are enabled.
One of the usage to support this is for VM migration between different iteration of devices. The newer ops are disabled in order to allow guest to migrate to a host that only support older ops. Another usage is to restrict the WQ to certain operations for QoS of performance.
A sysfs of ops_config attribute is added per wq. It is only usable when the ops_config bit is set under WQ_CAP register. This means that this attribute will return -EOPNOTSUPP on DSA 1.x devices. The expected input is a range list for the bits per operation the WQ supports.
--- .../ABI/stable/sysfs-driver-dma-idxd | 11 +++ drivers/dma/idxd/device.c | 15 +++- drivers/dma/idxd/idxd.h | 2 + drivers/dma/idxd/init.c | 10 +++ drivers/dma/idxd/registers.h | 8 +- drivers/dma/idxd/sysfs.c | 85 +++++++++++++++++++ 6 files changed, 128 insertions(+), 3 deletions(-)
Documentation/ABI/stable/sysfs-driver-dma-idxd +11 -0
@@ -227,6 +227,17 @@ Contact: [email protected] Description: Indicate the number of retires for an enqcmds submission on a sharedwq. A max value to set attribute is capped at 64. +What: /sys/bus/dsa/devices/wq<m>.<n>/op_config +Date: Sept 14, 2022 +KernelVersion: 6.0.0 +Contact: [email protected] +Description: Shows the operation capability bits displayed in bitmap format + presented by %*pb printk() output format specifier. + The attribute can be configured when the WQ is disabled in + order to configure the WQ to accept specific bits that + correlates to the operations allowed. It's visible only + on platforms that support the capability. + What: /sys/bus/dsa/devices/engine<m>.<n>/group_id Date: Oct 25, 2019 KernelVersion: 5.6.0
drivers/dma/idxd/device.c +14 -1
@@ -389,6 +389,8 @@ static void idxd_wq_disable_cleanup(struct idxd_wq *wq)memset (wq->name,0 ,WQ_NAME_SIZE ); wq->max_xfer_bytes =WQ_DEFAULT_MAX_XFER ; wq->max_batch_size =WQ_DEFAULT_MAX_BATCH ; +if (wq->opcap_bmap) +bitmap_copy (wq->opcap_bmap, idxd->opcap_bmap,IDXD_MAX_OPCAP_BITS ); }static void idxd_wq_device_reset_cleanup (struct idxd_wq *wq)
@@ -807,7 +809,7 @@ static int idxd_wq_config_write(struct idxd_wq *wq)struct idxd_device *idxd = wq->idxd;struct device *dev = &idxd->pdev->dev;u32 wq_offset; -int i; +int i, n;if (!wq->group)return 0 ;
@@ -865,6 +867,17 @@ static int idxd_wq_config_write(struct idxd_wq *wq) wq->wqcfg->max_xfer_shift =ilog2 (wq->max_xfer_bytes); wq->wqcfg->max_batch_shift =ilog2 (wq->max_batch_size); +/* bytes 32-63 */ +if (idxd->hw.wq_cap.op_config && wq->opcap_bmap) { +memset (wq->wqcfg->op_config,0 ,IDXD_MAX_OPCAP_BITS /8 ); +for_each_set_bit (n, wq->opcap_bmap,IDXD_MAX_OPCAP_BITS ) { +int pos = n %BITS_PER_LONG_LONG ; +int idx = n /BITS_PER_LONG_LONG ; + + wq->wqcfg->op_config[idx] |=BIT (pos); + } + } +dev_dbg (dev,"WQ %d CFGs\n" , wq->id);for (i =0 ; i <WQCFG_STRIDES (idxd); i++) { wq_offset =WQCFG_OFFSET (idxd, wq->id, i);
drivers/dma/idxd/idxd.h +2 -0
@@ -195,6 +195,8 @@ struct idxd_wq {enum idxd_wq_state state;unsigned long flags;union wqcfg *wqcfg; +unsigned long *opcap_bmap; +struct dsa_hw_desc **hw_descs;int num_descs;union {
drivers/dma/idxd/init.c +10 -0
@@ -185,6 +185,16 @@ static int idxd_setup_wqs(struct idxd_device *idxd) rc = -ENOMEM ; goto err; } + +if (idxd->hw.wq_cap.op_config) { + wq->opcap_bmap =bitmap_zalloc (IDXD_MAX_OPCAP_BITS ,GFP_KERNEL ); +if (!wq->opcap_bmap) { +put_device (conf_dev); + rc = -ENOMEM ; + goto err; + } +bitmap_copy (wq->opcap_bmap, idxd->opcap_bmap,IDXD_MAX_OPCAP_BITS ); + } idxd->wqs[i] = wq; }
drivers/dma/idxd/registers.h +6 -2
@@ -54,7 +54,8 @@ union wq_cap_reg { u64 priority:1; u64 occupancy:1; u64 occupancy_int:1; - u64 rsvd3:10; + u64 op_config:1; + u64 rsvd3:9; };u64 bits; } __packed;
@@ -350,8 +351,11 @@ union wqcfg {/* bytes 28-31 */ u32 rsvd8; + +/* bytes 32-63 */ +u64 op_config[4 ]; }; -u32 bits[8 ]; +u32 bits[16 ]; } __packed;#define WQCFG_PASID_IDX 2
drivers/dma/idxd/sysfs.c +85 -0
108 lines not on this page · raw message
Signature · 1 line
2.32.0
PATCH 4/5 dmaengine: idxd: add configuration for concurrent work descriptor processing
In reply to Fenghua YuFrom: Dave Jiang <[email protected]>
Add sysfs knob to allow control of the number of work descriptors that can be concurrently processed by an engine in the group as a fraction of the Maximum Work Descriptors in Progress value specified in ENGCAP register. This control knob is part of toggle for QoS control.
--- .../ABI/stable/sysfs-driver-dma-idxd | 12 +++++ drivers/dma/idxd/device.c | 13 +++-- drivers/dma/idxd/idxd.h | 1 + drivers/dma/idxd/registers.h | 23 ++++---- drivers/dma/idxd/sysfs.c | 53 +++++++++++++++++++ 5 files changed, 87 insertions(+), 15 deletions(-)
Documentation/ABI/stable/sysfs-driver-dma-idxd +12 -0
@@ -266,3 +266,15 @@ Contact: [email protected] Description: Indicates the number of Read Buffers reserved for the use of engines in the group. See DSA spec v1.2 9.2.18 GRPCFG Read Buffers Reserved. + +What: /sys/bus/dsa/devices/group<m>.<n>/desc_progress_limit +Date: Sept 14, 2022 +KernelVersion: 6.0.0 +Contact: [email protected] +Description: Allows control of the number of work descriptors that can be + concurrently processed by an engine in the group as a fraction + of the Maximum Work Descriptors in Progress value specified in + the ENGCAP register. The acceptable values are 0 (default), + 1 (1/2 of max value), 2 (1/4 of the max value), and 3 (1/8 of + the max value). It's visible only on platforms that support + the capability.
drivers/dma/idxd/device.c +8 -5
@@ -707,6 +707,7 @@ static void idxd_groups_clear_state(struct idxd_device *idxd) group->tc_a =-1 ; group->tc_b =-1 ; } + group->desc_progress_limit =0 ; } }
@@ -763,10 +764,10 @@ static void idxd_group_config_write(struct idxd_group *group)/* setup GRPFLAGS */ grpcfg_offset =GRPFLGCFG_OFFSET (idxd, group->id); -iowrite32 (group->grpcfg.flags.bits, idxd->reg_base + grpcfg_offset); -dev_dbg (dev,"GRPFLAGS flags[%d: %#x]: %#x\n" , +iowrite64 (group->grpcfg.flags.bits, idxd->reg_base + grpcfg_offset); +dev_dbg (dev,"GRPFLAGS flags[%d: %#x]: %#llx\n" , group->id, grpcfg_offset, -ioread32 (idxd->reg_base + grpcfg_offset)); +ioread64 (idxd->reg_base + grpcfg_offset)); }static int idxd_groups_config_write (struct idxd_device *idxd)
@@ -927,6 +928,8 @@ static void idxd_group_flags_setup(struct idxd_device *idxd) group->grpcfg.flags.rdbufs_allowed = group->rdbufs_allowed; else group->grpcfg.flags.rdbufs_allowed = idxd->max_rdbufs; + + group->grpcfg.flags.desc_progress_limit = group->desc_progress_limit; } }
@@ -1109,8 +1112,8 @@ static void idxd_group_load_config(struct idxd_group *group) } grpcfg_offset =GRPFLGCFG_OFFSET (idxd, group->id); - group->grpcfg.flags.bits =ioread32 (idxd->reg_base + grpcfg_offset); -dev_dbg (dev,"GRPFLAGS flags[%d: %#x]: %#x\n" , + group->grpcfg.flags.bits =ioread64 (idxd->reg_base + grpcfg_offset); +dev_dbg (dev,"GRPFLAGS flags[%d: %#x]: %#llx\n" , group->id, grpcfg_offset, group->grpcfg.flags.bits); }
drivers/dma/idxd/idxd.h +1 -0
@@ -95,6 +95,7 @@ struct idxd_group {u8 rdbufs_reserved;int tc_a;int tc_b; +int desc_progress_limit; };struct idxd_pmu {
drivers/dma/idxd/registers.h +13 -10
@@ -68,7 +68,8 @@ union group_cap_reg { u64 total_rdbufs:8; /* formerly total_tokens */ u64 rdbuf_ctrl:1; /* formerly token_en */ u64 rdbuf_limit:1; /* formerly token_limit */ - u64 rsvd:46; + u64 progress_limit:1; /* descriptor and batch descriptor */ + u64 rsvd:45; };u64 bits; } __packed;
@@ -288,16 +289,18 @@ union msix_perm {union group_flags {struct { -u32 tc_a:3 ; -u32 tc_b:3 ; -u32 rsvd:1 ; -u32 use_rdbuf_limit:1 ; -u32 rdbufs_reserved:8 ; -u32 rsvd2:4 ; -u32 rdbufs_allowed:8 ; -u32 rsvd3:4 ; +u64 tc_a:3 ; +u64 tc_b:3 ; +u64 rsvd:1 ; +u64 use_rdbuf_limit:1 ; +u64 rdbufs_reserved:8 ; +u64 rsvd2:4 ; +u64 rdbufs_allowed:8 ; +u64 rsvd3:4 ; +u64 desc_progress_limit:2 ; +u64 rsvd4:30 ; }; -u32 bits; +u64 bits; } __packed;struct grpcfg {
drivers/dma/idxd/sysfs.c +53 -0
70 lines not on this page · raw message
Signature · 1 line
2.32.0
PATCH 5/5 dmaengine: idxd: add configuration for concurrent batch descriptor processing
In reply to Fenghua YuFrom: Dave Jiang <[email protected]>
Add sysfs knob to allow control of the number of batch descriptors that can be concurrently processed by an engine in the group as a fraction of the Maximum Work Descriptors in Progress value specfied in ENGCAP register. This control knob is part of toggle for QoS control.
--- .../ABI/stable/sysfs-driver-dma-idxd | 12 +++++++ drivers/dma/idxd/device.c | 2 ++ drivers/dma/idxd/idxd.h | 1 + drivers/dma/idxd/registers.h | 4 ++- drivers/dma/idxd/sysfs.c | 36 +++++++++++++++++-- 5 files changed, 52 insertions(+), 3 deletions(-)
Documentation/ABI/stable/sysfs-driver-dma-idxd +12 -0
@@ -278,3 +278,15 @@ Description: Allows control of the number of work descriptors that can be 1 (1/2 of max value), 2 (1/4 of the max value), and 3 (1/8 of the max value). It's visible only on platforms that support the capability. + +What: /sys/bus/dsa/devices/group<m>.<n>/batch_progress_limit +Date: Sept 14, 2022 +KernelVersion: 6.0.0 +Contact: [email protected] +Description: Allows control of the number of batch descriptors that can be + concurrently processed by an engine in the group as a fraction + of the Maximum Batch Descriptors in Progress value specified in + the ENGCAP register. The acceptable values are 0 (default), + 1 (1/2 of max value), 2 (1/4 of the max value), and 3 (1/8 of + the max value). It's visible only on platforms that support + the capability.
drivers/dma/idxd/device.c +2 -0
@@ -708,6 +708,7 @@ static void idxd_groups_clear_state(struct idxd_device *idxd) group->tc_b =-1 ; } group->desc_progress_limit =0 ; + group->batch_progress_limit =0 ; } }
@@ -930,6 +931,7 @@ static void idxd_group_flags_setup(struct idxd_device *idxd) group->grpcfg.flags.rdbufs_allowed = idxd->max_rdbufs; group->grpcfg.flags.desc_progress_limit = group->desc_progress_limit; + group->grpcfg.flags.batch_progress_limit = group->batch_progress_limit; } }
drivers/dma/idxd/idxd.h +1 -0
@@ -96,6 +96,7 @@ struct idxd_group {int tc_a;int tc_b;int desc_progress_limit; +int batch_progress_limit; };struct idxd_pmu {
drivers/dma/idxd/registers.h +3 -1
@@ -298,7 +298,9 @@ union group_flags { u64 rdbufs_allowed:8; u64 rsvd3:4; u64 desc_progress_limit:2; - u64 rsvd4:30; + u64 rsvd4:2; + u64 batch_progress_limit:2; + u64 rsvd5:26; };u64 bits; } __packed;
drivers/dma/idxd/sysfs.c +34 -2
@@ -474,6 +474,36 @@ static struct device_attribute dev_attr_group_desc_progress_limit =__ATTR (desc_progress_limit,0644 , group_desc_progress_limit_show, group_desc_progress_limit_store); +static ssize_t group_batch_progress_limit_show (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct idxd_group *group =confdev_to_group (dev); + +return sysfs_emit (buf,"%d\n" , group->batch_progress_limit); +} + +static ssize_t group_batch_progress_limit_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) +{ +struct idxd_group *group =confdev_to_group (dev); +int val, rc; + + rc =kstrtoint (buf,10 , &val); +if (rc <0 ) +return -EINVAL ; + +if (val & ~GENMASK (1 ,0 )) +return -EINVAL ; + + group->batch_progress_limit = val; +return count; +} + +static struct device_attribute dev_attr_group_batch_progress_limit = +__ATTR (batch_progress_limit,0644 , group_batch_progress_limit_show, + group_batch_progress_limit_store);static struct attribute *idxd_group_attributes[] = { &dev_attr_group_work_queues.attr, &dev_attr_group_engines.attr,
@@ -486,14 +516,16 @@ static struct attribute *idxd_group_attributes[] = { &dev_attr_group_traffic_class_a.attr, &dev_attr_group_traffic_class_b.attr, &dev_attr_group_desc_progress_limit.attr, + &dev_attr_group_batch_progress_limit.attr, NULL, };static bool idxd_group_attr_progress_limit_invisible (struct attribute *attr,struct idxd_device *idxd) { -return attr == &dev_attr_group_desc_progress_limit.attr && - !idxd->hw.group_cap.progress_limit; +return (attr == &dev_attr_group_desc_progress_limit.attr || + attr == &dev_attr_group_batch_progress_limit.attr) && + !idxd->hw.group_cap.progress_limit; } static umode_t idxd_group_attr_visible(struct kobject *kobj,
Signature · 1 line
2.32.0
Quoted 2 lines · Fenghua Yu
Data Streaming Accelerator (DSA) 2.0 [1] introduces a few new features. This series enables the new features:
Applied, thanks
Signature · 1 line
~Vinod