Lines Matching full:cfg
50 struct cxlflash_cfg *cfg = afu->parent; in process_cmd_err() local
51 struct device *dev = &cfg->dev->dev; in process_cmd_err()
162 struct cxlflash_cfg *cfg = afu->parent; in cmd_complete() local
163 struct device *dev = &cfg->dev->dev; in cmd_complete()
181 spin_lock_irqsave(&cfg->tmf_slock, lock_flags); in cmd_complete()
182 cfg->tmf_active = false; in cmd_complete()
183 wake_up_all_locked(&cfg->tmf_waitq); in cmd_complete()
184 spin_unlock_irqrestore(&cfg->tmf_slock, lock_flags); in cmd_complete()
198 struct cxlflash_cfg *cfg = hwq->afu->parent; in flush_pending_cmds() local
218 spin_lock_irqsave(&cfg->tmf_slock, lock_flags); in flush_pending_cmds()
219 cfg->tmf_active = false; in flush_pending_cmds()
220 wake_up_all_locked(&cfg->tmf_waitq); in flush_pending_cmds()
221 spin_unlock_irqrestore(&cfg->tmf_slock, in flush_pending_cmds()
242 struct cxlflash_cfg *cfg = hwq->afu->parent; in context_reset() local
243 struct device *dev = &cfg->dev->dev; in context_reset()
307 struct cxlflash_cfg *cfg = afu->parent; in send_cmd_ioarrin() local
308 struct device *dev = &cfg->dev->dev; in send_cmd_ioarrin()
351 struct cxlflash_cfg *cfg = afu->parent; in send_cmd_sq() local
352 struct device *dev = &cfg->dev->dev; in send_cmd_sq()
396 struct cxlflash_cfg *cfg = afu->parent; in wait_resp() local
397 struct device *dev = &cfg->dev->dev; in wait_resp()
456 * @cfg: Internal structure associated with the host.
463 static int send_tmf(struct cxlflash_cfg *cfg, struct scsi_device *sdev, in send_tmf() argument
466 struct afu *afu = cfg->afu; in send_tmf()
468 struct device *dev = &cfg->dev->dev; in send_tmf()
487 spin_lock_irqsave(&cfg->tmf_slock, lock_flags); in send_tmf()
488 if (cfg->tmf_active) in send_tmf()
489 wait_event_interruptible_lock_irq(cfg->tmf_waitq, in send_tmf()
490 !cfg->tmf_active, in send_tmf()
491 cfg->tmf_slock); in send_tmf()
492 cfg->tmf_active = true; in send_tmf()
493 spin_unlock_irqrestore(&cfg->tmf_slock, lock_flags); in send_tmf()
510 spin_lock_irqsave(&cfg->tmf_slock, lock_flags); in send_tmf()
511 cfg->tmf_active = false; in send_tmf()
512 spin_unlock_irqrestore(&cfg->tmf_slock, lock_flags); in send_tmf()
516 spin_lock_irqsave(&cfg->tmf_slock, lock_flags); in send_tmf()
518 to = wait_event_interruptible_lock_irq_timeout(cfg->tmf_waitq, in send_tmf()
519 !cfg->tmf_active, in send_tmf()
520 cfg->tmf_slock, in send_tmf()
534 cfg->tmf_active = false; in send_tmf()
535 spin_unlock_irqrestore(&cfg->tmf_slock, lock_flags); in send_tmf()
567 struct cxlflash_cfg *cfg = shost_priv(host); in cxlflash_queuecommand() local
568 struct afu *afu = cfg->afu; in cxlflash_queuecommand()
569 struct device *dev = &cfg->dev->dev; in cxlflash_queuecommand()
591 spin_lock_irqsave(&cfg->tmf_slock, lock_flags); in cxlflash_queuecommand()
592 if (cfg->tmf_active) { in cxlflash_queuecommand()
593 spin_unlock_irqrestore(&cfg->tmf_slock, lock_flags); in cxlflash_queuecommand()
597 spin_unlock_irqrestore(&cfg->tmf_slock, lock_flags); in cxlflash_queuecommand()
599 switch (cfg->state) { in cxlflash_queuecommand()
646 * @cfg: Internal structure associated with the host.
648 static void cxlflash_wait_for_pci_err_recovery(struct cxlflash_cfg *cfg) in cxlflash_wait_for_pci_err_recovery() argument
650 struct pci_dev *pdev = cfg->dev; in cxlflash_wait_for_pci_err_recovery()
653 wait_event_timeout(cfg->reset_waitq, in cxlflash_wait_for_pci_err_recovery()
660 * @cfg: Internal structure associated with the host.
662 static void free_mem(struct cxlflash_cfg *cfg) in free_mem() argument
664 struct afu *afu = cfg->afu; in free_mem()
666 if (cfg->afu) { in free_mem()
668 cfg->afu = NULL; in free_mem()
674 * @cfg: Internal structure associated with the host.
676 static void cxlflash_reset_sync(struct cxlflash_cfg *cfg) in cxlflash_reset_sync() argument
678 if (cfg->async_reset_cookie == 0) in cxlflash_reset_sync()
682 async_synchronize_cookie(cfg->async_reset_cookie + 1); in cxlflash_reset_sync()
683 cfg->async_reset_cookie = 0; in cxlflash_reset_sync()
688 * @cfg: Internal structure associated with the host.
695 static void stop_afu(struct cxlflash_cfg *cfg) in stop_afu() argument
697 struct afu *afu = cfg->afu; in stop_afu()
701 cancel_work_sync(&cfg->work_q); in stop_afu()
703 cxlflash_reset_sync(cfg); in stop_afu()
718 cfg->ops->psa_unmap(afu->afu_map); in stop_afu()
726 * @cfg: Internal structure associated with the host.
732 static void term_intr(struct cxlflash_cfg *cfg, enum undo_level level, in term_intr() argument
735 struct afu *afu = cfg->afu; in term_intr()
736 struct device *dev = &cfg->dev->dev; in term_intr()
755 cfg->ops->unmap_afu_irq(hwq->ctx_cookie, 3, hwq); in term_intr()
758 cfg->ops->unmap_afu_irq(hwq->ctx_cookie, 2, hwq); in term_intr()
761 cfg->ops->unmap_afu_irq(hwq->ctx_cookie, 1, hwq); in term_intr()
764 cfg->ops->free_afu_irqs(hwq->ctx_cookie); in term_intr()
774 * @cfg: Internal structure associated with the host.
779 static void term_mc(struct cxlflash_cfg *cfg, u32 index) in term_mc() argument
781 struct afu *afu = cfg->afu; in term_mc()
782 struct device *dev = &cfg->dev->dev; in term_mc()
798 WARN_ON(cfg->ops->stop_context(hwq->ctx_cookie)); in term_mc()
800 WARN_ON(cfg->ops->release_context(hwq->ctx_cookie)); in term_mc()
814 * @cfg: Internal structure associated with the host.
818 static void term_afu(struct cxlflash_cfg *cfg) in term_afu() argument
820 struct device *dev = &cfg->dev->dev; in term_afu()
832 for (k = cfg->afu->num_hwqs - 1; k >= 0; k--) in term_afu()
833 term_intr(cfg, UNMAP_THREE, k); in term_afu()
835 stop_afu(cfg); in term_afu()
837 for (k = cfg->afu->num_hwqs - 1; k >= 0; k--) in term_afu()
838 term_mc(cfg, k); in term_afu()
845 * @cfg: Internal structure associated with the host.
853 static void notify_shutdown(struct cxlflash_cfg *cfg, bool wait) in notify_shutdown() argument
855 struct afu *afu = cfg->afu; in notify_shutdown()
856 struct device *dev = &cfg->dev->dev; in notify_shutdown()
862 ddv = (struct dev_dependent_vals *)cfg->dev_id->driver_data; in notify_shutdown()
872 for (i = 0; i < cfg->num_fc_ports; i++) { in notify_shutdown()
873 fc_port_regs = get_fc_port_regs(cfg, i); in notify_shutdown()
884 for (i = 0; i < cfg->num_fc_ports; i++) { in notify_shutdown()
885 fc_port_regs = get_fc_port_regs(cfg, i); in notify_shutdown()
932 * @cfg: Internal structure associated with the host.
934 static void cxlflash_release_chrdev(struct cxlflash_cfg *cfg) in cxlflash_release_chrdev() argument
936 device_unregister(cfg->chardev); in cxlflash_release_chrdev()
937 cfg->chardev = NULL; in cxlflash_release_chrdev()
938 cdev_del(&cfg->cdev); in cxlflash_release_chrdev()
939 cxlflash_put_minor(MINOR(cfg->cdev.dev)); in cxlflash_release_chrdev()
951 struct cxlflash_cfg *cfg = pci_get_drvdata(pdev); in cxlflash_remove() local
961 wait_event(cfg->reset_waitq, cfg->state != STATE_RESET && in cxlflash_remove()
962 cfg->state != STATE_PROBING); in cxlflash_remove()
963 spin_lock_irqsave(&cfg->tmf_slock, lock_flags); in cxlflash_remove()
964 if (cfg->tmf_active) in cxlflash_remove()
965 wait_event_interruptible_lock_irq(cfg->tmf_waitq, in cxlflash_remove()
966 !cfg->tmf_active, in cxlflash_remove()
967 cfg->tmf_slock); in cxlflash_remove()
968 spin_unlock_irqrestore(&cfg->tmf_slock, lock_flags); in cxlflash_remove()
971 notify_shutdown(cfg, true); in cxlflash_remove()
973 cfg->state = STATE_FAILTERM; in cxlflash_remove()
974 cxlflash_stop_term_user_contexts(cfg); in cxlflash_remove()
976 switch (cfg->init_state) { in cxlflash_remove()
978 cxlflash_release_chrdev(cfg); in cxlflash_remove()
981 cxlflash_term_local_luns(cfg); in cxlflash_remove()
982 scsi_remove_host(cfg->host); in cxlflash_remove()
985 term_afu(cfg); in cxlflash_remove()
988 cfg->ops->destroy_afu(cfg->afu_cookie); in cxlflash_remove()
992 free_mem(cfg); in cxlflash_remove()
993 scsi_host_put(cfg->host); in cxlflash_remove()
1002 * @cfg: Internal structure associated with the host.
1010 static int alloc_mem(struct cxlflash_cfg *cfg) in alloc_mem() argument
1013 struct device *dev = &cfg->dev->dev; in alloc_mem()
1016 cfg->afu = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, in alloc_mem()
1018 if (unlikely(!cfg->afu)) { in alloc_mem()
1024 cfg->afu->parent = cfg; in alloc_mem()
1025 cfg->afu->desired_hwqs = CXLFLASH_DEF_HWQS; in alloc_mem()
1026 cfg->afu->afu_map = NULL; in alloc_mem()
1033 * @cfg: Internal structure associated with the host.
1037 static int init_pci(struct cxlflash_cfg *cfg) in init_pci() argument
1039 struct pci_dev *pdev = cfg->dev; in init_pci()
1040 struct device *dev = &cfg->dev->dev; in init_pci()
1046 cxlflash_wait_for_pci_err_recovery(cfg); in init_pci()
1052 cxlflash_wait_for_pci_err_recovery(cfg); in init_pci()
1064 * @cfg: Internal structure associated with the host.
1068 static int init_scsi(struct cxlflash_cfg *cfg) in init_scsi() argument
1070 struct pci_dev *pdev = cfg->dev; in init_scsi()
1071 struct device *dev = &cfg->dev->dev; in init_scsi()
1074 rc = scsi_add_host(cfg->host, &pdev->dev); in init_scsi()
1080 scsi_scan_host(cfg->host); in init_scsi()
1196 struct cxlflash_cfg *cfg = afu->parent; in afu_set_wwpn() local
1197 struct device *dev = &cfg->dev->dev; in afu_set_wwpn()
1231 struct cxlflash_cfg *cfg = afu->parent; in afu_link_reset() local
1232 struct device *dev = &cfg->dev->dev; in afu_link_reset()
1267 struct cxlflash_cfg *cfg = afu->parent; in afu_err_intr_init() local
1298 fc_port_regs = get_fc_port_regs(cfg, 0); in afu_err_intr_init()
1306 for (i = 0; i < cfg->num_fc_ports; i++) { in afu_err_intr_init()
1307 fc_port_regs = get_fc_port_regs(cfg, i); in afu_err_intr_init()
1340 struct cxlflash_cfg *cfg = hwq->afu->parent; in cxlflash_sync_err_irq() local
1341 struct device *dev = &cfg->dev->dev; in cxlflash_sync_err_irq()
1547 struct cxlflash_cfg *cfg = afu->parent; in cxlflash_async_err_irq() local
1548 struct device *dev = &cfg->dev->dev; in cxlflash_async_err_irq()
1583 fc_port_regs = get_fc_port_regs(cfg, port); in cxlflash_async_err_irq()
1596 cfg->lr_state = LINK_RESET_REQUIRED; in cxlflash_async_err_irq()
1597 cfg->lr_port = port; in cxlflash_async_err_irq()
1598 schedule_work(&cfg->work_q); in cxlflash_async_err_irq()
1617 atomic_inc(&cfg->scan_host_needed); in cxlflash_async_err_irq()
1618 schedule_work(&cfg->work_q); in cxlflash_async_err_irq()
1628 * @cfg: Internal structure associated with the host.
1633 static int read_vpd(struct cxlflash_cfg *cfg, u64 wwpn[]) in read_vpd() argument
1635 struct device *dev = &cfg->dev->dev; in read_vpd()
1636 struct pci_dev *pdev = cfg->dev; in read_vpd()
1643 cfg->dev_id->driver_data; in read_vpd()
1648 vpd_size = cfg->ops->read_adapter_vpd(pdev, vpd_data, sizeof(vpd_data)); in read_vpd()
1670 for (k = 0; k < cfg->num_fc_ports; k++) { in read_vpd()
1707 * @cfg: Internal structure associated with the host.
1712 static void init_pcr(struct cxlflash_cfg *cfg) in init_pcr() argument
1714 struct afu *afu = cfg->afu; in init_pcr()
1734 hwq->ctx_hndl = (u16) cfg->ops->process_element(cookie); in init_pcr()
1745 * @cfg: Internal structure associated with the host.
1747 static int init_global(struct cxlflash_cfg *cfg) in init_global() argument
1749 struct afu *afu = cfg->afu; in init_global()
1750 struct device *dev = &cfg->dev->dev; in init_global()
1761 rc = read_vpd(cfg, &wwpn[0]); in init_global()
1797 writeq_be(PORT_MASK(cfg->num_fc_ports), in init_global()
1799 num_ports = cfg->num_fc_ports; in init_global()
1803 fc_port_regs = get_fc_port_regs(cfg, i); in init_global()
1827 reg = cfg->ops->get_irq_objhndl(ctx, j); in init_global()
1861 cfg->ws_unmap = true; in init_global()
1871 * @cfg: Internal structure associated with the host.
1873 static int start_afu(struct cxlflash_cfg *cfg) in start_afu() argument
1875 struct afu *afu = cfg->afu; in start_afu()
1876 struct device *dev = &cfg->dev->dev; in start_afu()
1881 init_pcr(cfg); in start_afu()
1917 rc = init_global(cfg); in start_afu()
1925 * @cfg: Internal structure associated with the host.
1930 static enum undo_level init_intr(struct cxlflash_cfg *cfg, in init_intr() argument
1933 struct device *dev = &cfg->dev->dev; in init_intr()
1940 rc = cfg->ops->allocate_afu_irqs(ctx, num_irqs); in init_intr()
1948 rc = cfg->ops->map_afu_irq(ctx, 1, cxlflash_sync_err_irq, hwq, in init_intr()
1956 rc = cfg->ops->map_afu_irq(ctx, 2, cxlflash_rrq_irq, hwq, in init_intr()
1968 rc = cfg->ops->map_afu_irq(ctx, 3, cxlflash_async_err_irq, hwq, in init_intr()
1981 * @cfg: Internal structure associated with the host.
1986 static int init_mc(struct cxlflash_cfg *cfg, u32 index) in init_mc() argument
1989 struct device *dev = &cfg->dev->dev; in init_mc()
1990 struct hwq *hwq = get_hwq(cfg->afu, index); in init_mc()
1995 hwq->afu = cfg->afu; in init_mc()
2000 ctx = cfg->ops->get_context(cfg->dev, cfg->afu_cookie); in init_mc()
2003 ctx = cfg->ops->dev_context_init(cfg->dev, cfg->afu_cookie); in init_mc()
2016 cfg->ops->set_master(ctx); in init_mc()
2020 rc = cfg->ops->afu_reset(ctx); in init_mc()
2028 level = init_intr(cfg, hwq); in init_mc()
2035 rc = cfg->ops->start_context(hwq->ctx_cookie); in init_mc()
2046 term_intr(cfg, level, index); in init_mc()
2048 cfg->ops->release_context(ctx); in init_mc()
2056 * @cfg: Internal structure associated with the host.
2069 static void get_num_afu_ports(struct cxlflash_cfg *cfg) in get_num_afu_ports() argument
2071 struct afu *afu = cfg->afu; in get_num_afu_ports()
2072 struct device *dev = &cfg->dev->dev; in get_num_afu_ports()
2083 cfg->num_fc_ports = num_fc_ports; in get_num_afu_ports()
2084 cfg->host->max_channel = PORTNUM2CHAN(num_fc_ports); in get_num_afu_ports()
2089 * @cfg: Internal structure associated with the host.
2096 static int init_afu(struct cxlflash_cfg *cfg) in init_afu() argument
2100 struct afu *afu = cfg->afu; in init_afu()
2101 struct device *dev = &cfg->dev->dev; in init_afu()
2105 cfg->ops->perst_reloads_same_image(cfg->afu_cookie, true); in init_afu()
2110 rc = init_mc(cfg, i); in init_afu()
2120 afu->afu_map = cfg->ops->psa_map(hwq->ctx_cookie); in init_afu()
2151 get_num_afu_ports(cfg); in init_afu()
2153 rc = start_afu(cfg); in init_afu()
2159 afu_err_intr_init(cfg->afu); in init_afu()
2167 cxlflash_restore_luntable(cfg); in init_afu()
2174 term_intr(cfg, UNMAP_THREE, i); in init_afu()
2175 term_mc(cfg, i); in init_afu()
2182 * @cfg: Internal structure associated with the host.
2186 static int afu_reset(struct cxlflash_cfg *cfg) in afu_reset() argument
2188 struct device *dev = &cfg->dev->dev; in afu_reset()
2194 term_afu(cfg); in afu_reset()
2196 rc = init_afu(cfg); in afu_reset()
2204 * @cfg: Internal structure associated with the host.
2209 static void drain_ioctls(struct cxlflash_cfg *cfg) in drain_ioctls() argument
2211 down_write(&cfg->ioctl_rwsem); in drain_ioctls()
2212 up_write(&cfg->ioctl_rwsem); in drain_ioctls()
2222 struct cxlflash_cfg *cfg = data; in cxlflash_async_reset_host() local
2223 struct device *dev = &cfg->dev->dev; in cxlflash_async_reset_host()
2226 if (cfg->state != STATE_RESET) { in cxlflash_async_reset_host()
2228 __func__, cfg->state); in cxlflash_async_reset_host()
2232 drain_ioctls(cfg); in cxlflash_async_reset_host()
2233 cxlflash_mark_contexts_error(cfg); in cxlflash_async_reset_host()
2234 rc = afu_reset(cfg); in cxlflash_async_reset_host()
2236 cfg->state = STATE_FAILTERM; in cxlflash_async_reset_host()
2238 cfg->state = STATE_NORMAL; in cxlflash_async_reset_host()
2239 wake_up_all(&cfg->reset_waitq); in cxlflash_async_reset_host()
2242 scsi_unblock_requests(cfg->host); in cxlflash_async_reset_host()
2247 * @cfg: Internal structure associated with the host.
2249 static void cxlflash_schedule_async_reset(struct cxlflash_cfg *cfg) in cxlflash_schedule_async_reset() argument
2251 struct device *dev = &cfg->dev->dev; in cxlflash_schedule_async_reset()
2253 if (cfg->state != STATE_NORMAL) { in cxlflash_schedule_async_reset()
2255 __func__, cfg->state); in cxlflash_schedule_async_reset()
2259 cfg->state = STATE_RESET; in cxlflash_schedule_async_reset()
2260 scsi_block_requests(cfg->host); in cxlflash_schedule_async_reset()
2261 cfg->async_reset_cookie = async_schedule(cxlflash_async_reset_host, in cxlflash_schedule_async_reset()
2262 cfg); in cxlflash_schedule_async_reset()
2283 struct cxlflash_cfg *cfg = afu->parent; in send_afu_cmd() local
2284 struct device *dev = &cfg->dev->dev; in send_afu_cmd()
2292 if (cfg->state != STATE_NORMAL) { in send_afu_cmd()
2294 __func__, cfg->state); in send_afu_cmd()
2337 cxlflash_schedule_async_reset(cfg); in send_afu_cmd()
2377 struct cxlflash_cfg *cfg = afu->parent; in cxlflash_afu_sync() local
2378 struct device *dev = &cfg->dev->dev; in cxlflash_afu_sync()
2410 struct cxlflash_cfg *cfg = shost_priv(host); in cxlflash_eh_abort_handler() local
2412 struct device *dev = &cfg->dev->dev; in cxlflash_eh_abort_handler()
2413 struct afu *afu = cfg->afu; in cxlflash_eh_abort_handler()
2427 if (cfg->state != STATE_NORMAL) { in cxlflash_eh_abort_handler()
2429 __func__, cfg->state); in cxlflash_eh_abort_handler()
2457 struct cxlflash_cfg *cfg = shost_priv(host); in cxlflash_eh_device_reset_handler() local
2458 struct device *dev = &cfg->dev->dev; in cxlflash_eh_device_reset_handler()
2464 switch (cfg->state) { in cxlflash_eh_device_reset_handler()
2466 rcr = send_tmf(cfg, sdev, TMF_LUN_RESET); in cxlflash_eh_device_reset_handler()
2471 wait_event(cfg->reset_waitq, cfg->state != STATE_RESET); in cxlflash_eh_device_reset_handler()
2500 struct cxlflash_cfg *cfg = shost_priv(host); in cxlflash_eh_host_reset_handler() local
2501 struct device *dev = &cfg->dev->dev; in cxlflash_eh_host_reset_handler()
2505 switch (cfg->state) { in cxlflash_eh_host_reset_handler()
2507 cfg->state = STATE_RESET; in cxlflash_eh_host_reset_handler()
2508 drain_ioctls(cfg); in cxlflash_eh_host_reset_handler()
2509 cxlflash_mark_contexts_error(cfg); in cxlflash_eh_host_reset_handler()
2510 rcr = afu_reset(cfg); in cxlflash_eh_host_reset_handler()
2513 cfg->state = STATE_FAILTERM; in cxlflash_eh_host_reset_handler()
2515 cfg->state = STATE_NORMAL; in cxlflash_eh_host_reset_handler()
2516 wake_up_all(&cfg->reset_waitq); in cxlflash_eh_host_reset_handler()
2520 wait_event(cfg->reset_waitq, cfg->state != STATE_RESET); in cxlflash_eh_host_reset_handler()
2521 if (cfg->state == STATE_NORMAL) in cxlflash_eh_host_reset_handler()
2555 * @cfg: Internal structure associated with the host.
2561 struct cxlflash_cfg *cfg, in cxlflash_show_port_status() argument
2564 struct device *dev = &cfg->dev->dev; in cxlflash_show_port_status()
2571 if (port >= cfg->num_fc_ports) { in cxlflash_show_port_status()
2577 fc_port_regs = get_fc_port_regs(cfg, port); in cxlflash_show_port_status()
2603 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port0_show() local
2605 return cxlflash_show_port_status(0, cfg, buf); in port0_show()
2620 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port1_show() local
2622 return cxlflash_show_port_status(1, cfg, buf); in port1_show()
2637 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port2_show() local
2639 return cxlflash_show_port_status(2, cfg, buf); in port2_show()
2654 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port3_show() local
2656 return cxlflash_show_port_status(3, cfg, buf); in port3_show()
2670 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in lun_mode_show() local
2671 struct afu *afu = cfg->afu; in lun_mode_show()
2703 struct cxlflash_cfg *cfg = shost_priv(shost); in lun_mode_store() local
2704 struct afu *afu = cfg->afu; in lun_mode_store()
2720 shost->max_channel = PORTNUM2CHAN(cfg->num_fc_ports); in lun_mode_store()
2722 afu_reset(cfg); in lun_mode_store()
2723 scsi_scan_host(cfg->host); in lun_mode_store()
2753 * @cfg: Internal structure associated with the host.
2759 struct cxlflash_cfg *cfg, in cxlflash_show_port_lun_table() argument
2762 struct device *dev = &cfg->dev->dev; in cxlflash_show_port_lun_table()
2769 if (port >= cfg->num_fc_ports) { in cxlflash_show_port_lun_table()
2775 fc_port_luns = get_fc_port_luns(cfg, port); in cxlflash_show_port_lun_table()
2796 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port0_lun_table_show() local
2798 return cxlflash_show_port_lun_table(0, cfg, buf); in port0_lun_table_show()
2813 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port1_lun_table_show() local
2815 return cxlflash_show_port_lun_table(1, cfg, buf); in port1_lun_table_show()
2830 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port2_lun_table_show() local
2832 return cxlflash_show_port_lun_table(2, cfg, buf); in port2_lun_table_show()
2847 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port3_lun_table_show() local
2849 return cxlflash_show_port_lun_table(3, cfg, buf); in port3_lun_table_show()
2866 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in irqpoll_weight_show() local
2867 struct afu *afu = cfg->afu; in irqpoll_weight_show()
2888 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in irqpoll_weight_store() local
2889 struct device *cfgdev = &cfg->dev->dev; in irqpoll_weight_store()
2890 struct afu *afu = cfg->afu; in irqpoll_weight_store()
2944 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in num_hwqs_show() local
2945 struct afu *afu = cfg->afu; in num_hwqs_show()
2968 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in num_hwqs_store() local
2969 struct afu *afu = cfg->afu; in num_hwqs_store()
2988 switch (cfg->state) { in num_hwqs_store()
2990 cfg->state = STATE_RESET; in num_hwqs_store()
2991 drain_ioctls(cfg); in num_hwqs_store()
2992 cxlflash_mark_contexts_error(cfg); in num_hwqs_store()
2993 rc = afu_reset(cfg); in num_hwqs_store()
2995 cfg->state = STATE_FAILTERM; in num_hwqs_store()
2997 cfg->state = STATE_NORMAL; in num_hwqs_store()
2998 wake_up_all(&cfg->reset_waitq); in num_hwqs_store()
3001 wait_event(cfg->reset_waitq, cfg->state != STATE_RESET); in num_hwqs_store()
3002 if (cfg->state == STATE_NORMAL) in num_hwqs_store()
3008 __func__, cfg->state); in num_hwqs_store()
3029 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in hwq_mode_show() local
3030 struct afu *afu = cfg->afu; in hwq_mode_show()
3054 struct cxlflash_cfg *cfg = shost_priv(shost); in hwq_mode_store() local
3055 struct device *cfgdev = &cfg->dev->dev; in hwq_mode_store()
3056 struct afu *afu = cfg->afu; in hwq_mode_store()
3203 struct cxlflash_cfg *cfg = container_of(work, struct cxlflash_cfg, in cxlflash_worker_thread() local
3205 struct afu *afu = cfg->afu; in cxlflash_worker_thread()
3206 struct device *dev = &cfg->dev->dev; in cxlflash_worker_thread()
3213 if (cfg->state != STATE_NORMAL) in cxlflash_worker_thread()
3216 spin_lock_irqsave(cfg->host->host_lock, lock_flags); in cxlflash_worker_thread()
3218 if (cfg->lr_state == LINK_RESET_REQUIRED) { in cxlflash_worker_thread()
3219 port = cfg->lr_port; in cxlflash_worker_thread()
3224 spin_unlock_irqrestore(cfg->host->host_lock, in cxlflash_worker_thread()
3228 fc_port_regs = get_fc_port_regs(cfg, port); in cxlflash_worker_thread()
3230 spin_lock_irqsave(cfg->host->host_lock, lock_flags); in cxlflash_worker_thread()
3233 cfg->lr_state = LINK_RESET_COMPLETE; in cxlflash_worker_thread()
3236 spin_unlock_irqrestore(cfg->host->host_lock, lock_flags); in cxlflash_worker_thread()
3238 if (atomic_dec_if_positive(&cfg->scan_host_needed) >= 0) in cxlflash_worker_thread()
3239 scsi_scan_host(cfg->host); in cxlflash_worker_thread()
3253 struct cxlflash_cfg *cfg; in cxlflash_chr_open() local
3258 cfg = container_of(inode->i_cdev, struct cxlflash_cfg, cdev); in cxlflash_chr_open()
3259 file->private_data = cfg; in cxlflash_chr_open()
3282 * @cfg: Internal structure associated with the host.
3287 static int cxlflash_lun_provision(struct cxlflash_cfg *cfg, void *arg) in cxlflash_lun_provision() argument
3290 struct afu *afu = cfg->afu; in cxlflash_lun_provision()
3291 struct device *dev = &cfg->dev->dev; in cxlflash_lun_provision()
3308 if (port >= cfg->num_fc_ports) { in cxlflash_lun_provision()
3325 fc_port_regs = get_fc_port_regs(cfg, port); in cxlflash_lun_provision()
3373 * @cfg: Internal structure associated with the host.
3381 static int cxlflash_afu_debug(struct cxlflash_cfg *cfg, void *arg) in cxlflash_afu_debug() argument
3384 struct afu *afu = cfg->afu; in cxlflash_afu_debug()
3385 struct device *dev = &cfg->dev->dev; in cxlflash_afu_debug()
3482 struct cxlflash_cfg *cfg = file->private_data; in cxlflash_chr_ioctl() local
3483 struct device *dev = &cfg->dev->dev; in cxlflash_chr_ioctl()
3502 down_read(&cfg->ioctl_rwsem); in cxlflash_chr_ioctl()
3546 rc = do_ioctl(cfg, (void *)&buf); in cxlflash_chr_ioctl()
3558 up_read(&cfg->ioctl_rwsem); in cxlflash_chr_ioctl()
3580 * @cfg: Internal structure associated with the host.
3584 static int init_chrdev(struct cxlflash_cfg *cfg) in init_chrdev() argument
3586 struct device *dev = &cfg->dev->dev; in init_chrdev()
3600 cdev_init(&cfg->cdev, &cxlflash_chr_fops); in init_chrdev()
3602 rc = cdev_add(&cfg->cdev, devno, 1); in init_chrdev()
3617 cfg->chardev = char_dev; in init_chrdev()
3622 cdev_del(&cfg->cdev); in init_chrdev()
3648 struct cxlflash_cfg *cfg = NULL; in cxlflash_probe() local
3674 cfg = shost_priv(host); in cxlflash_probe()
3675 cfg->state = STATE_PROBING; in cxlflash_probe()
3676 cfg->host = host; in cxlflash_probe()
3677 rc = alloc_mem(cfg); in cxlflash_probe()
3681 scsi_host_put(cfg->host); in cxlflash_probe()
3685 cfg->init_state = INIT_STATE_NONE; in cxlflash_probe()
3686 cfg->dev = pdev; in cxlflash_probe()
3687 cfg->cxl_fops = cxlflash_cxl_fops; in cxlflash_probe()
3688 cfg->ops = cxlflash_assign_ops(ddv); in cxlflash_probe()
3689 WARN_ON_ONCE(!cfg->ops); in cxlflash_probe()
3698 cfg->promote_lun_index = 0; in cxlflash_probe()
3701 cfg->last_lun_index[k] = CXLFLASH_NUM_VLUNS/2 - 1; in cxlflash_probe()
3703 cfg->dev_id = (struct pci_device_id *)dev_id; in cxlflash_probe()
3705 init_waitqueue_head(&cfg->tmf_waitq); in cxlflash_probe()
3706 init_waitqueue_head(&cfg->reset_waitq); in cxlflash_probe()
3708 INIT_WORK(&cfg->work_q, cxlflash_worker_thread); in cxlflash_probe()
3709 cfg->lr_state = LINK_RESET_INVALID; in cxlflash_probe()
3710 cfg->lr_port = -1; in cxlflash_probe()
3711 spin_lock_init(&cfg->tmf_slock); in cxlflash_probe()
3712 mutex_init(&cfg->ctx_tbl_list_mutex); in cxlflash_probe()
3713 mutex_init(&cfg->ctx_recovery_mutex); in cxlflash_probe()
3714 init_rwsem(&cfg->ioctl_rwsem); in cxlflash_probe()
3715 INIT_LIST_HEAD(&cfg->ctx_err_recovery); in cxlflash_probe()
3716 INIT_LIST_HEAD(&cfg->lluns); in cxlflash_probe()
3718 pci_set_drvdata(pdev, cfg); in cxlflash_probe()
3720 rc = init_pci(cfg); in cxlflash_probe()
3725 cfg->init_state = INIT_STATE_PCI; in cxlflash_probe()
3727 cfg->afu_cookie = cfg->ops->create_afu(pdev); in cxlflash_probe()
3728 if (unlikely(!cfg->afu_cookie)) { in cxlflash_probe()
3734 rc = init_afu(cfg); in cxlflash_probe()
3735 if (rc && !wq_has_sleeper(&cfg->reset_waitq)) { in cxlflash_probe()
3739 cfg->init_state = INIT_STATE_AFU; in cxlflash_probe()
3741 rc = init_scsi(cfg); in cxlflash_probe()
3746 cfg->init_state = INIT_STATE_SCSI; in cxlflash_probe()
3748 rc = init_chrdev(cfg); in cxlflash_probe()
3753 cfg->init_state = INIT_STATE_CDEV; in cxlflash_probe()
3755 if (wq_has_sleeper(&cfg->reset_waitq)) { in cxlflash_probe()
3756 cfg->state = STATE_PROBED; in cxlflash_probe()
3757 wake_up_all(&cfg->reset_waitq); in cxlflash_probe()
3759 cfg->state = STATE_NORMAL; in cxlflash_probe()
3765 cfg->state = STATE_PROBED; in cxlflash_probe()
3784 struct cxlflash_cfg *cfg = pci_get_drvdata(pdev); in cxlflash_pci_error_detected() local
3785 struct device *dev = &cfg->dev->dev; in cxlflash_pci_error_detected()
3791 wait_event(cfg->reset_waitq, cfg->state != STATE_RESET && in cxlflash_pci_error_detected()
3792 cfg->state != STATE_PROBING); in cxlflash_pci_error_detected()
3793 if (cfg->state == STATE_FAILTERM) in cxlflash_pci_error_detected()
3796 cfg->state = STATE_RESET; in cxlflash_pci_error_detected()
3797 scsi_block_requests(cfg->host); in cxlflash_pci_error_detected()
3798 drain_ioctls(cfg); in cxlflash_pci_error_detected()
3799 rc = cxlflash_mark_contexts_error(cfg); in cxlflash_pci_error_detected()
3803 term_afu(cfg); in cxlflash_pci_error_detected()
3806 cfg->state = STATE_FAILTERM; in cxlflash_pci_error_detected()
3807 wake_up_all(&cfg->reset_waitq); in cxlflash_pci_error_detected()
3808 scsi_unblock_requests(cfg->host); in cxlflash_pci_error_detected()
3828 struct cxlflash_cfg *cfg = pci_get_drvdata(pdev); in cxlflash_pci_slot_reset() local
3829 struct device *dev = &cfg->dev->dev; in cxlflash_pci_slot_reset()
3833 rc = init_afu(cfg); in cxlflash_pci_slot_reset()
3848 struct cxlflash_cfg *cfg = pci_get_drvdata(pdev); in cxlflash_pci_resume() local
3849 struct device *dev = &cfg->dev->dev; in cxlflash_pci_resume()
3853 cfg->state = STATE_NORMAL; in cxlflash_pci_resume()
3854 wake_up_all(&cfg->reset_waitq); in cxlflash_pci_resume()
3855 scsi_unblock_requests(cfg->host); in cxlflash_pci_resume()