aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew R. Ochs <mrochs@linux.vnet.ibm.com>2016-08-09 19:40:02 -0400
committerMartin K. Petersen <martin.petersen@oracle.com>2016-08-23 22:23:52 -0400
commitde9f0b0cbb86da288a2d38e35f2953a85608a6aa (patch)
tree30f55608f137d2469ba4688207f4c690f7fc3720
parentcd34af40a09c678abad36304eb68e1774640e908 (diff)
scsi: cxlflash: Remove adapter file descriptor cache
The adapter file descriptor was previously cached within the kernel for a given context in order to support performing a close on behalf of an application. This is no longer needed as applications are now required to perform a close on the adapter file descriptor. Inspired-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com> Acked-by: Manoj N. Kumar <manoj@linux.vnet.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r--drivers/scsi/cxlflash/superpipe.c26
-rw-r--r--drivers/scsi/cxlflash/superpipe.h1
2 files changed, 13 insertions, 14 deletions
diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c
index b3bb90df4e1f..c91fe6fe8d08 100644
--- a/drivers/scsi/cxlflash/superpipe.c
+++ b/drivers/scsi/cxlflash/superpipe.c
@@ -788,20 +788,18 @@ err:
788 * @cfg: Internal structure associated with the host. 788 * @cfg: Internal structure associated with the host.
789 * @ctx: Previously obtained CXL context reference. 789 * @ctx: Previously obtained CXL context reference.
790 * @ctxid: Previously obtained process element associated with CXL context. 790 * @ctxid: Previously obtained process element associated with CXL context.
791 * @adap_fd: Previously obtained adapter fd associated with CXL context.
792 * @file: Previously obtained file associated with CXL context. 791 * @file: Previously obtained file associated with CXL context.
793 * @perms: User-specified permissions. 792 * @perms: User-specified permissions.
794 */ 793 */
795static void init_context(struct ctx_info *ctxi, struct cxlflash_cfg *cfg, 794static void init_context(struct ctx_info *ctxi, struct cxlflash_cfg *cfg,
796 struct cxl_context *ctx, int ctxid, int adap_fd, 795 struct cxl_context *ctx, int ctxid, struct file *file,
797 struct file *file, u32 perms) 796 u32 perms)
798{ 797{
799 struct afu *afu = cfg->afu; 798 struct afu *afu = cfg->afu;
800 799
801 ctxi->rht_perms = perms; 800 ctxi->rht_perms = perms;
802 ctxi->ctrl_map = &afu->afu_map->ctrls[ctxid].ctrl; 801 ctxi->ctrl_map = &afu->afu_map->ctrls[ctxid].ctrl;
803 ctxi->ctxid = ENCODE_CTXID(ctxi, ctxid); 802 ctxi->ctxid = ENCODE_CTXID(ctxi, ctxid);
804 ctxi->lfd = adap_fd;
805 ctxi->pid = current->tgid; /* tgid = pid */ 803 ctxi->pid = current->tgid; /* tgid = pid */
806 ctxi->ctx = ctx; 804 ctxi->ctx = ctx;
807 ctxi->cfg = cfg; 805 ctxi->cfg = cfg;
@@ -1086,8 +1084,7 @@ static int cxlflash_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
1086 goto err; 1084 goto err;
1087 } 1085 }
1088 1086
1089 dev_dbg(dev, "%s: fault(%d) for context %d\n", 1087 dev_dbg(dev, "%s: fault for context %d\n", __func__, ctxid);
1090 __func__, ctxi->lfd, ctxid);
1091 1088
1092 if (likely(!ctxi->err_recovery_active)) { 1089 if (likely(!ctxi->err_recovery_active)) {
1093 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 1090 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
@@ -1162,8 +1159,7 @@ static int cxlflash_cxl_mmap(struct file *file, struct vm_area_struct *vma)
1162 goto out; 1159 goto out;
1163 } 1160 }
1164 1161
1165 dev_dbg(dev, "%s: mmap(%d) for context %d\n", 1162 dev_dbg(dev, "%s: mmap for context %d\n", __func__, ctxid);
1166 __func__, ctxi->lfd, ctxid);
1167 1163
1168 rc = cxl_fd_mmap(file, vma); 1164 rc = cxl_fd_mmap(file, vma);
1169 if (likely(!rc)) { 1165 if (likely(!rc)) {
@@ -1406,7 +1402,7 @@ static int cxlflash_disk_attach(struct scsi_device *sdev,
1406 perms = SISL_RHT_PERM(attach->hdr.flags + 1); 1402 perms = SISL_RHT_PERM(attach->hdr.flags + 1);
1407 1403
1408 /* Context mutex is locked upon return */ 1404 /* Context mutex is locked upon return */
1409 init_context(ctxi, cfg, ctx, ctxid, fd, file, perms); 1405 init_context(ctxi, cfg, ctx, ctxid, file, perms);
1410 1406
1411 rc = afu_attach(cfg, ctxi); 1407 rc = afu_attach(cfg, ctxi);
1412 if (unlikely(rc)) { 1408 if (unlikely(rc)) {
@@ -1488,12 +1484,15 @@ err:
1488 * recover_context() - recovers a context in error 1484 * recover_context() - recovers a context in error
1489 * @cfg: Internal structure associated with the host. 1485 * @cfg: Internal structure associated with the host.
1490 * @ctxi: Context to release. 1486 * @ctxi: Context to release.
1487 * @adap_fd: Adapter file descriptor associated with new/recovered context.
1491 * 1488 *
1492 * Restablishes the state for a context-in-error. 1489 * Restablishes the state for a context-in-error.
1493 * 1490 *
1494 * Return: 0 on success, -errno on failure 1491 * Return: 0 on success, -errno on failure
1495 */ 1492 */
1496static int recover_context(struct cxlflash_cfg *cfg, struct ctx_info *ctxi) 1493static int recover_context(struct cxlflash_cfg *cfg,
1494 struct ctx_info *ctxi,
1495 int *adap_fd)
1497{ 1496{
1498 struct device *dev = &cfg->dev->dev; 1497 struct device *dev = &cfg->dev->dev;
1499 int rc = 0; 1498 int rc = 0;
@@ -1546,7 +1545,6 @@ static int recover_context(struct cxlflash_cfg *cfg, struct ctx_info *ctxi)
1546 * visible to user space and can't be undone safely on this thread. 1545 * visible to user space and can't be undone safely on this thread.
1547 */ 1546 */
1548 ctxi->ctxid = ENCODE_CTXID(ctxi, ctxid); 1547 ctxi->ctxid = ENCODE_CTXID(ctxi, ctxid);
1549 ctxi->lfd = fd;
1550 ctxi->ctx = ctx; 1548 ctxi->ctx = ctx;
1551 ctxi->file = file; 1549 ctxi->file = file;
1552 1550
@@ -1563,6 +1561,7 @@ static int recover_context(struct cxlflash_cfg *cfg, struct ctx_info *ctxi)
1563 cfg->ctx_tbl[ctxid] = ctxi; 1561 cfg->ctx_tbl[ctxid] = ctxi;
1564 mutex_unlock(&cfg->ctx_tbl_list_mutex); 1562 mutex_unlock(&cfg->ctx_tbl_list_mutex);
1565 fd_install(fd, file); 1563 fd_install(fd, file);
1564 *adap_fd = fd;
1566out: 1565out:
1567 dev_dbg(dev, "%s: returning ctxid=%d fd=%d rc=%d\n", 1566 dev_dbg(dev, "%s: returning ctxid=%d fd=%d rc=%d\n",
1568 __func__, ctxid, fd, rc); 1567 __func__, ctxid, fd, rc);
@@ -1621,6 +1620,7 @@ static int cxlflash_afu_recover(struct scsi_device *sdev,
1621 rctxid = recover->context_id; 1620 rctxid = recover->context_id;
1622 long reg; 1621 long reg;
1623 int lretry = 20; /* up to 2 seconds */ 1622 int lretry = 20; /* up to 2 seconds */
1623 int new_adap_fd = -1;
1624 int rc = 0; 1624 int rc = 0;
1625 1625
1626 atomic_inc(&cfg->recovery_threads); 1626 atomic_inc(&cfg->recovery_threads);
@@ -1650,7 +1650,7 @@ retry:
1650 1650
1651 if (ctxi->err_recovery_active) { 1651 if (ctxi->err_recovery_active) {
1652retry_recover: 1652retry_recover:
1653 rc = recover_context(cfg, ctxi); 1653 rc = recover_context(cfg, ctxi, &new_adap_fd);
1654 if (unlikely(rc)) { 1654 if (unlikely(rc)) {
1655 dev_err(dev, "%s: Recovery failed for context %llu (rc=%d)\n", 1655 dev_err(dev, "%s: Recovery failed for context %llu (rc=%d)\n",
1656 __func__, ctxid, rc); 1656 __func__, ctxid, rc);
@@ -1672,7 +1672,7 @@ retry_recover:
1672 1672
1673 ctxi->err_recovery_active = false; 1673 ctxi->err_recovery_active = false;
1674 recover->context_id = ctxi->ctxid; 1674 recover->context_id = ctxi->ctxid;
1675 recover->adap_fd = ctxi->lfd; 1675 recover->adap_fd = new_adap_fd;
1676 recover->mmio_size = sizeof(afu->afu_map->hosts[0].harea); 1676 recover->mmio_size = sizeof(afu->afu_map->hosts[0].harea);
1677 recover->hdr.return_flags = DK_CXLFLASH_APP_CLOSE_ADAP_FD | 1677 recover->hdr.return_flags = DK_CXLFLASH_APP_CLOSE_ADAP_FD |
1678 DK_CXLFLASH_RECOVER_AFU_CONTEXT_RESET; 1678 DK_CXLFLASH_RECOVER_AFU_CONTEXT_RESET;
diff --git a/drivers/scsi/cxlflash/superpipe.h b/drivers/scsi/cxlflash/superpipe.h
index 5bda8b5758d5..9e62ff304e4b 100644
--- a/drivers/scsi/cxlflash/superpipe.h
+++ b/drivers/scsi/cxlflash/superpipe.h
@@ -100,7 +100,6 @@ struct ctx_info {
100 100
101 struct cxl_ioctl_start_work work; 101 struct cxl_ioctl_start_work work;
102 u64 ctxid; 102 u64 ctxid;
103 int lfd;
104 pid_t pid; 103 pid_t pid;
105 bool initialized; 104 bool initialized;
106 bool unavail; 105 bool unavail;