• Home
  • Raw
  • Download

Lines Matching full:cfg

49 	struct cxlflash_cfg *cfg = afu->parent;  in process_cmd_err()  local
50 struct device *dev = &cfg->dev->dev; in process_cmd_err()
166 struct cxlflash_cfg *cfg = afu->parent; in cmd_complete() local
167 struct device *dev = &cfg->dev->dev; in cmd_complete()
185 spin_lock_irqsave(&cfg->tmf_slock, lock_flags); in cmd_complete()
186 cfg->tmf_active = false; in cmd_complete()
187 wake_up_all_locked(&cfg->tmf_waitq); in cmd_complete()
188 spin_unlock_irqrestore(&cfg->tmf_slock, lock_flags); in cmd_complete()
202 struct cxlflash_cfg *cfg = hwq->afu->parent; in flush_pending_cmds() local
222 spin_lock_irqsave(&cfg->tmf_slock, lock_flags); in flush_pending_cmds()
223 cfg->tmf_active = false; in flush_pending_cmds()
224 wake_up_all_locked(&cfg->tmf_waitq); in flush_pending_cmds()
225 spin_unlock_irqrestore(&cfg->tmf_slock, in flush_pending_cmds()
246 struct cxlflash_cfg *cfg = hwq->afu->parent; in context_reset() local
247 struct device *dev = &cfg->dev->dev; in context_reset()
311 struct cxlflash_cfg *cfg = afu->parent; in send_cmd_ioarrin() local
312 struct device *dev = &cfg->dev->dev; in send_cmd_ioarrin()
355 struct cxlflash_cfg *cfg = afu->parent; in send_cmd_sq() local
356 struct device *dev = &cfg->dev->dev; in send_cmd_sq()
400 struct cxlflash_cfg *cfg = afu->parent; in wait_resp() local
401 struct device *dev = &cfg->dev->dev; in wait_resp()
460 * @cfg: Internal structure associated with the host.
467 static int send_tmf(struct cxlflash_cfg *cfg, struct scsi_device *sdev, in send_tmf() argument
470 struct afu *afu = cfg->afu; in send_tmf()
472 struct device *dev = &cfg->dev->dev; in send_tmf()
491 spin_lock_irqsave(&cfg->tmf_slock, lock_flags); in send_tmf()
492 if (cfg->tmf_active) in send_tmf()
493 wait_event_interruptible_lock_irq(cfg->tmf_waitq, in send_tmf()
494 !cfg->tmf_active, in send_tmf()
495 cfg->tmf_slock); in send_tmf()
496 cfg->tmf_active = true; in send_tmf()
497 spin_unlock_irqrestore(&cfg->tmf_slock, lock_flags); in send_tmf()
514 spin_lock_irqsave(&cfg->tmf_slock, lock_flags); in send_tmf()
515 cfg->tmf_active = false; in send_tmf()
516 spin_unlock_irqrestore(&cfg->tmf_slock, lock_flags); in send_tmf()
520 spin_lock_irqsave(&cfg->tmf_slock, lock_flags); in send_tmf()
522 to = wait_event_interruptible_lock_irq_timeout(cfg->tmf_waitq, in send_tmf()
523 !cfg->tmf_active, in send_tmf()
524 cfg->tmf_slock, in send_tmf()
538 cfg->tmf_active = false; in send_tmf()
539 spin_unlock_irqrestore(&cfg->tmf_slock, lock_flags); in send_tmf()
571 struct cxlflash_cfg *cfg = shost_priv(host); in cxlflash_queuecommand() local
572 struct afu *afu = cfg->afu; in cxlflash_queuecommand()
573 struct device *dev = &cfg->dev->dev; in cxlflash_queuecommand()
595 spin_lock_irqsave(&cfg->tmf_slock, lock_flags); in cxlflash_queuecommand()
596 if (cfg->tmf_active) { in cxlflash_queuecommand()
597 spin_unlock_irqrestore(&cfg->tmf_slock, lock_flags); in cxlflash_queuecommand()
601 spin_unlock_irqrestore(&cfg->tmf_slock, lock_flags); in cxlflash_queuecommand()
603 switch (cfg->state) { in cxlflash_queuecommand()
650 * @cfg: Internal structure associated with the host.
652 static void cxlflash_wait_for_pci_err_recovery(struct cxlflash_cfg *cfg) in cxlflash_wait_for_pci_err_recovery() argument
654 struct pci_dev *pdev = cfg->dev; in cxlflash_wait_for_pci_err_recovery()
657 wait_event_timeout(cfg->reset_waitq, in cxlflash_wait_for_pci_err_recovery()
664 * @cfg: Internal structure associated with the host.
666 static void free_mem(struct cxlflash_cfg *cfg) in free_mem() argument
668 struct afu *afu = cfg->afu; in free_mem()
670 if (cfg->afu) { in free_mem()
672 cfg->afu = NULL; in free_mem()
678 * @cfg: Internal structure associated with the host.
680 static void cxlflash_reset_sync(struct cxlflash_cfg *cfg) in cxlflash_reset_sync() argument
682 if (cfg->async_reset_cookie == 0) in cxlflash_reset_sync()
686 async_synchronize_cookie(cfg->async_reset_cookie + 1); in cxlflash_reset_sync()
687 cfg->async_reset_cookie = 0; in cxlflash_reset_sync()
692 * @cfg: Internal structure associated with the host.
699 static void stop_afu(struct cxlflash_cfg *cfg) in stop_afu() argument
701 struct afu *afu = cfg->afu; in stop_afu()
705 cancel_work_sync(&cfg->work_q); in stop_afu()
707 cxlflash_reset_sync(cfg); in stop_afu()
722 cfg->ops->psa_unmap(afu->afu_map); in stop_afu()
730 * @cfg: Internal structure associated with the host.
736 static void term_intr(struct cxlflash_cfg *cfg, enum undo_level level, in term_intr() argument
739 struct afu *afu = cfg->afu; in term_intr()
740 struct device *dev = &cfg->dev->dev; in term_intr()
759 cfg->ops->unmap_afu_irq(hwq->ctx_cookie, 3, hwq); in term_intr()
761 cfg->ops->unmap_afu_irq(hwq->ctx_cookie, 2, hwq); in term_intr()
763 cfg->ops->unmap_afu_irq(hwq->ctx_cookie, 1, hwq); in term_intr()
765 cfg->ops->free_afu_irqs(hwq->ctx_cookie); in term_intr()
775 * @cfg: Internal structure associated with the host.
780 static void term_mc(struct cxlflash_cfg *cfg, u32 index) in term_mc() argument
782 struct afu *afu = cfg->afu; in term_mc()
783 struct device *dev = &cfg->dev->dev; in term_mc()
799 WARN_ON(cfg->ops->stop_context(hwq->ctx_cookie)); in term_mc()
801 WARN_ON(cfg->ops->release_context(hwq->ctx_cookie)); in term_mc()
815 * @cfg: Internal structure associated with the host.
819 static void term_afu(struct cxlflash_cfg *cfg) in term_afu() argument
821 struct device *dev = &cfg->dev->dev; in term_afu()
833 for (k = cfg->afu->num_hwqs - 1; k >= 0; k--) in term_afu()
834 term_intr(cfg, UNMAP_THREE, k); in term_afu()
836 stop_afu(cfg); in term_afu()
838 for (k = cfg->afu->num_hwqs - 1; k >= 0; k--) in term_afu()
839 term_mc(cfg, k); in term_afu()
846 * @cfg: Internal structure associated with the host.
854 static void notify_shutdown(struct cxlflash_cfg *cfg, bool wait) in notify_shutdown() argument
856 struct afu *afu = cfg->afu; in notify_shutdown()
857 struct device *dev = &cfg->dev->dev; in notify_shutdown()
863 ddv = (struct dev_dependent_vals *)cfg->dev_id->driver_data; in notify_shutdown()
873 for (i = 0; i < cfg->num_fc_ports; i++) { in notify_shutdown()
874 fc_port_regs = get_fc_port_regs(cfg, i); in notify_shutdown()
885 for (i = 0; i < cfg->num_fc_ports; i++) { in notify_shutdown()
886 fc_port_regs = get_fc_port_regs(cfg, i); in notify_shutdown()
933 * @cfg: Internal structure associated with the host.
935 static void cxlflash_release_chrdev(struct cxlflash_cfg *cfg) in cxlflash_release_chrdev() argument
937 device_unregister(cfg->chardev); in cxlflash_release_chrdev()
938 cfg->chardev = NULL; in cxlflash_release_chrdev()
939 cdev_del(&cfg->cdev); in cxlflash_release_chrdev()
940 cxlflash_put_minor(MINOR(cfg->cdev.dev)); in cxlflash_release_chrdev()
952 struct cxlflash_cfg *cfg = pci_get_drvdata(pdev); in cxlflash_remove() local
962 wait_event(cfg->reset_waitq, cfg->state != STATE_RESET && in cxlflash_remove()
963 cfg->state != STATE_PROBING); in cxlflash_remove()
964 spin_lock_irqsave(&cfg->tmf_slock, lock_flags); in cxlflash_remove()
965 if (cfg->tmf_active) in cxlflash_remove()
966 wait_event_interruptible_lock_irq(cfg->tmf_waitq, in cxlflash_remove()
967 !cfg->tmf_active, in cxlflash_remove()
968 cfg->tmf_slock); in cxlflash_remove()
969 spin_unlock_irqrestore(&cfg->tmf_slock, lock_flags); in cxlflash_remove()
972 notify_shutdown(cfg, true); in cxlflash_remove()
974 cfg->state = STATE_FAILTERM; in cxlflash_remove()
975 cxlflash_stop_term_user_contexts(cfg); in cxlflash_remove()
977 switch (cfg->init_state) { in cxlflash_remove()
979 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()
984 term_afu(cfg); in cxlflash_remove()
986 cfg->ops->destroy_afu(cfg->afu_cookie); in cxlflash_remove()
989 free_mem(cfg); in cxlflash_remove()
990 scsi_host_put(cfg->host); in cxlflash_remove()
999 * @cfg: Internal structure associated with the host.
1007 static int alloc_mem(struct cxlflash_cfg *cfg) in alloc_mem() argument
1010 struct device *dev = &cfg->dev->dev; in alloc_mem()
1013 cfg->afu = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, in alloc_mem()
1015 if (unlikely(!cfg->afu)) { in alloc_mem()
1021 cfg->afu->parent = cfg; in alloc_mem()
1022 cfg->afu->desired_hwqs = CXLFLASH_DEF_HWQS; in alloc_mem()
1023 cfg->afu->afu_map = NULL; in alloc_mem()
1030 * @cfg: Internal structure associated with the host.
1034 static int init_pci(struct cxlflash_cfg *cfg) in init_pci() argument
1036 struct pci_dev *pdev = cfg->dev; in init_pci()
1037 struct device *dev = &cfg->dev->dev; in init_pci()
1043 cxlflash_wait_for_pci_err_recovery(cfg); in init_pci()
1049 cxlflash_wait_for_pci_err_recovery(cfg); in init_pci()
1061 * @cfg: Internal structure associated with the host.
1065 static int init_scsi(struct cxlflash_cfg *cfg) in init_scsi() argument
1067 struct pci_dev *pdev = cfg->dev; in init_scsi()
1068 struct device *dev = &cfg->dev->dev; in init_scsi()
1071 rc = scsi_add_host(cfg->host, &pdev->dev); in init_scsi()
1077 scsi_scan_host(cfg->host); in init_scsi()
1193 struct cxlflash_cfg *cfg = afu->parent; in afu_set_wwpn() local
1194 struct device *dev = &cfg->dev->dev; in afu_set_wwpn()
1228 struct cxlflash_cfg *cfg = afu->parent; in afu_link_reset() local
1229 struct device *dev = &cfg->dev->dev; in afu_link_reset()
1264 struct cxlflash_cfg *cfg = afu->parent; in afu_err_intr_init() local
1295 fc_port_regs = get_fc_port_regs(cfg, 0); in afu_err_intr_init()
1303 for (i = 0; i < cfg->num_fc_ports; i++) { in afu_err_intr_init()
1304 fc_port_regs = get_fc_port_regs(cfg, i); in afu_err_intr_init()
1337 struct cxlflash_cfg *cfg = hwq->afu->parent; in cxlflash_sync_err_irq() local
1338 struct device *dev = &cfg->dev->dev; in cxlflash_sync_err_irq()
1544 struct cxlflash_cfg *cfg = afu->parent; in cxlflash_async_err_irq() local
1545 struct device *dev = &cfg->dev->dev; in cxlflash_async_err_irq()
1580 fc_port_regs = get_fc_port_regs(cfg, port); in cxlflash_async_err_irq()
1593 cfg->lr_state = LINK_RESET_REQUIRED; in cxlflash_async_err_irq()
1594 cfg->lr_port = port; in cxlflash_async_err_irq()
1595 schedule_work(&cfg->work_q); in cxlflash_async_err_irq()
1614 atomic_inc(&cfg->scan_host_needed); in cxlflash_async_err_irq()
1615 schedule_work(&cfg->work_q); in cxlflash_async_err_irq()
1625 * @cfg: Internal structure associated with the host.
1630 static int read_vpd(struct cxlflash_cfg *cfg, u64 wwpn[]) in read_vpd() argument
1632 struct device *dev = &cfg->dev->dev; in read_vpd()
1633 struct pci_dev *pdev = cfg->dev; in read_vpd()
1640 cfg->dev_id->driver_data; in read_vpd()
1645 vpd_size = cfg->ops->read_adapter_vpd(pdev, vpd_data, sizeof(vpd_data)); in read_vpd()
1686 for (k = 0; k < cfg->num_fc_ports; k++) { in read_vpd()
1727 * @cfg: Internal structure associated with the host.
1732 static void init_pcr(struct cxlflash_cfg *cfg) in init_pcr() argument
1734 struct afu *afu = cfg->afu; in init_pcr()
1754 hwq->ctx_hndl = (u16) cfg->ops->process_element(cookie); in init_pcr()
1765 * @cfg: Internal structure associated with the host.
1767 static int init_global(struct cxlflash_cfg *cfg) in init_global() argument
1769 struct afu *afu = cfg->afu; in init_global()
1770 struct device *dev = &cfg->dev->dev; in init_global()
1781 rc = read_vpd(cfg, &wwpn[0]); in init_global()
1817 writeq_be(PORT_MASK(cfg->num_fc_ports), in init_global()
1819 num_ports = cfg->num_fc_ports; in init_global()
1823 fc_port_regs = get_fc_port_regs(cfg, i); in init_global()
1847 reg = cfg->ops->get_irq_objhndl(ctx, j); in init_global()
1881 cfg->ws_unmap = true; in init_global()
1891 * @cfg: Internal structure associated with the host.
1893 static int start_afu(struct cxlflash_cfg *cfg) in start_afu() argument
1895 struct afu *afu = cfg->afu; in start_afu()
1896 struct device *dev = &cfg->dev->dev; in start_afu()
1901 init_pcr(cfg); in start_afu()
1937 rc = init_global(cfg); in start_afu()
1945 * @cfg: Internal structure associated with the host.
1950 static enum undo_level init_intr(struct cxlflash_cfg *cfg, in init_intr() argument
1953 struct device *dev = &cfg->dev->dev; in init_intr()
1960 rc = cfg->ops->allocate_afu_irqs(ctx, num_irqs); in init_intr()
1968 rc = cfg->ops->map_afu_irq(ctx, 1, cxlflash_sync_err_irq, hwq, in init_intr()
1976 rc = cfg->ops->map_afu_irq(ctx, 2, cxlflash_rrq_irq, hwq, in init_intr()
1988 rc = cfg->ops->map_afu_irq(ctx, 3, cxlflash_async_err_irq, hwq, in init_intr()
2001 * @cfg: Internal structure associated with the host.
2006 static int init_mc(struct cxlflash_cfg *cfg, u32 index) in init_mc() argument
2009 struct device *dev = &cfg->dev->dev; in init_mc()
2010 struct hwq *hwq = get_hwq(cfg->afu, index); in init_mc()
2015 hwq->afu = cfg->afu; in init_mc()
2020 ctx = cfg->ops->get_context(cfg->dev, cfg->afu_cookie); in init_mc()
2023 ctx = cfg->ops->dev_context_init(cfg->dev, cfg->afu_cookie); in init_mc()
2036 cfg->ops->set_master(ctx); in init_mc()
2040 rc = cfg->ops->afu_reset(ctx); in init_mc()
2048 level = init_intr(cfg, hwq); in init_mc()
2055 rc = cfg->ops->start_context(hwq->ctx_cookie); in init_mc()
2066 term_intr(cfg, level, index); in init_mc()
2068 cfg->ops->release_context(ctx); in init_mc()
2076 * @cfg: Internal structure associated with the host.
2089 static void get_num_afu_ports(struct cxlflash_cfg *cfg) in get_num_afu_ports() argument
2091 struct afu *afu = cfg->afu; in get_num_afu_ports()
2092 struct device *dev = &cfg->dev->dev; in get_num_afu_ports()
2103 cfg->num_fc_ports = num_fc_ports; in get_num_afu_ports()
2104 cfg->host->max_channel = PORTNUM2CHAN(num_fc_ports); in get_num_afu_ports()
2109 * @cfg: Internal structure associated with the host.
2116 static int init_afu(struct cxlflash_cfg *cfg) in init_afu() argument
2120 struct afu *afu = cfg->afu; in init_afu()
2121 struct device *dev = &cfg->dev->dev; in init_afu()
2125 cfg->ops->perst_reloads_same_image(cfg->afu_cookie, true); in init_afu()
2130 rc = init_mc(cfg, i); in init_afu()
2140 afu->afu_map = cfg->ops->psa_map(hwq->ctx_cookie); in init_afu()
2171 get_num_afu_ports(cfg); in init_afu()
2173 rc = start_afu(cfg); in init_afu()
2179 afu_err_intr_init(cfg->afu); in init_afu()
2187 cxlflash_restore_luntable(cfg); in init_afu()
2194 term_intr(cfg, UNMAP_THREE, i); in init_afu()
2195 term_mc(cfg, i); in init_afu()
2202 * @cfg: Internal structure associated with the host.
2206 static int afu_reset(struct cxlflash_cfg *cfg) in afu_reset() argument
2208 struct device *dev = &cfg->dev->dev; in afu_reset()
2214 term_afu(cfg); in afu_reset()
2216 rc = init_afu(cfg); in afu_reset()
2224 * @cfg: Internal structure associated with the host.
2229 static void drain_ioctls(struct cxlflash_cfg *cfg) in drain_ioctls() argument
2231 down_write(&cfg->ioctl_rwsem); in drain_ioctls()
2232 up_write(&cfg->ioctl_rwsem); in drain_ioctls()
2242 struct cxlflash_cfg *cfg = data; in cxlflash_async_reset_host() local
2243 struct device *dev = &cfg->dev->dev; in cxlflash_async_reset_host()
2246 if (cfg->state != STATE_RESET) { in cxlflash_async_reset_host()
2248 __func__, cfg->state); in cxlflash_async_reset_host()
2252 drain_ioctls(cfg); in cxlflash_async_reset_host()
2253 cxlflash_mark_contexts_error(cfg); in cxlflash_async_reset_host()
2254 rc = afu_reset(cfg); in cxlflash_async_reset_host()
2256 cfg->state = STATE_FAILTERM; in cxlflash_async_reset_host()
2258 cfg->state = STATE_NORMAL; in cxlflash_async_reset_host()
2259 wake_up_all(&cfg->reset_waitq); in cxlflash_async_reset_host()
2262 scsi_unblock_requests(cfg->host); in cxlflash_async_reset_host()
2267 * @cfg: Internal structure associated with the host.
2269 static void cxlflash_schedule_async_reset(struct cxlflash_cfg *cfg) in cxlflash_schedule_async_reset() argument
2271 struct device *dev = &cfg->dev->dev; in cxlflash_schedule_async_reset()
2273 if (cfg->state != STATE_NORMAL) { in cxlflash_schedule_async_reset()
2275 __func__, cfg->state); in cxlflash_schedule_async_reset()
2279 cfg->state = STATE_RESET; in cxlflash_schedule_async_reset()
2280 scsi_block_requests(cfg->host); in cxlflash_schedule_async_reset()
2281 cfg->async_reset_cookie = async_schedule(cxlflash_async_reset_host, in cxlflash_schedule_async_reset()
2282 cfg); in cxlflash_schedule_async_reset()
2303 struct cxlflash_cfg *cfg = afu->parent; in send_afu_cmd() local
2304 struct device *dev = &cfg->dev->dev; in send_afu_cmd()
2312 if (cfg->state != STATE_NORMAL) { in send_afu_cmd()
2314 __func__, cfg->state); in send_afu_cmd()
2357 cxlflash_schedule_async_reset(cfg); in send_afu_cmd()
2397 struct cxlflash_cfg *cfg = afu->parent; in cxlflash_afu_sync() local
2398 struct device *dev = &cfg->dev->dev; in cxlflash_afu_sync()
2430 struct cxlflash_cfg *cfg = shost_priv(host); in cxlflash_eh_abort_handler() local
2432 struct device *dev = &cfg->dev->dev; in cxlflash_eh_abort_handler()
2433 struct afu *afu = cfg->afu; in cxlflash_eh_abort_handler()
2447 if (cfg->state != STATE_NORMAL) { in cxlflash_eh_abort_handler()
2449 __func__, cfg->state); in cxlflash_eh_abort_handler()
2477 struct cxlflash_cfg *cfg = shost_priv(host); in cxlflash_eh_device_reset_handler() local
2478 struct device *dev = &cfg->dev->dev; in cxlflash_eh_device_reset_handler()
2484 switch (cfg->state) { in cxlflash_eh_device_reset_handler()
2486 rcr = send_tmf(cfg, sdev, TMF_LUN_RESET); in cxlflash_eh_device_reset_handler()
2491 wait_event(cfg->reset_waitq, cfg->state != STATE_RESET); in cxlflash_eh_device_reset_handler()
2520 struct cxlflash_cfg *cfg = shost_priv(host); in cxlflash_eh_host_reset_handler() local
2521 struct device *dev = &cfg->dev->dev; in cxlflash_eh_host_reset_handler()
2525 switch (cfg->state) { in cxlflash_eh_host_reset_handler()
2527 cfg->state = STATE_RESET; in cxlflash_eh_host_reset_handler()
2528 drain_ioctls(cfg); in cxlflash_eh_host_reset_handler()
2529 cxlflash_mark_contexts_error(cfg); in cxlflash_eh_host_reset_handler()
2530 rcr = afu_reset(cfg); in cxlflash_eh_host_reset_handler()
2533 cfg->state = STATE_FAILTERM; in cxlflash_eh_host_reset_handler()
2535 cfg->state = STATE_NORMAL; in cxlflash_eh_host_reset_handler()
2536 wake_up_all(&cfg->reset_waitq); in cxlflash_eh_host_reset_handler()
2540 wait_event(cfg->reset_waitq, cfg->state != STATE_RESET); in cxlflash_eh_host_reset_handler()
2541 if (cfg->state == STATE_NORMAL) in cxlflash_eh_host_reset_handler()
2575 * @cfg: Internal structure associated with the host.
2581 struct cxlflash_cfg *cfg, in cxlflash_show_port_status() argument
2584 struct device *dev = &cfg->dev->dev; in cxlflash_show_port_status()
2591 if (port >= cfg->num_fc_ports) { in cxlflash_show_port_status()
2597 fc_port_regs = get_fc_port_regs(cfg, port); in cxlflash_show_port_status()
2623 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port0_show() local
2625 return cxlflash_show_port_status(0, cfg, buf); in port0_show()
2640 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port1_show() local
2642 return cxlflash_show_port_status(1, cfg, buf); in port1_show()
2657 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port2_show() local
2659 return cxlflash_show_port_status(2, cfg, buf); in port2_show()
2674 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port3_show() local
2676 return cxlflash_show_port_status(3, cfg, buf); in port3_show()
2690 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in lun_mode_show() local
2691 struct afu *afu = cfg->afu; in lun_mode_show()
2723 struct cxlflash_cfg *cfg = shost_priv(shost); in lun_mode_store() local
2724 struct afu *afu = cfg->afu; in lun_mode_store()
2740 shost->max_channel = PORTNUM2CHAN(cfg->num_fc_ports); in lun_mode_store()
2742 afu_reset(cfg); in lun_mode_store()
2743 scsi_scan_host(cfg->host); in lun_mode_store()
2773 * @cfg: Internal structure associated with the host.
2779 struct cxlflash_cfg *cfg, in cxlflash_show_port_lun_table() argument
2782 struct device *dev = &cfg->dev->dev; in cxlflash_show_port_lun_table()
2789 if (port >= cfg->num_fc_ports) { in cxlflash_show_port_lun_table()
2795 fc_port_luns = get_fc_port_luns(cfg, port); in cxlflash_show_port_lun_table()
2816 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port0_lun_table_show() local
2818 return cxlflash_show_port_lun_table(0, cfg, buf); in port0_lun_table_show()
2833 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port1_lun_table_show() local
2835 return cxlflash_show_port_lun_table(1, cfg, buf); in port1_lun_table_show()
2850 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port2_lun_table_show() local
2852 return cxlflash_show_port_lun_table(2, cfg, buf); in port2_lun_table_show()
2867 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in port3_lun_table_show() local
2869 return cxlflash_show_port_lun_table(3, cfg, buf); in port3_lun_table_show()
2886 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in irqpoll_weight_show() local
2887 struct afu *afu = cfg->afu; in irqpoll_weight_show()
2908 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in irqpoll_weight_store() local
2909 struct device *cfgdev = &cfg->dev->dev; in irqpoll_weight_store()
2910 struct afu *afu = cfg->afu; in irqpoll_weight_store()
2964 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in num_hwqs_show() local
2965 struct afu *afu = cfg->afu; in num_hwqs_show()
2988 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in num_hwqs_store() local
2989 struct afu *afu = cfg->afu; in num_hwqs_store()
3008 switch (cfg->state) { in num_hwqs_store()
3010 cfg->state = STATE_RESET; in num_hwqs_store()
3011 drain_ioctls(cfg); in num_hwqs_store()
3012 cxlflash_mark_contexts_error(cfg); in num_hwqs_store()
3013 rc = afu_reset(cfg); in num_hwqs_store()
3015 cfg->state = STATE_FAILTERM; in num_hwqs_store()
3017 cfg->state = STATE_NORMAL; in num_hwqs_store()
3018 wake_up_all(&cfg->reset_waitq); in num_hwqs_store()
3021 wait_event(cfg->reset_waitq, cfg->state != STATE_RESET); in num_hwqs_store()
3022 if (cfg->state == STATE_NORMAL) in num_hwqs_store()
3027 __func__, cfg->state); in num_hwqs_store()
3048 struct cxlflash_cfg *cfg = shost_priv(class_to_shost(dev)); in hwq_mode_show() local
3049 struct afu *afu = cfg->afu; in hwq_mode_show()
3073 struct cxlflash_cfg *cfg = shost_priv(shost); in hwq_mode_store() local
3074 struct device *cfgdev = &cfg->dev->dev; in hwq_mode_store()
3075 struct afu *afu = cfg->afu; in hwq_mode_store()
3225 struct cxlflash_cfg *cfg = container_of(work, struct cxlflash_cfg, in cxlflash_worker_thread() local
3227 struct afu *afu = cfg->afu; in cxlflash_worker_thread()
3228 struct device *dev = &cfg->dev->dev; in cxlflash_worker_thread()
3235 if (cfg->state != STATE_NORMAL) in cxlflash_worker_thread()
3238 spin_lock_irqsave(cfg->host->host_lock, lock_flags); in cxlflash_worker_thread()
3240 if (cfg->lr_state == LINK_RESET_REQUIRED) { in cxlflash_worker_thread()
3241 port = cfg->lr_port; in cxlflash_worker_thread()
3246 spin_unlock_irqrestore(cfg->host->host_lock, in cxlflash_worker_thread()
3250 fc_port_regs = get_fc_port_regs(cfg, port); in cxlflash_worker_thread()
3252 spin_lock_irqsave(cfg->host->host_lock, lock_flags); in cxlflash_worker_thread()
3255 cfg->lr_state = LINK_RESET_COMPLETE; in cxlflash_worker_thread()
3258 spin_unlock_irqrestore(cfg->host->host_lock, lock_flags); in cxlflash_worker_thread()
3260 if (atomic_dec_if_positive(&cfg->scan_host_needed) >= 0) in cxlflash_worker_thread()
3261 scsi_scan_host(cfg->host); in cxlflash_worker_thread()
3275 struct cxlflash_cfg *cfg; in cxlflash_chr_open() local
3280 cfg = container_of(inode->i_cdev, struct cxlflash_cfg, cdev); in cxlflash_chr_open()
3281 file->private_data = cfg; in cxlflash_chr_open()
3304 * @cfg: Internal structure associated with the host.
3309 static int cxlflash_lun_provision(struct cxlflash_cfg *cfg, in cxlflash_lun_provision() argument
3312 struct afu *afu = cfg->afu; in cxlflash_lun_provision()
3313 struct device *dev = &cfg->dev->dev; in cxlflash_lun_provision()
3330 if (port >= cfg->num_fc_ports) { in cxlflash_lun_provision()
3347 fc_port_regs = get_fc_port_regs(cfg, port); in cxlflash_lun_provision()
3395 * @cfg: Internal structure associated with the host.
3403 static int cxlflash_afu_debug(struct cxlflash_cfg *cfg, in cxlflash_afu_debug() argument
3406 struct afu *afu = cfg->afu; in cxlflash_afu_debug()
3407 struct device *dev = &cfg->dev->dev; in cxlflash_afu_debug()
3504 struct cxlflash_cfg *cfg = file->private_data; in cxlflash_chr_ioctl() local
3505 struct device *dev = &cfg->dev->dev; in cxlflash_chr_ioctl()
3526 down_read(&cfg->ioctl_rwsem); in cxlflash_chr_ioctl()
3570 rc = do_ioctl(cfg, (void *)&buf); in cxlflash_chr_ioctl()
3582 up_read(&cfg->ioctl_rwsem); in cxlflash_chr_ioctl()
3604 * @cfg: Internal structure associated with the host.
3608 static int init_chrdev(struct cxlflash_cfg *cfg) in init_chrdev() argument
3610 struct device *dev = &cfg->dev->dev; in init_chrdev()
3624 cdev_init(&cfg->cdev, &cxlflash_chr_fops); in init_chrdev()
3626 rc = cdev_add(&cfg->cdev, devno, 1); in init_chrdev()
3641 cfg->chardev = char_dev; in init_chrdev()
3646 cdev_del(&cfg->cdev); in init_chrdev()
3672 struct cxlflash_cfg *cfg = NULL; in cxlflash_probe() local
3696 cfg = shost_priv(host); in cxlflash_probe()
3697 cfg->state = STATE_PROBING; in cxlflash_probe()
3698 cfg->host = host; in cxlflash_probe()
3699 rc = alloc_mem(cfg); in cxlflash_probe()
3703 scsi_host_put(cfg->host); in cxlflash_probe()
3707 cfg->init_state = INIT_STATE_NONE; in cxlflash_probe()
3708 cfg->dev = pdev; in cxlflash_probe()
3709 cfg->cxl_fops = cxlflash_cxl_fops; in cxlflash_probe()
3710 cfg->ops = cxlflash_assign_ops(ddv); in cxlflash_probe()
3711 WARN_ON_ONCE(!cfg->ops); in cxlflash_probe()
3720 cfg->promote_lun_index = 0; in cxlflash_probe()
3723 cfg->last_lun_index[k] = CXLFLASH_NUM_VLUNS/2 - 1; in cxlflash_probe()
3725 cfg->dev_id = (struct pci_device_id *)dev_id; in cxlflash_probe()
3727 init_waitqueue_head(&cfg->tmf_waitq); in cxlflash_probe()
3728 init_waitqueue_head(&cfg->reset_waitq); in cxlflash_probe()
3730 INIT_WORK(&cfg->work_q, cxlflash_worker_thread); in cxlflash_probe()
3731 cfg->lr_state = LINK_RESET_INVALID; in cxlflash_probe()
3732 cfg->lr_port = -1; in cxlflash_probe()
3733 spin_lock_init(&cfg->tmf_slock); in cxlflash_probe()
3734 mutex_init(&cfg->ctx_tbl_list_mutex); in cxlflash_probe()
3735 mutex_init(&cfg->ctx_recovery_mutex); in cxlflash_probe()
3736 init_rwsem(&cfg->ioctl_rwsem); in cxlflash_probe()
3737 INIT_LIST_HEAD(&cfg->ctx_err_recovery); in cxlflash_probe()
3738 INIT_LIST_HEAD(&cfg->lluns); in cxlflash_probe()
3740 pci_set_drvdata(pdev, cfg); in cxlflash_probe()
3742 rc = init_pci(cfg); in cxlflash_probe()
3747 cfg->init_state = INIT_STATE_PCI; in cxlflash_probe()
3749 cfg->afu_cookie = cfg->ops->create_afu(pdev); in cxlflash_probe()
3750 if (unlikely(!cfg->afu_cookie)) { in cxlflash_probe()
3756 rc = init_afu(cfg); in cxlflash_probe()
3757 if (rc && !wq_has_sleeper(&cfg->reset_waitq)) { in cxlflash_probe()
3761 cfg->init_state = INIT_STATE_AFU; in cxlflash_probe()
3763 rc = init_scsi(cfg); in cxlflash_probe()
3768 cfg->init_state = INIT_STATE_SCSI; in cxlflash_probe()
3770 rc = init_chrdev(cfg); in cxlflash_probe()
3775 cfg->init_state = INIT_STATE_CDEV; in cxlflash_probe()
3777 if (wq_has_sleeper(&cfg->reset_waitq)) { in cxlflash_probe()
3778 cfg->state = STATE_PROBED; in cxlflash_probe()
3779 wake_up_all(&cfg->reset_waitq); in cxlflash_probe()
3781 cfg->state = STATE_NORMAL; in cxlflash_probe()
3787 cfg->state = STATE_PROBED; in cxlflash_probe()
3806 struct cxlflash_cfg *cfg = pci_get_drvdata(pdev); in cxlflash_pci_error_detected() local
3807 struct device *dev = &cfg->dev->dev; in cxlflash_pci_error_detected()
3813 wait_event(cfg->reset_waitq, cfg->state != STATE_RESET && in cxlflash_pci_error_detected()
3814 cfg->state != STATE_PROBING); in cxlflash_pci_error_detected()
3815 if (cfg->state == STATE_FAILTERM) in cxlflash_pci_error_detected()
3818 cfg->state = STATE_RESET; in cxlflash_pci_error_detected()
3819 scsi_block_requests(cfg->host); in cxlflash_pci_error_detected()
3820 drain_ioctls(cfg); in cxlflash_pci_error_detected()
3821 rc = cxlflash_mark_contexts_error(cfg); in cxlflash_pci_error_detected()
3825 term_afu(cfg); in cxlflash_pci_error_detected()
3828 cfg->state = STATE_FAILTERM; in cxlflash_pci_error_detected()
3829 wake_up_all(&cfg->reset_waitq); in cxlflash_pci_error_detected()
3830 scsi_unblock_requests(cfg->host); in cxlflash_pci_error_detected()
3850 struct cxlflash_cfg *cfg = pci_get_drvdata(pdev); in cxlflash_pci_slot_reset() local
3851 struct device *dev = &cfg->dev->dev; in cxlflash_pci_slot_reset()
3855 rc = init_afu(cfg); in cxlflash_pci_slot_reset()
3870 struct cxlflash_cfg *cfg = pci_get_drvdata(pdev); in cxlflash_pci_resume() local
3871 struct device *dev = &cfg->dev->dev; in cxlflash_pci_resume()
3875 cfg->state = STATE_NORMAL; in cxlflash_pci_resume()
3876 wake_up_all(&cfg->reset_waitq); in cxlflash_pci_resume()
3877 scsi_unblock_requests(cfg->host); in cxlflash_pci_resume()