Lines Matching defs:ctxi

131 	struct ctx_info *ctxi;
133 list_for_each_entry(ctxi, &cfg->ctx_err_recovery, list)
134 if ((ctxi->ctxid == rctxid) || (ctxi->file == file))
135 return ctxi;
159 struct ctx_info *ctxi = NULL;
178 ctxi = cfg->ctx_tbl[ctxid];
179 if (ctxi)
180 if ((file && (ctxi->file != file)) ||
181 (!file && (ctxi->ctxid != rctxid)))
182 ctxi = NULL;
185 (!ctxi && (ctx_ctrl & CTX_CTRL_ERR_FALLBACK)))
186 ctxi = find_error_context(cfg, rctxid, file);
187 if (!ctxi) {
200 * cfg->ctx_tbl_list_mutex -> ctxi->mutex
204 rc = mutex_trylock(&ctxi->mutex);
210 if (ctxi->unavail)
213 ctxpid = ctxi->pid;
219 list_for_each_entry(lun_access, &ctxi->luns, list)
228 "ctx_ctrl=%u\n", __func__, rctxid, ctxi, ctxpid, pid,
231 return ctxi;
234 mutex_unlock(&ctxi->mutex);
235 ctxi = NULL;
241 * @ctxi: Context to release.
245 void put_context(struct ctx_info *ctxi)
247 mutex_unlock(&ctxi->mutex);
253 * @ctxi: Context to attach.
261 static int afu_attach(struct cxlflash_cfg *cfg, struct ctx_info *ctxi)
265 struct sisl_ctrl_map __iomem *ctrl_map = ctxi->ctrl_map;
285 for (i = 0; i < ctxi->irqs; i++) {
286 val = cfg->ops->get_irq_objhndl(ctxi->ctx, i);
297 writeq_be((u64)ctxi->rht_start, &ctrl_map->rht_start);
430 * @ctxi: Context owning the resource handle.
436 struct sisl_rht_entry *get_rhte(struct ctx_info *ctxi, res_hndl_t rhndl,
439 struct cxlflash_cfg *cfg = ctxi->cfg;
443 if (unlikely(!ctxi->rht_start)) {
455 if (unlikely(ctxi->rht_lun[rhndl] != lli)) {
461 rhte = &ctxi->rht_start[rhndl];
475 * @ctxi: Context owning the resource handle.
480 struct sisl_rht_entry *rhte_checkout(struct ctx_info *ctxi,
483 struct cxlflash_cfg *cfg = ctxi->cfg;
490 if (ctxi->rht_start[i].nmask == 0) {
491 rhte = &ctxi->rht_start[i];
492 ctxi->rht_out++;
497 ctxi->rht_lun[i] = lli;
505 * @ctxi: Context owning the resource handle.
508 void rhte_checkin(struct ctx_info *ctxi,
511 u32 rsrc_handle = rhte - ctxi->rht_start;
515 ctxi->rht_out--;
516 ctxi->rht_lun[rsrc_handle] = NULL;
517 ctxi->rht_needs_ws[rsrc_handle] = false;
618 * @ctxi: Context owning resources.
631 struct ctx_info *ctxi,
655 if (!ctxi) {
656 ctxi = get_context(cfg, rctxid, lli, CTX_CTRL_ERR_FALLBACK);
657 if (unlikely(!ctxi)) {
667 rhte = get_rhte(ctxi, rhndl, lli);
686 rc = _cxlflash_vlun_resize(sdev, ctxi, &size);
710 if (!ctxi->err_recovery_active) {
722 rhte_checkin(ctxi, rhte);
727 put_context(ctxi);
741 * @ctxi: Context to release.
752 struct ctx_info *ctxi)
756 if (ctxi->initialized) {
757 WARN_ON(!list_empty(&ctxi->luns));
760 if (afu->afu_map && ctxi->ctrl_map) {
761 writeq_be(0, &ctxi->ctrl_map->rht_start);
762 writeq_be(0, &ctxi->ctrl_map->rht_cnt_id);
763 writeq_be(0, &ctxi->ctrl_map->ctx_cap);
768 free_page((ulong)ctxi->rht_start);
769 kfree(ctxi->rht_needs_ws);
770 kfree(ctxi->rht_lun);
771 kfree(ctxi);
783 struct ctx_info *ctxi = NULL;
788 ctxi = kzalloc(sizeof(*ctxi), GFP_KERNEL);
791 if (unlikely(!ctxi || !lli || !ws)) {
802 ctxi->rht_lun = lli;
803 ctxi->rht_needs_ws = ws;
804 ctxi->rht_start = rhte;
806 return ctxi;
811 kfree(ctxi);
812 ctxi = NULL;
818 * @ctxi: Previously allocated context
826 static void init_context(struct ctx_info *ctxi, struct cxlflash_cfg *cfg,
832 ctxi->rht_perms = perms;
833 ctxi->ctrl_map = &afu->afu_map->ctrls[ctxid].ctrl;
834 ctxi->ctxid = ENCODE_CTXID(ctxi, ctxid);
835 ctxi->irqs = irqs;
836 ctxi->pid = task_tgid_nr(current); /* tgid = pid */
837 ctxi->ctx = ctx;
838 ctxi->cfg = cfg;
839 ctxi->file = file;
840 ctxi->initialized = true;
841 mutex_init(&ctxi->mutex);
842 kref_init(&ctxi->kref);
843 INIT_LIST_HEAD(&ctxi->luns);
844 INIT_LIST_HEAD(&ctxi->list); /* initialize for list_empty() */
857 struct ctx_info *ctxi = container_of(kref, struct ctx_info, kref);
858 struct cxlflash_cfg *cfg = ctxi->cfg;
859 u64 ctxid = DECODE_CTXID(ctxi->ctxid);
862 WARN_ON(!mutex_is_locked(&ctxi->mutex));
863 ctxi->unavail = true;
864 mutex_unlock(&ctxi->mutex);
866 mutex_lock(&ctxi->mutex);
868 if (!list_empty(&ctxi->list))
869 list_del(&ctxi->list);
872 mutex_unlock(&ctxi->mutex);
875 destroy_context(cfg, ctxi);
881 * @ctxi: Context owning resources.
891 struct ctx_info *ctxi,
908 if (!ctxi) {
909 ctxi = get_context(cfg, rctxid, lli, CTX_CTRL_ERR_FALLBACK);
910 if (unlikely(!ctxi)) {
921 if (ctxi->rht_out) {
924 if (ctxi->rht_lun[i] == lli) {
926 _cxlflash_disk_release(sdev, ctxi, &rel);
930 if (ctxi->rht_out == 0)
936 list_for_each_entry_safe(lun_access, t, &ctxi->luns, list)
948 if (kref_put(&ctxi->kref, remove_context))
953 put_context(ctxi);
996 struct ctx_info *ctxi = NULL;
1009 ctxi = get_context(cfg, ctxid, file, ctrl);
1010 if (unlikely(!ctxi)) {
1011 ctxi = get_context(cfg, ctxid, file, ctrl | CTX_CTRL_CLONE);
1012 if (!ctxi) {
1020 put_context(ctxi);
1027 detach.context_id = ctxi->ctxid;
1028 list_for_each_entry_safe(lun_access, t, &ctxi->luns, list)
1029 _cxlflash_disk_detach(lun_access->sdev, ctxi, &detach);
1040 * @ctxi: Context owning the mapping.
1046 static void unmap_context(struct ctx_info *ctxi)
1048 unmap_mapping_range(ctxi->file->f_mapping, 0, 0, 1);
1111 struct ctx_info *ctxi = NULL;
1124 ctxi = get_context(cfg, ctxid, file, ctrl);
1125 if (unlikely(!ctxi)) {
1132 if (likely(!ctxi->err_recovery_active)) {
1134 rc = ctxi->cxl_mmap_vmops->fault(vmf);
1152 if (likely(ctxi))
1153 put_context(ctxi);
1184 struct ctx_info *ctxi = NULL;
1197 ctxi = get_context(cfg, ctxid, file, ctrl);
1198 if (unlikely(!ctxi)) {
1209 ctxi->cxl_mmap_vmops = vma->vm_ops;
1214 if (likely(ctxi))
1215 put_context(ctxi);
1237 struct ctx_info *ctxi = NULL;
1242 ctxi = cfg->ctx_tbl[i];
1243 if (ctxi) {
1244 mutex_lock(&ctxi->mutex);
1246 list_add(&ctxi->list, &cfg->ctx_err_recovery);
1247 ctxi->err_recovery_active = true;
1248 ctxi->ctrl_map = NULL;
1249 unmap_context(ctxi);
1250 mutex_unlock(&ctxi->mutex);
1325 struct ctx_info *ctxi = NULL;
1362 ctxi = get_context(cfg, rctxid, NULL, 0);
1363 if (!ctxi) {
1370 list_for_each_entry(lun_access, &ctxi->luns, list)
1396 if (ctxi) {
1399 kref_get(&ctxi->kref);
1400 list_add(&lun_access->list, &ctxi->luns);
1404 ctxi = create_context(cfg);
1405 if (unlikely(!ctxi)) {
1445 init_context(ctxi, cfg, ctx, ctxid, file, perms, irqs);
1447 rc = afu_attach(cfg, ctxi);
1459 list_add(&lun_access->list, &ctxi->luns);
1461 mutex_lock(&ctxi->mutex);
1462 cfg->ctx_tbl[ctxid] = ctxi;
1473 attach->context_id = ctxi->ctxid;
1483 if (ctxi)
1484 put_context(ctxi);
1514 if (ctxi) {
1515 destroy_context(cfg, ctxi);
1516 ctxi = NULL;
1527 * @ctxi: Context to release.
1535 struct ctx_info *ctxi,
1554 rc = cfg->ops->start_work(ctx, ctxi->irqs);
1576 ctxi->ctrl_map = &afu->afu_map->ctrls[ctxid].ctrl;
1578 rc = afu_attach(cfg, ctxi);
1588 ctxi->ctxid = ENCODE_CTXID(ctxi, ctxid);
1589 ctxi->ctx = ctx;
1590 ctxi->file = file;
1598 mutex_unlock(&ctxi->mutex);
1600 mutex_lock(&ctxi->mutex);
1601 list_del_init(&ctxi->list);
1602 cfg->ctx_tbl[ctxid] = ctxi;
1658 struct ctx_info *ctxi = NULL;
1691 ctxi = get_context(cfg, rctxid, lli, CTX_CTRL_ERR_FALLBACK);
1692 if (unlikely(!ctxi)) {
1698 if (ctxi->err_recovery_active) {
1700 rc = recover_context(cfg, ctxi, &new_adap_fd);
1722 ctxi->err_recovery_active = false;
1730 recover->context_id = ctxi->ctxid;
1746 put_context(ctxi);
1747 ctxi = NULL;
1757 if (likely(ctxi))
1758 put_context(ctxi);
1840 struct ctx_info *ctxi = NULL;
1855 ctxi = get_context(cfg, rctxid, lli, 0);
1856 if (unlikely(!ctxi)) {
1862 rhte = get_rhte(ctxi, rhndl, lli);
1878 ctxi->unavail = true;
1879 mutex_unlock(&ctxi->mutex);
1884 mutex_lock(&ctxi->mutex);
1885 ctxi->unavail = false;
1888 mutex_lock(&ctxi->mutex);
1889 ctxi->unavail = false;
1909 if (likely(ctxi))
1910 put_context(ctxi);
1981 struct ctx_info *ctxi = NULL;
1992 ctxi = get_context(cfg, rctxid, lli, 0);
1993 if (unlikely(!ctxi)) {
1999 rhte = rhte_checkout(ctxi, lli);
2007 rsrc_handle = (rhte - ctxi->rht_start);
2009 rht_format1(rhte, lli->lun_id[sdev->channel], ctxi->rht_perms, port);
2023 if (likely(ctxi))
2024 put_context(ctxi);
2031 _cxlflash_disk_release(sdev, ctxi, &rel);