Lines Matching full:cfg

45 	struct cxlflash_cfg *cfg = afu->parent;  in process_cmd_err()  local
46 struct device *dev = &cfg->dev->dev; in process_cmd_err()
157 struct cxlflash_cfg *cfg = afu->parent; in cmd_complete() local
158 struct device *dev = &cfg->dev->dev; in cmd_complete()
176 spin_lock_irqsave(&cfg->tmf_slock, lock_flags); in cmd_complete()
177 cfg->tmf_active = false; in cmd_complete()
178 wake_up_all_locked(&cfg->tmf_waitq); in cmd_complete()
179 spin_unlock_irqrestore(&cfg->tmf_slock, lock_flags); in cmd_complete()
193 struct cxlflash_cfg *cfg = hwq->afu->parent; in flush_pending_cmds() local
213 spin_lock_irqsave(&cfg->tmf_slock, lock_flags); in flush_pending_cmds()
214 cfg->tmf_active = false; in flush_pending_cmds()
215 wake_up_all_locked(&cfg->tmf_waitq); in flush_pending_cmds()
216 spin_unlock_irqrestore(&cfg->tmf_slock, in flush_pending_cmds()
237 struct cxlflash_cfg *cfg = hwq->afu->parent; in context_reset() local
238 struct device *dev = &cfg->dev->dev; in context_reset()
302 struct cxlflash_cfg *cfg = afu->parent; in send_cmd_ioarrin() local
303 struct device *dev = &cfg->dev->dev; in send_cmd_ioarrin()
346 struct cxlflash_cfg *cfg = afu->parent; in send_cmd_sq() local
347 struct device *dev = &cfg->dev->dev; in send_cmd_sq()
391 struct cxlflash_cfg *cfg = afu->parent; in wait_resp() local
392 struct device *dev = &cfg->dev->dev; in wait_resp()
451 * @cfg: Internal structure associated with the host.
458 static int send_tmf(struct cxlflash_cfg *cfg, struct scsi_device *sdev, in send_tmf() argument
461 struct afu *afu = cfg->afu; in send_tmf()
463 struct device *dev = &cfg->dev->dev; in send_tmf()
482 spin_lock_irqsave(&cfg->tmf_slock, lock_flags); in send_tmf()
483 if (cfg->tmf_active) in send_tmf()
484 wait_event_interruptible_lock_irq(cfg->tmf_waitq, in send_tmf()
485 !cfg->tmf_active, in send_tmf()
486 cfg->tmf_slock); in send_tmf()
487 cfg->tmf_active = true; in send_tmf()
488 spin_unlock_irqrestore(&cfg->tmf_slock, lock_flags); in send_tmf()
505 spin_lock_irqsave(&cfg->tmf_slock, lock_flags); in send_tmf()
506 cfg->tmf_active = false; in send_tmf()
507 spin_unlock_irqrestore(&cfg->tmf_slock, lock_flags); in send_tmf()
511 spin_lock_irqsave(&cfg->tmf_slock, lock_flags); in send_tmf()
513 to = wait_event_interruptible_lock_irq_timeout(cfg->tmf_waitq, in send_tmf()
514 !cfg->tmf_active, in send_tmf()
515 cfg->tmf_slock, in send_tmf()
529 cfg->tmf_active = false; in send_tmf()
530 spin_unlock_irqrestore(&cfg->tmf_slock, lock_flags); in send_tmf()
562 struct cxlflash_cfg *cfg = shost_priv(host); in cxlflash_queuecommand() local
563 struct afu *afu = cfg->afu; in cxlflash_queuecommand()
564 struct device *dev = &cfg->dev->dev; in cxlflash_queuecommand()
586 spin_lock_irqsave(&cfg->tmf_slock, lock_flags); in cxlflash_queuecommand()
587 if (cfg->tmf_active) { in cxlflash_queuecommand()
588 spin_unlock_irqrestore(&cfg->tmf_slock, lock_flags); in cxlflash_queuecommand()
592 spin_unlock_irqrestore(&cfg->tmf_slock, lock_flags); in cxlflash_queuecommand()
594 switch (cfg->state) { in cxlflash_queuecommand()
641 * @cfg: Internal structure associated with the host.
643 static void cxlflash_wait_for_pci_err_recovery(struct cxlflash_cfg *cfg) in cxlflash_wait_for_pci_err_recovery() argument
645 struct pci_dev *pdev = cfg->dev; in cxlflash_wait_for_pci_err_recovery()
648 wait_event_timeout(cfg->reset_waitq, in cxlflash_wait_for_pci_err_recovery()
655 * @cfg: Internal structure associated with the host.
657 static void free_mem(struct cxlflash_cfg *cfg) in free_mem() argument
659 struct afu *afu = cfg->afu; in free_mem()
661 if (cfg->afu) { in free_mem()
663 cfg->afu = NULL; in free_mem()
669 * @cfg: Internal structure associated with the host.
671 static void cxlflash_reset_sync(struct cxlflash_cfg *cfg) in cxlflash_reset_sync() argument
673 if (cfg->async_reset_cookie == 0) in cxlflash_reset_sync()
677 async_synchronize_cookie(cfg->async_reset_cookie + 1); in cxlflash_reset_sync()
678 cfg->async_reset_cookie = 0; in cxlflash_reset_sync()
683 * @cfg: Internal structure associated with the host.
690 static void stop_afu(struct cxlflash_cfg *cfg) in stop_afu() argument
692 struct afu *afu = cfg->afu; in stop_afu()
696 cancel_work_sync(&cfg->work_q); in stop_afu()
698 cxlflash_reset_sync(cfg); in stop_afu()
713 cfg->ops->psa_unmap(afu->afu_map); in stop_afu()
721 * @cfg: Internal structure associated with the host.
727 static void term_intr(struct cxlflash_cfg *cfg, enum undo_level level, in term_intr() argument
730 struct afu *afu = cfg->afu; in term_intr()
731 struct device *dev = &cfg->dev->dev; in term_intr()
750 cfg->ops->unmap_afu_irq(hwq->ctx_cookie, 3, hwq); in term_intr()
753 cfg->ops->unmap_afu_irq(hwq->ctx_cookie, 2, hwq); in term_intr()
756 cfg->ops->unmap_afu_irq(hwq->ctx_cookie, 1, hwq); in term_intr()
759 cfg->ops->free_afu_irqs(hwq->ctx_cookie); in term_intr()
769 * @cfg: Internal structure associated with the host.
774 static void term_mc(struct cxlflash_cfg *cfg, u32 index) in term_mc() argument
776 struct afu *afu = cfg->afu; in term_mc()
777 struct device *dev = &cfg->dev->dev; in term_mc()
793 WARN_ON(cfg->ops->stop_context(hwq->ctx_cookie)); in term_mc()
795 WARN_ON(cfg->ops->release_context(hwq->ctx_cookie)); in term_mc()
809 * @cfg: Internal structure associated with the host.
813 static void term_afu(struct cxlflash_cfg *cfg) in term_afu() argument
815 struct device *dev = &cfg->dev->dev; in term_afu()
827 for (k = cfg->afu->num_hwqs - 1; k >= 0; k--) in term_afu()
828 term_intr(cfg, UNMAP_THREE, k); in term_afu()
830 stop_afu(cfg); in term_afu()
832 for (k = cfg->afu->num_hwqs - 1; k >= 0; k--) in term_afu()
833 term_mc(cfg, k); in term_afu()
840 * @cfg: Internal structure associated with the host.
848 static void notify_shutdown(struct cxlflash_cfg *cfg, bool wait) in notify_shutdown() argument
850 struct afu *afu = cfg->afu; in notify_shutdown()
851 struct device *dev = &cfg->dev->dev; in notify_shutdown()
857 ddv = (struct dev_dependent_vals *)cfg->dev_id->driver_data; in notify_shutdown()
867 for (i = 0; i < cfg->num_fc_ports; i++) { in notify_shutdown()
868 fc_port_regs = get_fc_port_regs(cfg, i); in notify_shutdown()
879 for (i = 0; i < cfg->num_fc_ports; i++) { in notify_shutdown()
880 fc_port_regs = get_fc_port_regs(cfg, i); in notify_shutdown()
927 * @cfg: Internal structure associated with the host.
929 static void cxlflash_release_chrdev(struct cxlflash_cfg *cfg) in cxlflash_release_chrdev() argument
931 device_unregister(cfg->chardev); in cxlflash_release_chrdev()
932 cfg->chardev = NULL; in cxlflash_release_chrdev()
933 cdev_del(&cfg->cdev); in cxlflash_release_chrdev()
934 cxlflash_put_minor(MINOR(cfg->cdev.dev)); in cxlflash_release_chrdev()
946 struct cxlflash_cfg *cfg = pci_get_drvdata(pdev); in cxlflash_remove() local
956 wait_event(cfg->reset_waitq, cfg->state != STATE_RESET && in cxlflash_remove()
957 cfg->state != STATE_PROBING); in cxlflash_remove()
958 spin_lock_irqsave(&cfg->tmf_slock, lock_flags); in cxlflash_remove()
959 if (cfg->tmf_active) in cxlflash_remove()
960 wait_event_interruptible_lock_irq(cfg->tmf_waitq, in cxlflash_remove()
961 !cfg->tmf_active, in cxlflash_remove()
962 cfg->tmf_slock); in cxlflash_remove()
963 spin_unlock_irqrestore(&cfg->tmf_slock, lock_flags); in cxlflash_remove()
966 notify_shutdown(cfg, true); in cxlflash_remove()
968 cfg->state = STATE_FAILTERM; in cxlflash_remove()
969 cxlflash_stop_term_user_contexts(cfg); in cxlflash_remove()
971 switch (cfg->init_state) { in cxlflash_remove()
973 cxlflash_release_chrdev(cfg); in cxlflash_remove()
976 cxlflash_term_local_luns(cfg); in cxlflash_remove()
977 scsi_remove_host(cfg->host); in cxlflash_remove()
980 term_afu(cfg); in cxlflash_remove()
983 cfg->ops->destroy_afu(cfg->afu_cookie); in cxlflash_remove()
987 free_mem(cfg); in cxlflash_remove()
988 scsi_host_put(cfg->host); in cxlflash_remove()
997 * @cfg: Internal structure associated with the host.
1005 static int alloc_mem(struct cxlflash_cfg *cfg) in alloc_mem() argument
1008 struct device *dev = &cfg->dev->dev; in alloc_mem()
1011 cfg->afu = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, in alloc_mem()
1013 if (unlikely(!cfg->afu)) { in alloc_mem()
1019 cfg->afu->parent = cfg; in alloc_mem()
1020 cfg->afu->desired_hwqs = CXLFLASH_DEF_HWQS; in alloc_mem()
1021 cfg->afu->afu_map = NULL; in alloc_mem()
1028 * @cfg: Internal structure associated with the host.
1032 static int init_pci(struct cxlflash_cfg *cfg) in init_pci() argument
1034 struct pci_dev *pdev = cfg->dev; in init_pci()
1035 struct device *dev = &cfg->dev->dev; in init_pci()
1041 cxlflash_wait_for_pci_err_recovery(cfg); in init_pci()
1047 cxlflash_wait_for_pci_err_recovery(cfg); in init_pci()
1059 * @cfg: Internal structure associated with the host.
1063 static int init_scsi(struct cxlflash_cfg *cfg) in init_scsi() argument
1065 struct pci_dev *pdev = cfg->dev; in init_scsi()
1066 struct device *dev = &cfg->dev->dev; in init_scsi()
1069 rc = scsi_add_host(cfg->host, &pdev->dev); in init_scsi()
1075 scsi_scan_host(cfg->host); in init_scsi()
1191 struct cxlflash_cfg *cfg = afu->parent; in afu_set_wwpn() local
1192 struct device *dev = &cfg->dev->dev; in afu_set_wwpn()
1226 struct cxlflash_cfg *cfg = afu->parent; in afu_link_reset() local
1227 struct device *dev = &cfg->dev->dev; in afu_link_reset()
1262 struct cxlflash_cfg *cfg = afu->parent; in afu_err_intr_init() local
1293 fc_port_regs = get_fc_port_regs(cfg, 0); in afu_err_intr_init()
1301 for (i = 0; i < cfg->num_fc_ports; i++) { in afu_err_intr_init()
1302 fc_port_regs = get_fc_port_regs(cfg, i); in afu_err_intr_init()
1335 struct cxlflash_cfg *cfg = hwq->afu->parent; in cxlflash_sync_err_irq() local
1336 struct device *dev = &cfg->dev->dev; in cxlflash_sync_err_irq()
1542 struct cxlflash_cfg *cfg = afu->parent; in cxlflash_async_err_irq() local
1543 struct device *dev = &cfg->dev->dev; in cxlflash_async_err_irq()
1578 fc_port_regs = get_fc_port_regs(cfg, port); in cxlflash_async_err_irq()
1591 cfg->lr_state = LINK_RESET_REQUIRED; in cxlflash_async_err_irq()
1592 cfg->lr_port = port; in cxlflash_async_err_irq()
1593 schedule_work(&cfg->work_q); in cxlflash_async_err_irq()
1612 atomic_inc(&cfg->scan_host_needed); in cxlflash_async_err_irq()
1613 schedule_work(&cfg->work_q); in cxlflash_async_err_irq()
1623 * @cfg: Internal structure associated with the host.
1628 static int read_vpd(struct cxlflash_cfg *cfg, u64 wwpn[]) in read_vpd() argument
1630 struct device *dev = &cfg->dev->dev; in read_vpd()
1631 struct pci_dev *pdev = cfg->dev; in read_vpd()
1638 cfg->dev_id->driver_data; in read_vpd()
1643 vpd_size = cfg->ops->read_adapter_vpd(pdev, vpd_data, sizeof(vpd_data)); in read_vpd()
1665 for (k = 0; k < cfg->num_fc_ports; k++) { in read_vpd()
1702 * @cfg: Internal structure associated with the host.
1707 static void init_pcr(struct cxlflash_cfg *cfg) in init_pcr() argument
1709 struct afu *afu = cfg->afu; in init_pcr()
1729 hwq->ctx_hndl = (u16) cfg->ops->process_element(cookie); in init_pcr()
1740 * @cfg: Internal structure associated with the host.
1742 static int init_global(struct cxlflash_cfg *cfg) in init_global() argument
1744 struct afu *afu = cfg->afu; in init_global()
1745 struct device *dev = &cfg->dev->dev; in init_global()
1756 rc = read_vpd(cfg, &wwpn[0]); in init_global()
1792 writeq_be(PORT_MASK(cfg->num_fc_ports), in init_global()
1794 num_ports = cfg->num_fc_ports; in init_global()
1798 fc_port_regs = get_fc_port_regs(cfg, i); in init_global()
1822 reg = cfg->ops->get_irq_objhndl(ctx, j); in init_global()
1856 cfg->ws_unmap = true; in init_global()
1866 * @cfg: Internal structure associated with the host.
1868 static int start_afu(struct cxlflash_cfg *cfg) in start_afu() argument
1870 struct afu *afu = cfg->afu; in start_afu()
1871 struct device *dev = &cfg->dev->dev; in start_afu()
1876 init_pcr(cfg); in start_afu()
1912 rc = init_global(cfg); in start_afu()
1920 * @cfg: Internal structure associated with the host.
1925 static enum undo_level init_intr(struct cxlflash_cfg *cfg, in init_intr() argument
1928 struct device *dev = &cfg->dev->dev; in init_intr()
1935 rc = cfg->ops->allocate_afu_irqs(ctx, num_irqs); in init_intr()
1943 rc = cfg->ops->map_afu_irq(ctx, 1, cxlflash_sync_err_irq, hwq, in init_intr()
1951 rc = cfg->ops->map_afu_irq(ctx, 2, cxlflash_rrq_irq, hwq, in init_intr()
1963 rc = cfg->ops->map_afu_irq(ctx, 3, cxlflash_async_err_irq, hwq, in init_intr()
1976 * @cfg: Internal structure associated with the host.
1981 static int init_mc(struct cxlflash_cfg *cfg, u32 index) in init_mc() argument
1984 struct device *dev = &cfg->dev->dev; in init_mc()
1985 struct hwq *hwq = get_hwq(cfg->afu, index); in init_mc()
1990 hwq->afu = cfg->afu; in init_mc()
1995 ctx = cfg->ops->get_context(cfg->dev, cfg->afu_cookie); in init_mc()
1998 ctx = cfg->ops->dev_context_init(cfg->dev, cfg->afu_cookie); in init_mc()
2011 cfg->ops->set_master(ctx); in init_mc()
2015 rc = cfg->ops->afu_reset(ctx); in init_mc()
2023 level = init_intr(cfg, hwq); in init_mc()
2030 rc = cfg->ops->start_context(hwq->ctx_cookie); in init_mc()
2041 term_intr(cfg, level, index); in init_mc()
2043 cfg->ops->release_context(ctx); in init_mc()
2051 * @cfg: Internal structure associated with the host.
2064 static void get_num_afu_ports(struct cxlflash_cfg *cfg) in get_num_afu_ports() argument
2066 struct afu *afu = cfg->afu; in get_num_afu_ports()
2067 struct device *dev = &cfg->dev->dev; in get_num_afu_ports()
2078 cfg->num_fc_ports = num_fc_ports; in get_num_afu_ports()
2079 cfg->host->max_channel = PORTNUM2CHAN(num_fc_ports); in get_num_afu_ports()
2084 * @cfg: Internal structure associated with the host.
2091 static int init_afu(struct cxlflash_cfg *cfg) in init_afu() argument
2095 struct afu *afu = cfg->afu; in init_afu()
2096 struct device *dev = &cfg->dev->dev; in init_afu()
2100 cfg->ops->perst_reloads_same_image(cfg->afu_cookie, true); in init_afu()
2105 rc = init_mc(cfg, i); in init_afu()
2115 afu->afu_map = cfg->ops->psa_map(hwq->ctx_cookie); in init_afu()
2146 get_num_afu_ports(cfg); in init_afu()
2148 rc = start_afu(cfg); in init_afu()
2154 afu_err_intr_init(cfg->afu); in init_afu()
2162 cxlflash_restore_luntable(cfg); in init_afu()
2169 term_intr(cfg, UNMAP_THREE, i); in init_afu()
2170 term_mc(cfg, i); in init_afu()
2177 * @cfg: Internal structure associated with the host.
2181 static int afu_reset(struct cxlflash_cfg *cfg) in afu_reset() argument
2183 struct device *dev = &cfg->dev->dev; in afu_reset()
2189 term_afu(cfg); in afu_reset()
2191 rc = init_afu(cfg); in afu_reset()
2199 * @cfg: Internal structure associated with the host.
2204 static void drain_ioctls(struct cxlflash_cfg *cfg) in drain_ioctls() argument
2206 down_write(&cfg->ioctl_rwsem); in drain_ioctls()
2207 up_write(&cfg->ioctl_rwsem); in drain_ioctls()
2217 struct cxlflash_cfg *cfg = data; in cxlflash_async_reset_host() local
2218 struct device *dev = &cfg->dev->dev; in cxlflash_async_reset_host()
2221 if (cfg->state != STATE_RESET) { in cxlflash_async_reset_host()
2223 __func__, cfg->state); in cxlflash_async_reset_host()
2227 drain_ioctls(cfg); in cxlflash_async_reset_host()
2228 cxlflash_mark_contexts_error(cfg); in cxlflash_async_reset_host()
2229 rc = afu_reset(cfg); in cxlflash_async_reset_host()
2231 cfg->state = STATE_FAILTERM; in cxlflash_async_reset_host()
2233 cfg->state = STATE_NORMAL; in cxlflash_async_reset_host()
2234 wake_up_all(&cfg->reset_waitq); in cxlflash_async_reset_host()
2237 scsi_unblock_requests(cfg->host); in cxlflash_async_reset_host()
2242 * @cfg: Internal structure associated with the host.
2244 static void cxlflash_schedule_async_reset(struct cxlflash_cfg *cfg) in cxlflash_schedule_async_reset() argument
2246 struct device *dev = &cfg->dev->dev; in cxlflash_schedule_async_reset()
2248 if (cfg->state != STATE_NORMAL) { in cxlflash_schedule_async_reset()
2250 __func__, cfg->state); in cxlflash_schedule_async_reset()
2254 cfg->state = STATE_RESET; in cxlflash_schedule_async_reset()
2255 scsi_block_requests(cfg->host); in cxlflash_schedule_async_reset()
2256 cfg->async_reset_cookie = async_schedule(cxlflash_async_reset_host, in cxlflash_schedule_async_reset()
2257 cfg); in cxlflash_schedule_async_reset()
2278 struct cxlflash_cfg *cfg = afu->parent; in send_afu_cmd() local
2279 struct device *dev = &cfg->dev->dev; in send_afu_cmd()
2287 if (cfg->state != STATE_NORMAL) { in send_afu_cmd()
2289 __func__, cfg->state); in send_afu_cmd()
2332 cxlflash_schedule_async_reset(cfg); in send_afu_cmd()
2372 struct cxlflash_cfg *cfg = afu->parent; in cxlflash_afu_sync() local
2373 struct device *dev = &cfg->dev->dev; in cxlflash_afu_sync()
2405 struct cxlflash_cfg *cfg = shost_priv(host); in cxlflash_eh_abort_handler() local
2407 struct device *dev = &cfg->dev->dev; in cxlflash_eh_abort_handler()
2408 struct afu *afu = cfg->afu; in cxlflash_eh_abort_handler()
2422 if (cfg->state != STATE_NORMAL) { in cxlflash_eh_abort_handler()
2424 __func__, cfg->state); in cxlflash_eh_abort_handler()
2452 struct cxlflash_cfg *cfg = shost_priv(host); in cxlflash_eh_device_reset_handler() local
2453 struct device *dev = &cfg->dev->dev; in cxlflash_eh_device_reset_handler()
2459 switch (cfg->state) { in cxlflash_eh_device_reset_handler()
2461 rcr = send_tmf(cfg, sdev, TMF_LUN_RESET); in cxlflash_eh_device_reset_handler()
2466 wait_event(cfg->reset_waitq, cfg->state != STATE_RESET); in cxlflash_eh_device_reset_handler()
2495 struct cxlflash_cfg *cfg = shost_priv(host); in cxlflash_eh_host_reset_handler() local
2496 struct device *dev = &cfg->dev->dev; in cxlflash_eh_host_reset_handler()
2500 switch (cfg->state) { in cxlflash_eh_host_reset_handler()
2502 cfg->state = STATE_RESET; in cxlflash_eh_host_reset_handler()
2503 drain_ioctls(cfg); in cxlflash_eh_host_reset_handler()
2504 cxlflash_mark_contexts_error(cfg); in cxlflash_eh_host_reset_handler()
2505 rcr = afu_reset(cfg); in cxlflash_eh_host_reset_handler()
2508 cfg->state = STATE_FAILTERM; in cxlflash_eh_host_reset_handler()
2510 cfg->state = STATE_NORMAL; in cxlflash_eh_host_reset_handler()
2511 wake_up_all(&cfg->reset_waitq); in cxlflash_eh_host_reset_handler()
2515 wait_event(cfg->reset_waitq, cfg->state != STATE_RESET); in cxlflash_eh_host_reset_handler()
2516 if (cfg->state == STATE_NORMAL) in cxlflash_eh_host_reset_handler()
2550 * @cfg: Internal structure associated with the host.
2556 struct cxlflash_cfg *cfg, in cxlflash_show_port_status() argument
2559 struct device *dev = &cfg->dev->dev; in cxlflash_show_port_status()
2566 if (port >= cfg->num_fc_ports) { in cxlflash_show_port_status()
2572 fc_port_regs = get_fc_port_regs(cfg, port); in cxlflash_show_port_status()
2598 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port0_show() local
2600 return cxlflash_show_port_status(0, cfg, buf); in port0_show()
2615 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port1_show() local
2617 return cxlflash_show_port_status(1, cfg, buf); in port1_show()
2632 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port2_show() local
2634 return cxlflash_show_port_status(2, cfg, buf); in port2_show()
2649 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port3_show() local
2651 return cxlflash_show_port_status(3, cfg, buf); in port3_show()
2665 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in lun_mode_show() local
2666 struct afu *afu = cfg->afu; in lun_mode_show()
2698 struct cxlflash_cfg *cfg = shost_priv(shost); in lun_mode_store() local
2699 struct afu *afu = cfg->afu; in lun_mode_store()
2715 shost->max_channel = PORTNUM2CHAN(cfg->num_fc_ports); in lun_mode_store()
2717 afu_reset(cfg); in lun_mode_store()
2718 scsi_scan_host(cfg->host); in lun_mode_store()
2748 * @cfg: Internal structure associated with the host.
2754 struct cxlflash_cfg *cfg, in cxlflash_show_port_lun_table() argument
2757 struct device *dev = &cfg->dev->dev; in cxlflash_show_port_lun_table()
2764 if (port >= cfg->num_fc_ports) { in cxlflash_show_port_lun_table()
2770 fc_port_luns = get_fc_port_luns(cfg, port); in cxlflash_show_port_lun_table()
2791 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port0_lun_table_show() local
2793 return cxlflash_show_port_lun_table(0, cfg, buf); in port0_lun_table_show()
2808 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port1_lun_table_show() local
2810 return cxlflash_show_port_lun_table(1, cfg, buf); in port1_lun_table_show()
2825 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port2_lun_table_show() local
2827 return cxlflash_show_port_lun_table(2, cfg, buf); in port2_lun_table_show()
2842 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port3_lun_table_show() local
2844 return cxlflash_show_port_lun_table(3, cfg, buf); in port3_lun_table_show()
2861 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in irqpoll_weight_show() local
2862 struct afu *afu = cfg->afu; in irqpoll_weight_show()
2883 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in irqpoll_weight_store() local
2884 struct device *cfgdev = &cfg->dev->dev; in irqpoll_weight_store()
2885 struct afu *afu = cfg->afu; in irqpoll_weight_store()
2939 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in num_hwqs_show() local
2940 struct afu *afu = cfg->afu; in num_hwqs_show()
2963 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in num_hwqs_store() local
2964 struct afu *afu = cfg->afu; in num_hwqs_store()
2983 switch (cfg->state) { in num_hwqs_store()
2985 cfg->state = STATE_RESET; in num_hwqs_store()
2986 drain_ioctls(cfg); in num_hwqs_store()
2987 cxlflash_mark_contexts_error(cfg); in num_hwqs_store()
2988 rc = afu_reset(cfg); in num_hwqs_store()
2990 cfg->state = STATE_FAILTERM; in num_hwqs_store()
2992 cfg->state = STATE_NORMAL; in num_hwqs_store()
2993 wake_up_all(&cfg->reset_waitq); in num_hwqs_store()
2996 wait_event(cfg->reset_waitq, cfg->state != STATE_RESET); in num_hwqs_store()
2997 if (cfg->state == STATE_NORMAL) in num_hwqs_store()
3003 __func__, cfg->state); in num_hwqs_store()
3024 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in hwq_mode_show() local
3025 struct afu *afu = cfg->afu; in hwq_mode_show()
3049 struct cxlflash_cfg *cfg = shost_priv(shost); in hwq_mode_store() local
3050 struct device *cfgdev = &cfg->dev->dev; in hwq_mode_store()
3051 struct afu *afu = cfg->afu; in hwq_mode_store()
3198 struct cxlflash_cfg *cfg = container_of(work, struct cxlflash_cfg, in cxlflash_worker_thread() local
3200 struct afu *afu = cfg->afu; in cxlflash_worker_thread()
3201 struct device *dev = &cfg->dev->dev; in cxlflash_worker_thread()
3208 if (cfg->state != STATE_NORMAL) in cxlflash_worker_thread()
3211 spin_lock_irqsave(cfg->host->host_lock, lock_flags); in cxlflash_worker_thread()
3213 if (cfg->lr_state == LINK_RESET_REQUIRED) { in cxlflash_worker_thread()
3214 port = cfg->lr_port; in cxlflash_worker_thread()
3219 spin_unlock_irqrestore(cfg->host->host_lock, in cxlflash_worker_thread()
3223 fc_port_regs = get_fc_port_regs(cfg, port); in cxlflash_worker_thread()
3225 spin_lock_irqsave(cfg->host->host_lock, lock_flags); in cxlflash_worker_thread()
3228 cfg->lr_state = LINK_RESET_COMPLETE; in cxlflash_worker_thread()
3231 spin_unlock_irqrestore(cfg->host->host_lock, lock_flags); in cxlflash_worker_thread()
3233 if (atomic_dec_if_positive(&cfg->scan_host_needed) >= 0) in cxlflash_worker_thread()
3234 scsi_scan_host(cfg->host); in cxlflash_worker_thread()
3248 struct cxlflash_cfg *cfg; in cxlflash_chr_open() local
3253 cfg = container_of(inode->i_cdev, struct cxlflash_cfg, cdev); in cxlflash_chr_open()
3254 file->private_data = cfg; in cxlflash_chr_open()
3277 * @cfg: Internal structure associated with the host.
3282 static int cxlflash_lun_provision(struct cxlflash_cfg *cfg, in cxlflash_lun_provision() argument
3285 struct afu *afu = cfg->afu; in cxlflash_lun_provision()
3286 struct device *dev = &cfg->dev->dev; in cxlflash_lun_provision()
3303 if (port >= cfg->num_fc_ports) { in cxlflash_lun_provision()
3320 fc_port_regs = get_fc_port_regs(cfg, port); in cxlflash_lun_provision()
3368 * @cfg: Internal structure associated with the host.
3376 static int cxlflash_afu_debug(struct cxlflash_cfg *cfg, in cxlflash_afu_debug() argument
3379 struct afu *afu = cfg->afu; in cxlflash_afu_debug()
3380 struct device *dev = &cfg->dev->dev; in cxlflash_afu_debug()
3477 struct cxlflash_cfg *cfg = file->private_data; in cxlflash_chr_ioctl() local
3478 struct device *dev = &cfg->dev->dev; in cxlflash_chr_ioctl()
3499 down_read(&cfg->ioctl_rwsem); in cxlflash_chr_ioctl()
3543 rc = do_ioctl(cfg, (void *)&buf); in cxlflash_chr_ioctl()
3555 up_read(&cfg->ioctl_rwsem); in cxlflash_chr_ioctl()
3577 * @cfg: Internal structure associated with the host.
3581 static int init_chrdev(struct cxlflash_cfg *cfg) in init_chrdev() argument
3583 struct device *dev = &cfg->dev->dev; in init_chrdev()
3597 cdev_init(&cfg->cdev, &cxlflash_chr_fops); in init_chrdev()
3599 rc = cdev_add(&cfg->cdev, devno, 1); in init_chrdev()
3614 cfg->chardev = char_dev; in init_chrdev()
3619 cdev_del(&cfg->cdev); in init_chrdev()
3645 struct cxlflash_cfg *cfg = NULL; in cxlflash_probe() local
3669 cfg = shost_priv(host); in cxlflash_probe()
3670 cfg->state = STATE_PROBING; in cxlflash_probe()
3671 cfg->host = host; in cxlflash_probe()
3672 rc = alloc_mem(cfg); in cxlflash_probe()
3676 scsi_host_put(cfg->host); in cxlflash_probe()
3680 cfg->init_state = INIT_STATE_NONE; in cxlflash_probe()
3681 cfg->dev = pdev; in cxlflash_probe()
3682 cfg->cxl_fops = cxlflash_cxl_fops; in cxlflash_probe()
3683 cfg->ops = cxlflash_assign_ops(ddv); in cxlflash_probe()
3684 WARN_ON_ONCE(!cfg->ops); in cxlflash_probe()
3693 cfg->promote_lun_index = 0; in cxlflash_probe()
3696 cfg->last_lun_index[k] = CXLFLASH_NUM_VLUNS/2 - 1; in cxlflash_probe()
3698 cfg->dev_id = (struct pci_device_id *)dev_id; in cxlflash_probe()
3700 init_waitqueue_head(&cfg->tmf_waitq); in cxlflash_probe()
3701 init_waitqueue_head(&cfg->reset_waitq); in cxlflash_probe()
3703 INIT_WORK(&cfg->work_q, cxlflash_worker_thread); in cxlflash_probe()
3704 cfg->lr_state = LINK_RESET_INVALID; in cxlflash_probe()
3705 cfg->lr_port = -1; in cxlflash_probe()
3706 spin_lock_init(&cfg->tmf_slock); in cxlflash_probe()
3707 mutex_init(&cfg->ctx_tbl_list_mutex); in cxlflash_probe()
3708 mutex_init(&cfg->ctx_recovery_mutex); in cxlflash_probe()
3709 init_rwsem(&cfg->ioctl_rwsem); in cxlflash_probe()
3710 INIT_LIST_HEAD(&cfg->ctx_err_recovery); in cxlflash_probe()
3711 INIT_LIST_HEAD(&cfg->lluns); in cxlflash_probe()
3713 pci_set_drvdata(pdev, cfg); in cxlflash_probe()
3715 rc = init_pci(cfg); in cxlflash_probe()
3720 cfg->init_state = INIT_STATE_PCI; in cxlflash_probe()
3722 cfg->afu_cookie = cfg->ops->create_afu(pdev); in cxlflash_probe()
3723 if (unlikely(!cfg->afu_cookie)) { in cxlflash_probe()
3729 rc = init_afu(cfg); in cxlflash_probe()
3730 if (rc && !wq_has_sleeper(&cfg->reset_waitq)) { in cxlflash_probe()
3734 cfg->init_state = INIT_STATE_AFU; in cxlflash_probe()
3736 rc = init_scsi(cfg); in cxlflash_probe()
3741 cfg->init_state = INIT_STATE_SCSI; in cxlflash_probe()
3743 rc = init_chrdev(cfg); in cxlflash_probe()
3748 cfg->init_state = INIT_STATE_CDEV; in cxlflash_probe()
3750 if (wq_has_sleeper(&cfg->reset_waitq)) { in cxlflash_probe()
3751 cfg->state = STATE_PROBED; in cxlflash_probe()
3752 wake_up_all(&cfg->reset_waitq); in cxlflash_probe()
3754 cfg->state = STATE_NORMAL; in cxlflash_probe()
3760 cfg->state = STATE_PROBED; in cxlflash_probe()
3779 struct cxlflash_cfg *cfg = pci_get_drvdata(pdev); in cxlflash_pci_error_detected() local
3780 struct device *dev = &cfg->dev->dev; in cxlflash_pci_error_detected()
3786 wait_event(cfg->reset_waitq, cfg->state != STATE_RESET && in cxlflash_pci_error_detected()
3787 cfg->state != STATE_PROBING); in cxlflash_pci_error_detected()
3788 if (cfg->state == STATE_FAILTERM) in cxlflash_pci_error_detected()
3791 cfg->state = STATE_RESET; in cxlflash_pci_error_detected()
3792 scsi_block_requests(cfg->host); in cxlflash_pci_error_detected()
3793 drain_ioctls(cfg); in cxlflash_pci_error_detected()
3794 rc = cxlflash_mark_contexts_error(cfg); in cxlflash_pci_error_detected()
3798 term_afu(cfg); in cxlflash_pci_error_detected()
3801 cfg->state = STATE_FAILTERM; in cxlflash_pci_error_detected()
3802 wake_up_all(&cfg->reset_waitq); in cxlflash_pci_error_detected()
3803 scsi_unblock_requests(cfg->host); in cxlflash_pci_error_detected()
3823 struct cxlflash_cfg *cfg = pci_get_drvdata(pdev); in cxlflash_pci_slot_reset() local
3824 struct device *dev = &cfg->dev->dev; in cxlflash_pci_slot_reset()
3828 rc = init_afu(cfg); in cxlflash_pci_slot_reset()
3843 struct cxlflash_cfg *cfg = pci_get_drvdata(pdev); in cxlflash_pci_resume() local
3844 struct device *dev = &cfg->dev->dev; in cxlflash_pci_resume()
3848 cfg->state = STATE_NORMAL; in cxlflash_pci_resume()
3849 wake_up_all(&cfg->reset_waitq); in cxlflash_pci_resume()
3850 scsi_unblock_requests(cfg->host); in cxlflash_pci_resume()