Lines Matching refs:cfg

82 void cxlflash_stop_term_user_contexts(struct cxlflash_cfg *cfg)  in cxlflash_stop_term_user_contexts()  argument
84 struct device *dev = &cfg->dev->dev; in cxlflash_stop_term_user_contexts()
87 cxlflash_mark_contexts_error(cfg); in cxlflash_stop_term_user_contexts()
93 if (cfg->ctx_tbl[i]) { in cxlflash_stop_term_user_contexts()
98 if (!found && list_empty(&cfg->ctx_err_recovery)) in cxlflash_stop_term_user_contexts()
103 wake_up_all(&cfg->reset_waitq); in cxlflash_stop_term_user_contexts()
116 static struct ctx_info *find_error_context(struct cxlflash_cfg *cfg, u64 rctxid, in find_error_context() argument
121 list_for_each_entry(ctxi, &cfg->ctx_err_recovery, list) in find_error_context()
143 struct ctx_info *get_context(struct cxlflash_cfg *cfg, u64 rctxid, in get_context() argument
146 struct device *dev = &cfg->dev->dev; in get_context()
165 mutex_lock(&cfg->ctx_tbl_list_mutex); in get_context()
166 ctxi = cfg->ctx_tbl[ctxid]; in get_context()
174 ctxi = find_error_context(cfg, rctxid, file); in get_context()
176 mutex_unlock(&cfg->ctx_tbl_list_mutex); in get_context()
193 mutex_unlock(&cfg->ctx_tbl_list_mutex); in get_context()
249 static int afu_attach(struct cxlflash_cfg *cfg, struct ctx_info *ctxi) in afu_attach() argument
251 struct device *dev = &cfg->dev->dev; in afu_attach()
252 struct afu *afu = cfg->afu; in afu_attach()
305 struct cxlflash_cfg *cfg = (struct cxlflash_cfg *)sdev->host->hostdata; in read_cap16() local
306 struct device *dev = &cfg->dev->dev; in read_cap16()
333 up_read(&cfg->ioctl_rwsem); in read_cap16()
336 down_read(&cfg->ioctl_rwsem); in read_cap16()
337 rc = check_state(cfg); in read_cap16()
608 struct cxlflash_cfg *cfg = (struct cxlflash_cfg *)sdev->host->hostdata; in _cxlflash_disk_release() local
609 struct device *dev = &cfg->dev->dev; in _cxlflash_disk_release()
612 struct afu *afu = cfg->afu; in _cxlflash_disk_release()
629 ctxi = get_context(cfg, rctxid, lli, CTX_CTRL_ERR_FALLBACK); in _cxlflash_disk_release()
721 static void destroy_context(struct cxlflash_cfg *cfg, in destroy_context() argument
724 struct afu *afu = cfg->afu; in destroy_context()
755 static struct ctx_info *create_context(struct cxlflash_cfg *cfg, in create_context() argument
760 struct device *dev = &cfg->dev->dev; in create_context()
761 struct afu *afu = cfg->afu; in create_context()
824 struct cxlflash_cfg *cfg = (struct cxlflash_cfg *)sdev->host->hostdata; in _cxlflash_disk_detach() local
825 struct device *dev = &cfg->dev->dev; in _cxlflash_disk_detach()
840 ctxi = get_context(cfg, rctxid, lli, CTX_CTRL_ERR_FALLBACK); in _cxlflash_disk_detach()
879 mutex_lock(&cfg->ctx_tbl_list_mutex); in _cxlflash_disk_detach()
885 cfg->ctx_tbl[ctxid] = NULL; in _cxlflash_disk_detach()
886 mutex_unlock(&cfg->ctx_tbl_list_mutex); in _cxlflash_disk_detach()
890 destroy_context(cfg, ctxi); in _cxlflash_disk_detach()
963 struct cxlflash_cfg *cfg = container_of(file->f_op, struct cxlflash_cfg, in cxlflash_cxl_release() local
965 struct device *dev = &cfg->dev->dev; in cxlflash_cxl_release()
979 ctxi = get_context(cfg, ctxid, file, ctrl); in cxlflash_cxl_release()
981 ctxi = get_context(cfg, ctxid, file, ctrl | CTX_CTRL_CLONE); in cxlflash_cxl_release()
1076 struct cxlflash_cfg *cfg = container_of(file->f_op, struct cxlflash_cfg, in cxlflash_mmap_fault() local
1078 struct device *dev = &cfg->dev->dev; in cxlflash_mmap_fault()
1092 ctxi = get_context(cfg, ctxid, file, ctrl); in cxlflash_mmap_fault()
1151 struct cxlflash_cfg *cfg = container_of(file->f_op, struct cxlflash_cfg, in cxlflash_cxl_mmap() local
1153 struct device *dev = &cfg->dev->dev; in cxlflash_cxl_mmap()
1167 ctxi = get_context(cfg, ctxid, file, ctrl); in cxlflash_cxl_mmap()
1205 int cxlflash_mark_contexts_error(struct cxlflash_cfg *cfg) in cxlflash_mark_contexts_error() argument
1210 mutex_lock(&cfg->ctx_tbl_list_mutex); in cxlflash_mark_contexts_error()
1213 ctxi = cfg->ctx_tbl[i]; in cxlflash_mark_contexts_error()
1216 cfg->ctx_tbl[i] = NULL; in cxlflash_mark_contexts_error()
1217 list_add(&ctxi->list, &cfg->ctx_err_recovery); in cxlflash_mark_contexts_error()
1225 mutex_unlock(&cfg->ctx_tbl_list_mutex); in cxlflash_mark_contexts_error()
1249 int check_state(struct cxlflash_cfg *cfg) in check_state() argument
1251 struct device *dev = &cfg->dev->dev; in check_state()
1255 switch (cfg->state) { in check_state()
1258 up_read(&cfg->ioctl_rwsem); in check_state()
1259 rc = wait_event_interruptible(cfg->reset_waitq, in check_state()
1260 cfg->state != STATE_RESET); in check_state()
1261 down_read(&cfg->ioctl_rwsem); in check_state()
1291 struct cxlflash_cfg *cfg = (struct cxlflash_cfg *)sdev->host->hostdata; in cxlflash_disk_attach() local
1292 struct device *dev = &cfg->dev->dev; in cxlflash_disk_attach()
1293 struct afu *afu = cfg->afu; in cxlflash_disk_attach()
1332 ctxi = get_context(cfg, rctxid, NULL, 0); in cxlflash_disk_attach()
1374 ctx = cxl_dev_context_init(cfg->dev); in cxlflash_disk_attach()
1389 file = cxl_get_fd(ctx, &cfg->cxl_fops, &fd); in cxlflash_disk_attach()
1399 ctxi = create_context(cfg, ctx, ctxid, fd, file, perms); in cxlflash_disk_attach()
1417 rc = afu_attach(cfg, ctxi); in cxlflash_disk_attach()
1431 mutex_lock(&cfg->ctx_tbl_list_mutex); in cxlflash_disk_attach()
1433 cfg->ctx_tbl[ctxid] = ctxi; in cxlflash_disk_attach()
1434 mutex_unlock(&cfg->ctx_tbl_list_mutex); in cxlflash_disk_attach()
1460 destroy_context(cfg, ctxi); in cxlflash_disk_attach()
1492 static int recover_context(struct cxlflash_cfg *cfg, struct ctx_info *ctxi) in recover_context() argument
1494 struct device *dev = &cfg->dev->dev; in recover_context()
1500 struct afu *afu = cfg->afu; in recover_context()
1502 ctx = cxl_dev_context_init(cfg->dev); in recover_context()
1517 file = cxl_get_fd(ctx, &cfg->cxl_fops, &fd); in recover_context()
1534 rc = afu_attach(cfg, ctxi); in recover_context()
1557 mutex_lock(&cfg->ctx_tbl_list_mutex); in recover_context()
1560 cfg->ctx_tbl[ctxid] = ctxi; in recover_context()
1561 mutex_unlock(&cfg->ctx_tbl_list_mutex); in recover_context()
1607 struct cxlflash_cfg *cfg = (struct cxlflash_cfg *)sdev->host->hostdata; in cxlflash_afu_recover() local
1608 struct device *dev = &cfg->dev->dev; in cxlflash_afu_recover()
1610 struct afu *afu = cfg->afu; in cxlflash_afu_recover()
1612 struct mutex *mutex = &cfg->ctx_recovery_mutex; in cxlflash_afu_recover()
1619 atomic_inc(&cfg->recovery_threads); in cxlflash_afu_recover()
1629 ctxi = get_context(cfg, rctxid, lli, CTX_CTRL_ERR_FALLBACK); in cxlflash_afu_recover()
1638 rc = recover_context(cfg, ctxi); in cxlflash_afu_recover()
1643 ((atomic_read(&cfg->recovery_threads) > 1) || in cxlflash_afu_recover()
1680 rc = check_state(cfg); in cxlflash_afu_recover()
1691 atomic_dec_if_positive(&cfg->recovery_threads); in cxlflash_afu_recover()
1705 struct cxlflash_cfg *cfg = (struct cxlflash_cfg *)sdev->host->hostdata; in process_sense() local
1706 struct device *dev = &cfg->dev->dev; in process_sense()
1743 scsi_scan_host(cfg->host); in process_sense()
1772 struct cxlflash_cfg *cfg = (struct cxlflash_cfg *)sdev->host->hostdata; in cxlflash_disk_verify() local
1773 struct device *dev = &cfg->dev->dev; in cxlflash_disk_verify()
1786 ctxi = get_context(cfg, rctxid, lli, 0); in cxlflash_disk_verify()
1894 struct cxlflash_cfg *cfg = (struct cxlflash_cfg *)sdev->host->hostdata; in cxlflash_disk_direct_open() local
1895 struct device *dev = &cfg->dev->dev; in cxlflash_disk_direct_open()
1896 struct afu *afu = cfg->afu; in cxlflash_disk_direct_open()
1923 ctxi = get_context(cfg, rctxid, lli, 0); in cxlflash_disk_direct_open()
1972 struct cxlflash_cfg *cfg = (struct cxlflash_cfg *)sdev->host->hostdata; in ioctl_common() local
1973 struct device *dev = &cfg->dev->dev; in ioctl_common()
1983 rc = check_state(cfg); in ioctl_common()
1984 if (unlikely(rc) && (cfg->state == STATE_FAILTERM)) { in ioctl_common()
2019 struct cxlflash_cfg *cfg = (struct cxlflash_cfg *)sdev->host->hostdata; in cxlflash_ioctl() local
2020 struct device *dev = &cfg->dev->dev; in cxlflash_ioctl()
2021 struct afu *afu = cfg->afu; in cxlflash_ioctl()
2048 down_read(&cfg->ioctl_rwsem); in cxlflash_ioctl()
2131 up_read(&cfg->ioctl_rwsem); in cxlflash_ioctl()