From 8a6c8ba9ae6a70b96fb7658968d12ddade98173f Mon Sep 17 00:00:00 2001 From: paul luse Date: Wed, 5 Jan 2022 13:56:54 -0700 Subject: [PATCH] idxd: updates to WQ config routine to match updated spec Using the latest DSA we aren't supposed to (a) touch WQ space that we aren't configuring and (b) touch WQ config fields that we are configuring even if we are configuring that WQ. So, this patch will read in initial values of only the number of desired WQs and update them accordingly before updating the HW. Also updates a few vars to use shorter local variables consistently. Signed-off-by: paul luse Change-Id: I7641cdfc5ccc839e37a1d46d760248799a8fce1f Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10981 Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- lib/idxd/idxd_user.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/idxd/idxd_user.c b/lib/idxd/idxd_user.c index 27ff4e1a1..01c1620f4 100644 --- a/lib/idxd/idxd_user.c +++ b/lib/idxd/idxd_user.c @@ -291,14 +291,21 @@ idxd_wq_config(struct spdk_user_idxd_device *user_idxd) * and achieve optimal performance for common cases. */ idxd->chan_per_device = (idxd->total_wq_size >= 128) ? 8 : 4; - idxd->queues = calloc(1, user_idxd->registers.wqcap.num_wqs * sizeof(struct idxd_wq)); + idxd->queues = calloc(1, g_user_dev_cfg.total_wqs * sizeof(struct idxd_wq)); if (idxd->queues == NULL) { SPDK_ERRLOG("Failed to allocate queue memory\n"); return -ENOMEM; } for (i = 0; i < g_user_dev_cfg.total_wqs; i++) { - queue = &user_idxd->idxd.queues[i]; + queue = &idxd->queues[i]; + /* Per spec we need to read in existing values first so we don't zero out something we + * didn't touch when we write the cfg register out below. + */ + for (j = 0 ; j < (sizeof(union idxd_wqcfg) / sizeof(uint32_t)); j++) { + queue->wqcfg.raw[j] = _idxd_read_4(idxd, + user_idxd->wqcfg_offset + i * wqcap_size + j * sizeof(uint32_t)); + } queue->wqcfg.wq_size = wq_size; queue->wqcfg.mode = WQ_MODE_DEDICATED; queue->wqcfg.max_batch_shift = LOG2_WQ_MAX_BATCH; @@ -307,14 +314,14 @@ idxd_wq_config(struct spdk_user_idxd_device *user_idxd) queue->wqcfg.priority = WQ_PRIORITY_1; /* Not part of the config struct */ - queue->idxd = &user_idxd->idxd; + queue->idxd = idxd; queue->group = &idxd->groups[i % g_user_dev_cfg.num_groups]; } /* - * Now write the work queue config to the device for all wq space + * Now write the work queue config to the device for configured queues */ - for (i = 0 ; i < user_idxd->registers.wqcap.num_wqs; i++) { + for (i = 0 ; i < g_user_dev_cfg.total_wqs; i++) { queue = &idxd->queues[i]; for (j = 0 ; j < (sizeof(union idxd_wqcfg) / sizeof(uint32_t)); j++) { _idxd_write_4(idxd, user_idxd->wqcfg_offset + i * wqcap_size + j * sizeof(uint32_t),