• 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()
695 struct afu *afu = cfg->afu; in term_mc() local
698 if (!afu || !cfg->mcctx) { in term_mc()
709 cxl_unmap_afu_irq(cfg->mcctx, 3, afu); in term_mc()
711 cxl_unmap_afu_irq(cfg->mcctx, 2, afu); in term_mc()
713 cxl_unmap_afu_irq(cfg->mcctx, 1, afu); in term_mc()
731 if (cfg->afu) in term_afu()
799 cfg->afu = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, in alloc_mem()
800 get_order(sizeof(struct afu))); in alloc_mem()
801 if (unlikely(!cfg->afu)) { in alloc_mem()
803 __func__, get_order(sizeof(struct afu))); in alloc_mem()
807 cfg->afu->parent = cfg; in alloc_mem()
808 cfg->afu->afu_map = NULL; in alloc_mem()
823 cfg->afu->cmd[i].buf = buf; in alloc_mem()
824 atomic_set(&cfg->afu->cmd[i].free, 1); in alloc_mem()
825 cfg->afu->cmd[i].slot = i; in alloc_mem()
1057 static int afu_set_wwpn(struct afu *afu, int port, __be64 __iomem *fc_regs, in afu_set_wwpn() argument
1103 static void afu_link_reset(struct afu *afu, int port, __be64 __iomem *fc_regs) in afu_link_reset() argument
1108 port_sel = readq_be(&afu->afu_map->global.regs.afu_port_sel); in afu_link_reset()
1110 writeq_be(port_sel, &afu->afu_map->global.regs.afu_port_sel); in afu_link_reset()
1111 cxlflash_afu_sync(afu, 0, 0, AFU_GSYNC); in afu_link_reset()
1127 writeq_be(port_sel, &afu->afu_map->global.regs.afu_port_sel); in afu_link_reset()
1128 cxlflash_afu_sync(afu, 0, 0, AFU_GSYNC); in afu_link_reset()
1177 static void afu_err_intr_init(struct afu *afu) in afu_err_intr_init() argument
1190 writeq_be(-1ULL, &afu->afu_map->global.regs.aintr_mask); in afu_err_intr_init()
1192 reg = ((u64) (((afu->ctx_hndl << 8) | SISL_MSI_ASYNC_ERROR)) << 40); in afu_err_intr_init()
1194 if (afu->internal_lun) in afu_err_intr_init()
1196 writeq_be(reg, &afu->afu_map->global.regs.afu_ctrl); in afu_err_intr_init()
1198 writeq_be(-1ULL, &afu->afu_map->global.regs.aintr_clear); in afu_err_intr_init()
1201 writeq_be(SISL_ASTATUS_MASK, &afu->afu_map->global.regs.aintr_mask); in afu_err_intr_init()
1204 writeq_be(-1ULL, &afu->afu_map->global.regs.aintr_clear); in afu_err_intr_init()
1207 reg = readq_be(&afu->afu_map->global.fc_regs[0][FC_CONFIG2 / 8]); in afu_err_intr_init()
1209 if (afu->internal_lun) in afu_err_intr_init()
1210 reg |= ((u64)(afu->internal_lun - 1) << SISL_FC_INTERNAL_SHIFT); in afu_err_intr_init()
1211 writeq_be(reg, &afu->afu_map->global.fc_regs[0][FC_CONFIG2 / 8]); in afu_err_intr_init()
1216 &afu->afu_map->global.fc_regs[i][FC_ERROR / 8]); in afu_err_intr_init()
1217 writeq_be(0, &afu->afu_map->global.fc_regs[i][FC_ERRCAP / 8]); in afu_err_intr_init()
1226 writeq_be(SISL_MSI_SYNC_ERROR, &afu->host_map->ctx_ctrl); in afu_err_intr_init()
1227 writeq_be(SISL_ISTATUS_MASK, &afu->host_map->intr_mask); in afu_err_intr_init()
1239 struct afu *afu = (struct afu *)data; in cxlflash_sync_err_irq() local
1243 reg = readq_be(&afu->host_map->intr_status); in cxlflash_sync_err_irq()
1248 __func__, (u64)afu, reg); in cxlflash_sync_err_irq()
1253 __func__, (u64)afu, reg); in cxlflash_sync_err_irq()
1255 writeq_be(reg_unmasked, &afu->host_map->intr_clear); in cxlflash_sync_err_irq()
1271 struct afu *afu = (struct afu *)data; in cxlflash_rrq_irq() local
1273 bool toggle = afu->toggle; in cxlflash_rrq_irq()
1275 *hrrq_start = afu->hrrq_start, in cxlflash_rrq_irq()
1276 *hrrq_end = afu->hrrq_end, in cxlflash_rrq_irq()
1277 *hrrq_curr = afu->hrrq_curr; in cxlflash_rrq_irq()
1298 afu->hrrq_curr = hrrq_curr; in cxlflash_rrq_irq()
1299 afu->toggle = toggle; in cxlflash_rrq_irq()
1313 struct afu *afu = (struct afu *)data; in cxlflash_async_err_irq() local
1314 struct cxlflash_cfg *cfg = afu->parent; in cxlflash_async_err_irq()
1318 struct sisl_global_map __iomem *global = &afu->afu_map->global; in cxlflash_async_err_irq()
1356 kref_get(&cfg->afu->mapcount); in cxlflash_async_err_irq()
1377 kref_get(&cfg->afu->mapcount); in cxlflash_async_err_irq()
1383 dev_dbg(dev, "%s: returning IRQ_HANDLED, afu=%p\n", __func__, afu); in cxlflash_async_err_irq()
1398 cfg->afu->work.work_element_descriptor, in start_context()
1505 struct afu *afu = cfg->afu; in init_pcr() local
1510 ctrl_map = &afu->afu_map->ctrls[i].ctrl; in init_pcr()
1519 afu->ctx_hndl = (u16) cxl_process_element(cfg->mcctx); in init_pcr()
1520 afu->host_map = &afu->afu_map->hosts[afu->ctx_hndl].host; in init_pcr()
1521 afu->ctrl_map = &afu->afu_map->ctrls[afu->ctx_hndl].ctrl; in init_pcr()
1524 writeq_be(SISL_ENDIAN_CTRL, &afu->host_map->endian_ctrl); in init_pcr()
1528 afu->cmd[i].rcb.ctx_id = afu->ctx_hndl; in init_pcr()
1529 afu->cmd[i].rcb.msi = SISL_MSI_RRQ_UPDATED; in init_pcr()
1530 afu->cmd[i].rcb.rrq = 0x0; in init_pcr()
1540 struct afu *afu = cfg->afu; in init_global() local
1556 writeq_be((u64) afu->hrrq_start, &afu->host_map->rrq_start); in init_global()
1557 writeq_be((u64) afu->hrrq_end, &afu->host_map->rrq_end); in init_global()
1560 reg = readq_be(&afu->afu_map->global.regs.afu_config); in init_global()
1566 writeq_be(reg, &afu->afu_map->global.regs.afu_config); in init_global()
1569 if (afu->internal_lun) { in init_global()
1571 writeq_be(PORT0, &afu->afu_map->global.regs.afu_port_sel); in init_global()
1574 writeq_be(BOTH_PORTS, &afu->afu_map->global.regs.afu_port_sel); in init_global()
1580 writeq_be(0, &afu->afu_map->global.fc_regs[i][FC_ERRMSK / 8]); in init_global()
1582 (void)readq_be(&afu->afu_map->global. in init_global()
1584 writeq_be(MC_CRC_THRESH, &afu->afu_map->global.fc_regs[i] in init_global()
1589 afu_set_wwpn(afu, i, in init_global()
1590 &afu->afu_map->global.fc_regs[i][0], in init_global()
1606 (void)readq_be(&afu->ctrl_map->mbox_r); /* unlock ctx_cap */ in init_global()
1610 &afu->ctrl_map->ctx_cap); in init_global()
1612 afu->hb = readq_be(&afu->afu_map->global.regs.afu_hb); in init_global()
1624 struct afu *afu = cfg->afu; in start_afu() local
1631 cmd = &afu->cmd[i]; in start_afu()
1635 cmd->parent = afu; in start_afu()
1641 memset(&afu->rrq_entry, 0, sizeof(afu->rrq_entry)); in start_afu()
1644 afu->hrrq_start = &afu->rrq_entry[0]; in start_afu()
1645 afu->hrrq_end = &afu->rrq_entry[NUM_RRQ_ENTRY - 1]; in start_afu()
1646 afu->hrrq_curr = afu->hrrq_start; in start_afu()
1647 afu->toggle = 1; in start_afu()
1665 struct afu *afu = cfg->afu; in init_mc() local
1694 rc = cxl_map_afu_irq(ctx, 1, cxlflash_sync_err_irq, afu, in init_mc()
1703 rc = cxl_map_afu_irq(ctx, 2, cxlflash_rrq_irq, afu, in init_mc()
1712 rc = cxl_map_afu_irq(ctx, 3, cxlflash_async_err_irq, afu, in init_mc()
1754 struct afu *afu = cfg->afu; in init_afu() local
1767 afu->afu_map = cxl_psa_map(cfg->mcctx); in init_afu()
1768 if (!afu->afu_map) { in init_afu()
1773 kref_init(&afu->mapcount); in init_afu()
1776 reg = readq(&afu->afu_map->global.regs.afu_version); in init_afu()
1777 memcpy(afu->version, &reg, sizeof(reg)); in init_afu()
1778 afu->interface_version = in init_afu()
1779 readq_be(&afu->afu_map->global.regs.interface_version); in init_afu()
1780 if ((afu->interface_version + 1) == 0) { in init_afu()
1782 "interface version 0x%llx\n", afu->version, in init_afu()
1783 afu->interface_version); in init_afu()
1789 afu->version, afu->interface_version); in init_afu()
1798 afu_err_intr_init(cfg->afu); in init_afu()
1799 atomic64_set(&afu->room, readq_be(&afu->host_map->cmd_room)); in init_afu()
1808 kref_put(&afu->mapcount, afu_unmap); in init_afu()
1836 int cxlflash_afu_sync(struct afu *afu, ctx_hndl_t ctx_hndl_u, in cxlflash_afu_sync() argument
1839 struct cxlflash_cfg *cfg = afu->parent; in cxlflash_afu_sync()
1853 cmd = cmd_checkout(afu); in cxlflash_afu_sync()
1864 pr_debug("%s: afu=%p cmd=%p %d\n", __func__, afu, cmd, ctx_hndl_u); in cxlflash_afu_sync()
1882 rc = send_cmd(afu, cmd); in cxlflash_afu_sync()
1886 wait_resp(afu, cmd); in cxlflash_afu_sync()
1934 struct afu *afu = cfg->afu; in cxlflash_eh_device_reset_handler() local
1949 rcr = send_tmf(afu, scp, TMF_LUN_RESET); in cxlflash_eh_device_reset_handler()
2048 static ssize_t cxlflash_show_port_status(u32 port, struct afu *afu, char *buf) in cxlflash_show_port_status() argument
2057 fc_regs = &afu->afu_map->global.fc_regs[port][0]; in cxlflash_show_port_status()
2085 struct afu *afu = cfg->afu; in port0_show() local
2087 return cxlflash_show_port_status(0, afu, buf); in port0_show()
2104 struct afu *afu = cfg->afu; in port1_show() local
2106 return cxlflash_show_port_status(1, afu, buf); in port1_show()
2122 struct afu *afu = cfg->afu; in lun_mode_show() local
2124 return scnprintf(buf, PAGE_SIZE, "%u\n", afu->internal_lun); in lun_mode_show()
2155 struct afu *afu = cfg->afu; in lun_mode_store() local
2160 if (!rc && (lun_mode < 5) && (lun_mode != afu->internal_lun)) { in lun_mode_store()
2161 afu->internal_lun = lun_mode; in lun_mode_store()
2167 if (afu->internal_lun) in lun_mode_store()
2202 struct afu *afu, in cxlflash_show_port_lun_table() argument
2212 fc_port = &afu->afu_map->global.fc_port[port][0]; in cxlflash_show_port_lun_table()
2234 struct afu *afu = cfg->afu; in port0_lun_table_show() local
2236 return cxlflash_show_port_lun_table(0, afu, buf); in port0_lun_table_show()
2253 struct afu *afu = cfg->afu; in port1_lun_table_show() local
2255 return cxlflash_show_port_lun_table(1, afu, buf); in port1_lun_table_show()
2361 struct afu *afu = cfg->afu; in cxlflash_worker_thread() local
2383 afu_link_reset(afu, port, in cxlflash_worker_thread()
2384 &afu->afu_map->global.fc_regs[port][0]); in cxlflash_worker_thread()
2391 if (afu->read_room) { in cxlflash_worker_thread()
2392 atomic64_set(&afu->room, readq_be(&afu->host_map->cmd_room)); in cxlflash_worker_thread()
2393 afu->read_room = false; in cxlflash_worker_thread()
2400 kref_put(&afu->mapcount, afu_unmap); in cxlflash_worker_thread()