Skip to content

Commit fe7b87d

Browse files
ysunvinodkoul
authored andcommitted
dmaengine: idxd: Add Max SGL Size Support for DSA3.0
Certain DSA 3.0 opcodes, such as Gather copy and Gather reduce, require max SGL configured for workqueues prior to supporting these opcodes. Configure the maximum scatter-gather list (SGL) size for workqueues during setup on the supported HW. Application can then properly handle the SGL size without explicitly setting it. Signed-off-by: Yi Sun <yi.sun@intel.com> Co-developed-by: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> Signed-off-by: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Tested-by: Yi Lai <yi1.lai@intel.com> Acked-by: Vinicius Costa Gomes <vinicius.gomes@intel.com> Link: https://patch.msgid.link/20260107-idxd-yi-sun-dsa3-sgl-size-v2-2-dbef8f559e48@intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 8308510 commit fe7b87d

4 files changed

Lines changed: 28 additions & 1 deletion

File tree

drivers/dma/idxd/device.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ static void idxd_wq_disable_cleanup(struct idxd_wq *wq)
390390
memset(wq->name, 0, WQ_NAME_SIZE);
391391
wq->max_xfer_bytes = WQ_DEFAULT_MAX_XFER;
392392
idxd_wq_set_max_batch_size(idxd->data->type, wq, WQ_DEFAULT_MAX_BATCH);
393+
idxd_wq_set_init_max_sgl_size(idxd, wq);
393394
if (wq->opcap_bmap)
394395
bitmap_copy(wq->opcap_bmap, idxd->opcap_bmap, IDXD_MAX_OPCAP_BITS);
395396
}
@@ -989,6 +990,8 @@ static int idxd_wq_config_write(struct idxd_wq *wq)
989990
/* bytes 12-15 */
990991
wq->wqcfg->max_xfer_shift = ilog2(wq->max_xfer_bytes);
991992
idxd_wqcfg_set_max_batch_shift(idxd->data->type, wq->wqcfg, ilog2(wq->max_batch_size));
993+
if (idxd_sgl_supported(idxd))
994+
wq->wqcfg->max_sgl_shift = ilog2(wq->max_sgl_size);
992995

993996
/* bytes 32-63 */
994997
if (idxd->hw.wq_cap.op_config && wq->opcap_bmap) {
@@ -1167,6 +1170,8 @@ static int idxd_wq_load_config(struct idxd_wq *wq)
11671170

11681171
wq->max_xfer_bytes = 1ULL << wq->wqcfg->max_xfer_shift;
11691172
idxd_wq_set_max_batch_size(idxd->data->type, wq, 1U << wq->wqcfg->max_batch_shift);
1173+
if (idxd_sgl_supported(idxd))
1174+
wq->max_sgl_size = 1U << wq->wqcfg->max_sgl_shift;
11701175

11711176
for (i = 0; i < WQCFG_STRIDES(idxd); i++) {
11721177
wqcfg_offset = WQCFG_OFFSET(idxd, wq->id, i);

drivers/dma/idxd/idxd.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ struct idxd_wq {
227227
char name[WQ_NAME_SIZE + 1];
228228
u64 max_xfer_bytes;
229229
u32 max_batch_size;
230+
u32 max_sgl_size;
230231

231232
/* Lock to protect upasid_xa access. */
232233
struct mutex uc_lock;
@@ -348,6 +349,7 @@ struct idxd_device {
348349

349350
u64 max_xfer_bytes;
350351
u32 max_batch_size;
352+
u32 max_sgl_size;
351353
int max_groups;
352354
int max_engines;
353355
int max_rdbufs;
@@ -692,6 +694,20 @@ static inline void idxd_wq_set_max_batch_size(int idxd_type, struct idxd_wq *wq,
692694
wq->max_batch_size = max_batch_size;
693695
}
694696

697+
static bool idxd_sgl_supported(struct idxd_device *idxd)
698+
{
699+
return idxd->data->type == IDXD_TYPE_DSA &&
700+
idxd->hw.version >= DEVICE_VERSION_3 &&
701+
idxd->hw.dsacap0.sgl_formats;
702+
}
703+
704+
static inline void idxd_wq_set_init_max_sgl_size(struct idxd_device *idxd,
705+
struct idxd_wq *wq)
706+
{
707+
if (idxd_sgl_supported(idxd))
708+
wq->max_sgl_size = 1U << idxd->hw.dsacap0.max_sgl_shift;
709+
}
710+
695711
static inline void idxd_wqcfg_set_max_batch_shift(int idxd_type, union wqcfg *wqcfg,
696712
u32 max_batch_shift)
697713
{

drivers/dma/idxd/init.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ static int idxd_setup_wqs(struct idxd_device *idxd)
222222
init_completion(&wq->wq_resurrect);
223223
wq->max_xfer_bytes = WQ_DEFAULT_MAX_XFER;
224224
idxd_wq_set_max_batch_size(idxd->data->type, wq, WQ_DEFAULT_MAX_BATCH);
225+
idxd_wq_set_init_max_sgl_size(idxd, wq);
225226
wq->enqcmds_retries = IDXD_ENQCMDS_RETRIES;
226227
wq->wqcfg = kzalloc_node(idxd->wqcfg_size, GFP_KERNEL, dev_to_node(dev));
227228
if (!wq->wqcfg) {
@@ -590,6 +591,10 @@ static void idxd_read_caps(struct idxd_device *idxd)
590591
idxd->hw.dsacap1.bits = ioread64(idxd->reg_base + IDXD_DSACAP1_OFFSET);
591592
idxd->hw.dsacap2.bits = ioread64(idxd->reg_base + IDXD_DSACAP2_OFFSET);
592593
}
594+
if (idxd_sgl_supported(idxd)) {
595+
idxd->max_sgl_size = 1U << idxd->hw.dsacap0.max_sgl_shift;
596+
dev_dbg(dev, "max sgl size: %u\n", idxd->max_sgl_size);
597+
}
593598

594599
/* read iaa cap */
595600
if (idxd->data->type == IDXD_TYPE_IAX && idxd->hw.version >= DEVICE_VERSION_2)

drivers/dma/idxd/registers.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,8 @@ union wqcfg {
390390
/* bytes 12-15 */
391391
u32 max_xfer_shift:5;
392392
u32 max_batch_shift:4;
393-
u32 rsvd4:23;
393+
u32 max_sgl_shift:4;
394+
u32 rsvd4:19;
394395

395396
/* bytes 16-19 */
396397
u16 occupancy_inth;

0 commit comments

Comments
 (0)