• Home
  • Raw
  • Download

Lines Matching refs:afu

49 static struct afu_cmd *cmd_checkout(struct afu *afu)  in cmd_checkout()  argument
55 k = (afu->cmd_couts++ & (CXLFLASH_NUM_CMDS - 1)); in cmd_checkout()
57 cmd = &afu->cmd[k]; in cmd_checkout()
221 struct afu *afu = cmd->parent; in cmd_complete() local
222 struct cxlflash_cfg *cfg = afu->parent; in cmd_complete()
267 struct afu *afu = cmd->parent; in context_reset() local
288 room = readq_be(&afu->host_map->cmd_room); in context_reset()
289 atomic64_set(&afu->room, room); in context_reset()
300 writeq_be(rrin, &afu->host_map->ioarrin); in context_reset()
302 rrin = readq_be(&afu->host_map->ioarrin); in context_reset()
318 static int send_cmd(struct afu *afu, struct afu_cmd *cmd) in send_cmd() argument
320 struct cxlflash_cfg *cfg = afu->parent; in send_cmd()
334 newval = atomic64_dec_if_positive(&afu->room); in send_cmd()
337 room = readq_be(&afu->host_map->cmd_room); in send_cmd()
338 atomic64_set(&afu->room, room); in send_cmd()
363 writeq_be((u64)&cmd->rcb, &afu->host_map->ioarrin); in send_cmd()
370 afu->read_room = true; in send_cmd()
371 kref_get(&cfg->afu->mapcount); in send_cmd()
382 static void wait_resp(struct afu *afu, struct afu_cmd *cmd) in wait_resp() argument
406 static int send_tmf(struct afu *afu, struct scsi_cmnd *scp, u64 tmfcmd) in send_tmf() argument
419 cmd = cmd_checkout(afu); in send_tmf()
436 cmd->rcb.ctx_id = afu->ctx_hndl; in send_tmf()
452 rc = send_cmd(afu, cmd); in send_tmf()
479 struct afu *afu = container_of(ref, struct afu, mapcount); in afu_unmap() local
481 if (likely(afu->afu_map)) { in afu_unmap()
482 cxl_psa_unmap((void __iomem *)afu->afu_map); in afu_unmap()
483 afu->afu_map = NULL; in afu_unmap()
508 struct afu *afu = cfg->afu; in cxlflash_queuecommand() local
555 cmd = cmd_checkout(afu); in cxlflash_queuecommand()
562 kref_get(&cfg->afu->mapcount); in cxlflash_queuecommand()
565 cmd->rcb.ctx_id = afu->ctx_hndl; in cxlflash_queuecommand()
598 rc = send_cmd(afu, cmd); in cxlflash_queuecommand()
606 kref_put(&afu->mapcount, afu_unmap); in cxlflash_queuecommand()
633 struct afu *afu = cfg->afu; in free_mem() local
635 if (cfg->afu) { in free_mem()
637 buf = afu->cmd[i].buf; in free_mem()
642 free_pages((ulong)afu, get_order(sizeof(struct afu))); in free_mem()
643 cfg->afu = NULL; in free_mem()
666 struct afu *afu = cfg->afu; in stop_afu() local
669 if (likely(afu)) { in stop_afu()
671 cmd = &afu->cmd[i]; in stop_afu()
677 if (likely(afu->afu_map)) { in stop_afu()
678 cxl_psa_unmap((void __iomem *)afu->afu_map); in stop_afu()
679 afu->afu_map = NULL; in stop_afu()
681 kref_put(&afu->mapcount, afu_unmap); in stop_afu()
694 struct afu *afu = cfg->afu; in term_intr() local
697 if (!afu || !cfg->mcctx) { in term_intr()
704 cxl_unmap_afu_irq(cfg->mcctx, 3, afu); in term_intr()
706 cxl_unmap_afu_irq(cfg->mcctx, 2, afu); in term_intr()
708 cxl_unmap_afu_irq(cfg->mcctx, 1, afu); in term_intr()
728 struct afu *afu = cfg->afu; in term_mc() local
731 if (!afu || !cfg->mcctx) { in term_mc()
759 if (cfg->afu) in term_afu()
779 struct afu *afu = cfg->afu; in notify_shutdown() local
790 if (!afu || !afu->afu_map) { in notify_shutdown()
796 global = &afu->afu_map->global; in notify_shutdown()
894 cfg->afu = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, in alloc_mem()
895 get_order(sizeof(struct afu))); in alloc_mem()
896 if (unlikely(!cfg->afu)) { in alloc_mem()
898 __func__, get_order(sizeof(struct afu))); in alloc_mem()
902 cfg->afu->parent = cfg; in alloc_mem()
903 cfg->afu->afu_map = NULL; in alloc_mem()
918 cfg->afu->cmd[i].buf = buf; in alloc_mem()
919 atomic_set(&cfg->afu->cmd[i].free, 1); in alloc_mem()
920 cfg->afu->cmd[i].slot = i; in alloc_mem()
1097 static void afu_set_wwpn(struct afu *afu, int port, __be64 __iomem *fc_regs, in afu_set_wwpn() argument
1130 static void afu_link_reset(struct afu *afu, int port, __be64 __iomem *fc_regs) in afu_link_reset() argument
1135 port_sel = readq_be(&afu->afu_map->global.regs.afu_port_sel); in afu_link_reset()
1137 writeq_be(port_sel, &afu->afu_map->global.regs.afu_port_sel); in afu_link_reset()
1138 cxlflash_afu_sync(afu, 0, 0, AFU_GSYNC); in afu_link_reset()
1154 writeq_be(port_sel, &afu->afu_map->global.regs.afu_port_sel); in afu_link_reset()
1155 cxlflash_afu_sync(afu, 0, 0, AFU_GSYNC); in afu_link_reset()
1204 static void afu_err_intr_init(struct afu *afu) in afu_err_intr_init() argument
1217 writeq_be(-1ULL, &afu->afu_map->global.regs.aintr_mask); in afu_err_intr_init()
1219 reg = ((u64) (((afu->ctx_hndl << 8) | SISL_MSI_ASYNC_ERROR)) << 40); in afu_err_intr_init()
1221 if (afu->internal_lun) in afu_err_intr_init()
1223 writeq_be(reg, &afu->afu_map->global.regs.afu_ctrl); in afu_err_intr_init()
1225 writeq_be(-1ULL, &afu->afu_map->global.regs.aintr_clear); in afu_err_intr_init()
1228 writeq_be(SISL_ASTATUS_MASK, &afu->afu_map->global.regs.aintr_mask); in afu_err_intr_init()
1231 writeq_be(-1ULL, &afu->afu_map->global.regs.aintr_clear); in afu_err_intr_init()
1234 reg = readq_be(&afu->afu_map->global.fc_regs[0][FC_CONFIG2 / 8]); in afu_err_intr_init()
1236 if (afu->internal_lun) in afu_err_intr_init()
1237 reg |= ((u64)(afu->internal_lun - 1) << SISL_FC_INTERNAL_SHIFT); in afu_err_intr_init()
1238 writeq_be(reg, &afu->afu_map->global.fc_regs[0][FC_CONFIG2 / 8]); in afu_err_intr_init()
1243 &afu->afu_map->global.fc_regs[i][FC_ERROR / 8]); in afu_err_intr_init()
1244 writeq_be(0, &afu->afu_map->global.fc_regs[i][FC_ERRCAP / 8]); in afu_err_intr_init()
1253 writeq_be(SISL_MSI_SYNC_ERROR, &afu->host_map->ctx_ctrl); in afu_err_intr_init()
1254 writeq_be(SISL_ISTATUS_MASK, &afu->host_map->intr_mask); in afu_err_intr_init()
1266 struct afu *afu = (struct afu *)data; in cxlflash_sync_err_irq() local
1270 reg = readq_be(&afu->host_map->intr_status); in cxlflash_sync_err_irq()
1275 __func__, (u64)afu, reg); in cxlflash_sync_err_irq()
1280 __func__, (u64)afu, reg); in cxlflash_sync_err_irq()
1282 writeq_be(reg_unmasked, &afu->host_map->intr_clear); in cxlflash_sync_err_irq()
1298 struct afu *afu = (struct afu *)data; in cxlflash_rrq_irq() local
1300 bool toggle = afu->toggle; in cxlflash_rrq_irq()
1302 *hrrq_start = afu->hrrq_start, in cxlflash_rrq_irq()
1303 *hrrq_end = afu->hrrq_end, in cxlflash_rrq_irq()
1304 *hrrq_curr = afu->hrrq_curr; in cxlflash_rrq_irq()
1325 afu->hrrq_curr = hrrq_curr; in cxlflash_rrq_irq()
1326 afu->toggle = toggle; in cxlflash_rrq_irq()
1340 struct afu *afu = (struct afu *)data; in cxlflash_async_err_irq() local
1341 struct cxlflash_cfg *cfg = afu->parent; in cxlflash_async_err_irq()
1345 struct sisl_global_map __iomem *global = &afu->afu_map->global; in cxlflash_async_err_irq()
1383 kref_get(&cfg->afu->mapcount); in cxlflash_async_err_irq()
1404 kref_get(&cfg->afu->mapcount); in cxlflash_async_err_irq()
1410 dev_dbg(dev, "%s: returning IRQ_HANDLED, afu=%p\n", __func__, afu); in cxlflash_async_err_irq()
1425 cfg->afu->work.work_element_descriptor, in start_context()
1532 struct afu *afu = cfg->afu; in init_pcr() local
1537 ctrl_map = &afu->afu_map->ctrls[i].ctrl; in init_pcr()
1546 afu->ctx_hndl = (u16) cxl_process_element(cfg->mcctx); in init_pcr()
1547 afu->host_map = &afu->afu_map->hosts[afu->ctx_hndl].host; in init_pcr()
1548 afu->ctrl_map = &afu->afu_map->ctrls[afu->ctx_hndl].ctrl; in init_pcr()
1551 writeq_be(SISL_ENDIAN_CTRL, &afu->host_map->endian_ctrl); in init_pcr()
1555 afu->cmd[i].rcb.ctx_id = afu->ctx_hndl; in init_pcr()
1556 afu->cmd[i].rcb.msi = SISL_MSI_RRQ_UPDATED; in init_pcr()
1557 afu->cmd[i].rcb.rrq = 0x0; in init_pcr()
1567 struct afu *afu = cfg->afu; in init_global() local
1583 writeq_be((u64) afu->hrrq_start, &afu->host_map->rrq_start); in init_global()
1584 writeq_be((u64) afu->hrrq_end, &afu->host_map->rrq_end); in init_global()
1587 reg = readq_be(&afu->afu_map->global.regs.afu_config); in init_global()
1593 writeq_be(reg, &afu->afu_map->global.regs.afu_config); in init_global()
1596 if (afu->internal_lun) { in init_global()
1598 writeq_be(PORT0, &afu->afu_map->global.regs.afu_port_sel); in init_global()
1601 writeq_be(BOTH_PORTS, &afu->afu_map->global.regs.afu_port_sel); in init_global()
1607 writeq_be(0, &afu->afu_map->global.fc_regs[i][FC_ERRMSK / 8]); in init_global()
1609 (void)readq_be(&afu->afu_map->global. in init_global()
1611 writeq_be(MC_CRC_THRESH, &afu->afu_map->global.fc_regs[i] in init_global()
1616 afu_set_wwpn(afu, i, in init_global()
1617 &afu->afu_map->global.fc_regs[i][0], in init_global()
1628 (void)readq_be(&afu->ctrl_map->mbox_r); /* unlock ctx_cap */ in init_global()
1632 &afu->ctrl_map->ctx_cap); in init_global()
1634 afu->hb = readq_be(&afu->afu_map->global.regs.afu_hb); in init_global()
1646 struct afu *afu = cfg->afu; in start_afu() local
1653 cmd = &afu->cmd[i]; in start_afu()
1657 cmd->parent = afu; in start_afu()
1663 memset(&afu->rrq_entry, 0, sizeof(afu->rrq_entry)); in start_afu()
1666 afu->hrrq_start = &afu->rrq_entry[0]; in start_afu()
1667 afu->hrrq_end = &afu->rrq_entry[NUM_RRQ_ENTRY - 1]; in start_afu()
1668 afu->hrrq_curr = afu->hrrq_start; in start_afu()
1669 afu->toggle = 1; in start_afu()
1686 struct afu *afu = cfg->afu; in init_intr() local
1699 rc = cxl_map_afu_irq(ctx, 1, cxlflash_sync_err_irq, afu, in init_intr()
1708 rc = cxl_map_afu_irq(ctx, 2, cxlflash_rrq_irq, afu, in init_intr()
1717 rc = cxl_map_afu_irq(ctx, 3, cxlflash_async_err_irq, afu, in init_intr()
1798 struct afu *afu = cfg->afu; in init_afu() local
1811 afu->afu_map = cxl_psa_map(cfg->mcctx); in init_afu()
1812 if (!afu->afu_map) { in init_afu()
1817 kref_init(&afu->mapcount); in init_afu()
1820 reg = readq(&afu->afu_map->global.regs.afu_version); in init_afu()
1821 memcpy(afu->version, &reg, sizeof(reg)); in init_afu()
1822 afu->interface_version = in init_afu()
1823 readq_be(&afu->afu_map->global.regs.interface_version); in init_afu()
1824 if ((afu->interface_version + 1) == 0) { in init_afu()
1826 "interface version 0x%llx\n", afu->version, in init_afu()
1827 afu->interface_version); in init_afu()
1833 afu->version, afu->interface_version); in init_afu()
1842 afu_err_intr_init(cfg->afu); in init_afu()
1843 atomic64_set(&afu->room, readq_be(&afu->host_map->cmd_room)); in init_afu()
1852 kref_put(&afu->mapcount, afu_unmap); in init_afu()
1881 int cxlflash_afu_sync(struct afu *afu, ctx_hndl_t ctx_hndl_u, in cxlflash_afu_sync() argument
1884 struct cxlflash_cfg *cfg = afu->parent; in cxlflash_afu_sync()
1898 cmd = cmd_checkout(afu); in cxlflash_afu_sync()
1909 pr_debug("%s: afu=%p cmd=%p %d\n", __func__, afu, cmd, ctx_hndl_u); in cxlflash_afu_sync()
1927 rc = send_cmd(afu, cmd); in cxlflash_afu_sync()
1931 wait_resp(afu, cmd); in cxlflash_afu_sync()
1992 struct afu *afu = cfg->afu; in cxlflash_eh_device_reset_handler() local
2007 rcr = send_tmf(afu, scp, TMF_LUN_RESET); in cxlflash_eh_device_reset_handler()
2107 static ssize_t cxlflash_show_port_status(u32 port, struct afu *afu, char *buf) in cxlflash_show_port_status() argument
2116 fc_regs = &afu->afu_map->global.fc_regs[port][0]; in cxlflash_show_port_status()
2144 struct afu *afu = cfg->afu; in port0_show() local
2146 return cxlflash_show_port_status(0, afu, buf); in port0_show()
2163 struct afu *afu = cfg->afu; in port1_show() local
2165 return cxlflash_show_port_status(1, afu, buf); in port1_show()
2181 struct afu *afu = cfg->afu; in lun_mode_show() local
2183 return scnprintf(buf, PAGE_SIZE, "%u\n", afu->internal_lun); in lun_mode_show()
2214 struct afu *afu = cfg->afu; in lun_mode_store() local
2219 if (!rc && (lun_mode < 5) && (lun_mode != afu->internal_lun)) { in lun_mode_store()
2220 afu->internal_lun = lun_mode; in lun_mode_store()
2226 if (afu->internal_lun) in lun_mode_store()
2261 struct afu *afu, in cxlflash_show_port_lun_table() argument
2271 fc_port = &afu->afu_map->global.fc_port[port][0]; in cxlflash_show_port_lun_table()
2293 struct afu *afu = cfg->afu; in port0_lun_table_show() local
2295 return cxlflash_show_port_lun_table(0, afu, buf); in port0_lun_table_show()
2312 struct afu *afu = cfg->afu; in port1_lun_table_show() local
2314 return cxlflash_show_port_lun_table(1, afu, buf); in port1_lun_table_show()
2422 struct afu *afu = cfg->afu; in cxlflash_worker_thread() local
2444 afu_link_reset(afu, port, in cxlflash_worker_thread()
2445 &afu->afu_map->global.fc_regs[port][0]); in cxlflash_worker_thread()
2452 if (afu->read_room) { in cxlflash_worker_thread()
2453 atomic64_set(&afu->room, readq_be(&afu->host_map->cmd_room)); in cxlflash_worker_thread()
2454 afu->read_room = false; in cxlflash_worker_thread()
2461 kref_put(&afu->mapcount, afu_unmap); in cxlflash_worker_thread()