aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUma Krishnan <ukrishn@linux.vnet.ibm.com>2016-03-04 16:55:18 -0500
committerMartin K. Petersen <martin.petersen@oracle.com>2016-03-08 21:17:33 -0500
commit5d1952acd0d56f6b6835aa45bea763ee97b9e66f (patch)
treef37166e34c555d2c106efd20de6bcd369f0049e5
parent8a96b52af58721caf4f7496d0737e8ec6b63c86e (diff)
cxlflash: Reorder user context initialization
In order to support cxlflash in the PowerVM environment, underlying hypervisor APIs have imposed a kernel API ordering change. For the superpipe access to LUN, user applications need a context. The cxlflash module creates this context by making a sequence of cxl calls. In the current code, a context is initialized via cxl_dev_context_init() followed by cxl_process_element(), a function that obtains the process element id. Finally, cxl_start_work() is called to attach the process element. In the PowerVM environment, a process element id cannot be obtained from the hypervisor until the process element is attached. The cxlflash module is unable to create contexts without a valid process element id. To fix this problem, cxl_start_work() is called before obtaining the process element id. Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com> Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r--drivers/scsi/cxlflash/superpipe.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c
index 7ec0b7a92876..d8a5cb3cd2bd 100644
--- a/drivers/scsi/cxlflash/superpipe.c
+++ b/drivers/scsi/cxlflash/superpipe.c
@@ -1386,6 +1386,13 @@ static int cxlflash_disk_attach(struct scsi_device *sdev,
1386 goto out_attach; 1386 goto out_attach;
1387 } 1387 }
1388 1388
1389 ctxi = create_context(cfg);
1390 if (unlikely(!ctxi)) {
1391 dev_err(dev, "%s: Failed to create context! (%d)\n",
1392 __func__, ctxid);
1393 goto err;
1394 }
1395
1389 ctx = cxl_dev_context_init(cfg->dev); 1396 ctx = cxl_dev_context_init(cfg->dev);
1390 if (IS_ERR_OR_NULL(ctx)) { 1397 if (IS_ERR_OR_NULL(ctx)) {
1391 dev_err(dev, "%s: Could not initialize context %p\n", 1398 dev_err(dev, "%s: Could not initialize context %p\n",
@@ -1394,6 +1401,17 @@ static int cxlflash_disk_attach(struct scsi_device *sdev,
1394 goto err; 1401 goto err;
1395 } 1402 }
1396 1403
1404 work = &ctxi->work;
1405 work->num_interrupts = attach->num_interrupts;
1406 work->flags = CXL_START_WORK_NUM_IRQS;
1407
1408 rc = cxl_start_work(ctx, work);
1409 if (unlikely(rc)) {
1410 dev_dbg(dev, "%s: Could not start context rc=%d\n",
1411 __func__, rc);
1412 goto err;
1413 }
1414
1397 ctxid = cxl_process_element(ctx); 1415 ctxid = cxl_process_element(ctx);
1398 if (unlikely((ctxid >= MAX_CONTEXT) || (ctxid < 0))) { 1416 if (unlikely((ctxid >= MAX_CONTEXT) || (ctxid < 0))) {
1399 dev_err(dev, "%s: ctxid (%d) invalid!\n", __func__, ctxid); 1417 dev_err(dev, "%s: ctxid (%d) invalid!\n", __func__, ctxid);
@@ -1411,27 +1429,9 @@ static int cxlflash_disk_attach(struct scsi_device *sdev,
1411 /* Translate read/write O_* flags from fcntl.h to AFU permission bits */ 1429 /* Translate read/write O_* flags from fcntl.h to AFU permission bits */
1412 perms = SISL_RHT_PERM(attach->hdr.flags + 1); 1430 perms = SISL_RHT_PERM(attach->hdr.flags + 1);
1413 1431
1414 ctxi = create_context(cfg);
1415 if (unlikely(!ctxi)) {
1416 dev_err(dev, "%s: Failed to create context! (%d)\n",
1417 __func__, ctxid);
1418 goto err;
1419 }
1420
1421 /* Context mutex is locked upon return */ 1432 /* Context mutex is locked upon return */
1422 init_context(ctxi, cfg, ctx, ctxid, fd, file, perms); 1433 init_context(ctxi, cfg, ctx, ctxid, fd, file, perms);
1423 1434
1424 work = &ctxi->work;
1425 work->num_interrupts = attach->num_interrupts;
1426 work->flags = CXL_START_WORK_NUM_IRQS;
1427
1428 rc = cxl_start_work(ctx, work);
1429 if (unlikely(rc)) {
1430 dev_dbg(dev, "%s: Could not start context rc=%d\n",
1431 __func__, rc);
1432 goto err;
1433 }
1434
1435 rc = afu_attach(cfg, ctxi); 1435 rc = afu_attach(cfg, ctxi);
1436 if (unlikely(rc)) { 1436 if (unlikely(rc)) {
1437 dev_err(dev, "%s: Could not attach AFU rc %d\n", __func__, rc); 1437 dev_err(dev, "%s: Could not attach AFU rc %d\n", __func__, rc);
@@ -1532,24 +1532,24 @@ static int recover_context(struct cxlflash_cfg *cfg, struct ctx_info *ctxi)
1532 goto out; 1532 goto out;
1533 } 1533 }
1534 1534
1535 rc = cxl_start_work(ctx, &ctxi->work);
1536 if (unlikely(rc)) {
1537 dev_dbg(dev, "%s: Could not start context rc=%d\n",
1538 __func__, rc);
1539 goto err1;
1540 }
1541
1535 ctxid = cxl_process_element(ctx); 1542 ctxid = cxl_process_element(ctx);
1536 if (unlikely((ctxid >= MAX_CONTEXT) || (ctxid < 0))) { 1543 if (unlikely((ctxid >= MAX_CONTEXT) || (ctxid < 0))) {
1537 dev_err(dev, "%s: ctxid (%d) invalid!\n", __func__, ctxid); 1544 dev_err(dev, "%s: ctxid (%d) invalid!\n", __func__, ctxid);
1538 rc = -EPERM; 1545 rc = -EPERM;
1539 goto err1; 1546 goto err2;
1540 } 1547 }
1541 1548
1542 file = cxl_get_fd(ctx, &cfg->cxl_fops, &fd); 1549 file = cxl_get_fd(ctx, &cfg->cxl_fops, &fd);
1543 if (unlikely(fd < 0)) { 1550 if (unlikely(fd < 0)) {
1544 rc = -ENODEV; 1551 rc = -ENODEV;
1545 dev_err(dev, "%s: Could not get file descriptor\n", __func__); 1552 dev_err(dev, "%s: Could not get file descriptor\n", __func__);
1546 goto err1;
1547 }
1548
1549 rc = cxl_start_work(ctx, &ctxi->work);
1550 if (unlikely(rc)) {
1551 dev_dbg(dev, "%s: Could not start context rc=%d\n",
1552 __func__, rc);
1553 goto err2; 1553 goto err2;
1554 } 1554 }
1555 1555
@@ -1594,10 +1594,10 @@ out:
1594 return rc; 1594 return rc;
1595 1595
1596err3: 1596err3:
1597 cxl_stop_context(ctx);
1598err2:
1599 fput(file); 1597 fput(file);
1600 put_unused_fd(fd); 1598 put_unused_fd(fd);
1599err2:
1600 cxl_stop_context(ctx);
1601err1: 1601err1:
1602 cxl_release_context(ctx); 1602 cxl_release_context(ctx);
1603 goto out; 1603 goto out;