Commit 350bb478 authored by Matthew R. Ochs's avatar Matthew R. Ochs Committed by Martin K. Petersen

scsi: cxlflash: Allocate memory instead of using command pool for AFU sync

As staging for the removal of the AFU command pool, remove the reliance
upon the pool for the internal AFU sync command. Instead of obtaining an
AFU command from the pool, dynamically allocate memory with the appropriate
alignment requirements. Since the AFU sync service is only executed from
the process environment, blocking is acceptable.
Signed-off-by: default avatarMatthew R. Ochs <mrochs@linux.vnet.ibm.com>
Acked-by: default avatarUma Krishnan <ukrishn@linux.vnet.ibm.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent e7ab2d40
...@@ -1823,8 +1823,8 @@ int cxlflash_afu_sync(struct afu *afu, ctx_hndl_t ctx_hndl_u, ...@@ -1823,8 +1823,8 @@ int cxlflash_afu_sync(struct afu *afu, ctx_hndl_t ctx_hndl_u,
struct cxlflash_cfg *cfg = afu->parent; struct cxlflash_cfg *cfg = afu->parent;
struct device *dev = &cfg->dev->dev; struct device *dev = &cfg->dev->dev;
struct afu_cmd *cmd = NULL; struct afu_cmd *cmd = NULL;
char *buf = NULL;
int rc = 0; int rc = 0;
int retry_cnt = 0;
static DEFINE_MUTEX(sync_active); static DEFINE_MUTEX(sync_active);
if (cfg->state != STATE_NORMAL) { if (cfg->state != STATE_NORMAL) {
...@@ -1833,23 +1833,23 @@ int cxlflash_afu_sync(struct afu *afu, ctx_hndl_t ctx_hndl_u, ...@@ -1833,23 +1833,23 @@ int cxlflash_afu_sync(struct afu *afu, ctx_hndl_t ctx_hndl_u,
} }
mutex_lock(&sync_active); mutex_lock(&sync_active);
retry: buf = kzalloc(sizeof(*cmd) + __alignof__(*cmd) - 1, GFP_KERNEL);
cmd = cmd_checkout(afu); if (unlikely(!buf)) {
if (unlikely(!cmd)) { dev_err(dev, "%s: no memory for command\n", __func__);
retry_cnt++;
udelay(1000 * retry_cnt);
if (retry_cnt < MC_RETRY_CNT)
goto retry;
dev_err(dev, "%s: could not get a free command\n", __func__);
rc = -1; rc = -1;
goto out; goto out;
} }
pr_debug("%s: afu=%p cmd=%p %d\n", __func__, afu, cmd, ctx_hndl_u); cmd = (struct afu_cmd *)PTR_ALIGN(buf, __alignof__(*cmd));
init_completion(&cmd->cevent);
spin_lock_init(&cmd->slock);
cmd->parent = afu;
memset(cmd->rcb.cdb, 0, sizeof(cmd->rcb.cdb)); pr_debug("%s: afu=%p cmd=%p %d\n", __func__, afu, cmd, ctx_hndl_u);
cmd->rcb.req_flags = SISL_REQ_FLAGS_AFU_CMD; cmd->rcb.req_flags = SISL_REQ_FLAGS_AFU_CMD;
cmd->rcb.ctx_id = afu->ctx_hndl;
cmd->rcb.msi = SISL_MSI_RRQ_UPDATED;
cmd->rcb.port_sel = 0x0; /* NA */ cmd->rcb.port_sel = 0x0; /* NA */
cmd->rcb.lun_id = 0x0; /* NA */ cmd->rcb.lun_id = 0x0; /* NA */
cmd->rcb.data_len = 0x0; cmd->rcb.data_len = 0x0;
...@@ -1875,8 +1875,7 @@ int cxlflash_afu_sync(struct afu *afu, ctx_hndl_t ctx_hndl_u, ...@@ -1875,8 +1875,7 @@ int cxlflash_afu_sync(struct afu *afu, ctx_hndl_t ctx_hndl_u,
rc = -1; rc = -1;
out: out:
mutex_unlock(&sync_active); mutex_unlock(&sync_active);
if (cmd) kfree(buf);
cmd_checkin(cmd);
pr_debug("%s: returning rc=%d\n", __func__, rc); pr_debug("%s: returning rc=%d\n", __func__, rc);
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment