superpipe.c (b070545db112e4c815fbfce25449495eff20c170) superpipe.c (af2047ec00bfd61b46b653e856dcf1e0bc567619)
1/*
2 * CXL Flash Device Driver
3 *
4 * Written by: Manoj N. Kumar <manoj@linux.vnet.ibm.com>, IBM Corporation
5 * Matthew R. Ochs <mrochs@linux.vnet.ibm.com>, IBM Corporation
6 *
7 * Copyright (C) 2015 IBM Corporation
8 *

--- 800 unchanged lines hidden (view full) ---

809/**
810 * init_context() - initializes a previously allocated context
811 * @ctxi: Previously allocated context
812 * @cfg: Internal structure associated with the host.
813 * @ctx: Previously obtained context cookie.
814 * @ctxid: Previously obtained process element associated with CXL context.
815 * @file: Previously obtained file associated with CXL context.
816 * @perms: User-specified permissions.
1/*
2 * CXL Flash Device Driver
3 *
4 * Written by: Manoj N. Kumar <manoj@linux.vnet.ibm.com>, IBM Corporation
5 * Matthew R. Ochs <mrochs@linux.vnet.ibm.com>, IBM Corporation
6 *
7 * Copyright (C) 2015 IBM Corporation
8 *

--- 800 unchanged lines hidden (view full) ---

809/**
810 * init_context() - initializes a previously allocated context
811 * @ctxi: Previously allocated context
812 * @cfg: Internal structure associated with the host.
813 * @ctx: Previously obtained context cookie.
814 * @ctxid: Previously obtained process element associated with CXL context.
815 * @file: Previously obtained file associated with CXL context.
816 * @perms: User-specified permissions.
817 * @irqs: User-specified number of interrupts.
817 */
818static void init_context(struct ctx_info *ctxi, struct cxlflash_cfg *cfg,
818 */
819static void init_context(struct ctx_info *ctxi, struct cxlflash_cfg *cfg,
819 void *ctx, int ctxid, struct file *file, u32 perms)
820 void *ctx, int ctxid, struct file *file, u32 perms,
821 u64 irqs)
820{
821 struct afu *afu = cfg->afu;
822
823 ctxi->rht_perms = perms;
824 ctxi->ctrl_map = &afu->afu_map->ctrls[ctxid].ctrl;
825 ctxi->ctxid = ENCODE_CTXID(ctxi, ctxid);
822{
823 struct afu *afu = cfg->afu;
824
825 ctxi->rht_perms = perms;
826 ctxi->ctrl_map = &afu->afu_map->ctrls[ctxid].ctrl;
827 ctxi->ctxid = ENCODE_CTXID(ctxi, ctxid);
828 ctxi->irqs = irqs;
826 ctxi->pid = task_tgid_nr(current); /* tgid = pid */
827 ctxi->ctx = ctx;
828 ctxi->cfg = cfg;
829 ctxi->file = file;
830 ctxi->initialized = true;
831 mutex_init(&ctxi->mutex);
832 kref_init(&ctxi->kref);
833 INIT_LIST_HEAD(&ctxi->luns);

--- 473 unchanged lines hidden (view full) ---

1307 struct llun_info *lli = sdev->hostdata;
1308 struct glun_info *gli = lli->parent;
1309 struct cxl_ioctl_start_work *work;
1310 struct ctx_info *ctxi = NULL;
1311 struct lun_access *lun_access = NULL;
1312 int rc = 0;
1313 u32 perms;
1314 int ctxid = -1;
829 ctxi->pid = task_tgid_nr(current); /* tgid = pid */
830 ctxi->ctx = ctx;
831 ctxi->cfg = cfg;
832 ctxi->file = file;
833 ctxi->initialized = true;
834 mutex_init(&ctxi->mutex);
835 kref_init(&ctxi->kref);
836 INIT_LIST_HEAD(&ctxi->luns);

--- 473 unchanged lines hidden (view full) ---

1310 struct llun_info *lli = sdev->hostdata;
1311 struct glun_info *gli = lli->parent;
1312 struct cxl_ioctl_start_work *work;
1313 struct ctx_info *ctxi = NULL;
1314 struct lun_access *lun_access = NULL;
1315 int rc = 0;
1316 u32 perms;
1317 int ctxid = -1;
1318 u64 irqs = attach->num_interrupts;
1315 u64 flags = 0UL;
1316 u64 rctxid = 0UL;
1317 struct file *file = NULL;
1318
1319 void *ctx = NULL;
1320
1321 int fd = -1;
1322
1319 u64 flags = 0UL;
1320 u64 rctxid = 0UL;
1321 struct file *file = NULL;
1322
1323 void *ctx = NULL;
1324
1325 int fd = -1;
1326
1323 if (attach->num_interrupts > 4) {
1327 if (irqs > 4) {
1324 dev_dbg(dev, "%s: Cannot support this many interrupts %llu\n",
1328 dev_dbg(dev, "%s: Cannot support this many interrupts %llu\n",
1325 __func__, attach->num_interrupts);
1329 __func__, irqs);
1326 rc = -EINVAL;
1327 goto out;
1328 }
1329
1330 if (gli->max_lba == 0) {
1331 dev_dbg(dev, "%s: No capacity info for LUN=%016llx\n",
1332 __func__, lli->lun_id[sdev->channel]);
1333 rc = read_cap16(sdev, lli);

--- 63 unchanged lines hidden (view full) ---

1397 if (IS_ERR_OR_NULL(ctx)) {
1398 dev_err(dev, "%s: Could not initialize context %p\n",
1399 __func__, ctx);
1400 rc = -ENODEV;
1401 goto err;
1402 }
1403
1404 work = &ctxi->work;
1330 rc = -EINVAL;
1331 goto out;
1332 }
1333
1334 if (gli->max_lba == 0) {
1335 dev_dbg(dev, "%s: No capacity info for LUN=%016llx\n",
1336 __func__, lli->lun_id[sdev->channel]);
1337 rc = read_cap16(sdev, lli);

--- 63 unchanged lines hidden (view full) ---

1401 if (IS_ERR_OR_NULL(ctx)) {
1402 dev_err(dev, "%s: Could not initialize context %p\n",
1403 __func__, ctx);
1404 rc = -ENODEV;
1405 goto err;
1406 }
1407
1408 work = &ctxi->work;
1405 work->num_interrupts = attach->num_interrupts;
1409 work->num_interrupts = irqs;
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 }

--- 11 unchanged lines hidden (view full) ---

1425 dev_err(dev, "%s: Could not get file descriptor\n", __func__);
1426 goto err;
1427 }
1428
1429 /* Translate read/write O_* flags from fcntl.h to AFU permission bits */
1430 perms = SISL_RHT_PERM(attach->hdr.flags + 1);
1431
1432 /* Context mutex is locked upon return */
1410 work->flags = CXL_START_WORK_NUM_IRQS;
1411
1412 rc = cxl_start_work(ctx, work);
1413 if (unlikely(rc)) {
1414 dev_dbg(dev, "%s: Could not start context rc=%d\n",
1415 __func__, rc);
1416 goto err;
1417 }

--- 11 unchanged lines hidden (view full) ---

1429 dev_err(dev, "%s: Could not get file descriptor\n", __func__);
1430 goto err;
1431 }
1432
1433 /* Translate read/write O_* flags from fcntl.h to AFU permission bits */
1434 perms = SISL_RHT_PERM(attach->hdr.flags + 1);
1435
1436 /* Context mutex is locked upon return */
1433 init_context(ctxi, cfg, ctx, ctxid, file, perms);
1437 init_context(ctxi, cfg, ctx, ctxid, file, perms, irqs);
1434
1435 rc = afu_attach(cfg, ctxi);
1436 if (unlikely(rc)) {
1437 dev_err(dev, "%s: Could not attach AFU rc %d\n", __func__, rc);
1438 goto err;
1439 }
1440
1441 /*

--- 770 unchanged lines hidden ---
1438
1439 rc = afu_attach(cfg, ctxi);
1440 if (unlikely(rc)) {
1441 dev_err(dev, "%s: Could not attach AFU rc %d\n", __func__, rc);
1442 goto err;
1443 }
1444
1445 /*

--- 770 unchanged lines hidden ---