diff --git a/lib/idxd/idxd.c b/lib/idxd/idxd.c index a54ea416f..71cb7a053 100644 --- a/lib/idxd/idxd.c +++ b/lib/idxd/idxd.c @@ -95,7 +95,7 @@ spdk_idxd_get_channel(struct spdk_idxd_device *idxd) { struct spdk_idxd_io_channel *chan; struct idxd_batch *batch; - int i; + int i, num_batches; assert(idxd != NULL); @@ -105,7 +105,9 @@ spdk_idxd_get_channel(struct spdk_idxd_device *idxd) return NULL; } - chan->batch_base = calloc(NUM_BATCHES_PER_CHANNEL, sizeof(struct idxd_batch)); + num_batches = idxd->queues[idxd->wq_id].wqcfg.wq_size / idxd->chan_per_device; + + chan->batch_base = calloc(num_batches, sizeof(struct idxd_batch)); if (chan->batch_base == NULL) { SPDK_ERRLOG("Failed to allocate batch pool\n"); free(chan); @@ -134,7 +136,7 @@ spdk_idxd_get_channel(struct spdk_idxd_device *idxd) TAILQ_INIT(&chan->ops_outstanding); batch = chan->batch_base; - for (i = 0 ; i < NUM_BATCHES_PER_CHANNEL ; i++) { + for (i = 0 ; i < num_batches ; i++) { TAILQ_INSERT_TAIL(&chan->batch_pool, batch, link); batch++; } diff --git a/lib/idxd/idxd.h b/lib/idxd/idxd.h index 39da4928f..65dae94e7 100644 --- a/lib/idxd/idxd.h +++ b/lib/idxd/idxd.h @@ -65,11 +65,6 @@ static inline void movdir64b(void *dst, const void *src) /* The following sets up a max desc count per batch of 16 */ #define LOG2_WQ_MAX_BATCH 4 /* 2^4 = 16 */ #define DESC_PER_BATCH (1 << LOG2_WQ_MAX_BATCH) -/* We decide how many batches we want to support based on what max queue - * depth makes sense resource wise. There is a small price to pay with - * larger numbers wrt polling for completions. - */ -#define NUM_BATCHES_PER_CHANNEL 0x400 #define MIN_USER_DESC_COUNT 2 #define LOG2_WQ_MAX_XFER 30 /* 2^30 = 1073741824 */