Skip to content

Commit 92452a7

Browse files
davejiangvinodkoul
authored andcommitted
dmaengine: idxd: set defaults for wq configs
Add default values for wq size, max_xfer_size and max_batch_size. These values should provide a general guidance for the wq configuration when the user does not specify any specific values. Signed-off-by: Dave Jiang <[email protected]> Link: https://lore.kernel.org/r/163528473483.3926048.7950067926287180976.stgit@djiang5-desk3.ch.intel.com Signed-off-by: Vinod Koul <[email protected]>
1 parent 0f93f20 commit 92452a7

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

drivers/dma/idxd/device.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,8 @@ static void idxd_wq_disable_cleanup(struct idxd_wq *wq)
390390
clear_bit(WQ_FLAG_DEDICATED, &wq->flags);
391391
clear_bit(WQ_FLAG_BLOCK_ON_FAULT, &wq->flags);
392392
memset(wq->name, 0, WQ_NAME_SIZE);
393+
wq->max_xfer_bytes = WQ_DEFAULT_MAX_XFER;
394+
wq->max_batch_size = WQ_DEFAULT_MAX_BATCH;
393395
}
394396

395397
static void idxd_wq_ref_release(struct percpu_ref *ref)
@@ -839,15 +841,12 @@ static int idxd_wq_config_write(struct idxd_wq *wq)
839841
wq->wqcfg->bits[i] = ioread32(idxd->reg_base + wq_offset);
840842
}
841843

844+
if (wq->size == 0 && wq->type != IDXD_WQT_NONE)
845+
wq->size = WQ_DEFAULT_QUEUE_DEPTH;
846+
842847
/* byte 0-3 */
843848
wq->wqcfg->wq_size = wq->size;
844849

845-
if (wq->size == 0) {
846-
idxd->cmd_status = IDXD_SCMD_WQ_NO_SIZE;
847-
dev_warn(dev, "Incorrect work queue size: 0\n");
848-
return -EINVAL;
849-
}
850-
851850
/* bytes 4-7 */
852851
wq->wqcfg->wq_thresh = wq->threshold;
853852

@@ -993,8 +992,6 @@ static int idxd_wqs_setup(struct idxd_device *idxd)
993992

994993
if (!wq->group)
995994
continue;
996-
if (!wq->size)
997-
continue;
998995

999996
if (wq_shared(wq) && !device_swq_supported(idxd)) {
1000997
idxd->cmd_status = IDXD_SCMD_WQ_NO_SWQ_SUPPORT;

drivers/dma/idxd/idxd.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ struct idxd_cdev {
150150
#define WQ_NAME_SIZE 1024
151151
#define WQ_TYPE_SIZE 10
152152

153+
#define WQ_DEFAULT_QUEUE_DEPTH 16
154+
#define WQ_DEFAULT_MAX_XFER SZ_2M
155+
#define WQ_DEFAULT_MAX_BATCH 32
156+
153157
enum idxd_op_type {
154158
IDXD_OP_BLOCK = 0,
155159
IDXD_OP_NONBLOCK = 1,

drivers/dma/idxd/init.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ static int idxd_setup_wqs(struct idxd_device *idxd)
246246
init_waitqueue_head(&wq->err_queue);
247247
init_completion(&wq->wq_dead);
248248
init_completion(&wq->wq_resurrect);
249-
wq->max_xfer_bytes = idxd->max_xfer_bytes;
250-
wq->max_batch_size = idxd->max_batch_size;
249+
wq->max_xfer_bytes = WQ_DEFAULT_MAX_XFER;
250+
wq->max_batch_size = WQ_DEFAULT_MAX_BATCH;
251251
wq->wqcfg = kzalloc_node(idxd->wqcfg_size, GFP_KERNEL, dev_to_node(dev));
252252
if (!wq->wqcfg) {
253253
put_device(conf_dev);

0 commit comments

Comments
 (0)