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()
1684 for (k = 0; k < cfg->num_fc_ports; k++) { in read_vpd()
1725 * @cfg: Internal structure associated with the host.
1730 static void init_pcr(struct cxlflash_cfg *cfg) in init_pcr() argument
1732 struct afu *afu = cfg->afu; in init_pcr()
1752 hwq->ctx_hndl = (u16) cfg->ops->process_element(cookie); in init_pcr()
1763 * @cfg: Internal structure associated with the host.
1765 static int init_global(struct cxlflash_cfg *cfg) in init_global() argument
1767 struct afu *afu = cfg->afu; in init_global()
1768 struct device *dev = &cfg->dev->dev; in init_global()
1779 rc = read_vpd(cfg, &wwpn[0]); in init_global()
1815 writeq_be(PORT_MASK(cfg->num_fc_ports), in init_global()
1817 num_ports = cfg->num_fc_ports; in init_global()
1821 fc_port_regs = get_fc_port_regs(cfg, i); in init_global()
1845 reg = cfg->ops->get_irq_objhndl(ctx, j); in init_global()
1879 cfg->ws_unmap = true; in init_global()
1889 * @cfg: Internal structure associated with the host.
1891 static int start_afu(struct cxlflash_cfg *cfg) in start_afu() argument
1893 struct afu *afu = cfg->afu; in start_afu()
1894 struct device *dev = &cfg->dev->dev; in start_afu()
1899 init_pcr(cfg); in start_afu()
1935 rc = init_global(cfg); in start_afu()
1943 * @cfg: Internal structure associated with the host.
1948 static enum undo_level init_intr(struct cxlflash_cfg *cfg, in init_intr() argument
1951 struct device *dev = &cfg->dev->dev; in init_intr()
1958 rc = cfg->ops->allocate_afu_irqs(ctx, num_irqs); in init_intr()
1966 rc = cfg->ops->map_afu_irq(ctx, 1, cxlflash_sync_err_irq, hwq, in init_intr()
1974 rc = cfg->ops->map_afu_irq(ctx, 2, cxlflash_rrq_irq, hwq, in init_intr()
1986 rc = cfg->ops->map_afu_irq(ctx, 3, cxlflash_async_err_irq, hwq, in init_intr()
1999 * @cfg: Internal structure associated with the host.
2004 static int init_mc(struct cxlflash_cfg *cfg, u32 index) in init_mc() argument
2007 struct device *dev = &cfg->dev->dev; in init_mc()
2008 struct hwq *hwq = get_hwq(cfg->afu, index); in init_mc()
2013 hwq->afu = cfg->afu; in init_mc()
2018 ctx = cfg->ops->get_context(cfg->dev, cfg->afu_cookie); in init_mc()
2021 ctx = cfg->ops->dev_context_init(cfg->dev, cfg->afu_cookie); in init_mc()
2034 cfg->ops->set_master(ctx); in init_mc()
2038 rc = cfg->ops->afu_reset(ctx); in init_mc()
2046 level = init_intr(cfg, hwq); in init_mc()
2053 rc = cfg->ops->start_context(hwq->ctx_cookie); in init_mc()
2064 term_intr(cfg, level, index); in init_mc()
2066 cfg->ops->release_context(ctx); in init_mc()
2074 * @cfg: Internal structure associated with the host.
2087 static void get_num_afu_ports(struct cxlflash_cfg *cfg) in get_num_afu_ports() argument
2089 struct afu *afu = cfg->afu; in get_num_afu_ports()
2090 struct device *dev = &cfg->dev->dev; in get_num_afu_ports()
2101 cfg->num_fc_ports = num_fc_ports; in get_num_afu_ports()
2102 cfg->host->max_channel = PORTNUM2CHAN(num_fc_ports); in get_num_afu_ports()
2107 * @cfg: Internal structure associated with the host.
2114 static int init_afu(struct cxlflash_cfg *cfg) in init_afu() argument
2118 struct afu *afu = cfg->afu; in init_afu()
2119 struct device *dev = &cfg->dev->dev; in init_afu()
2123 cfg->ops->perst_reloads_same_image(cfg->afu_cookie, true); in init_afu()
2128 rc = init_mc(cfg, i); in init_afu()
2138 afu->afu_map = cfg->ops->psa_map(hwq->ctx_cookie); in init_afu()
2169 get_num_afu_ports(cfg); in init_afu()
2171 rc = start_afu(cfg); in init_afu()
2177 afu_err_intr_init(cfg->afu); in init_afu()
2185 cxlflash_restore_luntable(cfg); in init_afu()
2192 term_intr(cfg, UNMAP_THREE, i); in init_afu()
2193 term_mc(cfg, i); in init_afu()
2200 * @cfg: Internal structure associated with the host.
2204 static int afu_reset(struct cxlflash_cfg *cfg) in afu_reset() argument
2206 struct device *dev = &cfg->dev->dev; in afu_reset()
2212 term_afu(cfg); in afu_reset()
2214 rc = init_afu(cfg); in afu_reset()
2222 * @cfg: Internal structure associated with the host.
2227 static void drain_ioctls(struct cxlflash_cfg *cfg) in drain_ioctls() argument
2229 down_write(&cfg->ioctl_rwsem); in drain_ioctls()
2230 up_write(&cfg->ioctl_rwsem); in drain_ioctls()
2240 struct cxlflash_cfg *cfg = data; in cxlflash_async_reset_host() local
2241 struct device *dev = &cfg->dev->dev; in cxlflash_async_reset_host()
2244 if (cfg->state != STATE_RESET) { in cxlflash_async_reset_host()
2246 __func__, cfg->state); in cxlflash_async_reset_host()
2250 drain_ioctls(cfg); in cxlflash_async_reset_host()
2251 cxlflash_mark_contexts_error(cfg); in cxlflash_async_reset_host()
2252 rc = afu_reset(cfg); in cxlflash_async_reset_host()
2254 cfg->state = STATE_FAILTERM; in cxlflash_async_reset_host()
2256 cfg->state = STATE_NORMAL; in cxlflash_async_reset_host()
2257 wake_up_all(&cfg->reset_waitq); in cxlflash_async_reset_host()
2260 scsi_unblock_requests(cfg->host); in cxlflash_async_reset_host()
2265 * @cfg: Internal structure associated with the host.
2267 static void cxlflash_schedule_async_reset(struct cxlflash_cfg *cfg) in cxlflash_schedule_async_reset() argument
2269 struct device *dev = &cfg->dev->dev; in cxlflash_schedule_async_reset()
2271 if (cfg->state != STATE_NORMAL) { in cxlflash_schedule_async_reset()
2273 __func__, cfg->state); in cxlflash_schedule_async_reset()
2277 cfg->state = STATE_RESET; in cxlflash_schedule_async_reset()
2278 scsi_block_requests(cfg->host); in cxlflash_schedule_async_reset()
2279 cfg->async_reset_cookie = async_schedule(cxlflash_async_reset_host, in cxlflash_schedule_async_reset()
2280 cfg); in cxlflash_schedule_async_reset()
2301 struct cxlflash_cfg *cfg = afu->parent; in send_afu_cmd() local
2302 struct device *dev = &cfg->dev->dev; in send_afu_cmd()
2310 if (cfg->state != STATE_NORMAL) { in send_afu_cmd()
2312 __func__, cfg->state); in send_afu_cmd()
2355 cxlflash_schedule_async_reset(cfg); in send_afu_cmd()
2395 struct cxlflash_cfg *cfg = afu->parent; in cxlflash_afu_sync() local
2396 struct device *dev = &cfg->dev->dev; in cxlflash_afu_sync()
2428 struct cxlflash_cfg *cfg = shost_priv(host); in cxlflash_eh_abort_handler() local
2430 struct device *dev = &cfg->dev->dev; in cxlflash_eh_abort_handler()
2431 struct afu *afu = cfg->afu; in cxlflash_eh_abort_handler()
2445 if (cfg->state != STATE_NORMAL) { in cxlflash_eh_abort_handler()
2447 __func__, cfg->state); in cxlflash_eh_abort_handler()
2475 struct cxlflash_cfg *cfg = shost_priv(host); in cxlflash_eh_device_reset_handler() local
2476 struct device *dev = &cfg->dev->dev; in cxlflash_eh_device_reset_handler()
2482 switch (cfg->state) { in cxlflash_eh_device_reset_handler()
2484 rcr = send_tmf(cfg, sdev, TMF_LUN_RESET); in cxlflash_eh_device_reset_handler()
2489 wait_event(cfg->reset_waitq, cfg->state != STATE_RESET); in cxlflash_eh_device_reset_handler()
2518 struct cxlflash_cfg *cfg = shost_priv(host); in cxlflash_eh_host_reset_handler() local
2519 struct device *dev = &cfg->dev->dev; in cxlflash_eh_host_reset_handler()
2523 switch (cfg->state) { in cxlflash_eh_host_reset_handler()
2525 cfg->state = STATE_RESET; in cxlflash_eh_host_reset_handler()
2526 drain_ioctls(cfg); in cxlflash_eh_host_reset_handler()
2527 cxlflash_mark_contexts_error(cfg); in cxlflash_eh_host_reset_handler()
2528 rcr = afu_reset(cfg); in cxlflash_eh_host_reset_handler()
2531 cfg->state = STATE_FAILTERM; in cxlflash_eh_host_reset_handler()
2533 cfg->state = STATE_NORMAL; in cxlflash_eh_host_reset_handler()
2534 wake_up_all(&cfg->reset_waitq); in cxlflash_eh_host_reset_handler()
2538 wait_event(cfg->reset_waitq, cfg->state != STATE_RESET); in cxlflash_eh_host_reset_handler()
2539 if (cfg->state == STATE_NORMAL) in cxlflash_eh_host_reset_handler()
2573 * @cfg: Internal structure associated with the host.
2579 struct cxlflash_cfg *cfg, in cxlflash_show_port_status() argument
2582 struct device *dev = &cfg->dev->dev; in cxlflash_show_port_status()
2589 if (port >= cfg->num_fc_ports) { in cxlflash_show_port_status()
2595 fc_port_regs = get_fc_port_regs(cfg, port); in cxlflash_show_port_status()
2621 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port0_show() local
2623 return cxlflash_show_port_status(0, cfg, buf); in port0_show()
2638 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port1_show() local
2640 return cxlflash_show_port_status(1, cfg, buf); in port1_show()
2655 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port2_show() local
2657 return cxlflash_show_port_status(2, cfg, buf); in port2_show()
2672 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port3_show() local
2674 return cxlflash_show_port_status(3, cfg, buf); in port3_show()
2688 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in lun_mode_show() local
2689 struct afu *afu = cfg->afu; in lun_mode_show()
2721 struct cxlflash_cfg *cfg = shost_priv(shost); in lun_mode_store() local
2722 struct afu *afu = cfg->afu; in lun_mode_store()
2738 shost->max_channel = PORTNUM2CHAN(cfg->num_fc_ports); in lun_mode_store()
2740 afu_reset(cfg); in lun_mode_store()
2741 scsi_scan_host(cfg->host); in lun_mode_store()
2771 * @cfg: Internal structure associated with the host.
2777 struct cxlflash_cfg *cfg, in cxlflash_show_port_lun_table() argument
2780 struct device *dev = &cfg->dev->dev; in cxlflash_show_port_lun_table()
2787 if (port >= cfg->num_fc_ports) { in cxlflash_show_port_lun_table()
2793 fc_port_luns = get_fc_port_luns(cfg, port); in cxlflash_show_port_lun_table()
2814 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port0_lun_table_show() local
2816 return cxlflash_show_port_lun_table(0, cfg, buf); in port0_lun_table_show()
2831 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port1_lun_table_show() local
2833 return cxlflash_show_port_lun_table(1, cfg, buf); in port1_lun_table_show()
2848 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port2_lun_table_show() local
2850 return cxlflash_show_port_lun_table(2, cfg, buf); in port2_lun_table_show()
2865 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port3_lun_table_show() local
2867 return cxlflash_show_port_lun_table(3, cfg, buf); in port3_lun_table_show()
2884 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in irqpoll_weight_show() local
2885 struct afu *afu = cfg->afu; in irqpoll_weight_show()
2906 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in irqpoll_weight_store() local
2907 struct device *cfgdev = &cfg->dev->dev; in irqpoll_weight_store()
2908 struct afu *afu = cfg->afu; in irqpoll_weight_store()
2962 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in num_hwqs_show() local
2963 struct afu *afu = cfg->afu; in num_hwqs_show()
2986 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in num_hwqs_store() local
2987 struct afu *afu = cfg->afu; in num_hwqs_store()
3006 switch (cfg->state) { in num_hwqs_store()
3008 cfg->state = STATE_RESET; in num_hwqs_store()
3009 drain_ioctls(cfg); in num_hwqs_store()
3010 cxlflash_mark_contexts_error(cfg); in num_hwqs_store()
3011 rc = afu_reset(cfg); in num_hwqs_store()
3013 cfg->state = STATE_FAILTERM; in num_hwqs_store()
3015 cfg->state = STATE_NORMAL; in num_hwqs_store()
3016 wake_up_all(&cfg->reset_waitq); in num_hwqs_store()
3019 wait_event(cfg->reset_waitq, cfg->state != STATE_RESET); in num_hwqs_store()
3020 if (cfg->state == STATE_NORMAL) in num_hwqs_store()
3026 __func__, cfg->state); in num_hwqs_store()
3047 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in hwq_mode_show() local
3048 struct afu *afu = cfg->afu; in hwq_mode_show()
3072 struct cxlflash_cfg *cfg = shost_priv(shost); in hwq_mode_store() local
3073 struct device *cfgdev = &cfg->dev->dev; in hwq_mode_store()
3074 struct afu *afu = cfg->afu; in hwq_mode_store()
3217 struct cxlflash_cfg *cfg = container_of(work, struct cxlflash_cfg, in cxlflash_worker_thread() local
3219 struct afu *afu = cfg->afu; in cxlflash_worker_thread()
3220 struct device *dev = &cfg->dev->dev; in cxlflash_worker_thread()
3227 if (cfg->state != STATE_NORMAL) in cxlflash_worker_thread()
3230 spin_lock_irqsave(cfg->host->host_lock, lock_flags); in cxlflash_worker_thread()
3232 if (cfg->lr_state == LINK_RESET_REQUIRED) { in cxlflash_worker_thread()
3233 port = cfg->lr_port; in cxlflash_worker_thread()
3238 spin_unlock_irqrestore(cfg->host->host_lock, in cxlflash_worker_thread()
3242 fc_port_regs = get_fc_port_regs(cfg, port); in cxlflash_worker_thread()
3244 spin_lock_irqsave(cfg->host->host_lock, lock_flags); in cxlflash_worker_thread()
3247 cfg->lr_state = LINK_RESET_COMPLETE; in cxlflash_worker_thread()
3250 spin_unlock_irqrestore(cfg->host->host_lock, lock_flags); in cxlflash_worker_thread()
3252 if (atomic_dec_if_positive(&cfg->scan_host_needed) >= 0) in cxlflash_worker_thread()
3253 scsi_scan_host(cfg->host); in cxlflash_worker_thread()
3267 struct cxlflash_cfg *cfg; in cxlflash_chr_open() local
3272 cfg = container_of(inode->i_cdev, struct cxlflash_cfg, cdev); in cxlflash_chr_open()
3273 file->private_data = cfg; in cxlflash_chr_open()
3296 * @cfg: Internal structure associated with the host.
3301 static int cxlflash_lun_provision(struct cxlflash_cfg *cfg, in cxlflash_lun_provision() argument
3304 struct afu *afu = cfg->afu; in cxlflash_lun_provision()
3305 struct device *dev = &cfg->dev->dev; in cxlflash_lun_provision()
3322 if (port >= cfg->num_fc_ports) { in cxlflash_lun_provision()
3339 fc_port_regs = get_fc_port_regs(cfg, port); in cxlflash_lun_provision()
3387 * @cfg: Internal structure associated with the host.
3395 static int cxlflash_afu_debug(struct cxlflash_cfg *cfg, in cxlflash_afu_debug() argument
3398 struct afu *afu = cfg->afu; in cxlflash_afu_debug()
3399 struct device *dev = &cfg->dev->dev; in cxlflash_afu_debug()
3496 struct cxlflash_cfg *cfg = file->private_data; in cxlflash_chr_ioctl() local
3497 struct device *dev = &cfg->dev->dev; in cxlflash_chr_ioctl()
3518 down_read(&cfg->ioctl_rwsem); in cxlflash_chr_ioctl()
3562 rc = do_ioctl(cfg, (void *)&buf); in cxlflash_chr_ioctl()
3574 up_read(&cfg->ioctl_rwsem); in cxlflash_chr_ioctl()
3596 * @cfg: Internal structure associated with the host.
3600 static int init_chrdev(struct cxlflash_cfg *cfg) in init_chrdev() argument
3602 struct device *dev = &cfg->dev->dev; in init_chrdev()
3616 cdev_init(&cfg->cdev, &cxlflash_chr_fops); in init_chrdev()
3618 rc = cdev_add(&cfg->cdev, devno, 1); in init_chrdev()
3633 cfg->chardev = char_dev; in init_chrdev()
3638 cdev_del(&cfg->cdev); in init_chrdev()
3664 struct cxlflash_cfg *cfg = NULL; in cxlflash_probe() local
3688 cfg = shost_priv(host); in cxlflash_probe()
3689 cfg->state = STATE_PROBING; in cxlflash_probe()
3690 cfg->host = host; in cxlflash_probe()
3691 rc = alloc_mem(cfg); in cxlflash_probe()
3695 scsi_host_put(cfg->host); in cxlflash_probe()
3699 cfg->init_state = INIT_STATE_NONE; in cxlflash_probe()
3700 cfg->dev = pdev; in cxlflash_probe()
3701 cfg->cxl_fops = cxlflash_cxl_fops; in cxlflash_probe()
3702 cfg->ops = cxlflash_assign_ops(ddv); in cxlflash_probe()
3703 WARN_ON_ONCE(!cfg->ops); in cxlflash_probe()
3712 cfg->promote_lun_index = 0; in cxlflash_probe()
3715 cfg->last_lun_index[k] = CXLFLASH_NUM_VLUNS/2 - 1; in cxlflash_probe()
3717 cfg->dev_id = (struct pci_device_id *)dev_id; in cxlflash_probe()
3719 init_waitqueue_head(&cfg->tmf_waitq); in cxlflash_probe()
3720 init_waitqueue_head(&cfg->reset_waitq); in cxlflash_probe()
3722 INIT_WORK(&cfg->work_q, cxlflash_worker_thread); in cxlflash_probe()
3723 cfg->lr_state = LINK_RESET_INVALID; in cxlflash_probe()
3724 cfg->lr_port = -1; in cxlflash_probe()
3725 spin_lock_init(&cfg->tmf_slock); in cxlflash_probe()
3726 mutex_init(&cfg->ctx_tbl_list_mutex); in cxlflash_probe()
3727 mutex_init(&cfg->ctx_recovery_mutex); in cxlflash_probe()
3728 init_rwsem(&cfg->ioctl_rwsem); in cxlflash_probe()
3729 INIT_LIST_HEAD(&cfg->ctx_err_recovery); in cxlflash_probe()
3730 INIT_LIST_HEAD(&cfg->lluns); in cxlflash_probe()
3732 pci_set_drvdata(pdev, cfg); in cxlflash_probe()
3734 rc = init_pci(cfg); in cxlflash_probe()
3739 cfg->init_state = INIT_STATE_PCI; in cxlflash_probe()
3741 cfg->afu_cookie = cfg->ops->create_afu(pdev); in cxlflash_probe()
3742 if (unlikely(!cfg->afu_cookie)) { in cxlflash_probe()
3748 rc = init_afu(cfg); in cxlflash_probe()
3749 if (rc && !wq_has_sleeper(&cfg->reset_waitq)) { in cxlflash_probe()
3753 cfg->init_state = INIT_STATE_AFU; in cxlflash_probe()
3755 rc = init_scsi(cfg); in cxlflash_probe()
3760 cfg->init_state = INIT_STATE_SCSI; in cxlflash_probe()
3762 rc = init_chrdev(cfg); in cxlflash_probe()
3767 cfg->init_state = INIT_STATE_CDEV; in cxlflash_probe()
3769 if (wq_has_sleeper(&cfg->reset_waitq)) { in cxlflash_probe()
3770 cfg->state = STATE_PROBED; in cxlflash_probe()
3771 wake_up_all(&cfg->reset_waitq); in cxlflash_probe()
3773 cfg->state = STATE_NORMAL; in cxlflash_probe()
3779 cfg->state = STATE_PROBED; in cxlflash_probe()
3798 struct cxlflash_cfg *cfg = pci_get_drvdata(pdev); in cxlflash_pci_error_detected() local
3799 struct device *dev = &cfg->dev->dev; in cxlflash_pci_error_detected()
3805 wait_event(cfg->reset_waitq, cfg->state != STATE_RESET && in cxlflash_pci_error_detected()
3806 cfg->state != STATE_PROBING); in cxlflash_pci_error_detected()
3807 if (cfg->state == STATE_FAILTERM) in cxlflash_pci_error_detected()
3810 cfg->state = STATE_RESET; in cxlflash_pci_error_detected()
3811 scsi_block_requests(cfg->host); in cxlflash_pci_error_detected()
3812 drain_ioctls(cfg); in cxlflash_pci_error_detected()
3813 rc = cxlflash_mark_contexts_error(cfg); in cxlflash_pci_error_detected()
3817 term_afu(cfg); in cxlflash_pci_error_detected()
3820 cfg->state = STATE_FAILTERM; in cxlflash_pci_error_detected()
3821 wake_up_all(&cfg->reset_waitq); in cxlflash_pci_error_detected()
3822 scsi_unblock_requests(cfg->host); in cxlflash_pci_error_detected()
3842 struct cxlflash_cfg *cfg = pci_get_drvdata(pdev); in cxlflash_pci_slot_reset() local
3843 struct device *dev = &cfg->dev->dev; in cxlflash_pci_slot_reset()
3847 rc = init_afu(cfg); in cxlflash_pci_slot_reset()
3862 struct cxlflash_cfg *cfg = pci_get_drvdata(pdev); in cxlflash_pci_resume() local
3863 struct device *dev = &cfg->dev->dev; in cxlflash_pci_resume()
3867 cfg->state = STATE_NORMAL; in cxlflash_pci_resume()
3868 wake_up_all(&cfg->reset_waitq); in cxlflash_pci_resume()
3869 scsi_unblock_requests(cfg->host); in cxlflash_pci_resume()