From 80890c5ea068661d6fe4a34beb362ca0f2c49c90 Mon Sep 17 00:00:00 2001 From: Maurizio Lombardi Date: Mon, 28 Mar 2022 12:39:40 +0200 Subject: [PATCH 001/177] scsi: target: Allow changing dbroot if there are no registered devices The target driver prevents the users from changing the database root directory if a target module like ib_srpt has been registered. This makes it difficult for users to set their preferred database directory if the module gets loaded during the system boot. Let the users modify dbroot if there are no registered devices Link: https://lore.kernel.org/r/20220328103940.19977-1-mlombard@redhat.com Reviewed-by: Mike Christie Signed-off-by: Maurizio Lombardi Signed-off-by: Martin K. Petersen --- drivers/target/target_core_configfs.c | 47 ++++++++++++++++----------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index 4c86697fe4ec..bbcbbfa72b07 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c @@ -72,6 +72,9 @@ static struct config_group target_core_hbagroup; static struct config_group alua_group; static struct config_group alua_lu_gps_group; +static unsigned int target_devices; +static DEFINE_MUTEX(target_devices_lock); + static inline struct se_hba * item_to_hba(struct config_item *item) { @@ -105,51 +108,48 @@ static ssize_t target_core_item_dbroot_store(struct config_item *item, { ssize_t read_bytes; struct file *fp; + ssize_t r = -EINVAL; - mutex_lock(&g_tf_lock); - if (!list_empty(&g_tf_list)) { - mutex_unlock(&g_tf_lock); - pr_err("db_root: cannot be changed: target drivers registered"); - return -EINVAL; + mutex_lock(&target_devices_lock); + if (target_devices) { + pr_err("db_root: cannot be changed because it's in use\n"); + goto unlock; } if (count > (DB_ROOT_LEN - 1)) { - mutex_unlock(&g_tf_lock); pr_err("db_root: count %d exceeds DB_ROOT_LEN-1: %u\n", (int)count, DB_ROOT_LEN - 1); - return -EINVAL; + goto unlock; } read_bytes = snprintf(db_root_stage, DB_ROOT_LEN, "%s", page); - if (!read_bytes) { - mutex_unlock(&g_tf_lock); - return -EINVAL; - } + if (!read_bytes) + goto unlock; + if (db_root_stage[read_bytes - 1] == '\n') db_root_stage[read_bytes - 1] = '\0'; /* validate new db root before accepting it */ fp = filp_open(db_root_stage, O_RDONLY, 0); if (IS_ERR(fp)) { - mutex_unlock(&g_tf_lock); pr_err("db_root: cannot open: %s\n", db_root_stage); - return -EINVAL; + goto unlock; } if (!S_ISDIR(file_inode(fp)->i_mode)) { filp_close(fp, NULL); - mutex_unlock(&g_tf_lock); pr_err("db_root: not a directory: %s\n", db_root_stage); - return -EINVAL; + goto unlock; } filp_close(fp, NULL); strncpy(db_root, db_root_stage, read_bytes); - - mutex_unlock(&g_tf_lock); - pr_debug("Target_Core_ConfigFS: db_root set to %s\n", db_root); - return read_bytes; + r = read_bytes; + +unlock: + mutex_unlock(&target_devices_lock); + return r; } CONFIGFS_ATTR(target_core_item_, dbroot); @@ -3316,6 +3316,10 @@ static struct config_group *target_core_make_subdev( */ target_stat_setup_dev_default_groups(dev); + mutex_lock(&target_devices_lock); + target_devices++; + mutex_unlock(&target_devices_lock); + mutex_unlock(&hba->hba_access_mutex); return &dev->dev_group; @@ -3354,6 +3358,11 @@ static void target_core_drop_subdev( * se_dev is released from target_core_dev_item_ops->release() */ config_item_put(item); + + mutex_lock(&target_devices_lock); + target_devices--; + mutex_unlock(&target_devices_lock); + mutex_unlock(&hba->hba_access_mutex); } From 9ad659be37612b036fdbfb535d5f831901f37db2 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Fri, 1 Apr 2022 10:50:50 +0200 Subject: [PATCH 002/177] scsi: ufs: ufshcd-pltfrm: Simplify pdev->dev usage The 'struct device' pointer is already cached as a local variable in ufshcd_pltfrm_init(), so use it. Link: https://lore.kernel.org/r/20220401085050.119323-1-krzysztof.kozlowski@linaro.org Reviewed-by: Chanho Park Signed-off-by: Krzysztof Kozlowski Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufshcd-pltfrm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c index 87975d1a21c8..cca4b2181a81 100644 --- a/drivers/scsi/ufs/ufshcd-pltfrm.c +++ b/drivers/scsi/ufs/ufshcd-pltfrm.c @@ -341,7 +341,7 @@ int ufshcd_pltfrm_init(struct platform_device *pdev, err = ufshcd_alloc_host(dev, &hba); if (err) { - dev_err(&pdev->dev, "Allocation failed\n"); + dev_err(dev, "Allocation failed\n"); goto out; } @@ -349,13 +349,13 @@ int ufshcd_pltfrm_init(struct platform_device *pdev, err = ufshcd_parse_clock_info(hba); if (err) { - dev_err(&pdev->dev, "%s: clock parse failed %d\n", + dev_err(dev, "%s: clock parse failed %d\n", __func__, err); goto dealloc_host; } err = ufshcd_parse_regulator_info(hba); if (err) { - dev_err(&pdev->dev, "%s: regulator init failed %d\n", + dev_err(dev, "%s: regulator init failed %d\n", __func__, err); goto dealloc_host; } @@ -368,8 +368,8 @@ int ufshcd_pltfrm_init(struct platform_device *pdev, goto dealloc_host; } - pm_runtime_set_active(&pdev->dev); - pm_runtime_enable(&pdev->dev); + pm_runtime_set_active(dev); + pm_runtime_enable(dev); return 0; From 0848ccaea664970e559d99348484615ba0f7ab63 Mon Sep 17 00:00:00 2001 From: Christophe JAILLET Date: Wed, 23 Mar 2022 21:32:22 +0100 Subject: [PATCH 003/177] scsi: vmw_pvscsi: No need to clear memory after a dma_alloc_coherent() call dma_alloc_coherent() already clear the allocated memory, there is no need to explicitly call memset(). Since 'config_page' and 'header' are the same, a memset() call can be avoided. Link: https://lore.kernel.org/r/cd1220c628c89465dcfcbf4aa9bd53110898a529.1648067518.git.christophe.jaillet@wanadoo.fr Signed-off-by: Christophe JAILLET Signed-off-by: Martin K. Petersen --- drivers/scsi/vmw_pvscsi.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c index 1f037b8ab904..f88ecdb93a8a 100644 --- a/drivers/scsi/vmw_pvscsi.c +++ b/drivers/scsi/vmw_pvscsi.c @@ -1324,7 +1324,6 @@ static u32 pvscsi_get_max_targets(struct pvscsi_adapter *adapter) * indicate success. */ header = config_page; - memset(header, 0, sizeof *header); header->hostStatus = BTSTAT_INVPARAM; header->scsiStatus = SDSTAT_CHECK; From 3a6a7187f09a0b1add76aaf4015f215a381ab616 Mon Sep 17 00:00:00 2001 From: Wan Jiabing Date: Thu, 7 Apr 2022 15:24:42 +0800 Subject: [PATCH 004/177] scsi: megaraid_sas: Remove unnecessary memset instance->cmd_list is allocated by kcalloc(). The memory is already set to zero. It is unnecessary to call memset again. Link: https://lore.kernel.org/r/20220407072442.4137977-1-wanjiabing@vivo.com Acked-by: Sumit Saxena Signed-off-by: Wan Jiabing Signed-off-by: Martin K. Petersen --- drivers/scsi/megaraid/megaraid_sas_base.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 8bf72dbc33b7..33f3226023f3 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -4466,8 +4466,6 @@ int megasas_alloc_cmds(struct megasas_instance *instance) return -ENOMEM; } - memset(instance->cmd_list, 0, sizeof(struct megasas_cmd *) *max_cmd); - for (i = 0; i < max_cmd; i++) { instance->cmd_list[i] = kmalloc(sizeof(struct megasas_cmd), GFP_KERNEL); From 25a0bf213b8a563c5244326ae992456e8c9bb373 Mon Sep 17 00:00:00 2001 From: Po-Wen Kao Date: Tue, 12 Apr 2022 15:31:28 +0800 Subject: [PATCH 005/177] scsi: ufs: core: Remove redundant HPB unmap Since the HPB mapping is already reset in ufshpb_init() by setting flag QUERY_FLAG_IDN_HPB_RESET, there is no need doing so again in ufshpb_hpb_lu_prepared(). This also resolves the issue where HPB WRITE BUFFER is issued before UAC is cleared. Link: https://lore.kernel.org/r/20220412073131.10644-1-powen.kao@mediatek.com Acked-by: Bean Huo Signed-off-by: Po-Wen Kao Signed-off-by: Bean Huo Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufshpb.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c index b2bec19022cd..c8bab2eed43e 100644 --- a/drivers/scsi/ufs/ufshpb.c +++ b/drivers/scsi/ufs/ufshpb.c @@ -931,11 +931,6 @@ static int ufshpb_issue_umap_single_req(struct ufshpb_lu *hpb, return ufshpb_issue_umap_req(hpb, rgn, true); } -static int ufshpb_issue_umap_all_req(struct ufshpb_lu *hpb) -{ - return ufshpb_issue_umap_req(hpb, NULL, false); -} - static void __ufshpb_evict_region(struct ufshpb_lu *hpb, struct ufshpb_region *rgn) { @@ -2456,8 +2451,6 @@ static void ufshpb_hpb_lu_prepared(struct ufs_hba *hba) ufshpb_set_state(hpb, HPB_PRESENT); if ((hpb->lu_pinned_end - hpb->lu_pinned_start) > 0) queue_work(ufshpb_wq, &hpb->map_work); - if (!hpb->is_hcm) - ufshpb_issue_umap_all_req(hpb); } else { dev_err(hba->dev, "destroy HPB lu %d\n", hpb->lun); ufshpb_destroy_lu(hba, sdev); From b83a8c21f3fe874e12eb2b6e6c5cfb220d35c446 Mon Sep 17 00:00:00 2001 From: James Smart Date: Tue, 12 Apr 2022 15:19:43 -0700 Subject: [PATCH 006/177] scsi: lpfc: Tweak message log categories for ELS/FDMI/NVMe rescan Several log message categories were updated: - Enable msg 4623 (Xmit of ECD) to display for ELS logging. - Change msg 0220 (FDMI cmd failed) to display for ELS logging. - Change msg 6460 (FDMI RPA failure) to be warning not hard error. - Change msg 6172 (NVME rescan of DID) to be logged under NVMe discovery. Link: https://lore.kernel.org/r/20220412222008.126521-2-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_ct.c | 6 +++--- drivers/scsi/lpfc/lpfc_els.c | 2 +- drivers/scsi/lpfc/lpfc_nvme.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c index 4b024aa03c1b..4334bd358c5a 100644 --- a/drivers/scsi/lpfc/lpfc_ct.c +++ b/drivers/scsi/lpfc/lpfc_ct.c @@ -2236,7 +2236,7 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, cmd = be16_to_cpu(fdmi_cmd); if (fdmi_rsp == cpu_to_be16(SLI_CT_RESPONSE_FS_RJT)) { /* FDMI rsp failed */ - lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, + lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY | LOG_ELS, "0220 FDMI cmd failed FS_RJT Data: x%x", cmd); /* Should we fallback to FDMI-2 / FDMI-1 ? */ @@ -2272,9 +2272,9 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, phba->link_flag &= ~LS_CT_VEN_RPA; if (phba->cmf_active_mode == LPFC_CFG_OFF) return; - lpfc_printf_log(phba, KERN_ERR, + lpfc_printf_log(phba, KERN_WARNING, LOG_DISCOVERY | LOG_ELS, - "6460 VEN FDMI RPA failure\n"); + "6460 VEN FDMI RPA RJT\n"); return; } if (vport->fdmi_port_mask == LPFC_FDMI2_PORT_ATTR) { diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index ef6e8cd8c26a..7f2b65e4affa 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -4258,7 +4258,7 @@ lpfc_issue_els_edc(struct lpfc_vport *vport, uint8_t retry) phba->cgn_sig_freq = lpfc_fabric_cgn_frequency; - lpfc_printf_vlog(vport, KERN_INFO, LOG_CGN_MGMT, + lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS | LOG_CGN_MGMT, "4623 Xmit EDC to remote " "NPORT x%x reg_sig x%x reg_fpin:x%x\n", ndlp->nlp_DID, phba->cgn_reg_signal, diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c index 8d26f207ebd2..699b79d4f496 100644 --- a/drivers/scsi/lpfc/lpfc_nvme.c +++ b/drivers/scsi/lpfc/lpfc_nvme.c @@ -2466,12 +2466,12 @@ lpfc_nvme_rescan_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) if (!nrport || !remoteport) goto rescan_exit; - /* Only rescan if we are an NVME target in the MAPPED state */ + /* Rescan an NVME target in MAPPED state with DISCOVERY role set */ if (remoteport->port_role & FC_PORT_ROLE_NVME_DISCOVERY && ndlp->nlp_state == NLP_STE_MAPPED_NODE) { nvme_fc_rescan_remoteport(remoteport); - lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, + lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC, "6172 NVME rescanned DID x%06x " "port_state x%x\n", ndlp->nlp_DID, remoteport->port_state); From e294647b1aed4247fe52851f3a3b2b19ae906228 Mon Sep 17 00:00:00 2001 From: James Smart Date: Tue, 12 Apr 2022 15:19:44 -0700 Subject: [PATCH 007/177] scsi: lpfc: Move cfg_log_verbose check before calling lpfc_dmp_dbg() In an attempt to log message 0126 with LOG_TRACE_EVENT, the following hard lockup call trace hangs the system. Call Trace: _raw_spin_lock_irqsave+0x32/0x40 lpfc_dmp_dbg.part.32+0x28/0x220 [lpfc] lpfc_cmpl_els_fdisc+0x145/0x460 [lpfc] lpfc_sli_cancel_jobs+0x92/0xd0 [lpfc] lpfc_els_flush_cmd+0x43c/0x670 [lpfc] lpfc_els_flush_all_cmd+0x37/0x60 [lpfc] lpfc_sli4_async_event_proc+0x956/0x1720 [lpfc] lpfc_do_work+0x1485/0x1d70 [lpfc] kthread+0x112/0x130 ret_from_fork+0x1f/0x40 Kernel panic - not syncing: Hard LOCKUP The same CPU tries to claim the phba->port_list_lock twice. Move the cfg_log_verbose checks as part of the lpfc_printf_vlog() and lpfc_printf_log() macros before calling lpfc_dmp_dbg(). There is no need to take the phba->port_list_lock within lpfc_dmp_dbg(). Link: https://lore.kernel.org/r/20220412222008.126521-3-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_init.c | 29 +---------------------------- drivers/scsi/lpfc/lpfc_logmsg.h | 6 +++--- 2 files changed, 4 insertions(+), 31 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 461d333b1b3a..f9cd4b72d949 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -15700,34 +15700,7 @@ void lpfc_dmp_dbg(struct lpfc_hba *phba) unsigned int temp_idx; int i; int j = 0; - unsigned long rem_nsec, iflags; - bool log_verbose = false; - struct lpfc_vport *port_iterator; - - /* Don't dump messages if we explicitly set log_verbose for the - * physical port or any vport. - */ - if (phba->cfg_log_verbose) - return; - - spin_lock_irqsave(&phba->port_list_lock, iflags); - list_for_each_entry(port_iterator, &phba->port_list, listentry) { - if (port_iterator->load_flag & FC_UNLOADING) - continue; - if (scsi_host_get(lpfc_shost_from_vport(port_iterator))) { - if (port_iterator->cfg_log_verbose) - log_verbose = true; - - scsi_host_put(lpfc_shost_from_vport(port_iterator)); - - if (log_verbose) { - spin_unlock_irqrestore(&phba->port_list_lock, - iflags); - return; - } - } - } - spin_unlock_irqrestore(&phba->port_list_lock, iflags); + unsigned long rem_nsec; if (atomic_cmpxchg(&phba->dbg_log_dmping, 0, 1) != 0) return; diff --git a/drivers/scsi/lpfc/lpfc_logmsg.h b/drivers/scsi/lpfc/lpfc_logmsg.h index 7d480c798794..a5aafe230c74 100644 --- a/drivers/scsi/lpfc/lpfc_logmsg.h +++ b/drivers/scsi/lpfc/lpfc_logmsg.h @@ -73,7 +73,7 @@ do { \ #define lpfc_printf_vlog(vport, level, mask, fmt, arg...) \ do { \ { if (((mask) & (vport)->cfg_log_verbose) || (level[1] <= '3')) { \ - if ((mask) & LOG_TRACE_EVENT) \ + if ((mask) & LOG_TRACE_EVENT && !(vport)->cfg_log_verbose) \ lpfc_dmp_dbg((vport)->phba); \ dev_printk(level, &((vport)->phba->pcidev)->dev, "%d:(%d):" \ fmt, (vport)->phba->brd_no, vport->vpi, ##arg); \ @@ -89,11 +89,11 @@ do { \ (phba)->pport->cfg_log_verbose : \ (phba)->cfg_log_verbose; \ if (((mask) & log_verbose) || (level[1] <= '3')) { \ - if ((mask) & LOG_TRACE_EVENT) \ + if ((mask) & LOG_TRACE_EVENT && !log_verbose) \ lpfc_dmp_dbg(phba); \ dev_printk(level, &((phba)->pcidev)->dev, "%d:" \ fmt, phba->brd_no, ##arg); \ - } else if (!(phba)->cfg_log_verbose)\ + } else if (!log_verbose)\ lpfc_dbg_print(phba, "%d:" fmt, phba->brd_no, ##arg); \ } \ } while (0) From a6de9a2fa0d67ac33ce398333e7398ae24c7af2a Mon Sep 17 00:00:00 2001 From: James Smart Date: Tue, 12 Apr 2022 15:19:45 -0700 Subject: [PATCH 008/177] scsi: lpfc: Fix diagnostic fw logging after a function reset The lpfc_sli4_ras_setup() routine is only called from the lpfc_pci_probe_one_s4() routine, which means diagnostic fw logging initialization only occurs during probing. Thus, any path involving a reset of the HBA that restarts the state of the SLI port does not reinitialize diagnostic fw logging. Move lpfc_sli4_ras_setup() into lpfc_sli4_hba_setup() so that the LOWLEVEL_SET_DIAG_LOG_OPTIONS mailbox command can be sent after a function reset. Link: https://lore.kernel.org/r/20220412222008.126521-4-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_init.c | 3 --- drivers/scsi/lpfc/lpfc_sli.c | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index f9cd4b72d949..7dfd47dcaad9 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -14832,9 +14832,6 @@ lpfc_pci_probe_one_s4(struct pci_dev *pdev, const struct pci_device_id *pid) /* Check if there are static vports to be created. */ lpfc_create_static_vport(phba); - /* Enable RAS FW log support */ - lpfc_sli4_ras_setup(phba); - timer_setup(&phba->cpuhp_poll_timer, lpfc_sli4_poll_hbtimer, 0); cpuhp_state_add_instance_nocalls(lpfc_cpuhp_state, &phba->cpuhp); diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index bda2a7ba4e77..7c86271f05fd 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -8864,6 +8864,9 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba) } mempool_free(mboxq, phba->mbox_mem_pool); + /* Enable RAS FW log support */ + lpfc_sli4_ras_setup(phba); + phba->hba_flag |= HBA_SETUP; return rc; From 787d0580ca181d254f4dfd8b281cbea31120bde3 Mon Sep 17 00:00:00 2001 From: James Smart Date: Tue, 12 Apr 2022 15:19:46 -0700 Subject: [PATCH 009/177] scsi: lpfc: Zero SLI4 fcp_cmnd buffer's fcpCntl0 field It's possible that the fcpCntl0 reserved field is allocated non-zero. For certain target storage arrays this could cause problems expecting reserved fields to be all zero. SLI3 path already allocates fcp_cmnd buffer with dma_pool_zalloc() in lpfc_new_scsi_buf_s3. The fcpCntl0 field itself is never proactively set throughout the SCSI I/O path. Thus, we only change the SLI4 fcp_cmnd buffer allocation to dma_pool_zalloc. Link: https://lore.kernel.org/r/20220412222008.126521-5-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_sli.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index 7c86271f05fd..28d8ded9e7e1 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -22117,7 +22117,7 @@ lpfc_get_cmd_rsp_buf_per_hdwq(struct lpfc_hba *phba, return NULL; } - tmp->fcp_cmnd = dma_pool_alloc(phba->lpfc_cmd_rsp_buf_pool, + tmp->fcp_cmnd = dma_pool_zalloc(phba->lpfc_cmd_rsp_buf_pool, GFP_ATOMIC, &tmp->fcp_cmd_rsp_dma_handle); From b6474465e962369c1cd4b00324c2e175e2cf30cf Mon Sep 17 00:00:00 2001 From: James Smart Date: Tue, 12 Apr 2022 15:19:47 -0700 Subject: [PATCH 010/177] scsi: lpfc: Requeue SCSI I/O to upper layer when fw reports link down During heavy I/O stress tests with 100+ vports and cable pulls, it may take a while before the vport logs back into the fabric to resume I/O. Currently, the driver immediately fails the I/O with DID_ERROR. Change behavior to return DID_REQUEUE, and rely on SCSI layer's max retry of 5 before erroring out the I/O. Link: https://lore.kernel.org/r/20220412222008.126521-6-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_scsi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index ba9dbb51b75f..ae340850d94f 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -4276,6 +4276,7 @@ lpfc_fcp_io_cmd_wqe_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn, break; } if (lpfc_cmd->result == IOERR_INVALID_RPI || + lpfc_cmd->result == IOERR_LINK_DOWN || lpfc_cmd->result == IOERR_NO_RESOURCES || lpfc_cmd->result == IOERR_ABORT_REQUESTED || lpfc_cmd->result == IOERR_RPI_SUSPENDED || From 03cbbd7c2f5ee288f648f4aeedc765a181188553 Mon Sep 17 00:00:00 2001 From: James Smart Date: Tue, 12 Apr 2022 15:19:48 -0700 Subject: [PATCH 011/177] scsi: lpfc: Fix SCSI I/O completion and abort handler deadlock During stress I/O tests with 500+ vports, hard LOCKUP call traces are observed. CPU A: native_queued_spin_lock_slowpath+0x192 _raw_spin_lock_irqsave+0x32 lpfc_handle_fcp_err+0x4c6 lpfc_fcp_io_cmd_wqe_cmpl+0x964 lpfc_sli4_fp_handle_cqe+0x266 __lpfc_sli4_process_cq+0x105 __lpfc_sli4_hba_process_cq+0x3c lpfc_cq_poll_hdler+0x16 irq_poll_softirq+0x76 __softirqentry_text_start+0xe4 irq_exit+0xf7 do_IRQ+0x7f CPU B: native_queued_spin_lock_slowpath+0x5b _raw_spin_lock+0x1c lpfc_abort_handler+0x13e scmd_eh_abort_handler+0x85 process_one_work+0x1a7 worker_thread+0x30 kthread+0x112 ret_from_fork+0x1f Diagram of lockup: CPUA CPUB ---- ---- lpfc_cmd->buf_lock phba->hbalock lpfc_cmd->buf_lock phba->hbalock Fix by reordering the taking of the lpfc_cmd->buf_lock and phba->hbalock in lpfc_abort_handler routine so that it tries to take the lpfc_cmd->buf_lock first before phba->hbalock. Link: https://lore.kernel.org/r/20220412222008.126521-7-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_scsi.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index ae340850d94f..c3daf7a3e123 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -5865,25 +5865,25 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) if (!lpfc_cmd) return ret; - spin_lock_irqsave(&phba->hbalock, flags); + /* Guard against IO completion being called at same time */ + spin_lock_irqsave(&lpfc_cmd->buf_lock, flags); + + spin_lock(&phba->hbalock); /* driver queued commands are in process of being flushed */ if (phba->hba_flag & HBA_IOQ_FLUSH) { lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP, "3168 SCSI Layer abort requested I/O has been " "flushed by LLD.\n"); ret = FAILED; - goto out_unlock; + goto out_unlock_hba; } - /* Guard against IO completion being called at same time */ - spin_lock(&lpfc_cmd->buf_lock); - if (!lpfc_cmd->pCmd) { lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP, "2873 SCSI Layer I/O Abort Request IO CMPL Status " "x%x ID %d LUN %llu\n", SUCCESS, cmnd->device->id, cmnd->device->lun); - goto out_unlock_buf; + goto out_unlock_hba; } iocb = &lpfc_cmd->cur_iocbq; @@ -5891,7 +5891,7 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) pring_s4 = phba->sli4_hba.hdwq[iocb->hba_wqidx].io_wq->pring; if (!pring_s4) { ret = FAILED; - goto out_unlock_buf; + goto out_unlock_hba; } spin_lock(&pring_s4->ring_lock); } @@ -5924,8 +5924,8 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) "3389 SCSI Layer I/O Abort Request is pending\n"); if (phba->sli_rev == LPFC_SLI_REV4) spin_unlock(&pring_s4->ring_lock); - spin_unlock(&lpfc_cmd->buf_lock); - spin_unlock_irqrestore(&phba->hbalock, flags); + spin_unlock(&phba->hbalock); + spin_unlock_irqrestore(&lpfc_cmd->buf_lock, flags); goto wait_for_cmpl; } @@ -5946,15 +5946,13 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) if (ret_val != IOCB_SUCCESS) { /* Indicate the IO is not being aborted by the driver. */ lpfc_cmd->waitq = NULL; - spin_unlock(&lpfc_cmd->buf_lock); - spin_unlock_irqrestore(&phba->hbalock, flags); ret = FAILED; - goto out; + goto out_unlock_hba; } /* no longer need the lock after this point */ - spin_unlock(&lpfc_cmd->buf_lock); - spin_unlock_irqrestore(&phba->hbalock, flags); + spin_unlock(&phba->hbalock); + spin_unlock_irqrestore(&lpfc_cmd->buf_lock, flags); if (phba->cfg_poll & DISABLE_FCP_RING_INT) lpfc_sli_handle_fast_ring_event(phba, @@ -5989,10 +5987,9 @@ wait_for_cmpl: out_unlock_ring: if (phba->sli_rev == LPFC_SLI_REV4) spin_unlock(&pring_s4->ring_lock); -out_unlock_buf: - spin_unlock(&lpfc_cmd->buf_lock); -out_unlock: - spin_unlock_irqrestore(&phba->hbalock, flags); +out_unlock_hba: + spin_unlock(&phba->hbalock); + spin_unlock_irqrestore(&lpfc_cmd->buf_lock, flags); out: lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP, "0749 SCSI Layer I/O Abort Request Status x%x ID %d " From 3483a44bdfb475432081a27b38ea7fb8305814af Mon Sep 17 00:00:00 2001 From: James Smart Date: Tue, 12 Apr 2022 15:19:49 -0700 Subject: [PATCH 012/177] scsi: lpfc: Clear fabric topology flag before initiating a new FLOGI Previous topologies may no longer be in fabric mode, so clear FC_FABRIC in fc_flag for every new FLOGI. Link: https://lore.kernel.org/r/20220412222008.126521-8-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_els.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index 7f2b65e4affa..59e8c6f9d30e 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -1531,6 +1531,8 @@ lpfc_initial_flogi(struct lpfc_vport *vport) lpfc_enqueue_node(vport, ndlp); } + /* Reset the Fabric flag, topology change may have happened */ + vport->fc_flag &= ~FC_FABRIC; if (lpfc_issue_els_flogi(vport, ndlp, 0)) { /* This decrement of reference count to node shall kick off * the release of the node. From 577a942df3de2666f6947bdd3a5c9e8d30073424 Mon Sep 17 00:00:00 2001 From: James Smart Date: Tue, 12 Apr 2022 15:19:50 -0700 Subject: [PATCH 013/177] scsi: lpfc: Fix null pointer dereference after failing to issue FLOGI and PLOGI If lpfc_issue_els_flogi() fails and returns non-zero status, the node reference count is decremented to trigger the release of the nodelist structure. However, if there is a prior registration or dev-loss-evt work pending, the node may be released prematurely. When dev-loss-evt completes, the released node is referenced causing a use-after-free null pointer dereference. Similarly, when processing non-zero ELS PLOGI completion status in lpfc_cmpl_els_plogi(), the ndlp flags are checked for a transport registration before triggering node removal. If dev-loss-evt work is pending, the node may be released prematurely and a subsequent call to lpfc_dev_loss_tmo_handler() results in a use after free ndlp dereference. Add test for pending dev-loss before decrementing the node reference count for FLOGI, PLOGI, PRLI, and ADISC handling. Link: https://lore.kernel.org/r/20220412222008.126521-9-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_els.c | 51 +++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index 59e8c6f9d30e..44ef87324b80 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -1534,10 +1534,13 @@ lpfc_initial_flogi(struct lpfc_vport *vport) /* Reset the Fabric flag, topology change may have happened */ vport->fc_flag &= ~FC_FABRIC; if (lpfc_issue_els_flogi(vport, ndlp, 0)) { - /* This decrement of reference count to node shall kick off - * the release of the node. + /* A node reference should be retained while registered with a + * transport or dev-loss-evt work is pending. + * Otherwise, decrement node reference to trigger release. */ - lpfc_nlp_put(ndlp); + if (!(ndlp->fc4_xpt_flags & (SCSI_XPT_REGD | NVME_XPT_REGD)) && + !(ndlp->nlp_flag & NLP_IN_DEV_LOSS)) + lpfc_nlp_put(ndlp); return 0; } return 1; @@ -1580,10 +1583,13 @@ lpfc_initial_fdisc(struct lpfc_vport *vport) } if (lpfc_issue_els_fdisc(vport, ndlp, 0)) { - /* decrement node reference count to trigger the release of - * the node. + /* A node reference should be retained while registered with a + * transport or dev-loss-evt work is pending. + * Otherwise, decrement node reference to trigger release. */ - lpfc_nlp_put(ndlp); + if (!(ndlp->fc4_xpt_flags & (SCSI_XPT_REGD | NVME_XPT_REGD)) && + !(ndlp->nlp_flag & NLP_IN_DEV_LOSS)) + lpfc_nlp_put(ndlp); return 0; } return 1; @@ -1985,6 +1991,7 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, int disc; struct serv_parm *sp = NULL; u32 ulp_status, ulp_word4, did, iotag; + bool release_node = false; /* we pass cmdiocb to state machine which needs rspiocb as well */ cmdiocb->context_un.rsp_iocb = rspiocb; @@ -2073,19 +2080,21 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, spin_unlock_irq(&ndlp->lock); goto out; } - spin_unlock_irq(&ndlp->lock); /* No PLOGI collision and the node is not registered with the * scsi or nvme transport. It is no longer an active node. Just * start the device remove process. */ if (!(ndlp->fc4_xpt_flags & (SCSI_XPT_REGD | NVME_XPT_REGD))) { - spin_lock_irq(&ndlp->lock); ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; - spin_unlock_irq(&ndlp->lock); + if (!(ndlp->nlp_flag & NLP_IN_DEV_LOSS)) + release_node = true; + } + spin_unlock_irq(&ndlp->lock); + + if (release_node) lpfc_disc_state_machine(vport, ndlp, cmdiocb, NLP_EVT_DEVICE_RM); - } } else { /* Good status, call state machine */ prsp = list_entry(((struct lpfc_dmabuf *) @@ -2296,6 +2305,7 @@ lpfc_cmpl_els_prli(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, u32 loglevel; u32 ulp_status; u32 ulp_word4; + bool release_node = false; /* we pass cmdiocb to state machine which needs rspiocb as well */ cmdiocb->context_un.rsp_iocb = rspiocb; @@ -2372,14 +2382,18 @@ lpfc_cmpl_els_prli(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, * it is no longer an active node. Otherwise devloss * handles the final cleanup. */ + spin_lock_irq(&ndlp->lock); if (!(ndlp->fc4_xpt_flags & (SCSI_XPT_REGD | NVME_XPT_REGD)) && !ndlp->fc4_prli_sent) { - spin_lock_irq(&ndlp->lock); ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; - spin_unlock_irq(&ndlp->lock); + if (!(ndlp->nlp_flag & NLP_IN_DEV_LOSS)) + release_node = true; + } + spin_unlock_irq(&ndlp->lock); + + if (release_node) lpfc_disc_state_machine(vport, ndlp, cmdiocb, NLP_EVT_DEVICE_RM); - } } else { /* Good status, call state machine. However, if another * PRLI is outstanding, don't call the state machine @@ -2751,6 +2765,7 @@ lpfc_cmpl_els_adisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, struct lpfc_nodelist *ndlp; int disc; u32 ulp_status, ulp_word4, tmo; + bool release_node = false; /* we pass cmdiocb to state machine which needs rspiocb as well */ cmdiocb->context_un.rsp_iocb = rspiocb; @@ -2817,13 +2832,17 @@ lpfc_cmpl_els_adisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, * transport, it is no longer an active node. Otherwise * devloss handles the final cleanup. */ + spin_lock_irq(&ndlp->lock); if (!(ndlp->fc4_xpt_flags & (SCSI_XPT_REGD | NVME_XPT_REGD))) { - spin_lock_irq(&ndlp->lock); ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; - spin_unlock_irq(&ndlp->lock); + if (!(ndlp->nlp_flag & NLP_IN_DEV_LOSS)) + release_node = true; + } + spin_unlock_irq(&ndlp->lock); + + if (release_node) lpfc_disc_state_machine(vport, ndlp, cmdiocb, NLP_EVT_DEVICE_RM); - } } else /* Good status, call state machine */ lpfc_disc_state_machine(vport, ndlp, cmdiocb, From 672d1cb40551ea9c95efad43ab6d45e4ab4e015f Mon Sep 17 00:00:00 2001 From: James Smart Date: Tue, 12 Apr 2022 15:19:51 -0700 Subject: [PATCH 014/177] scsi: lpfc: Protect memory leak for NPIV ports sending PLOGI_RJT There is a potential memory leak in lpfc_ignore_els_cmpl() and lpfc_els_rsp_reject() that was allocated from NPIV PLOGI_RJT (lpfc_rcv_plogi()'s login_mbox). Check if cmdiocb->context_un.mbox was allocated in lpfc_ignore_els_cmpl(), and then free it back to phba->mbox_mem_pool along with mbox->ctx_buf for service parameters. For lpfc_els_rsp_reject() failure, free both the ctx_buf for service parameters and the login_mbox. Link: https://lore.kernel.org/r/20220412222008.126521-10-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_nportdisc.c | 10 ++++++++-- drivers/scsi/lpfc/lpfc_sli.c | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c index c4e1a07066a2..4b065c51ee1b 100644 --- a/drivers/scsi/lpfc/lpfc_nportdisc.c +++ b/drivers/scsi/lpfc/lpfc_nportdisc.c @@ -614,9 +614,15 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, stat.un.b.lsRjtRsnCode = LSRJT_INVALID_CMD; stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE; rc = lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, - ndlp, login_mbox); - if (rc) + ndlp, login_mbox); + if (rc) { + mp = (struct lpfc_dmabuf *)login_mbox->ctx_buf; + if (mp) { + lpfc_mbuf_free(phba, mp->virt, mp->phys); + kfree(mp); + } mempool_free(login_mbox, phba->mbox_mem_pool); + } return 1; } diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index 28d8ded9e7e1..ca7766940b4e 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -12069,6 +12069,8 @@ lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, { struct lpfc_nodelist *ndlp = NULL; IOCB_t *irsp; + LPFC_MBOXQ_t *mbox; + struct lpfc_dmabuf *mp; u32 ulp_command, ulp_status, ulp_word4, iotag; ulp_command = get_job_cmnd(phba, cmdiocb); @@ -12080,6 +12082,21 @@ lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, } else { irsp = &rspiocb->iocb; iotag = irsp->ulpIoTag; + + /* It is possible a PLOGI_RJT for NPIV ports to get aborted. + * The MBX_REG_LOGIN64 mbox command is freed back to the + * mbox_mem_pool here. + */ + if (cmdiocb->context_un.mbox) { + mbox = cmdiocb->context_un.mbox; + mp = (struct lpfc_dmabuf *)mbox->ctx_buf; + if (mp) { + lpfc_mbuf_free(phba, mp->virt, mp->phys); + kfree(mp); + } + mempool_free(mbox, phba->mbox_mem_pool); + cmdiocb->context_un.mbox = NULL; + } } /* ELS cmd tag completes */ From 31e887864eb2c0cce3d0c448a7b1ef9792e850b7 Mon Sep 17 00:00:00 2001 From: James Smart Date: Tue, 12 Apr 2022 15:19:52 -0700 Subject: [PATCH 015/177] scsi: lpfc: Update fc_prli_sent outstanding only after guaranteed IOCB submit If lpfc_sli_issue_iocb() fails, then the fc_prli_sent is never decremented. Move the fc_prli_sent++ to after a guaranteed IOCB submit. Link: https://lore.kernel.org/r/20220412222008.126521-11-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_els.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index 44ef87324b80..8155c63d793c 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -2571,16 +2571,6 @@ lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, phba->fc_stat.elsXmitPRLI++; elsiocb->cmd_cmpl = lpfc_cmpl_els_prli; - spin_lock_irq(&ndlp->lock); - ndlp->nlp_flag |= NLP_PRLI_SND; - - /* The vport counters are used for lpfc_scan_finished, but - * the ndlp is used to track outstanding PRLIs for different - * FC4 types. - */ - vport->fc_prli_sent++; - ndlp->fc4_prli_sent++; - spin_unlock_irq(&ndlp->lock); lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, "Issue PRLI: did:x%x refcnt %d", @@ -2588,16 +2578,25 @@ lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, elsiocb->context1 = lpfc_nlp_get(ndlp); if (!elsiocb->context1) { lpfc_els_free_iocb(phba, elsiocb); - goto err; + return 1; } rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); if (rc == IOCB_ERROR) { lpfc_els_free_iocb(phba, elsiocb); lpfc_nlp_put(ndlp); - goto err; + return 1; } + /* The vport counters are used for lpfc_scan_finished, but + * the ndlp is used to track outstanding PRLIs for different + * FC4 types. + */ + spin_lock_irq(&ndlp->lock); + ndlp->nlp_flag |= NLP_PRLI_SND; + vport->fc_prli_sent++; + ndlp->fc4_prli_sent++; + spin_unlock_irq(&ndlp->lock); /* The driver supports 2 FC4 types. Make sure * a PRLI is issued for all types before exiting. @@ -2607,12 +2606,6 @@ lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, goto send_next_prli; else return 0; - -err: - spin_lock_irq(&ndlp->lock); - ndlp->nlp_flag &= ~NLP_PRLI_SND; - spin_unlock_irq(&ndlp->lock); - return 1; } /** From 76395c88d0afb82c9bec87e99e282c4ff11ea5f4 Mon Sep 17 00:00:00 2001 From: James Smart Date: Tue, 12 Apr 2022 15:19:53 -0700 Subject: [PATCH 016/177] scsi: lpfc: Transition to NPR state upon LOGO cmpl if link down or aborted In P2P topology, a target controller reboot sometimes results in not reestablishing a login because the ndlp is stuck in LOGO state. Fix by transitioning to NPR state if we get link down before LOGO completes. Link: https://lore.kernel.org/r/20220412222008.126521-12-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_els.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index 8155c63d793c..50ecf9bfbf65 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -3007,7 +3007,10 @@ lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, ndlp->nlp_DID, ulp_status, ulp_word4); + /* Call NLP_EVT_DEVICE_RM if link is down or LOGO is aborted */ if (lpfc_error_lost_link(ulp_status, ulp_word4)) { + lpfc_disc_state_machine(vport, ndlp, cmdiocb, + NLP_EVT_DEVICE_RM); skip_recovery = 1; goto out; } From d531d9874da85e36fc99ce75175ed47c9c360c20 Mon Sep 17 00:00:00 2001 From: James Smart Date: Tue, 12 Apr 2022 15:19:54 -0700 Subject: [PATCH 017/177] scsi: lpfc: Remove unnecessary NULL pointer assignment for ELS_RDF path The command IOCB ndlp pointer is overwritten in lpfc_issue_els_rdf(), and the original ndlp pointer is stored ahead of time. This null ptr assignment can be safely removed. Link: https://lore.kernel.org/r/20220412222008.126521-13-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_els.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index 50ecf9bfbf65..a7a47da4bb9d 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -3388,7 +3388,6 @@ lpfc_cmpl_els_disc_cmd(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, lpfc_issue_els_edc(vport, cmdiocb->retry); break; case ELS_CMD_RDF: - cmdiocb->context1 = NULL; /* save ndlp refcnt */ lpfc_issue_els_rdf(vport, cmdiocb->retry); break; } From 39a1a86b9da22738f45460b50938515de8b9e48e Mon Sep 17 00:00:00 2001 From: James Smart Date: Tue, 12 Apr 2022 15:19:55 -0700 Subject: [PATCH 018/177] scsi: lpfc: Move MI module parameter check to handle dynamic disable lpfc_refresh_params() can be called for an async event handler. This could potentially override the value initialized by lpfc_cmf_setup(). Move module parameter check to lpfc_refresh_params(). Link: https://lore.kernel.org/r/20220412222008.126521-14-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_init.c | 8 +++++++- drivers/scsi/lpfc/lpfc_sli.c | 4 ---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 7dfd47dcaad9..ec6da7e27e4b 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -686,8 +686,14 @@ lpfc_sli4_refresh_params(struct lpfc_hba *phba) return rc; } mbx_sli4_parameters = &mqe->un.get_sli4_parameters.sli4_parameters; - phba->sli4_hba.pc_sli4_params.mi_ver = + + /* Are we forcing MI off via module parameter? */ + if (phba->cfg_enable_mi) + phba->sli4_hba.pc_sli4_params.mi_ver = bf_get(cfg_mi_ver, mbx_sli4_parameters); + else + phba->sli4_hba.pc_sli4_params.mi_ver = 0; + phba->sli4_hba.pc_sli4_params.cmf = bf_get(cfg_cmf, mbx_sli4_parameters); phba->sli4_hba.pc_sli4_params.pls = diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index ca7766940b4e..3b9359c1ee1c 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -7994,10 +7994,6 @@ lpfc_cmf_setup(struct lpfc_hba *phba) sli4_params = &phba->sli4_hba.pc_sli4_params; - /* Are we forcing MI off via module parameter? */ - if (!phba->cfg_enable_mi) - sli4_params->mi_ver = 0; - /* Always try to enable MI feature if we can */ if (sli4_params->mi_ver) { lpfc_set_features(phba, mboxq, LPFC_SET_ENABLE_MI); From 5295d19d4f97d66d88cea26ff3ef779a37264134 Mon Sep 17 00:00:00 2001 From: James Smart Date: Tue, 12 Apr 2022 15:19:56 -0700 Subject: [PATCH 019/177] scsi: lpfc: Correct CRC32 calculation for congestion stats lpfc_cgn_calc_crc32() is returning 32 bits, and lpfc_cgn_update_stat() was using u16 to store the crc32 value. Correct by redeclaring the local variable to u32. Link: https://lore.kernel.org/r/20220412222008.126521-15-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index ec6da7e27e4b..578e9947125b 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -5539,7 +5539,7 @@ lpfc_cgn_update_stat(struct lpfc_hba *phba, uint32_t dtag) struct tm broken; struct timespec64 cur_time; u32 cnt; - u16 value; + u32 value; /* Make sure we have a congestion info buffer */ if (!phba->cgn_i) From d6d45f67a11136cb88a70a29ab22ea6db8ae6bd5 Mon Sep 17 00:00:00 2001 From: James Smart Date: Tue, 12 Apr 2022 15:19:57 -0700 Subject: [PATCH 020/177] scsi: lpfc: Fix call trace observed during I/O with CMF enabled The following was seen with CMF enabled: BUG: using smp_processor_id() in preemptible code: systemd-udevd/31711 kernel: caller is lpfc_update_cmf_cmd+0x214/0x420 [lpfc] kernel: CPU: 12 PID: 31711 Comm: systemd-udevd kernel: Call Trace: kernel: kernel: dump_stack_lvl+0x44/0x57 kernel: check_preemption_disabled+0xbf/0xe0 kernel: lpfc_update_cmf_cmd+0x214/0x420 [lpfc] kernel: lpfc_nvme_fcp_io_submit+0x23b4/0x4df0 [lpfc] this_cpu_ptr() calls smp_processor_id() in a preemptible context. Fix by using per_cpu_ptr() with raw_smp_processor_id() instead. Link: https://lore.kernel.org/r/20220412222008.126521-16-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_scsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index c3daf7a3e123..a949fe53651a 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -3835,7 +3835,7 @@ lpfc_update_cmf_cmpl(struct lpfc_hba *phba, else time = div_u64(time + 500, 1000); /* round it */ - cgs = this_cpu_ptr(phba->cmf_stat); + cgs = per_cpu_ptr(phba->cmf_stat, raw_smp_processor_id()); atomic64_add(size, &cgs->rcv_bytes); atomic64_add(time, &cgs->rx_latency); atomic_inc(&cgs->rx_io_cnt); @@ -3879,7 +3879,7 @@ lpfc_update_cmf_cmd(struct lpfc_hba *phba, uint32_t size) atomic_set(&phba->rx_max_read_cnt, size); } - cgs = this_cpu_ptr(phba->cmf_stat); + cgs = per_cpu_ptr(phba->cmf_stat, raw_smp_processor_id()); atomic64_add(size, &cgs->total_bytes); return 0; } From c364c453d30a07e5f8b97481cbe346df075c3e13 Mon Sep 17 00:00:00 2001 From: James Smart Date: Tue, 12 Apr 2022 15:19:58 -0700 Subject: [PATCH 021/177] scsi: lpfc: Revise FDMI reporting of supported port speed for trunk groups Trunk port FDMI supported port speed shows single port supported speed rather than the trunked port speed. Modify supported port speed logic calculation during registration. Link: https://lore.kernel.org/r/20220412222008.126521-17-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_ct.c | 68 ++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 20 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c index 4334bd358c5a..5f2b2d8eacbf 100644 --- a/drivers/scsi/lpfc/lpfc_ct.c +++ b/drivers/scsi/lpfc/lpfc_ct.c @@ -2830,31 +2830,59 @@ lpfc_fdmi_port_attr_support_speed(struct lpfc_vport *vport, struct lpfc_hba *phba = vport->phba; struct lpfc_fdmi_attr_entry *ae; uint32_t size; + u32 tcfg; + u8 i, cnt; ae = &ad->AttrValue; ae->un.AttrInt = 0; if (!(phba->hba_flag & HBA_FCOE_MODE)) { - if (phba->lmt & LMT_256Gb) - ae->un.AttrInt |= HBA_PORTSPEED_256GFC; - if (phba->lmt & LMT_128Gb) - ae->un.AttrInt |= HBA_PORTSPEED_128GFC; - if (phba->lmt & LMT_64Gb) - ae->un.AttrInt |= HBA_PORTSPEED_64GFC; - if (phba->lmt & LMT_32Gb) - ae->un.AttrInt |= HBA_PORTSPEED_32GFC; - if (phba->lmt & LMT_16Gb) - ae->un.AttrInt |= HBA_PORTSPEED_16GFC; - if (phba->lmt & LMT_10Gb) - ae->un.AttrInt |= HBA_PORTSPEED_10GFC; - if (phba->lmt & LMT_8Gb) - ae->un.AttrInt |= HBA_PORTSPEED_8GFC; - if (phba->lmt & LMT_4Gb) - ae->un.AttrInt |= HBA_PORTSPEED_4GFC; - if (phba->lmt & LMT_2Gb) - ae->un.AttrInt |= HBA_PORTSPEED_2GFC; - if (phba->lmt & LMT_1Gb) - ae->un.AttrInt |= HBA_PORTSPEED_1GFC; + cnt = 0; + if (phba->sli_rev == LPFC_SLI_REV4) { + tcfg = phba->sli4_hba.conf_trunk; + for (i = 0; i < 4; i++, tcfg >>= 1) + if (tcfg & 1) + cnt++; + } + + if (cnt > 2) { /* 4 lane trunk group */ + if (phba->lmt & LMT_64Gb) + ae->un.AttrInt |= HBA_PORTSPEED_256GFC; + if (phba->lmt & LMT_32Gb) + ae->un.AttrInt |= HBA_PORTSPEED_128GFC; + if (phba->lmt & LMT_16Gb) + ae->un.AttrInt |= HBA_PORTSPEED_64GFC; + } else if (cnt) { /* 2 lane trunk group */ + if (phba->lmt & LMT_128Gb) + ae->un.AttrInt |= HBA_PORTSPEED_256GFC; + if (phba->lmt & LMT_64Gb) + ae->un.AttrInt |= HBA_PORTSPEED_128GFC; + if (phba->lmt & LMT_32Gb) + ae->un.AttrInt |= HBA_PORTSPEED_64GFC; + if (phba->lmt & LMT_16Gb) + ae->un.AttrInt |= HBA_PORTSPEED_32GFC; + } else { + if (phba->lmt & LMT_256Gb) + ae->un.AttrInt |= HBA_PORTSPEED_256GFC; + if (phba->lmt & LMT_128Gb) + ae->un.AttrInt |= HBA_PORTSPEED_128GFC; + if (phba->lmt & LMT_64Gb) + ae->un.AttrInt |= HBA_PORTSPEED_64GFC; + if (phba->lmt & LMT_32Gb) + ae->un.AttrInt |= HBA_PORTSPEED_32GFC; + if (phba->lmt & LMT_16Gb) + ae->un.AttrInt |= HBA_PORTSPEED_16GFC; + if (phba->lmt & LMT_10Gb) + ae->un.AttrInt |= HBA_PORTSPEED_10GFC; + if (phba->lmt & LMT_8Gb) + ae->un.AttrInt |= HBA_PORTSPEED_8GFC; + if (phba->lmt & LMT_4Gb) + ae->un.AttrInt |= HBA_PORTSPEED_4GFC; + if (phba->lmt & LMT_2Gb) + ae->un.AttrInt |= HBA_PORTSPEED_2GFC; + if (phba->lmt & LMT_1Gb) + ae->un.AttrInt |= HBA_PORTSPEED_1GFC; + } } else { /* FCoE links support only one speed */ switch (phba->fc_linkspeed) { From 6c8a3ce64b2cb36e4006a61533aedc998723b41b Mon Sep 17 00:00:00 2001 From: James Smart Date: Tue, 12 Apr 2022 15:19:59 -0700 Subject: [PATCH 022/177] scsi: lpfc: Remove false FDMI NVMe FC-4 support for NPIV ports FDMI FC-4 Active Type for vports mistakenly shows NVMe support. Add a check to only set the NVMe support bit for the physical port. Link: https://lore.kernel.org/r/20220412222008.126521-18-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_ct.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c index 5f2b2d8eacbf..8df5ba3ed482 100644 --- a/drivers/scsi/lpfc/lpfc_ct.c +++ b/drivers/scsi/lpfc/lpfc_ct.c @@ -3153,6 +3153,7 @@ static int lpfc_fdmi_port_attr_active_fc4type(struct lpfc_vport *vport, struct lpfc_fdmi_attr_def *ad) { + struct lpfc_hba *phba = vport->phba; struct lpfc_fdmi_attr_entry *ae; uint32_t size; @@ -3163,7 +3164,8 @@ lpfc_fdmi_port_attr_active_fc4type(struct lpfc_vport *vport, ae->un.AttrTypes[7] = 0x01; /* Type 0x20 - CT */ /* Check to see if NVME is configured or not */ - if (vport->phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) + if (vport == phba->pport && + phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) ae->un.AttrTypes[6] = 0x1; /* Type 0x28 - NVME */ size = FOURBYTES + 32; From 6c983d327b9e628923916f9780bb0d107740d76b Mon Sep 17 00:00:00 2001 From: James Smart Date: Tue, 12 Apr 2022 15:20:00 -0700 Subject: [PATCH 023/177] scsi: lpfc: Register for Application Services FC-4 type in Fabric topology Add new FC-4 type 0x60 Application Services for fabric registration when VMID is enabled. Modified rft struture to indicate __be format. Removed redundant ipReg variable as it was not used. Link: https://lore.kernel.org/r/20220412222008.126521-19-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_ct.c | 26 ++++++++++++++------------ drivers/scsi/lpfc/lpfc_hw.h | 36 ++++++++++++++++++------------------ 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c index 8df5ba3ed482..c74833ed78c6 100644 --- a/drivers/scsi/lpfc/lpfc_ct.c +++ b/drivers/scsi/lpfc/lpfc_ct.c @@ -2018,28 +2018,30 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode, vport->ct_flags &= ~FC_CT_RFT_ID; CtReq->CommandResponse.bits.CmdRsp = cpu_to_be16(SLI_CTNS_RFT_ID); - CtReq->un.rft.PortId = cpu_to_be32(vport->fc_myDID); + CtReq->un.rft.port_id = cpu_to_be32(vport->fc_myDID); + + /* Register Application Services type if vmid enabled. */ + if (phba->cfg_vmid_app_header) + CtReq->un.rft.app_serv_reg = + cpu_to_be32(RFT_APP_SERV_REG); /* Register FC4 FCP type if enabled. */ if (vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH || vport->cfg_enable_fc4_type == LPFC_ENABLE_FCP) - CtReq->un.rft.fcpReg = 1; + CtReq->un.rft.fcp_reg = cpu_to_be32(RFT_FCP_REG); - /* Register NVME type if enabled. Defined LE and swapped. - * rsvd[0] is used as word1 because of the hard-coded - * word0 usage in the ct_request data structure. - */ + /* Register NVME type if enabled. */ if (vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH || vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME) - CtReq->un.rft.rsvd[0] = - cpu_to_be32(LPFC_FC4_TYPE_BITMASK); + CtReq->un.rft.nvme_reg = cpu_to_be32(RFT_NVME_REG); ptr = (uint32_t *)CtReq; lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, - "6433 Issue RFT (%s %s): %08x %08x %08x %08x " - "%08x %08x %08x %08x\n", - CtReq->un.rft.fcpReg ? "FCP" : " ", - CtReq->un.rft.rsvd[0] ? "NVME" : " ", + "6433 Issue RFT (%s %s %s): %08x %08x %08x " + "%08x %08x %08x %08x %08x\n", + CtReq->un.rft.fcp_reg ? "FCP" : " ", + CtReq->un.rft.nvme_reg ? "NVME" : " ", + CtReq->un.rft.app_serv_reg ? "APPS" : " ", *ptr, *(ptr + 1), *(ptr + 2), *(ptr + 3), *(ptr + 4), *(ptr + 5), *(ptr + 6), *(ptr + 7)); diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h index d6050f3c9efe..2f5537f57846 100644 --- a/drivers/scsi/lpfc/lpfc_hw.h +++ b/drivers/scsi/lpfc/lpfc_hw.h @@ -97,6 +97,18 @@ union CtCommandResponse { #define FC4_FEATURE_INIT 0x2 #define FC4_FEATURE_NVME_DISC 0x4 +enum rft_word0 { + RFT_FCP_REG = (0x1 << 8), +}; + +enum rft_word1 { + RFT_NVME_REG = (0x1 << 8), +}; + +enum rft_word3 { + RFT_APP_SERV_REG = (0x1 << 0), +}; + struct lpfc_sli_ct_request { /* Structure is in Big Endian format */ union CtRevisionId RevisionId; @@ -131,25 +143,13 @@ struct lpfc_sli_ct_request { uint8_t Fc4Type; } gid_ff; struct rft { - uint32_t PortId; /* For RFT_ID requests */ + __be32 port_id; /* For RFT_ID requests */ -#ifdef __BIG_ENDIAN_BITFIELD - uint32_t rsvd0:16; - uint32_t rsvd1:7; - uint32_t fcpReg:1; /* Type 8 */ - uint32_t rsvd2:2; - uint32_t ipReg:1; /* Type 5 */ - uint32_t rsvd3:5; -#else /* __LITTLE_ENDIAN_BITFIELD */ - uint32_t rsvd0:16; - uint32_t fcpReg:1; /* Type 8 */ - uint32_t rsvd1:7; - uint32_t rsvd3:5; - uint32_t ipReg:1; /* Type 5 */ - uint32_t rsvd2:2; -#endif - - uint32_t rsvd[7]; + __be32 fcp_reg; /* rsvd 31:9, fcp_reg 8, rsvd 7:0 */ + __be32 nvme_reg; /* rsvd 31:9, nvme_reg 8, rsvd 7:0 */ + __be32 word2; + __be32 app_serv_reg; /* rsvd 31:1, app_serv_reg 0 */ + __be32 word[4]; } rft; struct rnn { uint32_t PortId; /* For RNN_ID requests */ From 1045592fc968fe1e4b360b3bce2e9b522f173cdc Mon Sep 17 00:00:00 2001 From: James Smart Date: Tue, 12 Apr 2022 15:20:01 -0700 Subject: [PATCH 024/177] scsi: lpfc: Introduce FC_RSCN_MEMENTO flag for tracking post RSCN completion During an NVMe target reboot, the target may initialize itself as FCP only during the first RSCN and shortly after trigger a second RSCN claiming NVMe support. The timing of these RSCNs occur before FCP-PRLI for the first RSCN completes leading discovery issues over NVMe. Change RSCN and NVME-PRLI send logic based on a new FC_RSCN_MEMENTO flag that signals when lpfc_end_rscn() is completed and serves as a memento that discovery was started from RSCN. Link: https://lore.kernel.org/r/20220412222008.126521-20-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc.h | 1 + drivers/scsi/lpfc/lpfc_els.c | 8 ++++++-- drivers/scsi/lpfc/lpfc_hbadisc.c | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h index 0025760230e5..a62cf1a19280 100644 --- a/drivers/scsi/lpfc/lpfc.h +++ b/drivers/scsi/lpfc/lpfc.h @@ -604,6 +604,7 @@ struct lpfc_vport { #define FC_VFI_REGISTERED 0x800000 /* VFI is registered */ #define FC_FDISC_COMPLETED 0x1000000/* FDISC completed */ #define FC_DISC_DELAYED 0x2000000/* Delay NPort discovery */ +#define FC_RSCN_MEMENTO 0x4000000/* RSCN cmd processed */ uint32_t ct_flags; #define FC_CT_RFF_ID 0x1 /* RFF_ID accepted by switch */ diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index a7a47da4bb9d..e734ae972d1e 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -1896,6 +1896,7 @@ lpfc_end_rscn(struct lpfc_vport *vport) else { spin_lock_irq(shost->host_lock); vport->fc_flag &= ~FC_RSCN_MODE; + vport->fc_flag |= FC_RSCN_MEMENTO; spin_unlock_irq(shost->host_lock); } } @@ -2444,13 +2445,14 @@ lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, u32 local_nlp_type, elscmd; /* - * If we are in RSCN mode, the FC4 types supported from a + * If discovery was kicked off from RSCN mode, + * the FC4 types supported from a * previous GFT_ID command may not be accurate. So, if we * are a NVME Initiator, always look for the possibility of * the remote NPort beng a NVME Target. */ if (phba->sli_rev == LPFC_SLI_REV4 && - vport->fc_flag & FC_RSCN_MODE && + vport->fc_flag & (FC_RSCN_MODE | FC_RSCN_MEMENTO) && vport->nvmei_support) ndlp->nlp_fc4_type |= NLP_FC4_NVME; local_nlp_type = ndlp->nlp_fc4_type; @@ -7988,6 +7990,7 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, if ((rscn_cnt < FC_MAX_HOLD_RSCN) && !(vport->fc_flag & FC_RSCN_DISCOVERY)) { vport->fc_flag |= FC_RSCN_MODE; + vport->fc_flag &= ~FC_RSCN_MEMENTO; spin_unlock_irq(shost->host_lock); if (rscn_cnt) { cmd = vport->fc_rscn_id_list[rscn_cnt-1]->virt; @@ -8037,6 +8040,7 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, spin_lock_irq(shost->host_lock); vport->fc_flag |= FC_RSCN_MODE; + vport->fc_flag &= ~FC_RSCN_MEMENTO; spin_unlock_irq(shost->host_lock); vport->fc_rscn_id_list[vport->fc_rscn_id_cnt++] = pcmd; /* Indicate we are done walking fc_rscn_id_list on this vport */ diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index 2b877dff5ed4..d6ff864b132b 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c @@ -1343,7 +1343,8 @@ lpfc_linkup_port(struct lpfc_vport *vport) spin_lock_irq(shost->host_lock); vport->fc_flag &= ~(FC_PT2PT | FC_PT2PT_PLOGI | FC_ABORT_DISCOVERY | - FC_RSCN_MODE | FC_NLP_MORE | FC_RSCN_DISCOVERY); + FC_RSCN_MEMENTO | FC_RSCN_MODE | + FC_NLP_MORE | FC_RSCN_DISCOVERY); vport->fc_flag |= FC_NDISC_ACTIVE; vport->fc_ns_retry = 0; spin_unlock_irq(shost->host_lock); From d51cf5bd926c7d00bd8a77fc39db73766fbf2a27 Mon Sep 17 00:00:00 2001 From: James Smart Date: Tue, 12 Apr 2022 15:20:02 -0700 Subject: [PATCH 025/177] scsi: lpfc: Fix field overload in lpfc_iocbq data structure The lpfc_iocbq data structure has void * pointers that are overloaded to be as many as 8 different data types and the driver translates the void * by casting. This patch removes the void * pointers by declaring the specific types needed by the driver. It also expands the context_un to include more seldom used pointer types to save structure bytes. It also groups the u8 types together to pack the 8 bytes needed. This work allows the lpfc_iocbq data structure to be more strongly typed and keeps it from being allocated from the 512 byte slab. [mkp: rolled in zeroday fix] Link: https://lore.kernel.org/r/20220412222008.126521-21-jsmart2021@gmail.com Reported-by: kernel test robot Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_bsg.c | 79 +++-- drivers/scsi/lpfc/lpfc_ct.c | 148 +++++----- drivers/scsi/lpfc/lpfc_els.c | 443 ++++++++++++++--------------- drivers/scsi/lpfc/lpfc_hbadisc.c | 8 +- drivers/scsi/lpfc/lpfc_init.c | 12 +- drivers/scsi/lpfc/lpfc_nportdisc.c | 32 +-- drivers/scsi/lpfc/lpfc_nvme.c | 31 +- drivers/scsi/lpfc/lpfc_nvmet.c | 73 ++--- drivers/scsi/lpfc/lpfc_scsi.c | 17 +- drivers/scsi/lpfc/lpfc_sli.c | 120 ++++---- drivers/scsi/lpfc/lpfc_sli.h | 28 +- 11 files changed, 490 insertions(+), 501 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_bsg.c b/drivers/scsi/lpfc/lpfc_bsg.c index 8b586fa90f70..ae46383b13bf 100644 --- a/drivers/scsi/lpfc/lpfc_bsg.c +++ b/drivers/scsi/lpfc/lpfc_bsg.c @@ -310,7 +310,7 @@ lpfc_bsg_send_mgmt_cmd_cmp(struct lpfc_hba *phba, int rc = 0; u32 ulp_status, ulp_word4, total_data_placed; - dd_data = cmdiocbq->context1; + dd_data = cmdiocbq->context_un.dd_data; /* Determine if job has been aborted */ spin_lock_irqsave(&phba->ct_ev_lock, flags); @@ -328,10 +328,10 @@ lpfc_bsg_send_mgmt_cmd_cmp(struct lpfc_hba *phba, spin_unlock_irqrestore(&phba->hbalock, flags); iocb = &dd_data->context_un.iocb; - ndlp = iocb->cmdiocbq->context_un.ndlp; + ndlp = iocb->cmdiocbq->ndlp; rmp = iocb->rmp; - cmp = cmdiocbq->context2; - bmp = cmdiocbq->context3; + cmp = cmdiocbq->cmd_dmabuf; + bmp = cmdiocbq->bpl_dmabuf; ulp_status = get_job_ulpstatus(phba, rspiocbq); ulp_word4 = get_job_word4(phba, rspiocbq); total_data_placed = get_job_data_placed(phba, rspiocbq); @@ -470,14 +470,12 @@ lpfc_bsg_send_mgmt_cmd(struct bsg_job *job) cmdiocbq->num_bdes = num_entry; cmdiocbq->vport = phba->pport; - cmdiocbq->context2 = cmp; - cmdiocbq->context3 = bmp; + cmdiocbq->cmd_dmabuf = cmp; + cmdiocbq->bpl_dmabuf = bmp; cmdiocbq->cmd_flag |= LPFC_IO_LIBDFC; cmdiocbq->cmd_cmpl = lpfc_bsg_send_mgmt_cmd_cmp; - cmdiocbq->context1 = dd_data; - cmdiocbq->context2 = cmp; - cmdiocbq->context3 = bmp; + cmdiocbq->context_un.dd_data = dd_data; dd_data->type = TYPE_IOCB; dd_data->set_job = job; @@ -495,8 +493,8 @@ lpfc_bsg_send_mgmt_cmd(struct bsg_job *job) readl(phba->HCregaddr); /* flush */ } - cmdiocbq->context_un.ndlp = lpfc_nlp_get(ndlp); - if (!cmdiocbq->context_un.ndlp) { + cmdiocbq->ndlp = lpfc_nlp_get(ndlp); + if (!cmdiocbq->ndlp) { rc = -ENODEV; goto free_rmp; } @@ -573,9 +571,9 @@ lpfc_bsg_rport_els_cmp(struct lpfc_hba *phba, int rc = 0; u32 ulp_status, ulp_word4, total_data_placed; - dd_data = cmdiocbq->context1; + dd_data = cmdiocbq->context_un.dd_data; ndlp = dd_data->context_un.iocb.ndlp; - cmdiocbq->context1 = ndlp; + cmdiocbq->ndlp = ndlp; /* Determine if job has been aborted */ spin_lock_irqsave(&phba->ct_ev_lock, flags); @@ -595,7 +593,7 @@ lpfc_bsg_rport_els_cmp(struct lpfc_hba *phba, ulp_status = get_job_ulpstatus(phba, rspiocbq); ulp_word4 = get_job_word4(phba, rspiocbq); total_data_placed = get_job_data_placed(phba, rspiocbq); - pcmd = (struct lpfc_dmabuf *)cmdiocbq->context2; + pcmd = cmdiocbq->cmd_dmabuf; prsp = (struct lpfc_dmabuf *)pcmd->list.next; /* Copy the completed job data or determine the job status if job is @@ -711,8 +709,8 @@ lpfc_bsg_rport_els(struct bsg_job *job) /* Transfer the request payload to allocated command dma buffer */ sg_copy_to_buffer(job->request_payload.sg_list, job->request_payload.sg_cnt, - ((struct lpfc_dmabuf *)cmdiocbq->context2)->virt, - job->request_payload.payload_len); + cmdiocbq->cmd_dmabuf->virt, + cmdsize); rpi = ndlp->nlp_rpi; @@ -722,8 +720,8 @@ lpfc_bsg_rport_els(struct bsg_job *job) else cmdiocbq->iocb.ulpContext = rpi; cmdiocbq->cmd_flag |= LPFC_IO_LIBDFC; - cmdiocbq->context1 = dd_data; - cmdiocbq->context_un.ndlp = ndlp; + cmdiocbq->context_un.dd_data = dd_data; + cmdiocbq->ndlp = ndlp; cmdiocbq->cmd_cmpl = lpfc_bsg_rport_els_cmp; dd_data->type = TYPE_IOCB; dd_data->set_job = job; @@ -742,8 +740,8 @@ lpfc_bsg_rport_els(struct bsg_job *job) readl(phba->HCregaddr); /* flush */ } - cmdiocbq->context1 = lpfc_nlp_get(ndlp); - if (!cmdiocbq->context1) { + cmdiocbq->ndlp = lpfc_nlp_get(ndlp); + if (!cmdiocbq->ndlp) { rc = -EIO; goto linkdown_err; } @@ -917,8 +915,8 @@ lpfc_bsg_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, struct ulp_bde64 *bde; dma_addr_t dma_addr; int i; - struct lpfc_dmabuf *bdeBuf1 = piocbq->context2; - struct lpfc_dmabuf *bdeBuf2 = piocbq->context3; + struct lpfc_dmabuf *bdeBuf1 = piocbq->cmd_dmabuf; + struct lpfc_dmabuf *bdeBuf2 = piocbq->bpl_dmabuf; struct lpfc_sli_ct_request *ct_req; struct bsg_job *job = NULL; struct fc_bsg_reply *bsg_reply; @@ -985,9 +983,8 @@ lpfc_bsg_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, list_for_each_entry(iocbq, &head, list) { size = 0; if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) { - bdeBuf1 = iocbq->context2; - bdeBuf2 = iocbq->context3; - + bdeBuf1 = iocbq->cmd_dmabuf; + bdeBuf2 = iocbq->bpl_dmabuf; } if (phba->sli_rev == LPFC_SLI_REV4) bde_count = iocbq->wcqe_cmpl.word3; @@ -1384,7 +1381,7 @@ lpfc_issue_ct_rsp_cmp(struct lpfc_hba *phba, int rc = 0; u32 ulp_status, ulp_word4; - dd_data = cmdiocbq->context1; + dd_data = cmdiocbq->context_un.dd_data; /* Determine if job has been aborted */ spin_lock_irqsave(&phba->ct_ev_lock, flags); @@ -1401,8 +1398,8 @@ lpfc_issue_ct_rsp_cmp(struct lpfc_hba *phba, spin_unlock_irqrestore(&phba->hbalock, flags); ndlp = dd_data->context_un.iocb.ndlp; - cmp = cmdiocbq->context2; - bmp = cmdiocbq->context3; + cmp = cmdiocbq->cmd_dmabuf; + bmp = cmdiocbq->bpl_dmabuf; ulp_status = get_job_ulpstatus(phba, rspiocbq); ulp_word4 = get_job_word4(phba, rspiocbq); @@ -1529,10 +1526,10 @@ lpfc_issue_ct_rsp(struct lpfc_hba *phba, struct bsg_job *job, uint32_t tag, ctiocb->cmd_flag |= LPFC_IO_LIBDFC; ctiocb->vport = phba->pport; - ctiocb->context1 = dd_data; - ctiocb->context2 = cmp; - ctiocb->context3 = bmp; - ctiocb->context_un.ndlp = ndlp; + ctiocb->context_un.dd_data = dd_data; + ctiocb->cmd_dmabuf = cmp; + ctiocb->bpl_dmabuf = bmp; + ctiocb->ndlp = ndlp; ctiocb->cmd_cmpl = lpfc_issue_ct_rsp_cmp; dd_data->type = TYPE_IOCB; @@ -2671,7 +2668,7 @@ static int lpfcdiag_loop_get_xri(struct lpfc_hba *phba, uint16_t rpi, ctreq->CommandResponse.bits.CmdRsp = ELX_LOOPBACK_XRI_SETUP; ctreq->CommandResponse.bits.Size = 0; - cmdiocbq->context3 = dmabuf; + cmdiocbq->bpl_dmabuf = dmabuf; cmdiocbq->cmd_flag |= LPFC_IO_LIBDFC; cmdiocbq->vport = phba->pport; cmdiocbq->cmd_cmpl = NULL; @@ -3231,7 +3228,7 @@ lpfc_bsg_diag_loopback_run(struct bsg_job *job) cmdiocbq->cmd_flag |= LPFC_IO_LOOPBACK; cmdiocbq->vport = phba->pport; cmdiocbq->cmd_cmpl = NULL; - cmdiocbq->context3 = txbmp; + cmdiocbq->bpl_dmabuf = txbmp; if (phba->sli_rev < LPFC_SLI_REV4) { lpfc_sli_prep_xmit_seq64(phba, cmdiocbq, txbmp, 0, txxri, @@ -3384,7 +3381,7 @@ job_error: * This is completion handler function for mailbox commands issued from * lpfc_bsg_issue_mbox function. This function is called by the * mailbox event handler function with no lock held. This function - * will wake up thread waiting on the wait queue pointed by context1 + * will wake up thread waiting on the wait queue pointed by dd_data * of the mailbox. **/ static void @@ -5034,9 +5031,9 @@ lpfc_bsg_menlo_cmd_cmp(struct lpfc_hba *phba, unsigned int rsp_size; int rc = 0; - dd_data = cmdiocbq->context1; - cmp = cmdiocbq->context2; - bmp = cmdiocbq->context3; + dd_data = cmdiocbq->context_un.dd_data; + cmp = cmdiocbq->cmd_dmabuf; + bmp = cmdiocbq->bpl_dmabuf; menlo = &dd_data->context_un.menlo; rmp = menlo->rmp; rsp = &rspiocbq->iocb; @@ -5233,9 +5230,9 @@ lpfc_menlo_cmd(struct bsg_job *job) /* We want the firmware to timeout before we do */ cmd->ulpTimeout = MENLO_TIMEOUT - 5; cmdiocbq->cmd_cmpl = lpfc_bsg_menlo_cmd_cmp; - cmdiocbq->context1 = dd_data; - cmdiocbq->context2 = cmp; - cmdiocbq->context3 = bmp; + cmdiocbq->context_un.dd_data = dd_data; + cmdiocbq->cmd_dmabuf = cmp; + cmdiocbq->bpl_dmabuf = bmp; if (menlo_cmd->cmd == LPFC_BSG_VENDOR_MENLO_CMD) { cmd->ulpCommand = CMD_GEN_REQUEST64_CR; cmd->ulpPU = MENLO_PU; /* 3 */ diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c index c74833ed78c6..6cda8ee25d4f 100644 --- a/drivers/scsi/lpfc/lpfc_ct.c +++ b/drivers/scsi/lpfc/lpfc_ct.c @@ -118,22 +118,22 @@ lpfc_ct_unsol_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, struct lpfc_nodelist *ndlp; struct lpfc_dmabuf *mp, *bmp; - ndlp = (struct lpfc_nodelist *)cmdiocb->context1; + ndlp = cmdiocb->ndlp; if (ndlp) lpfc_nlp_put(ndlp); - mp = cmdiocb->context2; - bmp = cmdiocb->context3; + mp = cmdiocb->rsp_dmabuf; + bmp = cmdiocb->bpl_dmabuf; if (mp) { lpfc_mbuf_free(phba, mp->virt, mp->phys); kfree(mp); - cmdiocb->context2 = NULL; + cmdiocb->rsp_dmabuf = NULL; } if (bmp) { lpfc_mbuf_free(phba, bmp->virt, bmp->phys); kfree(bmp); - cmdiocb->context3 = NULL; + cmdiocb->bpl_dmabuf = NULL; } lpfc_sli_release_iocbq(phba, cmdiocb); @@ -232,18 +232,17 @@ lpfc_ct_reject_event(struct lpfc_nodelist *ndlp, } /* Save for completion so we can release these resources */ - cmdiocbq->context2 = (uint8_t *)mp; - cmdiocbq->context3 = (uint8_t *)bmp; + cmdiocbq->rsp_dmabuf = mp; + cmdiocbq->bpl_dmabuf = bmp; cmdiocbq->cmd_cmpl = lpfc_ct_unsol_cmpl; tmo = (3 * phba->fc_ratov); cmdiocbq->retry = 0; cmdiocbq->vport = vport; - cmdiocbq->context_un.ndlp = NULL; cmdiocbq->drvrTimeout = tmo + LPFC_DRVR_TIMEOUT; - cmdiocbq->context1 = lpfc_nlp_get(ndlp); - if (!cmdiocbq->context1) + cmdiocbq->ndlp = lpfc_nlp_get(ndlp); + if (!cmdiocbq->ndlp) goto ct_no_ndlp; rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, cmdiocbq, 0); @@ -310,8 +309,8 @@ lpfc_ct_handle_mibreq(struct lpfc_hba *phba, struct lpfc_iocbq *ctiocbq) return; } - ct_req = ((struct lpfc_sli_ct_request *) - (((struct lpfc_dmabuf *)ctiocbq->context2)->virt)); + ct_req = (struct lpfc_sli_ct_request *)ctiocbq->cmd_dmabuf->virt; + mi_cmd = ct_req->CommandResponse.bits.CmdRsp; lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, "6442 : MI Cmd : x%x Not Supported\n", mi_cmd); @@ -347,14 +346,14 @@ lpfc_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, uint32_t size; struct list_head head; struct lpfc_sli_ct_request *ct_req; - struct lpfc_dmabuf *bdeBuf1 = ctiocbq->context2; - struct lpfc_dmabuf *bdeBuf2 = ctiocbq->context3; + struct lpfc_dmabuf *bdeBuf1 = ctiocbq->cmd_dmabuf; + struct lpfc_dmabuf *bdeBuf2 = ctiocbq->bpl_dmabuf; u32 status, parameter, bde_count = 0; struct lpfc_wcqe_complete *wcqe_cmpl = NULL; - ctiocbq->context1 = NULL; - ctiocbq->context2 = NULL; - ctiocbq->context3 = NULL; + ctiocbq->cmd_dmabuf = NULL; + ctiocbq->rsp_dmabuf = NULL; + ctiocbq->bpl_dmabuf = NULL; wcqe_cmpl = &ctiocbq->wcqe_cmpl; status = get_job_ulpstatus(phba, ctiocbq); @@ -382,12 +381,11 @@ lpfc_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, if (bde_count == 0) return; - ctiocbq->context2 = bdeBuf1; + ctiocbq->cmd_dmabuf = bdeBuf1; if (bde_count == 2) - ctiocbq->context3 = bdeBuf2; + ctiocbq->bpl_dmabuf = bdeBuf2; - ct_req = ((struct lpfc_sli_ct_request *) - (((struct lpfc_dmabuf *)ctiocbq->context2)->virt)); + ct_req = (struct lpfc_sli_ct_request *)ctiocbq->cmd_dmabuf->virt; if (ct_req->FsType == SLI_CT_MANAGEMENT_SERVICE && ct_req->FsSubType == SLI_CT_MIB_Subtypes) { @@ -408,8 +406,8 @@ lpfc_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, if (!bde_count) continue; - bdeBuf1 = iocb->context2; - iocb->context2 = NULL; + bdeBuf1 = iocb->cmd_dmabuf; + iocb->cmd_dmabuf = NULL; if (phba->sli_rev == LPFC_SLI_REV4) size = iocb->wqe.gen_req.bde.tus.f.bdeSize; else @@ -417,8 +415,8 @@ lpfc_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, lpfc_ct_unsol_buffer(phba, ctiocbq, bdeBuf1, size); lpfc_in_buf_free(phba, bdeBuf1); if (bde_count == 2) { - bdeBuf2 = iocb->context3; - iocb->context3 = NULL; + bdeBuf2 = iocb->bpl_dmabuf; + iocb->bpl_dmabuf = NULL; if (phba->sli_rev == LPFC_SLI_REV4) size = iocb->unsol_rcv_len; else @@ -549,24 +547,25 @@ lpfc_ct_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *ctiocb) { struct lpfc_dmabuf *buf_ptr; - /* I/O job is complete so context is now invalid*/ - ctiocb->context_un.ndlp = NULL; - if (ctiocb->context1) { - buf_ptr = (struct lpfc_dmabuf *) ctiocb->context1; + /* IOCBQ job structure gets cleaned during release. Just release + * the dma buffers here. + */ + if (ctiocb->cmd_dmabuf) { + buf_ptr = ctiocb->cmd_dmabuf; lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); kfree(buf_ptr); - ctiocb->context1 = NULL; + ctiocb->cmd_dmabuf = NULL; } - if (ctiocb->context2) { - lpfc_free_ct_rsp(phba, (struct lpfc_dmabuf *) ctiocb->context2); - ctiocb->context2 = NULL; + if (ctiocb->rsp_dmabuf) { + lpfc_free_ct_rsp(phba, ctiocb->rsp_dmabuf); + ctiocb->rsp_dmabuf = NULL; } - if (ctiocb->context3) { - buf_ptr = (struct lpfc_dmabuf *) ctiocb->context3; + if (ctiocb->bpl_dmabuf) { + buf_ptr = ctiocb->bpl_dmabuf; lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); kfree(buf_ptr); - ctiocb->context3 = NULL; + ctiocb->bpl_dmabuf = NULL; } lpfc_sli_release_iocbq(phba, ctiocb); return 0; @@ -605,11 +604,11 @@ lpfc_gen_req(struct lpfc_vport *vport, struct lpfc_dmabuf *bmp, /* Update the num_entry bde count */ geniocb->num_bdes = num_entry; - geniocb->context3 = (uint8_t *) bmp; + geniocb->bpl_dmabuf = bmp; /* Save for completion so we can release these resources */ - geniocb->context1 = (uint8_t *) inp; - geniocb->context2 = (uint8_t *) outp; + geniocb->cmd_dmabuf = inp; + geniocb->rsp_dmabuf = outp; geniocb->event_tag = event_tag; @@ -635,8 +634,8 @@ lpfc_gen_req(struct lpfc_vport *vport, struct lpfc_dmabuf *bmp, geniocb->drvrTimeout = tmo + LPFC_DRVR_TIMEOUT; geniocb->vport = vport; geniocb->retry = retry; - geniocb->context_un.ndlp = lpfc_nlp_get(ndlp); - if (!geniocb->context_un.ndlp) + geniocb->ndlp = lpfc_nlp_get(ndlp); + if (!geniocb->ndlp) goto out; rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, geniocb, 0); @@ -926,13 +925,12 @@ lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, int rc, type; /* First save ndlp, before we overwrite it */ - ndlp = cmdiocb->context_un.ndlp; + ndlp = cmdiocb->ndlp; /* we pass cmdiocb to state machine which needs rspiocb as well */ - cmdiocb->context_un.rsp_iocb = rspiocb; - - inp = (struct lpfc_dmabuf *) cmdiocb->context1; - outp = (struct lpfc_dmabuf *) cmdiocb->context2; + cmdiocb->rsp_iocb = rspiocb; + inp = cmdiocb->cmd_dmabuf; + outp = cmdiocb->rsp_dmabuf; lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, "GID_FT cmpl: status:x%x/x%x rtry:%d", @@ -1143,12 +1141,12 @@ lpfc_cmpl_ct_cmd_gid_pt(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, int rc; /* First save ndlp, before we overwrite it */ - ndlp = cmdiocb->context_un.ndlp; + ndlp = cmdiocb->ndlp; /* we pass cmdiocb to state machine which needs rspiocb as well */ - cmdiocb->context_un.rsp_iocb = rspiocb; - inp = (struct lpfc_dmabuf *)cmdiocb->context1; - outp = (struct lpfc_dmabuf *)cmdiocb->context2; + cmdiocb->rsp_iocb = rspiocb; + inp = cmdiocb->cmd_dmabuf; + outp = cmdiocb->rsp_dmabuf; lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, "GID_PT cmpl: status:x%x/x%x rtry:%d", @@ -1346,8 +1344,8 @@ lpfc_cmpl_ct_cmd_gff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, { struct lpfc_vport *vport = cmdiocb->vport; struct Scsi_Host *shost = lpfc_shost_from_vport(vport); - struct lpfc_dmabuf *inp = (struct lpfc_dmabuf *) cmdiocb->context1; - struct lpfc_dmabuf *outp = (struct lpfc_dmabuf *) cmdiocb->context2; + struct lpfc_dmabuf *inp = cmdiocb->cmd_dmabuf; + struct lpfc_dmabuf *outp = cmdiocb->rsp_dmabuf; struct lpfc_sli_ct_request *CTrsp; int did, rc, retry; uint8_t fbits; @@ -1426,7 +1424,7 @@ lpfc_cmpl_ct_cmd_gff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, cmdiocb->retry, did); if (rc == 0) { /* success */ - free_ndlp = cmdiocb->context_un.ndlp; + free_ndlp = cmdiocb->ndlp; lpfc_ct_free_iocb(phba, cmdiocb); lpfc_nlp_put(free_ndlp); return; @@ -1483,7 +1481,7 @@ out: } iocb_free: - free_ndlp = cmdiocb->context_un.ndlp; + free_ndlp = cmdiocb->ndlp; lpfc_ct_free_iocb(phba, cmdiocb); lpfc_nlp_put(free_ndlp); return; @@ -1494,8 +1492,8 @@ lpfc_cmpl_ct_cmd_gft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, struct lpfc_iocbq *rspiocb) { struct lpfc_vport *vport = cmdiocb->vport; - struct lpfc_dmabuf *inp = (struct lpfc_dmabuf *)cmdiocb->context1; - struct lpfc_dmabuf *outp = (struct lpfc_dmabuf *)cmdiocb->context2; + struct lpfc_dmabuf *inp = cmdiocb->cmd_dmabuf; + struct lpfc_dmabuf *outp = cmdiocb->rsp_dmabuf; struct lpfc_sli_ct_request *CTrsp; int did; struct lpfc_nodelist *ndlp = NULL; @@ -1519,7 +1517,7 @@ lpfc_cmpl_ct_cmd_gft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, } /* Preserve the nameserver node to release the reference. */ - ns_ndlp = cmdiocb->context_un.ndlp; + ns_ndlp = cmdiocb->ndlp; if (ulp_status == IOSTAT_SUCCESS) { /* Good status, continue checking */ @@ -1605,13 +1603,13 @@ lpfc_cmpl_ct(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, u32 ulp_word4 = get_job_word4(phba, rspiocb); /* First save ndlp, before we overwrite it */ - ndlp = cmdiocb->context_un.ndlp; + ndlp = cmdiocb->ndlp; /* we pass cmdiocb to state machine which needs rspiocb as well */ - cmdiocb->context_un.rsp_iocb = rspiocb; + cmdiocb->rsp_iocb = rspiocb; - inp = (struct lpfc_dmabuf *) cmdiocb->context1; - outp = (struct lpfc_dmabuf *) cmdiocb->context2; + inp = cmdiocb->cmd_dmabuf; + outp = cmdiocb->rsp_dmabuf; cmdcode = be16_to_cpu(((struct lpfc_sli_ct_request *) inp->virt)-> CommandResponse.bits.CmdRsp); @@ -1672,8 +1670,8 @@ lpfc_cmpl_ct_cmd_rft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, struct lpfc_dmabuf *outp; struct lpfc_sli_ct_request *CTrsp; - outp = (struct lpfc_dmabuf *) cmdiocb->context2; - CTrsp = (struct lpfc_sli_ct_request *) outp->virt; + outp = cmdiocb->rsp_dmabuf; + CTrsp = (struct lpfc_sli_ct_request *)outp->virt; if (CTrsp->CommandResponse.bits.CmdRsp == be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) vport->ct_flags |= FC_CT_RFT_ID; @@ -1693,7 +1691,7 @@ lpfc_cmpl_ct_cmd_rnn_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, struct lpfc_dmabuf *outp; struct lpfc_sli_ct_request *CTrsp; - outp = (struct lpfc_dmabuf *) cmdiocb->context2; + outp = cmdiocb->rsp_dmabuf; CTrsp = (struct lpfc_sli_ct_request *) outp->virt; if (CTrsp->CommandResponse.bits.CmdRsp == be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) @@ -1714,8 +1712,8 @@ lpfc_cmpl_ct_cmd_rspn_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, struct lpfc_dmabuf *outp; struct lpfc_sli_ct_request *CTrsp; - outp = (struct lpfc_dmabuf *) cmdiocb->context2; - CTrsp = (struct lpfc_sli_ct_request *) outp->virt; + outp = cmdiocb->rsp_dmabuf; + CTrsp = (struct lpfc_sli_ct_request *)outp->virt; if (CTrsp->CommandResponse.bits.CmdRsp == be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) vport->ct_flags |= FC_CT_RSPN_ID; @@ -1735,7 +1733,7 @@ lpfc_cmpl_ct_cmd_rsnn_nn(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, struct lpfc_dmabuf *outp; struct lpfc_sli_ct_request *CTrsp; - outp = (struct lpfc_dmabuf *) cmdiocb->context2; + outp = cmdiocb->rsp_dmabuf; CTrsp = (struct lpfc_sli_ct_request *) outp->virt; if (CTrsp->CommandResponse.bits.CmdRsp == be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) @@ -1768,8 +1766,8 @@ lpfc_cmpl_ct_cmd_rff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, struct lpfc_dmabuf *outp; struct lpfc_sli_ct_request *CTrsp; - outp = (struct lpfc_dmabuf *) cmdiocb->context2; - CTrsp = (struct lpfc_sli_ct_request *) outp->virt; + outp = cmdiocb->rsp_dmabuf; + CTrsp = (struct lpfc_sli_ct_request *)outp->virt; if (CTrsp->CommandResponse.bits.CmdRsp == be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) vport->ct_flags |= FC_CT_RFF_ID; @@ -1865,7 +1863,7 @@ lpfc_get_gidft_type(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb) struct lpfc_dmabuf *mp; uint32_t type; - mp = cmdiocb->context1; + mp = cmdiocb->cmd_dmabuf; if (mp == NULL) return 0; CtReq = (struct lpfc_sli_ct_request *)mp->virt; @@ -2171,8 +2169,8 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, struct lpfc_iocbq *rspiocb) { struct lpfc_vport *vport = cmdiocb->vport; - struct lpfc_dmabuf *inp = cmdiocb->context1; - struct lpfc_dmabuf *outp = cmdiocb->context2; + struct lpfc_dmabuf *inp = cmdiocb->cmd_dmabuf; + struct lpfc_dmabuf *outp = cmdiocb->rsp_dmabuf; struct lpfc_sli_ct_request *CTcmd = inp->virt; struct lpfc_sli_ct_request *CTrsp = outp->virt; uint16_t fdmi_cmd = CTcmd->CommandResponse.bits.CmdRsp; @@ -2226,7 +2224,7 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, ulp_word4); } - free_ndlp = cmdiocb->context_un.ndlp; + free_ndlp = cmdiocb->ndlp; lpfc_ct_free_iocb(phba, cmdiocb); lpfc_nlp_put(free_ndlp); @@ -3812,8 +3810,8 @@ lpfc_cmpl_ct_cmd_vmid(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, struct lpfc_iocbq *rspiocb) { struct lpfc_vport *vport = cmdiocb->vport; - struct lpfc_dmabuf *inp = cmdiocb->context1; - struct lpfc_dmabuf *outp = cmdiocb->context2; + struct lpfc_dmabuf *inp = cmdiocb->cmd_dmabuf; + struct lpfc_dmabuf *outp = cmdiocb->rsp_dmabuf; struct lpfc_sli_ct_request *ctcmd = inp->virt; struct lpfc_sli_ct_request *ctrsp = outp->virt; u16 rsp = ctrsp->CommandResponse.bits.CmdRsp; diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index e734ae972d1e..b84fa46a6889 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -152,7 +152,7 @@ lpfc_els_chk_latt(struct lpfc_vport *vport) * Buffer Descriptor Entries (BDEs), allocates buffers for both command * payload and response payload (if expected). The reference count on the * ndlp is incremented by 1 and the reference to the ndlp is put into - * context1 of the IOCB data structure for this IOCB to hold the ndlp + * ndlp of the IOCB data structure for this IOCB to hold the ndlp * reference for the command's callback function to access later. * * Return code @@ -279,8 +279,8 @@ lpfc_prep_els_iocb(struct lpfc_vport *vport, u8 expect_rsp, bpl->type_size |= cpu_to_le32(ULP_BDE64_TYPE_BDE_64); } - elsiocb->context2 = pcmd; - elsiocb->context3 = pbuflist; + elsiocb->cmd_dmabuf = pcmd; + elsiocb->bpl_dmabuf = pbuflist; elsiocb->retry = retry; elsiocb->vport = vport; elsiocb->drvrTimeout = (phba->fc_ratov << 1) + LPFC_DRVR_TIMEOUT; @@ -959,9 +959,9 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, { struct lpfc_vport *vport = cmdiocb->vport; struct Scsi_Host *shost = lpfc_shost_from_vport(vport); - struct lpfc_nodelist *ndlp = cmdiocb->context1; + struct lpfc_nodelist *ndlp = cmdiocb->ndlp; IOCB_t *irsp; - struct lpfc_dmabuf *pcmd = cmdiocb->context2, *prsp; + struct lpfc_dmabuf *pcmd = cmdiocb->cmd_dmabuf, *prsp; struct serv_parm *sp; uint16_t fcf_index; int rc; @@ -1232,7 +1232,7 @@ lpfc_cmpl_els_link_down(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, uint32_t cmd; u32 ulp_status, ulp_word4; - pcmd = (uint32_t *)(((struct lpfc_dmabuf *)cmdiocb->context2)->virt); + pcmd = (uint32_t *)cmdiocb->cmd_dmabuf->virt; cmd = *pcmd; ulp_status = get_job_ulpstatus(phba, rspiocb); @@ -1265,7 +1265,7 @@ lpfc_cmpl_els_link_down(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, * out FLOGI ELS command with one outstanding fabric IOCB at a time. * * Note that the ndlp reference count will be incremented by 1 for holding the - * ndlp and the reference to ndlp will be stored into the context1 field of + * ndlp and the reference to ndlp will be stored into the ndlp field of * the IOCB for the completion callback function to the FLOGI ELS command. * * Return code @@ -1295,7 +1295,7 @@ lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, return 1; wqe = &elsiocb->wqe; - pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); + pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt; icmd = &elsiocb->iocb; /* For FLOGI request, remainder of payload is service parameters */ @@ -1372,8 +1372,8 @@ lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, "Issue FLOGI: opt:x%x", phba->sli3_options, 0, 0); - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) { + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) { lpfc_els_free_iocb(phba, elsiocb); return 1; } @@ -1474,7 +1474,7 @@ lpfc_els_abort_flogi(struct lpfc_hba *phba) list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) { ulp_command = get_job_cmnd(phba, iocb); if (ulp_command == CMD_ELS_REQUEST64_CR) { - ndlp = (struct lpfc_nodelist *)(iocb->context1); + ndlp = iocb->ndlp; if (ndlp && ndlp->nlp_DID == Fabric_DID) { if ((phba->pport->fc_flag & FC_PT2PT) && !(phba->pport->fc_flag & FC_PT2PT_PLOGI)) @@ -1919,14 +1919,14 @@ lpfc_cmpl_els_rrq(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, struct lpfc_iocbq *rspiocb) { struct lpfc_vport *vport = cmdiocb->vport; - struct lpfc_nodelist *ndlp = cmdiocb->context1; + struct lpfc_nodelist *ndlp = cmdiocb->ndlp; struct lpfc_node_rrq *rrq; u32 ulp_status = get_job_ulpstatus(phba, rspiocb); u32 ulp_word4 = get_job_word4(phba, rspiocb); /* we pass cmdiocb to state machine which needs rspiocb as well */ rrq = cmdiocb->context_un.rrq; - cmdiocb->context_un.rsp_iocb = rspiocb; + cmdiocb->rsp_iocb = rspiocb; lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, "RRQ cmpl: status:x%x/x%x did:x%x", @@ -1995,7 +1995,7 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, bool release_node = false; /* we pass cmdiocb to state machine which needs rspiocb as well */ - cmdiocb->context_un.rsp_iocb = rspiocb; + cmdiocb->rsp_iocb = rspiocb; ulp_status = get_job_ulpstatus(phba, rspiocb); ulp_word4 = get_job_word4(phba, rspiocb); @@ -2098,8 +2098,7 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, NLP_EVT_DEVICE_RM); } else { /* Good status, call state machine */ - prsp = list_entry(((struct lpfc_dmabuf *) - cmdiocb->context2)->list.next, + prsp = list_entry(cmdiocb->cmd_dmabuf->list.next, struct lpfc_dmabuf, list); ndlp = lpfc_plogi_confirm_nport(phba, prsp->virt, ndlp); @@ -2144,7 +2143,7 @@ out: out_freeiocb: /* Release the reference on the original I/O request. */ - free_ndlp = (struct lpfc_nodelist *)cmdiocb->context1; + free_ndlp = cmdiocb->ndlp; lpfc_els_free_iocb(phba, cmdiocb); lpfc_nlp_put(free_ndlp); @@ -2164,7 +2163,7 @@ out_freeiocb: * the lpfc_sli_issue_iocb() routine to send out PLOGI ELS command. * * Note that the ndlp reference count will be incremented by 1 for holding - * the ndlp and the reference to ndlp will be stored into the context1 field + * the ndlp and the reference to ndlp will be stored into the ndlp field * of the IOCB for the completion callback function to the PLOGI ELS command. * * Return code @@ -2215,7 +2214,7 @@ lpfc_issue_els_plogi(struct lpfc_vport *vport, uint32_t did, uint8_t retry) ndlp->nlp_flag &= ~NLP_FCP_PRLI_RJT; spin_unlock_irq(&ndlp->lock); - pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); + pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt; /* For PLOGI request, remainder of payload is service parameters */ *((uint32_t *) (pcmd)) = ELS_CMD_PLOGI; @@ -2267,8 +2266,8 @@ lpfc_issue_els_plogi(struct lpfc_vport *vport, uint32_t did, uint8_t retry) lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, "Issue PLOGI: did:x%x refcnt %d", did, kref_read(&ndlp->kref), 0); - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) { + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) { lpfc_els_free_iocb(phba, elsiocb); return 1; } @@ -2309,9 +2308,9 @@ lpfc_cmpl_els_prli(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, bool release_node = false; /* we pass cmdiocb to state machine which needs rspiocb as well */ - cmdiocb->context_un.rsp_iocb = rspiocb; + cmdiocb->rsp_iocb = rspiocb; - ndlp = (struct lpfc_nodelist *) cmdiocb->context1; + ndlp = cmdiocb->ndlp; ulp_status = get_job_ulpstatus(phba, rspiocb); ulp_word4 = get_job_word4(phba, rspiocb); @@ -2424,7 +2423,7 @@ out: * routine lpfc_sli_issue_iocb() to send out PRLI command. * * Note that the ndlp reference count will be incremented by 1 for holding the - * ndlp and the reference to ndlp will be stored into the context1 field of + * ndlp and the reference to ndlp will be stored into the ndlp field of * the IOCB for the completion callback function to the PRLI ELS command. * * Return code @@ -2499,7 +2498,7 @@ lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, if (!elsiocb) return 1; - pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); + pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt; /* For PRLI request, remainder of payload is service parameters */ memset(pcmd, 0, cmdsize); @@ -2577,8 +2576,8 @@ lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, "Issue PRLI: did:x%x refcnt %d", ndlp->nlp_DID, kref_read(&ndlp->kref), 0); - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) { + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) { lpfc_els_free_iocb(phba, elsiocb); return 1; } @@ -2763,9 +2762,9 @@ lpfc_cmpl_els_adisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, bool release_node = false; /* we pass cmdiocb to state machine which needs rspiocb as well */ - cmdiocb->context_un.rsp_iocb = rspiocb; + cmdiocb->rsp_iocb = rspiocb; - ndlp = (struct lpfc_nodelist *) cmdiocb->context1; + ndlp = cmdiocb->ndlp; ulp_status = get_job_ulpstatus(phba, rspiocb); ulp_word4 = get_job_word4(phba, rspiocb); @@ -2864,7 +2863,7 @@ out: * to issue the ADISC ELS command. * * Note that the ndlp reference count will be incremented by 1 for holding the - * ndlp and the reference to ndlp will be stored into the context1 field of + * ndlp and the reference to ndlp will be stored into the ndlp field of * the IOCB for the completion callback function to the ADISC ELS command. * * Return code @@ -2888,7 +2887,7 @@ lpfc_issue_els_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, if (!elsiocb) return 1; - pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); + pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt; /* For ADISC request, remainder of payload is service parameters */ *((uint32_t *) (pcmd)) = ELS_CMD_ADISC; @@ -2906,8 +2905,8 @@ lpfc_issue_els_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, spin_lock_irq(&ndlp->lock); ndlp->nlp_flag |= NLP_ADISC_SND; spin_unlock_irq(&ndlp->lock); - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) { + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) { lpfc_els_free_iocb(phba, elsiocb); goto err; } @@ -2947,7 +2946,7 @@ static void lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, struct lpfc_iocbq *rspiocb) { - struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1; + struct lpfc_nodelist *ndlp = cmdiocb->ndlp; struct lpfc_vport *vport = ndlp->vport; IOCB_t *irsp; unsigned long flags; @@ -2958,7 +2957,7 @@ lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, u32 tmo; /* we pass cmdiocb to state machine which needs rspiocb as well */ - cmdiocb->context_un.rsp_iocb = rspiocb; + cmdiocb->rsp_iocb = rspiocb; ulp_status = get_job_ulpstatus(phba, rspiocb); ulp_word4 = get_job_word4(phba, rspiocb); @@ -3100,7 +3099,7 @@ out: * lpfc_sli_issue_iocb() routine to send out the LOGO ELS command. * * Note that the ndlp reference count will be incremented by 1 for holding the - * ndlp and the reference to ndlp will be stored into the context1 field of + * ndlp and the reference to ndlp will be stored into the ndlp field of * the IOCB for the completion callback function to the LOGO ELS command. * * Callers of this routine are expected to unregister the RPI first @@ -3132,7 +3131,7 @@ lpfc_issue_els_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, if (!elsiocb) return 1; - pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); + pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt; *((uint32_t *) (pcmd)) = ELS_CMD_LOGO; pcmd += sizeof(uint32_t); @@ -3147,8 +3146,8 @@ lpfc_issue_els_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, ndlp->nlp_flag |= NLP_LOGO_SND; ndlp->nlp_flag &= ~NLP_ISSUE_LOGO; spin_unlock_irq(&ndlp->lock); - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) { + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) { lpfc_els_free_iocb(phba, elsiocb); goto err; } @@ -3226,7 +3225,7 @@ lpfc_cmpl_els_cmd(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, /* Check to see if link went down during discovery */ lpfc_els_chk_latt(vport); - free_ndlp = (struct lpfc_nodelist *)cmdiocb->context1; + free_ndlp = cmdiocb->ndlp; lpfc_els_free_iocb(phba, cmdiocb); lpfc_nlp_put(free_ndlp); @@ -3342,7 +3341,7 @@ lpfc_cmpl_els_disc_cmd(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, struct lpfc_dmabuf *pcmd, *prsp; u32 *pdata; u32 cmd; - struct lpfc_nodelist *ndlp = cmdiocb->context1; + struct lpfc_nodelist *ndlp = cmdiocb->ndlp; u32 ulp_status, ulp_word4, tmo, did, iotag; ulp_status = get_job_ulpstatus(phba, rspiocb); @@ -3367,7 +3366,7 @@ lpfc_cmpl_els_disc_cmd(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, "0217 ELS cmd tag x%x completes Data: x%x x%x x%x x%x\n", iotag, ulp_status, ulp_word4, tmo, cmdiocb->retry); - pcmd = (struct lpfc_dmabuf *)cmdiocb->context2; + pcmd = cmdiocb->cmd_dmabuf; if (!pcmd) goto out; @@ -3457,7 +3456,7 @@ out: * routine is invoked to send the SCR IOCB. * * Note that the ndlp reference count will be incremented by 1 for holding the - * ndlp and the reference to ndlp will be stored into the context1 field of + * ndlp and the reference to ndlp will be stored into the ndlp field of * the IOCB for the completion callback function to the SCR ELS command. * * Return code @@ -3499,7 +3498,7 @@ lpfc_issue_els_scr(struct lpfc_vport *vport, uint8_t retry) return 1; } } - pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); + pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt; *((uint32_t *) (pcmd)) = ELS_CMD_SCR; pcmd += sizeof(uint32_t); @@ -3514,8 +3513,8 @@ lpfc_issue_els_scr(struct lpfc_vport *vport, uint8_t retry) phba->fc_stat.elsXmitSCR++; elsiocb->cmd_cmpl = lpfc_cmpl_els_disc_cmd; - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) { + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) { lpfc_els_free_iocb(phba, elsiocb); return 1; } @@ -3546,7 +3545,7 @@ lpfc_issue_els_scr(struct lpfc_vport *vport, uint8_t retry) * replay the RSCN to registered recipients. * * Note that the ndlp reference count will be incremented by 1 for holding the - * ndlp and the reference to ndlp will be stored into the context1 field of + * ndlp and the reference to ndlp will be stored into the ndlp field of * the IOCB for the completion callback function to the RSCN ELS command. * * Return code @@ -3596,7 +3595,7 @@ lpfc_issue_els_rscn(struct lpfc_vport *vport, uint8_t retry) if (!elsiocb) return 1; - event = ((struct lpfc_dmabuf *)elsiocb->context2)->virt; + event = elsiocb->cmd_dmabuf->virt; event->rscn.rscn_cmd = ELS_RSCN; event->rscn.rscn_page_len = sizeof(struct fc_els_rscn_page); @@ -3611,8 +3610,8 @@ lpfc_issue_els_rscn(struct lpfc_vport *vport, uint8_t retry) phba->fc_stat.elsXmitRSCN++; elsiocb->cmd_cmpl = lpfc_cmpl_els_cmd; - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) { + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) { lpfc_els_free_iocb(phba, elsiocb); return 1; } @@ -3645,7 +3644,7 @@ lpfc_issue_els_rscn(struct lpfc_vport *vport, uint8_t retry) * lpfc_sli_issue_iocb() routine is invoked to send the FARPR ELS command. * * Note that the ndlp reference count will be incremented by 1 for holding the - * ndlp and the reference to ndlp will be stored into the context1 field of + * ndlp and the reference to ndlp will be stored into the ndlp field of * the IOCB for the completion callback function to the FARPR ELS command. * * Return code @@ -3680,7 +3679,7 @@ lpfc_issue_els_farpr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) if (!elsiocb) return 1; - pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); + pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt; *((uint32_t *) (pcmd)) = ELS_CMD_FARPR; pcmd += sizeof(uint32_t); @@ -3710,8 +3709,8 @@ lpfc_issue_els_farpr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) phba->fc_stat.elsXmitFARPR++; elsiocb->cmd_cmpl = lpfc_cmpl_els_cmd; - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) { + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) { lpfc_els_free_iocb(phba, elsiocb); return 1; } @@ -3742,7 +3741,7 @@ lpfc_issue_els_farpr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) * for diagnostic functions. * * Note that the ndlp reference count will be incremented by 1 for holding the - * ndlp and the reference to ndlp will be stored into the context1 field of + * ndlp and the reference to ndlp will be stored into the ndlp field of * the IOCB for the completion callback function to the RDF ELS command. * * Return code @@ -3779,8 +3778,7 @@ lpfc_issue_els_rdf(struct lpfc_vport *vport, uint8_t retry) return -ENOMEM; /* Configure the payload for the supported FPIN events. */ - prdf = (struct lpfc_els_rdf_req *) - (((struct lpfc_dmabuf *)elsiocb->context2)->virt); + prdf = (struct lpfc_els_rdf_req *)elsiocb->cmd_dmabuf->virt; memset(prdf, 0, cmdsize); prdf->rdf.fpin_cmd = ELS_RDF; prdf->rdf.desc_len = cpu_to_be32(sizeof(struct lpfc_els_rdf_req) - @@ -3801,8 +3799,8 @@ lpfc_issue_els_rdf(struct lpfc_vport *vport, uint8_t retry) phba->cgn_fpin_frequency = LPFC_FPIN_INIT_FREQ; elsiocb->cmd_cmpl = lpfc_cmpl_els_disc_cmd; - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) { + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) { lpfc_els_free_iocb(phba, elsiocb); return -EIO; } @@ -3991,7 +3989,7 @@ lpfc_cmpl_els_edc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, struct lpfc_nodelist *ndlp; u32 ulp_status, ulp_word4, tmo, did, iotag; - ndlp = cmdiocb->context1; + ndlp = cmdiocb->ndlp; ulp_status = get_job_ulpstatus(phba, rspiocb); ulp_word4 = get_job_word4(phba, rspiocb); @@ -4015,7 +4013,7 @@ lpfc_cmpl_els_edc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, "4201 EDC cmd tag x%x completes Data: x%x x%x x%x\n", iotag, ulp_status, ulp_word4, tmo); - pcmd = (struct lpfc_dmabuf *)cmdiocb->context2; + pcmd = cmdiocb->cmd_dmabuf; if (!pcmd) goto out; @@ -4264,7 +4262,7 @@ lpfc_issue_els_edc(struct lpfc_vport *vport, uint8_t retry) goto try_rdf; /* Configure the payload for the supported Diagnostics capabilities. */ - pcmd = (u8 *)(((struct lpfc_dmabuf *)elsiocb->context2)->virt); + pcmd = (u8 *)elsiocb->cmd_dmabuf->virt; memset(pcmd, 0, cmdsize); edc_req = (struct lpfc_els_edc_req *)pcmd; edc_req->edc.desc_len = cpu_to_be32(cgn_desc_size); @@ -4283,8 +4281,8 @@ lpfc_issue_els_edc(struct lpfc_vport *vport, uint8_t retry) phba->cgn_reg_fpin); elsiocb->cmd_cmpl = lpfc_cmpl_els_disc_cmd; - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) { + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) { lpfc_els_free_iocb(phba, elsiocb); return -EIO; } @@ -4562,8 +4560,8 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, { struct lpfc_vport *vport = cmdiocb->vport; union lpfc_wqe128 *irsp = &rspiocb->wqe; - struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1; - struct lpfc_dmabuf *pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; + struct lpfc_nodelist *ndlp = cmdiocb->ndlp; + struct lpfc_dmabuf *pcmd = cmdiocb->cmd_dmabuf; uint32_t *elscmd; struct ls_rjt stat; int retry = 0, maxretry = lpfc_max_els_tries, delay = 0; @@ -4575,7 +4573,7 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, u32 ulp_word4 = get_job_word4(phba, rspiocb); - /* Note: context2 may be 0 for internal driver abort + /* Note: cmd_dmabuf may be 0 for internal driver abort * of delays ELS command. */ @@ -5086,10 +5084,10 @@ lpfc_els_free_bpl(struct lpfc_hba *phba, struct lpfc_dmabuf *buf_ptr) * command IOCB data structure contains the reference to various associated * resources, these fields must be set to NULL if the associated reference * not present: - * context1 - reference to ndlp - * context2 - reference to cmd - * context2->next - reference to rsp - * context3 - reference to bpl + * cmd_dmabuf - reference to cmd. + * cmd_dmabuf->next - reference to rsp + * rsp_dmabuf - unused + * bpl_dmabuf - reference to bpl * * It first properly decrements the reference count held on ndlp for the * IOCB completion callback function. If LPFC_DELAY_MEM_FREE flag is not @@ -5109,19 +5107,19 @@ lpfc_els_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *elsiocb) { struct lpfc_dmabuf *buf_ptr, *buf_ptr1; - /* The I/O iocb is complete. Clear the context1 data. */ - elsiocb->context1 = NULL; + /* The I/O iocb is complete. Clear the node and first dmbuf */ + elsiocb->ndlp = NULL; - /* context2 = cmd, context2->next = rsp, context3 = bpl */ - if (elsiocb->context2) { + /* cmd_dmabuf = cmd, cmd_dmabuf->next = rsp, bpl_dmabuf = bpl */ + if (elsiocb->cmd_dmabuf) { if (elsiocb->cmd_flag & LPFC_DELAY_MEM_FREE) { /* Firmware could still be in progress of DMAing * payload, so don't free data buffer till after * a hbeat. */ elsiocb->cmd_flag &= ~LPFC_DELAY_MEM_FREE; - buf_ptr = elsiocb->context2; - elsiocb->context2 = NULL; + buf_ptr = elsiocb->cmd_dmabuf; + elsiocb->cmd_dmabuf = NULL; if (buf_ptr) { buf_ptr1 = NULL; spin_lock_irq(&phba->hbalock); @@ -5140,16 +5138,16 @@ lpfc_els_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *elsiocb) spin_unlock_irq(&phba->hbalock); } } else { - buf_ptr1 = (struct lpfc_dmabuf *) elsiocb->context2; + buf_ptr1 = elsiocb->cmd_dmabuf; lpfc_els_free_data(phba, buf_ptr1); - elsiocb->context2 = NULL; + elsiocb->cmd_dmabuf = NULL; } } - if (elsiocb->context3) { - buf_ptr = (struct lpfc_dmabuf *) elsiocb->context3; + if (elsiocb->bpl_dmabuf) { + buf_ptr = elsiocb->bpl_dmabuf; lpfc_els_free_bpl(phba, buf_ptr); - elsiocb->context3 = NULL; + elsiocb->bpl_dmabuf = NULL; } lpfc_sli_release_iocbq(phba, elsiocb); return 0; @@ -5165,7 +5163,7 @@ lpfc_els_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *elsiocb) * Accept (ACC) Response ELS command. This routine is invoked to indicate * the completion of the LOGO process. It invokes the lpfc_nlp_not_used() to * release the ndlp if it has the last reference remaining (reference count - * is 1). If succeeded (meaning ndlp released), it sets the IOCB context1 + * is 1). If succeeded (meaning ndlp released), it sets the iocb ndlp * field to NULL to inform the following lpfc_els_free_iocb() routine no * ndlp reference count needs to be decremented. Otherwise, the ndlp * reference use-count shall be decremented by the lpfc_els_free_iocb() @@ -5176,7 +5174,7 @@ static void lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, struct lpfc_iocbq *rspiocb) { - struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1; + struct lpfc_nodelist *ndlp = cmdiocb->ndlp; struct lpfc_vport *vport = cmdiocb->vport; u32 ulp_status, ulp_word4; @@ -5222,7 +5220,7 @@ lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, /* Indicate the node has already released, should * not reference to it from within lpfc_els_free_iocb. */ - cmdiocb->context1 = NULL; + cmdiocb->ndlp = NULL; } } out: @@ -5251,7 +5249,7 @@ void lpfc_mbx_cmpl_dflt_rpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) { struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)(pmb->ctx_buf); - struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; + struct lpfc_nodelist *ndlp = pmb->ctx_ndlp; u32 mbx_flag = pmb->mbox_flag; u32 mbx_cmd = pmb->u.mb.mbxCommand; @@ -5303,7 +5301,7 @@ static void lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, struct lpfc_iocbq *rspiocb) { - struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1; + struct lpfc_nodelist *ndlp = cmdiocb->ndlp; struct lpfc_vport *vport = ndlp ? ndlp->vport : NULL; struct Scsi_Host *shost = vport ? lpfc_shost_from_vport(vport) : NULL; IOCB_t *irsp; @@ -5477,7 +5475,7 @@ out: * mailbox command to the HBA later when callback is invoked. * * Note that the ndlp reference count will be incremented by 1 for holding the - * ndlp and the reference to ndlp will be stored into the context1 field of + * ndlp and the reference to ndlp will be stored into the ndlp field of * the IOCB for the completion callback function to the corresponding * response ELS IOCB command. * @@ -5534,7 +5532,7 @@ lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, oldcmd->unsli3.rcvsli3.ox_id; } - pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt); + pcmd = elsiocb->cmd_dmabuf->virt; *((uint32_t *) (pcmd)) = ELS_CMD_ACC; pcmd += sizeof(uint32_t); @@ -5569,7 +5567,7 @@ lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, oldcmd->unsli3.rcvsli3.ox_id; } - pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt); + pcmd = (u8 *)elsiocb->cmd_dmabuf->virt; if (mbox) elsiocb->context_un.mbox = mbox; @@ -5647,9 +5645,9 @@ lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, oldcmd->unsli3.rcvsli3.ox_id; } - pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt); + pcmd = (u8 *) elsiocb->cmd_dmabuf->virt; - memcpy(pcmd, ((struct lpfc_dmabuf *) oldiocb->context2)->virt, + memcpy(pcmd, oldiocb->cmd_dmabuf->virt, sizeof(uint32_t) + sizeof(PRLO)); *((uint32_t *) (pcmd)) = ELS_CMD_PRLO_ACC; els_pkt_ptr = (ELS_PKT *) pcmd; @@ -5685,7 +5683,7 @@ lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, oldcmd->unsli3.rcvsli3.ox_id; } - pcmd = (((struct lpfc_dmabuf *)elsiocb->context2)->virt); + pcmd = (u8 *)elsiocb->cmd_dmabuf->virt; rdf_resp = (struct fc_els_rdf_resp *)pcmd; memset(rdf_resp, 0, sizeof(*rdf_resp)); rdf_resp->acc_hdr.la_cmd = ELS_LS_ACC; @@ -5713,8 +5711,8 @@ lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, } phba->fc_stat.elsXmitACC++; - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) { + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) { lpfc_els_free_iocb(phba, elsiocb); return 1; } @@ -5751,7 +5749,7 @@ lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, * to issue to the HBA later. * * Note that the ndlp reference count will be incremented by 1 for holding the - * ndlp and the reference to ndlp will be stored into the context1 field of + * ndlp and the reference to ndlp will be stored into the ndlp field of * the IOCB for the completion callback function to the reject response * ELS IOCB command. * @@ -5792,7 +5790,7 @@ lpfc_els_rsp_reject(struct lpfc_vport *vport, uint32_t rejectError, icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id; } - pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); + pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt; *((uint32_t *) (pcmd)) = ELS_CMD_LS_RJT; pcmd += sizeof(uint32_t); @@ -5815,8 +5813,8 @@ lpfc_els_rsp_reject(struct lpfc_vport *vport, uint32_t rejectError, phba->fc_stat.elsXmitLSRJT++; elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp; - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) { + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) { lpfc_els_free_iocb(phba, elsiocb); return 1; } @@ -5888,8 +5886,7 @@ lpfc_issue_els_edc_rsp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, icmd->unsli3.rcvsli3.ox_id = cmd->unsli3.rcvsli3.ox_id; } - pcmd = (((struct lpfc_dmabuf *)elsiocb->context2)->virt); - + pcmd = elsiocb->cmd_dmabuf->virt; memset(pcmd, 0, cmdsize); edc_rsp = (struct lpfc_els_edc_rsp *)pcmd; @@ -5909,8 +5906,8 @@ lpfc_issue_els_edc_rsp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp; phba->fc_stat.elsXmitACC++; - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) { + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) { lpfc_els_free_iocb(phba, elsiocb); return 1; } @@ -5945,7 +5942,7 @@ lpfc_issue_els_edc_rsp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, * and invokes the lpfc_sli_issue_iocb() routine to send out the command. * * Note that the ndlp reference count will be incremented by 1 for holding the - * ndlp and the reference to ndlp will be stored into the context1 field of + * ndlp and the reference to ndlp will be stored into the ndlp field of * the IOCB for the completion callback function to the ADISC Accept response * ELS IOCB command. * @@ -5998,7 +5995,7 @@ lpfc_els_rsp_adisc_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, elsiocb->iotag, ulp_context, ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); - pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); + pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt; *((uint32_t *) (pcmd)) = ELS_CMD_ACC; pcmd += sizeof(uint32_t); @@ -6015,8 +6012,8 @@ lpfc_els_rsp_adisc_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, phba->fc_stat.elsXmitACC++; elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp; - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) { + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) { lpfc_els_free_iocb(phba, elsiocb); return 1; } @@ -6042,7 +6039,7 @@ lpfc_els_rsp_adisc_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, * and invokes the lpfc_sli_issue_iocb() routine to send out the command. * * Note that the ndlp reference count will be incremented by 1 for holding the - * ndlp and the reference to ndlp will be stored into the context1 field of + * ndlp and the reference to ndlp will be stored into the ndlp field of * the IOCB for the completion callback function to the PRLI Accept response * ELS IOCB command. * @@ -6072,7 +6069,7 @@ lpfc_els_rsp_prli_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, /* Need the incoming PRLI payload to determine if the ACC is for an * FC4 or NVME PRLI type. The PRLI type is at word 1. */ - req_buf = (struct lpfc_dmabuf *)oldiocb->context2; + req_buf = oldiocb->cmd_dmabuf; req_payload = (((uint32_t *)req_buf->virt) + 1); /* PRLI type payload is at byte 3 for FCP or NVME. */ @@ -6120,7 +6117,7 @@ lpfc_els_rsp_prli_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, elsiocb->iotag, ulp_context, ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); - pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); + pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt; memset(pcmd, 0, cmdsize); *((uint32_t *)(pcmd)) = elsrspcmd; @@ -6193,8 +6190,8 @@ lpfc_els_rsp_prli_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, phba->fc_stat.elsXmitACC++; elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp; - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) { + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) { lpfc_els_free_iocb(phba, elsiocb); return 1; } @@ -6222,7 +6219,7 @@ lpfc_els_rsp_prli_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, * issue the response. * * Note that the ndlp reference count will be incremented by 1 for holding the - * ndlp and the reference to ndlp will be stored into the context1 field of + * ndlp and the reference to ndlp will be stored into the ndlp field of * the IOCB for the completion callback function. * * Return code @@ -6273,7 +6270,7 @@ lpfc_els_rsp_rnid_acc(struct lpfc_vport *vport, uint8_t format, lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, "0132 Xmit RNID ACC response tag x%x xri x%x\n", elsiocb->iotag, ulp_context); - pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); + pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt; *((uint32_t *) (pcmd)) = ELS_CMD_ACC; pcmd += sizeof(uint32_t); @@ -6307,8 +6304,8 @@ lpfc_els_rsp_rnid_acc(struct lpfc_vport *vport, uint8_t format, phba->fc_stat.elsXmitACC++; elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp; - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) { + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) { lpfc_els_free_iocb(phba, elsiocb); return 1; } @@ -6343,7 +6340,7 @@ lpfc_els_clear_rrq(struct lpfc_vport *vport, struct lpfc_node_rrq *prrq; - pcmd = (uint8_t *) (((struct lpfc_dmabuf *) iocb->context2)->virt); + pcmd = (uint8_t *)iocb->cmd_dmabuf->virt; pcmd += sizeof(uint32_t); rrq = (struct RRQ *)pcmd; rrq->rrq_exchg = be32_to_cpu(rrq->rrq_exchg); @@ -6430,7 +6427,7 @@ lpfc_els_rsp_echo_acc(struct lpfc_vport *vport, uint8_t *data, lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, "2876 Xmit ECHO ACC response tag x%x xri x%x\n", elsiocb->iotag, ulp_context); - pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); + pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt; *((uint32_t *) (pcmd)) = ELS_CMD_ACC; pcmd += sizeof(uint32_t); memcpy(pcmd, data, cmdsize - sizeof(uint32_t)); @@ -6441,8 +6438,8 @@ lpfc_els_rsp_echo_acc(struct lpfc_vport *vport, uint8_t *data, phba->fc_stat.elsXmitACC++; elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp; - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) { + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) { lpfc_els_free_iocb(phba, elsiocb); return 1; } @@ -7066,9 +7063,8 @@ lpfc_els_rdp_cmpl(struct lpfc_hba *phba, struct lpfc_rdp_context *rdp_context, elsiocb->iotag, ulp_context, ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); - rdp_res = (struct fc_rdp_res_frame *) - (((struct lpfc_dmabuf *) elsiocb->context2)->virt); - pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); + rdp_res = (struct fc_rdp_res_frame *)elsiocb->cmd_dmabuf->virt; + pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt; memset(pcmd, 0, sizeof(struct fc_rdp_res_frame)); *((uint32_t *) (pcmd)) = ELS_CMD_ACC; @@ -7119,15 +7115,14 @@ lpfc_els_rdp_cmpl(struct lpfc_hba *phba, struct lpfc_rdp_context *rdp_context, elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp; /* Now that we know the true size of the payload, update the BPL */ - bpl = (struct ulp_bde64 *) - (((struct lpfc_dmabuf *)(elsiocb->context3))->virt); + bpl = (struct ulp_bde64 *)elsiocb->bpl_dmabuf->virt; bpl->tus.f.bdeSize = len; bpl->tus.f.bdeFlags = 0; bpl->tus.w = le32_to_cpu(bpl->tus.w); phba->fc_stat.elsXmitACC++; - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) { + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) { lpfc_els_free_iocb(phba, elsiocb); goto free_rdp_context; } @@ -7161,7 +7156,7 @@ error: icmd->unsli3.rcvsli3.ox_id = rdp_context->ox_id; } - pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); + pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt; *((uint32_t *) (pcmd)) = ELS_CMD_LS_RJT; stat = (struct ls_rjt *)(pcmd + sizeof(uint32_t)); @@ -7169,8 +7164,8 @@ error: phba->fc_stat.elsXmitLSRJT++; elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp; - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) { + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) { lpfc_els_free_iocb(phba, elsiocb); goto free_rdp_context; } @@ -7266,7 +7261,7 @@ lpfc_els_rcv_rdp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, goto error; } - pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; + pcmd = cmdiocb->cmd_dmabuf; rdp_req = (struct fc_rdp_req_frame *) pcmd->virt; lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, @@ -7378,8 +7373,7 @@ lpfc_els_lcb_rsp(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) if (!elsiocb) goto free_lcb_context; - lcb_res = (struct fc_lcb_res_frame *) - (((struct lpfc_dmabuf *)elsiocb->context2)->virt); + lcb_res = (struct fc_lcb_res_frame *)elsiocb->cmd_dmabuf->virt; memset(lcb_res, 0, sizeof(struct fc_lcb_res_frame)); @@ -7394,7 +7388,7 @@ lpfc_els_lcb_rsp(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) icmd->unsli3.rcvsli3.ox_id = lcb_context->ox_id; } - pcmd = (uint8_t *)(((struct lpfc_dmabuf *)elsiocb->context2)->virt); + pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt; *((uint32_t *)(pcmd)) = ELS_CMD_ACC; lcb_res->lcb_sub_command = lcb_context->sub_command; lcb_res->lcb_type = lcb_context->type; @@ -7404,8 +7398,8 @@ lpfc_els_lcb_rsp(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp; phba->fc_stat.elsXmitACC++; - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) { + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) { lpfc_els_free_iocb(phba, elsiocb); goto out; } @@ -7439,7 +7433,7 @@ error: icmd->unsli3.rcvsli3.ox_id = lcb_context->ox_id; } - pcmd = (uint8_t *)(((struct lpfc_dmabuf *)elsiocb->context2)->virt); + pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt; *((uint32_t *)(pcmd)) = ELS_CMD_LS_RJT; stat = (struct ls_rjt *)(pcmd + sizeof(uint32_t)); @@ -7450,8 +7444,8 @@ error: elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp; phba->fc_stat.elsXmitLSRJT++; - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) { + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) { lpfc_els_free_iocb(phba, elsiocb); goto free_lcb_context; } @@ -7563,7 +7557,7 @@ lpfc_els_rcv_lcb(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, u8 state, rjt_err = 0; struct ls_rjt stat; - pcmd = (struct lpfc_dmabuf *)cmdiocb->context2; + pcmd = cmdiocb->cmd_dmabuf; lp = (uint8_t *)pcmd->virt; beacon = (struct fc_lcb_request_frame *)pcmd->virt; @@ -7809,7 +7803,7 @@ lpfc_send_rscn_event(struct lpfc_vport *vport, uint32_t payload_len; struct lpfc_rscn_event_header *rscn_event_data; - pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; + pcmd = cmdiocb->cmd_dmabuf; payload_ptr = (uint32_t *) pcmd->virt; payload_len = be32_to_cpu(*payload_ptr & ~ELS_CMD_MASK); @@ -7869,7 +7863,7 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, int rscn_id = 0, hba_id = 0; int i, tmo; - pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; + pcmd = cmdiocb->cmd_dmabuf; lp = (uint32_t *) pcmd->virt; payload_len = be32_to_cpu(*lp++ & ~ELS_CMD_MASK); @@ -7971,7 +7965,7 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, /* Get the array count after successfully have the token */ rscn_cnt = vport->fc_rscn_id_cnt; /* If we are already processing an RSCN, save the received - * RSCN payload buffer, cmdiocb->context2 to process later. + * RSCN payload buffer, cmdiocb->cmd_dmabuf to process later. */ if (vport->fc_flag & (FC_RSCN_MODE | FC_NDISC_ACTIVE)) { lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, @@ -8005,10 +7999,10 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, } else { vport->fc_rscn_id_list[rscn_cnt] = pcmd; vport->fc_rscn_id_cnt++; - /* If we zero, cmdiocb->context2, the calling + /* If we zero, cmdiocb->cmd_dmabuf, the calling * routine will not try to free it. */ - cmdiocb->context2 = NULL; + cmdiocb->cmd_dmabuf = NULL; } /* Deferred RSCN */ lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, @@ -8046,10 +8040,10 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, /* Indicate we are done walking fc_rscn_id_list on this vport */ vport->fc_rscn_flush = 0; /* - * If we zero, cmdiocb->context2, the calling routine will + * If we zero, cmdiocb->cmd_dmabuf, the calling routine will * not try to free it. */ - cmdiocb->context2 = NULL; + cmdiocb->cmd_dmabuf = NULL; lpfc_set_disctmo(vport); /* Send back ACC */ lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL); @@ -8173,7 +8167,7 @@ lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, { struct Scsi_Host *shost = lpfc_shost_from_vport(vport); struct lpfc_hba *phba = vport->phba; - struct lpfc_dmabuf *pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; + struct lpfc_dmabuf *pcmd = cmdiocb->cmd_dmabuf; uint32_t *lp = (uint32_t *) pcmd->virt; union lpfc_wqe128 *wqe = &cmdiocb->wqe; struct serv_parm *sp; @@ -8340,7 +8334,7 @@ lpfc_els_rcv_rnid(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, RNID *rn; struct ls_rjt stat; - pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; + pcmd = cmdiocb->cmd_dmabuf; lp = (uint32_t *) pcmd->virt; lp++; @@ -8381,7 +8375,7 @@ lpfc_els_rcv_echo(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, { uint8_t *pcmd; - pcmd = (uint8_t *) (((struct lpfc_dmabuf *) cmdiocb->context2)->virt); + pcmd = (uint8_t *)cmdiocb->cmd_dmabuf->virt; /* skip over first word of echo command to find echo data */ pcmd += sizeof(uint32_t); @@ -8457,7 +8451,7 @@ lpfc_els_rcv_rrq(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, * response to the RLS. * * Note that the ndlp reference count will be incremented by 1 for holding the - * ndlp and the reference to ndlp will be stored into the context1 field of + * ndlp and the reference to ndlp will be stored into the ndlp field of * the IOCB for the completion callback function to the RLS Accept Response * ELS IOCB command. * @@ -8480,7 +8474,7 @@ lpfc_els_rsp_rls_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) mb = &pmb->u.mb; - ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; + ndlp = pmb->ctx_ndlp; rxid = (uint16_t)((unsigned long)(pmb->ctx_buf) & 0xffff); oxid = (uint16_t)(((unsigned long)(pmb->ctx_buf) >> 16) & 0xffff); pmb->ctx_buf = NULL; @@ -8516,7 +8510,7 @@ lpfc_els_rsp_rls_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) icmd->unsli3.rcvsli3.ox_id = oxid; } - pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); + pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt; *((uint32_t *) (pcmd)) = ELS_CMD_ACC; pcmd += sizeof(uint32_t); /* Skip past command */ rls_rsp = (struct RLS_RSP *)pcmd; @@ -8537,8 +8531,8 @@ lpfc_els_rsp_rls_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) ndlp->nlp_rpi); elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp; phba->fc_stat.elsXmitACC++; - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) { + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) { lpfc_els_free_iocb(phba, elsiocb); return; } @@ -8629,7 +8623,7 @@ reject_out: * Value (RTV) unsolicited IOCB event. * * Note that the ndlp reference count will be incremented by 1 for holding the - * ndlp and the reference to ndlp will be stored into the context1 field of + * ndlp and the reference to ndlp will be stored into the ndlp field of * the IOCB for the completion callback function to the RTV Accept Response * ELS IOCB command. * @@ -8664,7 +8658,7 @@ lpfc_els_rcv_rtv(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, if (!elsiocb) return 1; - pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); + pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt; *((uint32_t *) (pcmd)) = ELS_CMD_ACC; pcmd += sizeof(uint32_t); /* Skip past command */ @@ -8702,8 +8696,8 @@ lpfc_els_rcv_rtv(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, rtv_rsp->ratov, rtv_rsp->edtov, rtv_rsp->qtov); elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp; phba->fc_stat.elsXmitACC++; - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) { + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) { lpfc_els_free_iocb(phba, elsiocb); return 0; } @@ -8759,7 +8753,7 @@ lpfc_issue_els_rrq(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, if (!elsiocb) return 1; - pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); + pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt; /* For RRQ request, remainder of payload is Exchange IDs */ *((uint32_t *) (pcmd)) = ELS_CMD_RRQ; @@ -8779,8 +8773,11 @@ lpfc_issue_els_rrq(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, elsiocb->context_un.rrq = rrq; elsiocb->cmd_cmpl = lpfc_cmpl_els_rrq; - lpfc_nlp_get(ndlp); - elsiocb->context1 = ndlp; + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) { + lpfc_els_free_iocb(phba, elsiocb); + return 1; + } ret = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); if (ret == IOCB_ERROR) @@ -8831,7 +8828,7 @@ lpfc_send_rrq(struct lpfc_hba *phba, struct lpfc_node_rrq *rrq) * It is to be called by the lpfc_els_rcv_rpl() routine to accept the RPL. * * Note that the ndlp reference count will be incremented by 1 for holding the - * ndlp and the reference to ndlp will be stored into the context1 field of + * ndlp and the reference to ndlp will be stored into the ndlp field of * the IOCB for the completion callback function to the RPL Accept Response * ELS command. * @@ -8872,7 +8869,7 @@ lpfc_els_rsp_rpl_acc(struct lpfc_vport *vport, uint16_t cmdsize, icmd->unsli3.rcvsli3.ox_id = get_job_rcvoxid(phba, oldiocb); } - pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt); + pcmd = elsiocb->cmd_dmabuf->virt; *((uint32_t *) (pcmd)) = ELS_CMD_ACC; pcmd += sizeof(uint16_t); *((uint16_t *)(pcmd)) = be16_to_cpu(cmdsize); @@ -8896,8 +8893,8 @@ lpfc_els_rsp_rpl_acc(struct lpfc_vport *vport, uint16_t cmdsize, ndlp->nlp_rpi); elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp; phba->fc_stat.elsXmitACC++; - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) { + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) { lpfc_els_free_iocb(phba, elsiocb); return 1; } @@ -8952,7 +8949,7 @@ lpfc_els_rcv_rpl(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, return 0; } - pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; + pcmd = cmdiocb->cmd_dmabuf; lp = (uint32_t *) pcmd->virt; rpl = (RPL *) (lp + 1); maxsize = be32_to_cpu(rpl->maxsize); @@ -9004,7 +9001,7 @@ lpfc_els_rcv_farp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, uint32_t cnt, did; did = get_job_els_rsp64_did(vport->phba, cmdiocb); - pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; + pcmd = cmdiocb->cmd_dmabuf; lp = (uint32_t *) pcmd->virt; lp++; @@ -9074,8 +9071,8 @@ lpfc_els_rcv_farpr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, uint32_t did; did = get_job_els_rsp64_did(vport->phba, cmdiocb); - pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; - lp = (uint32_t *) pcmd->virt; + pcmd = cmdiocb->cmd_dmabuf; + lp = (uint32_t *)pcmd->virt; lp++; /* FARP-RSP received from DID */ @@ -9115,7 +9112,7 @@ lpfc_els_rcv_fan(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, FAN *fp; lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, "0265 FAN received\n"); - lp = (uint32_t *)((struct lpfc_dmabuf *)cmdiocb->context2)->virt; + lp = (uint32_t *)cmdiocb->cmd_dmabuf->virt; fp = (FAN *) ++lp; /* FAN received; Fan does not have a reply sequence */ if ((vport == phba->pport) && @@ -9164,7 +9161,7 @@ lpfc_els_rcv_edc(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, int desc_cnt = 0, bytes_remain; bool rcv_cap_desc = false; - payload = ((struct lpfc_dmabuf *)cmdiocb->context2)->virt; + payload = cmdiocb->cmd_dmabuf->virt; edc_req = (struct fc_els_edc *)payload; bytes_remain = be32_to_cpu(edc_req->desc_len); @@ -9349,7 +9346,7 @@ lpfc_els_timeout_handler(struct lpfc_vport *vport) if (piocb->vport != vport) continue; - pcmd = (struct lpfc_dmabuf *) piocb->context2; + pcmd = piocb->cmd_dmabuf; if (pcmd) els_command = *(uint32_t *) (pcmd->virt); @@ -9604,7 +9601,7 @@ lpfc_send_els_failure_event(struct lpfc_hba *phba, uint32_t *pcmd; u32 ulp_status, ulp_word4; - ndlp = cmdiocbp->context1; + ndlp = cmdiocbp->ndlp; if (!ndlp) return; @@ -9618,8 +9615,7 @@ lpfc_send_els_failure_event(struct lpfc_hba *phba, sizeof(struct lpfc_name)); memcpy(lsrjt_event.header.wwnn, &ndlp->nlp_nodename, sizeof(struct lpfc_name)); - pcmd = (uint32_t *) (((struct lpfc_dmabuf *) - cmdiocbp->context2)->virt); + pcmd = (uint32_t *)cmdiocbp->cmd_dmabuf->virt; lsrjt_event.command = (pcmd != NULL) ? *pcmd : 0; stat.un.ls_rjt_error_be = cpu_to_be32(ulp_word4); lsrjt_event.reason_code = stat.un.b.lsRjtRsnCode; @@ -10153,12 +10149,12 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, struct lpfc_wcqe_complete *wcqe_cmpl = NULL; LPFC_MBOXQ_t *mbox; - if (!vport || !(elsiocb->context2)) + if (!vport || !elsiocb->cmd_dmabuf) goto dropit; newnode = 0; wcqe_cmpl = &elsiocb->wcqe_cmpl; - payload = ((struct lpfc_dmabuf *)elsiocb->context2)->virt; + payload = elsiocb->cmd_dmabuf->virt; if (phba->sli_rev == LPFC_SLI_REV4) payload_len = wcqe_cmpl->total_data_placed; else @@ -10219,8 +10215,8 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, } spin_unlock_irq(&ndlp->lock); - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) goto dropit; elsiocb->vport = vport; @@ -10576,8 +10572,8 @@ lsrjt: } /* Release the reference on this elsiocb, not the ndlp. */ - lpfc_nlp_put(elsiocb->context1); - elsiocb->context1 = NULL; + lpfc_nlp_put(elsiocb->ndlp); + elsiocb->ndlp = NULL; /* Special case. Driver received an unsolicited command that * unsupportable given the driver's current state. Reset the @@ -10631,13 +10627,13 @@ lpfc_els_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, u32 ulp_command, status, parameter, bde_count = 0; IOCB_t *icmd; struct lpfc_wcqe_complete *wcqe_cmpl = NULL; - struct lpfc_dmabuf *bdeBuf1 = elsiocb->context2; - struct lpfc_dmabuf *bdeBuf2 = elsiocb->context3; + struct lpfc_dmabuf *bdeBuf1 = elsiocb->cmd_dmabuf; + struct lpfc_dmabuf *bdeBuf2 = elsiocb->bpl_dmabuf; dma_addr_t paddr; - elsiocb->context1 = NULL; - elsiocb->context2 = NULL; - elsiocb->context3 = NULL; + elsiocb->cmd_dmabuf = NULL; + elsiocb->rsp_dmabuf = NULL; + elsiocb->bpl_dmabuf = NULL; wcqe_cmpl = &elsiocb->wcqe_cmpl; ulp_command = get_job_cmnd(phba, elsiocb); @@ -10681,38 +10677,39 @@ lpfc_els_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, /* Account for SLI2 or SLI3 and later unsolicited buffering */ if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) { - elsiocb->context2 = bdeBuf1; + elsiocb->cmd_dmabuf = bdeBuf1; if (bde_count == 2) - elsiocb->context3 = bdeBuf2; + elsiocb->bpl_dmabuf = bdeBuf2; } else { icmd = &elsiocb->iocb; paddr = getPaddr(icmd->un.cont64[0].addrHigh, icmd->un.cont64[0].addrLow); - elsiocb->context2 = lpfc_sli_ringpostbuf_get(phba, pring, - paddr); + elsiocb->cmd_dmabuf = lpfc_sli_ringpostbuf_get(phba, pring, + paddr); if (bde_count == 2) { paddr = getPaddr(icmd->un.cont64[1].addrHigh, icmd->un.cont64[1].addrLow); - elsiocb->context3 = lpfc_sli_ringpostbuf_get(phba, - pring, - paddr); + elsiocb->bpl_dmabuf = lpfc_sli_ringpostbuf_get(phba, + pring, + paddr); } } lpfc_els_unsol_buffer(phba, pring, vport, elsiocb); /* * The different unsolicited event handlers would tell us - * if they are done with "mp" by setting context2 to NULL. + * if they are done with "mp" by setting cmd_dmabuf to NULL. */ - if (elsiocb->context2) { - lpfc_in_buf_free(phba, (struct lpfc_dmabuf *)elsiocb->context2); - elsiocb->context2 = NULL; + if (elsiocb->cmd_dmabuf) { + lpfc_in_buf_free(phba, elsiocb->cmd_dmabuf); + elsiocb->cmd_dmabuf = NULL; } - if (elsiocb->context3) { - lpfc_in_buf_free(phba, elsiocb->context3); - elsiocb->context3 = NULL; + if (elsiocb->bpl_dmabuf) { + lpfc_in_buf_free(phba, elsiocb->bpl_dmabuf); + elsiocb->bpl_dmabuf = NULL; } + } static void @@ -10823,7 +10820,7 @@ lpfc_cmpl_reg_new_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) { struct lpfc_vport *vport = pmb->vport; struct Scsi_Host *shost = lpfc_shost_from_vport(vport); - struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; + struct lpfc_nodelist *ndlp = pmb->ctx_ndlp; MAILBOX_t *mb = &pmb->u.mb; int rc; @@ -11088,11 +11085,11 @@ lpfc_cmpl_els_fdisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, { struct lpfc_vport *vport = cmdiocb->vport; struct Scsi_Host *shost = lpfc_shost_from_vport(vport); - struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1; + struct lpfc_nodelist *ndlp = cmdiocb->ndlp; struct lpfc_nodelist *np; struct lpfc_nodelist *next_np; struct lpfc_iocbq *piocb; - struct lpfc_dmabuf *pcmd = cmdiocb->context2, *prsp; + struct lpfc_dmabuf *pcmd = cmdiocb->cmd_dmabuf, *prsp; struct serv_parm *sp; uint8_t fabric_param_changed; u32 ulp_status, ulp_word4; @@ -11230,7 +11227,7 @@ out: * IOCB will be sent off HBA at any given time. * * Note that the ndlp reference count will be incremented by 1 for holding the - * ndlp and the reference to ndlp will be stored into the context1 field of + * ndlp and the reference to ndlp will be stored into the ndlp field of * the IOCB for the completion callback function to the FDISC ELS command. * * Return code @@ -11275,7 +11272,7 @@ lpfc_issue_els_fdisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, icmd->ulpCt_l = 0; } - pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); + pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt; *((uint32_t *) (pcmd)) = ELS_CMD_FDISC; pcmd += sizeof(uint32_t); /* CSP Word 1 */ memcpy(pcmd, &vport->phba->pport->fc_sparam, sizeof(struct serv_parm)); @@ -11307,8 +11304,8 @@ lpfc_issue_els_fdisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, "Issue FDISC: did:x%x", did, 0, 0); - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) goto err_out; rc = lpfc_issue_fabric_iocb(phba, elsiocb); @@ -11352,7 +11349,7 @@ lpfc_cmpl_els_npiv_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, struct Scsi_Host *shost = lpfc_shost_from_vport(vport); u32 ulp_status, ulp_word4, did, tmo; - ndlp = (struct lpfc_nodelist *)cmdiocb->context1; + ndlp = cmdiocb->ndlp; ulp_status = get_job_ulpstatus(phba, rspiocb); ulp_word4 = get_job_word4(phba, rspiocb); @@ -11410,7 +11407,7 @@ lpfc_cmpl_els_npiv_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, * This routine issues a LOGO ELS command to an @ndlp off a @vport. * * Note that the ndlp reference count will be incremented by 1 for holding the - * ndlp and the reference to ndlp will be stored into the context1 field of + * ndlp and the reference to ndlp will be stored into the ndlp field of * the IOCB for the completion callback function to the LOGO ELS command. * * Return codes @@ -11432,7 +11429,7 @@ lpfc_issue_els_npiv_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) if (!elsiocb) return 1; - pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); + pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt; *((uint32_t *) (pcmd)) = ELS_CMD_LOGO; pcmd += sizeof(uint32_t); @@ -11449,8 +11446,8 @@ lpfc_issue_els_npiv_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) spin_lock_irq(&ndlp->lock); ndlp->nlp_flag |= NLP_LOGO_SND; spin_unlock_irq(&ndlp->lock); - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) { + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) { lpfc_els_free_iocb(phba, elsiocb); goto err; } @@ -12009,12 +12006,12 @@ lpfc_cmpl_els_qfpa(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, struct lpfc_dmabuf *prsp = NULL; struct lpfc_vmid_priority_range *vmid_range = NULL; u32 *data; - struct lpfc_dmabuf *dmabuf = cmdiocb->context2; + struct lpfc_dmabuf *dmabuf = cmdiocb->cmd_dmabuf; u32 ulp_status = get_job_ulpstatus(phba, rspiocb); u32 ulp_word4 = get_job_word4(phba, rspiocb); u8 *pcmd, max_desc; u32 len, i; - struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)cmdiocb->context1; + struct lpfc_nodelist *ndlp = cmdiocb->ndlp; prsp = list_get_first(&dmabuf->list, struct lpfc_dmabuf, list); if (!prsp) @@ -12110,15 +12107,15 @@ int lpfc_issue_els_qfpa(struct lpfc_vport *vport) if (!elsiocb) return -ENOMEM; - pcmd = (u8 *)(((struct lpfc_dmabuf *)elsiocb->context2)->virt); + pcmd = (u8 *)elsiocb->cmd_dmabuf->virt; *((u32 *)(pcmd)) = ELS_CMD_QFPA; pcmd += 4; elsiocb->cmd_cmpl = lpfc_cmpl_els_qfpa; - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) { + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) { lpfc_els_free_iocb(vport->phba, elsiocb); return -ENXIO; } @@ -12165,7 +12162,7 @@ lpfc_vmid_uvem(struct lpfc_vport *vport, vmid_context->nlp = ndlp; vmid_context->instantiated = instantiated; elsiocb->vmid_tag.vmid_context = vmid_context; - pcmd = (u8 *)(((struct lpfc_dmabuf *)elsiocb->context2)->virt); + pcmd = (u8 *)elsiocb->cmd_dmabuf->virt; if (uuid_is_null((uuid_t *)vport->lpfc_vmid_host_uuid)) memcpy(vport->lpfc_vmid_host_uuid, vmid->host_vmid, @@ -12200,8 +12197,8 @@ lpfc_vmid_uvem(struct lpfc_vport *vport, elsiocb->cmd_cmpl = lpfc_cmpl_els_uvem; - elsiocb->context1 = lpfc_nlp_get(ndlp); - if (!elsiocb->context1) { + elsiocb->ndlp = lpfc_nlp_get(ndlp); + if (!elsiocb->ndlp) { lpfc_els_free_iocb(vport->phba, elsiocb); goto out; } @@ -12227,12 +12224,12 @@ lpfc_cmpl_els_uvem(struct lpfc_hba *phba, struct lpfc_iocbq *icmdiocb, struct lpfc_dmabuf *prsp = NULL; struct lpfc_vmid_context *vmid_context = icmdiocb->vmid_tag.vmid_context; - struct lpfc_nodelist *ndlp = icmdiocb->context1; + struct lpfc_nodelist *ndlp = icmdiocb->ndlp; u8 *pcmd; u32 *data; u32 ulp_status = get_job_ulpstatus(phba, rspiocb); u32 ulp_word4 = get_job_word4(phba, rspiocb); - struct lpfc_dmabuf *dmabuf = icmdiocb->context2; + struct lpfc_dmabuf *dmabuf = icmdiocb->cmd_dmabuf; struct lpfc_vmid *vmid; vmid = vmid_context->vmp; diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index d6ff864b132b..46a01801186b 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c @@ -5156,7 +5156,7 @@ lpfc_check_sli_ndlp(struct lpfc_hba *phba, if (pring->ringno == LPFC_ELS_RING) { switch (ulp_command) { case CMD_GEN_REQUEST64_CR: - if (iocb->context_un.ndlp == ndlp) + if (iocb->ndlp == ndlp) return 1; fallthrough; case CMD_ELS_REQUEST64_CR: @@ -5164,7 +5164,7 @@ lpfc_check_sli_ndlp(struct lpfc_hba *phba, return 1; fallthrough; case CMD_XMIT_ELS_RSP64_CX: - if (iocb->context1 == (uint8_t *) ndlp) + if (iocb->ndlp == ndlp) return 1; } } else if (pring->ringno == LPFC_FCP_RING) { @@ -6099,7 +6099,7 @@ lpfc_free_tx(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) */ spin_lock_irq(&phba->hbalock); list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) { - if (iocb->context1 != ndlp) + if (iocb->ndlp != ndlp) continue; ulp_command = get_job_cmnd(phba, iocb); @@ -6113,7 +6113,7 @@ lpfc_free_tx(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) /* Next check the txcmplq */ list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) { - if (iocb->context1 != ndlp) + if (iocb->ndlp != ndlp) continue; ulp_command = get_job_cmnd(phba, iocb); diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 578e9947125b..590ebf0008ac 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -4323,9 +4323,10 @@ lpfc_sli4_io_sgl_update(struct lpfc_hba *phba) lpfc_printf_log(phba, KERN_INFO, LOG_SLI, "6074 Current allocated XRI sgl count:%d, " - "maximum XRI count:%d\n", + "maximum XRI count:%d els_xri_cnt:%d\n\n", phba->sli4_hba.io_xri_cnt, - phba->sli4_hba.io_xri_max); + phba->sli4_hba.io_xri_max, + els_xri_cnt); cnt = lpfc_io_buf_flush(phba, &io_sgl_list); @@ -4464,12 +4465,11 @@ lpfc_new_io_buf(struct lpfc_hba *phba, int num_to_alloc) } pwqeq->sli4_lxritag = lxri; pwqeq->sli4_xritag = phba->sli4_hba.xri_ids[lxri]; - pwqeq->context1 = lpfc_ncmd; /* Initialize local short-hand pointers. */ lpfc_ncmd->dma_sgl = lpfc_ncmd->data; lpfc_ncmd->dma_phys_sgl = lpfc_ncmd->dma_handle; - lpfc_ncmd->cur_iocbq.context1 = lpfc_ncmd; + lpfc_ncmd->cur_iocbq.io_buf = lpfc_ncmd; spin_lock_init(&lpfc_ncmd->buf_lock); /* add the nvme buffer to a post list */ @@ -4478,7 +4478,9 @@ lpfc_new_io_buf(struct lpfc_hba *phba, int num_to_alloc) } lpfc_printf_log(phba, KERN_INFO, LOG_NVME, "6114 Allocate %d out of %d requested new NVME " - "buffers\n", bcnt, num_to_alloc); + "buffers of size x%zu bytes\n", bcnt, num_to_alloc, + sizeof(*lpfc_ncmd)); + /* post the list of nvme buffer sgls to port if available */ if (!list_empty(&post_nblist)) diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c index 4b065c51ee1b..4bfd17175a79 100644 --- a/drivers/scsi/lpfc/lpfc_nportdisc.c +++ b/drivers/scsi/lpfc/lpfc_nportdisc.c @@ -173,9 +173,9 @@ lpfc_check_elscmpl_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, void *ptr = NULL; u32 ulp_status = get_job_ulpstatus(phba, rspiocb); - pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; + pcmd = cmdiocb->cmd_dmabuf; - /* For lpfc_els_abort, context2 could be zero'ed to delay + /* For lpfc_els_abort, cmd_dmabuf could be zero'ed to delay * freeing associated memory till after ABTS completes. */ if (pcmd) { @@ -343,7 +343,7 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, u32 remote_did; memset(&stat, 0, sizeof (struct ls_rjt)); - pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; + pcmd = cmdiocb->cmd_dmabuf; lp = (uint32_t *) pcmd->virt; sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t)); if (wwn_to_u64(sp->portName.u.wwn) == 0) { @@ -716,7 +716,7 @@ lpfc_rcv_padisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, uint32_t *lp; uint32_t cmd; - pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; + pcmd = cmdiocb->cmd_dmabuf; lp = (uint32_t *) pcmd->virt; cmd = *lp++; @@ -924,7 +924,7 @@ lpfc_rcv_prli_support_check(struct lpfc_vport *vport, uint32_t *payload; uint32_t cmd; - payload = ((struct lpfc_dmabuf *)cmdiocb->context2)->virt; + payload = cmdiocb->cmd_dmabuf->virt; cmd = *payload; if (vport->phba->nvmet_support) { /* Must be a NVME PRLI */ @@ -961,9 +961,9 @@ lpfc_rcv_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, struct fc_rport *rport = ndlp->rport; u32 roles; - pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; - lp = (uint32_t *) pcmd->virt; - npr = (PRLI *) ((uint8_t *) lp + sizeof (uint32_t)); + pcmd = cmdiocb->cmd_dmabuf; + lp = (uint32_t *)pcmd->virt; + npr = (PRLI *)((uint8_t *)lp + sizeof(uint32_t)); if ((npr->prliType == PRLI_FCP_TYPE) || (npr->prliType == PRLI_NVME_TYPE)) { @@ -1224,7 +1224,7 @@ lpfc_rcv_plogi_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, struct Scsi_Host *shost = lpfc_shost_from_vport(vport); struct lpfc_hba *phba = vport->phba; struct lpfc_iocbq *cmdiocb = arg; - struct lpfc_dmabuf *pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; + struct lpfc_dmabuf *pcmd = cmdiocb->cmd_dmabuf; uint32_t *lp = (uint32_t *) pcmd->virt; struct serv_parm *sp = (struct serv_parm *) (lp + 1); struct ls_rjt stat; @@ -1345,7 +1345,7 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_vport *vport, u32 did; cmdiocb = (struct lpfc_iocbq *) arg; - rspiocb = cmdiocb->context_un.rsp_iocb; + rspiocb = cmdiocb->rsp_iocb; ulp_status = get_job_ulpstatus(phba, rspiocb); @@ -1357,7 +1357,7 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_vport *vport, if (ulp_status) goto out; - pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; + pcmd = cmdiocb->cmd_dmabuf; prsp = list_get_first(&pcmd->list, struct lpfc_dmabuf, list); if (!prsp) @@ -1703,7 +1703,7 @@ lpfc_cmpl_adisc_adisc_issue(struct lpfc_vport *vport, u32 ulp_status; cmdiocb = (struct lpfc_iocbq *) arg; - rspiocb = cmdiocb->context_un.rsp_iocb; + rspiocb = cmdiocb->rsp_iocb; ulp_status = get_job_ulpstatus(phba, rspiocb); @@ -2158,7 +2158,7 @@ lpfc_cmpl_prli_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, u32 ulp_status; cmdiocb = (struct lpfc_iocbq *) arg; - rspiocb = cmdiocb->context_un.rsp_iocb; + rspiocb = cmdiocb->rsp_iocb; ulp_status = get_job_ulpstatus(phba, rspiocb); @@ -2778,7 +2778,7 @@ lpfc_cmpl_plogi_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, u32 ulp_status; cmdiocb = (struct lpfc_iocbq *) arg; - rspiocb = cmdiocb->context_un.rsp_iocb; + rspiocb = cmdiocb->rsp_iocb; ulp_status = get_job_ulpstatus(phba, rspiocb); @@ -2797,7 +2797,7 @@ lpfc_cmpl_prli_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, u32 ulp_status; cmdiocb = (struct lpfc_iocbq *) arg; - rspiocb = cmdiocb->context_un.rsp_iocb; + rspiocb = cmdiocb->rsp_iocb; ulp_status = get_job_ulpstatus(phba, rspiocb); @@ -2833,7 +2833,7 @@ lpfc_cmpl_adisc_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, u32 ulp_status; cmdiocb = (struct lpfc_iocbq *) arg; - rspiocb = cmdiocb->context_un.rsp_iocb; + rspiocb = cmdiocb->rsp_iocb; ulp_status = get_job_ulpstatus(phba, rspiocb); diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c index 699b79d4f496..376f6c0265c0 100644 --- a/drivers/scsi/lpfc/lpfc_nvme.c +++ b/drivers/scsi/lpfc/lpfc_nvme.c @@ -319,8 +319,10 @@ __lpfc_nvme_ls_req_cmp(struct lpfc_hba *phba, struct lpfc_vport *vport, struct lpfc_nodelist *ndlp; uint32_t status; - pnvme_lsreq = (struct nvmefc_ls_req *)cmdwqe->context2; - ndlp = (struct lpfc_nodelist *)cmdwqe->context1; + pnvme_lsreq = cmdwqe->context_un.nvme_lsreq; + ndlp = cmdwqe->ndlp; + buf_ptr = cmdwqe->bpl_dmabuf; + status = bf_get(lpfc_wcqe_c_status, wcqe) & LPFC_IOCB_STATUS_MASK; lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC, @@ -330,16 +332,16 @@ __lpfc_nvme_ls_req_cmp(struct lpfc_hba *phba, struct lpfc_vport *vport, pnvme_lsreq, ndlp ? ndlp->nlp_DID : 0, cmdwqe->sli4_xritag, status, (wcqe->parameter & 0xffff), - cmdwqe, pnvme_lsreq, cmdwqe->context3, ndlp); + cmdwqe, pnvme_lsreq, cmdwqe->bpl_dmabuf, + ndlp); lpfc_nvmeio_data(phba, "NVMEx LS CMPL: xri x%x stat x%x parm x%x\n", cmdwqe->sli4_xritag, status, wcqe->parameter); - if (cmdwqe->context3) { - buf_ptr = (struct lpfc_dmabuf *)cmdwqe->context3; + if (buf_ptr) { lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); kfree(buf_ptr); - cmdwqe->context3 = NULL; + cmdwqe->bpl_dmabuf = NULL; } if (pnvme_lsreq->done) pnvme_lsreq->done(pnvme_lsreq, status); @@ -351,7 +353,7 @@ __lpfc_nvme_ls_req_cmp(struct lpfc_hba *phba, struct lpfc_vport *vport, cmdwqe->sli4_xritag, status); if (ndlp) { lpfc_nlp_put(ndlp); - cmdwqe->context1 = NULL; + cmdwqe->ndlp = NULL; } lpfc_sli_release_iocbq(phba, cmdwqe); } @@ -407,19 +409,19 @@ lpfc_nvme_gen_req(struct lpfc_vport *vport, struct lpfc_dmabuf *bmp, /* Initialize only 64 bytes */ memset(wqe, 0, sizeof(union lpfc_wqe)); - genwqe->context3 = (uint8_t *)bmp; + genwqe->bpl_dmabuf = bmp; genwqe->cmd_flag |= LPFC_IO_NVME_LS; /* Save for completion so we can release these resources */ - genwqe->context1 = lpfc_nlp_get(ndlp); - if (!genwqe->context1) { + genwqe->ndlp = lpfc_nlp_get(ndlp); + if (!genwqe->ndlp) { dev_warn(&phba->pcidev->dev, "Warning: Failed node ref, not sending LS_REQ\n"); lpfc_sli_release_iocbq(phba, genwqe); return 1; } - genwqe->context2 = (uint8_t *)pnvme_lsreq; + genwqe->context_un.nvme_lsreq = pnvme_lsreq; /* Fill in payload, bp points to frame payload */ if (!tmo) @@ -730,7 +732,7 @@ __lpfc_nvme_ls_abort(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, spin_lock_irq(&phba->hbalock); spin_lock(&pring->ring_lock); list_for_each_entry_safe(wqe, next_wqe, &pring->txcmplq, list) { - if (wqe->context2 == pnvme_lsreq) { + if (wqe->context_un.nvme_lsreq == pnvme_lsreq) { wqe->cmd_flag |= LPFC_DRIVER_ABORTED; foundit = true; break; @@ -929,8 +931,7 @@ static void lpfc_nvme_io_cmd_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn, struct lpfc_iocbq *pwqeOut) { - struct lpfc_io_buf *lpfc_ncmd = - (struct lpfc_io_buf *)pwqeIn->context1; + struct lpfc_io_buf *lpfc_ncmd = pwqeIn->io_buf; struct lpfc_wcqe_complete *wcqe = &pwqeOut->wcqe_cmpl; struct lpfc_vport *vport = pwqeIn->vport; struct nvmefc_fcp_req *nCmd; @@ -2717,7 +2718,7 @@ lpfc_nvme_cancel_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn, struct lpfc_wcqe_complete wcqe; struct lpfc_wcqe_complete *wcqep = &wcqe; - lpfc_ncmd = (struct lpfc_io_buf *)pwqeIn->context1; + lpfc_ncmd = pwqeIn->io_buf; if (!lpfc_ncmd) { lpfc_sli_release_iocbq(phba, pwqeIn); return; diff --git a/drivers/scsi/lpfc/lpfc_nvmet.c b/drivers/scsi/lpfc/lpfc_nvmet.c index 95438265fb16..c0ee0b39075d 100644 --- a/drivers/scsi/lpfc/lpfc_nvmet.c +++ b/drivers/scsi/lpfc/lpfc_nvmet.c @@ -295,7 +295,7 @@ void __lpfc_nvme_xmt_ls_rsp_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, struct lpfc_iocbq *rspwqe) { - struct lpfc_async_xchg_ctx *axchg = cmdwqe->context2; + struct lpfc_async_xchg_ctx *axchg = cmdwqe->context_un.axchg; struct lpfc_wcqe_complete *wcqe = &rspwqe->wcqe_cmpl; struct nvmefc_ls_rsp *ls_rsp = &axchg->ls_rsp; uint32_t status, result; @@ -317,9 +317,9 @@ __lpfc_nvme_xmt_ls_rsp_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, "6038 NVMEx LS rsp cmpl: %d %d oxid x%x\n", status, result, axchg->oxid); - lpfc_nlp_put(cmdwqe->context1); - cmdwqe->context2 = NULL; - cmdwqe->context3 = NULL; + lpfc_nlp_put(cmdwqe->ndlp); + cmdwqe->context_un.axchg = NULL; + cmdwqe->bpl_dmabuf = NULL; lpfc_sli_release_iocbq(phba, cmdwqe); ls_rsp->done(ls_rsp); lpfc_printf_log(phba, KERN_INFO, LOG_NVME_DISC, @@ -728,7 +728,7 @@ lpfc_nvmet_xmt_fcp_op_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, int id; #endif - ctxp = cmdwqe->context2; + ctxp = cmdwqe->context_un.axchg; ctxp->flag &= ~LPFC_NVME_IO_INP; rsp = &ctxp->hdlrctx.fcp_req; @@ -903,7 +903,7 @@ __lpfc_nvme_xmt_ls_rsp(struct lpfc_async_xchg_ctx *axchg, /* Save numBdes for bpl2sgl */ nvmewqeq->num_bdes = 1; nvmewqeq->hba_wqidx = 0; - nvmewqeq->context3 = &dmabuf; + nvmewqeq->bpl_dmabuf = &dmabuf; dmabuf.virt = &bpl; bpl.addrLow = nvmewqeq->wqe.xmit_sequence.bde.addrLow; bpl.addrHigh = nvmewqeq->wqe.xmit_sequence.bde.addrHigh; @@ -917,7 +917,7 @@ __lpfc_nvme_xmt_ls_rsp(struct lpfc_async_xchg_ctx *axchg, */ nvmewqeq->cmd_cmpl = xmt_ls_rsp_cmp; - nvmewqeq->context2 = axchg; + nvmewqeq->context_un.axchg = axchg; lpfc_nvmeio_data(phba, "NVMEx LS RSP: xri x%x wqidx x%x len x%x\n", axchg->oxid, nvmewqeq->hba_wqidx, ls_rsp->rsplen); @@ -925,7 +925,7 @@ __lpfc_nvme_xmt_ls_rsp(struct lpfc_async_xchg_ctx *axchg, rc = lpfc_sli4_issue_wqe(phba, axchg->hdwq, nvmewqeq); /* clear to be sure there's no reference */ - nvmewqeq->context3 = NULL; + nvmewqeq->bpl_dmabuf = NULL; if (rc == WQE_SUCCESS) { /* @@ -942,7 +942,7 @@ __lpfc_nvme_xmt_ls_rsp(struct lpfc_async_xchg_ctx *axchg, rc = -ENXIO; - lpfc_nlp_put(nvmewqeq->context1); + lpfc_nlp_put(nvmewqeq->ndlp); out_free_buf: /* Give back resources */ @@ -1075,7 +1075,7 @@ lpfc_nvmet_xmt_fcp_op(struct nvmet_fc_target_port *tgtport, } nvmewqeq->cmd_cmpl = lpfc_nvmet_xmt_fcp_op_cmp; - nvmewqeq->context2 = ctxp; + nvmewqeq->context_un.axchg = ctxp; nvmewqeq->cmd_flag |= LPFC_IO_NVMET; ctxp->wqeq->hba_wqidx = rsp->hwqid; @@ -1119,8 +1119,8 @@ lpfc_nvmet_xmt_fcp_op(struct nvmet_fc_target_port *tgtport, ctxp->oxid, rc); ctxp->wqeq->hba_wqidx = 0; - nvmewqeq->context2 = NULL; - nvmewqeq->context3 = NULL; + nvmewqeq->context_un.axchg = NULL; + nvmewqeq->bpl_dmabuf = NULL; rc = -EBUSY; aerr: return rc; @@ -1590,7 +1590,7 @@ lpfc_nvmet_setup_io_context(struct lpfc_hba *phba) /* Initialize WQE */ memset(wqe, 0, sizeof(union lpfc_wqe)); - ctx_buf->iocbq->context1 = NULL; + ctx_buf->iocbq->cmd_dmabuf = NULL; spin_lock(&phba->sli4_hba.sgl_list_lock); ctx_buf->sglq = __lpfc_sli_get_nvmet_sglq(phba, ctx_buf->iocbq); spin_unlock(&phba->sli4_hba.sgl_list_lock); @@ -2025,7 +2025,7 @@ lpfc_nvmet_wqfull_flush(struct lpfc_hba *phba, struct lpfc_queue *wq, &wq->wqfull_list, list) { if (ctxp) { /* Checking for a specific IO to flush */ - if (nvmewqeq->context2 == ctxp) { + if (nvmewqeq->context_un.axchg == ctxp) { list_del(&nvmewqeq->list); spin_unlock_irqrestore(&pring->ring_lock, iflags); @@ -2071,7 +2071,7 @@ lpfc_nvmet_wqfull_process(struct lpfc_hba *phba, list_remove_head(&wq->wqfull_list, nvmewqeq, struct lpfc_iocbq, list); spin_unlock_irqrestore(&pring->ring_lock, iflags); - ctxp = (struct lpfc_async_xchg_ctx *)nvmewqeq->context2; + ctxp = nvmewqeq->context_un.axchg; rc = lpfc_sli4_issue_wqe(phba, ctxp->hdwq, nvmewqeq); spin_lock_irqsave(&pring->ring_lock, iflags); if (rc == -EBUSY) { @@ -2617,10 +2617,10 @@ lpfc_nvmet_prep_ls_wqe(struct lpfc_hba *phba, ctxp->wqeq = nvmewqe; /* prevent preparing wqe with NULL ndlp reference */ - nvmewqe->context1 = lpfc_nlp_get(ndlp); - if (nvmewqe->context1 == NULL) + nvmewqe->ndlp = lpfc_nlp_get(ndlp); + if (!nvmewqe->ndlp) goto nvme_wqe_free_wqeq_exit; - nvmewqe->context2 = ctxp; + nvmewqe->context_un.axchg = ctxp; wqe = &nvmewqe->wqe; memset(wqe, 0, sizeof(union lpfc_wqe)); @@ -2692,8 +2692,9 @@ lpfc_nvmet_prep_ls_wqe(struct lpfc_hba *phba, return nvmewqe; nvme_wqe_free_wqeq_exit: - nvmewqe->context2 = NULL; - nvmewqe->context3 = NULL; + nvmewqe->context_un.axchg = NULL; + nvmewqe->ndlp = NULL; + nvmewqe->bpl_dmabuf = NULL; lpfc_sli_release_iocbq(phba, nvmewqe); return NULL; } @@ -2995,7 +2996,7 @@ lpfc_nvmet_prep_fcp_wqe(struct lpfc_hba *phba, nvmewqe->retry = 1; nvmewqe->vport = phba->pport; nvmewqe->drvrTimeout = (phba->fc_ratov * 3) + LPFC_DRVR_TIMEOUT; - nvmewqe->context1 = ndlp; + nvmewqe->ndlp = ndlp; for_each_sg(rsp->sg, sgel, nsegs, i) { physaddr = sg_dma_address(sgel); @@ -3053,7 +3054,7 @@ lpfc_nvmet_sol_fcp_abort_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, bool released = false; struct lpfc_wcqe_complete *wcqe = &rspwqe->wcqe_cmpl; - ctxp = cmdwqe->context2; + ctxp = cmdwqe->context_un.axchg; result = wcqe->parameter; tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private; @@ -3084,8 +3085,8 @@ lpfc_nvmet_sol_fcp_abort_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, wcqe->word0, wcqe->total_data_placed, result, wcqe->word3); - cmdwqe->context2 = NULL; - cmdwqe->context3 = NULL; + cmdwqe->rsp_dmabuf = NULL; + cmdwqe->bpl_dmabuf = NULL; /* * if transport has released ctx, then can reuse it. Otherwise, * will be recycled by transport release call. @@ -3123,7 +3124,7 @@ lpfc_nvmet_unsol_fcp_abort_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, bool released = false; struct lpfc_wcqe_complete *wcqe = &rspwqe->wcqe_cmpl; - ctxp = cmdwqe->context2; + ctxp = cmdwqe->context_un.axchg; result = wcqe->parameter; if (!ctxp) { @@ -3169,8 +3170,8 @@ lpfc_nvmet_unsol_fcp_abort_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, wcqe->word0, wcqe->total_data_placed, result, wcqe->word3); - cmdwqe->context2 = NULL; - cmdwqe->context3 = NULL; + cmdwqe->rsp_dmabuf = NULL; + cmdwqe->bpl_dmabuf = NULL; /* * if transport has released ctx, then can reuse it. Otherwise, * will be recycled by transport release call. @@ -3203,7 +3204,7 @@ lpfc_nvmet_xmt_ls_abort_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, uint32_t result; struct lpfc_wcqe_complete *wcqe = &rspwqe->wcqe_cmpl; - ctxp = cmdwqe->context2; + ctxp = cmdwqe->context_un.axchg; result = wcqe->parameter; if (phba->nvmet_support) { @@ -3234,8 +3235,8 @@ lpfc_nvmet_xmt_ls_abort_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, ctxp->oxid, ctxp->state, ctxp->entry_cnt); } - cmdwqe->context2 = NULL; - cmdwqe->context3 = NULL; + cmdwqe->rsp_dmabuf = NULL; + cmdwqe->bpl_dmabuf = NULL; lpfc_sli_release_iocbq(phba, cmdwqe); kfree(ctxp); } @@ -3322,9 +3323,9 @@ lpfc_nvmet_unsol_issue_abort(struct lpfc_hba *phba, OTHER_COMMAND); abts_wqeq->vport = phba->pport; - abts_wqeq->context1 = ndlp; - abts_wqeq->context2 = ctxp; - abts_wqeq->context3 = NULL; + abts_wqeq->ndlp = ndlp; + abts_wqeq->context_un.axchg = ctxp; + abts_wqeq->bpl_dmabuf = NULL; abts_wqeq->num_bdes = 0; /* hba_wqidx should already be setup from command we are aborting */ abts_wqeq->iocb.ulpCommand = CMD_XMIT_SEQUENCE64_CR; @@ -3477,7 +3478,7 @@ lpfc_nvmet_sol_fcp_issue_abort(struct lpfc_hba *phba, abts_wqeq->hba_wqidx = ctxp->wqeq->hba_wqidx; abts_wqeq->cmd_cmpl = lpfc_nvmet_sol_fcp_abort_cmp; abts_wqeq->cmd_flag |= LPFC_IO_NVME; - abts_wqeq->context2 = ctxp; + abts_wqeq->context_un.axchg = ctxp; abts_wqeq->vport = phba->pport; if (!ctxp->hdwq) ctxp->hdwq = &phba->sli4_hba.hdwq[abts_wqeq->hba_wqidx]; @@ -3630,8 +3631,8 @@ lpfc_nvme_unsol_ls_issue_abort(struct lpfc_hba *phba, out: if (tgtp) atomic_inc(&tgtp->xmt_abort_rsp_error); - abts_wqeq->context2 = NULL; - abts_wqeq->context3 = NULL; + abts_wqeq->rsp_dmabuf = NULL; + abts_wqeq->bpl_dmabuf = NULL; lpfc_sli_release_iocbq(phba, abts_wqeq); lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, "6056 Failed to Issue ABTS. Status x%x\n", rc); diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index a949fe53651a..1959c58d22f8 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -433,7 +433,7 @@ lpfc_new_scsi_buf_s3(struct lpfc_vport *vport, int num_to_alloc) iocb->ulpClass = CLASS3; psb->status = IOSTAT_SUCCESS; /* Put it back into the SCSI buffer list */ - psb->cur_iocbq.context1 = psb; + psb->cur_iocbq.io_buf = psb; spin_lock_init(&psb->buf_lock); lpfc_release_scsi_buf_s3(phba, psb); @@ -4082,8 +4082,7 @@ static void lpfc_fcp_io_cmd_wqe_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn, struct lpfc_iocbq *pwqeOut) { - struct lpfc_io_buf *lpfc_cmd = - (struct lpfc_io_buf *)pwqeIn->context1; + struct lpfc_io_buf *lpfc_cmd = pwqeIn->io_buf; struct lpfc_wcqe_complete *wcqe = &pwqeOut->wcqe_cmpl; struct lpfc_vport *vport = pwqeIn->vport; struct lpfc_rport_data *rdata; @@ -4421,7 +4420,7 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, struct lpfc_iocbq *pIocbOut) { struct lpfc_io_buf *lpfc_cmd = - (struct lpfc_io_buf *) pIocbIn->context1; + (struct lpfc_io_buf *) pIocbIn->io_buf; struct lpfc_vport *vport = pIocbIn->vport; struct lpfc_rport_data *rdata = lpfc_cmd->rdata; struct lpfc_nodelist *pnode = rdata->pnode; @@ -4744,7 +4743,7 @@ static int lpfc_scsi_prep_cmnd_buf_s3(struct lpfc_vport *vport, piocbq->iocb.ulpFCP2Rcvy = 0; piocbq->iocb.ulpClass = (pnode->nlp_fcp_info & 0x0f); - piocbq->context1 = lpfc_cmd; + piocbq->io_buf = lpfc_cmd; if (!piocbq->cmd_cmpl) piocbq->cmd_cmpl = lpfc_scsi_cmd_iocb_cmpl; piocbq->iocb.ulpTimeout = tmo; @@ -4856,8 +4855,7 @@ static int lpfc_scsi_prep_cmnd_buf_s4(struct lpfc_vport *vport, bf_set(wqe_reqtag, &wqe->generic.wqe_com, pwqeq->iotag); pwqeq->vport = vport; - pwqeq->vport = vport; - pwqeq->context1 = lpfc_cmd; + pwqeq->io_buf = lpfc_cmd; pwqeq->hba_wqidx = lpfc_cmd->hdwq_no; pwqeq->cmd_cmpl = lpfc_fcp_io_cmd_wqe_cmpl; @@ -5098,8 +5096,7 @@ lpfc_tskmgmt_def_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocbq, struct lpfc_iocbq *rspiocbq) { - struct lpfc_io_buf *lpfc_cmd = - (struct lpfc_io_buf *) cmdiocbq->context1; + struct lpfc_io_buf *lpfc_cmd = cmdiocbq->io_buf; if (lpfc_cmd) lpfc_release_scsi_buf(phba, lpfc_cmd); return; @@ -5916,7 +5913,7 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) goto out_unlock_ring; } - BUG_ON(iocb->context1 != lpfc_cmd); + WARN_ON(iocb->io_buf != lpfc_cmd); /* abort issued in recovery is still in progress */ if (iocb->cmd_flag & LPFC_DRIVER_ABORTED) { diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index 3b9359c1ee1c..ae26a004552d 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -1254,19 +1254,19 @@ __lpfc_sli_get_els_sglq(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq) cmnd = get_job_cmnd(phba, piocbq); - if (piocbq->cmd_flag & LPFC_IO_FCP) { - lpfc_cmd = (struct lpfc_io_buf *) piocbq->context1; + if (piocbq->cmd_flag & LPFC_IO_FCP) { + lpfc_cmd = piocbq->io_buf; ndlp = lpfc_cmd->rdata->pnode; } else if ((cmnd == CMD_GEN_REQUEST64_CR) && !(piocbq->cmd_flag & LPFC_IO_LIBDFC)) { - ndlp = piocbq->context_un.ndlp; + ndlp = piocbq->ndlp; } else if (piocbq->cmd_flag & LPFC_IO_LIBDFC) { if (piocbq->cmd_flag & LPFC_IO_LOOPBACK) ndlp = NULL; else - ndlp = piocbq->context_un.ndlp; + ndlp = piocbq->ndlp; } else { - ndlp = piocbq->context1; + ndlp = piocbq->ndlp; } spin_lock(&phba->sli4_hba.sgl_list_lock); @@ -1996,9 +1996,9 @@ initpath: sync_buf->vport = phba->pport; sync_buf->cmd_cmpl = lpfc_cmf_sync_cmpl; - sync_buf->context1 = NULL; - sync_buf->context2 = NULL; - sync_buf->context3 = NULL; + sync_buf->cmd_dmabuf = NULL; + sync_buf->rsp_dmabuf = NULL; + sync_buf->bpl_dmabuf = NULL; sync_buf->sli4_xritag = NO_XRI; sync_buf->cmd_flag |= LPFC_IO_CMF; @@ -3197,7 +3197,7 @@ lpfc_nvme_unsol_ls_handler(struct lpfc_hba *phba, struct lpfc_iocbq *piocb) uint32_t oxid, sid, did, fctl, size; int ret = 1; - d_buf = piocb->context2; + d_buf = piocb->cmd_dmabuf; nvmebuf = container_of(d_buf, struct hbq_dmabuf, dbuf); fc_hdr = nvmebuf->hbuf.virt; @@ -3478,9 +3478,9 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) { if (irsp->ulpBdeCount != 0) { - saveq->context2 = lpfc_sli_get_buff(phba, pring, + saveq->cmd_dmabuf = lpfc_sli_get_buff(phba, pring, irsp->un.ulpWord[3]); - if (!saveq->context2) + if (!saveq->cmd_dmabuf) lpfc_printf_log(phba, KERN_ERR, LOG_SLI, @@ -3490,9 +3490,9 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, irsp->un.ulpWord[3]); } if (irsp->ulpBdeCount == 2) { - saveq->context3 = lpfc_sli_get_buff(phba, pring, + saveq->bpl_dmabuf = lpfc_sli_get_buff(phba, pring, irsp->unsli3.sli3Words[7]); - if (!saveq->context3) + if (!saveq->bpl_dmabuf) lpfc_printf_log(phba, KERN_ERR, LOG_SLI, @@ -3504,10 +3504,10 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, list_for_each_entry(iocbq, &saveq->list, list) { irsp = &iocbq->iocb; if (irsp->ulpBdeCount != 0) { - iocbq->context2 = lpfc_sli_get_buff(phba, + iocbq->cmd_dmabuf = lpfc_sli_get_buff(phba, pring, irsp->un.ulpWord[3]); - if (!iocbq->context2) + if (!iocbq->cmd_dmabuf) lpfc_printf_log(phba, KERN_ERR, LOG_SLI, @@ -3517,10 +3517,10 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, irsp->un.ulpWord[3]); } if (irsp->ulpBdeCount == 2) { - iocbq->context3 = lpfc_sli_get_buff(phba, + iocbq->bpl_dmabuf = lpfc_sli_get_buff(phba, pring, irsp->unsli3.sli3Words[7]); - if (!iocbq->context3) + if (!iocbq->bpl_dmabuf) lpfc_printf_log(phba, KERN_ERR, LOG_SLI, @@ -3534,12 +3534,12 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, } else { paddr = getPaddr(irsp->un.cont64[0].addrHigh, irsp->un.cont64[0].addrLow); - saveq->context2 = lpfc_sli_ringpostbuf_get(phba, pring, + saveq->cmd_dmabuf = lpfc_sli_ringpostbuf_get(phba, pring, paddr); if (irsp->ulpBdeCount == 2) { paddr = getPaddr(irsp->un.cont64[1].addrHigh, irsp->un.cont64[1].addrLow); - saveq->context3 = lpfc_sli_ringpostbuf_get(phba, + saveq->bpl_dmabuf = lpfc_sli_ringpostbuf_get(phba, pring, paddr); } @@ -10342,8 +10342,7 @@ __lpfc_sli_issue_fcp_io_s4(struct lpfc_hba *phba, uint32_t ring_number, struct lpfc_iocbq *piocb, uint32_t flag) { int rc; - struct lpfc_io_buf *lpfc_cmd = - (struct lpfc_io_buf *)piocb->context1; + struct lpfc_io_buf *lpfc_cmd = piocb->io_buf; lpfc_prep_embed_io(phba, lpfc_cmd); rc = lpfc_sli4_issue_wqe(phba, lpfc_cmd->hdwq, piocb); @@ -10989,7 +10988,7 @@ lpfc_sli4_calc_ring(struct lpfc_hba *phba, struct lpfc_iocbq *piocb) * be setup based on what work queue we used. */ if (!(piocb->cmd_flag & LPFC_USE_FCPWQIDX)) { - lpfc_cmd = (struct lpfc_io_buf *)piocb->context1; + lpfc_cmd = piocb->io_buf; piocb->hba_wqidx = lpfc_cmd->hdwq_no; } return phba->sli4_hba.hdwq[piocb->hba_wqidx].io_wq->pring; @@ -12063,7 +12062,7 @@ void lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, struct lpfc_iocbq *rspiocb) { - struct lpfc_nodelist *ndlp = NULL; + struct lpfc_nodelist *ndlp = cmdiocb->ndlp; IOCB_t *irsp; LPFC_MBOXQ_t *mbox; struct lpfc_dmabuf *mp; @@ -12098,20 +12097,17 @@ lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, /* ELS cmd tag completes */ lpfc_printf_log(phba, KERN_INFO, LOG_ELS, "0139 Ignoring ELS cmd code x%x completion Data: " - "x%x x%x x%x\n", - ulp_command, ulp_status, ulp_word4, iotag); - + "x%x x%x x%x x%px\n", + ulp_command, ulp_status, ulp_word4, iotag, + cmdiocb->ndlp); /* * Deref the ndlp after free_iocb. sli_release_iocb will access the ndlp * if exchange is busy. */ - if (ulp_command == CMD_GEN_REQUEST64_CR) { - ndlp = cmdiocb->context_un.ndlp; + if (ulp_command == CMD_GEN_REQUEST64_CR) lpfc_ct_free_iocb(phba, cmdiocb); - } else { - ndlp = (struct lpfc_nodelist *) cmdiocb->context1; + else lpfc_els_free_iocb(phba, cmdiocb); - } lpfc_nlp_put(ndlp); } @@ -12192,7 +12188,7 @@ lpfc_sli_issue_abort_iotag(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, } else { iotag = cmdiocb->iocb.ulpIoTag; if (pring->ringno == LPFC_ELS_RING) { - ndlp = (struct lpfc_nodelist *)(cmdiocb->context1); + ndlp = cmdiocb->ndlp; ulp_context = ndlp->nlp_rpi; } else { ulp_context = cmdiocb->iocb.ulpContext; @@ -12650,7 +12646,7 @@ lpfc_sli_abort_taskmgmt(struct lpfc_vport *vport, struct lpfc_sli_ring *pring, } else { iotag = iocbq->iocb.ulpIoTag; if (pring->ringno == LPFC_ELS_RING) { - ndlp = (struct lpfc_nodelist *)(iocbq->context1); + ndlp = iocbq->ndlp; ulp_context = ndlp->nlp_rpi; } else { ulp_context = iocbq->iocb.ulpContext; @@ -12755,8 +12751,8 @@ lpfc_sli_wake_iocb_wait(struct lpfc_hba *phba, /* Copy the contents of the local rspiocb into the caller's buffer. */ cmdiocbq->cmd_flag |= LPFC_IO_WAKE; - if (cmdiocbq->context2 && rspiocbq) - memcpy((char *)cmdiocbq->context2 + offset, + if (cmdiocbq->rsp_iocb && rspiocbq) + memcpy((char *)cmdiocbq->rsp_iocb + offset, (char *)rspiocbq + offset, sizeof(*rspiocbq) - offset); /* Set the exchange busy flag for task management commands */ @@ -12864,13 +12860,13 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba *phba, } else pring = &phba->sli.sli3_ring[ring_number]; /* - * If the caller has provided a response iocbq buffer, then context2 + * If the caller has provided a response iocbq buffer, then rsp_iocb * is NULL or its an error. */ if (prspiocbq) { - if (piocb->context2) + if (piocb->rsp_iocb) return IOCB_ERROR; - piocb->context2 = prspiocbq; + piocb->rsp_iocb = prspiocbq; } piocb->wait_cmd_cmpl = piocb->cmd_cmpl; @@ -12954,7 +12950,7 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba *phba, } if (prspiocbq) - piocb->context2 = NULL; + piocb->rsp_iocb = NULL; piocb->context_un.wait_queue = NULL; piocb->cmd_cmpl = NULL; @@ -18528,11 +18524,8 @@ lpfc_sli4_seq_abort_rsp_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmd_iocbq, struct lpfc_iocbq *rsp_iocbq) { - struct lpfc_nodelist *ndlp; - if (cmd_iocbq) { - ndlp = (struct lpfc_nodelist *)cmd_iocbq->context1; - lpfc_nlp_put(ndlp); + lpfc_nlp_put(cmd_iocbq->ndlp); lpfc_sli_release_iocbq(phba, cmd_iocbq); } @@ -18616,8 +18609,8 @@ lpfc_sli4_seq_abort_rsp(struct lpfc_vport *vport, /* Extract the F_CTL field from FC_HDR */ fctl = sli4_fctl_from_fc_hdr(fc_hdr); - ctiocb->context1 = lpfc_nlp_get(ndlp); - if (!ctiocb->context1) { + ctiocb->ndlp = lpfc_nlp_get(ndlp); + if (!ctiocb->ndlp) { lpfc_sli_release_iocbq(phba, ctiocb); return; } @@ -18708,7 +18701,7 @@ lpfc_sli4_seq_abort_rsp(struct lpfc_vport *vport, ctiocb->abort_rctl, oxid, phba->link_state); lpfc_nlp_put(ndlp); - ctiocb->context1 = NULL; + ctiocb->ndlp = NULL; lpfc_sli_release_iocbq(phba, ctiocb); } } @@ -18860,8 +18853,8 @@ lpfc_prep_seq(struct lpfc_vport *vport, struct hbq_dmabuf *seq_dmabuf) tot_len = bf_get(lpfc_rcqe_length, &seq_dmabuf->cq_event.cqe.rcqe_cmpl); - first_iocbq->context2 = &seq_dmabuf->dbuf; - first_iocbq->context3 = NULL; + first_iocbq->cmd_dmabuf = &seq_dmabuf->dbuf; + first_iocbq->bpl_dmabuf = NULL; /* Keep track of the BDE count */ first_iocbq->wcqe_cmpl.word3 = 1; @@ -18885,8 +18878,8 @@ lpfc_prep_seq(struct lpfc_vport *vport, struct hbq_dmabuf *seq_dmabuf) lpfc_in_buf_free(vport->phba, d_buf); continue; } - if (!iocbq->context3) { - iocbq->context3 = d_buf; + if (!iocbq->bpl_dmabuf) { + iocbq->bpl_dmabuf = d_buf; iocbq->wcqe_cmpl.word3++; /* We need to get the size out of the right CQE */ hbq_buf = container_of(d_buf, struct hbq_dmabuf, dbuf); @@ -18912,8 +18905,8 @@ lpfc_prep_seq(struct lpfc_vport *vport, struct hbq_dmabuf *seq_dmabuf) hbq_buf = container_of(d_buf, struct hbq_dmabuf, dbuf); len = bf_get(lpfc_rcqe_length, &hbq_buf->cq_event.cqe.rcqe_cmpl); - iocbq->context2 = d_buf; - iocbq->context3 = NULL; + iocbq->cmd_dmabuf = d_buf; + iocbq->bpl_dmabuf = NULL; iocbq->wcqe_cmpl.word3 = 1; if (len > LPFC_DATA_BUF_SIZE) @@ -18978,7 +18971,7 @@ static void lpfc_sli4_mds_loopback_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, struct lpfc_iocbq *rspiocb) { - struct lpfc_dmabuf *pcmd = cmdiocb->context2; + struct lpfc_dmabuf *pcmd = cmdiocb->cmd_dmabuf; if (pcmd && pcmd->virt) dma_pool_free(phba->lpfc_drb_pool, pcmd->virt, pcmd->phys); @@ -19029,7 +19022,7 @@ lpfc_sli4_handle_mds_loopback(struct lpfc_vport *vport, /* copyin the payload */ memcpy(pcmd->virt, dmabuf->dbuf.virt, frame_len); - iocbq->context2 = pcmd; + iocbq->cmd_dmabuf = pcmd; iocbq->vport = vport; iocbq->cmd_flag &= ~LPFC_FIP_ELS_ID_MASK; iocbq->cmd_flag |= LPFC_USE_FCPWQIDX; @@ -20904,8 +20897,8 @@ lpfc_wqe_bpl2sgl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeq, * have not been byteswapped yet so there is no * need to swap them back. */ - if (pwqeq->context3) - dmabuf = (struct lpfc_dmabuf *)pwqeq->context3; + if (pwqeq->bpl_dmabuf) + dmabuf = pwqeq->bpl_dmabuf; else return xritag; @@ -21057,7 +21050,7 @@ lpfc_sli4_issue_wqe(struct lpfc_hba *phba, struct lpfc_sli4_hdw_queue *qp, wq = qp->io_wq; pring = wq->pring; - ctxp = pwqe->context2; + ctxp = pwqe->context_un.axchg; sglq = ctxp->ctxbuf->sglq; if (pwqe->sli4_xritag == NO_XRI) { pwqe->sli4_lxritag = sglq->sli4_lxritag; @@ -22252,7 +22245,6 @@ lpfc_sli_prep_wqe(struct lpfc_hba *phba, struct lpfc_iocbq *job) u32 fip, abort_tag; struct lpfc_nodelist *ndlp = NULL; union lpfc_wqe128 *wqe = &job->wqe; - struct lpfc_dmabuf *context2; u32 els_id = LPFC_ELS_ID_DEFAULT; u8 command_type = ELS_COMMAND_NON_FIP; @@ -22270,10 +22262,7 @@ lpfc_sli_prep_wqe(struct lpfc_hba *phba, struct lpfc_iocbq *job) switch (cmnd) { case CMD_ELS_REQUEST64_WQE: - if (job->cmd_flag & LPFC_IO_LIBDFC) - ndlp = job->context_un.ndlp; - else - ndlp = (struct lpfc_nodelist *)job->context1; + ndlp = job->ndlp; /* CCP CCPE PV PRI in word10 were set in the memcpy */ if (command_type == ELS_COMMAND_FIP) @@ -22283,8 +22272,7 @@ lpfc_sli_prep_wqe(struct lpfc_hba *phba, struct lpfc_iocbq *job) if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); if (if_type >= LPFC_SLI_INTF_IF_TYPE_2) { - context2 = (struct lpfc_dmabuf *)job->context2; - pcmd = (u32 *)context2->virt; + pcmd = (u32 *)job->cmd_dmabuf->virt; if (pcmd && (*pcmd == ELS_CMD_FLOGI || *pcmd == ELS_CMD_SCR || *pcmd == ELS_CMD_RDF || @@ -22307,7 +22295,7 @@ lpfc_sli_prep_wqe(struct lpfc_hba *phba, struct lpfc_iocbq *job) bf_set(wqe_ct, &wqe->els_req.wqe_com, 1); bf_set(wqe_ctxt_tag, &wqe->els_req.wqe_com, phba->vpi_ids[job->vport->vpi]); - } else if (pcmd) { + } else if (pcmd && ndlp) { bf_set(wqe_ct, &wqe->els_req.wqe_com, 0); bf_set(wqe_ctxt_tag, &wqe->els_req.wqe_com, phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]); @@ -22325,7 +22313,7 @@ lpfc_sli_prep_wqe(struct lpfc_hba *phba, struct lpfc_iocbq *job) bf_set(wqe_ebde_cnt, &wqe->els_req.wqe_com, 0); break; case CMD_XMIT_ELS_RSP64_WQE: - ndlp = (struct lpfc_nodelist *)job->context1; + ndlp = job->ndlp; /* word4 */ wqe->xmit_els_rsp.word4 = 0; diff --git a/drivers/scsi/lpfc/lpfc_sli.h b/drivers/scsi/lpfc/lpfc_sli.h index 663cc90a8798..776eb4ab52d2 100644 --- a/drivers/scsi/lpfc/lpfc_sli.h +++ b/drivers/scsi/lpfc/lpfc_sli.h @@ -77,11 +77,15 @@ struct lpfc_iocbq { u32 unsol_rcv_len; /* Receive len in usol path */ - uint8_t num_bdes; - uint8_t abort_bls; /* ABTS by initiator or responder */ - u8 abort_rctl; /* ACC or RJT flag */ - uint8_t priority; /* OAS priority */ - uint8_t retry; /* retry counter for IOCB cmd - if needed */ + /* Pack the u8's together and make them module-4. */ + u8 num_bdes; /* Number of BDEs */ + u8 abort_bls; /* ABTS by initiator or responder */ + u8 abort_rctl; /* ACC or RJT flag */ + u8 priority; /* OAS priority */ + u8 retry; /* retry counter for IOCB cmd - if needed */ + u8 rsvd1; /* Pad for u32 */ + u8 rsvd2; /* Pad for u32 */ + u8 rsvd3; /* Pad for u32 */ u32 cmd_flag; #define LPFC_IO_LIBDFC 1 /* libdfc iocb */ @@ -116,18 +120,22 @@ struct lpfc_iocbq { uint32_t drvrTimeout; /* driver timeout in seconds */ struct lpfc_vport *vport;/* virtual port pointer */ - void *context1; /* caller context information */ - void *context2; /* caller context information */ - void *context3; /* caller context information */ + struct lpfc_dmabuf *cmd_dmabuf; + struct lpfc_dmabuf *rsp_dmabuf; + struct lpfc_dmabuf *bpl_dmabuf; uint32_t event_tag; /* LA Event tag */ union { wait_queue_head_t *wait_queue; - struct lpfc_iocbq *rsp_iocb; struct lpfcMboxq *mbox; - struct lpfc_nodelist *ndlp; struct lpfc_node_rrq *rrq; + struct nvmefc_ls_req *nvme_lsreq; + struct lpfc_async_xchg_ctx *axchg; + struct bsg_job_data *dd_data; } context_un; + struct lpfc_io_buf *io_buf; + struct lpfc_iocbq *rsp_iocb; + struct lpfc_nodelist *ndlp; union lpfc_vmid_tag vmid_tag; void (*fabric_cmd_cmpl)(struct lpfc_hba *phba, struct lpfc_iocbq *cmd, struct lpfc_iocbq *rsp); From ef47575fd982c7ed1993fbe104909722afa1994b Mon Sep 17 00:00:00 2001 From: James Smart Date: Tue, 12 Apr 2022 15:20:03 -0700 Subject: [PATCH 026/177] scsi: lpfc: Refactor cleanup of mailbox commands The intention of this patch is to refactor mailbox memory allocation and cleanup steps in one routine respectively to prevent memory leaks or memory errors related to mailbox commands. There are trivial localized fixes as well. Provide lpfc_mbox_rsrc_prep() - this routine allocates the dmabuf and the mbuf associated with it. It also catches allocation errors and returns status. Provide lpfc_mbox_rsrc_cleanup() - this routine verifies a dmabuf exists and if so releases the associated mbuf and the dmabuf memory. It then sets the ctx_buf to NULL and releases the mailbox memory to the mailbox pool. Link: https://lore.kernel.org/r/20220412222008.126521-22-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_crtn.h | 4 +- drivers/scsi/lpfc/lpfc_els.c | 105 ++++----------- drivers/scsi/lpfc/lpfc_hbadisc.c | 124 +++++------------- drivers/scsi/lpfc/lpfc_init.c | 83 ++++-------- drivers/scsi/lpfc/lpfc_mbox.c | 201 +++++++++++++++++------------ drivers/scsi/lpfc/lpfc_nportdisc.c | 36 ++---- drivers/scsi/lpfc/lpfc_sli.c | 55 ++------ drivers/scsi/lpfc/lpfc_sli.h | 6 + drivers/scsi/lpfc/lpfc_vport.c | 29 ++--- 9 files changed, 248 insertions(+), 395 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h index 9897a1aa387b..6f88fd0df8b0 100644 --- a/drivers/scsi/lpfc/lpfc_crtn.h +++ b/drivers/scsi/lpfc/lpfc_crtn.h @@ -32,7 +32,9 @@ int lpfc_dump_static_vport(struct lpfc_hba *, LPFC_MBOXQ_t *, uint16_t); int lpfc_sli4_dump_cfg_rg23(struct lpfc_hba *, struct lpfcMboxq *); void lpfc_read_nv(struct lpfc_hba *, LPFC_MBOXQ_t *); void lpfc_config_async(struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t); - +int lpfc_mbox_rsrc_prep(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox); +void lpfc_mbox_rsrc_cleanup(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox, + enum lpfc_mbox_ctx locked); void lpfc_heart_beat(struct lpfc_hba *, LPFC_MBOXQ_t *); int lpfc_read_topology(struct lpfc_hba *, LPFC_MBOXQ_t *, struct lpfc_dmabuf *); void lpfc_clear_la(struct lpfc_hba *, LPFC_MBOXQ_t *); diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index b84fa46a6889..527f2c148e04 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -345,7 +345,6 @@ lpfc_issue_fabric_reglogin(struct lpfc_vport *vport) { struct lpfc_hba *phba = vport->phba; LPFC_MBOXQ_t *mbox; - struct lpfc_dmabuf *mp; struct lpfc_nodelist *ndlp; struct serv_parm *sp; int rc; @@ -395,7 +394,7 @@ lpfc_issue_fabric_reglogin(struct lpfc_vport *vport) mbox->ctx_ndlp = lpfc_nlp_get(ndlp); if (!mbox->ctx_ndlp) { err = 6; - goto fail_no_ndlp; + goto fail_free_mbox; } rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); @@ -411,13 +410,8 @@ fail_issue_reg_login: * for the failed mbox command. */ lpfc_nlp_put(ndlp); -fail_no_ndlp: - mp = (struct lpfc_dmabuf *)mbox->ctx_buf; - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); fail_free_mbox: - mempool_free(mbox, phba->mbox_mem_pool); - + lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED); fail: lpfc_vport_set_state(vport, FC_VPORT_FAILED); lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, @@ -465,45 +459,37 @@ lpfc_issue_reg_vfi(struct lpfc_vport *vport) /* Supply CSP's only if we are fabric connect or pt-to-pt connect */ if ((vport->fc_flag & FC_FABRIC) || (vport->fc_flag & FC_PT2PT)) { - dmabuf = kzalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); - if (!dmabuf) { + rc = lpfc_mbox_rsrc_prep(phba, mboxq); + if (rc) { rc = -ENOMEM; - goto fail; - } - dmabuf->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &dmabuf->phys); - if (!dmabuf->virt) { - rc = -ENOMEM; - goto fail; + goto fail_mbox; } + dmabuf = mboxq->ctx_buf; memcpy(dmabuf->virt, &phba->fc_fabparam, sizeof(struct serv_parm)); } vport->port_state = LPFC_FABRIC_CFG_LINK; - if (dmabuf) + if (dmabuf) { lpfc_reg_vfi(mboxq, vport, dmabuf->phys); - else + /* lpfc_reg_vfi memsets the mailbox. Restore the ctx_buf. */ + mboxq->ctx_buf = dmabuf; + } else { lpfc_reg_vfi(mboxq, vport, 0); + } mboxq->mbox_cmpl = lpfc_mbx_cmpl_reg_vfi; mboxq->vport = vport; - mboxq->ctx_buf = dmabuf; rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_NOWAIT); if (rc == MBX_NOT_FINISHED) { rc = -ENXIO; - goto fail; + goto fail_mbox; } return 0; +fail_mbox: + lpfc_mbox_rsrc_cleanup(phba, mboxq, MBOX_THD_UNLOCKED); fail: - if (mboxq) - mempool_free(mboxq, phba->mbox_mem_pool); - if (dmabuf) { - if (dmabuf->virt) - lpfc_mbuf_free(phba, dmabuf->virt, dmabuf->phys); - kfree(dmabuf); - } - lpfc_vport_set_state(vport, FC_VPORT_FAILED); lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, "0289 Issue Register VFI failed: Err %d\n", rc); @@ -3252,7 +3238,6 @@ lpfc_reg_fab_ctrl_node(struct lpfc_vport *vport, struct lpfc_nodelist *fc_ndlp) struct lpfc_hba *phba = vport->phba; struct lpfc_nodelist *ns_ndlp; LPFC_MBOXQ_t *mbox; - struct lpfc_dmabuf *mp; if (fc_ndlp->nlp_flag & NLP_RPI_REGISTERED) return rc; @@ -3289,7 +3274,7 @@ lpfc_reg_fab_ctrl_node(struct lpfc_vport *vport, struct lpfc_nodelist *fc_ndlp) mbox->ctx_ndlp = lpfc_nlp_get(fc_ndlp); if (!mbox->ctx_ndlp) { rc = -ENOMEM; - goto out_mem; + goto out; } mbox->vport = vport; @@ -3297,21 +3282,15 @@ lpfc_reg_fab_ctrl_node(struct lpfc_vport *vport, struct lpfc_nodelist *fc_ndlp) if (rc == MBX_NOT_FINISHED) { rc = -ENODEV; lpfc_nlp_put(fc_ndlp); - goto out_mem; + goto out; } /* Success path. Exit. */ lpfc_nlp_set_state(vport, fc_ndlp, NLP_STE_REG_LOGIN_ISSUE); return 0; - out_mem: - fc_ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND; - mp = (struct lpfc_dmabuf *)mbox->ctx_buf; - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); - out: - mempool_free(mbox, phba->mbox_mem_pool); + lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED); lpfc_printf_vlog(vport, KERN_ERR, LOG_NODE, "0938 %s: failed to format reg_login " "Data: x%x x%x x%x x%x\n", __func__, @@ -5248,14 +5227,10 @@ lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, void lpfc_mbx_cmpl_dflt_rpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) { - struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)(pmb->ctx_buf); struct lpfc_nodelist *ndlp = pmb->ctx_ndlp; u32 mbx_flag = pmb->mbox_flag; u32 mbx_cmd = pmb->u.mb.mbxCommand; - pmb->ctx_buf = NULL; - pmb->ctx_ndlp = NULL; - if (ndlp) { lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_NODE, "0006 rpi x%x DID:%x flg:%x %d x%px " @@ -5278,10 +5253,7 @@ lpfc_mbx_cmpl_dflt_rpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) lpfc_drop_node(ndlp->vport, ndlp); } - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); - mempool_free(pmb, phba->mbox_mem_pool); - return; + lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED); } /** @@ -5306,7 +5278,6 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, struct Scsi_Host *shost = vport ? lpfc_shost_from_vport(vport) : NULL; IOCB_t *irsp; LPFC_MBOXQ_t *mbox = NULL; - struct lpfc_dmabuf *mp = NULL; u32 ulp_status, ulp_word4, tmo, did, iotag; if (!vport) { @@ -5332,14 +5303,8 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, /* Check to see if link went down during discovery */ if (!ndlp || lpfc_els_chk_latt(vport)) { - if (mbox) { - mp = (struct lpfc_dmabuf *)mbox->ctx_buf; - if (mp) { - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); - } - mempool_free(mbox, phba->mbox_mem_pool); - } + if (mbox) + lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED); goto out; } @@ -5370,14 +5335,7 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, ndlp->nlp_state, ndlp->nlp_rpi, ndlp->nlp_flag); - mp = mbox->ctx_buf; - if (mp) { - lpfc_mbuf_free(phba, mp->virt, - mp->phys); - kfree(mp); - } - mempool_free(mbox, phba->mbox_mem_pool); - goto out; + goto out_free_mbox; } } @@ -5386,7 +5344,7 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, */ mbox->ctx_ndlp = lpfc_nlp_get(ndlp); if (!mbox->ctx_ndlp) - goto out; + goto out_free_mbox; mbox->vport = vport; if (ndlp->nlp_flag & NLP_RM_DFLT_RPI) { @@ -5418,12 +5376,8 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); } - mp = (struct lpfc_dmabuf *)mbox->ctx_buf; - if (mp) { - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); - } - mempool_free(mbox, phba->mbox_mem_pool); +out_free_mbox: + lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED); } out: if (ndlp && shost) { @@ -7188,7 +7142,6 @@ static int lpfc_get_rdp_info(struct lpfc_hba *phba, struct lpfc_rdp_context *rdp_context) { LPFC_MBOXQ_t *mbox = NULL; - struct lpfc_dmabuf *mp; int rc; mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); @@ -7199,21 +7152,19 @@ lpfc_get_rdp_info(struct lpfc_hba *phba, struct lpfc_rdp_context *rdp_context) } if (lpfc_sli4_dump_page_a0(phba, mbox)) - goto prep_mbox_fail; + goto rdp_fail; mbox->vport = rdp_context->ndlp->vport; mbox->mbox_cmpl = lpfc_mbx_cmpl_rdp_page_a0; mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context; rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); if (rc == MBX_NOT_FINISHED) { - mp = (struct lpfc_dmabuf *)mbox->ctx_buf; - lpfc_mbuf_free(phba, mp->virt, mp->phys); - goto issue_mbox_fail; + lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED); + return 1; } return 0; -prep_mbox_fail: -issue_mbox_fail: +rdp_fail: mempool_free(mbox, phba->mbox_mem_pool); return 1; } diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index 46a01801186b..f2baf3bd8dd8 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c @@ -1459,7 +1459,6 @@ lpfc_mbx_cmpl_local_config_link(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) { struct lpfc_vport *vport = pmb->vport; LPFC_MBOXQ_t *sparam_mb; - struct lpfc_dmabuf *sparam_mp; u16 status = pmb->u.mb.mbxStatus; int rc; @@ -1508,13 +1507,8 @@ lpfc_mbx_cmpl_local_config_link(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) sparam_mb->mbox_cmpl = lpfc_mbx_cmpl_read_sparam; rc = lpfc_sli_issue_mbox(phba, sparam_mb, MBX_NOWAIT); if (rc == MBX_NOT_FINISHED) { - sparam_mp = (struct lpfc_dmabuf *) - sparam_mb->ctx_buf; - lpfc_mbuf_free(phba, sparam_mp->virt, - sparam_mp->phys); - kfree(sparam_mp); - sparam_mb->ctx_buf = NULL; - mempool_free(sparam_mb, phba->mbox_mem_pool); + lpfc_mbox_rsrc_cleanup(phba, sparam_mb, + MBOX_THD_UNLOCKED); goto sparam_out; } @@ -3313,7 +3307,6 @@ lpfc_start_fdiscs(struct lpfc_hba *phba) void lpfc_mbx_cmpl_reg_vfi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) { - struct lpfc_dmabuf *dmabuf = mboxq->ctx_buf; struct lpfc_vport *vport = mboxq->vport; struct Scsi_Host *shost = lpfc_shost_from_vport(vport); @@ -3394,12 +3387,7 @@ lpfc_mbx_cmpl_reg_vfi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) } out_free_mem: - mempool_free(mboxq, phba->mbox_mem_pool); - if (dmabuf) { - lpfc_mbuf_free(phba, dmabuf->virt, dmabuf->phys); - kfree(dmabuf); - } - return; + lpfc_mbox_rsrc_cleanup(phba, mboxq, MBOX_THD_UNLOCKED); } static void @@ -3444,9 +3432,7 @@ lpfc_mbx_cmpl_read_sparam(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) memcpy(&phba->wwpn, &vport->fc_portname, sizeof(phba->wwnn)); } - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); - mempool_free(pmb, phba->mbox_mem_pool); + lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED); /* Check if sending the FLOGI is being deferred to after we get * up to date CSPs from MBX_READ_SPARAM. @@ -3458,12 +3444,8 @@ lpfc_mbx_cmpl_read_sparam(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) return; out: - pmb->ctx_buf = NULL; - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); + lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED); lpfc_issue_clear_la(phba, vport); - mempool_free(pmb, phba->mbox_mem_pool); - return; } static void @@ -3473,7 +3455,6 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, struct lpfc_mbx_read_top *la) LPFC_MBOXQ_t *sparam_mbox, *cfglink_mbox = NULL; struct Scsi_Host *shost; int i; - struct lpfc_dmabuf *mp; int rc; struct fcf_record *fcf_record; uint32_t fc_flags = 0; @@ -3601,10 +3582,7 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, struct lpfc_mbx_read_top *la) sparam_mbox->mbox_cmpl = lpfc_mbx_cmpl_read_sparam; rc = lpfc_sli_issue_mbox(phba, sparam_mbox, MBX_NOWAIT); if (rc == MBX_NOT_FINISHED) { - mp = (struct lpfc_dmabuf *)sparam_mbox->ctx_buf; - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); - mempool_free(sparam_mbox, phba->mbox_mem_pool); + lpfc_mbox_rsrc_cleanup(phba, sparam_mbox, MBOX_THD_UNLOCKED); goto out; } @@ -3880,10 +3858,7 @@ lpfc_mbx_cmpl_read_topology(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) } lpfc_mbx_cmpl_read_topology_free_mbuf: - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); - mempool_free(pmb, phba->mbox_mem_pool); - return; + lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED); } /* @@ -3896,9 +3871,13 @@ void lpfc_mbx_cmpl_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) { struct lpfc_vport *vport = pmb->vport; - struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)(pmb->ctx_buf); + struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)pmb->ctx_buf; struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; + /* The driver calls the state machine with the pmb pointer + * but wants to make sure a stale ctx_buf isn't acted on. + * The ctx_buf is restored later and cleaned up. + */ pmb->ctx_buf = NULL; pmb->ctx_ndlp = NULL; @@ -3935,10 +3914,9 @@ lpfc_mbx_cmpl_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) /* Call state machine */ lpfc_disc_state_machine(vport, ndlp, pmb, NLP_EVT_CMPL_REG_LOGIN); + pmb->ctx_buf = mp; + lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED); - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); - mempool_free(pmb, phba->mbox_mem_pool); /* decrement the node reference count held for this callback * function. */ @@ -4105,11 +4083,15 @@ lpfc_create_static_vport(struct lpfc_hba *phba) vport_buff = (uint8_t *) vport_info; do { - /* free dma buffer from previous round */ + /* While loop iteration forces a free dma buffer from + * the previous loop because the mbox is reused and + * the dump routine is a single-use construct. + */ if (pmb->ctx_buf) { mp = (struct lpfc_dmabuf *)pmb->ctx_buf; lpfc_mbuf_free(phba, mp->virt, mp->phys); kfree(mp); + pmb->ctx_buf = NULL; } if (lpfc_dump_static_vport(phba, pmb, offset)) goto out; @@ -4194,16 +4176,8 @@ lpfc_create_static_vport(struct lpfc_hba *phba) out: kfree(vport_info); - if (mbx_wait_rc != MBX_TIMEOUT) { - if (pmb->ctx_buf) { - mp = (struct lpfc_dmabuf *)pmb->ctx_buf; - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); - } - mempool_free(pmb, phba->mbox_mem_pool); - } - - return; + if (mbx_wait_rc != MBX_TIMEOUT) + lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED); } /* @@ -4217,22 +4191,16 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) { struct lpfc_vport *vport = pmb->vport; MAILBOX_t *mb = &pmb->u.mb; - struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)(pmb->ctx_buf); - struct lpfc_nodelist *ndlp; + struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; struct Scsi_Host *shost; - ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; pmb->ctx_ndlp = NULL; - pmb->ctx_buf = NULL; if (mb->mbxStatus) { lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, "0258 Register Fabric login error: 0x%x\n", mb->mbxStatus); - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); - mempool_free(pmb, phba->mbox_mem_pool); - + lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED); if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { /* FLOGI failed, use loop map to make discovery list */ lpfc_disc_list_loopmap(vport); @@ -4274,9 +4242,7 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) lpfc_do_scr_ns_plogi(phba, vport); } - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); - mempool_free(pmb, phba->mbox_mem_pool); + lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED); /* Drop the reference count from the mbox at the end after * all the current reference to the ndlp have been done. @@ -4370,12 +4336,10 @@ void lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) { MAILBOX_t *mb = &pmb->u.mb; - struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)(pmb->ctx_buf); struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; struct lpfc_vport *vport = pmb->vport; int rc; - pmb->ctx_buf = NULL; pmb->ctx_ndlp = NULL; vport->gidft_inp = 0; @@ -4389,9 +4353,7 @@ out: * callback function. */ lpfc_nlp_put(ndlp); - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); - mempool_free(pmb, phba->mbox_mem_pool); + lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED); /* If the node is not registered with the scsi or nvme * transport, remove the fabric node. The failed reg_login @@ -4480,10 +4442,7 @@ out: * callback function. */ lpfc_nlp_put(ndlp); - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); - mempool_free(pmb, phba->mbox_mem_pool); - + lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED); return; } @@ -4497,13 +4456,9 @@ lpfc_mbx_cmpl_fc_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) { struct lpfc_vport *vport = pmb->vport; MAILBOX_t *mb = &pmb->u.mb; - struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)(pmb->ctx_buf); - struct lpfc_nodelist *ndlp; + struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; - ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; pmb->ctx_ndlp = NULL; - pmb->ctx_buf = NULL; - if (mb->mbxStatus) { lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, "0933 %s: Register FC login error: 0x%x\n", @@ -4527,9 +4482,7 @@ lpfc_mbx_cmpl_fc_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE); out: - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); - mempool_free(pmb, phba->mbox_mem_pool); + lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED); /* Drop the reference count from the mbox at the end after * all the current reference to the ndlp have been done. @@ -5570,7 +5523,6 @@ lpfc_cleanup_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) { struct lpfc_hba *phba = vport->phba; LPFC_MBOXQ_t *mb, *nextmb; - struct lpfc_dmabuf *mp; /* Cleanup node for NPort */ lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE, @@ -5608,16 +5560,11 @@ lpfc_cleanup_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) && !(mb->mbox_flag & LPFC_MBX_IMED_UNREG) && (ndlp == (struct lpfc_nodelist *)mb->ctx_ndlp)) { - mp = (struct lpfc_dmabuf *)(mb->ctx_buf); - if (mp) { - __lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); - } list_del(&mb->list); - mempool_free(mb, phba->mbox_mem_pool); - /* We shall not invoke the lpfc_nlp_put to decrement - * the ndlp reference count as we are in the process - * of lpfc_nlp_release. + lpfc_mbox_rsrc_cleanup(phba, mb, MBOX_THD_LOCKED); + + /* Don't invoke lpfc_nlp_put. The driver is in + * lpfc_nlp_release context. */ } } @@ -6462,11 +6409,9 @@ void lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) { MAILBOX_t *mb = &pmb->u.mb; - struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)(pmb->ctx_buf); struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; struct lpfc_vport *vport = pmb->vport; - pmb->ctx_buf = NULL; pmb->ctx_ndlp = NULL; if (phba->sli_rev < LPFC_SLI_REV4) @@ -6497,10 +6442,7 @@ lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) * function. */ lpfc_nlp_put(ndlp); - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); - mempool_free(pmb, phba->mbox_mem_pool); - + lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED); return; } diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 590ebf0008ac..fad7ad90c57f 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -443,15 +443,16 @@ lpfc_config_port_post(struct lpfc_hba *phba) "READ_SPARM mbxStatus x%x\n", mb->mbxCommand, mb->mbxStatus); phba->link_state = LPFC_HBA_ERROR; - mp = (struct lpfc_dmabuf *)pmb->ctx_buf; - mempool_free(pmb, phba->mbox_mem_pool); - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); + lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED); return -EIO; } mp = (struct lpfc_dmabuf *)pmb->ctx_buf; + /* This dmabuf was allocated by lpfc_read_sparam. The dmabuf is no + * longer needed. Prevent unintended ctx_buf access as the mbox is + * reused. + */ memcpy(&vport->fc_sparam, mp->virt, sizeof (struct serv_parm)); lpfc_mbuf_free(phba, mp->virt, mp->phys); kfree(mp); @@ -2182,7 +2183,6 @@ lpfc_handle_latt(struct lpfc_hba *phba) struct lpfc_sli *psli = &phba->sli; LPFC_MBOXQ_t *pmb; volatile uint32_t control; - struct lpfc_dmabuf *mp; int rc = 0; pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); @@ -2191,23 +2191,17 @@ lpfc_handle_latt(struct lpfc_hba *phba) goto lpfc_handle_latt_err_exit; } - mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); - if (!mp) { + rc = lpfc_mbox_rsrc_prep(phba, pmb); + if (rc) { rc = 2; - goto lpfc_handle_latt_free_pmb; - } - - mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys); - if (!mp->virt) { - rc = 3; - goto lpfc_handle_latt_free_mp; + mempool_free(pmb, phba->mbox_mem_pool); + goto lpfc_handle_latt_err_exit; } /* Cleanup any outstanding ELS commands */ lpfc_els_flush_all_cmd(phba); - psli->slistat.link_event++; - lpfc_read_topology(phba, pmb, mp); + lpfc_read_topology(phba, pmb, (struct lpfc_dmabuf *)pmb->ctx_buf); pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology; pmb->vport = vport; /* Block ELS IOCBs until we have processed this mbox command */ @@ -2228,11 +2222,7 @@ lpfc_handle_latt(struct lpfc_hba *phba) lpfc_handle_latt_free_mbuf: phba->sli.sli3_ring[LPFC_ELS_RING].flag &= ~LPFC_STOP_IOCB_EVENT; - lpfc_mbuf_free(phba, mp->virt, mp->phys); -lpfc_handle_latt_free_mp: - kfree(mp); -lpfc_handle_latt_free_pmb: - mempool_free(pmb, phba->mbox_mem_pool); + lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED); lpfc_handle_latt_err_exit: /* Enable Link attention interrupts */ spin_lock_irq(&phba->hbalock); @@ -5315,7 +5305,6 @@ static void lpfc_sli4_async_link_evt(struct lpfc_hba *phba, struct lpfc_acqe_link *acqe_link) { - struct lpfc_dmabuf *mp; LPFC_MBOXQ_t *pmb; MAILBOX_t *mb; struct lpfc_mbx_read_top *la; @@ -5332,18 +5321,13 @@ lpfc_sli4_async_link_evt(struct lpfc_hba *phba, "0395 The mboxq allocation failed\n"); return; } - mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); - if (!mp) { + + rc = lpfc_mbox_rsrc_prep(phba, pmb); + if (rc) { lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, - "0396 The lpfc_dmabuf allocation failed\n"); + "0396 mailbox allocation failed\n"); goto out_free_pmb; } - mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys); - if (!mp->virt) { - lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, - "0397 The mbuf allocation failed\n"); - goto out_free_dmabuf; - } /* Cleanup any outstanding ELS commands */ lpfc_els_flush_all_cmd(phba); @@ -5355,7 +5339,7 @@ lpfc_sli4_async_link_evt(struct lpfc_hba *phba, phba->sli.slistat.link_event++; /* Create lpfc_handle_latt mailbox command from link ACQE */ - lpfc_read_topology(phba, pmb, mp); + lpfc_read_topology(phba, pmb, (struct lpfc_dmabuf *)pmb->ctx_buf); pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology; pmb->vport = phba->pport; @@ -5393,10 +5377,8 @@ lpfc_sli4_async_link_evt(struct lpfc_hba *phba, */ if (!(phba->hba_flag & HBA_FCOE_MODE)) { rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); - if (rc == MBX_NOT_FINISHED) { - lpfc_mbuf_free(phba, mp->virt, mp->phys); - goto out_free_dmabuf; - } + if (rc == MBX_NOT_FINISHED) + goto out_free_pmb; return; } /* @@ -5431,10 +5413,8 @@ lpfc_sli4_async_link_evt(struct lpfc_hba *phba, return; -out_free_dmabuf: - kfree(mp); out_free_pmb: - mempool_free(pmb, phba->mbox_mem_pool); + lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED); } /** @@ -6245,7 +6225,6 @@ lpfc_update_trunk_link_status(struct lpfc_hba *phba, static void lpfc_sli4_async_fc_evt(struct lpfc_hba *phba, struct lpfc_acqe_fc_la *acqe_fc) { - struct lpfc_dmabuf *mp; LPFC_MBOXQ_t *pmb; MAILBOX_t *mb; struct lpfc_mbx_read_top *la; @@ -6305,18 +6284,12 @@ lpfc_sli4_async_fc_evt(struct lpfc_hba *phba, struct lpfc_acqe_fc_la *acqe_fc) "2897 The mboxq allocation failed\n"); return; } - mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); - if (!mp) { + rc = lpfc_mbox_rsrc_prep(phba, pmb); + if (rc) { lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, - "2898 The lpfc_dmabuf allocation failed\n"); + "2898 The mboxq prep failed\n"); goto out_free_pmb; } - mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys); - if (!mp->virt) { - lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, - "2899 The mbuf allocation failed\n"); - goto out_free_dmabuf; - } /* Cleanup any outstanding ELS commands */ lpfc_els_flush_all_cmd(phba); @@ -6328,7 +6301,7 @@ lpfc_sli4_async_fc_evt(struct lpfc_hba *phba, struct lpfc_acqe_fc_la *acqe_fc) phba->sli.slistat.link_event++; /* Create lpfc_handle_latt mailbox command from link ACQE */ - lpfc_read_topology(phba, pmb, mp); + lpfc_read_topology(phba, pmb, (struct lpfc_dmabuf *)pmb->ctx_buf); pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology; pmb->vport = phba->pport; @@ -6372,16 +6345,12 @@ lpfc_sli4_async_fc_evt(struct lpfc_hba *phba, struct lpfc_acqe_fc_la *acqe_fc) } rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); - if (rc == MBX_NOT_FINISHED) { - lpfc_mbuf_free(phba, mp->virt, mp->phys); - goto out_free_dmabuf; - } + if (rc == MBX_NOT_FINISHED) + goto out_free_pmb; return; -out_free_dmabuf: - kfree(mp); out_free_pmb: - mempool_free(pmb, phba->mbox_mem_pool); + lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED); } /** diff --git a/drivers/scsi/lpfc/lpfc_mbox.c b/drivers/scsi/lpfc/lpfc_mbox.c index e1404ab5000d..712c8f6e4de2 100644 --- a/drivers/scsi/lpfc/lpfc_mbox.c +++ b/drivers/scsi/lpfc/lpfc_mbox.c @@ -43,6 +43,80 @@ #include "lpfc_crtn.h" #include "lpfc_compat.h" +/** + * lpfc_mbox_rsrc_prep - Prepare a mailbox with DMA buffer memory. + * @phba: pointer to lpfc hba data structure. + * @mbox: pointer to the driver internal queue element for mailbox command. + * + * A mailbox command consists of the pool memory for the command, @mbox, and + * one or more DMA buffers for the data transfer. This routine provides + * a standard framework for allocating the dma buffer and assigning to the + * @mbox. Callers should cleanup the mbox with a call to + * lpfc_mbox_rsrc_cleanup. + * + * The lpfc_mbuf_alloc routine acquires the hbalock so the caller is + * responsible to ensure the hbalock is released. Also note that the + * driver design is a single dmabuf/mbuf per mbox in the ctx_buf. + * + **/ +int +lpfc_mbox_rsrc_prep(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox) +{ + struct lpfc_dmabuf *mp; + + mp = kmalloc(sizeof(*mp), GFP_KERNEL); + if (!mp) + return -ENOMEM; + + mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys); + if (!mp->virt) { + kfree(mp); + return -ENOMEM; + } + + memset(mp->virt, 0, LPFC_BPL_SIZE); + + /* Initialization only. Driver does not use a list of dmabufs. */ + INIT_LIST_HEAD(&mp->list); + mbox->ctx_buf = mp; + return 0; +} + +/** + * lpfc_mbox_rsrc_cleanup - Free the mailbox DMA buffer and virtual memory. + * @phba: pointer to lpfc hba data structure. + * @mbox: pointer to the driver internal queue element for mailbox command. + * @locked: value that indicates if the hbalock is held (1) or not (0). + * + * A mailbox command consists of the pool memory for the command, @mbox, and + * possibly a DMA buffer for the data transfer. This routine provides + * a standard framework for releasing any dma buffers and freeing all + * memory resources in it as well as releasing the @mbox back to the @phba pool. + * Callers should use this routine for cleanup for all mailboxes prepped with + * lpfc_mbox_rsrc_prep. + * + **/ +void +lpfc_mbox_rsrc_cleanup(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox, + enum lpfc_mbox_ctx locked) +{ + struct lpfc_dmabuf *mp; + + mp = (struct lpfc_dmabuf *)mbox->ctx_buf; + mbox->ctx_buf = NULL; + + /* Release the generic BPL buffer memory. */ + if (mp) { + if (locked == MBOX_THD_LOCKED) + __lpfc_mbuf_free(phba, mp->virt, mp->phys); + else + lpfc_mbuf_free(phba, mp->virt, mp->phys); + kfree(mp); + } + + mempool_free(mbox, phba->mbox_mem_pool); +} + /** * lpfc_dump_static_vport - Dump HBA's static vport information. * @phba: pointer to lpfc hba data structure. @@ -61,6 +135,7 @@ lpfc_dump_static_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb, { MAILBOX_t *mb; struct lpfc_dmabuf *mp; + int rc; mb = &pmb->u.mb; @@ -79,22 +154,15 @@ lpfc_dump_static_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb, return 0; } - /* For SLI4 HBAs driver need to allocate memory */ - mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); - if (mp) - mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys); - - if (!mp || !mp->virt) { - kfree(mp); + rc = lpfc_mbox_rsrc_prep(phba, pmb); + if (rc) { lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, - "2605 lpfc_dump_static_vport: memory" - " allocation failed\n"); + "2605 %s: memory allocation failed\n", + __func__); return 1; } - memset(mp->virt, 0, LPFC_BPL_SIZE); - INIT_LIST_HEAD(&mp->list); - /* save address for completion */ - pmb->ctx_buf = (uint8_t *)mp; + + mp = pmb->ctx_buf; mb->un.varWords[3] = putPaddrLow(mp->phys); mb->un.varWords[4] = putPaddrHigh(mp->phys); mb->un.varDmp.sli4_length = sizeof(struct static_vport_info); @@ -606,26 +674,21 @@ lpfc_read_sparam(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb, int vpi) { struct lpfc_dmabuf *mp; MAILBOX_t *mb; + int rc; - mb = &pmb->u.mb; memset(pmb, 0, sizeof (LPFC_MBOXQ_t)); - mb->mbxOwner = OWN_HOST; - /* Get a buffer to hold the HBAs Service Parameters */ - - mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); - if (mp) - mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys); - if (!mp || !mp->virt) { - kfree(mp); - mb->mbxCommand = MBX_READ_SPARM64; - /* READ_SPARAM: no buffers */ + rc = lpfc_mbox_rsrc_prep(phba, pmb); + if (rc) { lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX, "0301 READ_SPARAM: no buffers\n"); - return (1); + return 1; } - INIT_LIST_HEAD(&mp->list); + + mp = pmb->ctx_buf; + mb = &pmb->u.mb; + mb->mbxOwner = OWN_HOST; mb->mbxCommand = MBX_READ_SPARM64; mb->un.varRdSparm.un.sp64.tus.f.bdeSize = sizeof (struct serv_parm); mb->un.varRdSparm.un.sp64.addrHigh = putPaddrHigh(mp->phys); @@ -633,9 +696,6 @@ lpfc_read_sparam(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb, int vpi) if (phba->sli_rev >= LPFC_SLI_REV3) mb->un.varRdSparm.vpi = phba->vpi_ids[vpi]; - /* save address for completion */ - pmb->ctx_buf = mp; - return (0); } @@ -756,6 +816,7 @@ lpfc_reg_rpi(struct lpfc_hba *phba, uint16_t vpi, uint32_t did, MAILBOX_t *mb = &pmb->u.mb; uint8_t *sparam; struct lpfc_dmabuf *mp; + int rc; memset(pmb, 0, sizeof (LPFC_MBOXQ_t)); @@ -766,12 +827,10 @@ lpfc_reg_rpi(struct lpfc_hba *phba, uint16_t vpi, uint32_t did, mb->un.varRegLogin.vpi = phba->vpi_ids[vpi]; mb->un.varRegLogin.did = did; mb->mbxOwner = OWN_HOST; + /* Get a buffer to hold NPorts Service Parameters */ - mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); - if (mp) - mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys); - if (!mp || !mp->virt) { - kfree(mp); + rc = lpfc_mbox_rsrc_prep(phba, pmb); + if (rc) { mb->mbxCommand = MBX_REG_LOGIN64; /* REG_LOGIN: no buffers */ lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX, @@ -779,15 +838,13 @@ lpfc_reg_rpi(struct lpfc_hba *phba, uint16_t vpi, uint32_t did, "rpi x%x\n", vpi, did, rpi); return 1; } - INIT_LIST_HEAD(&mp->list); - sparam = mp->virt; /* Copy param's into a new buffer */ + mp = pmb->ctx_buf; + sparam = mp->virt; memcpy(sparam, param, sizeof (struct serv_parm)); - /* save address for completion */ - pmb->ctx_buf = (uint8_t *)mp; - + /* Finish initializing the mailbox. */ mb->mbxCommand = MBX_REG_LOGIN64; mb->un.varRegLogin.un.sp64.tus.f.bdeSize = sizeof (struct serv_parm); mb->un.varRegLogin.un.sp64.addrHigh = putPaddrHigh(mp->phys); @@ -1723,7 +1780,9 @@ lpfc_sli4_mbx_sge_get(struct lpfcMboxq *mbox, uint32_t sgentry, * @phba: pointer to lpfc hba data structure. * @mbox: pointer to lpfc mbox command. * - * This routine frees SLI4 specific mailbox command for sending IOCTL command. + * This routine cleans up and releases an SLI4 mailbox command that was + * configured using lpfc_sli4_config. It accounts for the embedded and + * non-embedded config types. **/ void lpfc_sli4_mbox_cmd_free(struct lpfc_hba *phba, struct lpfcMboxq *mbox) @@ -2277,33 +2336,24 @@ lpfc_sli4_dump_cfg_rg23(struct lpfc_hba *phba, struct lpfcMboxq *mbox) { struct lpfc_dmabuf *mp = NULL; MAILBOX_t *mb; + int rc; memset(mbox, 0, sizeof(*mbox)); mb = &mbox->u.mb; - mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); - if (mp) - mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys); - - if (!mp || !mp->virt) { - kfree(mp); - /* dump config region 23 failed to allocate memory */ + rc = lpfc_mbox_rsrc_prep(phba, mbox); + if (rc) { lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX, - "2569 lpfc dump config region 23: memory" - " allocation failed\n"); + "2569 %s: memory allocation failed\n", + __func__); return 1; } - memset(mp->virt, 0, LPFC_BPL_SIZE); - INIT_LIST_HEAD(&mp->list); - - /* save address for completion */ - mbox->ctx_buf = (uint8_t *)mp; - mb->mbxCommand = MBX_DUMP_MEMORY; mb->un.varDmp.type = DMP_NV_PARAMS; mb->un.varDmp.region_id = DMP_REGION_23; mb->un.varDmp.sli4_length = DMP_RGN23_SIZE; + mp = mbox->ctx_buf; mb->un.varWords[3] = putPaddrLow(mp->phys); mb->un.varWords[4] = putPaddrHigh(mp->phys); return 0; @@ -2326,7 +2376,7 @@ lpfc_mbx_cmpl_rdp_link_stat(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) rc = SUCCESS; mbx_failed: - lpfc_sli4_mbox_cmd_free(phba, mboxq); + lpfc_mbox_rsrc_cleanup(phba, mboxq, MBOX_THD_UNLOCKED); rdp_context->cmpl(phba, rdp_context, rc); } @@ -2338,30 +2388,25 @@ lpfc_mbx_cmpl_rdp_page_a2(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox) (struct lpfc_rdp_context *)(mbox->ctx_ndlp); if (bf_get(lpfc_mqe_status, &mbox->u.mqe)) - goto error_mbuf_free; + goto error_mbox_free; lpfc_sli_bemem_bcopy(mp->virt, &rdp_context->page_a2, DMP_SFF_PAGE_A2_SIZE); - /* We don't need dma buffer for link stat. */ - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); - - memset(mbox, 0, sizeof(*mbox)); lpfc_read_lnk_stat(phba, mbox); mbox->vport = rdp_context->ndlp->vport; + + /* Save the dma buffer for cleanup in the final completion. */ + mbox->ctx_buf = mp; mbox->mbox_cmpl = lpfc_mbx_cmpl_rdp_link_stat; mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context; if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) == MBX_NOT_FINISHED) - goto error_cmd_free; + goto error_mbox_free; return; -error_mbuf_free: - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); -error_cmd_free: - lpfc_sli4_mbox_cmd_free(phba, mbox); +error_mbox_free: + lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED); rdp_context->cmpl(phba, rdp_context, FAILURE); } @@ -2409,9 +2454,7 @@ lpfc_mbx_cmpl_rdp_page_a0(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox) return; error: - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); - lpfc_sli4_mbox_cmd_free(phba, mbox); + lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED); rdp_context->cmpl(phba, rdp_context, FAILURE); } @@ -2427,27 +2470,19 @@ error: int lpfc_sli4_dump_page_a0(struct lpfc_hba *phba, struct lpfcMboxq *mbox) { + int rc; struct lpfc_dmabuf *mp = NULL; memset(mbox, 0, sizeof(*mbox)); - mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); - if (mp) - mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys); - if (!mp || !mp->virt) { - kfree(mp); + rc = lpfc_mbox_rsrc_prep(phba, mbox); + if (rc) { lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX, "3569 dump type 3 page 0xA0 allocation failed\n"); return 1; } - memset(mp->virt, 0, LPFC_BPL_SIZE); - INIT_LIST_HEAD(&mp->list); - bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_DUMP_MEMORY); - /* save address for completion */ - mbox->ctx_buf = mp; - bf_set(lpfc_mbx_memory_dump_type3_type, &mbox->u.mqe.un.mem_dump_type3, DMP_LMSD); bf_set(lpfc_mbx_memory_dump_type3_link, @@ -2456,6 +2491,8 @@ lpfc_sli4_dump_page_a0(struct lpfc_hba *phba, struct lpfcMboxq *mbox) &mbox->u.mqe.un.mem_dump_type3, DMP_PAGE_A0); bf_set(lpfc_mbx_memory_dump_type3_length, &mbox->u.mqe.un.mem_dump_type3, DMP_SFF_PAGE_A0_SIZE); + + mp = mbox->ctx_buf; mbox->u.mqe.un.mem_dump_type3.addr_lo = putPaddrLow(mp->phys); mbox->u.mqe.un.mem_dump_type3.addr_hi = putPaddrHigh(mp->phys); diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c index 4bfd17175a79..5e4822bf54f4 100644 --- a/drivers/scsi/lpfc/lpfc_nportdisc.c +++ b/drivers/scsi/lpfc/lpfc_nportdisc.c @@ -327,7 +327,6 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, { struct lpfc_hba *phba = vport->phba; struct lpfc_dmabuf *pcmd; - struct lpfc_dmabuf *mp; uint64_t nlp_portwwn = 0; uint32_t *lp; union lpfc_wqe128 *wqe; @@ -592,12 +591,8 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, * a default RPI. */ if (phba->sli_rev == LPFC_SLI_REV4) { - mp = (struct lpfc_dmabuf *)login_mbox->ctx_buf; - if (mp) { - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); - } - mempool_free(login_mbox, phba->mbox_mem_pool); + lpfc_mbox_rsrc_cleanup(phba, login_mbox, + MBOX_THD_UNLOCKED); login_mbox = NULL; } else { /* In order to preserve RPIs, we want to cleanup @@ -615,14 +610,9 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE; rc = lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, login_mbox); - if (rc) { - mp = (struct lpfc_dmabuf *)login_mbox->ctx_buf; - if (mp) { - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); - } - mempool_free(login_mbox, phba->mbox_mem_pool); - } + if (rc && login_mbox) + lpfc_mbox_rsrc_cleanup(phba, login_mbox, + MBOX_THD_UNLOCKED); return 1; } @@ -1334,7 +1324,7 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_vport *vport, { struct lpfc_hba *phba = vport->phba; struct lpfc_iocbq *cmdiocb, *rspiocb; - struct lpfc_dmabuf *pcmd, *prsp, *mp; + struct lpfc_dmabuf *pcmd, *prsp; uint32_t *lp; uint32_t vid, flag; struct serv_parm *sp; @@ -1501,11 +1491,7 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_vport *vport, * command */ lpfc_nlp_put(ndlp); - mp = (struct lpfc_dmabuf *)mbox->ctx_buf; - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); - mempool_free(mbox, phba->mbox_mem_pool); - + lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED); lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, "0134 PLOGI: cannot issue reg_login " "Data: x%x x%x x%x x%x\n", @@ -1856,7 +1842,6 @@ lpfc_rcv_logo_reglogin_issue(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; LPFC_MBOXQ_t *mb; LPFC_MBOXQ_t *nextmb; - struct lpfc_dmabuf *mp; struct lpfc_nodelist *ns_ndlp; cmdiocb = (struct lpfc_iocbq *) arg; @@ -1876,16 +1861,11 @@ lpfc_rcv_logo_reglogin_issue(struct lpfc_vport *vport, list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) { if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) && (ndlp == (struct lpfc_nodelist *)mb->ctx_ndlp)) { - mp = (struct lpfc_dmabuf *)(mb->ctx_buf); - if (mp) { - __lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); - } ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND; lpfc_nlp_put(ndlp); list_del(&mb->list); phba->sli.mboxq_cnt--; - mempool_free(mb, phba->mbox_mem_pool); + lpfc_mbox_rsrc_cleanup(phba, mb, MBOX_THD_LOCKED); } } spin_unlock_irq(&phba->hbalock); diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index ae26a004552d..c4b00e188f0f 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -2848,19 +2848,11 @@ void lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) { struct lpfc_vport *vport = pmb->vport; - struct lpfc_dmabuf *mp; struct lpfc_nodelist *ndlp; struct Scsi_Host *shost; uint16_t rpi, vpi; int rc; - mp = (struct lpfc_dmabuf *)(pmb->ctx_buf); - - if (mp) { - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); - } - /* * If a REG_LOGIN succeeded after node is destroyed or node * is in re-discovery driver need to cleanup the RPI. @@ -2893,8 +2885,6 @@ lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) if (pmb->u.mb.mbxCommand == MBX_REG_LOGIN64) { ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; lpfc_nlp_put(ndlp); - pmb->ctx_buf = NULL; - pmb->ctx_ndlp = NULL; } if (pmb->u.mb.mbxCommand == MBX_UNREG_LOGIN) { @@ -2945,7 +2935,7 @@ lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) if (bf_get(lpfc_mqe_command, &pmb->u.mqe) == MBX_SLI4_CONFIG) lpfc_sli4_mbox_cmd_free(phba, pmb); else - mempool_free(pmb, phba->mbox_mem_pool); + lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED); } /** * lpfc_sli4_unreg_rpi_cmpl_clr - mailbox completion handler @@ -5851,26 +5841,20 @@ lpfc_sli4_read_fcoe_params(struct lpfc_hba *phba) mboxq->mcqe.trailer); if (rc) { - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); rc = -EIO; goto out_free_mboxq; } data_length = mqe->un.mb_words[5]; if (data_length > DMP_RGN23_SIZE) { - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); rc = -EIO; goto out_free_mboxq; } lpfc_parse_fcoe_conf(phba, mp->virt, data_length); - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); rc = 0; out_free_mboxq: - mempool_free(mboxq, phba->mbox_mem_pool); + lpfc_mbox_rsrc_cleanup(phba, mboxq, MBOX_THD_UNLOCKED); return rc; } @@ -8539,8 +8523,9 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba) } /* - * This memory was allocated by the lpfc_read_sparam routine. Release - * it to the mbuf pool. + * This memory was allocated by the lpfc_read_sparam routine but is + * no longer needed. It is released and ctx_buf NULLed to prevent + * unintended pointer access as the mbox is reused. */ lpfc_mbuf_free(phba, mp->virt, mp->phys); kfree(mp); @@ -12065,7 +12050,6 @@ lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, struct lpfc_nodelist *ndlp = cmdiocb->ndlp; IOCB_t *irsp; LPFC_MBOXQ_t *mbox; - struct lpfc_dmabuf *mp; u32 ulp_command, ulp_status, ulp_word4, iotag; ulp_command = get_job_cmnd(phba, cmdiocb); @@ -12084,12 +12068,7 @@ lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, */ if (cmdiocb->context_un.mbox) { mbox = cmdiocb->context_un.mbox; - mp = (struct lpfc_dmabuf *)mbox->ctx_buf; - if (mp) { - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); - } - mempool_free(mbox, phba->mbox_mem_pool); + lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED); cmdiocb->context_un.mbox = NULL; } } @@ -15744,7 +15723,6 @@ lpfc_modify_hba_eq_delay(struct lpfc_hba *phba, uint32_t startq, mbox->vport = phba->pport; mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; - mbox->ctx_buf = NULL; mbox->ctx_ndlp = NULL; rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL); shdr = (union lpfc_sli4_cfg_shdr *) &eq_delay->header.cfg_shdr; @@ -20341,11 +20319,7 @@ lpfc_sli4_get_config_region23(struct lpfc_hba *phba, char *rgn23_data) } lpfc_sli_pcimem_bcopy((char *)mp->virt, rgn23_data, data_length); out: - mempool_free(mboxq, phba->mbox_mem_pool); - if (mp) { - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); - } + lpfc_mbox_rsrc_cleanup(phba, mboxq, MBOX_THD_UNLOCKED); return data_length; } @@ -20660,7 +20634,6 @@ lpfc_cleanup_pending_mbox(struct lpfc_vport *vport) { struct lpfc_hba *phba = vport->phba; LPFC_MBOXQ_t *mb, *nextmb; - struct lpfc_dmabuf *mp; struct lpfc_nodelist *ndlp; struct lpfc_nodelist *act_mbx_ndlp = NULL; LIST_HEAD(mbox_cmd_list); @@ -20730,12 +20703,6 @@ lpfc_cleanup_pending_mbox(struct lpfc_vport *vport) while (!list_empty(&mbox_cmd_list)) { list_remove_head(&mbox_cmd_list, mb, LPFC_MBOXQ_t, list); if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) { - mp = (struct lpfc_dmabuf *)(mb->ctx_buf); - if (mp) { - __lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); - } - mb->ctx_buf = NULL; ndlp = (struct lpfc_nodelist *)mb->ctx_ndlp; mb->ctx_ndlp = NULL; if (ndlp) { @@ -20745,7 +20712,7 @@ lpfc_cleanup_pending_mbox(struct lpfc_vport *vport) lpfc_nlp_put(ndlp); } } - mempool_free(mb, phba->mbox_mem_pool); + lpfc_mbox_rsrc_cleanup(phba, mb, MBOX_THD_UNLOCKED); } /* Release the ndlp with the cleaned-up active mailbox command */ @@ -21892,7 +21859,6 @@ lpfc_read_object(struct lpfc_hba *phba, char *rdobject, uint32_t *datap, mbox->vport = phba->pport; mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; - mbox->ctx_buf = NULL; mbox->ctx_ndlp = NULL; rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL); @@ -21929,9 +21895,12 @@ lpfc_read_object(struct lpfc_hba *phba, char *rdobject, uint32_t *datap, } exit: + /* This is an embedded SLI4 mailbox with an external buffer allocated. + * Free the pcmd and then cleanup with the correct routine. + */ lpfc_mbuf_free(phba, pcmd->virt, pcmd->phys); kfree(pcmd); - mempool_free(mbox, phba->mbox_mem_pool); + lpfc_sli4_mbox_cmd_free(phba, mbox); return byte_cnt; } diff --git a/drivers/scsi/lpfc/lpfc_sli.h b/drivers/scsi/lpfc/lpfc_sli.h index 776eb4ab52d2..0af6860b8936 100644 --- a/drivers/scsi/lpfc/lpfc_sli.h +++ b/drivers/scsi/lpfc/lpfc_sli.h @@ -35,6 +35,12 @@ typedef enum _lpfc_ctx_cmd { LPFC_CTX_HOST } lpfc_ctx_cmd; +/* Enumeration to describe the thread lock context. */ +enum lpfc_mbox_ctx { + MBOX_THD_UNLOCKED, + MBOX_THD_LOCKED +}; + union lpfc_vmid_tag { uint32_t app_id; uint8_t cs_ctl_vmid; diff --git a/drivers/scsi/lpfc/lpfc_vport.c b/drivers/scsi/lpfc/lpfc_vport.c index d694d0cff5a5..f635eb8e9711 100644 --- a/drivers/scsi/lpfc/lpfc_vport.c +++ b/drivers/scsi/lpfc/lpfc_vport.c @@ -135,12 +135,14 @@ lpfc_vport_sparm(struct lpfc_hba *phba, struct lpfc_vport *vport) } /* - * Grab buffer pointer and clear context1 so we can use - * lpfc_sli_issue_box_wait + * Wait for the read_sparams mailbox to complete. Driver needs + * this per vport to start the FDISC. If the mailbox fails, + * just cleanup and return an error unless the failure is a + * mailbox timeout. For MBX_TIMEOUT, allow the default + * mbox completion handler to take care of the cleanup. This + * is safe as the mailbox command isn't one that triggers + * another mailbox. */ - mp = (struct lpfc_dmabuf *)pmb->ctx_buf; - pmb->ctx_buf = NULL; - pmb->vport = vport; rc = lpfc_sli_issue_mbox_wait(phba, pmb, phba->fc_ratov * 2); if (rc != MBX_SUCCESS) { @@ -148,34 +150,29 @@ lpfc_vport_sparm(struct lpfc_hba *phba, struct lpfc_vport *vport) lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, "1830 Signal aborted mbxCmd x%x\n", mb->mbxCommand); - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); if (rc != MBX_TIMEOUT) - mempool_free(pmb, phba->mbox_mem_pool); + lpfc_mbox_rsrc_cleanup(phba, pmb, + MBOX_THD_UNLOCKED); return -EINTR; } else { lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, "1818 VPort failed init, mbxCmd x%x " "READ_SPARM mbxStatus x%x, rc = x%x\n", mb->mbxCommand, mb->mbxStatus, rc); - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); if (rc != MBX_TIMEOUT) - mempool_free(pmb, phba->mbox_mem_pool); + lpfc_mbox_rsrc_cleanup(phba, pmb, + MBOX_THD_UNLOCKED); return -EIO; } } + mp = (struct lpfc_dmabuf *)pmb->ctx_buf; memcpy(&vport->fc_sparam, mp->virt, sizeof (struct serv_parm)); memcpy(&vport->fc_nodename, &vport->fc_sparam.nodeName, sizeof (struct lpfc_name)); memcpy(&vport->fc_portname, &vport->fc_sparam.portName, sizeof (struct lpfc_name)); - - lpfc_mbuf_free(phba, mp->virt, mp->phys); - kfree(mp); - mempool_free(pmb, phba->mbox_mem_pool); - + lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED); return 0; } From 1b6f71f7fcb685970aa1c4ecca3dd60ed37a32ea Mon Sep 17 00:00:00 2001 From: James Smart Date: Tue, 12 Apr 2022 15:20:04 -0700 Subject: [PATCH 027/177] scsi: lpfc: Change FA-PWWN detection methodology Do not rely on vendor version field of the CSPs to determine if we are in a FA-PWWN environment. Instead, use the following procedure: First, during HBA initialization, driver does a READ_CONFIG to determine if FA-PWWN is configured on the HBA. A LPFC_FAWWPN_CONFIG hba_flag is set accordingly. Next, when the link comes up before the driver gets a link up event, the firmware logs into the fabric with FA-PWWN. If the fabric port does not support FA-PWWN, the driver will get a Misconfigured FA-WWN async event before the link up. A LPFC_FAWWPN_FABRIC hba_flag will be set accordingly. Finally, if the fabric supports FA-PWWN, the firmware will replace its CSPs WWN with the Fabric Assigned ones. Then after link up, the driver will retrieve the Fabric Assigned WWN when it does a READ_SPARAM mbox command. Link: https://lore.kernel.org/r/20220412222008.126521-23-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc.h | 5 +-- drivers/scsi/lpfc/lpfc_attr.c | 18 ++++++-- drivers/scsi/lpfc/lpfc_hbadisc.c | 8 ++++ drivers/scsi/lpfc/lpfc_hw.h | 2 - drivers/scsi/lpfc/lpfc_hw4.h | 3 ++ drivers/scsi/lpfc/lpfc_init.c | 72 ++++++++++++++++++++++++-------- drivers/scsi/lpfc/lpfc_sli.c | 1 + drivers/scsi/lpfc/lpfc_sli4.h | 3 ++ 8 files changed, 86 insertions(+), 26 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h index a62cf1a19280..346661dc5bf2 100644 --- a/drivers/scsi/lpfc/lpfc.h +++ b/drivers/scsi/lpfc/lpfc.h @@ -739,9 +739,8 @@ struct lpfc_vport { struct list_head rcv_buffer_list; unsigned long rcv_buffer_time_stamp; uint32_t vport_flag; -#define STATIC_VPORT 1 -#define FAWWPN_SET 2 -#define FAWWPN_PARAM_CHG 4 +#define STATIC_VPORT 0x1 +#define FAWWPN_PARAM_CHG 0x2 uint16_t fdmi_num_disc; uint32_t fdmi_hba_mask; diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c index 9b982cc270d9..ea6de542d42a 100644 --- a/drivers/scsi/lpfc/lpfc_attr.c +++ b/drivers/scsi/lpfc/lpfc_attr.c @@ -1120,12 +1120,22 @@ lpfc_link_state_show(struct device *dev, struct device_attribute *attr, len += scnprintf(buf + len, PAGE_SIZE-len, " Private Loop\n"); } else { - if (vport->fc_flag & FC_FABRIC) - len += scnprintf(buf + len, PAGE_SIZE-len, - " Fabric\n"); - else + if (vport->fc_flag & FC_FABRIC) { + if (phba->sli_rev == LPFC_SLI_REV4 && + vport->port_type == LPFC_PHYSICAL_PORT && + phba->sli4_hba.fawwpn_flag & + LPFC_FAWWPN_FABRIC) + len += scnprintf(buf + len, + PAGE_SIZE - len, + " Fabric FA-PWWN\n"); + else + len += scnprintf(buf + len, + PAGE_SIZE - len, + " Fabric\n"); + } else { len += scnprintf(buf + len, PAGE_SIZE-len, " Point-2-Point\n"); + } } } diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index f2baf3bd8dd8..2d846256990c 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c @@ -1183,6 +1183,7 @@ lpfc_port_link_failure(struct lpfc_vport *vport) void lpfc_linkdown_port(struct lpfc_vport *vport) { + struct lpfc_hba *phba = vport->phba; struct Scsi_Host *shost = lpfc_shost_from_vport(vport); if (vport->cfg_enable_fc4_type != LPFC_ENABLE_NVME) @@ -1200,6 +1201,13 @@ lpfc_linkdown_port(struct lpfc_vport *vport) vport->fc_flag &= ~FC_DISC_DELAYED; spin_unlock_irq(shost->host_lock); del_timer_sync(&vport->delayed_disc_tmo); + + if (phba->sli_rev == LPFC_SLI_REV4 && + vport->port_type == LPFC_PHYSICAL_PORT && + phba->sli4_hba.fawwpn_flag & LPFC_FAWWPN_CONFIG) { + /* Assume success on link up */ + phba->sli4_hba.fawwpn_flag |= LPFC_FAWWPN_FABRIC; + } } int diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h index 2f5537f57846..70c3dd7b7105 100644 --- a/drivers/scsi/lpfc/lpfc_hw.h +++ b/drivers/scsi/lpfc/lpfc_hw.h @@ -511,8 +511,6 @@ struct class_parms { uint8_t word3Reserved2; /* Fc Word 3, bit 0: 7 */ }; -#define FAPWWN_KEY_VENDOR 0x42524344 /*valid vendor version fawwpn key*/ - struct serv_parm { /* Structure is in Big Endian format */ struct csp cmn; struct lpfc_name portName; diff --git a/drivers/scsi/lpfc/lpfc_hw4.h b/drivers/scsi/lpfc/lpfc_hw4.h index 02e230ed6280..6d20c97762e9 100644 --- a/drivers/scsi/lpfc/lpfc_hw4.h +++ b/drivers/scsi/lpfc/lpfc_hw4.h @@ -2893,6 +2893,9 @@ struct lpfc_mbx_read_config { #define lpfc_mbx_rd_conf_extnts_inuse_SHIFT 31 #define lpfc_mbx_rd_conf_extnts_inuse_MASK 0x00000001 #define lpfc_mbx_rd_conf_extnts_inuse_WORD word1 +#define lpfc_mbx_rd_conf_fawwpn_SHIFT 30 +#define lpfc_mbx_rd_conf_fawwpn_MASK 0x00000001 +#define lpfc_mbx_rd_conf_fawwpn_WORD word1 #define lpfc_mbx_rd_conf_wcs_SHIFT 28 /* warning signaling */ #define lpfc_mbx_rd_conf_wcs_MASK 0x00000001 #define lpfc_mbx_rd_conf_wcs_WORD word1 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index fad7ad90c57f..39267016f339 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -350,8 +350,7 @@ lpfc_dump_wakeup_param_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq) void lpfc_update_vport_wwn(struct lpfc_vport *vport) { - uint8_t vvvl = vport->fc_sparam.cmn.valid_vendor_ver_level; - u32 *fawwpn_key = (u32 *)&vport->fc_sparam.un.vendorVersion[0]; + struct lpfc_hba *phba = vport->phba; /* * If the name is empty or there exists a soft name @@ -370,21 +369,32 @@ lpfc_update_vport_wwn(struct lpfc_vport *vport) */ if (vport->fc_portname.u.wwn[0] != 0 && memcmp(&vport->fc_portname, &vport->fc_sparam.portName, - sizeof(struct lpfc_name))) + sizeof(struct lpfc_name))) { vport->vport_flag |= FAWWPN_PARAM_CHG; - if (vport->fc_portname.u.wwn[0] == 0 || - (vvvl == 1 && cpu_to_be32(*fawwpn_key) == FAPWWN_KEY_VENDOR) || - vport->vport_flag & FAWWPN_SET) { - memcpy(&vport->fc_portname, &vport->fc_sparam.portName, - sizeof(struct lpfc_name)); - vport->vport_flag &= ~FAWWPN_SET; - if (vvvl == 1 && cpu_to_be32(*fawwpn_key) == FAPWWN_KEY_VENDOR) - vport->vport_flag |= FAWWPN_SET; + if (phba->sli_rev == LPFC_SLI_REV4 && + vport->port_type == LPFC_PHYSICAL_PORT && + phba->sli4_hba.fawwpn_flag & LPFC_FAWWPN_FABRIC) { + lpfc_printf_log(phba, KERN_INFO, + LOG_SLI | LOG_DISCOVERY | LOG_ELS, + "2701 FA-PWWN change WWPN from %llx to " + "%llx: vflag x%x fawwpn_flag x%x\n", + wwn_to_u64(vport->fc_portname.u.wwn), + wwn_to_u64 + (vport->fc_sparam.portName.u.wwn), + vport->vport_flag, + phba->sli4_hba.fawwpn_flag); + memcpy(&vport->fc_portname, &vport->fc_sparam.portName, + sizeof(struct lpfc_name)); + } } + + if (vport->fc_portname.u.wwn[0] == 0) + memcpy(&vport->fc_portname, &vport->fc_sparam.portName, + sizeof(struct lpfc_name)); else memcpy(&vport->fc_sparam.portName, &vport->fc_portname, - sizeof(struct lpfc_name)); + sizeof(struct lpfc_name)); } /** @@ -6542,12 +6552,15 @@ lpfc_sli4_async_sli_evt(struct lpfc_hba *phba, struct lpfc_acqe_sli *acqe_sli) case LPFC_SLI_EVENT_TYPE_MISCONF_FAWWN: /* Misconfigured WWN. Reports that the SLI Port is configured * to use FA-WWN, but the attached device doesn’t support it. - * No driver action is required. * Event Data1 - N.A, Event Data2 - N.A + * This event only happens on the physical port. */ - lpfc_log_msg(phba, KERN_WARNING, LOG_SLI, - "2699 Misconfigured FA-WWN - Attached device does " - "not support FA-WWN\n"); + lpfc_log_msg(phba, KERN_WARNING, LOG_SLI | LOG_DISCOVERY, + "2699 Misconfigured FA-PWWN - Attached device " + "does not support FA-PWWN\n"); + phba->sli4_hba.fawwpn_flag &= ~LPFC_FAWWPN_FABRIC; + memset(phba->pport->fc_portname.u.wwn, 0, + sizeof(struct lpfc_name)); break; case LPFC_SLI_EVENT_TYPE_EEPROM_FAILURE: /* EEPROM failure. No driver action is required */ @@ -8004,6 +8017,18 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba) rc = lpfc_sli4_read_config(phba); if (unlikely(rc)) goto out_free_bsmbx; + + if (phba->sli4_hba.fawwpn_flag & LPFC_FAWWPN_CONFIG) { + /* Right now the link is down, if FA-PWWN is configured the + * firmware will try FLOGI before the driver gets a link up. + * If it fails, the driver should get a MISCONFIGURED async + * event which will clear this flag. The only notification + * the driver gets is if it fails, if it succeeds there is no + * notification given. Assume success. + */ + phba->sli4_hba.fawwpn_flag |= LPFC_FAWWPN_FABRIC; + } + rc = lpfc_mem_alloc_active_rrq_pool_s4(phba); if (unlikely(rc)) goto out_free_bsmbx; @@ -9807,7 +9832,7 @@ lpfc_sli4_read_config(struct lpfc_hba *phba) struct lpfc_rsrc_desc_fcfcoe *desc; char *pdesc_0; uint16_t forced_link_speed; - uint32_t if_type, qmin; + uint32_t if_type, qmin, fawwpn; int length, i, rc = 0, rc2; pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); @@ -9849,10 +9874,23 @@ lpfc_sli4_read_config(struct lpfc_hba *phba) phba->sli4_hba.bbscn_params.word0 = rd_config->word8; } + fawwpn = bf_get(lpfc_mbx_rd_conf_fawwpn, rd_config); + + if (fawwpn) { + lpfc_printf_log(phba, KERN_INFO, + LOG_INIT | LOG_DISCOVERY, + "2702 READ_CONFIG: FA-PWWN is " + "configured on\n"); + phba->sli4_hba.fawwpn_flag |= LPFC_FAWWPN_CONFIG; + } else { + phba->sli4_hba.fawwpn_flag = 0; + } + phba->sli4_hba.conf_trunk = bf_get(lpfc_mbx_rd_conf_trunk, rd_config); phba->sli4_hba.extents_in_use = bf_get(lpfc_mbx_rd_conf_extnts_inuse, rd_config); + phba->sli4_hba.max_cfg_param.max_xri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config); /* Reduce resource usage in kdump environment */ diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index c4b00e188f0f..22fe7de63fb6 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -5265,6 +5265,7 @@ lpfc_sli_brdrestart_s4(struct lpfc_hba *phba) phba->pport->stopped = 0; phba->link_state = LPFC_INIT_START; phba->hba_flag = 0; + phba->sli4_hba.fawwpn_flag = 0; spin_unlock_irq(&phba->hbalock); memset(&psli->lnk_stat_offsets, 0, sizeof(psli->lnk_stat_offsets)); diff --git a/drivers/scsi/lpfc/lpfc_sli4.h b/drivers/scsi/lpfc/lpfc_sli4.h index e0c25699f4b8..1ddad5b170a6 100644 --- a/drivers/scsi/lpfc/lpfc_sli4.h +++ b/drivers/scsi/lpfc/lpfc_sli4.h @@ -981,6 +981,9 @@ struct lpfc_sli4_hba { #define lpfc_conf_trunk_port3_nd_MASK 0x1 uint8_t flash_id; uint8_t asic_rev; + uint16_t fawwpn_flag; /* FA-WWPN support state */ +#define LPFC_FAWWPN_CONFIG 0x1 /* FA-PWWN is configured */ +#define LPFC_FAWWPN_FABRIC 0x2 /* FA-PWWN success with Fabric */ }; enum lpfc_sge_type { From f4fbf4acaa503a8509337572d0c10e5fa4309bc9 Mon Sep 17 00:00:00 2001 From: James Smart Date: Tue, 12 Apr 2022 15:20:05 -0700 Subject: [PATCH 028/177] scsi: lpfc: Update stat accounting for READ_STATUS mbox command READ_STATUS tx/rx byte count fields are now expanded to 64 bit wide counters. This patch updates logic for the READ_STATUS mbox command when displaying tx_word and rx_word statistics in sysfs. Link: https://lore.kernel.org/r/20220412222008.126521-24-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_attr.c | 37 +++++++++++++++++++++++++---------- drivers/scsi/lpfc/lpfc_hw.h | 37 ++++++++++++++++++++++++----------- 2 files changed, 53 insertions(+), 21 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c index ea6de542d42a..856e02b0d35f 100644 --- a/drivers/scsi/lpfc/lpfc_attr.c +++ b/drivers/scsi/lpfc/lpfc_attr.c @@ -6888,17 +6888,34 @@ lpfc_get_stats(struct Scsi_Host *shost) memset(hs, 0, sizeof (struct fc_host_statistics)); hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt; - /* - * The MBX_READ_STATUS returns tx_k_bytes which has to - * converted to words - */ - hs->tx_words = (uint64_t) - ((uint64_t)pmb->un.varRdStatus.xmitByteCnt - * (uint64_t)256); hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt; - hs->rx_words = (uint64_t) - ((uint64_t)pmb->un.varRdStatus.rcvByteCnt - * (uint64_t)256); + + /* + * The MBX_READ_STATUS returns tx_k_bytes which has to be + * converted to words. + * + * Check if extended byte flag is set, to know when to collect upper + * bits of 64 bit wide statistics counter. + */ + if (pmb->un.varRdStatus.xkb & RD_ST_XKB) { + hs->tx_words = (u64) + ((((u64)(pmb->un.varRdStatus.xmit_xkb & + RD_ST_XMIT_XKB_MASK) << 32) | + (u64)pmb->un.varRdStatus.xmitByteCnt) * + (u64)256); + hs->rx_words = (u64) + ((((u64)(pmb->un.varRdStatus.rcv_xkb & + RD_ST_RCV_XKB_MASK) << 32) | + (u64)pmb->un.varRdStatus.rcvByteCnt) * + (u64)256); + } else { + hs->tx_words = (uint64_t) + ((uint64_t)pmb->un.varRdStatus.xmitByteCnt + * (uint64_t)256); + hs->rx_words = (uint64_t) + ((uint64_t)pmb->un.varRdStatus.rcvByteCnt + * (uint64_t)256); + } memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t)); pmb->mbxCommand = MBX_READ_LNK_STAT; diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h index 70c3dd7b7105..748c53219986 100644 --- a/drivers/scsi/lpfc/lpfc_hw.h +++ b/drivers/scsi/lpfc/lpfc_hw.h @@ -2648,19 +2648,26 @@ typedef struct { } READ_SPARM_VAR; /* Structure for MB Command READ_STATUS (14) */ +enum read_status_word1 { + RD_ST_CC = 0x01, + RD_ST_XKB = 0x80, +}; + +enum read_status_word17 { + RD_ST_XMIT_XKB_MASK = 0x3fffff, +}; + +enum read_status_word18 { + RD_ST_RCV_XKB_MASK = 0x3fffff, +}; typedef struct { -#ifdef __BIG_ENDIAN_BITFIELD - uint32_t rsvd1:31; - uint32_t clrCounters:1; - uint16_t activeXriCnt; - uint16_t activeRpiCnt; -#else /* __LITTLE_ENDIAN_BITFIELD */ - uint32_t clrCounters:1; - uint32_t rsvd1:31; - uint16_t activeRpiCnt; - uint16_t activeXriCnt; -#endif + u8 clear_counters; /* rsvd 7:1, cc 0 */ + u8 rsvd5; + u8 rsvd6; + u8 xkb; /* xkb 7, rsvd 6:0 */ + + u32 rsvd8; uint32_t xmitByteCnt; uint32_t rcvByteCnt; @@ -2672,6 +2679,14 @@ typedef struct { uint32_t totalRespExchanges; uint32_t rcvPbsyCnt; uint32_t rcvFbsyCnt; + + u32 drop_frame_no_rq; + u32 empty_rq; + u32 drop_frame_no_xri; + u32 empty_xri; + + u32 xmit_xkb; /* rsvd 31:22, xmit_xkb 21:0 */ + u32 rcv_xkb; /* rsvd 31:22, rcv_xkb 21:0 */ } READ_STATUS_VAR; /* Structure for MB Command READ_RPI (15) */ From fd4a0c6da5c12aa881b933fb4e426cb706fc2c01 Mon Sep 17 00:00:00 2001 From: James Smart Date: Tue, 12 Apr 2022 15:20:06 -0700 Subject: [PATCH 029/177] scsi: lpfc: Expand setting ELS_ID field in ELS_REQUEST64_WQE ELS_ID field for ELS_REQUEST64_WQE is not filled out when FIP is not supported by the HBA. Move setting ELS_ID logic into __lpfc_sli_prep_els_req_rsp_s4(), and remove ELS_ID FIP dependency logic from lpfc_sli_prep_wqe(). Introduce PLOGI ELS_ID and as a result update wqe_els_id_MASK because PLOGI ELS_ID = 0x4 occupies up to 3 bits. While in __lpfc_sli_prep_els_req_rsp_s4() routine, remove SLI3-isms. Link: https://lore.kernel.org/r/20220412222008.126521-25-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_hw4.h | 14 ++++++++----- drivers/scsi/lpfc/lpfc_sli.c | 38 ++++++++++++++++++++++++++---------- 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_hw4.h b/drivers/scsi/lpfc/lpfc_hw4.h index 6d20c97762e9..8511369d2cf8 100644 --- a/drivers/scsi/lpfc/lpfc_hw4.h +++ b/drivers/scsi/lpfc/lpfc_hw4.h @@ -4476,12 +4476,8 @@ struct wqe_common { #define wqe_cmd_type_MASK 0x0000000f #define wqe_cmd_type_WORD word11 #define wqe_els_id_SHIFT 4 -#define wqe_els_id_MASK 0x00000003 +#define wqe_els_id_MASK 0x00000007 #define wqe_els_id_WORD word11 -#define LPFC_ELS_ID_FLOGI 3 -#define LPFC_ELS_ID_FDISC 2 -#define LPFC_ELS_ID_LOGO 1 -#define LPFC_ELS_ID_DEFAULT 0 #define wqe_irsp_SHIFT 4 #define wqe_irsp_MASK 0x00000001 #define wqe_irsp_WORD word11 @@ -4528,6 +4524,14 @@ struct lpfc_wqe_generic{ uint32_t payload[4]; }; +enum els_request64_wqe_word11 { + LPFC_ELS_ID_DEFAULT, + LPFC_ELS_ID_LOGO, + LPFC_ELS_ID_FDISC, + LPFC_ELS_ID_FLOGI, + LPFC_ELS_ID_PLOGI, +}; + struct els_request64_wqe { struct ulp_bde64 bde; uint32_t payload_len; diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index 22fe7de63fb6..8bf62697317a 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -10583,6 +10583,7 @@ __lpfc_sli_prep_els_req_rsp_s4(struct lpfc_iocbq *cmdiocbq, struct lpfc_hba *phba = vport->phba; union lpfc_wqe128 *wqe; struct ulp_bde64_le *bde; + u8 els_id; wqe = &cmdiocbq->wqe; memset(wqe, 0, sizeof(*wqe)); @@ -10595,7 +10596,7 @@ __lpfc_sli_prep_els_req_rsp_s4(struct lpfc_iocbq *cmdiocbq, bde->type_size |= cpu_to_le32(ULP_BDE64_TYPE_BDE_64); if (expect_rsp) { - bf_set(wqe_cmnd, &wqe->els_req.wqe_com, CMD_ELS_REQUEST64_CR); + bf_set(wqe_cmnd, &wqe->els_req.wqe_com, CMD_ELS_REQUEST64_WQE); /* Transfer length */ wqe->els_req.payload_len = cmd_size; @@ -10603,6 +10604,30 @@ __lpfc_sli_prep_els_req_rsp_s4(struct lpfc_iocbq *cmdiocbq, /* DID */ bf_set(wqe_els_did, &wqe->els_req.wqe_dest, did); + + /* Word 11 - ELS_ID */ + switch (elscmd) { + case ELS_CMD_PLOGI: + els_id = LPFC_ELS_ID_PLOGI; + break; + case ELS_CMD_FLOGI: + els_id = LPFC_ELS_ID_FLOGI; + break; + case ELS_CMD_LOGO: + els_id = LPFC_ELS_ID_LOGO; + break; + case ELS_CMD_FDISC: + if (!vport->fc_myDID) { + els_id = LPFC_ELS_ID_FDISC; + break; + } + fallthrough; + default: + els_id = LPFC_ELS_ID_DEFAULT; + break; + } + + bf_set(wqe_els_id, &wqe->els_req.wqe_com, els_id); } else { /* DID */ bf_set(wqe_els_did, &wqe->xmit_els_rsp.wqe_dest, did); @@ -10611,7 +10636,7 @@ __lpfc_sli_prep_els_req_rsp_s4(struct lpfc_iocbq *cmdiocbq, wqe->xmit_els_rsp.response_payload_len = cmd_size; bf_set(wqe_cmnd, &wqe->xmit_els_rsp.wqe_com, - CMD_XMIT_ELS_RSP64_CX); + CMD_XMIT_ELS_RSP64_WQE); } bf_set(wqe_tmo, &wqe->generic.wqe_com, tmo); @@ -10627,7 +10652,7 @@ __lpfc_sli_prep_els_req_rsp_s4(struct lpfc_iocbq *cmdiocbq, if (expect_rsp) { bf_set(els_req64_sid, &wqe->els_req, vport->fc_myDID); - /* For ELS_REQUEST64_CR, use the VPI by default */ + /* For ELS_REQUEST64_WQE, use the VPI by default */ bf_set(wqe_ctxt_tag, &wqe->els_req.wqe_com, phba->vpi_ids[vport->vpi]); } @@ -22215,7 +22240,6 @@ lpfc_sli_prep_wqe(struct lpfc_hba *phba, struct lpfc_iocbq *job) u32 fip, abort_tag; struct lpfc_nodelist *ndlp = NULL; union lpfc_wqe128 *wqe = &job->wqe; - u32 els_id = LPFC_ELS_ID_DEFAULT; u8 command_type = ELS_COMMAND_NON_FIP; fip = phba->hba_flag & HBA_FIP_SUPPORT; @@ -22234,11 +22258,6 @@ lpfc_sli_prep_wqe(struct lpfc_hba *phba, struct lpfc_iocbq *job) case CMD_ELS_REQUEST64_WQE: ndlp = job->ndlp; - /* CCP CCPE PV PRI in word10 were set in the memcpy */ - if (command_type == ELS_COMMAND_FIP) - els_id = ((job->cmd_flag & LPFC_FIP_ELS_ID_MASK) - >> LPFC_FIP_ELS_ID_SHIFT); - if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); if (if_type >= LPFC_SLI_INTF_IF_TYPE_2) { @@ -22275,7 +22294,6 @@ lpfc_sli_prep_wqe(struct lpfc_hba *phba, struct lpfc_iocbq *job) bf_set(wqe_temp_rpi, &wqe->els_req.wqe_com, phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]); - bf_set(wqe_els_id, &wqe->els_req.wqe_com, els_id); bf_set(wqe_dbde, &wqe->els_req.wqe_com, 1); bf_set(wqe_iod, &wqe->els_req.wqe_com, LPFC_WQE_IOD_READ); bf_set(wqe_qosd, &wqe->els_req.wqe_com, 1); From 4af4d0e2ea942a7f141fec51bde224fcb8c551a1 Mon Sep 17 00:00:00 2001 From: James Smart Date: Tue, 12 Apr 2022 15:20:07 -0700 Subject: [PATCH 030/177] scsi: lpfc: Update lpfc version to 14.2.0.2 Update lpfc version to 14.2.0.2. Link: https://lore.kernel.org/r/20220412222008.126521-26-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/lpfc/lpfc_version.h b/drivers/scsi/lpfc/lpfc_version.h index a4d3259b8c52..a615011c282d 100644 --- a/drivers/scsi/lpfc/lpfc_version.h +++ b/drivers/scsi/lpfc/lpfc_version.h @@ -20,7 +20,7 @@ * included with this package. * *******************************************************************/ -#define LPFC_DRIVER_VERSION "14.2.0.1" +#define LPFC_DRIVER_VERSION "14.2.0.2" #define LPFC_DRIVER_NAME "lpfc" /* Used for SLI 2/3 */ From 66c20a97367a6a9254af7cf863271d55a731a4a0 Mon Sep 17 00:00:00 2001 From: James Smart Date: Tue, 12 Apr 2022 15:20:08 -0700 Subject: [PATCH 031/177] scsi: lpfc: Copyright updates for 14.2.0.2 patches Update copyrights to 2022 for files modified in the 14.2.0.2 patch set. Link: https://lore.kernel.org/r/20220412222008.126521-27-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_attr.c | 2 +- drivers/scsi/lpfc/lpfc_logmsg.h | 2 +- drivers/scsi/lpfc/lpfc_mbox.c | 2 +- drivers/scsi/lpfc/lpfc_vport.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c index 856e02b0d35f..3caaa7c4af48 100644 --- a/drivers/scsi/lpfc/lpfc_attr.c +++ b/drivers/scsi/lpfc/lpfc_attr.c @@ -1,7 +1,7 @@ /******************************************************************* * This file is part of the Emulex Linux Device Driver for * * Fibre Channel Host Bus Adapters. * - * Copyright (C) 2017-2021 Broadcom. All Rights Reserved. The term * + * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term * * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * * Copyright (C) 2004-2016 Emulex. All rights reserved. * * EMULEX and SLI are trademarks of Emulex. * diff --git a/drivers/scsi/lpfc/lpfc_logmsg.h b/drivers/scsi/lpfc/lpfc_logmsg.h index a5aafe230c74..4d455da9cd69 100644 --- a/drivers/scsi/lpfc/lpfc_logmsg.h +++ b/drivers/scsi/lpfc/lpfc_logmsg.h @@ -1,7 +1,7 @@ /******************************************************************* * This file is part of the Emulex Linux Device Driver for * * Fibre Channel Host Bus Adapters. * - * Copyright (C) 2017-2021 Broadcom. All Rights Reserved. The term * + * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term * * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * * Copyright (C) 2004-2009 Emulex. All rights reserved. * * EMULEX and SLI are trademarks of Emulex. * diff --git a/drivers/scsi/lpfc/lpfc_mbox.c b/drivers/scsi/lpfc/lpfc_mbox.c index 712c8f6e4de2..9858b1743769 100644 --- a/drivers/scsi/lpfc/lpfc_mbox.c +++ b/drivers/scsi/lpfc/lpfc_mbox.c @@ -1,7 +1,7 @@ /******************************************************************* * This file is part of the Emulex Linux Device Driver for * * Fibre Channel Host Bus Adapters. * - * Copyright (C) 2017-2021 Broadcom. All Rights Reserved. The term * + * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term * * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * * Copyright (C) 2004-2016 Emulex. All rights reserved. * * EMULEX and SLI are trademarks of Emulex. * diff --git a/drivers/scsi/lpfc/lpfc_vport.c b/drivers/scsi/lpfc/lpfc_vport.c index f635eb8e9711..e7efb025ed50 100644 --- a/drivers/scsi/lpfc/lpfc_vport.c +++ b/drivers/scsi/lpfc/lpfc_vport.c @@ -1,7 +1,7 @@ /******************************************************************* * This file is part of the Emulex Linux Device Driver for * * Fibre Channel Host Bus Adapters. * - * Copyright (C) 2017-2021 Broadcom. All Rights Reserved. The term * + * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term * * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. * * Copyright (C) 2004-2016 Emulex. All rights reserved. * * EMULEX and SLI are trademarks of Emulex. * From 21a023ce397ba1959d342b1087216655abc2ba49 Mon Sep 17 00:00:00 2001 From: Jiapeng Chong Date: Fri, 1 Apr 2022 11:06:40 +0800 Subject: [PATCH 032/177] scsi: pmcraid: Remove unneeded semicolon Fix the following coccicheck warning: ./drivers/scsi/pmcraid.c:4593:2-3: Unneeded semicolon. Link: https://lore.kernel.org/r/20220401030640.28246-1-jiapeng.chong@linux.alibaba.com Reported-by: Abaci Robot Signed-off-by: Jiapeng Chong Signed-off-by: Martin K. Petersen --- drivers/scsi/pmcraid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c index fd674ed1febe..3d5cd337a2a6 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c @@ -4590,7 +4590,7 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host, mapped_pci_addr + chip_cfg->ioa_host_mask_clr; pint_regs->global_interrupt_mask_reg = mapped_pci_addr + chip_cfg->global_intr_mask; - }; + } pinstance->ioa_reset_attempts = 0; init_waitqueue_head(&pinstance->reset_wait_q); From 65db22e505c4f3d13f588775844074bee5e93163 Mon Sep 17 00:00:00 2001 From: Yihao Han Date: Fri, 8 Apr 2022 01:12:37 -0700 Subject: [PATCH 033/177] scsi: fcoe: Simplify if-if to if-else Replace 'if (!is_zero_ether_addr(mac))' with 'else' for simplification and add curly brackets according to the kernel coding style: "Do not unnecessarily use braces where a single statement will do." ... "This does not apply if only one branch of a conditional statement is a single statement; in the latter case use braces in both branches" Please refer to: https://www.kernel.org/doc/html/v5.17-rc8/process/coding-style.html Link: https://lore.kernel.org/r/20220408081237.14037-1-hanyihao@vivo.com Signed-off-by: Yihao Han Signed-off-by: Martin K. Petersen --- drivers/scsi/fcoe/fcoe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c index 44ca6110213c..983e00135fea 100644 --- a/drivers/scsi/fcoe/fcoe.c +++ b/drivers/scsi/fcoe/fcoe.c @@ -2580,7 +2580,7 @@ static void fcoe_flogi_resp(struct fc_seq *seq, struct fc_frame *fp, void *arg) /* pre-FIP */ if (is_zero_ether_addr(mac)) fcoe_ctlr_recv_flogi(fip, lport, fp); - if (!is_zero_ether_addr(mac)) + else fcoe_update_src_mac(lport, mac); done: fc_lport_flogi_resp(seq, fp, lport); From f9bdac31cf4b8609c1b241749b0ceb8f67c8685b Mon Sep 17 00:00:00 2001 From: Sumit Saxena Date: Thu, 14 Apr 2022 06:36:01 -0400 Subject: [PATCH 034/177] scsi: core: Increase max device queue_depth to 4096 The maximum SCSI device queue depth of 1024 is not sufficient for RAID volumes configured behind Broadcom RAID controllers. For a 16-drive RAID volume with a device queue depth limit of 1024, only 64 I/Os (1024/16) can be issued per drive. That is not sufficient to saturate the device. Link: https://lore.kernel.org/r/20220414103601.140687-1-sumit.saxena@broadcom.com Cc: Ming Lei Cc: Hannes Reinecke Cc: Bart Van Assche Cc: Sumanesh Samanta Signed-off-by: Sumit Saxena Signed-off-by: Martin K. Petersen --- drivers/scsi/scsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 211aace69c22..735b6c862b46 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -200,11 +200,11 @@ void scsi_finish_command(struct scsi_cmnd *cmd) /* - * 1024 is big enough for saturating fast SCSI LUNs. + * 4096 is big enough for saturating fast SCSI LUNs. */ int scsi_device_max_queue_depth(struct scsi_device *sdev) { - return min_t(int, sdev->host->can_queue, 1024); + return min_t(int, sdev->host->can_queue, 4096); } /** From ad14649fc5ab216e0abb6b38115898238a0991f5 Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Fri, 15 Apr 2022 12:42:24 +0000 Subject: [PATCH 035/177] scsi: qla2xxx: Remove free_sg command flag The use of the free_sg command flag was dropped in commit 2c39b5ca2a8c ("qla2xxx: Remove SRR code"). Hence remove this flag and its check. Link: https://lore.kernel.org/r/AS8PR10MB4952747D20B76DC8FE793CCA9DEE9@AS8PR10MB4952.EURPRD10.PROD.OUTLOOK.COM Reviewed-by: Himanshu Madhani Signed-off-by: Gleb Chesnokov Signed-off-by: Martin K. Petersen --- drivers/scsi/qla2xxx/qla_target.c | 2 -- drivers/scsi/qla2xxx/qla_target.h | 1 - 2 files changed, 3 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index 85dbf81f3204..2d30578aebcf 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -3863,8 +3863,6 @@ void qlt_free_cmd(struct qla_tgt_cmd *cmd) BUG_ON(cmd->sg_mapped); cmd->jiffies_at_free = get_jiffies_64(); - if (unlikely(cmd->free_sg)) - kfree(cmd->sg); if (!sess || !sess->se_sess) { WARN_ON(1); diff --git a/drivers/scsi/qla2xxx/qla_target.h b/drivers/scsi/qla2xxx/qla_target.h index 156b950ca7e7..de3942b8efc4 100644 --- a/drivers/scsi/qla2xxx/qla_target.h +++ b/drivers/scsi/qla2xxx/qla_target.h @@ -883,7 +883,6 @@ struct qla_tgt_cmd { /* to save extra sess dereferences */ unsigned int conf_compl_supported:1; unsigned int sg_mapped:1; - unsigned int free_sg:1; unsigned int write_data_transferred:1; unsigned int q_full:1; unsigned int term_exchg:1; From dceaef94a4753d4d49d493a6cd4a81168e384d6f Mon Sep 17 00:00:00 2001 From: Damien Le Moal Date: Tue, 8 Mar 2022 08:48:50 +0900 Subject: [PATCH 036/177] scsi: mpt3sas: Fix _ctl_set_task_mid() TaskMID check The TaskMID field of struct Mpi2SCSITaskManagementRequest_t is a 16-bit little endian value. Fix the search loop in _ctl_set_task_mid() to add a cpu_to_le16() conversion before checking the value of TaskMID to avoid sparse warnings. While at it, simplify the search loop code to remove an unnecessarily complicated if condition. Link: https://lore.kernel.org/r/20220307234854.148145-2-damien.lemoal@opensource.wdc.com Signed-off-by: Damien Le Moal Signed-off-by: Martin K. Petersen --- drivers/scsi/mpt3sas/mpt3sas_ctl.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c index d92ca140d298..84c87c2c3e7e 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c @@ -578,7 +578,7 @@ static int _ctl_set_task_mid(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command *karg, Mpi2SCSITaskManagementRequest_t *tm_request) { - u8 found = 0; + bool found = false; u16 smid; u16 handle; struct scsi_cmnd *scmd; @@ -600,6 +600,7 @@ _ctl_set_task_mid(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command *karg, handle = le16_to_cpu(tm_request->DevHandle); for (smid = ioc->scsiio_depth; smid && !found; smid--) { struct scsiio_tracker *st; + __le16 task_mid; scmd = mpt3sas_scsih_scsi_lookup_get(ioc, smid); if (!scmd) @@ -618,10 +619,10 @@ _ctl_set_task_mid(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command *karg, * first outstanding smid will be picked up. Otherwise, * targeted smid will be the one. */ - if (!tm_request->TaskMID || tm_request->TaskMID == st->smid) { - tm_request->TaskMID = cpu_to_le16(st->smid); - found = 1; - } + task_mid = cpu_to_le16(st->smid); + if (!tm_request->TaskMID) + tm_request->TaskMID = task_mid; + found = tm_request->TaskMID == task_mid; } if (!found) { From b4efbec4c2a75b619fae4e8768be379e88c78687 Mon Sep 17 00:00:00 2001 From: Damien Le Moal Date: Tue, 8 Mar 2022 08:48:51 +0900 Subject: [PATCH 037/177] scsi: mpt3sas: Fix writel() use writel() internally executes cpu_to_le32() to convert the value being written to little endian. The caller should thus not use this conversion function for the value passed to writel(). Remove the cpu_to_le32() calls in _base_put_smid_scsi_io_atomic(), _base_put_smid_fast_path_atomic(), _base_put_smid_hi_priority_atomic() _base_put_smid_default_atomic() and _base_handshake_req_reply_wait(). Link: https://lore.kernel.org/r/20220307234854.148145-3-damien.lemoal@opensource.wdc.com Signed-off-by: Damien Le Moal Signed-off-by: Martin K. Petersen --- drivers/scsi/mpt3sas/mpt3sas_base.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 538d2c0cd971..d7b23eb9b630 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -4312,7 +4312,7 @@ _base_put_smid_scsi_io_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid, descriptor.MSIxIndex = _base_set_and_get_msix_index(ioc, smid); descriptor.SMID = cpu_to_le16(smid); - writel(cpu_to_le32(*request), &ioc->chip->AtomicRequestDescriptorPost); + writel(*request, &ioc->chip->AtomicRequestDescriptorPost); } /** @@ -4334,7 +4334,7 @@ _base_put_smid_fast_path_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid, descriptor.MSIxIndex = _base_set_and_get_msix_index(ioc, smid); descriptor.SMID = cpu_to_le16(smid); - writel(cpu_to_le32(*request), &ioc->chip->AtomicRequestDescriptorPost); + writel(*request, &ioc->chip->AtomicRequestDescriptorPost); } /** @@ -4357,7 +4357,7 @@ _base_put_smid_hi_priority_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid, descriptor.MSIxIndex = msix_task; descriptor.SMID = cpu_to_le16(smid); - writel(cpu_to_le32(*request), &ioc->chip->AtomicRequestDescriptorPost); + writel(*request, &ioc->chip->AtomicRequestDescriptorPost); } /** @@ -4378,7 +4378,7 @@ _base_put_smid_default_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid) descriptor.MSIxIndex = _base_set_and_get_msix_index(ioc, smid); descriptor.SMID = cpu_to_le16(smid); - writel(cpu_to_le32(*request), &ioc->chip->AtomicRequestDescriptorPost); + writel(*request, &ioc->chip->AtomicRequestDescriptorPost); } /** @@ -6893,7 +6893,7 @@ _base_handshake_req_reply_wait(struct MPT3SAS_ADAPTER *ioc, int request_bytes, /* send message 32-bits at a time */ for (i = 0, failed = 0; i < request_bytes/4 && !failed; i++) { - writel(cpu_to_le32(request[i]), &ioc->chip->Doorbell); + writel(request[i], &ioc->chip->Doorbell); if ((_base_wait_for_doorbell_ack(ioc, 5))) failed = 1; } From 7ab4d2441b952977556672c2fe3f4c2a698cbb37 Mon Sep 17 00:00:00 2001 From: Damien Le Moal Date: Tue, 8 Mar 2022 08:48:52 +0900 Subject: [PATCH 038/177] scsi: mpt3sas: Fix ioc->base_readl() use The functions _base_readl_aero() and _base_readl() used for an adapter base_readl() method are implemented using a regular readl() call which internally performs a conversion to CPU endianness (le32_to_cpu()) of the values read. The users of the ioc base_readl() method should thus not convert again the values read using le16_to_cpu(). Fixing this removes sparse warnings. Link: https://lore.kernel.org/r/20220307234854.148145-4-damien.lemoal@opensource.wdc.com Signed-off-by: Damien Le Moal Signed-off-by: Martin K. Petersen --- drivers/scsi/mpt3sas/mpt3sas_base.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index d7b23eb9b630..baacba436fce 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -6912,16 +6912,16 @@ _base_handshake_req_reply_wait(struct MPT3SAS_ADAPTER *ioc, int request_bytes, } /* read the first two 16-bits, it gives the total length of the reply */ - reply[0] = le16_to_cpu(ioc->base_readl(&ioc->chip->Doorbell) - & MPI2_DOORBELL_DATA_MASK); + reply[0] = ioc->base_readl(&ioc->chip->Doorbell) + & MPI2_DOORBELL_DATA_MASK; writel(0, &ioc->chip->HostInterruptStatus); if ((_base_wait_for_doorbell_int(ioc, 5))) { ioc_err(ioc, "doorbell handshake int failed (line=%d)\n", __LINE__); return -EFAULT; } - reply[1] = le16_to_cpu(ioc->base_readl(&ioc->chip->Doorbell) - & MPI2_DOORBELL_DATA_MASK); + reply[1] = ioc->base_readl(&ioc->chip->Doorbell) + & MPI2_DOORBELL_DATA_MASK; writel(0, &ioc->chip->HostInterruptStatus); for (i = 2; i < default_reply->MsgLength * 2; i++) { @@ -6933,9 +6933,8 @@ _base_handshake_req_reply_wait(struct MPT3SAS_ADAPTER *ioc, int request_bytes, if (i >= reply_bytes/2) /* overflow case */ ioc->base_readl(&ioc->chip->Doorbell); else - reply[i] = le16_to_cpu( - ioc->base_readl(&ioc->chip->Doorbell) - & MPI2_DOORBELL_DATA_MASK); + reply[i] = ioc->base_readl(&ioc->chip->Doorbell) + & MPI2_DOORBELL_DATA_MASK; writel(0, &ioc->chip->HostInterruptStatus); } From 82b4420c288c45cc38a1be6c5b4e396c1ea4599f Mon Sep 17 00:00:00 2001 From: Damien Le Moal Date: Tue, 8 Mar 2022 08:48:53 +0900 Subject: [PATCH 039/177] scsi: mpt3sas: Fix event callback log_code value handling In mpt3sas_scsih_event_callback(), fix a sparse warning when testing the event log code value by replacing the use of a pointer to the address storing the event log code with a log code local variable. Doing so, le32_to_cpu() is used when the log code value is assigned, avoiding a sparse warning. Link: https://lore.kernel.org/r/20220307234854.148145-5-damien.lemoal@opensource.wdc.com Signed-off-by: Damien Le Moal Signed-off-by: Martin K. Petersen --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 7e476f50935b..6022875bc4a7 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -10926,20 +10926,20 @@ mpt3sas_scsih_event_callback(struct MPT3SAS_ADAPTER *ioc, u8 msix_index, case MPI2_EVENT_LOG_ENTRY_ADDED: { Mpi2EventDataLogEntryAdded_t *log_entry; - u32 *log_code; + u32 log_code; if (!ioc->is_warpdrive) break; log_entry = (Mpi2EventDataLogEntryAdded_t *) mpi_reply->EventData; - log_code = (u32 *)log_entry->LogData; + log_code = le32_to_cpu(*(__le32 *)log_entry->LogData); if (le16_to_cpu(log_entry->LogEntryQualifier) != MPT2_WARPDRIVE_LOGENTRY) break; - switch (le32_to_cpu(*log_code)) { + switch (log_code) { case MPT2_WARPDRIVE_LC_SSDT: ioc_warn(ioc, "WarpDrive Warning: IO Throttling has occurred in the WarpDrive subsystem. Check WarpDrive documentation for additional details.\n"); break; From fe413ab32b240d30c2500c3ba8f3f0ccbcf59fe4 Mon Sep 17 00:00:00 2001 From: Damien Le Moal Date: Tue, 8 Mar 2022 08:48:54 +0900 Subject: [PATCH 040/177] scsi: mpt3sas: Fix adapter replyPostRegisterIndex declaration The replyPostRegisterIndex array of struct MPT3SAS_ADAPTER stores iomem resource addresses. Fix its declaration to annotate it with __iomem to avoid sparse warnings for writel() calls using the stored addresses. Link: https://lore.kernel.org/r/20220307234854.148145-6-damien.lemoal@opensource.wdc.com Signed-off-by: Damien Le Moal Signed-off-by: Martin K. Petersen --- drivers/scsi/mpt3sas/mpt3sas_base.c | 9 +++++---- drivers/scsi/mpt3sas/mpt3sas_base.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index baacba436fce..4961be5d527b 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -3692,10 +3692,11 @@ mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc) } for (i = 0; i < ioc->combined_reply_index_count; i++) { - ioc->replyPostRegisterIndex[i] = (resource_size_t *) - ((u8 __force *)&ioc->chip->Doorbell + - MPI25_SUP_REPLY_POST_HOST_INDEX_OFFSET + - (i * MPT3_SUP_REPLY_POST_HOST_INDEX_REG_OFFSET)); + ioc->replyPostRegisterIndex[i] = + (resource_size_t __iomem *) + ((u8 __force *)&ioc->chip->Doorbell + + MPI25_SUP_REPLY_POST_HOST_INDEX_OFFSET + + (i * MPT3_SUP_REPLY_POST_HOST_INDEX_REG_OFFSET)); } } diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h index 949e98d523e2..209f8680c01d 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h @@ -1588,7 +1588,7 @@ struct MPT3SAS_ADAPTER { u8 combined_reply_index_count; u8 smp_affinity_enable; /* reply post register index */ - resource_size_t **replyPostRegisterIndex; + resource_size_t __iomem **replyPostRegisterIndex; struct list_head delayed_tr_list; struct list_head delayed_tr_volume_list; From 95af09fabf3782be9728a6af6461f6937cd8e528 Mon Sep 17 00:00:00 2001 From: Konstantin Shelekhin Date: Tue, 19 Apr 2022 00:26:22 +0300 Subject: [PATCH 041/177] scsi: target: core: Silence the message about unknown VPD pages Target does not support some VPD pages and is very verbose about it. Sometimes initiators don't bother and just keep sending the same request from time to time, filling up the logs. This patch lowers the message priority to debug. Link: https://lore.kernel.org/r/20220418212622.275516-1-k.shelekhin@yadro.com Signed-off-by: Konstantin Shelekhin Signed-off-by: Martin K. Petersen --- drivers/target/target_core_spc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c index 4c76498d3fb0..c14441c89bed 100644 --- a/drivers/target/target_core_spc.c +++ b/drivers/target/target_core_spc.c @@ -769,7 +769,7 @@ spc_emulate_inquiry(struct se_cmd *cmd) } } - pr_err("Unknown VPD Code: 0x%02x\n", cdb[2]); + pr_debug("Unknown VPD Code: 0x%02x\n", cdb[2]); ret = TCM_INVALID_CDB_FIELD; out: From 565138ac5f8a5330669a20e5f94759764e9165ec Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 21 Apr 2022 18:03:52 +0300 Subject: [PATCH 042/177] scsi: iscsi: Fix harmless double shift bug These flags are supposed to be bit numbers. Right now they cause a double shift bug where we use BIT(BIT(2)) instead of BIT(2). Fortunately, the bit numbers are small and it's done consistently so it does not cause an issue at run time. Link: https://lore.kernel.org/r/YmFyWHf8nrrx+SHa@kili Fixes: 5bd856256f8c ("scsi: iscsi: Merge suspend fields") Reviewed-by: Mike Christie Reviewed-by: Lee Duncan Signed-off-by: Dan Carpenter Signed-off-by: Martin K. Petersen --- include/scsi/libiscsi.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index d0a24779c52d..c0703cd20a99 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -54,9 +54,9 @@ enum { #define ISID_SIZE 6 /* Connection flags */ -#define ISCSI_CONN_FLAG_SUSPEND_TX BIT(0) -#define ISCSI_CONN_FLAG_SUSPEND_RX BIT(1) -#define ISCSI_CONN_FLAG_BOUND BIT(2) +#define ISCSI_CONN_FLAG_SUSPEND_TX 0 +#define ISCSI_CONN_FLAG_SUSPEND_RX 1 +#define ISCSI_CONN_FLAG_BOUND 2 #define ISCSI_ITT_MASK 0x1fff #define ISCSI_TOTAL_CMDS_MAX 4096 From a4e6496fca3f32e997e8a3b5c44e2a1ae09d018e Mon Sep 17 00:00:00 2001 From: Konstantin Vyshetsky Date: Wed, 20 Apr 2022 17:24:29 -0700 Subject: [PATCH 043/177] scsi: ufs: core: Increase fDeviceInit poll frequency UFS devices are expected to clear fDeviceInit flag in single digit milliseconds. Current values of 5 to 10 millisecond sleep add to increased latency during the initialization and resume path. This CL lowers the sleep range to 500 to 1000 microseconds. Link: https://lore.kernel.org/r/20220421002429.3136933-1-bvanassche@acm.org Acked-by: Avri Altman Signed-off-by: Konstantin Vyshetsky Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufshcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 3f9caafa91bf..ba9c7f9ec424 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -4438,7 +4438,7 @@ static int ufshcd_complete_dev_init(struct ufs_hba *hba) QUERY_FLAG_IDN_FDEVICEINIT, 0, &flag_res); if (!flag_res) break; - usleep_range(5000, 10000); + usleep_range(500, 1000); } while (ktime_before(ktime_get(), timeout)); if (err) { From 2abe580023644d76f9d4ef1c3f13f6ef38de7e15 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Apr 2022 15:57:44 -0700 Subject: [PATCH 044/177] scsi: ufs: Fix a spelling error in a source code comment Change one occurrence of "adpater" into "adapter". Link: https://lore.kernel.org/r/20220419225811.4127248-2-bvanassche@acm.org Tested-by: Bean Huo Reviewed-by: Avri Altman Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/unipro.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/unipro.h b/drivers/scsi/ufs/unipro.h index 8e9e486a4f7b..705a6465ba5c 100644 --- a/drivers/scsi/ufs/unipro.h +++ b/drivers/scsi/ufs/unipro.h @@ -103,7 +103,7 @@ #define UNIPRO_CB_OFFSET(x) (0x8000 | x) /* - * PHY Adpater attributes + * PHY Adapter attributes */ #define PA_ACTIVETXDATALANES 0x1560 #define PA_ACTIVERXDATALANES 0x1580 From 59a57bb79e1079ab634370c07eb6506711c69f85 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Apr 2022 15:57:45 -0700 Subject: [PATCH 045/177] scsi: ufs: Declare ufshcd_wait_for_register() static Declare this function static since it is only used inside the ufshcd.c source file. Link: https://lore.kernel.org/r/20220419225811.4127248-3-bvanassche@acm.org Tested-by: Bean Huo Reviewed-by: Avri Altman Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufshcd.c | 2 +- drivers/scsi/ufs/ufshcd.h | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index ba9c7f9ec424..28bdc6770e6d 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -639,7 +639,7 @@ EXPORT_SYMBOL_GPL(ufshcd_delay_us); * Return: * -ETIMEDOUT on error, zero on success. */ -int ufshcd_wait_for_register(struct ufs_hba *hba, u32 reg, u32 mask, +static int ufshcd_wait_for_register(struct ufs_hba *hba, u32 reg, u32 mask, u32 val, unsigned long interval_us, unsigned long timeout_ms) { diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 94f545be183a..c3a2043fe13d 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -1028,9 +1028,6 @@ void ufshcd_remove(struct ufs_hba *); int ufshcd_uic_hibern8_enter(struct ufs_hba *hba); int ufshcd_uic_hibern8_exit(struct ufs_hba *hba); void ufshcd_delay_us(unsigned long us, unsigned long tolerance); -int ufshcd_wait_for_register(struct ufs_hba *hba, u32 reg, u32 mask, - u32 val, unsigned long interval_us, - unsigned long timeout_ms); void ufshcd_parse_dev_ref_clk_freq(struct ufs_hba *hba, struct clk *refclk); void ufshcd_update_evt_hist(struct ufs_hba *hba, u32 id, u32 val); void ufshcd_hba_stop(struct ufs_hba *hba); From 51d1628fc4572705daabac18a7935b661baae1a0 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Apr 2022 15:57:46 -0700 Subject: [PATCH 046/177] scsi: ufs: Remove superfluous boolean conversions Remove "? true : false" if the preceding expression yields a boolean or if the result of the expression is assigned to a boolean since in these two cases the "? true : false" part is superfluous. Link: https://lore.kernel.org/r/20220419225811.4127248-4-bvanassche@acm.org Tested-by: Bean Huo Reviewed-by: Bjorn Andersson Reviewed-by: Avri Altman Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufs-qcom.c | 3 +-- drivers/scsi/ufs/ufshcd.c | 9 ++++----- drivers/scsi/ufs/ufshcd.h | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c index 586c0e567ff9..46b24b926860 100644 --- a/drivers/scsi/ufs/ufs-qcom.c +++ b/drivers/scsi/ufs/ufs-qcom.c @@ -299,8 +299,7 @@ static int ufs_qcom_power_up_sequence(struct ufs_hba *hba) struct ufs_qcom_host *host = ufshcd_get_variant(hba); struct phy *phy = host->generic_phy; int ret = 0; - bool is_rate_B = (UFS_QCOM_LIMIT_HS_RATE == PA_HS_MODE_B) - ? true : false; + bool is_rate_B = UFS_QCOM_LIMIT_HS_RATE == PA_HS_MODE_B; /* Reset UFS Host Controller and PHY */ ret = ufs_qcom_host_reset(hba); diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 28bdc6770e6d..c1a8bfe7f7cb 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -712,8 +712,7 @@ static inline u32 ufshcd_get_ufs_version(struct ufs_hba *hba) */ static inline bool ufshcd_is_device_present(struct ufs_hba *hba) { - return (ufshcd_readl(hba, REG_CONTROLLER_STATUS) & - DEVICE_PRESENT) ? true : false; + return ufshcd_readl(hba, REG_CONTROLLER_STATUS) & DEVICE_PRESENT; } /** @@ -840,7 +839,7 @@ ufshcd_get_rsp_upiu_data_seg_len(struct utp_upiu_rsp *ucd_rsp_ptr) static inline bool ufshcd_is_exception_event(struct utp_upiu_rsp *ucd_rsp_ptr) { return be32_to_cpu(ucd_rsp_ptr->header.dword_2) & - MASK_RSP_EXCEPTION_EVENT ? true : false; + MASK_RSP_EXCEPTION_EVENT; } /** @@ -1350,7 +1349,7 @@ static int ufshcd_devfreq_target(struct device *dev, } /* Decide based on the rounded-off frequency and update */ - scale_up = (*freq == clki->max_freq) ? true : false; + scale_up = *freq == clki->max_freq; if (!scale_up) *freq = clki->min_freq; /* Update the frequency */ @@ -2800,7 +2799,7 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) lrbp->sense_buffer = cmd->sense_buffer; lrbp->task_tag = tag; lrbp->lun = ufshcd_scsi_to_upiu_lun(cmd->device->lun); - lrbp->intr_cmd = !ufshcd_is_intr_aggr_allowed(hba) ? true : false; + lrbp->intr_cmd = !ufshcd_is_intr_aggr_allowed(hba); ufshcd_prepare_lrbp_crypto(scsi_cmd_to_rq(cmd), lrbp); diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index c3a2043fe13d..28ce0fda7c43 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -983,7 +983,7 @@ static inline bool ufshcd_is_auto_hibern8_supported(struct ufs_hba *hba) static inline bool ufshcd_is_auto_hibern8_enabled(struct ufs_hba *hba) { - return FIELD_GET(UFSHCI_AHIBERN8_TIMER_MASK, hba->ahit) ? true : false; + return FIELD_GET(UFSHCI_AHIBERN8_TIMER_MASK, hba->ahit); } static inline bool ufshcd_is_wb_allowed(struct ufs_hba *hba) From a858af9a9e01972c33f61036a3de6f707184e51b Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Apr 2022 15:57:47 -0700 Subject: [PATCH 047/177] scsi: ufs: Simplify statements that return a boolean Convert "if (expr) return true; else return false;" into "return expr;" if either 'expr' is a boolean expression or the return type of the function is 'bool'. Link: https://lore.kernel.org/r/20220419225811.4127248-5-bvanassche@acm.org Tested-by: Bean Huo Reviewed-by: Bjorn Andersson Reviewed-by: Keoseong Park Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufs-qcom.h | 5 +---- drivers/scsi/ufs/ufshcd.c | 22 +++++----------------- drivers/scsi/ufs/ufshpb.c | 8 ++------ 3 files changed, 8 insertions(+), 27 deletions(-) diff --git a/drivers/scsi/ufs/ufs-qcom.h b/drivers/scsi/ufs/ufs-qcom.h index 8208e3a3ef59..51570224a6e2 100644 --- a/drivers/scsi/ufs/ufs-qcom.h +++ b/drivers/scsi/ufs/ufs-qcom.h @@ -239,10 +239,7 @@ int ufs_qcom_testbus_config(struct ufs_qcom_host *host); static inline bool ufs_qcom_cap_qunipro(struct ufs_qcom_host *host) { - if (host->caps & UFS_QCOM_CAP_QUNIPRO) - return true; - else - return false; + return host->caps & UFS_QCOM_CAP_QUNIPRO; } /* ufs-qcom-ice.c */ diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index c1a8bfe7f7cb..31009007b91a 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -939,10 +939,7 @@ static bool ufshcd_is_unipro_pa_params_tuning_req(struct ufs_hba *hba) * logic simple, we will only do manual tuning if local unipro version * doesn't support ver1.6 or later. */ - if (ufshcd_get_local_unipro_ver(hba) < UFS_UNIPRO_VER_1_6) - return true; - else - return false; + return ufshcd_get_local_unipro_ver(hba) < UFS_UNIPRO_VER_1_6; } /** @@ -2216,10 +2213,7 @@ static inline int ufshcd_hba_capabilities(struct ufs_hba *hba) */ static inline bool ufshcd_ready_for_uic_cmd(struct ufs_hba *hba) { - if (ufshcd_readl(hba, REG_CONTROLLER_STATUS) & UIC_COMMAND_READY) - return true; - else - return false; + return ufshcd_readl(hba, REG_CONTROLLER_STATUS) & UIC_COMMAND_READY; } /** @@ -5781,10 +5775,7 @@ static bool ufshcd_wb_presrv_usrspc_keep_vcc_on(struct ufs_hba *hba, return false; } /* Let it continue to flush when available buffer exceeds threshold */ - if (avail_buf < hba->vps->wb_flush_threshold) - return true; - - return false; + return avail_buf < hba->vps->wb_flush_threshold; } static void ufshcd_wb_force_disable(struct ufs_hba *hba) @@ -5863,11 +5854,8 @@ static bool ufshcd_wb_need_flush(struct ufs_hba *hba) return false; } - if (!hba->dev_info.b_presrv_uspc_en) { - if (avail_buf <= UFS_WB_BUF_REMAIN_PERCENT(10)) - return true; - return false; - } + if (!hba->dev_info.b_presrv_uspc_en) + return avail_buf <= UFS_WB_BUF_REMAIN_PERCENT(10); return ufshcd_wb_presrv_usrspc_keep_vcc_on(hba, avail_buf); } diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c index fd31e516e491..40f365c537f5 100644 --- a/drivers/scsi/ufs/ufshpb.c +++ b/drivers/scsi/ufs/ufshpb.c @@ -90,12 +90,8 @@ static bool ufshpb_is_general_lun(int lun) static bool ufshpb_is_pinned_region(struct ufshpb_lu *hpb, int rgn_idx) { - if (hpb->lu_pinned_end != PINNED_NOT_SET && - rgn_idx >= hpb->lu_pinned_start && - rgn_idx <= hpb->lu_pinned_end) - return true; - - return false; + return hpb->lu_pinned_end != PINNED_NOT_SET && + rgn_idx >= hpb->lu_pinned_start && rgn_idx <= hpb->lu_pinned_end; } static void ufshpb_kick_map_work(struct ufshpb_lu *hpb) From b639b59b44fdab99bcff7b4d01ef642605ae7aa4 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Apr 2022 15:57:48 -0700 Subject: [PATCH 048/177] scsi: ufs: Remove ufshcd_lrb.sense_bufflen ufshcd_lrb.sense_bufflen is set but never read. Hence remove this struct member. Link: https://lore.kernel.org/r/20220419225811.4127248-6-bvanassche@acm.org Tested-by: Bean Huo Reviewed-by: Avri Altman Reviewed-by: Keoseong Park Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufshcd.c | 3 --- drivers/scsi/ufs/ufshcd.h | 2 -- 2 files changed, 5 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 31009007b91a..9f4bd3ac253a 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -2789,7 +2789,6 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) lrbp = &hba->lrb[tag]; WARN_ON(lrbp->cmd); lrbp->cmd = cmd; - lrbp->sense_bufflen = UFS_SENSE_SIZE; lrbp->sense_buffer = cmd->sense_buffer; lrbp->task_tag = tag; lrbp->lun = ufshcd_scsi_to_upiu_lun(cmd->device->lun); @@ -2830,7 +2829,6 @@ static int ufshcd_compose_dev_cmd(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, enum dev_cmd_type cmd_type, int tag) { lrbp->cmd = NULL; - lrbp->sense_bufflen = 0; lrbp->sense_buffer = NULL; lrbp->task_tag = tag; lrbp->lun = 0; /* device management cmd is not specific to any LUN */ @@ -6802,7 +6800,6 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba, lrbp = &hba->lrb[tag]; WARN_ON(lrbp->cmd); lrbp->cmd = NULL; - lrbp->sense_bufflen = 0; lrbp->sense_buffer = NULL; lrbp->task_tag = tag; lrbp->lun = 0; diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 28ce0fda7c43..acac2acfe347 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -182,7 +182,6 @@ struct ufs_pm_lvl_states { * @ucd_req_dma_addr: UPIU request dma address for debug * @cmd: pointer to SCSI command * @sense_buffer: pointer to sense buffer address of the SCSI command - * @sense_bufflen: Length of the sense buffer * @scsi_status: SCSI status of the command * @command_type: SCSI, UFS, Query. * @task_tag: Task tag of the command @@ -207,7 +206,6 @@ struct ufshcd_lrb { struct scsi_cmnd *cmd; u8 *sense_buffer; - unsigned int sense_bufflen; int scsi_status; int command_type; From 1de4378f605787d79a6aab905c96a4320411b9b1 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Apr 2022 15:57:49 -0700 Subject: [PATCH 049/177] scsi: ufs: Remove ufshcd_lrb.sense_buffer ufshcd_lrb.sense_buffer is NULL if ufshcd_lrb.cmd is NULL and ufshcd_lrb.sense_buffer points at cmd->sense_buffer if ufshcd_lrb.cmd is set. In other words, the ufshcd_lrb.sense_buffer member is identical to cmd->sense_buffer. Hence this patch that removes the ufshcd_lrb.sense_buffer structure member. Link: https://lore.kernel.org/r/20220419225811.4127248-7-bvanassche@acm.org Tested-by: Bean Huo Reviewed-by: Avri Altman Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufshcd.c | 9 ++++----- drivers/scsi/ufs/ufshcd.h | 2 -- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 9f4bd3ac253a..cb967fecd16d 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -2127,15 +2127,17 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag) */ static inline void ufshcd_copy_sense_data(struct ufshcd_lrb *lrbp) { + u8 *const sense_buffer = lrbp->cmd->sense_buffer; int len; - if (lrbp->sense_buffer && + + if (sense_buffer && ufshcd_get_rsp_upiu_data_seg_len(lrbp->ucd_rsp_ptr)) { int len_to_copy; len = be16_to_cpu(lrbp->ucd_rsp_ptr->sr.sense_data_len); len_to_copy = min_t(int, UFS_SENSE_SIZE, len); - memcpy(lrbp->sense_buffer, lrbp->ucd_rsp_ptr->sr.sense_data, + memcpy(sense_buffer, lrbp->ucd_rsp_ptr->sr.sense_data, len_to_copy); } } @@ -2789,7 +2791,6 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) lrbp = &hba->lrb[tag]; WARN_ON(lrbp->cmd); lrbp->cmd = cmd; - lrbp->sense_buffer = cmd->sense_buffer; lrbp->task_tag = tag; lrbp->lun = ufshcd_scsi_to_upiu_lun(cmd->device->lun); lrbp->intr_cmd = !ufshcd_is_intr_aggr_allowed(hba); @@ -2829,7 +2830,6 @@ static int ufshcd_compose_dev_cmd(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, enum dev_cmd_type cmd_type, int tag) { lrbp->cmd = NULL; - lrbp->sense_buffer = NULL; lrbp->task_tag = tag; lrbp->lun = 0; /* device management cmd is not specific to any LUN */ lrbp->intr_cmd = true; /* No interrupt aggregation */ @@ -6800,7 +6800,6 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba, lrbp = &hba->lrb[tag]; WARN_ON(lrbp->cmd); lrbp->cmd = NULL; - lrbp->sense_buffer = NULL; lrbp->task_tag = tag; lrbp->lun = 0; lrbp->intr_cmd = true; diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index acac2acfe347..83a0b6904f77 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -181,7 +181,6 @@ struct ufs_pm_lvl_states { * @ucd_rsp_dma_addr: UPIU response dma address for debug * @ucd_req_dma_addr: UPIU request dma address for debug * @cmd: pointer to SCSI command - * @sense_buffer: pointer to sense buffer address of the SCSI command * @scsi_status: SCSI status of the command * @command_type: SCSI, UFS, Query. * @task_tag: Task tag of the command @@ -205,7 +204,6 @@ struct ufshcd_lrb { dma_addr_t ucd_prdt_dma_addr; struct scsi_cmnd *cmd; - u8 *sense_buffer; int scsi_status; int command_type; From 9d3ab17e840c48c3ca427c5f7138f361e2d8394c Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Apr 2022 15:57:50 -0700 Subject: [PATCH 050/177] scsi: ufs: Use get_unaligned_be16() instead of be16_to_cpup() Use get_unaligned_be16(...) instead of the equivalent but harder to read be16_to_cpup((__be16 *)...). Link: https://lore.kernel.org/r/20220419225811.4127248-8-bvanassche@acm.org Tested-by: Bean Huo Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufshcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index cb967fecd16d..e400f28e54a3 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -7334,7 +7334,7 @@ static u32 ufshcd_get_max_icc_level(int sup_curr_uA, u32 start_scan, char *buff) u16 unit; for (i = start_scan; i >= 0; i--) { - data = be16_to_cpup((__be16 *)&buff[2 * i]); + data = get_unaligned_be16(&buff[2 * i]); unit = (data & ATTR_ICC_LVL_UNIT_MASK) >> ATTR_ICC_LVL_UNIT_OFFSET; curr_uA = data & ATTR_ICC_LVL_VALUE_MASK; From dd2cf44ff4eca20b4b42014d1c7ada3518fda4e1 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Apr 2022 15:57:51 -0700 Subject: [PATCH 051/177] scsi: ufs: Remove the UFS_FIX() and END_FIX() macros Since these two macros reduce code readability, remove them. Link: https://lore.kernel.org/r/20220419225811.4127248-9-bvanassche@acm.org Tested-by: Bean Huo Reviewed-by: Avri Altman Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufs-mediatek.c | 12 +++++---- drivers/scsi/ufs/ufs_quirks.h | 9 ------- drivers/scsi/ufs/ufshcd.c | 43 +++++++++++++++++++-------------- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c index 86a938075f30..b275b440f027 100644 --- a/drivers/scsi/ufs/ufs-mediatek.c +++ b/drivers/scsi/ufs/ufs-mediatek.c @@ -45,11 +45,13 @@ ufs_mtk_smc(UFS_MTK_SIP_DEVICE_RESET, high, res) static struct ufs_dev_fix ufs_mtk_dev_fixups[] = { - UFS_FIX(UFS_VENDOR_MICRON, UFS_ANY_MODEL, - UFS_DEVICE_QUIRK_DELAY_AFTER_LPM), - UFS_FIX(UFS_VENDOR_SKHYNIX, "H9HQ21AFAMZDAR", - UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES), - END_FIX + { .wmanufacturerid = UFS_VENDOR_MICRON, + .model = UFS_ANY_MODEL, + .quirk = UFS_DEVICE_QUIRK_DELAY_AFTER_LPM }, + { .wmanufacturerid = UFS_VENDOR_SKHYNIX, + .model = "H9HQ21AFAMZDAR", + .quirk = UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES }, + {} }; static const struct of_device_id ufs_mtk_of_match[] = { diff --git a/drivers/scsi/ufs/ufs_quirks.h b/drivers/scsi/ufs/ufs_quirks.h index 35ec9ea79869..e6c535c77527 100644 --- a/drivers/scsi/ufs/ufs_quirks.h +++ b/drivers/scsi/ufs/ufs_quirks.h @@ -29,15 +29,6 @@ struct ufs_dev_fix { unsigned int quirk; }; -#define END_FIX { } - -/* add specific device quirk */ -#define UFS_FIX(_vendor, _model, _quirk) { \ - .wmanufacturerid = (_vendor),\ - .model = (_model), \ - .quirk = (_quirk), \ -} - /* * Some vendor's UFS device sends back to back NACs for the DL data frames * causing the host controller to raise the DFES error status. Sometimes diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index e400f28e54a3..23a1b71e0e58 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -206,24 +206,31 @@ ufs_get_desired_pm_lvl_for_dev_link_state(enum ufs_dev_pwr_mode dev_state, static struct ufs_dev_fix ufs_fixups[] = { /* UFS cards deviations table */ - UFS_FIX(UFS_VENDOR_MICRON, UFS_ANY_MODEL, - UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM | - UFS_DEVICE_QUIRK_SWAP_L2P_ENTRY_FOR_HPB_READ), - UFS_FIX(UFS_VENDOR_SAMSUNG, UFS_ANY_MODEL, - UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM | - UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE | - UFS_DEVICE_QUIRK_RECOVERY_FROM_DL_NAC_ERRORS), - UFS_FIX(UFS_VENDOR_SKHYNIX, UFS_ANY_MODEL, - UFS_DEVICE_QUIRK_HOST_PA_SAVECONFIGTIME), - UFS_FIX(UFS_VENDOR_SKHYNIX, "hB8aL1" /*H28U62301AMR*/, - UFS_DEVICE_QUIRK_HOST_VS_DEBUGSAVECONFIGTIME), - UFS_FIX(UFS_VENDOR_TOSHIBA, UFS_ANY_MODEL, - UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM), - UFS_FIX(UFS_VENDOR_TOSHIBA, "THGLF2G9C8KBADG", - UFS_DEVICE_QUIRK_PA_TACTIVATE), - UFS_FIX(UFS_VENDOR_TOSHIBA, "THGLF2G9D8KBADG", - UFS_DEVICE_QUIRK_PA_TACTIVATE), - END_FIX + { .wmanufacturerid = UFS_VENDOR_MICRON, + .model = UFS_ANY_MODEL, + .quirk = UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM | + UFS_DEVICE_QUIRK_SWAP_L2P_ENTRY_FOR_HPB_READ }, + { .wmanufacturerid = UFS_VENDOR_SAMSUNG, + .model = UFS_ANY_MODEL, + .quirk = UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM | + UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE | + UFS_DEVICE_QUIRK_RECOVERY_FROM_DL_NAC_ERRORS }, + { .wmanufacturerid = UFS_VENDOR_SKHYNIX, + .model = UFS_ANY_MODEL, + .quirk = UFS_DEVICE_QUIRK_HOST_PA_SAVECONFIGTIME }, + { .wmanufacturerid = UFS_VENDOR_SKHYNIX, + .model = "hB8aL1" /*H28U62301AMR*/, + .quirk = UFS_DEVICE_QUIRK_HOST_VS_DEBUGSAVECONFIGTIME }, + { .wmanufacturerid = UFS_VENDOR_TOSHIBA, + .model = UFS_ANY_MODEL, + .quirk = UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM }, + { .wmanufacturerid = UFS_VENDOR_TOSHIBA, + .model = "THGLF2G9C8KBADG", + .quirk = UFS_DEVICE_QUIRK_PA_TACTIVATE }, + { .wmanufacturerid = UFS_VENDOR_TOSHIBA, + .model = "THGLF2G9D8KBADG", + .quirk = UFS_DEVICE_QUIRK_PA_TACTIVATE }, + {} }; static irqreturn_t ufshcd_tmc_handler(struct ufs_hba *hba); From 25eff2f543b11597a6200c55ca3a1bdf0a77bf9f Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Apr 2022 15:57:52 -0700 Subject: [PATCH 052/177] scsi: ufs: Rename struct ufs_dev_fix into ufs_dev_quirk Since struct ufs_dev_fix contains quirk information, rename it into struct ufs_dev_quirk. Link: https://lore.kernel.org/r/20220419225811.4127248-10-bvanassche@acm.org Tested-by: Bean Huo Reviewed-by: Avri Altman Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufs-mediatek.c | 2 +- drivers/scsi/ufs/ufs_quirks.h | 4 ++-- drivers/scsi/ufs/ufshcd.c | 6 +++--- drivers/scsi/ufs/ufshcd.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c index b275b440f027..217348dde6a6 100644 --- a/drivers/scsi/ufs/ufs-mediatek.c +++ b/drivers/scsi/ufs/ufs-mediatek.c @@ -44,7 +44,7 @@ #define ufs_mtk_device_reset_ctrl(high, res) \ ufs_mtk_smc(UFS_MTK_SIP_DEVICE_RESET, high, res) -static struct ufs_dev_fix ufs_mtk_dev_fixups[] = { +static struct ufs_dev_quirk ufs_mtk_dev_fixups[] = { { .wmanufacturerid = UFS_VENDOR_MICRON, .model = UFS_ANY_MODEL, .quirk = UFS_DEVICE_QUIRK_DELAY_AFTER_LPM }, diff --git a/drivers/scsi/ufs/ufs_quirks.h b/drivers/scsi/ufs/ufs_quirks.h index e6c535c77527..e38dec5f0351 100644 --- a/drivers/scsi/ufs/ufs_quirks.h +++ b/drivers/scsi/ufs/ufs_quirks.h @@ -19,11 +19,11 @@ #define UFS_VENDOR_WDC 0x145 /** - * ufs_dev_fix - ufs device quirk info + * ufs_dev_quirk - ufs device quirk info * @card: ufs card details * @quirk: device quirk */ -struct ufs_dev_fix { +struct ufs_dev_quirk { u16 wmanufacturerid; u8 *model; unsigned int quirk; diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 23a1b71e0e58..d9294a65ea46 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -204,7 +204,7 @@ ufs_get_desired_pm_lvl_for_dev_link_state(enum ufs_dev_pwr_mode dev_state, return UFS_PM_LVL_0; } -static struct ufs_dev_fix ufs_fixups[] = { +static struct ufs_dev_quirk ufs_fixups[] = { /* UFS cards deviations table */ { .wmanufacturerid = UFS_VENDOR_MICRON, .model = UFS_ANY_MODEL, @@ -7624,9 +7624,9 @@ static void ufshcd_temp_notif_probe(struct ufs_hba *hba, u8 *desc_buf) } } -void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, struct ufs_dev_fix *fixups) +void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, struct ufs_dev_quirk *fixups) { - struct ufs_dev_fix *f; + struct ufs_dev_quirk *f; struct ufs_dev_info *dev_info = &hba->dev_info; if (!fixups) diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 83a0b6904f77..84b723b1855a 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -1178,7 +1178,7 @@ int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode, void ufshcd_auto_hibern8_enable(struct ufs_hba *hba); void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit); -void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, struct ufs_dev_fix *fixups); +void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, struct ufs_dev_quirk *fixups); #define SD_ASCII_STD true #define SD_RAW false int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index, From aead21f32ae787af140233e32e18801dfd5185b1 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Apr 2022 15:57:53 -0700 Subject: [PATCH 053/177] scsi: ufs: Declare the quirks array const Declare the quirks array and also its 'model' member const to make it explicit that these are not modified. Link: https://lore.kernel.org/r/20220419225811.4127248-11-bvanassche@acm.org Tested-by: Bean Huo Reviewed-by: Avri Altman Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufs-mediatek.c | 2 +- drivers/scsi/ufs/ufs_quirks.h | 2 +- drivers/scsi/ufs/ufshcd.c | 7 ++++--- drivers/scsi/ufs/ufshcd.h | 3 ++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c index 217348dde6a6..9a4474210627 100644 --- a/drivers/scsi/ufs/ufs-mediatek.c +++ b/drivers/scsi/ufs/ufs-mediatek.c @@ -44,7 +44,7 @@ #define ufs_mtk_device_reset_ctrl(high, res) \ ufs_mtk_smc(UFS_MTK_SIP_DEVICE_RESET, high, res) -static struct ufs_dev_quirk ufs_mtk_dev_fixups[] = { +static const struct ufs_dev_quirk ufs_mtk_dev_fixups[] = { { .wmanufacturerid = UFS_VENDOR_MICRON, .model = UFS_ANY_MODEL, .quirk = UFS_DEVICE_QUIRK_DELAY_AFTER_LPM }, diff --git a/drivers/scsi/ufs/ufs_quirks.h b/drivers/scsi/ufs/ufs_quirks.h index e38dec5f0351..bcb4f004bed5 100644 --- a/drivers/scsi/ufs/ufs_quirks.h +++ b/drivers/scsi/ufs/ufs_quirks.h @@ -25,7 +25,7 @@ */ struct ufs_dev_quirk { u16 wmanufacturerid; - u8 *model; + const u8 *model; unsigned int quirk; }; diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index d9294a65ea46..e2d93f9668a3 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -204,7 +204,7 @@ ufs_get_desired_pm_lvl_for_dev_link_state(enum ufs_dev_pwr_mode dev_state, return UFS_PM_LVL_0; } -static struct ufs_dev_quirk ufs_fixups[] = { +static const struct ufs_dev_quirk ufs_fixups[] = { /* UFS cards deviations table */ { .wmanufacturerid = UFS_VENDOR_MICRON, .model = UFS_ANY_MODEL, @@ -7624,9 +7624,10 @@ static void ufshcd_temp_notif_probe(struct ufs_hba *hba, u8 *desc_buf) } } -void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, struct ufs_dev_quirk *fixups) +void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, + const struct ufs_dev_quirk *fixups) { - struct ufs_dev_quirk *f; + const struct ufs_dev_quirk *f; struct ufs_dev_info *dev_info = &hba->dev_info; if (!fixups) diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 84b723b1855a..37e8b72b8c86 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -1178,7 +1178,8 @@ int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode, void ufshcd_auto_hibern8_enable(struct ufs_hba *hba); void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit); -void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, struct ufs_dev_quirk *fixups); +void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, + const struct ufs_dev_quirk *fixups); #define SD_ASCII_STD true #define SD_RAW false int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index, From acbbfe484faac99d0088aa259e62a5b55aef3b39 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Apr 2022 15:57:54 -0700 Subject: [PATCH 054/177] scsi: ufs: Invert the return value of ufshcd_is_hba_active() It is confusing that ufshcd_is_hba_active() returns 'true' if the HBA is not active. Clear up this confusion by inverting the return value of ufshcd_is_hba_active(). This patch does not change any functionality. Link: https://lore.kernel.org/r/20220419225811.4127248-12-bvanassche@acm.org Tested-by: Bean Huo Reviewed-by: Avri Altman Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufshcd.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index e2d93f9668a3..e27d62e9bc83 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -917,12 +917,11 @@ static inline void ufshcd_hba_start(struct ufs_hba *hba) * ufshcd_is_hba_active - Get controller state * @hba: per adapter instance * - * Returns false if controller is active, true otherwise + * Returns true if and only if the controller is active. */ static inline bool ufshcd_is_hba_active(struct ufs_hba *hba) { - return (ufshcd_readl(hba, REG_CONTROLLER_ENABLE) & CONTROLLER_ENABLE) - ? false : true; + return ufshcd_readl(hba, REG_CONTROLLER_ENABLE) & CONTROLLER_ENABLE; } u32 ufshcd_get_local_unipro_ver(struct ufs_hba *hba) @@ -4552,7 +4551,7 @@ static int ufshcd_hba_execute_hce(struct ufs_hba *hba) int retry_inner; start: - if (!ufshcd_is_hba_active(hba)) + if (ufshcd_is_hba_active(hba)) /* change controller state to "reset state" */ ufshcd_hba_stop(hba); @@ -4578,7 +4577,7 @@ start: /* wait for the host controller to complete initialization */ retry_inner = 50; - while (ufshcd_is_hba_active(hba)) { + while (!ufshcd_is_hba_active(hba)) { if (retry_inner) { retry_inner--; } else { From 9474c64e83ca5561a7c5b410395ec6c24616d3b4 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Apr 2022 15:57:55 -0700 Subject: [PATCH 055/177] scsi: ufs: Remove unused constants and code Commit 5b44a07b6bb2 ("scsi: ufs: Remove pre-defined initial voltage values of device power") removed the code that uses the UFS_VREG_VCC* constants and also the code that sets the min_uV and max_uV member variables. Hence also remove these constants and that member variable. Link: https://lore.kernel.org/r/20220419225811.4127248-13-bvanassche@acm.org Tested-by: Bean Huo Reviewed-by: Stanley Chu Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufs.h | 11 ----------- drivers/scsi/ufs/ufshcd.c | 29 +++-------------------------- 2 files changed, 3 insertions(+), 37 deletions(-) diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h index 4a00c24a3209..225b5b4a2a7e 100644 --- a/drivers/scsi/ufs/ufs.h +++ b/drivers/scsi/ufs/ufs.h @@ -562,15 +562,6 @@ struct ufs_query_res { struct utp_upiu_query upiu_res; }; -#define UFS_VREG_VCC_MIN_UV 2700000 /* uV */ -#define UFS_VREG_VCC_MAX_UV 3600000 /* uV */ -#define UFS_VREG_VCC_1P8_MIN_UV 1700000 /* uV */ -#define UFS_VREG_VCC_1P8_MAX_UV 1950000 /* uV */ -#define UFS_VREG_VCCQ_MIN_UV 1140000 /* uV */ -#define UFS_VREG_VCCQ_MAX_UV 1260000 /* uV */ -#define UFS_VREG_VCCQ2_MIN_UV 1700000 /* uV */ -#define UFS_VREG_VCCQ2_MAX_UV 1950000 /* uV */ - /* * VCCQ & VCCQ2 current requirement when UFS device is in sleep state * and link is in Hibern8 state. @@ -582,8 +573,6 @@ struct ufs_vreg { const char *name; bool always_on; bool enabled; - int min_uV; - int max_uV; int max_uA; }; diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index e27d62e9bc83..71feec3345ec 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -8309,33 +8309,10 @@ static inline int ufshcd_config_vreg_hpm(struct ufs_hba *hba, static int ufshcd_config_vreg(struct device *dev, struct ufs_vreg *vreg, bool on) { - int ret = 0; - struct regulator *reg; - const char *name; - int min_uV, uA_load; + if (regulator_count_voltages(vreg->reg) <= 0) + return 0; - BUG_ON(!vreg); - - reg = vreg->reg; - name = vreg->name; - - if (regulator_count_voltages(reg) > 0) { - uA_load = on ? vreg->max_uA : 0; - ret = ufshcd_config_vreg_load(dev, vreg, uA_load); - if (ret) - goto out; - - if (vreg->min_uV && vreg->max_uV) { - min_uV = on ? vreg->min_uV : 0; - ret = regulator_set_voltage(reg, min_uV, vreg->max_uV); - if (ret) - dev_err(dev, - "%s: %s set voltage failed, err=%d\n", - __func__, name, ret); - } - } -out: - return ret; + return ufshcd_config_vreg_load(dev, vreg, on ? vreg->max_uA : 0); } static int ufshcd_enable_vreg(struct device *dev, struct ufs_vreg *vreg) From 778d2b0ec6d11642f42ad55b0415988a85255f6c Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Apr 2022 15:57:56 -0700 Subject: [PATCH 056/177] scsi: ufs: Switch to aggregate initialization Make it easier to verify for humans that ufshcd_init_pwr_dev_param() initializes all structure members. This patch does not change any functionality. Link: https://lore.kernel.org/r/20220419225811.4127248-14-bvanassche@acm.org Tested-by: Bean Huo Reviewed-by: Avri Altman Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufshcd-pltfrm.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c index cca4b2181a81..9923cbc70653 100644 --- a/drivers/scsi/ufs/ufshcd-pltfrm.c +++ b/drivers/scsi/ufs/ufshcd-pltfrm.c @@ -297,18 +297,20 @@ EXPORT_SYMBOL_GPL(ufshcd_get_pwr_dev_param); void ufshcd_init_pwr_dev_param(struct ufs_dev_params *dev_param) { - dev_param->tx_lanes = 2; - dev_param->rx_lanes = 2; - dev_param->hs_rx_gear = UFS_HS_G3; - dev_param->hs_tx_gear = UFS_HS_G3; - dev_param->pwm_rx_gear = UFS_PWM_G4; - dev_param->pwm_tx_gear = UFS_PWM_G4; - dev_param->rx_pwr_pwm = SLOW_MODE; - dev_param->tx_pwr_pwm = SLOW_MODE; - dev_param->rx_pwr_hs = FAST_MODE; - dev_param->tx_pwr_hs = FAST_MODE; - dev_param->hs_rate = PA_HS_MODE_B; - dev_param->desired_working_mode = UFS_HS_MODE; + *dev_param = (struct ufs_dev_params){ + .tx_lanes = 2, + .rx_lanes = 2, + .hs_rx_gear = UFS_HS_G3, + .hs_tx_gear = UFS_HS_G3, + .pwm_rx_gear = UFS_PWM_G4, + .pwm_tx_gear = UFS_PWM_G4, + .rx_pwr_pwm = SLOW_MODE, + .tx_pwr_pwm = SLOW_MODE, + .rx_pwr_hs = FAST_MODE, + .tx_pwr_hs = FAST_MODE, + .hs_rate = PA_HS_MODE_B, + .desired_working_mode = UFS_HS_MODE, + }; } EXPORT_SYMBOL_GPL(ufshcd_init_pwr_dev_param); From c906e8328de83b27f27af07cf79afb799e69838a Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Apr 2022 15:57:57 -0700 Subject: [PATCH 057/177] scsi: ufs: Make the config_scaling_param calls type safe Pass the actual type to config_scaling_param callback as the third argment instead of a void pointer. Remove a superfluous NULL pointer check from ufs_qcom_config_scaling_param(). Link: https://lore.kernel.org/r/20220419225811.4127248-15-bvanassche@acm.org Tested-by: Bean Huo Reviewed-by: Bjorn Andersson Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufs-qcom.c | 14 ++++---------- drivers/scsi/ufs/ufshcd.h | 10 +++++----- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c index 46b24b926860..851caef04a60 100644 --- a/drivers/scsi/ufs/ufs-qcom.c +++ b/drivers/scsi/ufs/ufs-qcom.c @@ -1448,23 +1448,17 @@ static int ufs_qcom_device_reset(struct ufs_hba *hba) #if IS_ENABLED(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND) static void ufs_qcom_config_scaling_param(struct ufs_hba *hba, - struct devfreq_dev_profile *p, - void *data) + struct devfreq_dev_profile *p, + struct devfreq_simple_ondemand_data *d) { - static struct devfreq_simple_ondemand_data *d; - - if (!data) - return; - - d = (struct devfreq_simple_ondemand_data *)data; p->polling_ms = 60; d->upthreshold = 70; d->downdifferential = 5; } #else static void ufs_qcom_config_scaling_param(struct ufs_hba *hba, - struct devfreq_dev_profile *p, - void *data) + struct devfreq_dev_profile *p, + struct devfreq_simple_ondemand_data *data) { } #endif diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 37e8b72b8c86..a755718649ae 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -348,8 +348,8 @@ struct ufs_hba_variant_ops { int (*phy_initialization)(struct ufs_hba *); int (*device_reset)(struct ufs_hba *hba); void (*config_scaling_param)(struct ufs_hba *hba, - struct devfreq_dev_profile *profile, - void *data); + struct devfreq_dev_profile *profile, + struct devfreq_simple_ondemand_data *data); int (*program_key)(struct ufs_hba *hba, const union ufs_crypto_cfg_entry *cfg, int slot); void (*event_notify)(struct ufs_hba *hba, @@ -1358,11 +1358,11 @@ static inline int ufshcd_vops_device_reset(struct ufs_hba *hba) } static inline void ufshcd_vops_config_scaling_param(struct ufs_hba *hba, - struct devfreq_dev_profile - *profile, void *data) + struct devfreq_dev_profile *p, + struct devfreq_simple_ondemand_data *data) { if (hba->vops && hba->vops->config_scaling_param) - hba->vops->config_scaling_param(hba, profile, data); + hba->vops->config_scaling_param(hba, p, data); } extern struct ufs_pm_lvl_states ufs_pm_lvl_states[]; From b4ade33b0d168334177466488cd7aa03b1569a86 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Apr 2022 15:57:58 -0700 Subject: [PATCH 058/177] scsi: ufs: Remove the driver version The current version number is 0.2. That driver version was assigned more than nine years ago. A version number that is not updated while the driver is updated is not useful. Hence remove the driver version number from the UFS driver. See also commit e0eca63e3421 ("[SCSI] ufs: Separate PCI code into glue driver"). Link: https://lore.kernel.org/r/20220419225811.4127248-16-bvanassche@acm.org Tested-by: Bean Huo Reviewed-by: Bean Huo Reviewed-by: Avri Altman Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/cdns-pltfrm.c | 1 - drivers/scsi/ufs/ufshcd-pci.c | 1 - drivers/scsi/ufs/ufshcd-pltfrm.c | 1 - drivers/scsi/ufs/ufshcd.c | 1 - drivers/scsi/ufs/ufshcd.h | 1 - 5 files changed, 5 deletions(-) diff --git a/drivers/scsi/ufs/cdns-pltfrm.c b/drivers/scsi/ufs/cdns-pltfrm.c index 7da8be2f35c4..e91cf9fd5a95 100644 --- a/drivers/scsi/ufs/cdns-pltfrm.c +++ b/drivers/scsi/ufs/cdns-pltfrm.c @@ -340,4 +340,3 @@ module_platform_driver(cdns_ufs_pltfrm_driver); MODULE_AUTHOR("Jan Kotas "); MODULE_DESCRIPTION("Cadence UFS host controller platform driver"); MODULE_LICENSE("GPL v2"); -MODULE_VERSION(UFSHCD_DRIVER_VERSION); diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs/ufshcd-pci.c index e892b9feffb1..27029d2523b6 100644 --- a/drivers/scsi/ufs/ufshcd-pci.c +++ b/drivers/scsi/ufs/ufshcd-pci.c @@ -618,4 +618,3 @@ MODULE_AUTHOR("Santosh Yaragnavi "); MODULE_AUTHOR("Vinayak Holikatti "); MODULE_DESCRIPTION("UFS host controller PCI glue driver"); MODULE_LICENSE("GPL"); -MODULE_VERSION(UFSHCD_DRIVER_VERSION); diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c index 9923cbc70653..fc5191101192 100644 --- a/drivers/scsi/ufs/ufshcd-pltfrm.c +++ b/drivers/scsi/ufs/ufshcd-pltfrm.c @@ -386,4 +386,3 @@ MODULE_AUTHOR("Santosh Yaragnavi "); MODULE_AUTHOR("Vinayak Holikatti "); MODULE_DESCRIPTION("UFS host controller Platform bus based glue driver"); MODULE_LICENSE("GPL"); -MODULE_VERSION(UFSHCD_DRIVER_VERSION); diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 71feec3345ec..9e09856229eb 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -9923,4 +9923,3 @@ MODULE_AUTHOR("Santosh Yaragnavi "); MODULE_AUTHOR("Vinayak Holikatti "); MODULE_DESCRIPTION("Generic UFS host controller driver Core"); MODULE_LICENSE("GPL"); -MODULE_VERSION(UFSHCD_DRIVER_VERSION); diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index a755718649ae..a6c12869b2db 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -49,7 +49,6 @@ #include "ufshci.h" #define UFSHCD "ufshcd" -#define UFSHCD_DRIVER_VERSION "0.2" struct ufs_hba; From e2106584d0110b2613cc7de3bf013fa9e070bfd1 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Apr 2022 15:57:59 -0700 Subject: [PATCH 059/177] scsi: ufs: Rename sdev_ufs_device into ufs_device_wlun The new name reflects the role of this member variable better: a WLUN through which the power mode of the UFS device is controlled. Link: https://lore.kernel.org/r/20220419225811.4127248-17-bvanassche@acm.org Tested-by: Bean Huo Reviewed-by: Avri Altman Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufshcd.c | 50 +++++++++++++++++++-------------------- drivers/scsi/ufs/ufshcd.h | 17 ++++++------- 2 files changed, 32 insertions(+), 35 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 9e09856229eb..11808ce43357 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -540,7 +540,7 @@ static void ufshcd_print_tmrs(struct ufs_hba *hba, unsigned long bitmap) static void ufshcd_print_host_state(struct ufs_hba *hba) { - struct scsi_device *sdev_ufs = hba->sdev_ufs_device; + struct scsi_device *sdev_ufs = hba->ufs_device_wlun; dev_err(hba->dev, "UFS Host state=%d\n", hba->ufshcd_state); dev_err(hba->dev, "outstanding reqs=0x%lx tasks=0x%lx\n", @@ -4195,7 +4195,7 @@ void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit) spin_unlock_irqrestore(hba->host->host_lock, flags); if (update && - !pm_runtime_suspended(&hba->sdev_ufs_device->sdev_gendev)) { + !pm_runtime_suspended(&hba->ufs_device_wlun->sdev_gendev)) { ufshcd_rpm_get_sync(hba); ufshcd_hold(hba, false); ufshcd_auto_hibern8_enable(hba); @@ -4911,13 +4911,13 @@ static void ufshcd_setup_links(struct ufs_hba *hba, struct scsi_device *sdev) * Device wlun is the supplier & rest of the luns are consumers. * This ensures that device wlun suspends after all other luns. */ - if (hba->sdev_ufs_device) { + if (hba->ufs_device_wlun) { link = device_link_add(&sdev->sdev_gendev, - &hba->sdev_ufs_device->sdev_gendev, + &hba->ufs_device_wlun->sdev_gendev, DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); if (!link) { dev_err(&sdev->sdev_gendev, "Failed establishing link - %s\n", - dev_name(&hba->sdev_ufs_device->sdev_gendev)); + dev_name(&hba->ufs_device_wlun->sdev_gendev)); return; } hba->luns_avail--; @@ -5053,15 +5053,15 @@ static void ufshcd_slave_destroy(struct scsi_device *sdev) /* Drop the reference as it won't be needed anymore */ if (ufshcd_scsi_to_upiu_lun(sdev->lun) == UFS_UPIU_UFS_DEVICE_WLUN) { spin_lock_irqsave(hba->host->host_lock, flags); - hba->sdev_ufs_device = NULL; + hba->ufs_device_wlun = NULL; spin_unlock_irqrestore(hba->host->host_lock, flags); - } else if (hba->sdev_ufs_device) { + } else if (hba->ufs_device_wlun) { struct device *supplier = NULL; /* Ensure UFS Device WLUN exists and does not disappear */ spin_lock_irqsave(hba->host->host_lock, flags); - if (hba->sdev_ufs_device) { - supplier = &hba->sdev_ufs_device->sdev_gendev; + if (hba->ufs_device_wlun) { + supplier = &hba->ufs_device_wlun->sdev_gendev; get_device(supplier); } spin_unlock_irqrestore(hba->host->host_lock, flags); @@ -6037,7 +6037,7 @@ static void ufshcd_clk_scaling_suspend(struct ufs_hba *hba, bool suspend) static void ufshcd_err_handling_prepare(struct ufs_hba *hba) { ufshcd_rpm_get_sync(hba); - if (pm_runtime_status_suspended(&hba->sdev_ufs_device->sdev_gendev) || + if (pm_runtime_status_suspended(&hba->ufs_device_wlun->sdev_gendev) || hba->is_sys_suspended) { enum ufs_pm_op pm_op; @@ -6082,7 +6082,7 @@ static void ufshcd_err_handling_unprepare(struct ufs_hba *hba) static inline bool ufshcd_err_handling_should_stop(struct ufs_hba *hba) { return (!hba->is_powered || hba->shutting_down || - !hba->sdev_ufs_device || + !hba->ufs_device_wlun || hba->ufshcd_state == UFSHCD_STATE_ERROR || (!(hba->saved_err || hba->saved_uic_err || hba->force_reset || ufshcd_is_link_broken(hba)))); @@ -6101,7 +6101,7 @@ static void ufshcd_recover_pm_error(struct ufs_hba *hba) * Set RPM status of wlun device to RPM_ACTIVE, * this also clears its runtime error. */ - ret = pm_runtime_set_active(&hba->sdev_ufs_device->sdev_gendev); + ret = pm_runtime_set_active(&hba->ufs_device_wlun->sdev_gendev); /* hba device might have a runtime error otherwise */ if (ret) @@ -7495,20 +7495,20 @@ static int ufshcd_scsi_add_wlus(struct ufs_hba *hba) int ret = 0; struct scsi_device *sdev_boot, *sdev_rpmb; - hba->sdev_ufs_device = __scsi_add_device(hba->host, 0, 0, + hba->ufs_device_wlun = __scsi_add_device(hba->host, 0, 0, ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_UFS_DEVICE_WLUN), NULL); - if (IS_ERR(hba->sdev_ufs_device)) { - ret = PTR_ERR(hba->sdev_ufs_device); - hba->sdev_ufs_device = NULL; + if (IS_ERR(hba->ufs_device_wlun)) { + ret = PTR_ERR(hba->ufs_device_wlun); + hba->ufs_device_wlun = NULL; goto out; } - scsi_device_put(hba->sdev_ufs_device); + scsi_device_put(hba->ufs_device_wlun); sdev_rpmb = __scsi_add_device(hba->host, 0, 0, ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_RPMB_WLUN), NULL); if (IS_ERR(sdev_rpmb)) { ret = PTR_ERR(sdev_rpmb); - goto remove_sdev_ufs_device; + goto remove_ufs_device_wlun; } ufshcd_blk_pm_runtime_init(sdev_rpmb); scsi_device_put(sdev_rpmb); @@ -7523,8 +7523,8 @@ static int ufshcd_scsi_add_wlus(struct ufs_hba *hba) } goto out; -remove_sdev_ufs_device: - scsi_remove_device(hba->sdev_ufs_device); +remove_ufs_device_wlun: + scsi_remove_device(hba->ufs_device_wlun); out: return ret; } @@ -8660,7 +8660,7 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba, int ret, retries; spin_lock_irqsave(hba->host->host_lock, flags); - sdp = hba->sdev_ufs_device; + sdp = hba->ufs_device_wlun; if (sdp) { ret = scsi_device_get(sdp); if (!ret && !scsi_device_online(sdp)) { @@ -9224,7 +9224,7 @@ static void ufshcd_wl_shutdown(struct device *dev) ufshcd_rpm_get_sync(hba); scsi_device_quiesce(sdev); shost_for_each_device(sdev, hba->host) { - if (sdev == hba->sdev_ufs_device) + if (sdev == hba->ufs_device_wlun) continue; scsi_device_quiesce(sdev); } @@ -9445,7 +9445,7 @@ EXPORT_SYMBOL(ufshcd_shutdown); */ void ufshcd_remove(struct ufs_hba *hba) { - if (hba->sdev_ufs_device) + if (hba->ufs_device_wlun) ufshcd_rpm_get_sync(hba); ufs_hwmon_remove(hba); ufs_bsg_remove(hba); @@ -9773,7 +9773,7 @@ EXPORT_SYMBOL_GPL(ufshcd_resume_complete); static bool ufshcd_rpm_ok_for_spm(struct ufs_hba *hba) { - struct device *dev = &hba->sdev_ufs_device->sdev_gendev; + struct device *dev = &hba->ufs_device_wlun->sdev_gendev; enum ufs_dev_pwr_mode dev_pwr_mode; enum uic_link_state link_state; unsigned long flags; @@ -9802,7 +9802,7 @@ int __ufshcd_suspend_prepare(struct device *dev, bool rpm_ok_for_spm) * if it's runtime suspended. But ufs doesn't follow that. * Refer ufshcd_resume_complete() */ - if (hba->sdev_ufs_device) { + if (hba->ufs_device_wlun) { /* Prevent runtime suspend */ ufshcd_rpm_get_noresume(hba); /* diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index a6c12869b2db..e9cdfbe64c09 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -732,6 +732,7 @@ struct ufs_hba_monitor { * @utmrdl_dma_addr: UTMRDL DMA address * @host: Scsi_Host instance of the driver * @dev: device handle + * @ufs_device_wlun: WLUN that controls the entire UFS device. * @lrb: local reference block * @outstanding_tasks: Bits representing outstanding task requests * @outstanding_lock: Protects @outstanding_reqs. @@ -799,11 +800,7 @@ struct ufs_hba { struct Scsi_Host *host; struct device *dev; - /* - * This field is to keep a reference to "scsi_device" corresponding to - * "UFS device" W-LU. - */ - struct scsi_device *sdev_ufs_device; + struct scsi_device *ufs_device_wlun; #ifdef CONFIG_SCSI_UFS_HWMON struct device *hwmon_device; @@ -1405,27 +1402,27 @@ static inline int ufshcd_update_ee_usr_mask(struct ufs_hba *hba, static inline int ufshcd_rpm_get_sync(struct ufs_hba *hba) { - return pm_runtime_get_sync(&hba->sdev_ufs_device->sdev_gendev); + return pm_runtime_get_sync(&hba->ufs_device_wlun->sdev_gendev); } static inline int ufshcd_rpm_put_sync(struct ufs_hba *hba) { - return pm_runtime_put_sync(&hba->sdev_ufs_device->sdev_gendev); + return pm_runtime_put_sync(&hba->ufs_device_wlun->sdev_gendev); } static inline void ufshcd_rpm_get_noresume(struct ufs_hba *hba) { - pm_runtime_get_noresume(&hba->sdev_ufs_device->sdev_gendev); + pm_runtime_get_noresume(&hba->ufs_device_wlun->sdev_gendev); } static inline int ufshcd_rpm_resume(struct ufs_hba *hba) { - return pm_runtime_resume(&hba->sdev_ufs_device->sdev_gendev); + return pm_runtime_resume(&hba->ufs_device_wlun->sdev_gendev); } static inline int ufshcd_rpm_put(struct ufs_hba *hba) { - return pm_runtime_put(&hba->sdev_ufs_device->sdev_gendev); + return pm_runtime_put(&hba->ufs_device_wlun->sdev_gendev); } #endif /* End of Header */ From 2b10863f71637797121a729a55ba6872b8c85b2b Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Apr 2022 15:58:00 -0700 Subject: [PATCH 060/177] scsi: ufs: Use an SPDX license identifier in the Kconfig file As requested in Documentation/process/license-rules.rst, use an SPDX license identifier. Link: https://lore.kernel.org/r/20220419225811.4127248-18-bvanassche@acm.org Tested-by: Bean Huo Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/Kconfig | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig index 9fe27b01904e..3ebcd5bbc344 100644 --- a/drivers/scsi/ufs/Kconfig +++ b/drivers/scsi/ufs/Kconfig @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0+ # # Kernel configuration file for the UFS Host Controller # @@ -7,30 +8,6 @@ # Authors: # Santosh Yaraganavi # Vinayak Holikatti -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# See the COPYING file in the top-level directory or visit -# -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# This program is provided "AS IS" and "WITH ALL FAULTS" and -# without warranty of any kind. You are solely responsible for -# determining the appropriateness of using and distributing -# the program and assume all risks associated with your exercise -# of rights with respect to the program, including but not limited -# to infringement of third party rights, the risks and costs of -# program errors, damage to or loss of data, programs or equipment, -# and unavailability or interruption of operations. Under no -# circumstances will the contributor of this Program be liable for -# any damages of any kind arising from your use or distribution of -# this program. config SCSI_UFSHCD tristate "Universal Flash Storage Controller Driver Core" From d0c1725b1e64d9fd4e082f4b600d658b8a535cac Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Apr 2022 15:58:01 -0700 Subject: [PATCH 061/177] scsi: ufs: Remove paths from source code comments Since specifying the path in a source file is redundant, remove the paths from source code comments. Link: https://lore.kernel.org/r/20220419225811.4127248-19-bvanassche@acm.org Tested-by: Bean Huo Reviewed-by: Avri Altman Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/Kconfig | 1 - drivers/scsi/ufs/ufshcd-pci.c | 1 - drivers/scsi/ufs/unipro.h | 2 -- 3 files changed, 4 deletions(-) diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig index 3ebcd5bbc344..393b9a01da36 100644 --- a/drivers/scsi/ufs/Kconfig +++ b/drivers/scsi/ufs/Kconfig @@ -2,7 +2,6 @@ # # Kernel configuration file for the UFS Host Controller # -# This code is based on drivers/scsi/ufs/Kconfig # Copyright (C) 2011-2013 Samsung India Software Operations # # Authors: diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs/ufshcd-pci.c index 27029d2523b6..270ec675d15c 100644 --- a/drivers/scsi/ufs/ufshcd-pci.c +++ b/drivers/scsi/ufs/ufshcd-pci.c @@ -2,7 +2,6 @@ /* * Universal Flash Storage Host controller PCI glue driver * - * This code is based on drivers/scsi/ufs/ufshcd-pci.c * Copyright (C) 2011-2013 Samsung India Software Operations * * Authors: diff --git a/drivers/scsi/ufs/unipro.h b/drivers/scsi/ufs/unipro.h index 705a6465ba5c..64647aa5c2e0 100644 --- a/drivers/scsi/ufs/unipro.h +++ b/drivers/scsi/ufs/unipro.h @@ -1,7 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ /* - * drivers/scsi/ufs/unipro.h - * * Copyright (C) 2013 Samsung Electronics Co., Ltd. */ From 21c2e3418d07955c7b87fc3f75688cb1c2b04a32 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Apr 2022 15:58:02 -0700 Subject: [PATCH 062/177] scsi: ufs: Remove the TRUE and FALSE definitions In the Linux kernel coding style document (Documentation/process/coding-style.rst) it is recommended to use the type 'bool' and also the values 'true' and 'false'. Hence this patch that removes the definitions and uses of TRUE and FALSE from the UFS driver. Link: https://lore.kernel.org/r/20220419225811.4127248-20-bvanassche@acm.org Tested-by: Bean Huo Reviewed-by: Avri Altman Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufs-exynos.c | 4 ++-- drivers/scsi/ufs/ufs-exynos.h | 8 ++++---- drivers/scsi/ufs/ufshcd.c | 8 ++++---- drivers/scsi/ufs/unipro.h | 14 -------------- 4 files changed, 10 insertions(+), 24 deletions(-) diff --git a/drivers/scsi/ufs/ufs-exynos.c b/drivers/scsi/ufs/ufs-exynos.c index 474a4a064a68..0b99c74955ef 100644 --- a/drivers/scsi/ufs/ufs-exynos.c +++ b/drivers/scsi/ufs/ufs-exynos.c @@ -704,7 +704,7 @@ static void exynos_ufs_establish_connt(struct exynos_ufs *ufs) /* local unipro attributes */ ufshcd_dme_set(hba, UIC_ARG_MIB(N_DEVICEID), DEV_ID); - ufshcd_dme_set(hba, UIC_ARG_MIB(N_DEVICEID_VALID), TRUE); + ufshcd_dme_set(hba, UIC_ARG_MIB(N_DEVICEID_VALID), true); ufshcd_dme_set(hba, UIC_ARG_MIB(T_PEERDEVICEID), PEER_DEV_ID); ufshcd_dme_set(hba, UIC_ARG_MIB(T_PEERCPORTID), PEER_CPORT_ID); ufshcd_dme_set(hba, UIC_ARG_MIB(T_CPORTFLAGS), CPORT_DEF_FLAGS); @@ -1028,7 +1028,7 @@ static int exynos_ufs_post_link(struct ufs_hba *hba) if (ufs->opts & EXYNOS_UFS_OPT_SKIP_CONNECTION_ESTAB) ufshcd_dme_set(hba, - UIC_ARG_MIB(T_DBG_SKIP_INIT_HIBERN8_EXIT), TRUE); + UIC_ARG_MIB(T_DBG_SKIP_INIT_HIBERN8_EXIT), true); if (attr->pa_granularity) { exynos_ufs_enable_dbg_mode(hba); diff --git a/drivers/scsi/ufs/ufs-exynos.h b/drivers/scsi/ufs/ufs-exynos.h index 1c33e5466082..0b0a3d530ca6 100644 --- a/drivers/scsi/ufs/ufs-exynos.h +++ b/drivers/scsi/ufs/ufs-exynos.h @@ -248,22 +248,22 @@ long exynos_ufs_calc_time_cntr(struct exynos_ufs *, long); static inline void exynos_ufs_enable_ov_tm(struct ufs_hba *hba) { - ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_OV_TM), TRUE); + ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_OV_TM), true); } static inline void exynos_ufs_disable_ov_tm(struct ufs_hba *hba) { - ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_OV_TM), FALSE); + ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_OV_TM), false); } static inline void exynos_ufs_enable_dbg_mode(struct ufs_hba *hba) { - ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_MODE), TRUE); + ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_MODE), true); } static inline void exynos_ufs_disable_dbg_mode(struct ufs_hba *hba) { - ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_MODE), FALSE); + ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_MODE), false); } #endif /* _UFS_EXYNOS_H_ */ diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 11808ce43357..ef39d26afa90 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -4325,18 +4325,18 @@ static int ufshcd_change_power_mode(struct ufs_hba *hba, pwr_mode->lane_rx); if (pwr_mode->pwr_rx == FASTAUTO_MODE || pwr_mode->pwr_rx == FAST_MODE) - ufshcd_dme_set(hba, UIC_ARG_MIB(PA_RXTERMINATION), TRUE); + ufshcd_dme_set(hba, UIC_ARG_MIB(PA_RXTERMINATION), true); else - ufshcd_dme_set(hba, UIC_ARG_MIB(PA_RXTERMINATION), FALSE); + ufshcd_dme_set(hba, UIC_ARG_MIB(PA_RXTERMINATION), false); ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXGEAR), pwr_mode->gear_tx); ufshcd_dme_set(hba, UIC_ARG_MIB(PA_ACTIVETXDATALANES), pwr_mode->lane_tx); if (pwr_mode->pwr_tx == FASTAUTO_MODE || pwr_mode->pwr_tx == FAST_MODE) - ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXTERMINATION), TRUE); + ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXTERMINATION), true); else - ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXTERMINATION), FALSE); + ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXTERMINATION), false); if (pwr_mode->pwr_rx == FASTAUTO_MODE || pwr_mode->pwr_tx == FASTAUTO_MODE || diff --git a/drivers/scsi/ufs/unipro.h b/drivers/scsi/ufs/unipro.h index 64647aa5c2e0..0521f887e3ac 100644 --- a/drivers/scsi/ufs/unipro.h +++ b/drivers/scsi/ufs/unipro.h @@ -298,20 +298,6 @@ enum ufs_unipro_ver { #define T_TC0TXMAXSDUSIZE 0x4060 #define T_TC1TXMAXSDUSIZE 0x4061 -#ifdef FALSE -#undef FALSE -#endif - -#ifdef TRUE -#undef TRUE -#endif - -/* Boolean attribute values */ -enum { - FALSE = 0, - TRUE, -}; - /* CPort setting */ #define E2EFC_ON (1 << 0) #define E2EFC_OFF (0 << 0) From 3fb20fcd93fe5a1580355f1ea73f6daed1712f06 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Apr 2022 15:58:03 -0700 Subject: [PATCH 063/177] scsi: ufs: Remove locking from around single register writes Single register writes are atomic and hence do not need to be surrounded by locking. Additionally, MMIO writes are typically posted asynchronously. Hence, there is no guarantee that these have finished by the time the spin_unlock*() call has finished. See also the nonposted-mmio property of the Open Firmware tree. See also pci_iomap(). Link: https://lore.kernel.org/r/20220419225811.4127248-21-bvanassche@acm.org Tested-by: Bean Huo Reviewed-by: Avri Altman Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufs-mediatek.c | 8 -------- drivers/scsi/ufs/ufshcd.c | 4 ---- 2 files changed, 12 deletions(-) diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c index 9a4474210627..2b26acc74efb 100644 --- a/drivers/scsi/ufs/ufs-mediatek.c +++ b/drivers/scsi/ufs/ufs-mediatek.c @@ -171,7 +171,6 @@ static int ufs_mtk_hce_enable_notify(struct ufs_hba *hba, enum ufs_notify_change_status status) { struct ufs_mtk_host *host = ufshcd_get_variant(hba); - unsigned long flags; if (status == PRE_CHANGE) { if (host->unipro_lpm) { @@ -185,12 +184,8 @@ static int ufs_mtk_hce_enable_notify(struct ufs_hba *hba, ufs_mtk_crypto_enable(hba); if (host->caps & UFS_MTK_CAP_DISABLE_AH8) { - spin_lock_irqsave(hba->host->host_lock, flags); ufshcd_writel(hba, 0, REG_AUTO_HIBERNATE_IDLE_TIMER); - spin_unlock_irqrestore(hba->host->host_lock, - flags); - hba->capabilities &= ~MASK_AUTO_HIBERN8_SUPPORT; hba->ahit = 0; } @@ -994,13 +989,10 @@ static void ufs_mtk_vreg_set_lpm(struct ufs_hba *hba, bool lpm) static void ufs_mtk_auto_hibern8_disable(struct ufs_hba *hba) { - unsigned long flags; int ret; /* disable auto-hibern8 */ - spin_lock_irqsave(hba->host->host_lock, flags); ufshcd_writel(hba, 0, REG_AUTO_HIBERNATE_IDLE_TIMER); - spin_unlock_irqrestore(hba->host->host_lock, flags); /* wait host return to idle state when auto-hibern8 off */ ufs_mtk_wait_idle_state(hba, 5); diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index ef39d26afa90..254dd1e568dd 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -4207,14 +4207,10 @@ EXPORT_SYMBOL_GPL(ufshcd_auto_hibern8_update); void ufshcd_auto_hibern8_enable(struct ufs_hba *hba) { - unsigned long flags; - if (!ufshcd_is_auto_hibern8_supported(hba)) return; - spin_lock_irqsave(hba->host->host_lock, flags); ufshcd_writel(hba, hba->ahit, REG_AUTO_HIBERNATE_IDLE_TIMER); - spin_unlock_irqrestore(hba->host->host_lock, flags); } /** From ad8a647e77294dde3487c86847ca28bd4c8543cd Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Apr 2022 15:58:04 -0700 Subject: [PATCH 064/177] scsi: ufs: Introduce ufshcd_clkgate_delay_set() Since the code to modify delay_ms while holding the host lock occurs twice, introduce a function that performs this action. Link: https://lore.kernel.org/r/20220419225811.4127248-22-bvanassche@acm.org Tested-by: Bean Huo Reviewed-by: Avri Altman Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufs-mediatek.c | 5 +---- drivers/scsi/ufs/ufshcd.c | 20 ++++++++++++++------ drivers/scsi/ufs/ufshcd.h | 2 ++ 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c index 2b26acc74efb..d19b35495302 100644 --- a/drivers/scsi/ufs/ufs-mediatek.c +++ b/drivers/scsi/ufs/ufs-mediatek.c @@ -857,7 +857,6 @@ static int ufs_mtk_pre_link(struct ufs_hba *hba) static void ufs_mtk_setup_clk_gating(struct ufs_hba *hba) { - unsigned long flags; u32 ah_ms; if (ufshcd_is_clkgating_allowed(hba)) { @@ -866,9 +865,7 @@ static void ufs_mtk_setup_clk_gating(struct ufs_hba *hba) hba->ahit); else ah_ms = 10; - spin_lock_irqsave(hba->host->host_lock, flags); - hba->clk_gating.delay_ms = ah_ms + 5; - spin_unlock_irqrestore(hba->host->host_lock, flags); + ufshcd_clkgate_delay_set(hba->dev, ah_ms + 5); } } diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 254dd1e568dd..ba6b35f36bcc 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -1864,18 +1864,26 @@ static ssize_t ufshcd_clkgate_delay_show(struct device *dev, return sysfs_emit(buf, "%lu\n", hba->clk_gating.delay_ms); } -static ssize_t ufshcd_clkgate_delay_store(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) +void ufshcd_clkgate_delay_set(struct device *dev, unsigned long value) { struct ufs_hba *hba = dev_get_drvdata(dev); - unsigned long flags, value; - - if (kstrtoul(buf, 0, &value)) - return -EINVAL; + unsigned long flags; spin_lock_irqsave(hba->host->host_lock, flags); hba->clk_gating.delay_ms = value; spin_unlock_irqrestore(hba->host->host_lock, flags); +} +EXPORT_SYMBOL_GPL(ufshcd_clkgate_delay_set); + +static ssize_t ufshcd_clkgate_delay_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + unsigned long value; + + if (kstrtoul(buf, 0, &value)) + return -EINVAL; + + ufshcd_clkgate_delay_set(dev, value); return count; } diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index e9cdfbe64c09..af896cbde395 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -1184,6 +1184,8 @@ int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index, int ufshcd_hold(struct ufs_hba *hba, bool async); void ufshcd_release(struct ufs_hba *hba); +void ufshcd_clkgate_delay_set(struct device *dev, unsigned long value); + void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id, int *desc_length); From bee40dc167da159ea5b939c074e1da258610a3d6 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Apr 2022 15:58:05 -0700 Subject: [PATCH 065/177] scsi: ufs: qcom: Fix ufs_qcom_resume() Clearing hba->is_sys_suspended if ufs_qcom_resume() succeeds is wrong. That variable must only be cleared if all actions involved in a resume succeed. Hence remove the statement that clears hba->is_sys_suspended from ufs_qcom_resume(). Link: https://lore.kernel.org/r/20220419225811.4127248-23-bvanassche@acm.org Fixes: 81c0fc51b7a7 ("ufs-qcom: add support for Qualcomm Technologies Inc platforms") Tested-by: Bean Huo Reviewed-by: Bjorn Andersson Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufs-qcom.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c index 851caef04a60..150a8313dcdb 100644 --- a/drivers/scsi/ufs/ufs-qcom.c +++ b/drivers/scsi/ufs/ufs-qcom.c @@ -640,12 +640,7 @@ static int ufs_qcom_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op) return err; } - err = ufs_qcom_ice_resume(host); - if (err) - return err; - - hba->is_sys_suspended = false; - return 0; + return ufs_qcom_ice_resume(host); } static void ufs_qcom_dev_ref_clk_ctrl(struct ufs_qcom_host *host, bool enable) From c10d52d73ae0ebc66a837c486b82d1259be01459 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Apr 2022 15:58:06 -0700 Subject: [PATCH 066/177] scsi: ufs: Remove unnecessary ufshcd-crypto.h include directives ufshcd-crypto.h declares functions that must only be called by the UFS core. Hence remove the #include "ufshcd-crypto.h" directive from UFS drivers. Link: https://lore.kernel.org/r/20220419225811.4127248-24-bvanassche@acm.org Tested-by: Bean Huo Reviewed-by: Eric Biggers Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufs-mediatek.c | 1 - drivers/scsi/ufs/ufs-qcom-ice.c | 1 - drivers/scsi/ufs/ufs-qcom.h | 1 + 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c index d19b35495302..84ccb5258736 100644 --- a/drivers/scsi/ufs/ufs-mediatek.c +++ b/drivers/scsi/ufs/ufs-mediatek.c @@ -19,7 +19,6 @@ #include #include "ufshcd.h" -#include "ufshcd-crypto.h" #include "ufshcd-pltfrm.h" #include "ufs_quirks.h" #include "unipro.h" diff --git a/drivers/scsi/ufs/ufs-qcom-ice.c b/drivers/scsi/ufs/ufs-qcom-ice.c index bbb0ad7590ec..921d6a93b653 100644 --- a/drivers/scsi/ufs/ufs-qcom-ice.c +++ b/drivers/scsi/ufs/ufs-qcom-ice.c @@ -9,7 +9,6 @@ #include #include -#include "ufshcd-crypto.h" #include "ufs-qcom.h" #define AES_256_XTS_KEY_SIZE 64 diff --git a/drivers/scsi/ufs/ufs-qcom.h b/drivers/scsi/ufs/ufs-qcom.h index 51570224a6e2..771bc95d02c7 100644 --- a/drivers/scsi/ufs/ufs-qcom.h +++ b/drivers/scsi/ufs/ufs-qcom.h @@ -7,6 +7,7 @@ #include #include +#include "ufshcd.h" #define MAX_UFS_QCOM_HOSTS 1 #define MAX_U32 (~(u32)0) From cff91daf52d364d0d84fa47b489abcfd4eb19bb9 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Apr 2022 15:58:07 -0700 Subject: [PATCH 067/177] scsi: ufs: Fix kernel-doc syntax in ufshcd.h This patch fixes all the warnings and errors reported by the following command: scripts/kernel-doc -none drivers/scsi/ufs/ufshcd.h Link: https://lore.kernel.org/r/20220419225811.4127248-25-bvanassche@acm.org Tested-by: Bean Huo Reviewed-by: Avri Altman Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufshcd.h | 89 ++++++++++++++++++++++++++++++--------- 1 file changed, 68 insertions(+), 21 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index af896cbde395..b42ed2fcc459 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -236,6 +236,7 @@ struct ufs_query { * @type: device management command type - Query, NOP OUT * @lock: lock to allow one command at a time * @complete: internal commands completion + * @query: Device management query information */ struct ufs_dev_cmd { enum dev_cmd_type type; @@ -253,7 +254,7 @@ struct ufs_dev_cmd { * @min_freq: min frequency that can be used for clock scaling * @curr_freq: indicates the current frequency that it is set to * @keep_link_active: indicates that the clk should not be disabled if - link is active + * link is active * @enabled: variable to check against multiple enable/disable */ struct ufs_clk_info { @@ -308,11 +309,13 @@ struct ufs_pwr_mode_info { * to set some things * @hibern8_notify: called around hibern8 enter/exit * @apply_dev_quirks: called to apply device specific quirks + * @fixup_dev_quirks: called to modify device specific quirks * @suspend: called during host controller PM callback * @resume: called during host controller PM callback * @dbg_register_dump: used to dump controller debug information * @phy_initialization: used to initialize phys * @device_reset: called to issue a reset pulse on the UFS device + * @config_scaling_param: called to configure clock scaling parameters * @program_key: program or evict an inline encryption key * @event_notify: called to notify important events */ @@ -379,6 +382,7 @@ enum clk_gating_state { * @is_initialized: Indicates whether clock gating is initialized or not * @active_reqs: number of requests that are pending and should be waited for * completion before gating clocks. + * @clk_gating_workq: workqueue for clock gating work. */ struct ufs_clk_gating { struct delayed_work gate_work; @@ -415,9 +419,9 @@ struct ufs_saved_pwr_info { * @resume_work: worker to resume devfreq * @min_gear: lowest HS gear to scale down to * @is_enabled: tracks if scaling is currently enabled or not, controlled by - clkscale_enable sysfs node + * clkscale_enable sysfs node * @is_allowed: tracks if scaling is currently allowed or not, used to block - clock scaling which is not invoked from devfreq governor + * clock scaling which is not invoked from devfreq governor * @is_initialized: Indicates whether clock scaling is initialized or not * @is_busy_started: tracks if busy period has started or not * @is_suspended: tracks if devfreq is suspended or not @@ -444,7 +448,7 @@ struct ufs_clk_scaling { /** * struct ufs_event_hist - keeps history of errors * @pos: index to indicate cyclic buffer position - * @reg: cyclic buffer for registers value + * @val: cyclic buffer for registers value * @tstamp: cyclic buffer for time stamp * @cnt: error counter */ @@ -463,6 +467,7 @@ struct ufs_event_hist { * reset this after link-startup. * @last_hibern8_exit_tstamp: Set time after the hibern8 exit. * Clear after the first successful command completion. + * @event: array with event history. */ struct ufs_stats { u32 last_intr_status; @@ -733,6 +738,13 @@ struct ufs_hba_monitor { * @host: Scsi_Host instance of the driver * @dev: device handle * @ufs_device_wlun: WLUN that controls the entire UFS device. + * @hwmon_device: device instance registered with the hwmon core. + * @curr_dev_pwr_mode: active UFS device power mode. + * @uic_link_state: active state of the link to the UFS device. + * @rpm_lvl: desired UFS power management level during runtime PM. + * @spm_lvl: desired UFS power management level during system PM. + * @pm_op_in_progress: whether or not a PM operation is in progress. + * @ahit: value of Auto-Hibernate Idle Timer register. * @lrb: local reference block * @outstanding_tasks: Bits representing outstanding task requests * @outstanding_lock: Protects @outstanding_reqs. @@ -743,17 +755,26 @@ struct ufs_hba_monitor { * @reserved_slot: Used to submit device commands. Protected by @dev_cmd.lock. * @ufs_version: UFS Version to which controller complies * @vops: pointer to variant specific operations + * @vps: pointer to variant specific parameters * @priv: pointer to variant specific private data * @irq: Irq number of the controller - * @active_uic_cmd: handle of active UIC command - * @uic_cmd_mutex: mutex for UIC command + * @is_irq_enabled: whether or not the UFS controller interrupt is enabled. + * @dev_ref_clk_freq: reference clock frequency + * @quirks: bitmask with information about deviations from the UFSHCI standard. + * @dev_quirks: bitmask with information about deviations from the UFS standard. * @tmf_tag_set: TMF tag set. * @tmf_queue: Used to allocate TMF tags. - * @pwr_done: completion for power mode change + * @tmf_rqs: array with pointers to TMF requests while these are in progress. + * @active_uic_cmd: handle of active UIC command + * @uic_cmd_mutex: mutex for UIC command + * @uic_async_done: completion used during UIC processing * @ufshcd_state: UFSHCD state * @eh_flags: Error handling flags * @intr_mask: Interrupt Mask Bits * @ee_ctrl_mask: Exception event control mask + * @ee_drv_mask: Exception event mask for driver + * @ee_usr_mask: Exception event mask for user (set via debugfs) + * @ee_ctrl_mutex: Used to serialize exception event information. * @is_powered: flag to check if HBA is powered * @shutting_down: flag to check if shutdown has been invoked * @host_sem: semaphore used to serialize concurrent contexts @@ -764,26 +785,52 @@ struct ufs_hba_monitor { * @uic_error: UFS interconnect layer error status * @saved_err: sticky error mask * @saved_uic_err: sticky UIC error mask + * @ufs_stats: various error counters * @force_reset: flag to force eh_work perform a full reset * @force_pmc: flag to force a power mode change * @silence_err_logs: flag to silence error logs * @dev_cmd: ufs device management command information * @last_dme_cmd_tstamp: time stamp of the last completed DME command + * @nop_out_timeout: NOP OUT timeout value + * @dev_info: information about the UFS device * @auto_bkops_enabled: to track whether bkops is enabled in device * @vreg_info: UFS device voltage regulator information * @clk_list_head: UFS host controller clocks list node head + * @req_abort_count: number of times ufshcd_abort() has been called + * @lanes_per_direction: number of lanes per data direction between the UFS + * controller and the UFS device. * @pwr_info: holds current power mode * @max_pwr_info: keeps the device max valid pwm - * @clk_scaling_lock: used to serialize device commands and clock scaling - * @desc_size: descriptor sizes reported by device + * @clk_gating: information related to clock gating + * @caps: bitmask with information about UFS controller capabilities + * @devfreq: frequency scaling information owned by the devfreq core + * @clk_scaling: frequency scaling information owned by the UFS driver + * @is_sys_suspended: whether or not the entire system has been suspended * @urgent_bkops_lvl: keeps track of urgent bkops level for device * @is_urgent_bkops_lvl_checked: keeps track if the urgent bkops level for * device is known or not. + * @clk_scaling_lock: used to serialize device commands and clock scaling + * @desc_size: descriptor sizes reported by device * @scsi_block_reqs_cnt: reference counting for scsi block requests + * @bsg_dev: struct device associated with the BSG queue + * @bsg_queue: BSG queue associated with the UFS controller + * @rpm_dev_flush_recheck_work: used to suspend from RPM (runtime power + * management) after the UFS device has finished a WriteBooster buffer + * flush or auto BKOP. + * @ufshpb_dev: information related to HPB (Host Performance Booster). + * @monitor: statistics about UFS commands * @crypto_capabilities: Content of crypto capabilities register (0x100) * @crypto_cap_array: Array of crypto capabilities * @crypto_cfg_register: Start of the crypto cfg array * @crypto_profile: the crypto profile of this hba (if applicable) + * @debugfs_root: UFS controller debugfs root directory + * @debugfs_ee_work: used to restore ee_ctrl_mask after a delay + * @debugfs_ee_rate_limit_ms: user configurable delay after which to restore + * ee_ctrl_mask + * @luns_avail: number of regular and well known LUNs supported by the UFS + * device + * @complete_put: whether or not to call ufshcd_rpm_put() from inside + * ufshcd_resume_complete() */ struct ufs_hba { void __iomem *mmio_base; @@ -851,9 +898,9 @@ struct ufs_hba { enum ufshcd_state ufshcd_state; u32 eh_flags; u32 intr_mask; - u16 ee_ctrl_mask; /* Exception event mask */ - u16 ee_drv_mask; /* Exception event mask for driver */ - u16 ee_usr_mask; /* Exception event mask for user (via debugfs) */ + u16 ee_ctrl_mask; + u16 ee_drv_mask; + u16 ee_usr_mask; struct mutex ee_ctrl_mutex; bool is_powered; bool shutting_down; @@ -994,11 +1041,11 @@ static inline bool ufshcd_is_user_access_allowed(struct ufs_hba *hba) readl((hba)->mmio_base + (reg)) /** - * ufshcd_rmwl - read modify write into a register - * @hba - per adapter instance - * @mask - mask to apply on read value - * @val - actual value to write - * @reg - register address + * ufshcd_rmwl - perform read/modify/write for a controller register + * @hba: per adapter instance + * @mask: mask to apply on read value + * @val: actual value to write + * @reg: register address */ static inline void ufshcd_rmwl(struct ufs_hba *hba, u32 mask, u32 val, u32 reg) { @@ -1033,8 +1080,8 @@ static inline void check_upiu_size(void) /** * ufshcd_set_variant - set variant specific data to the hba - * @hba - per adapter instance - * @variant - pointer to variant specific data + * @hba: per adapter instance + * @variant: pointer to variant specific data */ static inline void ufshcd_set_variant(struct ufs_hba *hba, void *variant) { @@ -1044,7 +1091,7 @@ static inline void ufshcd_set_variant(struct ufs_hba *hba, void *variant) /** * ufshcd_get_variant - get variant specific data from the hba - * @hba - per adapter instance + * @hba: per adapter instance */ static inline void *ufshcd_get_variant(struct ufs_hba *hba) { @@ -1365,7 +1412,7 @@ static inline void ufshcd_vops_config_scaling_param(struct ufs_hba *hba, extern struct ufs_pm_lvl_states ufs_pm_lvl_states[]; -/* +/** * ufshcd_scsi_to_upiu_lun - maps scsi LUN to UPIU LUN * @scsi_lun: scsi LUN id * From 3f06f7800b80462e8f6aadade6bb823496204e06 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Apr 2022 15:58:08 -0700 Subject: [PATCH 068/177] scsi: ufs: Minimize #include directives Follow the convention that is used elsewhere in the Linux kernel source code and only include those headers of which the declarations are used directly. Link: https://lore.kernel.org/r/20220419225811.4127248-26-bvanassche@acm.org Tested-by: Bean Huo Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/cdns-pltfrm.c | 1 + drivers/scsi/ufs/tc-dwc-g210-pci.c | 1 + drivers/scsi/ufs/tc-dwc-g210-pltfrm.c | 1 + drivers/scsi/ufs/tc-dwc-g210.c | 2 ++ drivers/scsi/ufs/tc-dwc-g210.h | 2 ++ drivers/scsi/ufs/ufs-exynos.c | 1 + drivers/scsi/ufs/ufs-hisi.c | 2 ++ drivers/scsi/ufs/ufs-mediatek.c | 3 +++ drivers/scsi/ufs/ufs-qcom-ice.c | 1 + drivers/scsi/ufs/ufs-qcom.c | 4 ++++ drivers/scsi/ufs/ufs-sysfs.c | 1 + drivers/scsi/ufs/ufs-sysfs.h | 3 ++- drivers/scsi/ufs/ufs_bsg.c | 5 ++++ drivers/scsi/ufs/ufs_bsg.h | 7 +----- drivers/scsi/ufs/ufshcd-crypto.h | 5 ++-- drivers/scsi/ufs/ufshcd-dwc.c | 2 ++ drivers/scsi/ufs/ufshcd-dwc.h | 2 ++ drivers/scsi/ufs/ufshcd-pci.c | 2 ++ drivers/scsi/ufs/ufshcd-pltfrm.c | 1 + drivers/scsi/ufs/ufshcd.c | 9 ++++++++ drivers/scsi/ufs/ufshcd.h | 33 ++++----------------------- drivers/scsi/ufs/ufshci.h | 2 ++ drivers/scsi/ufs/ufshpb.c | 4 ++++ 23 files changed, 56 insertions(+), 38 deletions(-) diff --git a/drivers/scsi/ufs/cdns-pltfrm.c b/drivers/scsi/ufs/cdns-pltfrm.c index e91cf9fd5a95..e05c0ae64eea 100644 --- a/drivers/scsi/ufs/cdns-pltfrm.c +++ b/drivers/scsi/ufs/cdns-pltfrm.c @@ -9,6 +9,7 @@ * */ +#include #include #include #include diff --git a/drivers/scsi/ufs/tc-dwc-g210-pci.c b/drivers/scsi/ufs/tc-dwc-g210-pci.c index 7b08e2e07cc5..e635c211c783 100644 --- a/drivers/scsi/ufs/tc-dwc-g210-pci.c +++ b/drivers/scsi/ufs/tc-dwc-g210-pci.c @@ -11,6 +11,7 @@ #include "ufshcd-dwc.h" #include "tc-dwc-g210.h" +#include #include #include diff --git a/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c b/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c index 783ec43efa78..f15a84d0c176 100644 --- a/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c +++ b/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "ufshcd-pltfrm.h" #include "ufshcd-dwc.h" diff --git a/drivers/scsi/ufs/tc-dwc-g210.c b/drivers/scsi/ufs/tc-dwc-g210.c index f954a68f6b4c..7ef67c9fc5b8 100644 --- a/drivers/scsi/ufs/tc-dwc-g210.c +++ b/drivers/scsi/ufs/tc-dwc-g210.c @@ -7,6 +7,8 @@ * Authors: Joao Pinto */ +#include + #include "ufshcd.h" #include "unipro.h" diff --git a/drivers/scsi/ufs/tc-dwc-g210.h b/drivers/scsi/ufs/tc-dwc-g210.h index 5a506da03f4a..f7154012f5c7 100644 --- a/drivers/scsi/ufs/tc-dwc-g210.h +++ b/drivers/scsi/ufs/tc-dwc-g210.h @@ -10,6 +10,8 @@ #ifndef _TC_DWC_G210_H #define _TC_DWC_G210_H +struct ufs_hba; + int tc_dwc_g210_config_40_bit(struct ufs_hba *hba); int tc_dwc_g210_config_20_bit(struct ufs_hba *hba); diff --git a/drivers/scsi/ufs/ufs-exynos.c b/drivers/scsi/ufs/ufs-exynos.c index 0b99c74955ef..ddb2d42605c5 100644 --- a/drivers/scsi/ufs/ufs-exynos.c +++ b/drivers/scsi/ufs/ufs-exynos.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include diff --git a/drivers/scsi/ufs/ufs-hisi.c b/drivers/scsi/ufs/ufs-hisi.c index ab1a7ebd89b1..7046143063ee 100644 --- a/drivers/scsi/ufs/ufs-hisi.c +++ b/drivers/scsi/ufs/ufs-hisi.c @@ -7,6 +7,8 @@ */ #include +#include +#include #include #include #include diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c index 84ccb5258736..083d6bd4d561 100644 --- a/drivers/scsi/ufs/ufs-mediatek.c +++ b/drivers/scsi/ufs/ufs-mediatek.c @@ -8,6 +8,9 @@ #include #include +#include +#include +#include #include #include #include diff --git a/drivers/scsi/ufs/ufs-qcom-ice.c b/drivers/scsi/ufs/ufs-qcom-ice.c index 921d6a93b653..745e48ec598f 100644 --- a/drivers/scsi/ufs/ufs-qcom-ice.c +++ b/drivers/scsi/ufs/ufs-qcom-ice.c @@ -6,6 +6,7 @@ * Copyright 2019 Google LLC */ +#include #include #include diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c index 150a8313dcdb..d18bc534c62d 100644 --- a/drivers/scsi/ufs/ufs-qcom.c +++ b/drivers/scsi/ufs/ufs-qcom.c @@ -5,6 +5,9 @@ #include #include +#include +#include +#include #include #include #include @@ -18,6 +21,7 @@ #include "ufs-qcom.h" #include "ufshci.h" #include "ufs_quirks.h" + #define UFS_QCOM_DEFAULT_DBG_PRINT_EN \ (UFS_QCOM_DBG_PRINT_REGS_EN | UFS_QCOM_DBG_PRINT_TEST_BUS_EN) diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c index 5c405ff7b6ea..95a4e64ce401 100644 --- a/drivers/scsi/ufs/ufs-sysfs.c +++ b/drivers/scsi/ufs/ufs-sysfs.c @@ -8,6 +8,7 @@ #include "ufs.h" #include "ufs-sysfs.h" +#include "ufshcd.h" static const char *ufshcd_uic_link_state_to_string( enum uic_link_state state) diff --git a/drivers/scsi/ufs/ufs-sysfs.h b/drivers/scsi/ufs/ufs-sysfs.h index 0f4e750a6748..8d94af3b8077 100644 --- a/drivers/scsi/ufs/ufs-sysfs.h +++ b/drivers/scsi/ufs/ufs-sysfs.h @@ -7,11 +7,12 @@ #include -#include "ufshcd.h" +struct device; void ufs_sysfs_add_nodes(struct device *dev); void ufs_sysfs_remove_nodes(struct device *dev); extern const struct attribute_group ufs_sysfs_unit_descriptor_group; extern const struct attribute_group ufs_sysfs_lun_attributes_group; + #endif diff --git a/drivers/scsi/ufs/ufs_bsg.c b/drivers/scsi/ufs/ufs_bsg.c index 39bf204c6ec3..fbcdfb713542 100644 --- a/drivers/scsi/ufs/ufs_bsg.c +++ b/drivers/scsi/ufs/ufs_bsg.c @@ -4,7 +4,12 @@ * * Copyright (C) 2018 Western Digital Corporation */ + +#include +#include +#include #include "ufs_bsg.h" +#include "ufshcd.h" static int ufs_bsg_get_query_desc_size(struct ufs_hba *hba, int *desc_len, struct utp_upiu_query *qr) diff --git a/drivers/scsi/ufs/ufs_bsg.h b/drivers/scsi/ufs/ufs_bsg.h index d09918758631..57712d2656d2 100644 --- a/drivers/scsi/ufs/ufs_bsg.h +++ b/drivers/scsi/ufs/ufs_bsg.h @@ -5,12 +5,7 @@ #ifndef UFS_BSG_H #define UFS_BSG_H -#include -#include -#include - -#include "ufshcd.h" -#include "ufs.h" +struct ufs_hba; #ifdef CONFIG_SCSI_UFS_BSG void ufs_bsg_remove(struct ufs_hba *hba); diff --git a/drivers/scsi/ufs/ufshcd-crypto.h b/drivers/scsi/ufs/ufshcd-crypto.h index e18c01276873..57dd51256b57 100644 --- a/drivers/scsi/ufs/ufshcd-crypto.h +++ b/drivers/scsi/ufs/ufshcd-crypto.h @@ -6,9 +6,10 @@ #ifndef _UFSHCD_CRYPTO_H #define _UFSHCD_CRYPTO_H -#ifdef CONFIG_SCSI_UFS_CRYPTO +#include #include "ufshcd.h" -#include "ufshci.h" + +#ifdef CONFIG_SCSI_UFS_CRYPTO static inline void ufshcd_prepare_lrbp_crypto(struct request *rq, struct ufshcd_lrb *lrbp) diff --git a/drivers/scsi/ufs/ufshcd-dwc.c b/drivers/scsi/ufs/ufshcd-dwc.c index 5bb9d3a88795..a57973c8d2a1 100644 --- a/drivers/scsi/ufs/ufshcd-dwc.c +++ b/drivers/scsi/ufs/ufshcd-dwc.c @@ -7,6 +7,8 @@ * Authors: Joao Pinto */ +#include + #include "ufshcd.h" #include "unipro.h" diff --git a/drivers/scsi/ufs/ufshcd-dwc.h b/drivers/scsi/ufs/ufshcd-dwc.h index 4268ca2eb64c..43b70794e24f 100644 --- a/drivers/scsi/ufs/ufshcd-dwc.h +++ b/drivers/scsi/ufs/ufshcd-dwc.h @@ -10,6 +10,8 @@ #ifndef _UFSHCD_DWC_H #define _UFSHCD_DWC_H +#include "ufshcd.h" + struct ufshcd_dme_attr_val { u32 attr_sel; u32 mib_val; diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs/ufshcd-pci.c index 270ec675d15c..20af2fbc3af1 100644 --- a/drivers/scsi/ufs/ufshcd-pci.c +++ b/drivers/scsi/ufs/ufshcd-pci.c @@ -10,6 +10,8 @@ */ #include "ufshcd.h" +#include +#include #include #include #include diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c index fc5191101192..f5313f407617 100644 --- a/drivers/scsi/ufs/ufshcd-pltfrm.c +++ b/drivers/scsi/ufs/ufshcd-pltfrm.c @@ -8,6 +8,7 @@ * Vinayak Holikatti */ +#include #include #include #include diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index ba6b35f36bcc..bac4ae63eb20 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -16,7 +16,16 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include #include "ufshcd.h" #include "ufs_quirks.h" #include "unipro.h" diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index b42ed2fcc459..ca36d8354f11 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -12,38 +12,13 @@ #ifndef _UFSHCD_H #define _UFSHCD_H -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include #include +#include +#include +#include +#include #include "unipro.h" - -#include -#include -#include -#include -#include -#include -#include -#include - #include "ufs.h" #include "ufs_quirks.h" #include "ufshci.h" diff --git a/drivers/scsi/ufs/ufshci.h b/drivers/scsi/ufs/ufshci.h index a7ff0e5b5494..f81aa95ffbc4 100644 --- a/drivers/scsi/ufs/ufshci.h +++ b/drivers/scsi/ufs/ufshci.h @@ -11,6 +11,8 @@ #ifndef _UFSHCI_H #define _UFSHCI_H +#include + enum { TASK_REQ_UPIU_SIZE_DWORDS = 8, TASK_RSP_UPIU_SIZE_DWORDS = 8, diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c index 40f365c537f5..68c97a2e825c 100644 --- a/drivers/scsi/ufs/ufshpb.c +++ b/drivers/scsi/ufs/ufshpb.c @@ -10,6 +10,10 @@ */ #include +#include +#include +#include +#include #include "ufshcd.h" #include "ufshpb.h" From 4bc26113c603073363ac96f6f1c7d6389bc0b243 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Apr 2022 15:58:09 -0700 Subject: [PATCH 069/177] scsi: ufs: Split the ufshcd.h header file Split the ufshcd.h header file into a header file that defines the interface used by UFS drivers and another header file with declarations and data structures only used by the UFS core. Link: https://lore.kernel.org/r/20220419225811.4127248-27-bvanassche@acm.org Tested-by: Bean Huo Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufs-debugfs.c | 1 + drivers/scsi/ufs/ufs-hwmon.c | 1 + drivers/scsi/ufs/ufs-sysfs.c | 2 +- drivers/scsi/ufs/ufs_bsg.c | 1 + drivers/scsi/ufs/ufshcd-crypto.h | 2 + drivers/scsi/ufs/ufshcd-priv.h | 279 +++++++++++++++++++++++++++++++ drivers/scsi/ufs/ufshcd.c | 2 +- drivers/scsi/ufs/ufshcd.h | 222 ------------------------ drivers/scsi/ufs/ufshpb.c | 2 +- 9 files changed, 287 insertions(+), 225 deletions(-) create mode 100644 drivers/scsi/ufs/ufshcd-priv.h diff --git a/drivers/scsi/ufs/ufs-debugfs.c b/drivers/scsi/ufs/ufs-debugfs.c index 4a0bbcf1757a..c10a8f09682b 100644 --- a/drivers/scsi/ufs/ufs-debugfs.c +++ b/drivers/scsi/ufs/ufs-debugfs.c @@ -5,6 +5,7 @@ #include "ufs-debugfs.h" #include "ufshcd.h" +#include "ufshcd-priv.h" static struct dentry *ufs_debugfs_root; diff --git a/drivers/scsi/ufs/ufs-hwmon.c b/drivers/scsi/ufs/ufs-hwmon.c index 74855491dc8f..c38d9d98a86d 100644 --- a/drivers/scsi/ufs/ufs-hwmon.c +++ b/drivers/scsi/ufs/ufs-hwmon.c @@ -8,6 +8,7 @@ #include #include "ufshcd.h" +#include "ufshcd-priv.h" struct ufs_hwmon_data { struct ufs_hba *hba; diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c index 95a4e64ce401..8a3c6442f291 100644 --- a/drivers/scsi/ufs/ufs-sysfs.c +++ b/drivers/scsi/ufs/ufs-sysfs.c @@ -8,7 +8,7 @@ #include "ufs.h" #include "ufs-sysfs.h" -#include "ufshcd.h" +#include "ufshcd-priv.h" static const char *ufshcd_uic_link_state_to_string( enum uic_link_state state) diff --git a/drivers/scsi/ufs/ufs_bsg.c b/drivers/scsi/ufs/ufs_bsg.c index fbcdfb713542..9e9b93867cab 100644 --- a/drivers/scsi/ufs/ufs_bsg.c +++ b/drivers/scsi/ufs/ufs_bsg.c @@ -10,6 +10,7 @@ #include #include "ufs_bsg.h" #include "ufshcd.h" +#include "ufshcd-priv.h" static int ufs_bsg_get_query_desc_size(struct ufs_hba *hba, int *desc_len, struct utp_upiu_query *qr) diff --git a/drivers/scsi/ufs/ufshcd-crypto.h b/drivers/scsi/ufs/ufshcd-crypto.h index 57dd51256b57..9f98f18f9646 100644 --- a/drivers/scsi/ufs/ufshcd-crypto.h +++ b/drivers/scsi/ufs/ufshcd-crypto.h @@ -8,6 +8,8 @@ #include #include "ufshcd.h" +#include "ufshcd-priv.h" +#include "ufshci.h" #ifdef CONFIG_SCSI_UFS_CRYPTO diff --git a/drivers/scsi/ufs/ufshcd-priv.h b/drivers/scsi/ufs/ufshcd-priv.h new file mode 100644 index 000000000000..3fa8ab94e4e1 --- /dev/null +++ b/drivers/scsi/ufs/ufshcd-priv.h @@ -0,0 +1,279 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef _UFSHCD_PRIV_H_ +#define _UFSHCD_PRIV_H_ + +#include +#include "ufshcd.h" + +static inline bool ufshcd_is_user_access_allowed(struct ufs_hba *hba) +{ + return !hba->shutting_down; +} + +void ufshcd_schedule_eh_work(struct ufs_hba *hba); + +static inline bool ufshcd_keep_autobkops_enabled_except_suspend( + struct ufs_hba *hba) +{ + return hba->caps & UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND; +} + +static inline u8 ufshcd_wb_get_query_index(struct ufs_hba *hba) +{ + if (hba->dev_info.wb_buffer_type == WB_BUF_MODE_LU_DEDICATED) + return hba->dev_info.wb_dedicated_lu; + return 0; +} + +#ifdef CONFIG_SCSI_UFS_HWMON +void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask); +void ufs_hwmon_remove(struct ufs_hba *hba); +void ufs_hwmon_notify_event(struct ufs_hba *hba, u8 ee_mask); +#else +static inline void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask) {} +static inline void ufs_hwmon_remove(struct ufs_hba *hba) {} +static inline void ufs_hwmon_notify_event(struct ufs_hba *hba, u8 ee_mask) {} +#endif + +int ufshcd_read_desc_param(struct ufs_hba *hba, + enum desc_idn desc_id, + int desc_index, + u8 param_offset, + u8 *param_read_buf, + u8 param_size); +int ufshcd_query_attr_retry(struct ufs_hba *hba, enum query_opcode opcode, + enum attr_idn idn, u8 index, u8 selector, + u32 *attr_val); +int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode, + enum attr_idn idn, u8 index, u8 selector, u32 *attr_val); +int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode, + enum flag_idn idn, u8 index, bool *flag_res); +void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit); + +#define SD_ASCII_STD true +#define SD_RAW false +int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index, + u8 **buf, bool ascii); + +int ufshcd_hold(struct ufs_hba *hba, bool async); +void ufshcd_release(struct ufs_hba *hba); + +void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id, + int *desc_length); + +int ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd); + +int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba, + struct utp_upiu_req *req_upiu, + struct utp_upiu_req *rsp_upiu, + int msgcode, + u8 *desc_buff, int *buff_len, + enum query_opcode desc_op); + +int ufshcd_wb_toggle(struct ufs_hba *hba, bool enable); + +/* Wrapper functions for safely calling variant operations */ +static inline const char *ufshcd_get_var_name(struct ufs_hba *hba) +{ + if (hba->vops) + return hba->vops->name; + return ""; +} + +static inline void ufshcd_vops_exit(struct ufs_hba *hba) +{ + if (hba->vops && hba->vops->exit) + return hba->vops->exit(hba); +} + +static inline u32 ufshcd_vops_get_ufs_hci_version(struct ufs_hba *hba) +{ + if (hba->vops && hba->vops->get_ufs_hci_version) + return hba->vops->get_ufs_hci_version(hba); + + return ufshcd_readl(hba, REG_UFS_VERSION); +} + +static inline int ufshcd_vops_clk_scale_notify(struct ufs_hba *hba, + bool up, enum ufs_notify_change_status status) +{ + if (hba->vops && hba->vops->clk_scale_notify) + return hba->vops->clk_scale_notify(hba, up, status); + return 0; +} + +static inline void ufshcd_vops_event_notify(struct ufs_hba *hba, + enum ufs_event_type evt, + void *data) +{ + if (hba->vops && hba->vops->event_notify) + hba->vops->event_notify(hba, evt, data); +} + +static inline int ufshcd_vops_setup_clocks(struct ufs_hba *hba, bool on, + enum ufs_notify_change_status status) +{ + if (hba->vops && hba->vops->setup_clocks) + return hba->vops->setup_clocks(hba, on, status); + return 0; +} + +static inline int ufshcd_vops_hce_enable_notify(struct ufs_hba *hba, + bool status) +{ + if (hba->vops && hba->vops->hce_enable_notify) + return hba->vops->hce_enable_notify(hba, status); + + return 0; +} +static inline int ufshcd_vops_link_startup_notify(struct ufs_hba *hba, + bool status) +{ + if (hba->vops && hba->vops->link_startup_notify) + return hba->vops->link_startup_notify(hba, status); + + return 0; +} + +static inline int ufshcd_vops_pwr_change_notify(struct ufs_hba *hba, + enum ufs_notify_change_status status, + struct ufs_pa_layer_attr *dev_max_params, + struct ufs_pa_layer_attr *dev_req_params) +{ + if (hba->vops && hba->vops->pwr_change_notify) + return hba->vops->pwr_change_notify(hba, status, + dev_max_params, dev_req_params); + + return -ENOTSUPP; +} + +static inline void ufshcd_vops_setup_task_mgmt(struct ufs_hba *hba, + int tag, u8 tm_function) +{ + if (hba->vops && hba->vops->setup_task_mgmt) + return hba->vops->setup_task_mgmt(hba, tag, tm_function); +} + +static inline void ufshcd_vops_hibern8_notify(struct ufs_hba *hba, + enum uic_cmd_dme cmd, + enum ufs_notify_change_status status) +{ + if (hba->vops && hba->vops->hibern8_notify) + return hba->vops->hibern8_notify(hba, cmd, status); +} + +static inline int ufshcd_vops_apply_dev_quirks(struct ufs_hba *hba) +{ + if (hba->vops && hba->vops->apply_dev_quirks) + return hba->vops->apply_dev_quirks(hba); + return 0; +} + +static inline void ufshcd_vops_fixup_dev_quirks(struct ufs_hba *hba) +{ + if (hba->vops && hba->vops->fixup_dev_quirks) + hba->vops->fixup_dev_quirks(hba); +} + +static inline int ufshcd_vops_suspend(struct ufs_hba *hba, enum ufs_pm_op op, + enum ufs_notify_change_status status) +{ + if (hba->vops && hba->vops->suspend) + return hba->vops->suspend(hba, op, status); + + return 0; +} + +static inline int ufshcd_vops_resume(struct ufs_hba *hba, enum ufs_pm_op op) +{ + if (hba->vops && hba->vops->resume) + return hba->vops->resume(hba, op); + + return 0; +} + +static inline void ufshcd_vops_dbg_register_dump(struct ufs_hba *hba) +{ + if (hba->vops && hba->vops->dbg_register_dump) + hba->vops->dbg_register_dump(hba); +} + +static inline int ufshcd_vops_device_reset(struct ufs_hba *hba) +{ + if (hba->vops && hba->vops->device_reset) + return hba->vops->device_reset(hba); + + return -EOPNOTSUPP; +} + +static inline void ufshcd_vops_config_scaling_param(struct ufs_hba *hba, + struct devfreq_dev_profile *p, + struct devfreq_simple_ondemand_data *data) +{ + if (hba->vops && hba->vops->config_scaling_param) + hba->vops->config_scaling_param(hba, p, data); +} + +extern struct ufs_pm_lvl_states ufs_pm_lvl_states[]; + +/** + * ufshcd_scsi_to_upiu_lun - maps scsi LUN to UPIU LUN + * @scsi_lun: scsi LUN id + * + * Returns UPIU LUN id + */ +static inline u8 ufshcd_scsi_to_upiu_lun(unsigned int scsi_lun) +{ + if (scsi_is_wlun(scsi_lun)) + return (scsi_lun & UFS_UPIU_MAX_UNIT_NUM_ID) + | UFS_UPIU_WLUN_ID; + else + return scsi_lun & UFS_UPIU_MAX_UNIT_NUM_ID; +} + +int __ufshcd_write_ee_control(struct ufs_hba *hba, u32 ee_ctrl_mask); +int ufshcd_write_ee_control(struct ufs_hba *hba); +int ufshcd_update_ee_control(struct ufs_hba *hba, u16 *mask, u16 *other_mask, + u16 set, u16 clr); + +static inline int ufshcd_update_ee_drv_mask(struct ufs_hba *hba, + u16 set, u16 clr) +{ + return ufshcd_update_ee_control(hba, &hba->ee_drv_mask, + &hba->ee_usr_mask, set, clr); +} + +static inline int ufshcd_update_ee_usr_mask(struct ufs_hba *hba, + u16 set, u16 clr) +{ + return ufshcd_update_ee_control(hba, &hba->ee_usr_mask, + &hba->ee_drv_mask, set, clr); +} + +static inline int ufshcd_rpm_get_sync(struct ufs_hba *hba) +{ + return pm_runtime_get_sync(&hba->ufs_device_wlun->sdev_gendev); +} + +static inline int ufshcd_rpm_put_sync(struct ufs_hba *hba) +{ + return pm_runtime_put_sync(&hba->ufs_device_wlun->sdev_gendev); +} + +static inline void ufshcd_rpm_get_noresume(struct ufs_hba *hba) +{ + pm_runtime_get_noresume(&hba->ufs_device_wlun->sdev_gendev); +} + +static inline int ufshcd_rpm_resume(struct ufs_hba *hba) +{ + return pm_runtime_resume(&hba->ufs_device_wlun->sdev_gendev); +} + +static inline int ufshcd_rpm_put(struct ufs_hba *hba) +{ + return pm_runtime_put(&hba->ufs_device_wlun->sdev_gendev); +} + +#endif /* _UFSHCD_PRIV_H_ */ diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index bac4ae63eb20..12e02d653990 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -26,7 +26,7 @@ #include #include #include -#include "ufshcd.h" +#include "ufshcd-priv.h" #include "ufs_quirks.h" #include "unipro.h" #include "ufs-sysfs.h" diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index ca36d8354f11..2b0f3441b813 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -1005,11 +1005,6 @@ static inline bool ufshcd_is_wb_allowed(struct ufs_hba *hba) return hba->caps & UFSHCD_CAP_WB_EN; } -static inline bool ufshcd_is_user_access_allowed(struct ufs_hba *hba) -{ - return !hba->shutting_down; -} - #define ufshcd_writel(hba, val, reg) \ writel((val), (hba)->mmio_base + (reg)) #define ufshcd_readl(hba, reg) \ @@ -1073,28 +1068,6 @@ static inline void *ufshcd_get_variant(struct ufs_hba *hba) BUG_ON(!hba); return hba->priv; } -static inline bool ufshcd_keep_autobkops_enabled_except_suspend( - struct ufs_hba *hba) -{ - return hba->caps & UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND; -} - -static inline u8 ufshcd_wb_get_query_index(struct ufs_hba *hba) -{ - if (hba->dev_info.wb_buffer_type == WB_BUF_MODE_LU_DEDICATED) - return hba->dev_info.wb_dedicated_lu; - return 0; -} - -#ifdef CONFIG_SCSI_UFS_HWMON -void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask); -void ufs_hwmon_remove(struct ufs_hba *hba); -void ufs_hwmon_notify_event(struct ufs_hba *hba, u8 ee_mask); -#else -static inline void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask) {} -static inline void ufs_hwmon_remove(struct ufs_hba *hba) {} -static inline void ufs_hwmon_notify_event(struct ufs_hba *hba, u8 ee_mask) {} -#endif #ifdef CONFIG_PM extern int ufshcd_runtime_suspend(struct device *dev); @@ -1228,13 +1201,6 @@ int __ufshcd_suspend_prepare(struct device *dev, bool rpm_ok_for_spm); void ufshcd_resume_complete(struct device *dev); /* Wrapper functions for safely calling variant operations */ -static inline const char *ufshcd_get_var_name(struct ufs_hba *hba) -{ - if (hba->vops) - return hba->vops->name; - return ""; -} - static inline int ufshcd_vops_init(struct ufs_hba *hba) { if (hba->vops && hba->vops->init) @@ -1243,61 +1209,6 @@ static inline int ufshcd_vops_init(struct ufs_hba *hba) return 0; } -static inline void ufshcd_vops_exit(struct ufs_hba *hba) -{ - if (hba->vops && hba->vops->exit) - return hba->vops->exit(hba); -} - -static inline u32 ufshcd_vops_get_ufs_hci_version(struct ufs_hba *hba) -{ - if (hba->vops && hba->vops->get_ufs_hci_version) - return hba->vops->get_ufs_hci_version(hba); - - return ufshcd_readl(hba, REG_UFS_VERSION); -} - -static inline int ufshcd_vops_clk_scale_notify(struct ufs_hba *hba, - bool up, enum ufs_notify_change_status status) -{ - if (hba->vops && hba->vops->clk_scale_notify) - return hba->vops->clk_scale_notify(hba, up, status); - return 0; -} - -static inline void ufshcd_vops_event_notify(struct ufs_hba *hba, - enum ufs_event_type evt, - void *data) -{ - if (hba->vops && hba->vops->event_notify) - hba->vops->event_notify(hba, evt, data); -} - -static inline int ufshcd_vops_setup_clocks(struct ufs_hba *hba, bool on, - enum ufs_notify_change_status status) -{ - if (hba->vops && hba->vops->setup_clocks) - return hba->vops->setup_clocks(hba, on, status); - return 0; -} - -static inline int ufshcd_vops_hce_enable_notify(struct ufs_hba *hba, - bool status) -{ - if (hba->vops && hba->vops->hce_enable_notify) - return hba->vops->hce_enable_notify(hba, status); - - return 0; -} -static inline int ufshcd_vops_link_startup_notify(struct ufs_hba *hba, - bool status) -{ - if (hba->vops && hba->vops->link_startup_notify) - return hba->vops->link_startup_notify(hba, status); - - return 0; -} - static inline int ufshcd_vops_phy_initialization(struct ufs_hba *hba) { if (hba->vops && hba->vops->phy_initialization) @@ -1306,102 +1217,8 @@ static inline int ufshcd_vops_phy_initialization(struct ufs_hba *hba) return 0; } -static inline int ufshcd_vops_pwr_change_notify(struct ufs_hba *hba, - enum ufs_notify_change_status status, - struct ufs_pa_layer_attr *dev_max_params, - struct ufs_pa_layer_attr *dev_req_params) -{ - if (hba->vops && hba->vops->pwr_change_notify) - return hba->vops->pwr_change_notify(hba, status, - dev_max_params, dev_req_params); - - return -ENOTSUPP; -} - -static inline void ufshcd_vops_setup_task_mgmt(struct ufs_hba *hba, - int tag, u8 tm_function) -{ - if (hba->vops && hba->vops->setup_task_mgmt) - return hba->vops->setup_task_mgmt(hba, tag, tm_function); -} - -static inline void ufshcd_vops_hibern8_notify(struct ufs_hba *hba, - enum uic_cmd_dme cmd, - enum ufs_notify_change_status status) -{ - if (hba->vops && hba->vops->hibern8_notify) - return hba->vops->hibern8_notify(hba, cmd, status); -} - -static inline int ufshcd_vops_apply_dev_quirks(struct ufs_hba *hba) -{ - if (hba->vops && hba->vops->apply_dev_quirks) - return hba->vops->apply_dev_quirks(hba); - return 0; -} - -static inline void ufshcd_vops_fixup_dev_quirks(struct ufs_hba *hba) -{ - if (hba->vops && hba->vops->fixup_dev_quirks) - hba->vops->fixup_dev_quirks(hba); -} - -static inline int ufshcd_vops_suspend(struct ufs_hba *hba, enum ufs_pm_op op, - enum ufs_notify_change_status status) -{ - if (hba->vops && hba->vops->suspend) - return hba->vops->suspend(hba, op, status); - - return 0; -} - -static inline int ufshcd_vops_resume(struct ufs_hba *hba, enum ufs_pm_op op) -{ - if (hba->vops && hba->vops->resume) - return hba->vops->resume(hba, op); - - return 0; -} - -static inline void ufshcd_vops_dbg_register_dump(struct ufs_hba *hba) -{ - if (hba->vops && hba->vops->dbg_register_dump) - hba->vops->dbg_register_dump(hba); -} - -static inline int ufshcd_vops_device_reset(struct ufs_hba *hba) -{ - if (hba->vops && hba->vops->device_reset) - return hba->vops->device_reset(hba); - - return -EOPNOTSUPP; -} - -static inline void ufshcd_vops_config_scaling_param(struct ufs_hba *hba, - struct devfreq_dev_profile *p, - struct devfreq_simple_ondemand_data *data) -{ - if (hba->vops && hba->vops->config_scaling_param) - hba->vops->config_scaling_param(hba, p, data); -} - extern struct ufs_pm_lvl_states ufs_pm_lvl_states[]; -/** - * ufshcd_scsi_to_upiu_lun - maps scsi LUN to UPIU LUN - * @scsi_lun: scsi LUN id - * - * Returns UPIU LUN id - */ -static inline u8 ufshcd_scsi_to_upiu_lun(unsigned int scsi_lun) -{ - if (scsi_is_wlun(scsi_lun)) - return (scsi_lun & UFS_UPIU_MAX_UNIT_NUM_ID) - | UFS_UPIU_WLUN_ID; - else - return scsi_lun & UFS_UPIU_MAX_UNIT_NUM_ID; -} - int ufshcd_dump_regs(struct ufs_hba *hba, size_t offset, size_t len, const char *prefix); @@ -1410,43 +1227,4 @@ int ufshcd_write_ee_control(struct ufs_hba *hba); int ufshcd_update_ee_control(struct ufs_hba *hba, u16 *mask, u16 *other_mask, u16 set, u16 clr); -static inline int ufshcd_update_ee_drv_mask(struct ufs_hba *hba, - u16 set, u16 clr) -{ - return ufshcd_update_ee_control(hba, &hba->ee_drv_mask, - &hba->ee_usr_mask, set, clr); -} - -static inline int ufshcd_update_ee_usr_mask(struct ufs_hba *hba, - u16 set, u16 clr) -{ - return ufshcd_update_ee_control(hba, &hba->ee_usr_mask, - &hba->ee_drv_mask, set, clr); -} - -static inline int ufshcd_rpm_get_sync(struct ufs_hba *hba) -{ - return pm_runtime_get_sync(&hba->ufs_device_wlun->sdev_gendev); -} - -static inline int ufshcd_rpm_put_sync(struct ufs_hba *hba) -{ - return pm_runtime_put_sync(&hba->ufs_device_wlun->sdev_gendev); -} - -static inline void ufshcd_rpm_get_noresume(struct ufs_hba *hba) -{ - pm_runtime_get_noresume(&hba->ufs_device_wlun->sdev_gendev); -} - -static inline int ufshcd_rpm_resume(struct ufs_hba *hba) -{ - return pm_runtime_resume(&hba->ufs_device_wlun->sdev_gendev); -} - -static inline int ufshcd_rpm_put(struct ufs_hba *hba) -{ - return pm_runtime_put(&hba->ufs_device_wlun->sdev_gendev); -} - #endif /* End of Header */ diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c index 68c97a2e825c..6e5237a041b5 100644 --- a/drivers/scsi/ufs/ufshpb.c +++ b/drivers/scsi/ufs/ufshpb.c @@ -15,7 +15,7 @@ #include #include -#include "ufshcd.h" +#include "ufshcd-priv.h" #include "ufshpb.h" #include "../sd.h" From 743b09d8541e2d6ae419bf41c4815f8be318dcc5 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Apr 2022 15:58:10 -0700 Subject: [PATCH 070/177] scsi: ufs: Move the struct ufs_ref_clk definition Move the definition of this data structure since it is only used in a single source file. Link: https://lore.kernel.org/r/20220419225811.4127248-28-bvanassche@acm.org Tested-by: Bean Huo Reviewed-by: Avri Altman Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufs.h | 5 ----- drivers/scsi/ufs/ufshcd.c | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h index 225b5b4a2a7e..f52173b8ad96 100644 --- a/drivers/scsi/ufs/ufs.h +++ b/drivers/scsi/ufs/ufs.h @@ -415,11 +415,6 @@ enum ufs_ref_clk_freq { REF_CLK_FREQ_INVAL = -1, }; -struct ufs_ref_clk { - unsigned long freq_hz; - enum ufs_ref_clk_freq val; -}; - /* Query response result code */ enum { QUERY_RESULT_SUCCESS = 0x00, diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 12e02d653990..1b87f26b5193 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -7959,6 +7959,11 @@ out: return err; } +struct ufs_ref_clk { + unsigned long freq_hz; + enum ufs_ref_clk_freq val; +}; + static struct ufs_ref_clk ufs_ref_clk_freqs[] = { {19200000, REF_CLK_FREQ_19_2_MHZ}, {26000000, REF_CLK_FREQ_26_MHZ}, From a8b032b5b3ba4e9d8ecb913724d0725121445b24 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 19 Apr 2022 15:58:11 -0700 Subject: [PATCH 071/177] scsi: ufs: Move the ufs_is_valid_unit_desc_lun() definition Move the definition of this function from a public into a private header file since it is only used inside the UFS core. Link: https://lore.kernel.org/r/20220419225811.4127248-29-bvanassche@acm.org Tested-by: Bean Huo Reviewed-by: Bean Huo Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufs.h | 19 ------------------- drivers/scsi/ufs/ufshcd-priv.h | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h index f52173b8ad96..1bba3fead2ce 100644 --- a/drivers/scsi/ufs/ufs.h +++ b/drivers/scsi/ufs/ufs.h @@ -620,23 +620,4 @@ enum ufs_trace_tsf_t { UFS_TSF_CDB, UFS_TSF_OSF, UFS_TSF_TM_INPUT, UFS_TSF_TM_OUTPUT }; -/** - * ufs_is_valid_unit_desc_lun - checks if the given LUN has a unit descriptor - * @dev_info: pointer of instance of struct ufs_dev_info - * @lun: LU number to check - * @return: true if the lun has a matching unit descriptor, false otherwise - */ -static inline bool ufs_is_valid_unit_desc_lun(struct ufs_dev_info *dev_info, - u8 lun, u8 param_offset) -{ - if (!dev_info || !dev_info->max_lu_supported) { - pr_err("Max General LU supported by UFS isn't initialized\n"); - return false; - } - /* WB is available only for the logical unit from 0 to 7 */ - if (param_offset == UNIT_DESC_PARAM_WB_BUF_ALLOC_UNITS) - return lun < UFS_UPIU_MAX_WB_LUN_ID; - return lun == UFS_UPIU_RPMB_WLUN || (lun < dev_info->max_lu_supported); -} - #endif /* End of Header */ diff --git a/drivers/scsi/ufs/ufshcd-priv.h b/drivers/scsi/ufs/ufshcd-priv.h index 3fa8ab94e4e1..38bc77d3dbbd 100644 --- a/drivers/scsi/ufs/ufshcd-priv.h +++ b/drivers/scsi/ufs/ufshcd-priv.h @@ -276,4 +276,23 @@ static inline int ufshcd_rpm_put(struct ufs_hba *hba) return pm_runtime_put(&hba->ufs_device_wlun->sdev_gendev); } +/** + * ufs_is_valid_unit_desc_lun - checks if the given LUN has a unit descriptor + * @dev_info: pointer of instance of struct ufs_dev_info + * @lun: LU number to check + * @return: true if the lun has a matching unit descriptor, false otherwise + */ +static inline bool ufs_is_valid_unit_desc_lun(struct ufs_dev_info *dev_info, + u8 lun, u8 param_offset) +{ + if (!dev_info || !dev_info->max_lu_supported) { + pr_err("Max General LU supported by UFS isn't initialized\n"); + return false; + } + /* WB is available only for the logical unit from 0 to 7 */ + if (param_offset == UNIT_DESC_PARAM_WB_BUF_ALLOC_UNITS) + return lun < UFS_UPIU_MAX_WB_LUN_ID; + return lun == UFS_UPIU_RPMB_WLUN || (lun < dev_info->max_lu_supported); +} + #endif /* _UFSHCD_PRIV_H_ */ From aa96bfb4caff59c93f0637092efe3a714cab0fe6 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 21 Apr 2022 11:30:15 -0700 Subject: [PATCH 072/177] scsi: sd: sd_zbc: Improve source code documentation Add several kernel-doc headers. Declare input arrays const. Specify the array size in function declarations. Link: https://lore.kernel.org/r/20220421183023.3462291-2-bvanassche@acm.org Reviewed-by: Damien Le Moal Reviewed-by: Himanshu Madhani Acked-by: Douglas Gilbert Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/sd.h | 5 ++-- drivers/scsi/sd_zbc.c | 55 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h index 0a33a4b68ffb..4849cbe771a7 100644 --- a/drivers/scsi/sd.h +++ b/drivers/scsi/sd.h @@ -222,7 +222,7 @@ static inline int sd_is_zoned(struct scsi_disk *sdkp) #ifdef CONFIG_BLK_DEV_ZONED void sd_zbc_release_disk(struct scsi_disk *sdkp); -int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buffer); +int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE]); int sd_zbc_revalidate_zones(struct scsi_disk *sdkp); blk_status_t sd_zbc_setup_zone_mgmt_cmnd(struct scsi_cmnd *cmd, unsigned char op, bool all); @@ -238,8 +238,7 @@ blk_status_t sd_zbc_prepare_zone_append(struct scsi_cmnd *cmd, sector_t *lba, static inline void sd_zbc_release_disk(struct scsi_disk *sdkp) {} -static inline int sd_zbc_read_zones(struct scsi_disk *sdkp, - unsigned char *buf) +static inline int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE]) { return 0; } diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c index 7f466280993b..2ae44bc52a5f 100644 --- a/drivers/scsi/sd_zbc.c +++ b/drivers/scsi/sd_zbc.c @@ -20,6 +20,12 @@ #include "sd.h" +/** + * sd_zbc_get_zone_wp_offset - Get zone write pointer offset. + * @zone: Zone for which to return the write pointer offset. + * + * Return: offset of the write pointer from the start of the zone. + */ static unsigned int sd_zbc_get_zone_wp_offset(struct blk_zone *zone) { if (zone->type == ZBC_ZONE_TYPE_CONV) @@ -44,7 +50,21 @@ static unsigned int sd_zbc_get_zone_wp_offset(struct blk_zone *zone) } } -static int sd_zbc_parse_report(struct scsi_disk *sdkp, u8 *buf, +/** + * sd_zbc_parse_report - Parse a SCSI zone descriptor + * @sdkp: SCSI disk pointer. + * @buf: SCSI zone descriptor. + * @idx: Index of the zone relative to the first zone reported by the current + * sd_zbc_report_zones() call. + * @cb: Callback function pointer. + * @data: Second argument passed to @cb. + * + * Return: Value returned by @cb. + * + * Convert a SCSI zone descriptor into struct blk_zone format. Additionally, + * call @cb(blk_zone, @data). + */ +static int sd_zbc_parse_report(struct scsi_disk *sdkp, const u8 buf[64], unsigned int idx, report_zones_cb cb, void *data) { struct scsi_device *sdp = sdkp->device; @@ -189,6 +209,17 @@ static inline sector_t sd_zbc_zone_sectors(struct scsi_disk *sdkp) return logical_to_sectors(sdkp->device, sdkp->zone_blocks); } +/** + * sd_zbc_report_zones - SCSI .report_zones() callback. + * @disk: Disk to report zones for. + * @sector: Start sector. + * @nr_zones: Maximum number of zones to report. + * @cb: Callback function called to report zone information. + * @data: Second argument passed to @cb. + * + * Called by the block layer to iterate over zone information. See also the + * disk->fops->report_zones() calls in block/blk-zoned.c. + */ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector, unsigned int nr_zones, report_zones_cb cb, void *data) { @@ -276,6 +307,10 @@ static int sd_zbc_update_wp_offset_cb(struct blk_zone *zone, unsigned int idx, return 0; } +/* + * An attempt to append a zone triggered an invalid write pointer error. + * Reread the write pointer of the zone(s) in which the append failed. + */ static void sd_zbc_update_wp_offset_workfn(struct work_struct *work) { struct scsi_disk *sdkp; @@ -585,7 +620,7 @@ static int sd_zbc_check_zoned_characteristics(struct scsi_disk *sdkp, * sd_zbc_check_capacity - Check the device capacity * @sdkp: Target disk * @buf: command buffer - * @zblocks: zone size in number of blocks + * @zblocks: zone size in logical blocks * * Get the device zone size and check that the device capacity as reported * by READ CAPACITY matches the max_lba value (plus one) of the report zones @@ -696,6 +731,11 @@ static void sd_zbc_revalidate_zones_cb(struct gendisk *disk) swap(sdkp->zones_wp_offset, sdkp->rev_wp_offset); } +/* + * Call blk_revalidate_disk_zones() if any of the zoned disk properties have + * changed that make it necessary to call that function. Called by + * sd_revalidate_disk() after the gendisk capacity has been set. + */ int sd_zbc_revalidate_zones(struct scsi_disk *sdkp) { struct gendisk *disk = sdkp->disk; @@ -774,7 +814,16 @@ unlock: return ret; } -int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buf) +/** + * sd_zbc_read_zones - Read zone information and update the request queue + * @sdkp: SCSI disk pointer. + * @buf: 512 byte buffer used for storing SCSI command output. + * + * Read zone information and update the request queue zone characteristics and + * also the zoned device information in *sdkp. Called by sd_revalidate_disk() + * before the gendisk capacity has been set. + */ +int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE]) { struct gendisk *disk = sdkp->disk; struct request_queue *q = disk->queue; From 9a93b9c9d38aee1f729f3cea72971a2616dca936 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 21 Apr 2022 11:30:16 -0700 Subject: [PATCH 073/177] scsi: sd: sd_zbc: Verify that the zone size is a power of two The following check in sd_zbc_cmnd_checks() can only work correctly if the zone size is a power of two: if (sector & (sd_zbc_zone_sectors(sdkp) - 1)) /* Unaligned request */ return BLK_STS_IOERR; Hence this patch that verifies that the zone size is a power of two. Link: https://lore.kernel.org/r/20220421183023.3462291-3-bvanassche@acm.org Reviewed-by: Damien Le Moal Reviewed-by: Himanshu Madhani Acked-by: Douglas Gilbert Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/sd_zbc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c index 2ae44bc52a5f..9ef5ad345185 100644 --- a/drivers/scsi/sd_zbc.c +++ b/drivers/scsi/sd_zbc.c @@ -664,6 +664,13 @@ static int sd_zbc_check_capacity(struct scsi_disk *sdkp, unsigned char *buf, return -EFBIG; } + if (!is_power_of_2(zone_blocks)) { + sd_printk(KERN_ERR, sdkp, + "Zone size %llu is not a power of two.\n", + zone_blocks); + return -EINVAL; + } + *zblocks = zone_blocks; return 0; From 43af5da09efb8abe450ec859d3063adeb7d1eb54 Mon Sep 17 00:00:00 2001 From: Damien Le Moal Date: Thu, 21 Apr 2022 11:30:17 -0700 Subject: [PATCH 074/177] scsi: sd: sd_zbc: Use logical blocks as unit when querying zones When querying zones, track the position in logical blocks instead of in sectors. This change slightly simplifies sd_zbc_report_zones(). Link: https://lore.kernel.org/r/20220421183023.3462291-4-bvanassche@acm.org Reviewed-by: Himanshu Madhani Acked-by: Douglas Gilbert Signed-off-by: Damien Le Moal [ bvanassche: extracted this change from a larger patch ] Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/sd_zbc.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c index 9ef5ad345185..e76bcbfd0d1c 100644 --- a/drivers/scsi/sd_zbc.c +++ b/drivers/scsi/sd_zbc.c @@ -224,7 +224,7 @@ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector, unsigned int nr_zones, report_zones_cb cb, void *data) { struct scsi_disk *sdkp = scsi_disk(disk); - sector_t capacity = logical_to_sectors(sdkp->device, sdkp->capacity); + sector_t lba = sectors_to_logical(sdkp->device, sector); unsigned int nr, i; unsigned char *buf; size_t offset, buflen = 0; @@ -235,7 +235,7 @@ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector, /* Not a zoned device */ return -EOPNOTSUPP; - if (!capacity) + if (!sdkp->capacity) /* Device gone or invalid */ return -ENODEV; @@ -243,9 +243,8 @@ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector, if (!buf) return -ENOMEM; - while (zone_idx < nr_zones && sector < capacity) { - ret = sd_zbc_do_report_zones(sdkp, buf, buflen, - sectors_to_logical(sdkp->device, sector), true); + while (zone_idx < nr_zones && lba < sdkp->capacity) { + ret = sd_zbc_do_report_zones(sdkp, buf, buflen, lba, true); if (ret) goto out; @@ -263,7 +262,7 @@ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector, zone_idx++; } - sector += sd_zbc_zone_sectors(sdkp) * i; + lba += sdkp->zone_blocks * i; } ret = zone_idx; From 628617be8968e575ca0a0637fb227f8a990cb2f7 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 21 Apr 2022 11:30:18 -0700 Subject: [PATCH 075/177] scsi: sd: sd_zbc: Introduce struct zoned_disk_info Deriving the meaning of the nr_zones, rev_nr_zones, zone_blocks and rev_zone_blocks member variables requires careful analysis of the source code. Make the meaning of these member variables easier to understand by introducing struct zoned_disk_info. Link: https://lore.kernel.org/r/20220421183023.3462291-5-bvanassche@acm.org Reviewed-by: Damien Le Moal Reviewed-by: Himanshu Madhani Acked-by: Douglas Gilbert Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/sd.h | 22 +++++++++++++++---- drivers/scsi/sd_zbc.c | 49 ++++++++++++++++++++----------------------- 2 files changed, 41 insertions(+), 30 deletions(-) diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h index 4849cbe771a7..47434f905b0a 100644 --- a/drivers/scsi/sd.h +++ b/drivers/scsi/sd.h @@ -67,6 +67,20 @@ enum { SD_ZERO_WS10_UNMAP, /* Use WRITE SAME(10) with UNMAP */ }; +/** + * struct zoned_disk_info - Specific properties of a ZBC SCSI device. + * @nr_zones: number of zones. + * @zone_blocks: number of logical blocks per zone. + * + * This data structure holds the ZBC SCSI device properties that are retrieved + * twice: a first time before the gendisk capacity is known and a second time + * after the gendisk capacity is known. + */ +struct zoned_disk_info { + u32 nr_zones; + u32 zone_blocks; +}; + struct scsi_disk { struct scsi_device *device; @@ -78,10 +92,10 @@ struct scsi_disk { struct gendisk *disk; struct opal_dev *opal_dev; #ifdef CONFIG_BLK_DEV_ZONED - u32 nr_zones; - u32 rev_nr_zones; - u32 zone_blocks; - u32 rev_zone_blocks; + /* Updated during revalidation before the gendisk capacity is known. */ + struct zoned_disk_info early_zone_info; + /* Updated during revalidation after the gendisk capacity is known. */ + struct zoned_disk_info zone_info; u32 zones_optimal_open; u32 zones_optimal_nonseq; u32 zones_max_open; diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c index e76bcbfd0d1c..ac557a5a65c8 100644 --- a/drivers/scsi/sd_zbc.c +++ b/drivers/scsi/sd_zbc.c @@ -181,7 +181,7 @@ static void *sd_zbc_alloc_report_buffer(struct scsi_disk *sdkp, * sure that the allocated buffer can always be mapped by limiting the * number of pages allocated to the HBA max segments limit. */ - nr_zones = min(nr_zones, sdkp->nr_zones); + nr_zones = min(nr_zones, sdkp->zone_info.nr_zones); bufsize = roundup((nr_zones + 1) * 64, SECTOR_SIZE); bufsize = min_t(size_t, bufsize, queue_max_hw_sectors(q) << SECTOR_SHIFT); @@ -206,7 +206,7 @@ static void *sd_zbc_alloc_report_buffer(struct scsi_disk *sdkp, */ static inline sector_t sd_zbc_zone_sectors(struct scsi_disk *sdkp) { - return logical_to_sectors(sdkp->device, sdkp->zone_blocks); + return logical_to_sectors(sdkp->device, sdkp->zone_info.zone_blocks); } /** @@ -262,7 +262,7 @@ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector, zone_idx++; } - lba += sdkp->zone_blocks * i; + lba += sdkp->zone_info.zone_blocks * i; } ret = zone_idx; @@ -320,14 +320,14 @@ static void sd_zbc_update_wp_offset_workfn(struct work_struct *work) sdkp = container_of(work, struct scsi_disk, zone_wp_offset_work); spin_lock_irqsave(&sdkp->zones_wp_offset_lock, flags); - for (zno = 0; zno < sdkp->nr_zones; zno++) { + for (zno = 0; zno < sdkp->zone_info.nr_zones; zno++) { if (sdkp->zones_wp_offset[zno] != SD_ZBC_UPDATING_WP_OFST) continue; spin_unlock_irqrestore(&sdkp->zones_wp_offset_lock, flags); ret = sd_zbc_do_report_zones(sdkp, sdkp->zone_wp_update_buf, SD_BUF_SIZE, - zno * sdkp->zone_blocks, true); + zno * sdkp->zone_info.zone_blocks, true); spin_lock_irqsave(&sdkp->zones_wp_offset_lock, flags); if (!ret) sd_zbc_parse_report(sdkp, sdkp->zone_wp_update_buf + 64, @@ -394,7 +394,7 @@ blk_status_t sd_zbc_prepare_zone_append(struct scsi_cmnd *cmd, sector_t *lba, break; default: wp_offset = sectors_to_logical(sdkp->device, wp_offset); - if (wp_offset + nr_blocks > sdkp->zone_blocks) { + if (wp_offset + nr_blocks > sdkp->zone_info.zone_blocks) { ret = BLK_STS_IOERR; break; } @@ -523,7 +523,7 @@ static unsigned int sd_zbc_zone_wp_update(struct scsi_cmnd *cmd, break; case REQ_OP_ZONE_RESET_ALL: memset(sdkp->zones_wp_offset, 0, - sdkp->nr_zones * sizeof(unsigned int)); + sdkp->zone_info.nr_zones * sizeof(unsigned int)); break; default: break; @@ -680,16 +680,16 @@ static void sd_zbc_print_zones(struct scsi_disk *sdkp) if (!sd_is_zoned(sdkp) || !sdkp->capacity) return; - if (sdkp->capacity & (sdkp->zone_blocks - 1)) + if (sdkp->capacity & (sdkp->zone_info.zone_blocks - 1)) sd_printk(KERN_NOTICE, sdkp, "%u zones of %u logical blocks + 1 runt zone\n", - sdkp->nr_zones - 1, - sdkp->zone_blocks); + sdkp->zone_info.nr_zones - 1, + sdkp->zone_info.zone_blocks); else sd_printk(KERN_NOTICE, sdkp, "%u zones of %u logical blocks\n", - sdkp->nr_zones, - sdkp->zone_blocks); + sdkp->zone_info.nr_zones, + sdkp->zone_info.zone_blocks); } static int sd_zbc_init_disk(struct scsi_disk *sdkp) @@ -716,10 +716,8 @@ static void sd_zbc_clear_zone_info(struct scsi_disk *sdkp) kfree(sdkp->zone_wp_update_buf); sdkp->zone_wp_update_buf = NULL; - sdkp->nr_zones = 0; - sdkp->rev_nr_zones = 0; - sdkp->zone_blocks = 0; - sdkp->rev_zone_blocks = 0; + sdkp->early_zone_info = (struct zoned_disk_info){ }; + sdkp->zone_info = (struct zoned_disk_info){ }; mutex_unlock(&sdkp->rev_mutex); } @@ -746,8 +744,8 @@ int sd_zbc_revalidate_zones(struct scsi_disk *sdkp) { struct gendisk *disk = sdkp->disk; struct request_queue *q = disk->queue; - u32 zone_blocks = sdkp->rev_zone_blocks; - unsigned int nr_zones = sdkp->rev_nr_zones; + u32 zone_blocks = sdkp->early_zone_info.zone_blocks; + unsigned int nr_zones = sdkp->early_zone_info.nr_zones; u32 max_append; int ret = 0; unsigned int flags; @@ -778,14 +776,14 @@ int sd_zbc_revalidate_zones(struct scsi_disk *sdkp) */ mutex_lock(&sdkp->rev_mutex); - if (sdkp->zone_blocks == zone_blocks && - sdkp->nr_zones == nr_zones && + if (sdkp->zone_info.zone_blocks == zone_blocks && + sdkp->zone_info.nr_zones == nr_zones && disk->queue->nr_zones == nr_zones) goto unlock; flags = memalloc_noio_save(); - sdkp->zone_blocks = zone_blocks; - sdkp->nr_zones = nr_zones; + sdkp->zone_info.zone_blocks = zone_blocks; + sdkp->zone_info.nr_zones = nr_zones; sdkp->rev_wp_offset = kvcalloc(nr_zones, sizeof(u32), GFP_KERNEL); if (!sdkp->rev_wp_offset) { ret = -ENOMEM; @@ -800,8 +798,7 @@ int sd_zbc_revalidate_zones(struct scsi_disk *sdkp) sdkp->rev_wp_offset = NULL; if (ret) { - sdkp->zone_blocks = 0; - sdkp->nr_zones = 0; + sdkp->zone_info = (struct zoned_disk_info){ }; sdkp->capacity = 0; goto unlock; } @@ -887,8 +884,8 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE]) if (blk_queue_zoned_model(q) == BLK_ZONED_HM) blk_queue_zone_write_granularity(q, sdkp->physical_block_size); - sdkp->rev_nr_zones = nr_zones; - sdkp->rev_zone_blocks = zone_blocks; + sdkp->early_zone_info.nr_zones = nr_zones; + sdkp->early_zone_info.zone_blocks = zone_blocks; return 0; From 60caf3758103b8edc90724ba781ff119f739162a Mon Sep 17 00:00:00 2001 From: Damien Le Moal Date: Thu, 21 Apr 2022 11:30:19 -0700 Subject: [PATCH 076/177] scsi: sd: sd_zbc: Return early in sd_zbc_check_zoned_characteristics() Return early in sd_zbc_check_zoned_characteristics() for host-aware disks. This patch does not change any functionality but makes a later patch easier to read. Link: https://lore.kernel.org/r/20220421183023.3462291-6-bvanassche@acm.org Reviewed-by: Himanshu Madhani Acked-by: Douglas Gilbert Signed-off-by: Damien Le Moal [ bvanassche: extracted this change from a larger patch ] Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/sd_zbc.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c index ac557a5a65c8..c53e166362b9 100644 --- a/drivers/scsi/sd_zbc.c +++ b/drivers/scsi/sd_zbc.c @@ -592,14 +592,15 @@ static int sd_zbc_check_zoned_characteristics(struct scsi_disk *sdkp, sdkp->zones_optimal_open = get_unaligned_be32(&buf[8]); sdkp->zones_optimal_nonseq = get_unaligned_be32(&buf[12]); sdkp->zones_max_open = 0; - } else { - /* Host-managed */ - sdkp->urswrz = buf[4] & 1; - sdkp->zones_optimal_open = 0; - sdkp->zones_optimal_nonseq = 0; - sdkp->zones_max_open = get_unaligned_be32(&buf[16]); + return 0; } + /* Host-managed */ + sdkp->urswrz = buf[4] & 1; + sdkp->zones_optimal_open = 0; + sdkp->zones_optimal_nonseq = 0; + sdkp->zones_max_open = get_unaligned_be32(&buf[16]); + /* * Check for unconstrained reads: host-managed devices with * constrained reads (drives failing read after write pointer) From c976e588b34e4ff2fdd2922edab4b983244a17e6 Mon Sep 17 00:00:00 2001 From: Damien Le Moal Date: Thu, 21 Apr 2022 11:30:20 -0700 Subject: [PATCH 077/177] scsi: sd: sd_zbc: Hide gap zones ZBC-2 allows host-managed disks to report gap zones. This allow zoned disks to report an offset between data zone starts that is a power of two even if the number of logical blocks with data per zone is not a power of two. Another new feature in ZBC-2 is support for constant zone starting LBA offsets. For zoned disks that report a constant zone starting LBA offset, hide the gap zones from the block layer. Report the offset between data zone starts as zone size and report the number of logical blocks with data per zone as the zone capacity. Link: https://lore.kernel.org/r/20220421183023.3462291-7-bvanassche@acm.org Acked-by: Douglas Gilbert Signed-off-by: Damien Le Moal [ bvanassche: Reworked this patch ] Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/sd.h | 5 ++ drivers/scsi/sd_zbc.c | 105 +++++++++++++++++++++++++++++++++----- include/scsi/scsi_proto.h | 9 +++- 3 files changed, 105 insertions(+), 14 deletions(-) diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h index 47434f905b0a..d249933ba69e 100644 --- a/drivers/scsi/sd.h +++ b/drivers/scsi/sd.h @@ -99,6 +99,11 @@ struct scsi_disk { u32 zones_optimal_open; u32 zones_optimal_nonseq; u32 zones_max_open; + /* + * Either zero or a power of two. If not zero it means that the offset + * between zone starting LBAs is constant. + */ + u32 zone_starting_lba_gran; u32 *zones_wp_offset; spinlock_t zones_wp_offset_lock; u32 *rev_wp_offset; diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c index c53e166362b9..5b9fad70aa88 100644 --- a/drivers/scsi/sd_zbc.c +++ b/drivers/scsi/sd_zbc.c @@ -50,6 +50,12 @@ static unsigned int sd_zbc_get_zone_wp_offset(struct blk_zone *zone) } } +/* Whether or not a SCSI zone descriptor describes a gap zone. */ +static bool sd_zbc_is_gap_zone(const u8 buf[64]) +{ + return (buf[0] & 0xf) == ZBC_ZONE_TYPE_GAP; +} + /** * sd_zbc_parse_report - Parse a SCSI zone descriptor * @sdkp: SCSI disk pointer. @@ -69,8 +75,12 @@ static int sd_zbc_parse_report(struct scsi_disk *sdkp, const u8 buf[64], { struct scsi_device *sdp = sdkp->device; struct blk_zone zone = { 0 }; + sector_t start_lba, gran; int ret; + if (WARN_ON_ONCE(sd_zbc_is_gap_zone(buf))) + return -EINVAL; + zone.type = buf[0] & 0x0f; zone.cond = (buf[1] >> 4) & 0xf; if (buf[1] & 0x01) @@ -78,9 +88,27 @@ static int sd_zbc_parse_report(struct scsi_disk *sdkp, const u8 buf[64], if (buf[1] & 0x02) zone.non_seq = 1; - zone.len = logical_to_sectors(sdp, get_unaligned_be64(&buf[8])); - zone.capacity = zone.len; - zone.start = logical_to_sectors(sdp, get_unaligned_be64(&buf[16])); + start_lba = get_unaligned_be64(&buf[16]); + zone.start = logical_to_sectors(sdp, start_lba); + zone.capacity = logical_to_sectors(sdp, get_unaligned_be64(&buf[8])); + zone.len = zone.capacity; + if (sdkp->zone_starting_lba_gran) { + gran = logical_to_sectors(sdp, sdkp->zone_starting_lba_gran); + if (zone.len > gran) { + sd_printk(KERN_ERR, sdkp, + "Invalid zone at LBA %llu with capacity %llu and length %llu; granularity = %llu\n", + start_lba, + sectors_to_logical(sdp, zone.capacity), + sectors_to_logical(sdp, zone.len), + sectors_to_logical(sdp, gran)); + return -EINVAL; + } + /* + * Use the starting LBA granularity instead of the zone length + * obtained from the REPORT ZONES command. + */ + zone.len = gran; + } if (zone.cond == ZBC_ZONE_COND_FULL) zone.wp = zone.start + zone.len; else @@ -227,6 +255,7 @@ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector, sector_t lba = sectors_to_logical(sdkp->device, sector); unsigned int nr, i; unsigned char *buf; + u64 zone_length, start_lba; size_t offset, buflen = 0; int zone_idx = 0; int ret; @@ -255,14 +284,36 @@ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector, for (i = 0; i < nr && zone_idx < nr_zones; i++) { offset += 64; + start_lba = get_unaligned_be64(&buf[offset + 16]); + zone_length = get_unaligned_be64(&buf[offset + 8]); + if ((zone_idx == 0 && + (lba < start_lba || + lba >= start_lba + zone_length)) || + (zone_idx > 0 && start_lba != lba) || + start_lba + zone_length < start_lba) { + sd_printk(KERN_ERR, sdkp, + "Zone %d at LBA %llu is invalid: %llu + %llu\n", + zone_idx, lba, start_lba, zone_length); + ret = -EINVAL; + goto out; + } + lba = start_lba + zone_length; + if (sd_zbc_is_gap_zone(&buf[offset])) { + if (sdkp->zone_starting_lba_gran) + continue; + sd_printk(KERN_ERR, sdkp, + "Gap zone without constant LBA offsets\n"); + ret = -EINVAL; + goto out; + } + ret = sd_zbc_parse_report(sdkp, buf + offset, zone_idx, cb, data); if (ret) goto out; + zone_idx++; } - - lba += sdkp->zone_info.zone_blocks * i; } ret = zone_idx; @@ -579,6 +630,7 @@ unsigned int sd_zbc_complete(struct scsi_cmnd *cmd, unsigned int good_bytes, static int sd_zbc_check_zoned_characteristics(struct scsi_disk *sdkp, unsigned char *buf) { + u64 zone_starting_lba_gran; if (scsi_get_vpd_page(sdkp->device, 0xb6, buf, 64)) { sd_printk(KERN_NOTICE, sdkp, @@ -600,6 +652,29 @@ static int sd_zbc_check_zoned_characteristics(struct scsi_disk *sdkp, sdkp->zones_optimal_open = 0; sdkp->zones_optimal_nonseq = 0; sdkp->zones_max_open = get_unaligned_be32(&buf[16]); + /* Check zone alignment method */ + switch (buf[23] & 0xf) { + case 0: + case ZBC_CONSTANT_ZONE_LENGTH: + /* Use zone length */ + break; + case ZBC_CONSTANT_ZONE_START_OFFSET: + zone_starting_lba_gran = get_unaligned_be64(&buf[24]); + if (zone_starting_lba_gran == 0 || + !is_power_of_2(zone_starting_lba_gran) || + logical_to_sectors(sdkp->device, zone_starting_lba_gran) > + UINT_MAX) { + sd_printk(KERN_ERR, sdkp, + "Invalid zone starting LBA granularity %llu\n", + zone_starting_lba_gran); + return -ENODEV; + } + sdkp->zone_starting_lba_gran = zone_starting_lba_gran; + break; + default: + sd_printk(KERN_ERR, sdkp, "Invalid zone alignment method\n"); + return -ENODEV; + } /* * Check for unconstrained reads: host-managed devices with @@ -654,14 +729,18 @@ static int sd_zbc_check_capacity(struct scsi_disk *sdkp, unsigned char *buf, } } - /* Get the size of the first reported zone */ - rec = buf + 64; - zone_blocks = get_unaligned_be64(&rec[8]); - if (logical_to_sectors(sdkp->device, zone_blocks) > UINT_MAX) { - if (sdkp->first_scan) - sd_printk(KERN_NOTICE, sdkp, - "Zone size too large\n"); - return -EFBIG; + if (sdkp->zone_starting_lba_gran == 0) { + /* Get the size of the first reported zone */ + rec = buf + 64; + zone_blocks = get_unaligned_be64(&rec[8]); + if (logical_to_sectors(sdkp->device, zone_blocks) > UINT_MAX) { + if (sdkp->first_scan) + sd_printk(KERN_NOTICE, sdkp, + "Zone size too large\n"); + return -EFBIG; + } + } else { + zone_blocks = sdkp->zone_starting_lba_gran; } if (!is_power_of_2(zone_blocks)) { diff --git a/include/scsi/scsi_proto.h b/include/scsi/scsi_proto.h index f017843a8124..c03e35fc382c 100644 --- a/include/scsi/scsi_proto.h +++ b/include/scsi/scsi_proto.h @@ -307,7 +307,9 @@ enum zbc_zone_type { ZBC_ZONE_TYPE_CONV = 0x1, ZBC_ZONE_TYPE_SEQWRITE_REQ = 0x2, ZBC_ZONE_TYPE_SEQWRITE_PREF = 0x3, - /* 0x4 to 0xf are reserved */ + ZBC_ZONE_TYPE_SEQ_OR_BEFORE_REQ = 0x4, + ZBC_ZONE_TYPE_GAP = 0x5, + /* 0x6 to 0xf are reserved */ }; /* Zone conditions of REPORT ZONES zone descriptors */ @@ -323,6 +325,11 @@ enum zbc_zone_cond { ZBC_ZONE_COND_OFFLINE = 0xf, }; +enum zbc_zone_alignment_method { + ZBC_CONSTANT_ZONE_LENGTH = 0x1, + ZBC_CONSTANT_ZONE_START_OFFSET = 0x8, +}; + /* Version descriptor values for INQUIRY */ enum scsi_version_descriptor { SCSI_VERSION_DESCRIPTOR_FCP4 = 0x0a40, From 897284e8a04894537b58a079a2729a70731c229d Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 21 Apr 2022 11:30:21 -0700 Subject: [PATCH 078/177] scsi: scsi_debug: Fix a typo Change a single occurrence of "nad" into "and". Link: https://lore.kernel.org/r/20220421183023.3462291-8-bvanassche@acm.org Cc: Douglas Gilbert Reviewed-by: Damien Le Moal Reviewed-by: Himanshu Madhani Acked-by: Douglas Gilbert Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/scsi_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 592a290e6cfa..e1c47c68fe25 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -4404,7 +4404,7 @@ cleanup: #define RZONES_DESC_HD 64 -/* Report zones depending on start LBA nad reporting options */ +/* Report zones depending on start LBA and reporting options */ static int resp_report_zones(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) { From 35dbe2b9a7b0c92777c855c6a2cca8390f4c166b Mon Sep 17 00:00:00 2001 From: Damien Le Moal Date: Thu, 21 Apr 2022 11:30:22 -0700 Subject: [PATCH 079/177] scsi: scsi_debug: Rename zone type constants Rename the scsi_debug zone type constants to prevent a conflict with the ZBC_ZONE_TYPE_GAP constant from include/scsi/scsi_proto.h. Link: https://lore.kernel.org/r/20220421183023.3462291-9-bvanassche@acm.org Cc: Douglas Gilbert Acked-by: Douglas Gilbert Signed-off-by: Damien Le Moal [ bvanassche: Extracted these changes from a larger patch ] Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/scsi_debug.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index e1c47c68fe25..8e95b7a351c3 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -251,9 +251,9 @@ static const char *sdebug_version_date = "20210520"; /* Zone types (zbcr05 table 25) */ enum sdebug_z_type { - ZBC_ZONE_TYPE_CNV = 0x1, - ZBC_ZONE_TYPE_SWR = 0x2, - ZBC_ZONE_TYPE_SWP = 0x3, + ZBC_ZTYPE_CNV = 0x1, + ZBC_ZTYPE_SWR = 0x2, + ZBC_ZTYPE_SWP = 0x3, }; /* enumeration names taken from table 26, zbcr05 */ @@ -2716,7 +2716,7 @@ static struct sdeb_zone_state *zbc_zone(struct sdebug_dev_info *devip, static inline bool zbc_zone_is_conv(struct sdeb_zone_state *zsp) { - return zsp->z_type == ZBC_ZONE_TYPE_CNV; + return zsp->z_type == ZBC_ZTYPE_CNV; } static void zbc_close_zone(struct sdebug_dev_info *devip, @@ -2797,7 +2797,7 @@ static void zbc_inc_wp(struct sdebug_dev_info *devip, if (zbc_zone_is_conv(zsp)) return; - if (zsp->z_type == ZBC_ZONE_TYPE_SWR) { + if (zsp->z_type == ZBC_ZTYPE_SWR) { zsp->z_wp += num; if (zsp->z_wp >= zend) zsp->z_cond = ZC5_FULL; @@ -2864,7 +2864,7 @@ static int check_zbc_access_params(struct scsi_cmnd *scp, return 0; } - if (zsp->z_type == ZBC_ZONE_TYPE_SWR) { + if (zsp->z_type == ZBC_ZTYPE_SWR) { /* Writes cannot cross sequential zone boundaries */ if (zsp_end != zsp) { mk_sense_buffer(scp, ILLEGAL_REQUEST, @@ -5001,14 +5001,14 @@ static int sdebug_device_create_zones(struct sdebug_dev_info *devip) zsp->z_start = zstart; if (i < devip->nr_conv_zones) { - zsp->z_type = ZBC_ZONE_TYPE_CNV; + zsp->z_type = ZBC_ZTYPE_CNV; zsp->z_cond = ZBC_NOT_WRITE_POINTER; zsp->z_wp = (sector_t)-1; } else { if (devip->zmodel == BLK_ZONED_HM) - zsp->z_type = ZBC_ZONE_TYPE_SWR; + zsp->z_type = ZBC_ZTYPE_SWR; else - zsp->z_type = ZBC_ZONE_TYPE_SWP; + zsp->z_type = ZBC_ZTYPE_SWP; zsp->z_cond = ZC1_EMPTY; zsp->z_wp = zsp->z_start; } From 4a5fc1c6d75261f2f014a961d39ab10aae66a0f9 Mon Sep 17 00:00:00 2001 From: Damien Le Moal Date: Thu, 21 Apr 2022 11:30:23 -0700 Subject: [PATCH 080/177] scsi: scsi_debug: Add gap zone support Add the 'zone_cap_mb' kernel module parameter. This parameter defines the zone capacity. The zone capacity must be less than or equal to the zone size. Report that sequential write zones and gap zones are paired in the Zoned Block Device Characteristics VPD page (page B6h). This patch has been tested as follows: modprobe scsi_debug delay=0 sector_size=512 dev_size_mb=128 zbc=host-managed zone_nr_conv=16 zone_size_mb=4 zone_cap_mb=3 modprobe brd rd_nr=1 rd_size=$((1<<20)) mkfs.f2fs -m /dev/ram0 -c /dev/${scsi_debug_dev} mount /dev/ram0 /mnt # Run a fio job that uses /mnt Link: https://lore.kernel.org/r/20220421183023.3462291-10-bvanassche@acm.org Cc: Douglas Gilbert Acked-by: Douglas Gilbert Signed-off-by: Damien Le Moal [ bvanassche: Switched to reporting a constant zone starting LBA granularity ] Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/scsi_debug.c | 129 ++++++++++++++++++++++++++++++-------- 1 file changed, 104 insertions(+), 25 deletions(-) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 8e95b7a351c3..1f423f723d06 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -16,7 +16,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__ #include - +#include #include #include #include @@ -98,6 +98,7 @@ static const char *sdebug_version_date = "20210520"; #define WRITE_BOUNDARY_ASCQ 0x5 #define READ_INVDATA_ASCQ 0x6 #define READ_BOUNDARY_ASCQ 0x7 +#define ATTEMPT_ACCESS_GAP 0x9 #define INSUFF_ZONE_ASCQ 0xe /* Additional Sense Code Qualifier (ASCQ) */ @@ -254,6 +255,8 @@ enum sdebug_z_type { ZBC_ZTYPE_CNV = 0x1, ZBC_ZTYPE_SWR = 0x2, ZBC_ZTYPE_SWP = 0x3, + /* ZBC_ZTYPE_SOBR = 0x4, */ + ZBC_ZTYPE_GAP = 0x5, }; /* enumeration names taken from table 26, zbcr05 */ @@ -291,10 +294,12 @@ struct sdebug_dev_info { /* For ZBC devices */ enum blk_zoned_model zmodel; + unsigned int zcap; unsigned int zsize; unsigned int zsize_shift; unsigned int nr_zones; unsigned int nr_conv_zones; + unsigned int nr_seq_zones; unsigned int nr_imp_open; unsigned int nr_exp_open; unsigned int nr_closed; @@ -829,6 +834,7 @@ static int dif_errors; /* ZBC global data */ static bool sdeb_zbc_in_use; /* true for host-aware and host-managed disks */ +static int sdeb_zbc_zone_cap_mb; static int sdeb_zbc_zone_size_mb; static int sdeb_zbc_max_open = DEF_ZBC_MAX_OPEN_ZONES; static int sdeb_zbc_nr_conv = DEF_ZBC_NR_CONV_ZONES; @@ -1559,6 +1565,12 @@ static int inquiry_vpd_b6(struct sdebug_dev_info *devip, unsigned char *arr) put_unaligned_be32(devip->max_open, &arr[12]); else put_unaligned_be32(0xffffffff, &arr[12]); + if (devip->zcap < devip->zsize) { + arr[19] = ZBC_CONSTANT_ZONE_START_OFFSET; + put_unaligned_be64(devip->zsize, &arr[20]); + } else { + arr[19] = 0; + } return 0x3c; } @@ -2711,7 +2723,23 @@ static inline bool sdebug_dev_is_zoned(struct sdebug_dev_info *devip) static struct sdeb_zone_state *zbc_zone(struct sdebug_dev_info *devip, unsigned long long lba) { - return &devip->zstate[lba >> devip->zsize_shift]; + u32 zno = lba >> devip->zsize_shift; + struct sdeb_zone_state *zsp; + + if (devip->zcap == devip->zsize || zno < devip->nr_conv_zones) + return &devip->zstate[zno]; + + /* + * If the zone capacity is less than the zone size, adjust for gap + * zones. + */ + zno = 2 * zno - devip->nr_conv_zones; + WARN_ONCE(zno >= devip->nr_zones, "%u > %u\n", zno, devip->nr_zones); + zsp = &devip->zstate[zno]; + if (lba >= zsp->z_start + zsp->z_size) + zsp++; + WARN_ON_ONCE(lba >= zsp->z_start + zsp->z_size); + return zsp; } static inline bool zbc_zone_is_conv(struct sdeb_zone_state *zsp) @@ -2719,12 +2747,22 @@ static inline bool zbc_zone_is_conv(struct sdeb_zone_state *zsp) return zsp->z_type == ZBC_ZTYPE_CNV; } +static inline bool zbc_zone_is_gap(struct sdeb_zone_state *zsp) +{ + return zsp->z_type == ZBC_ZTYPE_GAP; +} + +static inline bool zbc_zone_is_seq(struct sdeb_zone_state *zsp) +{ + return !zbc_zone_is_conv(zsp) && !zbc_zone_is_gap(zsp); +} + static void zbc_close_zone(struct sdebug_dev_info *devip, struct sdeb_zone_state *zsp) { enum sdebug_z_cond zc; - if (zbc_zone_is_conv(zsp)) + if (!zbc_zone_is_seq(zsp)) return; zc = zsp->z_cond; @@ -2762,7 +2800,7 @@ static void zbc_open_zone(struct sdebug_dev_info *devip, { enum sdebug_z_cond zc; - if (zbc_zone_is_conv(zsp)) + if (!zbc_zone_is_seq(zsp)) return; zc = zsp->z_cond; @@ -2794,7 +2832,7 @@ static void zbc_inc_wp(struct sdebug_dev_info *devip, struct sdeb_zone_state *zsp = zbc_zone(devip, lba); unsigned long long n, end, zend = zsp->z_start + zsp->z_size; - if (zbc_zone_is_conv(zsp)) + if (!zbc_zone_is_seq(zsp)) return; if (zsp->z_type == ZBC_ZTYPE_SWR) { @@ -2842,9 +2880,7 @@ static int check_zbc_access_params(struct scsi_cmnd *scp, if (devip->zmodel == BLK_ZONED_HA) return 0; /* For host-managed, reads cannot cross zone types boundaries */ - if (zsp_end != zsp && - zbc_zone_is_conv(zsp) && - !zbc_zone_is_conv(zsp_end)) { + if (zsp->z_type != zsp_end->z_type) { mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, READ_INVDATA_ASCQ); @@ -2853,6 +2889,13 @@ static int check_zbc_access_params(struct scsi_cmnd *scp, return 0; } + /* Writing into a gap zone is not allowed */ + if (zbc_zone_is_gap(zsp)) { + mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE, + ATTEMPT_ACCESS_GAP); + return check_condition_result; + } + /* No restrictions for writes within conventional zones */ if (zbc_zone_is_conv(zsp)) { if (!zbc_zone_is_conv(zsp_end)) { @@ -4408,14 +4451,14 @@ cleanup: static int resp_report_zones(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) { - unsigned int i, max_zones, rep_max_zones, nrz = 0; + unsigned int rep_max_zones, nrz = 0; int ret = 0; u32 alloc_len, rep_opts, rep_len; bool partial; u64 lba, zs_lba; u8 *arr = NULL, *desc; u8 *cmd = scp->cmnd; - struct sdeb_zone_state *zsp; + struct sdeb_zone_state *zsp = NULL; struct sdeb_store_info *sip = devip2sip(devip, false); if (!sdebug_dev_is_zoned(devip)) { @@ -4434,9 +4477,7 @@ static int resp_report_zones(struct scsi_cmnd *scp, return check_condition_result; } - max_zones = devip->nr_zones - (zs_lba >> devip->zsize_shift); - rep_max_zones = min((alloc_len - 64) >> ilog2(RZONES_DESC_HD), - max_zones); + rep_max_zones = (alloc_len - 64) >> ilog2(RZONES_DESC_HD); arr = kzalloc(alloc_len, GFP_ATOMIC); if (!arr) { @@ -4448,9 +4489,9 @@ static int resp_report_zones(struct scsi_cmnd *scp, sdeb_read_lock(sip); desc = arr + 64; - for (i = 0; i < max_zones; i++) { - lba = zs_lba + devip->zsize * i; - if (lba > sdebug_capacity) + for (lba = zs_lba; lba < sdebug_capacity; + lba = zsp->z_start + zsp->z_size) { + if (WARN_ONCE(zbc_zone(devip, lba) == zsp, "lba = %llu\n", lba)) break; zsp = zbc_zone(devip, lba); switch (rep_opts) { @@ -4495,9 +4536,14 @@ static int resp_report_zones(struct scsi_cmnd *scp, if (!zsp->z_non_seq_resource) continue; break; + case 0x3e: + /* All zones except gap zones. */ + if (zbc_zone_is_gap(zsp)) + continue; + break; case 0x3f: /* Not write pointer (conventional) zones */ - if (!zbc_zone_is_conv(zsp)) + if (zbc_zone_is_seq(zsp)) continue; break; default: @@ -4526,8 +4572,13 @@ static int resp_report_zones(struct scsi_cmnd *scp, } /* Report header */ + /* Zone list length. */ put_unaligned_be32(nrz * RZONES_DESC_HD, arr + 0); + /* Maximum LBA */ put_unaligned_be64(sdebug_capacity - 1, arr + 8); + /* Zone starting LBA granularity. */ + if (devip->zcap < devip->zsize) + put_unaligned_be64(devip->zsize, arr + 16); rep_len = (unsigned long)desc - (unsigned long)arr; ret = fill_from_dev_buffer(scp, arr, min_t(u32, alloc_len, rep_len)); @@ -4752,7 +4803,7 @@ static void zbc_rwp_zone(struct sdebug_dev_info *devip, enum sdebug_z_cond zc; struct sdeb_store_info *sip = devip2sip(devip, false); - if (zbc_zone_is_conv(zsp)) + if (!zbc_zone_is_seq(zsp)) return; zc = zsp->z_cond; @@ -4942,6 +4993,7 @@ static int sdebug_device_create_zones(struct sdebug_dev_info *devip) { struct sdeb_zone_state *zsp; sector_t capacity = get_sdebug_capacity(); + sector_t conv_capacity; sector_t zstart = 0; unsigned int i; @@ -4976,11 +5028,30 @@ static int sdebug_device_create_zones(struct sdebug_dev_info *devip) devip->zsize_shift = ilog2(devip->zsize); devip->nr_zones = (capacity + devip->zsize - 1) >> devip->zsize_shift; - if (sdeb_zbc_nr_conv >= devip->nr_zones) { + if (sdeb_zbc_zone_cap_mb == 0) { + devip->zcap = devip->zsize; + } else { + devip->zcap = (sdeb_zbc_zone_cap_mb * SZ_1M) >> + ilog2(sdebug_sector_size); + if (devip->zcap > devip->zsize) { + pr_err("Zone capacity too large\n"); + return -EINVAL; + } + } + + conv_capacity = (sector_t)sdeb_zbc_nr_conv << devip->zsize_shift; + if (conv_capacity >= capacity) { pr_err("Number of conventional zones too large\n"); return -EINVAL; } devip->nr_conv_zones = sdeb_zbc_nr_conv; + devip->nr_seq_zones = ALIGN(capacity - conv_capacity, devip->zsize) >> + devip->zsize_shift; + devip->nr_zones = devip->nr_conv_zones + devip->nr_seq_zones; + + /* Add gap zones if zone capacity is smaller than the zone size */ + if (devip->zcap < devip->zsize) + devip->nr_zones += devip->nr_seq_zones; if (devip->zmodel == BLK_ZONED_HM) { /* zbc_max_open_zones can be 0, meaning "not reported" */ @@ -5004,20 +5075,26 @@ static int sdebug_device_create_zones(struct sdebug_dev_info *devip) zsp->z_type = ZBC_ZTYPE_CNV; zsp->z_cond = ZBC_NOT_WRITE_POINTER; zsp->z_wp = (sector_t)-1; - } else { + zsp->z_size = + min_t(u64, devip->zsize, capacity - zstart); + } else if ((zstart & (devip->zsize - 1)) == 0) { if (devip->zmodel == BLK_ZONED_HM) zsp->z_type = ZBC_ZTYPE_SWR; else zsp->z_type = ZBC_ZTYPE_SWP; zsp->z_cond = ZC1_EMPTY; zsp->z_wp = zsp->z_start; + zsp->z_size = + min_t(u64, devip->zcap, capacity - zstart); + } else { + zsp->z_type = ZBC_ZTYPE_GAP; + zsp->z_cond = ZBC_NOT_WRITE_POINTER; + zsp->z_wp = (sector_t)-1; + zsp->z_size = min_t(u64, devip->zsize - devip->zcap, + capacity - zstart); } - if (zsp->z_start + devip->zsize < capacity) - zsp->z_size = devip->zsize; - else - zsp->z_size = capacity - zsp->z_start; - + WARN_ON_ONCE((int)zsp->z_size <= 0); zstart += zsp->z_size; } @@ -5779,6 +5856,7 @@ module_param_named(wp, sdebug_wp, bool, S_IRUGO | S_IWUSR); module_param_named(write_same_length, sdebug_write_same_length, int, S_IRUGO | S_IWUSR); module_param_named(zbc, sdeb_zbc_model_s, charp, S_IRUGO); +module_param_named(zone_cap_mb, sdeb_zbc_zone_cap_mb, int, S_IRUGO); module_param_named(zone_max_open, sdeb_zbc_max_open, int, S_IRUGO); module_param_named(zone_nr_conv, sdeb_zbc_nr_conv, int, S_IRUGO); module_param_named(zone_size_mb, sdeb_zbc_zone_size_mb, int, S_IRUGO); @@ -5850,6 +5928,7 @@ MODULE_PARM_DESC(vpd_use_hostno, "0 -> dev ids ignore hostno (def=1 -> unique de MODULE_PARM_DESC(wp, "Write Protect (def=0)"); MODULE_PARM_DESC(write_same_length, "Maximum blocks per WRITE SAME cmd (def=0xffff)"); MODULE_PARM_DESC(zbc, "'none' [0]; 'aware' [1]; 'managed' [2] (def=0). Can have 'host-' prefix"); +MODULE_PARM_DESC(zone_cap_mb, "Zone capacity in MiB (def=zone size)"); MODULE_PARM_DESC(zone_max_open, "Maximum number of open zones; [0] for no limit (def=auto)"); MODULE_PARM_DESC(zone_nr_conv, "Number of conventional zones (def=1)"); MODULE_PARM_DESC(zone_size_mb, "Zone size in MiB (def=auto)"); From 331c6e910f1acfcd854428241789431ebed65677 Mon Sep 17 00:00:00 2001 From: Borislav Petkov Date: Tue, 5 Apr 2022 17:15:07 +0200 Subject: [PATCH 081/177] scsi: aacraid: Fix undefined behavior due to shift overflowing the constant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix: drivers/scsi/aacraid/commsup.c: In function ‘aac_handle_sa_aif’: drivers/scsi/aacraid/commsup.c:1983:2: error: case label does not reduce to an integer constant case SA_AIF_BPCFG_CHANGE: ^~~~ See https://lore.kernel.org/r/YkwQ6%2BtIH8GQpuct@zn.tnic for the gory details as to why it triggers with older gccs only. Link: https://lore.kernel.org/r/20220405151517.29753-2-bp@alien8.de Cc: Adaptec OEM Raid Solutions Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: linux-scsi@vger.kernel.org Reviewed-by: Randy Dunlap Signed-off-by: Borislav Petkov Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aacraid.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index f849e7c9d428..5e115e8b2ba4 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -121,7 +121,7 @@ enum { #define SA_AIF_PDEV_CHANGE (1<<4) #define SA_AIF_LDEV_CHANGE (1<<5) #define SA_AIF_BPSTAT_CHANGE (1<<30) -#define SA_AIF_BPCFG_CHANGE (1<<31) +#define SA_AIF_BPCFG_CHANGE (1U<<31) #define HBA_MAX_SG_EMBEDDED 28 #define HBA_MAX_SG_SEPARATE 90 From 93de8df20537697cc2e74ac42b61e94b5ef5a1eb Mon Sep 17 00:00:00 2001 From: Haowen Bai Date: Mon, 14 Mar 2022 15:58:31 +0800 Subject: [PATCH 082/177] scsi: mac53c94: Fix warning comparing pointer to 0 Fix the following coccicheck warning: drivers/scsi/mac53c94.c:237:12-13: WARNING comparing pointer to 0 Link: https://lore.kernel.org/r/1647244711-31575-1-git-send-email-baihaowen@meizu.com Signed-off-by: Haowen Bai Signed-off-by: Martin K. Petersen --- drivers/scsi/mac53c94.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/mac53c94.c b/drivers/scsi/mac53c94.c index 070ebe352f9e..f75928f7773e 100644 --- a/drivers/scsi/mac53c94.c +++ b/drivers/scsi/mac53c94.c @@ -234,7 +234,7 @@ static void mac53c94_interrupt(int irq, void *dev_id) ++mac53c94_errors; writeb(CMD_NOP + CMD_DMA_MODE, ®s->command); } - if (cmd == 0) { + if (!cmd) { printk(KERN_DEBUG "53c94: interrupt with no command active?\n"); return; } From 1dcd96c4d0b726df1155066126e029cb17a6dd3d Mon Sep 17 00:00:00 2001 From: Haowen Bai Date: Tue, 15 Mar 2022 09:53:39 +0800 Subject: [PATCH 083/177] scsi: fnic: Remove redundant NULL check Fix the following warning reported by coccicheck: drivers/scsi/fnic/fnic_debugfs.c:90:2-7: WARNING: NULL check before some freeing functions is not needed. Link: https://lore.kernel.org/r/1647309219-12772-1-git-send-email-baihaowen@meizu.com Signed-off-by: Haowen Bai Signed-off-by: Martin K. Petersen --- drivers/scsi/fnic/fnic_debugfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/fnic/fnic_debugfs.c b/drivers/scsi/fnic/fnic_debugfs.c index e7326505cabb..866b4c983ace 100644 --- a/drivers/scsi/fnic/fnic_debugfs.c +++ b/drivers/scsi/fnic/fnic_debugfs.c @@ -86,8 +86,7 @@ void fnic_debugfs_terminate(void) debugfs_remove(fnic_trace_debugfs_root); fnic_trace_debugfs_root = NULL; - if (fc_trc_flag) - vfree(fc_trc_flag); + vfree(fc_trc_flag); } /* From 8e897c84661e67e30c0c57dd4d25e18869958951 Mon Sep 17 00:00:00 2001 From: Haowen Bai Date: Tue, 15 Mar 2022 09:57:14 +0800 Subject: [PATCH 084/177] scsi: bfa: Remove redundant NULL check Fix the following warning reported by coccicheck: drivers/scsi/bfa/bfad_debugfs.c:375:2-7: WARNING: NULL check before some freeing functions is not needed. Link: https://lore.kernel.org/r/1647309434-13936-1-git-send-email-baihaowen@meizu.com Signed-off-by: Haowen Bai Signed-off-by: Martin K. Petersen --- drivers/scsi/bfa/bfad_debugfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/bfa/bfad_debugfs.c b/drivers/scsi/bfa/bfad_debugfs.c index fd1b378a263a..52db147d9979 100644 --- a/drivers/scsi/bfa/bfad_debugfs.c +++ b/drivers/scsi/bfa/bfad_debugfs.c @@ -371,8 +371,7 @@ bfad_debugfs_release_fwtrc(struct inode *inode, struct file *file) if (!fw_debug) return 0; - if (fw_debug->debug_buffer) - vfree(fw_debug->debug_buffer); + vfree(fw_debug->debug_buffer); file->private_data = NULL; kfree(fw_debug); From 8c36b054df01e15d285a7414a7bafff7a2ed9eb0 Mon Sep 17 00:00:00 2001 From: Haowen Bai Date: Tue, 15 Mar 2022 10:04:25 +0800 Subject: [PATCH 085/177] scsi: aha1542: Remove unneeded semicolon Fixes coccicheck warning: drivers/scsi/aha1542.c:553:2-3: Unneeded semicolon drivers/scsi/aha1542.c:582:2-3: Unneeded semicolon drivers/scsi/aha1542.c:605:2-3: Unneeded semicolon drivers/scsi/aha1542.c:306:2-3: Unneeded semicolon drivers/scsi/aha1542.c:348:3-4: Unneeded semicolon drivers/scsi/aha1542.c:412:2-3: Unneeded semicolon drivers/scsi/aha1542.c:640:2-3: Unneeded semicolon drivers/scsi/aha1542.c:658:2-3: Unneeded semicolon drivers/scsi/aha1542.c:677:2-3: Unneeded semicolon drivers/scsi/aha1542.c:538:2-3: Unneeded semicolon Link: https://lore.kernel.org/r/1647309865-15620-1-git-send-email-baihaowen@meizu.com Signed-off-by: Haowen Bai Signed-off-by: Martin K. Petersen --- drivers/scsi/aha1542.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index cf7bba2ca68d..552ca95157da 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -302,7 +302,7 @@ static irqreturn_t aha1542_interrupt(int irq, void *dev_id) if (flag & SCRD) printk("SCRD "); printk("status %02x\n", inb(STATUS(sh->io_port))); - }; + } #endif number_serviced = 0; @@ -344,7 +344,7 @@ static irqreturn_t aha1542_interrupt(int irq, void *dev_id) if (!number_serviced) shost_printk(KERN_WARNING, sh, "interrupt received, but no mail.\n"); return IRQ_HANDLED; - }; + } mbo = (scsi2int(mb[mbi].ccbptr) - (unsigned long)aha1542->ccb_handle) / sizeof(struct ccb); mbistatus = mb[mbi].status; @@ -408,7 +408,7 @@ static irqreturn_t aha1542_interrupt(int irq, void *dev_id) */ scsi_done(tmp_cmd); number_serviced++; - }; + } } static int aha1542_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *cmd) @@ -534,7 +534,7 @@ static void setup_mailboxes(struct Scsi_Host *sh) any2scsi(aha1542->mb[i].ccbptr, aha1542->ccb_handle + i * sizeof(struct ccb)); aha1542->mb[AHA1542_MAILBOXES + i].status = 0; - }; + } aha1542_intr_reset(sh->io_port); /* reset interrupts, so they don't block */ any2scsi(mb_cmd + 2, aha1542->mb_handle); if (aha1542_out(sh->io_port, mb_cmd, 5)) @@ -549,7 +549,7 @@ static int aha1542_getconfig(struct Scsi_Host *sh) i = inb(STATUS(sh->io_port)); if (i & DF) { i = inb(DATA(sh->io_port)); - }; + } aha1542_outb(sh->io_port, CMD_RETCONF); aha1542_in(sh->io_port, inquiry_result, 3, 0); if (!wait_mask(INTRFLAGS(sh->io_port), INTRMASK, HACC, 0, 0)) @@ -578,7 +578,7 @@ static int aha1542_getconfig(struct Scsi_Host *sh) default: shost_printk(KERN_ERR, sh, "Unable to determine DMA channel.\n"); return -1; - }; + } switch (inquiry_result[1]) { case 0x40: sh->irq = 15; @@ -601,7 +601,7 @@ static int aha1542_getconfig(struct Scsi_Host *sh) default: shost_printk(KERN_ERR, sh, "Unable to determine IRQ level.\n"); return -1; - }; + } sh->this_id = inquiry_result[2] & 7; return 0; } @@ -636,7 +636,7 @@ static int aha1542_mbenable(struct Scsi_Host *sh) if (aha1542_out(sh->io_port, mbenable_cmd, 3)) goto fail; - }; + } while (0) { fail: shost_printk(KERN_ERR, sh, "Mailbox init failed\n"); @@ -654,7 +654,7 @@ static int aha1542_query(struct Scsi_Host *sh) i = inb(STATUS(sh->io_port)); if (i & DF) { i = inb(DATA(sh->io_port)); - }; + } aha1542_outb(sh->io_port, CMD_INQUIRY); aha1542_in(sh->io_port, inquiry_result, 4, 0); if (!wait_mask(INTRFLAGS(sh->io_port), INTRMASK, HACC, 0, 0)) @@ -673,7 +673,7 @@ static int aha1542_query(struct Scsi_Host *sh) if (inquiry_result[0] == 0x43) { shost_printk(KERN_INFO, sh, "Emulation mode not supported for AHA-1740 hardware, use aha1740 driver instead.\n"); return 1; - }; + } /* * Always call this - boards that do not support extended bios translation From ce781c3f05cd93515e31091def848c134f5bb2f2 Mon Sep 17 00:00:00 2001 From: Alexander Vorwerk Date: Thu, 17 Mar 2022 04:03:25 +0100 Subject: [PATCH 086/177] scsi: message: fusion: Remove unused variable retval MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The following warning showed up when compiling with W=1. drivers/message/fusion/mptctl.c: In function ‘mptctl_hp_hostinfo’: drivers/message/fusion/mptctl.c:2337:8: warning: variable ‘retval’ set but not used [-Wunused-but-set-variable] int retval; Fixing by removing the variable. Link: https://lore.kernel.org/r/20220317030325.30526-1-alexander.vorwerk@stud.uni-goettingen.de Signed-off-by: Alexander Vorwerk Signed-off-by: Martin K. Petersen --- drivers/message/fusion/mptctl.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c index 03c8fb1795c2..f9ee957072c3 100644 --- a/drivers/message/fusion/mptctl.c +++ b/drivers/message/fusion/mptctl.c @@ -2334,7 +2334,6 @@ mptctl_hp_hostinfo(MPT_ADAPTER *ioc, unsigned long arg, unsigned int data_size) ToolboxIstwiReadWriteRequest_t *IstwiRWRequest; MPT_FRAME_HDR *mf = NULL; unsigned long timeleft; - int retval; u32 msgcontext; /* Reset long to int. Should affect IA64 and SPARC only @@ -2488,7 +2487,6 @@ mptctl_hp_hostinfo(MPT_ADAPTER *ioc, unsigned long arg, unsigned int data_size) ioc->add_sge((char *)&IstwiRWRequest->SGL, (MPT_SGE_FLAGS_SSIMPLE_READ|4), buf_dma); - retval = 0; SET_MGMT_MSG_CONTEXT(ioc->ioctl_cmds.msg_context, IstwiRWRequest->MsgContext); INITIALIZE_MGMT_STATUS(ioc->ioctl_cmds.status) @@ -2498,7 +2496,6 @@ retry_wait: timeleft = wait_for_completion_timeout(&ioc->ioctl_cmds.done, HZ*MPT_IOCTL_DEFAULT_TIMEOUT); if (!(ioc->ioctl_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) { - retval = -ETIME; printk(MYIOC_s_WARN_FMT "%s: failed\n", ioc->name, __func__); if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET) { mpt_free_msg_frame(ioc, mf); From 507bd398a056c08d5618450db86bad69b02dde6b Mon Sep 17 00:00:00 2001 From: Wan Jiabing Date: Fri, 18 Mar 2022 22:52:20 +0800 Subject: [PATCH 087/177] scsi: elx: efct: Remove unnecessary memset() in efct_io() io->sgl is allocated by kzalloc(). The memory is set to zero. It is unnecessary to call memset again. Link: https://lore.kernel.org/r/20220318145230.1031-1-wanjiabing@vivo.com Signed-off-by: Wan Jiabing Signed-off-by: Martin K. Petersen --- drivers/scsi/elx/efct/efct_io.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/elx/efct/efct_io.c b/drivers/scsi/elx/efct/efct_io.c index c3247b951a76..c612f0a48839 100644 --- a/drivers/scsi/elx/efct/efct_io.c +++ b/drivers/scsi/elx/efct/efct_io.c @@ -62,7 +62,6 @@ efct_io_pool_create(struct efct *efct, u32 num_sgl) return NULL; } - memset(io->sgl, 0, sizeof(*io->sgl) * num_sgl); io->sgl_allocated = num_sgl; io->sgl_count = 0; From 391b8dac55770686d33f65ab5e87cfbc5bb3942d Mon Sep 17 00:00:00 2001 From: Haowen Bai Date: Mon, 28 Mar 2022 10:05:03 +0800 Subject: [PATCH 088/177] scsi: ipr: Directly return instead of using local ret variable Fixes coccinelle warning: ./drivers/scsi/ipr.c:10095:13-15: Unneeded variable: "rc". Return "IRQ_HANDLED" on line 10104 Link: https://lore.kernel.org/r/1648433103-24308-1-git-send-email-baihaowen@meizu.com Signed-off-by: Haowen Bai Signed-off-by: Martin K. Petersen --- drivers/scsi/ipr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index 104bee9b3a9d..353cf47db79c 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c @@ -10092,7 +10092,6 @@ static irqreturn_t ipr_test_intr(int irq, void *devp) { struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)devp; unsigned long lock_flags = 0; - irqreturn_t rc = IRQ_HANDLED; dev_info(&ioa_cfg->pdev->dev, "Received IRQ : %d\n", irq); spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); @@ -10101,7 +10100,7 @@ static irqreturn_t ipr_test_intr(int irq, void *devp) wake_up(&ioa_cfg->msi_wait_q); spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); - return rc; + return IRQ_HANDLED; } /** From bda57fede0a6211f9c3423e8b972caffbe623ee0 Mon Sep 17 00:00:00 2001 From: Haowen Bai Date: Thu, 21 Apr 2022 17:24:50 +0800 Subject: [PATCH 089/177] scsi: qla4xxx: Drop redundant memset() The region set by the call to memset() is immediately overwritten by the subsequent call to memcpy(). Drop redundant memset(). Link: https://lore.kernel.org/r/1650533091-28815-1-git-send-email-baihaowen@meizu.com Signed-off-by: Haowen Bai Signed-off-by: Martin K. Petersen --- drivers/scsi/qla4xxx/ql4_os.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index 3f6cb2a5c2c2..9e849f6b0d0f 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c @@ -671,7 +671,6 @@ static void qla4xxx_create_chap_list(struct scsi_qla_host *ha) goto exit_chap_list; } - memset(ha->chap_list, 0, chap_size); memcpy(ha->chap_list, chap_flash_data, chap_size); exit_chap_list: From 21faafff6abbbe79fe56e3c7049514df08a9e66e Mon Sep 17 00:00:00 2001 From: Haowen Bai Date: Thu, 21 Apr 2022 18:24:53 +0800 Subject: [PATCH 090/177] scsi: qedf: Remove unnecessary code Buffer 'msg' is memset() but never actually used. Drop it. Link: https://lore.kernel.org/r/1650536693-13089-1-git-send-email-baihaowen@meizu.com Signed-off-by: Haowen Bai Signed-off-by: Martin K. Petersen --- drivers/scsi/qedf/qedf_attr.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/scsi/qedf/qedf_attr.c b/drivers/scsi/qedf/qedf_attr.c index fdc66d294813..8d8c760eee43 100644 --- a/drivers/scsi/qedf/qedf_attr.c +++ b/drivers/scsi/qedf/qedf_attr.c @@ -131,7 +131,6 @@ qedf_sysfs_write_grcdump(struct file *filep, struct kobject *kobj, struct qedf_ctx *qedf = NULL; long reading; int ret = 0; - char msg[40]; if (off != 0) return ret; @@ -148,7 +147,6 @@ qedf_sysfs_write_grcdump(struct file *filep, struct kobject *kobj, return ret; } - memset(msg, 0, sizeof(msg)); switch (reading) { case 0: memset(qedf->grcdump, 0, qedf->grcdump_size); From 4c0df601e150c1e48566e7e4e183ba40c9f81157 Mon Sep 17 00:00:00 2001 From: ran jianping Date: Sun, 24 Apr 2022 06:18:45 +0000 Subject: [PATCH 091/177] scsi: bfa: Remove unneeded flush_workqueue() All work currently pending will be done first by calling destroy_workqueue(). There is no need to flush it explicitly. Link: https://lore.kernel.org/r/20220424061845.3218774-1-ran.jianping@zte.com.cn Reported-by: Zeal Robot Signed-off-by: ran jianping Signed-off-by: Martin K. Petersen --- drivers/scsi/bfa/bfad_im.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c index 8419a1a89485..c335f7a188d2 100644 --- a/drivers/scsi/bfa/bfad_im.c +++ b/drivers/scsi/bfa/bfad_im.c @@ -755,7 +755,6 @@ void bfad_destroy_workq(struct bfad_im_s *im) { if (im && im->drv_workq) { - flush_workqueue(im->drv_workq); destroy_workqueue(im->drv_workq); im->drv_workq = NULL; } From cf97628fe1a1f25f3a5617fa10619d7bef904da1 Mon Sep 17 00:00:00 2001 From: ran jianping Date: Sun, 24 Apr 2022 06:24:13 +0000 Subject: [PATCH 092/177] scsi: qla2xxx: Remove unneeded flush_workqueue() All work currently pending will be done first by calling destroy_workqueue(). There is no need to flush it explicitly. Link: https://lore.kernel.org/r/20220424062413.3220315-1-ran.jianping@zte.com.cn Reported-by: Zeal Robot Signed-off-by: ran jianping Signed-off-by: Martin K. Petersen --- drivers/scsi/qla2xxx/qla_os.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 762229d495a8..73073fb08369 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -3933,7 +3933,6 @@ qla2x00_free_device(scsi_qla_host_t *vha) /* Flush the work queue and remove it */ if (ha->wq) { - flush_workqueue(ha->wq); destroy_workqueue(ha->wq); ha->wq = NULL; } From 671a52f2aeafe2f42bddb53dcfe3933b1f641843 Mon Sep 17 00:00:00 2001 From: ran jianping Date: Sun, 24 Apr 2022 06:54:06 +0000 Subject: [PATCH 093/177] scsi: fnic: Remove unneeded flush_workqueue() All work currently pending will be done first by calling destroy_workqueue(). There is no need to flush it explicitly. Link: https://lore.kernel.org/r/20220424065406.3228528-1-ran.jianping@zte.com.cn Reported-by: Zeal Robot Signed-off-by: ran jianping Signed-off-by: Martin K. Petersen --- drivers/scsi/fnic/fnic_main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c index 9161bd2fd421..460e03a55096 100644 --- a/drivers/scsi/fnic/fnic_main.c +++ b/drivers/scsi/fnic/fnic_main.c @@ -1146,10 +1146,8 @@ static void __exit fnic_cleanup_module(void) { pci_unregister_driver(&fnic_driver); destroy_workqueue(fnic_event_queue); - if (fnic_fip_queue) { - flush_workqueue(fnic_fip_queue); + if (fnic_fip_queue) destroy_workqueue(fnic_fip_queue); - } kmem_cache_destroy(fnic_sgl_cache[FNIC_SGL_CACHE_MAX]); kmem_cache_destroy(fnic_sgl_cache[FNIC_SGL_CACHE_DFLT]); kmem_cache_destroy(fnic_io_req_cache); From a346f28ad231cb6746109219a1a371d7de11d67c Mon Sep 17 00:00:00 2001 From: Changcheng Deng Date: Tue, 19 Apr 2022 06:57:50 +0000 Subject: [PATCH 094/177] scsi: lpfc: Remove unneeded variable Remove unneeded variable 'rc' used to store return value. Link: https://lore.kernel.org/r/20220419065750.2573861-1-deng.changcheng@zte.com.cn Reported-by: Zeal Robot Signed-off-by: Changcheng Deng Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_sli.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index 8bf62697317a..1b613f630ed5 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -3707,7 +3707,6 @@ lpfc_sli_process_sol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, struct lpfc_iocbq *saveq) { struct lpfc_iocbq *cmdiocbp; - int rc = 1; unsigned long iflag; u32 ulp_command, ulp_status, ulp_word4, ulp_context, iotag; @@ -3847,7 +3846,7 @@ lpfc_sli_process_sol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, } } - return rc; + return 1; } /** From 973dac8a8a14a7fcfd4fa0b682851f415eb91b04 Mon Sep 17 00:00:00 2001 From: John Garry Date: Wed, 30 Mar 2022 19:38:35 +0800 Subject: [PATCH 095/177] scsi: core: Refine how we set tag_set NUMA node For SCSI hosts which enable host_tagset the NUMA node returned from blk_mq_hw_queue_to_node() is NUMA_NO_NODE always. Then, since in scsi_mq_setup_tags() the default we choose for the tag_set NUMA node is NUMA_NO_NODE, we always evaluate the NUMA node as NUMA_NO_NODE in functions like blk_mq_alloc_rq_map(). The reason we get NUMA_NO_NODE from blk_mq_hw_queue_to_node() is that the hctx_idx passed is BLK_MQ_NO_HCTX_IDX - so we can't match against a (HW) queue mapping index. Improve this by defaulting the tag_set NUMA node to the same NUMA node of the SCSI host DMA dev. Link: https://lore.kernel.org/r/1648640315-21419-1-git-send-email-john.garry@huawei.com Signed-off-by: John Garry Signed-off-by: Martin K. Petersen --- drivers/scsi/hosts.c | 8 ++++---- drivers/scsi/scsi_lib.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index f69b77cbf538..8352f90d997d 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -229,10 +229,6 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev, if (error) goto fail; - error = scsi_mq_setup_tags(shost); - if (error) - goto fail; - if (!shost->shost_gendev.parent) shost->shost_gendev.parent = dev ? dev : &platform_bus; if (!dma_dev) @@ -240,6 +236,10 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev, shost->dma_dev = dma_dev; + error = scsi_mq_setup_tags(shost); + if (error) + goto fail; + /* * Increase usage count temporarily here so that calling * scsi_autopm_put_host() will trigger runtime idle if there is diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 8d18cc7e510e..e9db7da0c79c 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1977,7 +1977,7 @@ int scsi_mq_setup_tags(struct Scsi_Host *shost) tag_set->nr_maps = shost->nr_maps ? : 1; tag_set->queue_depth = shost->can_queue; tag_set->cmd_size = cmd_size; - tag_set->numa_node = NUMA_NO_NODE; + tag_set->numa_node = dev_to_node(shost->dma_dev); tag_set->flags = BLK_MQ_F_SHOULD_MERGE; tag_set->flags |= BLK_ALLOC_POLICY_TO_MQ_FLAG(shost->hostt->tag_alloc_policy); From ef60031022eb6d972aac86ca26c98c33e1289436 Mon Sep 17 00:00:00 2001 From: Kiwoong Kim Date: Thu, 31 Mar 2022 10:24:05 +0900 Subject: [PATCH 096/177] scsi: ufs: core: Exclude UECxx from SFR dump list Some devices may return invalid or zeroed data during an UIC error condition. In addition, reading these SFRs will clear them. This means the subsequent error handling will not be able to see them and therefore no error handling will be scheduled. Skip reading these SFRs in ufshcd_dump_regs(). Link: https://lore.kernel.org/r/1648689845-33521-1-git-send-email-kwmad.kim@samsung.com Fixes: d67247566450 ("scsi: ufs: Use explicit access size in ufshcd_dump_regs") Signed-off-by: Kiwoong Kim Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufshcd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 1b87f26b5193..f4a3326a4803 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -122,8 +122,13 @@ int ufshcd_dump_regs(struct ufs_hba *hba, size_t offset, size_t len, if (!regs) return -ENOMEM; - for (pos = 0; pos < len; pos += 4) + for (pos = 0; pos < len; pos += 4) { + if (offset == 0 && + pos >= REG_UIC_ERROR_CODE_PHY_ADAPTER_LAYER && + pos <= REG_UIC_ERROR_CODE_DME) + continue; regs[pos / 4] = ufshcd_readl(hba, offset + pos); + } ufshcd_hex_dump(prefix, regs, len); kfree(regs); From 8ad8edd2fbaedbd4761c14319df26db2b556376e Mon Sep 17 00:00:00 2001 From: Wan Jiabing Date: Tue, 26 Apr 2022 18:45:07 +0800 Subject: [PATCH 097/177] scsi: ufs: core: Remove duplicate include in ufshcd Fix following checkincludes warning: drivers/scsi/ufs/ufshcd.c: linux/nls.h is included more than once. The include is in line 14. Remove the duplicate. Link: https://lore.kernel.org/r/20220426104509.621394-1-wanjiabing@vivo.com Reviewed-by: Avri Altman Signed-off-by: Wan Jiabing Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufshcd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index f4a3326a4803..2b4390a1106e 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include From 505420bd5543e806288a47ae3d2abeec8fc9642a Mon Sep 17 00:00:00 2001 From: Xiaomeng Tong Date: Tue, 5 Apr 2022 08:40:55 +0800 Subject: [PATCH 098/177] scsi: qedf: Remove an unneeded NULL check on list iterator The list iterator 'fcport' is always non-NULL so it doesn't need to be checked. Thus just remove the unnecessary NULL check. Also remove the unnecessary initializer because the list iterator is always initialized. And adjust the position of blank lines. Link: https://lore.kernel.org/r/20220405004055.24312-1-xiam0nd.tong@gmail.com Signed-off-by: Xiaomeng Tong Signed-off-by: Martin K. Petersen --- drivers/scsi/qedf/qedf_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index 18dc68d577b6..cbe01915da8c 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -873,7 +873,7 @@ static int qedf_eh_device_reset(struct scsi_cmnd *sc_cmd) bool qedf_wait_for_upload(struct qedf_ctx *qedf) { - struct qedf_rport *fcport = NULL; + struct qedf_rport *fcport; int wait_cnt = 120; while (wait_cnt--) { @@ -888,7 +888,7 @@ bool qedf_wait_for_upload(struct qedf_ctx *qedf) rcu_read_lock(); list_for_each_entry_rcu(fcport, &qedf->fcports, peers) { - if (fcport && test_bit(QEDF_RPORT_SESSION_READY, + if (test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags)) { if (fcport->rdata) QEDF_ERR(&qedf->dbg_ctx, @@ -899,9 +899,9 @@ bool qedf_wait_for_upload(struct qedf_ctx *qedf) "Waiting for fcport %p.\n", fcport); } } + rcu_read_unlock(); return false; - } /* Performs soft reset of qedf_ctx by simulating a link down/up */ From 036a45aa587a10fa2abbd50fbd0f6c4cfc44f69f Mon Sep 17 00:00:00 2001 From: Xiaomeng Tong Date: Thu, 14 Apr 2022 12:02:31 +0800 Subject: [PATCH 099/177] scsi: dc395x: Fix a missing check on list iterator The bug is here: p->target_id, p->target_lun); The list iterator 'p' will point to a bogus position containing HEAD if the list is empty or no element is found. This case must be checked before any use of the iterator, otherwise it will lead to an invalid memory access. To fix this bug, add a check. Use a new variable 'iter' as the list iterator, and use the original variable 'p' as a dedicated pointer to point to the found element. Link: https://lore.kernel.org/r/20220414040231.2662-1-xiam0nd.tong@gmail.com Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Signed-off-by: Xiaomeng Tong Signed-off-by: Martin K. Petersen --- drivers/scsi/dc395x.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c index 67a89715c863..670a836a6ba1 100644 --- a/drivers/scsi/dc395x.c +++ b/drivers/scsi/dc395x.c @@ -3585,10 +3585,19 @@ static struct DeviceCtlBlk *device_alloc(struct AdapterCtlBlk *acb, #endif if (dcb->target_lun != 0) { /* Copy settings */ - struct DeviceCtlBlk *p; - list_for_each_entry(p, &acb->dcb_list, list) - if (p->target_id == dcb->target_id) + struct DeviceCtlBlk *p = NULL, *iter; + + list_for_each_entry(iter, &acb->dcb_list, list) + if (iter->target_id == dcb->target_id) { + p = iter; break; + } + + if (!p) { + kfree(dcb); + return NULL; + } + dprintkdbg(DBG_1, "device_alloc: <%02i-%i> copy from <%02i-%i>\n", dcb->target_id, dcb->target_lun, From 1497e95e22c3be382217da290106ab4f865dc1fa Mon Sep 17 00:00:00 2001 From: Guo Zhengkui Date: Tue, 26 Apr 2022 15:43:34 +0800 Subject: [PATCH 100/177] scsi: qla2xxx: edif: Remove unneeded variable Fix the following coccicheck warning: drivers/scsi/qla2xxx/qla_edif.c:660:11-15: Unneeded variable: "rval". Return "0" on line 761. Link: https://lore.kernel.org/r/20220426074334.9281-1-guozhengkui@vivo.com Signed-off-by: Guo Zhengkui Signed-off-by: Martin K. Petersen --- drivers/scsi/qla2xxx/qla_edif.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_edif.c b/drivers/scsi/qla2xxx/qla_edif.c index 0628633c7c7e..cb8145a9ac09 100644 --- a/drivers/scsi/qla2xxx/qla_edif.c +++ b/drivers/scsi/qla2xxx/qla_edif.c @@ -657,7 +657,6 @@ qla_edif_app_chk_sa_update(scsi_qla_host_t *vha, fc_port_t *fcport, static int qla_edif_app_authok(scsi_qla_host_t *vha, struct bsg_job *bsg_job) { - int32_t rval = 0; struct auth_complete_cmd appplogiok; struct app_plogi_reply appplogireply = {0}; struct fc_bsg_reply *bsg_reply = bsg_job->reply; @@ -758,7 +757,7 @@ errstate_exit: &appplogireply, sizeof(struct app_plogi_reply)); - return rval; + return 0; } /** From c5acd61dbb32b6bda0f3a354108f2b8dcb788985 Mon Sep 17 00:00:00 2001 From: Lv Ruyi Date: Mon, 18 Apr 2022 10:57:55 +0000 Subject: [PATCH 101/177] scsi: megaraid: Fix error check return value of register_chrdev() If major equals 0, register_chrdev() returns an error code when it fails. This function dynamically allocates a major and returns its number on success, so we should use "< 0" to check it instead of "!". Link: https://lore.kernel.org/r/20220418105755.2558828-1-lv.ruyi@zte.com.cn Reported-by: Zeal Robot Signed-off-by: Lv Ruyi Signed-off-by: Martin K. Petersen --- drivers/scsi/megaraid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index a5d8cee2d510..bf491af9f0d6 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c @@ -4607,7 +4607,7 @@ static int __init megaraid_init(void) * major number allocation. */ major = register_chrdev(0, "megadev_legacy", &megadev_fops); - if (!major) { + if (major < 0) { printk(KERN_WARNING "megaraid: failed to register char device\n"); } From 75b8715e20a20bc7b4844835e4035543a2674200 Mon Sep 17 00:00:00 2001 From: Minghao Chi Date: Wed, 20 Apr 2022 09:03:52 +0000 Subject: [PATCH 102/177] scsi: ufs: Use pm_runtime_resume_and_get() instead of pm_runtime_get_sync() Using pm_runtime_resume_and_get() to replace pm_runtime_get_sync() and pm_runtime_put_noidle(). This change is just to simplify the code, no actual functional changes. Link: https://lore.kernel.org/r/20220420090353.2588804-1-chi.minghao@zte.com.cn Reported-by: Zeal Robot Signed-off-by: Minghao Chi Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ti-j721e-ufs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/ufs/ti-j721e-ufs.c b/drivers/scsi/ufs/ti-j721e-ufs.c index eafe0db98d54..122d650d0810 100644 --- a/drivers/scsi/ufs/ti-j721e-ufs.c +++ b/drivers/scsi/ufs/ti-j721e-ufs.c @@ -29,11 +29,9 @@ static int ti_j721e_ufs_probe(struct platform_device *pdev) return PTR_ERR(regbase); pm_runtime_enable(dev); - ret = pm_runtime_get_sync(dev); - if (ret < 0) { - pm_runtime_put_noidle(dev); + ret = pm_runtime_resume_and_get(dev); + if (ret < 0) goto disable_pm; - } /* Select MPHY refclk frequency */ clk = devm_clk_get(dev, NULL); From 3d1d34ec1fbcab2d77e3733ff385a074fdf2d60c Mon Sep 17 00:00:00 2001 From: James Smart Date: Tue, 26 Apr 2022 11:13:15 -0700 Subject: [PATCH 103/177] scsi: lpfc: Remove unnecessary null ndlp check in lpfc_sli_prep_wqe() Smatch had the following warning: drivers/scsi/lpfc/lpfc_sli.c:22305 lpfc_sli_prep_wqe() error: we previously assumed 'ndlp' could be null (see line 22298) Remove the unnecessary null check. Link: https://lore.kernel.org/r/20220426181315.8990-1-jsmart2021@gmail.com Fixes: d51cf5bd926c ("scsi: lpfc: Fix field overload in lpfc_iocbq data structure") Reported-by: kernel test robot Reported-by: Dan Carpenter Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_sli.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index 1b613f630ed5..b02c9ae39cde 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -22283,7 +22283,7 @@ lpfc_sli_prep_wqe(struct lpfc_hba *phba, struct lpfc_iocbq *job) bf_set(wqe_ct, &wqe->els_req.wqe_com, 1); bf_set(wqe_ctxt_tag, &wqe->els_req.wqe_com, phba->vpi_ids[job->vport->vpi]); - } else if (pcmd && ndlp) { + } else if (pcmd) { bf_set(wqe_ct, &wqe->els_req.wqe_com, 0); bf_set(wqe_ctxt_tag, &wqe->els_req.wqe_com, phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]); From 646db1a560f44236b7278b822ca99a1d3b6ea72c Mon Sep 17 00:00:00 2001 From: James Smart Date: Tue, 26 Apr 2022 11:14:19 -0700 Subject: [PATCH 104/177] scsi: lpfc: Fix resource leak in lpfc_sli4_send_seq_to_ulp() If no handler is found in lpfc_complete_unsol_iocb() to match the rctl of a received frame, the frame is dropped and resources are leaked. Fix by returning resources when discarding an unhandled frame type. Update lpfc_fc_frame_check() handling of NOP basic link service. Link: https://lore.kernel.org/r/20220426181419.9154-1-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_sli.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index b02c9ae39cde..e8c31c080ef3 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -18122,7 +18122,6 @@ lpfc_fc_frame_check(struct lpfc_hba *phba, struct fc_frame_header *fc_hdr) case FC_RCTL_ELS_REP: /* extended link services reply */ case FC_RCTL_ELS4_REQ: /* FC-4 ELS request */ case FC_RCTL_ELS4_REP: /* FC-4 ELS reply */ - case FC_RCTL_BA_NOP: /* basic link service NOP */ case FC_RCTL_BA_ABTS: /* basic link service abort */ case FC_RCTL_BA_RMC: /* remove connection */ case FC_RCTL_BA_ACC: /* basic accept */ @@ -18143,6 +18142,7 @@ lpfc_fc_frame_check(struct lpfc_hba *phba, struct fc_frame_header *fc_hdr) fc_vft_hdr = (struct fc_vft_header *)fc_hdr; fc_hdr = &((struct fc_frame_header *)fc_vft_hdr)[1]; return lpfc_fc_frame_check(phba, fc_hdr); + case FC_RCTL_BA_NOP: /* basic link service NOP */ default: goto drop; } @@ -18954,12 +18954,14 @@ lpfc_sli4_send_seq_to_ulp(struct lpfc_vport *vport, if (!lpfc_complete_unsol_iocb(phba, phba->sli4_hba.els_wq->pring, iocbq, fc_hdr->fh_r_ctl, - fc_hdr->fh_type)) + fc_hdr->fh_type)) { lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, "2540 Ring %d handler: unexpected Rctl " "x%x Type x%x received\n", LPFC_ELS_RING, fc_hdr->fh_r_ctl, fc_hdr->fh_type); + lpfc_in_buf_free(phba, &seq_dmabuf->dbuf); + } /* Free iocb created in lpfc_prep_seq */ list_for_each_entry_safe(curr_iocb, next_iocb, From dc1178767cba9d67f5100fb370670fd613319362 Mon Sep 17 00:00:00 2001 From: "Martin K. Petersen" Date: Wed, 2 Mar 2022 00:35:46 -0500 Subject: [PATCH 105/177] scsi: mpt3sas: Use cached ATA Information VPD page We now cache VPD page 0x89 (ATA Information) so there is no need to request it from the hardware. Make mpt3sas use the cached page. Link: https://lore.kernel.org/r/20220302053559.32147-2-martin.petersen@oracle.com Cc: Sreekanth Reddy Reviewed-by: Hannes Reinecke Reviewed-by: Johannes Thumshirn Reviewed-by: Christoph Hellwig Signed-off-by: Martin K. Petersen --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 6022875bc4a7..b519f4b59d30 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -12588,20 +12588,18 @@ scsih_pci_mmio_enabled(struct pci_dev *pdev) */ bool scsih_ncq_prio_supp(struct scsi_device *sdev) { - unsigned char *buf; + struct scsi_vpd *vpd; bool ncq_prio_supp = false; - if (!scsi_device_supports_vpd(sdev)) - return ncq_prio_supp; + rcu_read_lock(); + vpd = rcu_dereference(sdev->vpd_pg89); + if (!vpd || vpd->len < 214) + goto out; - buf = kmalloc(SCSI_VPD_PG_LEN, GFP_KERNEL); - if (!buf) - return ncq_prio_supp; + ncq_prio_supp = (vpd->data[213] >> 4) & 1; +out: + rcu_read_unlock(); - if (!scsi_get_vpd_page(sdev, 0x89, buf, SCSI_VPD_PG_LEN)) - ncq_prio_supp = (buf[213] >> 4) & 1; - - kfree(buf); return ncq_prio_supp; } /* From c92a6b5d63359dd6d2ce6ea88ecd8e31dd769f6b Mon Sep 17 00:00:00 2001 From: "Martin K. Petersen" Date: Wed, 2 Mar 2022 00:35:47 -0500 Subject: [PATCH 106/177] scsi: core: Query VPD size before getting full page We currently default to 255 bytes when fetching VPD pages during discovery. However, we have had a few devices that are known to wedge if the requested buffer exceeds a certain size. See commit af73623f5f10 ("[SCSI] sd: Reduce buffer size for vpd request") which works around one example of this problem in the SCSI disk driver. With commit d188b0675b21 ("scsi: core: Add sysfs attributes for VPD pages 0h and 89h") we now risk triggering the same issue in the generic midlayer code. The problem with the ATA VPD page in particular is that the SCSI portion of the page is trailed by 512 bytes of verbatim ATA Identify Device information. However, not all controllers actually provide the additional 512 bytes and will lock up if one asks for more than the 64 bytes containing the SCSI protocol fields. Instead of picking a new, somewhat arbitrary, number of bytes for the VPD buffer size, start fetching the 4-byte header for each page. The header contains the size of the page as far as the device is concerned. We can use the reported size to specify the correct allocation length when subsequently fetching the full page. The header validation is done by a new helper function scsi_get_vpd_size() and both scsi_get_vpd_page() and scsi_get_vpd_buf() now rely on this to query the page size. In addition, scsi_get_vpd_page() is simplified to mirror the logic in scsi_get_vpd_page(). This involves removing the Supported VPD Pages lookup prior to attempting to query a page. There does not appear any evidence, even in the oldest SCSI specs, that this step is required. We already rely on scsi_get_vpd_page() throughout the stack and this function never consulted the Supported VPD Pages. Since this has not caused any problems it should be safe to remove the precondition from scsi_get_vpd_page(). Instrumented runs also revealed that the Supported VPD Pages lookup had little effect since the device page index often was larger than the supplied buffer size. As a result, inquiries frequently bypassed the index check and went through the "If we ran off the end of the buffer, give us the benefit of the doubt" code path which assumed the page was present despite not being listed. The revised code takes both the page size reported by the device as well as the size of the buffer provided by the scsi_get_vpd_page() caller into account. Link: https://lore.kernel.org/r/20220302053559.32147-3-martin.petersen@oracle.com Fixes: d188b0675b21 ("scsi: core: Add sysfs attributes for VPD pages 0h and 89h") Reported-by: Maciej W. Rozycki Tested-by: Maciej W. Rozycki Reviewed-by: Christoph Hellwig Signed-off-by: Martin K. Petersen --- drivers/scsi/scsi.c | 89 +++++++++++++++++++++++++------------- include/scsi/scsi_device.h | 5 ++- 2 files changed, 62 insertions(+), 32 deletions(-) diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 735b6c862b46..a17392880da2 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -321,6 +321,31 @@ static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer, return get_unaligned_be16(&buffer[2]) + 4; } +static int scsi_get_vpd_size(struct scsi_device *sdev, u8 page) +{ + unsigned char vpd_header[SCSI_VPD_HEADER_SIZE] __aligned(4); + int result; + + /* + * Fetch the VPD page header to find out how big the page + * is. This is done to prevent problems on legacy devices + * which can not handle allocation lengths as large as + * potentially requested by the caller. + */ + result = scsi_vpd_inquiry(sdev, vpd_header, page, sizeof(vpd_header)); + if (result < 0) + return 0; + + if (result < SCSI_VPD_HEADER_SIZE) { + dev_warn_once(&sdev->sdev_gendev, + "%s: short VPD page 0x%02x length: %d bytes\n", + __func__, page, result); + return 0; + } + + return result; +} + /** * scsi_get_vpd_page - Get Vital Product Data from a SCSI device * @sdev: The device to ask @@ -330,47 +355,38 @@ static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer, * * SCSI devices may optionally supply Vital Product Data. Each 'page' * of VPD is defined in the appropriate SCSI document (eg SPC, SBC). - * If the device supports this VPD page, this routine returns a pointer - * to a buffer containing the data from that page. The caller is - * responsible for calling kfree() on this pointer when it is no longer - * needed. If we cannot retrieve the VPD page this routine returns %NULL. + * If the device supports this VPD page, this routine fills @buf + * with the data from that page and return 0. If the VPD page is not + * supported or its content cannot be retrieved, -EINVAL is returned. */ int scsi_get_vpd_page(struct scsi_device *sdev, u8 page, unsigned char *buf, int buf_len) { - int i, result; + int result, vpd_len; - if (sdev->skip_vpd_pages) - goto fail; + if (!scsi_device_supports_vpd(sdev)) + return -EINVAL; - /* Ask for all the pages supported by this device */ - result = scsi_vpd_inquiry(sdev, buf, 0, buf_len); - if (result < 4) - goto fail; + vpd_len = scsi_get_vpd_size(sdev, page); + if (vpd_len <= 0) + return -EINVAL; - /* If the user actually wanted this page, we can skip the rest */ - if (page == 0) - return 0; + vpd_len = min(vpd_len, buf_len); - for (i = 4; i < min(result, buf_len); i++) - if (buf[i] == page) - goto found; - - if (i < result && i >= buf_len) - /* ran off the end of the buffer, give us benefit of doubt */ - goto found; - /* The device claims it doesn't support the requested page */ - goto fail; - - found: - result = scsi_vpd_inquiry(sdev, buf, page, buf_len); + /* + * Fetch the actual page. Since the appropriate size was reported + * by the device it is now safe to ask for something bigger. + */ + memset(buf, 0, buf_len); + result = scsi_vpd_inquiry(sdev, buf, page, vpd_len); if (result < 0) - goto fail; + return -EINVAL; + else if (result > vpd_len) + dev_warn_once(&sdev->sdev_gendev, + "%s: VPD page 0x%02x result %d > %d bytes\n", + __func__, page, result, vpd_len); return 0; - - fail: - return -EINVAL; } EXPORT_SYMBOL_GPL(scsi_get_vpd_page); @@ -384,9 +400,17 @@ EXPORT_SYMBOL_GPL(scsi_get_vpd_page); static struct scsi_vpd *scsi_get_vpd_buf(struct scsi_device *sdev, u8 page) { struct scsi_vpd *vpd_buf; - int vpd_len = SCSI_VPD_PG_LEN, result; + int vpd_len, result; + + vpd_len = scsi_get_vpd_size(sdev, page); + if (vpd_len <= 0) + return NULL; retry_pg: + /* + * Fetch the actual page. Since the appropriate size was reported + * by the device it is now safe to ask for something bigger. + */ vpd_buf = kmalloc(sizeof(*vpd_buf) + vpd_len, GFP_KERNEL); if (!vpd_buf) return NULL; @@ -397,6 +421,9 @@ retry_pg: return NULL; } if (result > vpd_len) { + dev_warn_once(&sdev->sdev_gendev, + "%s: VPD page 0x%02x result %d > %d bytes\n", + __func__, page, result, vpd_len); vpd_len = result; kfree(vpd_buf); goto retry_pg; diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 57e3e239a1fc..c37cc5b3ebeb 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -100,6 +100,10 @@ struct scsi_vpd { unsigned char data[]; }; +enum scsi_vpd_parameters { + SCSI_VPD_HEADER_SIZE = 4, +}; + struct scsi_device { struct Scsi_Host *host; struct request_queue *request_queue; @@ -141,7 +145,6 @@ struct scsi_device { const char * model; /* ... after scan; point to static string */ const char * rev; /* ... "nullnullnullnull" before scan */ -#define SCSI_VPD_PG_LEN 255 struct scsi_vpd __rcu *vpd_pg0; struct scsi_vpd __rcu *vpd_pg83; struct scsi_vpd __rcu *vpd_pg80; From e17d63403076affccd72d195f93bbf3f39514005 Mon Sep 17 00:00:00 2001 From: "Martin K. Petersen" Date: Wed, 2 Mar 2022 00:35:49 -0500 Subject: [PATCH 107/177] scsi: core: Pick suitable allocation length in scsi_report_opcode() Some devices hang when a buffer size larger than expected is passed in the ALLOCATION LENGTH field. For REPORT SUPPORTED OPERATION CODES we currently only request a single command descriptor at a time and therefore the actual size of the command is known ahead of time. Limit the ALLOCATION LENGTH to the header size plus the command length of the opcode we are asking about. Link: https://lore.kernel.org/r/20220302053559.32147-5-martin.petersen@oracle.com Reviewed-by: Hannes Reinecke Reviewed-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn Reviewed-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/scsi.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index a17392880da2..3db2a928faec 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -503,21 +503,30 @@ int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer, { unsigned char cmd[16]; struct scsi_sense_hdr sshdr; - int result; + int result, request_len; if (sdev->no_report_opcodes || sdev->scsi_level < SCSI_SPC_3) return -EINVAL; + /* RSOC header + size of command we are asking about */ + request_len = 4 + COMMAND_SIZE(opcode); + if (request_len > len) { + dev_warn_once(&sdev->sdev_gendev, + "%s: len %u bytes, opcode 0x%02x needs %u\n", + __func__, len, opcode, request_len); + return -EINVAL; + } + memset(cmd, 0, 16); cmd[0] = MAINTENANCE_IN; cmd[1] = MI_REPORT_SUPPORTED_OPERATION_CODES; cmd[2] = 1; /* One command format */ cmd[3] = opcode; - put_unaligned_be32(len, &cmd[6]); + put_unaligned_be32(request_len, &cmd[6]); memset(buffer, 0, len); - result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len, - &sshdr, 30 * HZ, 3, NULL); + result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, + request_len, &sshdr, 30 * HZ, 3, NULL); if (result < 0) return result; From e60ac0b9e445822e60230c00e68d8cdb7748701b Mon Sep 17 00:00:00 2001 From: "Martin K. Petersen" Date: Wed, 2 Mar 2022 00:35:50 -0500 Subject: [PATCH 108/177] scsi: core: Cache VPD pages b0, b1, b2 The SCSI disk driver consults VPD pages b0 (Block Limits), b1 (Block Device Characteristics), and b2 (Logical Block Provisioning). Instead of having sd.c request these pages every revalidate cycle, cache them along with the other commonly used VPDs. Link: https://lore.kernel.org/r/20220302053559.32147-6-martin.petersen@oracle.com Reviewed-by: Hannes Reinecke Reviewed-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn Reviewed-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/scsi.c | 6 ++++++ drivers/scsi/scsi_sysfs.c | 28 ++++++++++++++++++++++++++++ include/scsi/scsi_device.h | 4 ++++ 3 files changed, 38 insertions(+) diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 3db2a928faec..c59eac7a32f2 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -483,6 +483,12 @@ void scsi_attach_vpd(struct scsi_device *sdev) scsi_update_vpd_page(sdev, 0x83, &sdev->vpd_pg83); if (vpd_buf->data[i] == 0x89) scsi_update_vpd_page(sdev, 0x89, &sdev->vpd_pg89); + if (vpd_buf->data[i] == 0xb0) + scsi_update_vpd_page(sdev, 0xb0, &sdev->vpd_pgb0); + if (vpd_buf->data[i] == 0xb1) + scsi_update_vpd_page(sdev, 0xb1, &sdev->vpd_pgb1); + if (vpd_buf->data[i] == 0xb2) + scsi_update_vpd_page(sdev, 0xb2, &sdev->vpd_pgb2); } kfree(vpd_buf); } diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index dc6872e352bd..546a9e3cfbec 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -448,6 +448,7 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work) struct list_head *this, *tmp; struct scsi_vpd *vpd_pg80 = NULL, *vpd_pg83 = NULL; struct scsi_vpd *vpd_pg0 = NULL, *vpd_pg89 = NULL; + struct scsi_vpd *vpd_pgb0 = NULL, *vpd_pgb1 = NULL, *vpd_pgb2 = NULL; unsigned long flags; struct module *mod; @@ -490,6 +491,12 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work) lockdep_is_held(&sdev->inquiry_mutex)); vpd_pg89 = rcu_replace_pointer(sdev->vpd_pg89, vpd_pg89, lockdep_is_held(&sdev->inquiry_mutex)); + vpd_pgb0 = rcu_replace_pointer(sdev->vpd_pgb0, vpd_pgb0, + lockdep_is_held(&sdev->inquiry_mutex)); + vpd_pgb1 = rcu_replace_pointer(sdev->vpd_pgb1, vpd_pgb1, + lockdep_is_held(&sdev->inquiry_mutex)); + vpd_pgb2 = rcu_replace_pointer(sdev->vpd_pgb2, vpd_pgb2, + lockdep_is_held(&sdev->inquiry_mutex)); mutex_unlock(&sdev->inquiry_mutex); if (vpd_pg0) @@ -500,6 +507,12 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work) kfree_rcu(vpd_pg80, rcu); if (vpd_pg89) kfree_rcu(vpd_pg89, rcu); + if (vpd_pgb0) + kfree_rcu(vpd_pgb0, rcu); + if (vpd_pgb1) + kfree_rcu(vpd_pgb1, rcu); + if (vpd_pgb2) + kfree_rcu(vpd_pgb2, rcu); kfree(sdev->inquiry); kfree(sdev); @@ -913,6 +926,9 @@ static struct bin_attribute dev_attr_vpd_##_page = { \ sdev_vpd_pg_attr(pg83); sdev_vpd_pg_attr(pg80); sdev_vpd_pg_attr(pg89); +sdev_vpd_pg_attr(pgb0); +sdev_vpd_pg_attr(pgb1); +sdev_vpd_pg_attr(pgb2); sdev_vpd_pg_attr(pg0); static ssize_t show_inquiry(struct file *filep, struct kobject *kobj, @@ -1250,6 +1266,15 @@ static umode_t scsi_sdev_bin_attr_is_visible(struct kobject *kobj, if (attr == &dev_attr_vpd_pg89 && !sdev->vpd_pg89) return 0; + if (attr == &dev_attr_vpd_pgb0 && !sdev->vpd_pgb0) + return 0; + + if (attr == &dev_attr_vpd_pgb1 && !sdev->vpd_pgb1) + return 0; + + if (attr == &dev_attr_vpd_pgb2 && !sdev->vpd_pgb2) + return 0; + return S_IRUGO; } @@ -1296,6 +1321,9 @@ static struct bin_attribute *scsi_sdev_bin_attrs[] = { &dev_attr_vpd_pg83, &dev_attr_vpd_pg80, &dev_attr_vpd_pg89, + &dev_attr_vpd_pgb0, + &dev_attr_vpd_pgb1, + &dev_attr_vpd_pgb2, &dev_attr_inquiry, NULL }; diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index c37cc5b3ebeb..7cf5f3b7589f 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -149,6 +149,10 @@ struct scsi_device { struct scsi_vpd __rcu *vpd_pg83; struct scsi_vpd __rcu *vpd_pg80; struct scsi_vpd __rcu *vpd_pg89; + struct scsi_vpd __rcu *vpd_pgb0; + struct scsi_vpd __rcu *vpd_pgb1; + struct scsi_vpd __rcu *vpd_pgb2; + struct scsi_target *sdev_target; blist_flags_t sdev_bflags; /* black/white flags as also found in From d657700ccac71da19a4d1a591fafcd598ce0dd6e Mon Sep 17 00:00:00 2001 From: "Martin K. Petersen" Date: Wed, 2 Mar 2022 00:35:48 -0500 Subject: [PATCH 109/177] scsi: core: Do not truncate INQUIRY data on modern devices Low-level device drivers have had the ability to limit the size of an INQUIRY for many years. This made sense for a wide variety of legacy devices. However, we are unnecessarily truncating the INQUIRY response for many modern devices. This prevents us from consulting fields beyond the first 36 bytes. If a device reports that it supports a larger INQUIRY response, and the device also reports that it implements SPC-4 or newer, allow the larger INQUIRY to proceed. Link: https://lore.kernel.org/r/20220302053559.32147-4-martin.petersen@oracle.com Reviewed-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn Signed-off-by: Martin K. Petersen --- drivers/scsi/scsi_scan.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 2ef78083f1ef..91ac901a6682 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -733,7 +733,17 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result, if (pass == 1) { if (BLIST_INQUIRY_36 & *bflags) next_inquiry_len = 36; - else if (sdev->inquiry_len) + /* + * LLD specified a maximum sdev->inquiry_len + * but device claims it has more data. Capping + * the length only makes sense for legacy + * devices. If a device supports SPC-4 (2014) + * or newer, assume that it is safe to ask for + * as much as the device says it supports. + */ + else if (sdev->inquiry_len && + response_len > sdev->inquiry_len && + (inq_result[2] & 0x7) < 6) /* SPC-4 */ next_inquiry_len = sdev->inquiry_len; else next_inquiry_len = response_len; From e38d9e83a376923454af599b2add53e71cd7508a Mon Sep 17 00:00:00 2001 From: "Martin K. Petersen" Date: Wed, 2 Mar 2022 00:35:51 -0500 Subject: [PATCH 110/177] scsi: sd: Use cached ATA Information VPD page Since the ATA Information VPD is now cached at device discovery time it is no longer necessary to request this page when we configure WRITE SAME. Instead use the cached information to determine if this disk sits behind a SCSI-ATA translation layer. Link: https://lore.kernel.org/r/20220302053559.32147-7-martin.petersen@oracle.com Reviewed-by: Christoph Hellwig Reviewed-by: Bart Van Assche Reviewed-by: Johannes Thumshirn Signed-off-by: Martin K. Petersen --- drivers/scsi/sd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index dc6e55761fd1..027738af5a22 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2996,8 +2996,7 @@ static void sd_read_write_same(struct scsi_disk *sdkp, unsigned char *buffer) } if (scsi_report_opcode(sdev, buffer, SD_BUF_SIZE, INQUIRY) < 0) { - /* too large values might cause issues with arcmsr */ - int vpd_buf_len = 64; + struct scsi_vpd *vpd; sdev->no_report_opcodes = 1; @@ -3005,8 +3004,11 @@ static void sd_read_write_same(struct scsi_disk *sdkp, unsigned char *buffer) * CODES is unsupported and the device has an ATA * Information VPD page (SAT). */ - if (!scsi_get_vpd_page(sdev, 0x89, buffer, vpd_buf_len)) + rcu_read_lock(); + vpd = rcu_dereference(sdev->vpd_pg89); + if (vpd) sdev->no_write_same = 1; + rcu_read_unlock(); } if (scsi_report_opcode(sdev, buffer, SD_BUF_SIZE, WRITE_SAME_16) == 1) From 7fb019c46eeea4e3cc3ddfd3e01a24e610f34fac Mon Sep 17 00:00:00 2001 From: "Martin K. Petersen" Date: Wed, 2 Mar 2022 00:35:52 -0500 Subject: [PATCH 111/177] scsi: sd: Switch to using scsi_device VPD pages Use the VPD pages already provided by the SCSI midlayer. No need to request them individually in the SCSI disk driver. Link: https://lore.kernel.org/r/20220302053559.32147-8-martin.petersen@oracle.com Reviewed-by: Christoph Hellwig Reviewed-by: Bart Van Assche Reviewed-by: Johannes Thumshirn Signed-off-by: Martin K. Petersen --- drivers/scsi/sd.c | 80 +++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 027738af5a22..1e580e9e4a37 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2844,39 +2844,39 @@ static void sd_read_app_tag_own(struct scsi_disk *sdkp, unsigned char *buffer) static void sd_read_block_limits(struct scsi_disk *sdkp) { unsigned int sector_sz = sdkp->device->sector_size; - const int vpd_len = 64; - unsigned char *buffer = kmalloc(vpd_len, GFP_KERNEL); + struct scsi_vpd *vpd; - if (!buffer || - /* Block Limits VPD */ - scsi_get_vpd_page(sdkp->device, 0xb0, buffer, vpd_len)) + rcu_read_lock(); + + vpd = rcu_dereference(sdkp->device->vpd_pgb0); + if (!vpd || vpd->len < 16) goto out; blk_queue_io_min(sdkp->disk->queue, - get_unaligned_be16(&buffer[6]) * sector_sz); + get_unaligned_be16(&vpd->data[6]) * sector_sz); - sdkp->max_xfer_blocks = get_unaligned_be32(&buffer[8]); - sdkp->opt_xfer_blocks = get_unaligned_be32(&buffer[12]); + sdkp->max_xfer_blocks = get_unaligned_be32(&vpd->data[8]); + sdkp->opt_xfer_blocks = get_unaligned_be32(&vpd->data[12]); - if (buffer[3] == 0x3c) { + if (vpd->len >= 64) { unsigned int lba_count, desc_count; - sdkp->max_ws_blocks = (u32)get_unaligned_be64(&buffer[36]); + sdkp->max_ws_blocks = (u32)get_unaligned_be64(&vpd->data[36]); if (!sdkp->lbpme) goto out; - lba_count = get_unaligned_be32(&buffer[20]); - desc_count = get_unaligned_be32(&buffer[24]); + lba_count = get_unaligned_be32(&vpd->data[20]); + desc_count = get_unaligned_be32(&vpd->data[24]); if (lba_count && desc_count) sdkp->max_unmap_blocks = lba_count; - sdkp->unmap_granularity = get_unaligned_be32(&buffer[28]); + sdkp->unmap_granularity = get_unaligned_be32(&vpd->data[28]); - if (buffer[32] & 0x80) + if (vpd->data[32] & 0x80) sdkp->unmap_alignment = - get_unaligned_be32(&buffer[32]) & ~(1 << 31); + get_unaligned_be32(&vpd->data[32]) & ~(1 << 31); if (!sdkp->lbpvpd) { /* LBP VPD page not provided */ @@ -2898,7 +2898,7 @@ static void sd_read_block_limits(struct scsi_disk *sdkp) } out: - kfree(buffer); + rcu_read_unlock(); } /** @@ -2908,18 +2908,21 @@ static void sd_read_block_limits(struct scsi_disk *sdkp) static void sd_read_block_characteristics(struct scsi_disk *sdkp) { struct request_queue *q = sdkp->disk->queue; - unsigned char *buffer; + struct scsi_vpd *vpd; u16 rot; - const int vpd_len = 64; + u8 zoned; - buffer = kmalloc(vpd_len, GFP_KERNEL); + rcu_read_lock(); + vpd = rcu_dereference(sdkp->device->vpd_pgb1); - if (!buffer || - /* Block Device Characteristics VPD */ - scsi_get_vpd_page(sdkp->device, 0xb1, buffer, vpd_len)) - goto out; + if (!vpd || vpd->len < 8) { + rcu_read_unlock(); + return; + } - rot = get_unaligned_be16(&buffer[4]); + rot = get_unaligned_be16(&vpd->data[4]); + zoned = (vpd->data[8] >> 4) & 3; + rcu_read_unlock(); if (rot == 1) { blk_queue_flag_set(QUEUE_FLAG_NONROT, q); @@ -2930,7 +2933,7 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp) /* Host-managed */ blk_queue_set_zoned(sdkp->disk, BLK_ZONED_HM); } else { - sdkp->zoned = (buffer[8] >> 4) & 3; + sdkp->zoned = zoned; if (sdkp->zoned == 1) { /* Host-aware */ blk_queue_set_zoned(sdkp->disk, BLK_ZONED_HA); @@ -2941,7 +2944,7 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp) } if (!sdkp->first_scan) - goto out; + return; if (blk_queue_is_zoned(q)) { sd_printk(KERN_NOTICE, sdkp, "Host-%s zoned block device\n", @@ -2954,9 +2957,6 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp) sd_printk(KERN_NOTICE, sdkp, "Drive-managed SMR disk\n"); } - - out: - kfree(buffer); } /** @@ -2965,24 +2965,24 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp) */ static void sd_read_block_provisioning(struct scsi_disk *sdkp) { - unsigned char *buffer; - const int vpd_len = 8; + struct scsi_vpd *vpd; if (sdkp->lbpme == 0) return; - buffer = kmalloc(vpd_len, GFP_KERNEL); + rcu_read_lock(); + vpd = rcu_dereference(sdkp->device->vpd_pgb2); - if (!buffer || scsi_get_vpd_page(sdkp->device, 0xb2, buffer, vpd_len)) - goto out; + if (!vpd || vpd->len < 8) { + rcu_read_unlock(); + return; + } sdkp->lbpvpd = 1; - sdkp->lbpu = (buffer[5] >> 7) & 1; /* UNMAP */ - sdkp->lbpws = (buffer[5] >> 6) & 1; /* WRITE SAME(16) with UNMAP */ - sdkp->lbpws10 = (buffer[5] >> 5) & 1; /* WRITE SAME(10) with UNMAP */ - - out: - kfree(buffer); + sdkp->lbpu = (vpd->data[5] >> 7) & 1; /* UNMAP */ + sdkp->lbpws = (vpd->data[5] >> 6) & 1; /* WRITE SAME(16) w/ UNMAP */ + sdkp->lbpws10 = (vpd->data[5] >> 5) & 1; /* WRITE SAME(10) w/ UNMAP */ + rcu_read_unlock(); } static void sd_read_write_same(struct scsi_disk *sdkp, unsigned char *buffer) From 631669a256f96c7115c34cc19578a461c72568de Mon Sep 17 00:00:00 2001 From: "Martin K. Petersen" Date: Wed, 2 Mar 2022 00:35:53 -0500 Subject: [PATCH 112/177] scsi: sd: Optimal I/O size should be a multiple of reported granularity Commit a83da8a4509d ("scsi: sd: Optimal I/O size should be a multiple of physical block size") validated the reported optimal I/O size against the physical block size to overcome problems with devices reporting nonsensical transfer sizes. However, some devices claim conformity to older SCSI versions that predate the physical block size being reported. Other devices do not report a physical block size at all. We need to be able to validate the optimal I/O size on those devices as well. Many devices report an OPTIMAL TRANSFER LENGTH GRANULARITY in the same VPD page as the OPTIMAL TRANSFER LENGTH. Use this value to validate the optimal I/O size. Also check that the reported granularity is a multiple of the physical block size, if supported. Link: https://lore.kernel.org/r/33fb522e-4f61-1b76-914f-c9e6a3553c9b@gmail.com Link: https://lore.kernel.org/r/20220302053559.32147-9-martin.petersen@oracle.com Reported-by: Bernhard Sulzer Reviewed-by: Christoph Hellwig Signed-off-by: Martin K. Petersen --- drivers/scsi/sd.c | 45 +++++++++++++++++++++++++++++++++++++++++---- drivers/scsi/sd.h | 1 + 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 1e580e9e4a37..e1c884db7fca 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2843,7 +2843,6 @@ static void sd_read_app_tag_own(struct scsi_disk *sdkp, unsigned char *buffer) */ static void sd_read_block_limits(struct scsi_disk *sdkp) { - unsigned int sector_sz = sdkp->device->sector_size; struct scsi_vpd *vpd; rcu_read_lock(); @@ -2852,9 +2851,7 @@ static void sd_read_block_limits(struct scsi_disk *sdkp) if (!vpd || vpd->len < 16) goto out; - blk_queue_io_min(sdkp->disk->queue, - get_unaligned_be16(&vpd->data[6]) * sector_sz); - + sdkp->min_xfer_blocks = get_unaligned_be16(&vpd->data[6]); sdkp->max_xfer_blocks = get_unaligned_be32(&vpd->data[8]); sdkp->opt_xfer_blocks = get_unaligned_be32(&vpd->data[12]); @@ -3112,6 +3109,29 @@ out: kfree(buffer); } +static bool sd_validate_min_xfer_size(struct scsi_disk *sdkp) +{ + struct scsi_device *sdp = sdkp->device; + unsigned int min_xfer_bytes = + logical_to_bytes(sdp, sdkp->min_xfer_blocks); + + if (sdkp->min_xfer_blocks == 0) + return false; + + if (min_xfer_bytes & (sdkp->physical_block_size - 1)) { + sd_first_printk(KERN_WARNING, sdkp, + "Preferred minimum I/O size %u bytes not a " \ + "multiple of physical block size (%u bytes)\n", + min_xfer_bytes, sdkp->physical_block_size); + sdkp->min_xfer_blocks = 0; + return false; + } + + sd_first_printk(KERN_INFO, sdkp, "Preferred minimum I/O size %u bytes\n", + min_xfer_bytes); + return true; +} + /* * Determine the device's preferred I/O size for reads and writes * unless the reported value is unreasonably small, large, not a @@ -3123,6 +3143,8 @@ static bool sd_validate_opt_xfer_size(struct scsi_disk *sdkp, struct scsi_device *sdp = sdkp->device; unsigned int opt_xfer_bytes = logical_to_bytes(sdp, sdkp->opt_xfer_blocks); + unsigned int min_xfer_bytes = + logical_to_bytes(sdp, sdkp->min_xfer_blocks); if (sdkp->opt_xfer_blocks == 0) return false; @@ -3151,6 +3173,15 @@ static bool sd_validate_opt_xfer_size(struct scsi_disk *sdkp, return false; } + if (min_xfer_bytes && opt_xfer_bytes % min_xfer_bytes) { + sd_first_printk(KERN_WARNING, sdkp, + "Optimal transfer size %u bytes not a " \ + "multiple of preferred minimum block " \ + "size (%u bytes)\n", + opt_xfer_bytes, min_xfer_bytes); + return false; + } + if (opt_xfer_bytes & (sdkp->physical_block_size - 1)) { sd_first_printk(KERN_WARNING, sdkp, "Optimal transfer size %u bytes not a " \ @@ -3243,6 +3274,12 @@ static int sd_revalidate_disk(struct gendisk *disk) dev_max = min_not_zero(dev_max, sdkp->max_xfer_blocks); q->limits.max_dev_sectors = logical_to_sectors(sdp, dev_max); + if (sd_validate_min_xfer_size(sdkp)) + blk_queue_io_min(sdkp->disk->queue, + logical_to_bytes(sdp, sdkp->min_xfer_blocks)); + else + blk_queue_io_min(sdkp->disk->queue, 0); + if (sd_validate_opt_xfer_size(sdkp, dev_max)) { q->limits.io_opt = logical_to_bytes(sdp, sdkp->opt_xfer_blocks); rw_max = logical_to_sectors(sdp, sdkp->opt_xfer_blocks); diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h index d249933ba69e..2abad54fd23f 100644 --- a/drivers/scsi/sd.h +++ b/drivers/scsi/sd.h @@ -114,6 +114,7 @@ struct scsi_disk { atomic_t openers; sector_t capacity; /* size in logical blocks */ int max_retries; + u32 min_xfer_blocks; u32 max_xfer_blocks; u32 opt_xfer_blocks; u32 max_ws_blocks; From 1e029397d12f9085840691f4f12991a80d89888c Mon Sep 17 00:00:00 2001 From: "Martin K. Petersen" Date: Wed, 2 Mar 2022 00:35:58 -0500 Subject: [PATCH 113/177] scsi: sd: Reorganize DIF/DIX code to avoid calling revalidate twice During device discovery we ended up calling revalidate twice and thus requested the same parameters multiple times. This was originally necessary due to the request_queue and gendisk needing to be instantiated to configure the block integrity profile. Since this dependency no longer exists, reorganize the integrity probing code so it can be run once at the end of discovery and drop the superfluous revalidate call. Postponing the registration step involves splitting sd_read_protection() into two functions, one to read the device protection type and one to configure the mode of operation. As part of this cleanup, make the printing code a bit less verbose. Link: https://lore.kernel.org/r/20220302053559.32147-14-martin.petersen@oracle.com Reviewed-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn Signed-off-by: Martin K. Petersen --- drivers/scsi/sd.c | 62 +++++++++++++++++++++++-------------------- drivers/scsi/sd_dif.c | 8 +++--- 2 files changed, 36 insertions(+), 34 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index e1c884db7fca..c583301ff4ec 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2176,40 +2176,48 @@ static int sd_read_protection_type(struct scsi_disk *sdkp, unsigned char *buffer { struct scsi_device *sdp = sdkp->device; u8 type; - int ret = 0; if (scsi_device_protection(sdp) == 0 || (buffer[12] & 1) == 0) { sdkp->protection_type = 0; - return ret; + return 0; } type = ((buffer[12] >> 1) & 7) + 1; /* P_TYPE 0 = Type 1 */ - if (type > T10_PI_TYPE3_PROTECTION) - ret = -ENODEV; - else if (scsi_host_dif_capable(sdp->host, type)) - ret = 1; - - if (sdkp->first_scan || type != sdkp->protection_type) - switch (ret) { - case -ENODEV: - sd_printk(KERN_ERR, sdkp, "formatted with unsupported" \ - " protection type %u. Disabling disk!\n", - type); - break; - case 1: - sd_printk(KERN_NOTICE, sdkp, - "Enabling DIF Type %u protection\n", type); - break; - case 0: - sd_printk(KERN_NOTICE, sdkp, - "Disabling DIF Type %u protection\n", type); - break; - } + if (type > T10_PI_TYPE3_PROTECTION) { + sd_printk(KERN_ERR, sdkp, "formatted with unsupported" \ + " protection type %u. Disabling disk!\n", + type); + sdkp->protection_type = 0; + return -ENODEV; + } sdkp->protection_type = type; - return ret; + return 0; +} + +static void sd_config_protection(struct scsi_disk *sdkp) +{ + struct scsi_device *sdp = sdkp->device; + + if (!sdkp->first_scan) + return; + + sd_dif_config_host(sdkp); + + if (!sdkp->protection_type) + return; + + if (!scsi_host_dif_capable(sdp->host, sdkp->protection_type)) { + sd_printk(KERN_NOTICE, sdkp, + "Disabling DIF Type %u protection\n", + sdkp->protection_type); + sdkp->protection_type = 0; + } + + sd_printk(KERN_NOTICE, sdkp, "Enabling DIF Type %u protection\n", + sdkp->protection_type); } static void read_capacity_error(struct scsi_disk *sdkp, struct scsi_device *sdp, @@ -3259,6 +3267,7 @@ static int sd_revalidate_disk(struct gendisk *disk) sd_read_app_tag_own(sdkp, buffer); sd_read_write_same(sdkp, buffer); sd_read_security(sdkp, buffer); + sd_config_protection(sdkp); } /* @@ -3518,11 +3527,6 @@ static int sd_probe(struct device *dev) goto out; } - if (sdkp->capacity) - sd_dif_config_host(sdkp); - - sd_revalidate_disk(gd); - if (sdkp->security) { sdkp->opal_dev = init_opal_dev(sdkp, &sd_sec_submit); if (sdkp->opal_dev) diff --git a/drivers/scsi/sd_dif.c b/drivers/scsi/sd_dif.c index 349950616adc..968993ee6d5d 100644 --- a/drivers/scsi/sd_dif.c +++ b/drivers/scsi/sd_dif.c @@ -59,8 +59,6 @@ void sd_dif_config_host(struct scsi_disk *sdkp) bi.profile = &t10_pi_type1_crc; bi.tuple_size = sizeof(struct t10_pi_tuple); - sd_printk(KERN_NOTICE, sdkp, - "Enabling DIX %s protection\n", bi.profile->name); if (dif && type) { bi.flags |= BLK_INTEGRITY_DEVICE_CAPABLE; @@ -72,11 +70,11 @@ void sd_dif_config_host(struct scsi_disk *sdkp) bi.tag_size = sizeof(u16) + sizeof(u32); else bi.tag_size = sizeof(u16); - - sd_printk(KERN_NOTICE, sdkp, "DIF application tag size %u\n", - bi.tag_size); } + sd_printk(KERN_NOTICE, sdkp, + "Enabling DIX %s, application tag size %u bytes\n", + bi.profile->name, bi.tag_size); out: blk_integrity_register(disk, &bi); } From 92bd903da12b0c0c5e9e2f560388fe80bb7ce749 Mon Sep 17 00:00:00 2001 From: James Smart Date: Wed, 27 Apr 2022 15:21:58 -0700 Subject: [PATCH 114/177] scsi: lpfc: Fix additional reference counting in lpfc_bsg_rport_els() Code inspection has found an additional reference is taken in lpfc_bsg_rport_els(). Results in the ndlp not being freed thus is leaked. Fix by removing the redundant refcount taken before WQE submission. Link: https://lore.kernel.org/r/20220427222158.57867-1-jsmart2021@gmail.com Co-developed-by: Nigel Kirkland Signed-off-by: Nigel Kirkland Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_bsg.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_bsg.c b/drivers/scsi/lpfc/lpfc_bsg.c index ae46383b13bf..676e7d54b97a 100644 --- a/drivers/scsi/lpfc/lpfc_bsg.c +++ b/drivers/scsi/lpfc/lpfc_bsg.c @@ -740,12 +740,6 @@ lpfc_bsg_rport_els(struct bsg_job *job) readl(phba->HCregaddr); /* flush */ } - cmdiocbq->ndlp = lpfc_nlp_get(ndlp); - if (!cmdiocbq->ndlp) { - rc = -EIO; - goto linkdown_err; - } - rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, cmdiocbq, 0); if (rc == IOCB_SUCCESS) { spin_lock_irqsave(&phba->hbalock, flags); From c2024e3b33ee785960e21c22da478c937a6af538 Mon Sep 17 00:00:00 2001 From: James Smart Date: Wed, 27 Apr 2022 15:22:23 -0700 Subject: [PATCH 115/177] scsi: lpfc: Remove redundant lpfc_sli_prep_wqe() call Prior patch added a call to lpfc_sli_prep_wqe() prior to lpfc_sli_issue_iocb(). This call should not have been added as prep_wqe is called within the issue_iocb routine. So it's called twice now. Remove the redundant prep call. Link: https://lore.kernel.org/r/20220427222223.57920-1-jsmart2021@gmail.com Fixes: 31a59f75702f ("scsi: lpfc: SLI path split: Refactor Abort paths") Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_sli.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index e8c31c080ef3..aba06794146d 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -18689,13 +18689,11 @@ lpfc_sli4_seq_abort_rsp(struct lpfc_vport *vport, phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]); bf_set(wqe_cmnd, &icmd->generic.wqe_com, CMD_XMIT_BLS_RSP64_CX); - /* Xmit CT abts response on exchange */ lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, "1200 Send BLS cmd x%x on oxid x%x Data: x%x\n", ctiocb->abort_rctl, oxid, phba->link_state); - lpfc_sli_prep_wqe(phba, ctiocb); rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, ctiocb, 0); if (rc == IOCB_ERROR) { lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, From bb9b9eb0ae2e9d3f6036f0ad907c3a83dcd43485 Mon Sep 17 00:00:00 2001 From: Xiaoguang Wang Date: Thu, 21 Apr 2022 10:37:35 +0800 Subject: [PATCH 116/177] scsi: target: tcmu: Fix possible data corruption When tcmu_vma_fault() gets a page successfully, before the current context completes page fault procedure, find_free_blocks() may run and call unmap_mapping_range() to unmap the page. Assume that when find_free_blocks() initially completes and the previous page fault procedure starts to run again and completes, then one truncated page has been mapped to userspace. But note that tcmu_vma_fault() has gotten a refcount for the page so any other subsystem won't be able to use the page unless the userspace address is unmapped later. If another command subsequently runs and needs to extend dbi_thresh it may reuse the corresponding slot for the previous page in data_bitmap. Then though we'll allocate new page for this slot in data_area, no page fault will happen because we have a valid map and the real request's data will be lost. Filesystem implementations will also run into this issue but they usually lock the page when vm_operations_struct->fault gets a page and unlock the page after finish_fault() completes. For truncate filesystems lock pages in truncate_inode_pages() to protect against racing wrt. page faults. To fix this possible data corruption scenario we can apply a method similar to the filesystems. For pages that are to be freed, tcmu_blocks_release() locks and unlocks. Make tcmu_vma_fault() also lock found page under cmdr_lock. At the same time, since tcmu_vma_fault() gets an extra page refcount, tcmu_blocks_release() won't free pages if pages are in page fault procedure, which means it is safe to call tcmu_blocks_release() before unmap_mapping_range(). With these changes tcmu_blocks_release() will wait for all page faults to be completed before calling unmap_mapping_range(). And later, if unmap_mapping_range() is called, it will ensure stale mappings are removed. Link: https://lore.kernel.org/r/20220421023735.9018-1-xiaoguang.wang@linux.alibaba.com Reviewed-by: Bodo Stroesser Signed-off-by: Xiaoguang Wang Signed-off-by: Martin K. Petersen --- drivers/target/target_core_user.c | 40 ++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index fd7267baa707..b1fd06edea59 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -1667,6 +1668,26 @@ static u32 tcmu_blocks_release(struct tcmu_dev *udev, unsigned long first, xas_lock(&xas); xas_for_each(&xas, page, (last + 1) * udev->data_pages_per_blk - 1) { xas_store(&xas, NULL); + /* + * While reaching here there may be page faults occurring on + * the to-be-released pages. A race condition may occur if + * unmap_mapping_range() is called before page faults on these + * pages have completed; a valid but stale map is created. + * + * If another command subsequently runs and needs to extend + * dbi_thresh, it may reuse the slot corresponding to the + * previous page in data_bitmap. Though we will allocate a new + * page for the slot in data_area, no page fault will happen + * because we have a valid map. Therefore the command's data + * will be lost. + * + * We lock and unlock pages that are to be released to ensure + * all page faults have completed. This way + * unmap_mapping_range() can ensure stale maps are cleanly + * removed. + */ + lock_page(page); + unlock_page(page); __free_page(page); pages_freed++; } @@ -1822,6 +1843,7 @@ static struct page *tcmu_try_get_data_page(struct tcmu_dev *udev, uint32_t dpi) page = xa_load(&udev->data_pages, dpi); if (likely(page)) { get_page(page); + lock_page(page); mutex_unlock(&udev->cmdr_lock); return page; } @@ -1863,6 +1885,7 @@ static vm_fault_t tcmu_vma_fault(struct vm_fault *vmf) struct page *page; unsigned long offset; void *addr; + vm_fault_t ret = 0; int mi = tcmu_find_mem_index(vmf->vma); if (mi < 0) @@ -1887,10 +1910,11 @@ static vm_fault_t tcmu_vma_fault(struct vm_fault *vmf) page = tcmu_try_get_data_page(udev, dpi); if (!page) return VM_FAULT_SIGBUS; + ret = VM_FAULT_LOCKED; } vmf->page = page; - return 0; + return ret; } static const struct vm_operations_struct tcmu_vm_ops = { @@ -3205,12 +3229,22 @@ static void find_free_blocks(void) udev->dbi_max = block; } + /* + * Release the block pages. + * + * Also note that since tcmu_vma_fault() gets an extra page + * refcount, tcmu_blocks_release() won't free pages if pages + * are mapped. This means it is safe to call + * tcmu_blocks_release() before unmap_mapping_range() which + * drops the refcount of any pages it unmaps and thus releases + * them. + */ + pages_freed = tcmu_blocks_release(udev, start, end - 1); + /* Here will truncate the data area from off */ off = udev->data_off + (loff_t)start * udev->data_blk_size; unmap_mapping_range(udev->inode->i_mapping, off, 0, 1); - /* Release the block pages */ - pages_freed = tcmu_blocks_release(udev, start, end - 1); mutex_unlock(&udev->cmdr_lock); total_pages_freed += pages_freed; From ebc95c790653508ad7e031cfb9de5d0fa39135e2 Mon Sep 17 00:00:00 2001 From: Enze Li Date: Wed, 27 Apr 2022 10:56:47 +0800 Subject: [PATCH 117/177] scsi: sr: Add memory allocation failure handling for get_capabilities() The function get_capabilities() has the possibility of failing to allocate the transfer buffer but it does not currently handle this. This may lead to exceptions when accessing the buffer. Add error handling when memory allocation fails. Link: https://lore.kernel.org/r/20220427025647.298358-1-lienze@kylinos.cn Signed-off-by: Enze Li Signed-off-by: Martin K. Petersen --- drivers/scsi/sr.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index cbd92891a762..32d3b8274f14 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -113,7 +113,7 @@ static int sr_open(struct cdrom_device_info *, int); static void sr_release(struct cdrom_device_info *); static void get_sectorsize(struct scsi_cd *); -static void get_capabilities(struct scsi_cd *); +static int get_capabilities(struct scsi_cd *); static unsigned int sr_check_events(struct cdrom_device_info *cdi, unsigned int clearing, int slot); @@ -669,8 +669,9 @@ static int sr_probe(struct device *dev) sdev->sector_size = 2048; /* A guess, just in case */ - /* FIXME: need to handle a get_capabilities failure properly ?? */ - get_capabilities(cd); + error = -ENOMEM; + if (get_capabilities(cd)) + goto fail_minor; sr_vendor_init(cd); set_capacity(disk, cd->capacity); @@ -794,7 +795,7 @@ static void get_sectorsize(struct scsi_cd *cd) return; } -static void get_capabilities(struct scsi_cd *cd) +static int get_capabilities(struct scsi_cd *cd) { unsigned char *buffer; struct scsi_mode_data data; @@ -819,7 +820,7 @@ static void get_capabilities(struct scsi_cd *cd) buffer = kmalloc(512, GFP_KERNEL); if (!buffer) { sr_printk(KERN_ERR, cd, "out of memory.\n"); - return; + return -ENOMEM; } /* eat unit attentions */ @@ -839,7 +840,7 @@ static void get_capabilities(struct scsi_cd *cd) CDC_MRW | CDC_MRW_W | CDC_RAM); kfree(buffer); sr_printk(KERN_INFO, cd, "scsi-1 drive"); - return; + return 0; } n = data.header_length + data.block_descriptor_length; @@ -898,6 +899,7 @@ static void get_capabilities(struct scsi_cd *cd) } kfree(buffer); + return 0; } /* From 4268fa7513655a83d5492705591fdac6c65db48a Mon Sep 17 00:00:00 2001 From: Sumit Saxena Date: Fri, 29 Apr 2022 17:16:34 -0400 Subject: [PATCH 118/177] scsi: mpi3mr: Add bsg device support Create bsg device per controller for controller management purposes. bsg device nodes will be named /dev/bsg/mpi3mrctl0, /dev/bsg/mpi3mrctl1, etc. Link: https://lore.kernel.org/r/20220429211641.642010-2-sumit.saxena@broadcom.com Reported-by: kernel test robot Reviewed-by: Hannes Reinecke Reviewed-by: Himanshu Madhani Signed-off-by: Sumit Saxena Signed-off-by: Martin K. Petersen --- drivers/scsi/mpi3mr/Kconfig | 1 + drivers/scsi/mpi3mr/Makefile | 1 + drivers/scsi/mpi3mr/mpi3mr.h | 20 ++++++ drivers/scsi/mpi3mr/mpi3mr_app.c | 105 +++++++++++++++++++++++++++++++ drivers/scsi/mpi3mr/mpi3mr_os.c | 2 + 5 files changed, 129 insertions(+) create mode 100644 drivers/scsi/mpi3mr/mpi3mr_app.c diff --git a/drivers/scsi/mpi3mr/Kconfig b/drivers/scsi/mpi3mr/Kconfig index f7882375e74f..8997531940c2 100644 --- a/drivers/scsi/mpi3mr/Kconfig +++ b/drivers/scsi/mpi3mr/Kconfig @@ -3,5 +3,6 @@ config SCSI_MPI3MR tristate "Broadcom MPI3 Storage Controller Device Driver" depends on PCI && SCSI + select BLK_DEV_BSGLIB help MPI3 based Storage & RAID Controllers Driver. diff --git a/drivers/scsi/mpi3mr/Makefile b/drivers/scsi/mpi3mr/Makefile index 7c2063e04c81..f5cdbe48c150 100644 --- a/drivers/scsi/mpi3mr/Makefile +++ b/drivers/scsi/mpi3mr/Makefile @@ -2,3 +2,4 @@ obj-m += mpi3mr.o mpi3mr-y += mpi3mr_os.o \ mpi3mr_fw.o \ + mpi3mr_app.o \ diff --git a/drivers/scsi/mpi3mr/mpi3mr.h b/drivers/scsi/mpi3mr/mpi3mr.h index 96c85f719af0..70bbc2074e15 100644 --- a/drivers/scsi/mpi3mr/mpi3mr.h +++ b/drivers/scsi/mpi3mr/mpi3mr.h @@ -148,6 +148,7 @@ extern int prot_mask; #define MPI3MR_DEFAULT_MDTS (128 * 1024) #define MPI3MR_DEFAULT_PGSZEXP (12) + /* Command retry count definitions */ #define MPI3MR_DEV_RMHS_RETRY_COUNT 3 @@ -175,6 +176,18 @@ extern int prot_mask; /* MSI Index from Reply Queue Index */ #define REPLY_QUEUE_IDX_TO_MSIX_IDX(qidx, offset) (qidx + offset) +/* + * Maximum data transfer size definitions for management + * application commands + */ +#define MPI3MR_MAX_APP_XFER_SIZE (1 * 1024 * 1024) +#define MPI3MR_MAX_APP_XFER_SEGMENTS 512 +/* + * 2048 sectors are for data buffers and additional 512 sectors for + * other buffers + */ +#define MPI3MR_MAX_APP_XFER_SECTORS (2048 + 512) + /* IOC State definitions */ enum mpi3mr_iocstate { MRIOC_STATE_READY = 1, @@ -714,6 +727,8 @@ struct scmd_priv { * @default_qcount: Total Default queues * @active_poll_qcount: Currently active poll queue count * @requested_poll_qcount: User requested poll queue count + * @bsg_dev: BSG device structure + * @bsg_queue: Request queue for BSG device */ struct mpi3mr_ioc { struct list_head list; @@ -854,6 +869,9 @@ struct mpi3mr_ioc { u16 default_qcount; u16 active_poll_qcount; u16 requested_poll_qcount; + + struct device *bsg_dev; + struct request_queue *bsg_queue; }; /** @@ -962,5 +980,7 @@ void mpi3mr_check_rh_fault_ioc(struct mpi3mr_ioc *mrioc, u32 reason_code); int mpi3mr_process_op_reply_q(struct mpi3mr_ioc *mrioc, struct op_reply_qinfo *op_reply_q); int mpi3mr_blk_mq_poll(struct Scsi_Host *shost, unsigned int queue_num); +void mpi3mr_bsg_init(struct mpi3mr_ioc *mrioc); +void mpi3mr_bsg_exit(struct mpi3mr_ioc *mrioc); #endif /*MPI3MR_H_INCLUDED*/ diff --git a/drivers/scsi/mpi3mr/mpi3mr_app.c b/drivers/scsi/mpi3mr/mpi3mr_app.c new file mode 100644 index 000000000000..948d4ff2ea06 --- /dev/null +++ b/drivers/scsi/mpi3mr/mpi3mr_app.c @@ -0,0 +1,105 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Driver for Broadcom MPI3 Storage Controllers + * + * Copyright (C) 2017-2022 Broadcom Inc. + * (mailto: mpi3mr-linuxdrv.pdl@broadcom.com) + * + */ + +#include "mpi3mr.h" +#include + +/** + * mpi3mr_bsg_request - bsg request entry point + * @job: BSG job reference + * + * This is driver's entry point for bsg requests + * + * Return: 0 on success and proper error codes on failure + */ +static int mpi3mr_bsg_request(struct bsg_job *job) +{ + return 0; +} + +/** + * mpi3mr_bsg_exit - de-registration from bsg layer + * + * This will be called during driver unload and all + * bsg resources allocated during load will be freed. + * + * Return:Nothing + */ +void mpi3mr_bsg_exit(struct mpi3mr_ioc *mrioc) +{ + if (!mrioc->bsg_queue) + return; + + bsg_remove_queue(mrioc->bsg_queue); + mrioc->bsg_queue = NULL; + + device_del(mrioc->bsg_dev); + put_device(mrioc->bsg_dev); + kfree(mrioc->bsg_dev); +} + +/** + * mpi3mr_bsg_node_release -release bsg device node + * @dev: bsg device node + * + * decrements bsg dev reference count + * + * Return:Nothing + */ +static void mpi3mr_bsg_node_release(struct device *dev) +{ + put_device(dev); +} + +/** + * mpi3mr_bsg_init - registration with bsg layer + * + * This will be called during driver load and it will + * register driver with bsg layer + * + * Return:Nothing + */ +void mpi3mr_bsg_init(struct mpi3mr_ioc *mrioc) +{ + mrioc->bsg_dev = kzalloc(sizeof(struct device), GFP_KERNEL); + if (!mrioc->bsg_dev) { + ioc_err(mrioc, "bsg device mem allocation failed\n"); + return; + } + + device_initialize(mrioc->bsg_dev); + dev_set_name(mrioc->bsg_dev, "mpi3mrctl%u", mrioc->id); + + if (device_add(mrioc->bsg_dev)) { + ioc_err(mrioc, "%s: bsg device add failed\n", + dev_name(mrioc->bsg_dev)); + goto err_device_add; + } + + mrioc->bsg_dev->release = mpi3mr_bsg_node_release; + + mrioc->bsg_queue = bsg_setup_queue(mrioc->bsg_dev, dev_name(mrioc->bsg_dev), + mpi3mr_bsg_request, NULL, 0); + if (!mrioc->bsg_queue) { + ioc_err(mrioc, "%s: bsg registration failed\n", + dev_name(mrioc->bsg_dev)); + goto err_setup_queue; + } + + blk_queue_max_segments(mrioc->bsg_queue, MPI3MR_MAX_APP_XFER_SEGMENTS); + blk_queue_max_hw_sectors(mrioc->bsg_queue, MPI3MR_MAX_APP_XFER_SECTORS); + + return; + +err_setup_queue: + device_del(mrioc->bsg_dev); + put_device(mrioc->bsg_dev); +err_device_add: + kfree(mrioc->bsg_dev); +} diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index f7cd70a15ea6..faf14a5f9123 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -4345,6 +4345,7 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id) } scsi_scan_host(shost); + mpi3mr_bsg_init(mrioc); return retval; addhost_failed: @@ -4389,6 +4390,7 @@ static void mpi3mr_remove(struct pci_dev *pdev) while (mrioc->reset_in_progress || mrioc->is_driver_loading) ssleep(1); + mpi3mr_bsg_exit(mrioc); mrioc->stop_drv_processing = 1; mpi3mr_cleanup_fwevt_list(mrioc); spin_lock_irqsave(&mrioc->fwevt_lock, flags); From f5e6d5a343761081317c89d23489c93fbafc69ff Mon Sep 17 00:00:00 2001 From: Sumit Saxena Date: Fri, 29 Apr 2022 17:16:35 -0400 Subject: [PATCH 119/177] scsi: mpi3mr: Add support for driver commands There are certain bsg commands which need to be completed by the driver without involving firmware. These requests are termed driver commands. Add support for these. Link: https://lore.kernel.org/r/20220429211641.642010-3-sumit.saxena@broadcom.com Reported by: Stephen Rothwell Reported-by: kernel test robot Reviewed-by: Himanshu Madhani Signed-off-by: Sumit Saxena Signed-off-by: Martin K. Petersen --- drivers/scsi/mpi3mr/mpi/mpi30_ioc.h | 10 - drivers/scsi/mpi3mr/mpi3mr.h | 16 +- drivers/scsi/mpi3mr/mpi3mr_app.c | 390 ++++++++++++++++++++++++ drivers/scsi/mpi3mr/mpi3mr_debug.h | 12 +- drivers/scsi/mpi3mr/mpi3mr_fw.c | 21 +- drivers/scsi/mpi3mr/mpi3mr_os.c | 3 + include/uapi/scsi/scsi_bsg_mpi3mr.h | 457 ++++++++++++++++++++++++++++ 7 files changed, 887 insertions(+), 22 deletions(-) create mode 100644 include/uapi/scsi/scsi_bsg_mpi3mr.h diff --git a/drivers/scsi/mpi3mr/mpi/mpi30_ioc.h b/drivers/scsi/mpi3mr/mpi/mpi30_ioc.h index 633037dc7012..33fc05f218d6 100644 --- a/drivers/scsi/mpi3mr/mpi/mpi30_ioc.h +++ b/drivers/scsi/mpi3mr/mpi/mpi30_ioc.h @@ -38,16 +38,6 @@ struct mpi3_ioc_init_request { #define MPI3_WHOINIT_ROM_BIOS (0x02) #define MPI3_WHOINIT_HOST_DRIVER (0x03) #define MPI3_WHOINIT_MANUFACTURER (0x04) -struct mpi3_driver_info_layout { - __le32 information_length; - u8 driver_signature[12]; - u8 os_name[16]; - u8 os_version[12]; - u8 driver_name[20]; - u8 driver_version[32]; - u8 driver_release_date[20]; - __le32 driver_capabilities; -}; struct mpi3_ioc_facts_request { __le16 host_tag; diff --git a/drivers/scsi/mpi3mr/mpi3mr.h b/drivers/scsi/mpi3mr/mpi3mr.h index 70bbc2074e15..b72a1df5c136 100644 --- a/drivers/scsi/mpi3mr/mpi3mr.h +++ b/drivers/scsi/mpi3mr/mpi3mr.h @@ -89,7 +89,7 @@ extern int prot_mask; /* Reserved Host Tag definitions */ #define MPI3MR_HOSTTAG_INVALID 0xFFFF #define MPI3MR_HOSTTAG_INITCMDS 1 -#define MPI3MR_HOSTTAG_IOCTLCMDS 2 +#define MPI3MR_HOSTTAG_BSG_CMDS 2 #define MPI3MR_HOSTTAG_BLK_TMS 5 #define MPI3MR_NUM_DEVRMCMD 16 @@ -202,10 +202,10 @@ enum mpi3mr_iocstate { enum mpi3mr_reset_reason { MPI3MR_RESET_FROM_BRINGUP = 1, MPI3MR_RESET_FROM_FAULT_WATCH = 2, - MPI3MR_RESET_FROM_IOCTL = 3, + MPI3MR_RESET_FROM_APP = 3, MPI3MR_RESET_FROM_EH_HOS = 4, MPI3MR_RESET_FROM_TM_TIMEOUT = 5, - MPI3MR_RESET_FROM_IOCTL_TIMEOUT = 6, + MPI3MR_RESET_FROM_APP_TIMEOUT = 6, MPI3MR_RESET_FROM_MUR_FAILURE = 7, MPI3MR_RESET_FROM_CTLR_CLEANUP = 8, MPI3MR_RESET_FROM_CIACTIV_FAULT = 9, @@ -698,6 +698,7 @@ struct scmd_priv { * @chain_bitmap_sz: Chain buffer allocator bitmap size * @chain_bitmap: Chain buffer allocator bitmap * @chain_buf_lock: Chain buffer list lock + * @bsg_cmds: Command tracker for BSG command * @host_tm_cmds: Command tracker for task management commands * @dev_rmhs_cmds: Command tracker for device removal commands * @evtack_cmds: Command tracker for event ack commands @@ -729,6 +730,10 @@ struct scmd_priv { * @requested_poll_qcount: User requested poll queue count * @bsg_dev: BSG device structure * @bsg_queue: Request queue for BSG device + * @stop_bsgs: Stop BSG request flag + * @logdata_buf: Circular buffer to store log data entries + * @logdata_buf_idx: Index of entry in buffer to store + * @logdata_entry_sz: log data entry size */ struct mpi3mr_ioc { struct list_head list; @@ -835,6 +840,7 @@ struct mpi3mr_ioc { void *chain_bitmap; spinlock_t chain_buf_lock; + struct mpi3mr_drv_cmd bsg_cmds; struct mpi3mr_drv_cmd host_tm_cmds; struct mpi3mr_drv_cmd dev_rmhs_cmds[MPI3MR_NUM_DEVRMCMD]; struct mpi3mr_drv_cmd evtack_cmds[MPI3MR_NUM_EVTACKCMD]; @@ -872,6 +878,10 @@ struct mpi3mr_ioc { struct device *bsg_dev; struct request_queue *bsg_queue; + u8 stop_bsgs; + u8 *logdata_buf; + u16 logdata_buf_idx; + u16 logdata_entry_sz; }; /** diff --git a/drivers/scsi/mpi3mr/mpi3mr_app.c b/drivers/scsi/mpi3mr/mpi3mr_app.c index 948d4ff2ea06..0dcd64c8afea 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_app.c +++ b/drivers/scsi/mpi3mr/mpi3mr_app.c @@ -9,6 +9,379 @@ #include "mpi3mr.h" #include +#include + +/** + * mpi3mr_bsg_verify_adapter - verify adapter number is valid + * @ioc_number: Adapter number + * + * This function returns the adapter instance pointer of given + * adapter number. If adapter number does not match with the + * driver's adapter list, driver returns NULL. + * + * Return: adapter instance reference + */ +static struct mpi3mr_ioc *mpi3mr_bsg_verify_adapter(int ioc_number) +{ + struct mpi3mr_ioc *mrioc = NULL; + + spin_lock(&mrioc_list_lock); + list_for_each_entry(mrioc, &mrioc_list, list) { + if (mrioc->id == ioc_number) { + spin_unlock(&mrioc_list_lock); + return mrioc; + } + } + spin_unlock(&mrioc_list_lock); + return NULL; +} + +/** + * mpi3mr_enable_logdata - Handler for log data enable + * @mrioc: Adapter instance reference + * @job: BSG job reference + * + * This function enables log data caching in the driver if not + * already enabled and return the maximum number of log data + * entries that can be cached in the driver. + * + * Return: 0 on success and proper error codes on failure + */ +static long mpi3mr_enable_logdata(struct mpi3mr_ioc *mrioc, + struct bsg_job *job) +{ + struct mpi3mr_logdata_enable logdata_enable; + + if (!mrioc->logdata_buf) { + mrioc->logdata_entry_sz = + (mrioc->reply_sz - (sizeof(struct mpi3_event_notification_reply) - 4)) + + MPI3MR_BSG_LOGDATA_ENTRY_HEADER_SZ; + mrioc->logdata_buf_idx = 0; + mrioc->logdata_buf = kcalloc(MPI3MR_BSG_LOGDATA_MAX_ENTRIES, + mrioc->logdata_entry_sz, GFP_KERNEL); + + if (!mrioc->logdata_buf) + return -ENOMEM; + } + + memset(&logdata_enable, 0, sizeof(logdata_enable)); + logdata_enable.max_entries = + MPI3MR_BSG_LOGDATA_MAX_ENTRIES; + if (job->request_payload.payload_len >= sizeof(logdata_enable)) { + sg_copy_from_buffer(job->request_payload.sg_list, + job->request_payload.sg_cnt, + &logdata_enable, sizeof(logdata_enable)); + return 0; + } + + return -EINVAL; +} +/** + * mpi3mr_get_logdata - Handler for get log data + * @mrioc: Adapter instance reference + * @job: BSG job pointer + * This function copies the log data entries to the user buffer + * when log caching is enabled in the driver. + * + * Return: 0 on success and proper error codes on failure + */ +static long mpi3mr_get_logdata(struct mpi3mr_ioc *mrioc, + struct bsg_job *job) +{ + u16 num_entries, sz, entry_sz = mrioc->logdata_entry_sz; + + if ((!mrioc->logdata_buf) || (job->request_payload.payload_len < entry_sz)) + return -EINVAL; + + num_entries = job->request_payload.payload_len / entry_sz; + if (num_entries > MPI3MR_BSG_LOGDATA_MAX_ENTRIES) + num_entries = MPI3MR_BSG_LOGDATA_MAX_ENTRIES; + sz = num_entries * entry_sz; + + if (job->request_payload.payload_len >= sz) { + sg_copy_from_buffer(job->request_payload.sg_list, + job->request_payload.sg_cnt, + mrioc->logdata_buf, sz); + return 0; + } + return -EINVAL; +} + +/** + * mpi3mr_get_all_tgt_info - Get all target information + * @mrioc: Adapter instance reference + * @job: BSG job reference + * + * This function copies the driver managed target devices device + * handle, persistent ID, bus ID and taret ID to the user + * provided buffer for the specific controller. This function + * also provides the number of devices managed by the driver for + * the specific controller. + * + * Return: 0 on success and proper error codes on failure + */ +static long mpi3mr_get_all_tgt_info(struct mpi3mr_ioc *mrioc, + struct bsg_job *job) +{ + long rval = -EINVAL; + u16 num_devices = 0, i = 0, size; + unsigned long flags; + struct mpi3mr_tgt_dev *tgtdev; + struct mpi3mr_device_map_info *devmap_info = NULL; + struct mpi3mr_all_tgt_info *alltgt_info = NULL; + uint32_t min_entrylen = 0, kern_entrylen = 0, usr_entrylen = 0; + + if (job->request_payload.payload_len < sizeof(u32)) { + dprint_bsg_err(mrioc, "%s: invalid size argument\n", + __func__); + return rval; + } + + spin_lock_irqsave(&mrioc->tgtdev_lock, flags); + list_for_each_entry(tgtdev, &mrioc->tgtdev_list, list) + num_devices++; + spin_unlock_irqrestore(&mrioc->tgtdev_lock, flags); + + if ((job->request_payload.payload_len == sizeof(u32)) || + list_empty(&mrioc->tgtdev_list)) { + sg_copy_from_buffer(job->request_payload.sg_list, + job->request_payload.sg_cnt, + &num_devices, sizeof(num_devices)); + return 0; + } + + kern_entrylen = (num_devices - 1) * sizeof(*devmap_info); + size = sizeof(*alltgt_info) + kern_entrylen; + alltgt_info = kzalloc(size, GFP_KERNEL); + if (!alltgt_info) + return -ENOMEM; + + devmap_info = alltgt_info->dmi; + memset((u8 *)devmap_info, 0xFF, (kern_entrylen + sizeof(*devmap_info))); + spin_lock_irqsave(&mrioc->tgtdev_lock, flags); + list_for_each_entry(tgtdev, &mrioc->tgtdev_list, list) { + if (i < num_devices) { + devmap_info[i].handle = tgtdev->dev_handle; + devmap_info[i].perst_id = tgtdev->perst_id; + if (tgtdev->host_exposed && tgtdev->starget) { + devmap_info[i].target_id = tgtdev->starget->id; + devmap_info[i].bus_id = + tgtdev->starget->channel; + } + i++; + } + } + num_devices = i; + spin_unlock_irqrestore(&mrioc->tgtdev_lock, flags); + + memcpy(&alltgt_info->num_devices, &num_devices, sizeof(num_devices)); + + usr_entrylen = (job->request_payload.payload_len - sizeof(u32)) / sizeof(*devmap_info); + usr_entrylen *= sizeof(*devmap_info); + min_entrylen = min(usr_entrylen, kern_entrylen); + if (min_entrylen && (!memcpy(&alltgt_info->dmi, devmap_info, min_entrylen))) { + dprint_bsg_err(mrioc, "%s:%d: device map info copy failed\n", + __func__, __LINE__); + rval = -EFAULT; + goto out; + } + + sg_copy_from_buffer(job->request_payload.sg_list, + job->request_payload.sg_cnt, + alltgt_info, job->request_payload.payload_len); + rval = 0; +out: + kfree(alltgt_info); + return rval; +} + +/** + * mpi3mr_get_change_count - Get topology change count + * @mrioc: Adapter instance reference + * @job: BSG job reference + * + * This function copies the toplogy change count provided by the + * driver in events and cached in the driver to the user + * provided buffer for the specific controller. + * + * Return: 0 on success and proper error codes on failure + */ +static long mpi3mr_get_change_count(struct mpi3mr_ioc *mrioc, + struct bsg_job *job) +{ + struct mpi3mr_change_count chgcnt; + + memset(&chgcnt, 0, sizeof(chgcnt)); + chgcnt.change_count = mrioc->change_count; + if (job->request_payload.payload_len >= sizeof(chgcnt)) { + sg_copy_from_buffer(job->request_payload.sg_list, + job->request_payload.sg_cnt, + &chgcnt, sizeof(chgcnt)); + return 0; + } + return -EINVAL; +} + +/** + * mpi3mr_bsg_adp_reset - Issue controller reset + * @mrioc: Adapter instance reference + * @job: BSG job reference + * + * This function identifies the user provided reset type and + * issues approporiate reset to the controller and wait for that + * to complete and reinitialize the controller and then returns + * + * Return: 0 on success and proper error codes on failure + */ +static long mpi3mr_bsg_adp_reset(struct mpi3mr_ioc *mrioc, + struct bsg_job *job) +{ + long rval = -EINVAL; + u8 save_snapdump; + struct mpi3mr_bsg_adp_reset adpreset; + + if (job->request_payload.payload_len != + sizeof(adpreset)) { + dprint_bsg_err(mrioc, "%s: invalid size argument\n", + __func__); + goto out; + } + + sg_copy_to_buffer(job->request_payload.sg_list, + job->request_payload.sg_cnt, + &adpreset, sizeof(adpreset)); + + switch (adpreset.reset_type) { + case MPI3MR_BSG_ADPRESET_SOFT: + save_snapdump = 0; + break; + case MPI3MR_BSG_ADPRESET_DIAG_FAULT: + save_snapdump = 1; + break; + default: + dprint_bsg_err(mrioc, "%s: unknown reset_type(%d)\n", + __func__, adpreset.reset_type); + goto out; + } + + rval = mpi3mr_soft_reset_handler(mrioc, MPI3MR_RESET_FROM_APP, + save_snapdump); + + if (rval) + dprint_bsg_err(mrioc, + "%s: reset handler returned error(%ld) for reset type %d\n", + __func__, rval, adpreset.reset_type); +out: + return rval; +} + +/** + * mpi3mr_bsg_populate_adpinfo - Get adapter info command handler + * @mrioc: Adapter instance reference + * @job: BSG job reference + * + * This function provides adapter information for the given + * controller + * + * Return: 0 on success and proper error codes on failure + */ +static long mpi3mr_bsg_populate_adpinfo(struct mpi3mr_ioc *mrioc, + struct bsg_job *job) +{ + enum mpi3mr_iocstate ioc_state; + struct mpi3mr_bsg_in_adpinfo adpinfo; + + memset(&adpinfo, 0, sizeof(adpinfo)); + adpinfo.adp_type = MPI3MR_BSG_ADPTYPE_AVGFAMILY; + adpinfo.pci_dev_id = mrioc->pdev->device; + adpinfo.pci_dev_hw_rev = mrioc->pdev->revision; + adpinfo.pci_subsys_dev_id = mrioc->pdev->subsystem_device; + adpinfo.pci_subsys_ven_id = mrioc->pdev->subsystem_vendor; + adpinfo.pci_bus = mrioc->pdev->bus->number; + adpinfo.pci_dev = PCI_SLOT(mrioc->pdev->devfn); + adpinfo.pci_func = PCI_FUNC(mrioc->pdev->devfn); + adpinfo.pci_seg_id = pci_domain_nr(mrioc->pdev->bus); + adpinfo.app_intfc_ver = MPI3MR_IOCTL_VERSION; + + ioc_state = mpi3mr_get_iocstate(mrioc); + if (ioc_state == MRIOC_STATE_UNRECOVERABLE) + adpinfo.adp_state = MPI3MR_BSG_ADPSTATE_UNRECOVERABLE; + else if ((mrioc->reset_in_progress) || (mrioc->stop_bsgs)) + adpinfo.adp_state = MPI3MR_BSG_ADPSTATE_IN_RESET; + else if (ioc_state == MRIOC_STATE_FAULT) + adpinfo.adp_state = MPI3MR_BSG_ADPSTATE_FAULT; + else + adpinfo.adp_state = MPI3MR_BSG_ADPSTATE_OPERATIONAL; + + memcpy((u8 *)&adpinfo.driver_info, (u8 *)&mrioc->driver_info, + sizeof(adpinfo.driver_info)); + + if (job->request_payload.payload_len >= sizeof(adpinfo)) { + sg_copy_from_buffer(job->request_payload.sg_list, + job->request_payload.sg_cnt, + &adpinfo, sizeof(adpinfo)); + return 0; + } + return -EINVAL; +} + +/** + * mpi3mr_bsg_process_drv_cmds - Driver Command handler + * @job: BSG job reference + * + * This function is the top level handler for driver commands, + * this does basic validation of the buffer and identifies the + * opcode and switches to correct sub handler. + * + * Return: 0 on success and proper error codes on failure + */ +static long mpi3mr_bsg_process_drv_cmds(struct bsg_job *job) +{ + long rval = -EINVAL; + struct mpi3mr_ioc *mrioc = NULL; + struct mpi3mr_bsg_packet *bsg_req = NULL; + struct mpi3mr_bsg_drv_cmd *drvrcmd = NULL; + + bsg_req = job->request; + drvrcmd = &bsg_req->cmd.drvrcmd; + + mrioc = mpi3mr_bsg_verify_adapter(drvrcmd->mrioc_id); + if (!mrioc) + return -ENODEV; + + if (drvrcmd->opcode == MPI3MR_DRVBSG_OPCODE_ADPINFO) { + rval = mpi3mr_bsg_populate_adpinfo(mrioc, job); + return rval; + } + + if (mutex_lock_interruptible(&mrioc->bsg_cmds.mutex)) + return -ERESTARTSYS; + + switch (drvrcmd->opcode) { + case MPI3MR_DRVBSG_OPCODE_ADPRESET: + rval = mpi3mr_bsg_adp_reset(mrioc, job); + break; + case MPI3MR_DRVBSG_OPCODE_ALLTGTDEVINFO: + rval = mpi3mr_get_all_tgt_info(mrioc, job); + break; + case MPI3MR_DRVBSG_OPCODE_GETCHGCNT: + rval = mpi3mr_get_change_count(mrioc, job); + break; + case MPI3MR_DRVBSG_OPCODE_LOGDATAENABLE: + rval = mpi3mr_enable_logdata(mrioc, job); + break; + case MPI3MR_DRVBSG_OPCODE_GETLOGDATA: + rval = mpi3mr_get_logdata(mrioc, job); + break; + case MPI3MR_DRVBSG_OPCODE_UNKNOWN: + default: + pr_err("%s: unsupported driver command opcode %d\n", + MPI3MR_DRIVER_NAME, drvrcmd->opcode); + break; + } + mutex_unlock(&mrioc->bsg_cmds.mutex); + return rval; +} /** * mpi3mr_bsg_request - bsg request entry point @@ -20,6 +393,23 @@ */ static int mpi3mr_bsg_request(struct bsg_job *job) { + long rval = -EINVAL; + unsigned int reply_payload_rcv_len = 0; + + struct mpi3mr_bsg_packet *bsg_req = job->request; + + switch (bsg_req->cmd_type) { + case MPI3MR_DRV_CMD: + rval = mpi3mr_bsg_process_drv_cmds(job); + break; + default: + pr_err("%s: unsupported BSG command(0x%08x)\n", + MPI3MR_DRIVER_NAME, bsg_req->cmd_type); + break; + } + + bsg_job_done(job, rval, reply_payload_rcv_len); + return 0; } diff --git a/drivers/scsi/mpi3mr/mpi3mr_debug.h b/drivers/scsi/mpi3mr/mpi3mr_debug.h index c7982443f45a..65bfac72948c 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_debug.h +++ b/drivers/scsi/mpi3mr/mpi3mr_debug.h @@ -23,8 +23,8 @@ #define MPI3_DEBUG_RESET 0x00000020 #define MPI3_DEBUG_SCSI_ERROR 0x00000040 #define MPI3_DEBUG_REPLY 0x00000080 -#define MPI3_DEBUG_IOCTL_ERROR 0x00008000 -#define MPI3_DEBUG_IOCTL_INFO 0x00010000 +#define MPI3_DEBUG_BSG_ERROR 0x00008000 +#define MPI3_DEBUG_BSG_INFO 0x00010000 #define MPI3_DEBUG_SCSI_INFO 0x00020000 #define MPI3_DEBUG 0x01000000 #define MPI3_DEBUG_SG 0x02000000 @@ -110,15 +110,15 @@ } while (0) -#define dprint_ioctl_info(ioc, fmt, ...) \ +#define dprint_bsg_info(ioc, fmt, ...) \ do { \ - if (ioc->logging_level & MPI3_DEBUG_IOCTL_INFO) \ + if (ioc->logging_level & MPI3_DEBUG_BSG_INFO) \ pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \ } while (0) -#define dprint_ioctl_err(ioc, fmt, ...) \ +#define dprint_bsg_err(ioc, fmt, ...) \ do { \ - if (ioc->logging_level & MPI3_DEBUG_IOCTL_ERROR) \ + if (ioc->logging_level & MPI3_DEBUG_BSG_ERROR) \ pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \ } while (0) diff --git a/drivers/scsi/mpi3mr/mpi3mr_fw.c b/drivers/scsi/mpi3mr/mpi3mr_fw.c index e25c02466043..480730721f50 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_fw.c +++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c @@ -297,6 +297,8 @@ mpi3mr_get_drv_cmd(struct mpi3mr_ioc *mrioc, u16 host_tag, switch (host_tag) { case MPI3MR_HOSTTAG_INITCMDS: return &mrioc->init_cmds; + case MPI3MR_HOSTTAG_BSG_CMDS: + return &mrioc->bsg_cmds; case MPI3MR_HOSTTAG_BLK_TMS: return &mrioc->host_tm_cmds; case MPI3MR_HOSTTAG_INVALID: @@ -865,10 +867,10 @@ static const struct { } mpi3mr_reset_reason_codes[] = { { MPI3MR_RESET_FROM_BRINGUP, "timeout in bringup" }, { MPI3MR_RESET_FROM_FAULT_WATCH, "fault" }, - { MPI3MR_RESET_FROM_IOCTL, "application invocation" }, + { MPI3MR_RESET_FROM_APP, "application invocation" }, { MPI3MR_RESET_FROM_EH_HOS, "error handling" }, { MPI3MR_RESET_FROM_TM_TIMEOUT, "TM timeout" }, - { MPI3MR_RESET_FROM_IOCTL_TIMEOUT, "IOCTL timeout" }, + { MPI3MR_RESET_FROM_APP_TIMEOUT, "application command timeout" }, { MPI3MR_RESET_FROM_MUR_FAILURE, "MUR failure" }, { MPI3MR_RESET_FROM_CTLR_CLEANUP, "timeout in controller cleanup" }, { MPI3MR_RESET_FROM_CIACTIV_FAULT, "component image activation fault" }, @@ -2813,6 +2815,10 @@ static int mpi3mr_alloc_reply_sense_bufs(struct mpi3mr_ioc *mrioc) if (!mrioc->init_cmds.reply) goto out_failed; + mrioc->bsg_cmds.reply = kzalloc(mrioc->reply_sz, GFP_KERNEL); + if (!mrioc->bsg_cmds.reply) + goto out_failed; + for (i = 0; i < MPI3MR_NUM_DEVRMCMD; i++) { mrioc->dev_rmhs_cmds[i].reply = kzalloc(mrioc->reply_sz, GFP_KERNEL); @@ -3948,6 +3954,8 @@ void mpi3mr_memset_buffers(struct mpi3mr_ioc *mrioc) if (mrioc->init_cmds.reply) { memset(mrioc->init_cmds.reply, 0, sizeof(*mrioc->init_cmds.reply)); + memset(mrioc->bsg_cmds.reply, 0, + sizeof(*mrioc->bsg_cmds.reply)); memset(mrioc->host_tm_cmds.reply, 0, sizeof(*mrioc->host_tm_cmds.reply)); for (i = 0; i < MPI3MR_NUM_DEVRMCMD; i++) @@ -4050,6 +4058,9 @@ void mpi3mr_free_mem(struct mpi3mr_ioc *mrioc) kfree(mrioc->init_cmds.reply); mrioc->init_cmds.reply = NULL; + kfree(mrioc->bsg_cmds.reply); + mrioc->bsg_cmds.reply = NULL; + kfree(mrioc->host_tm_cmds.reply); mrioc->host_tm_cmds.reply = NULL; @@ -4235,6 +4246,8 @@ static void mpi3mr_flush_drv_cmds(struct mpi3mr_ioc *mrioc) cmdptr = &mrioc->init_cmds; mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr); + cmdptr = &mrioc->bsg_cmds; + mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr); cmdptr = &mrioc->host_tm_cmds; mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr); @@ -4258,7 +4271,7 @@ static void mpi3mr_flush_drv_cmds(struct mpi3mr_ioc *mrioc) * This is an handler for recovering controller by issuing soft * reset are diag fault reset. This is a blocking function and * when one reset is executed if any other resets they will be - * blocked. All IOCTLs/IO will be blocked during the reset. If + * blocked. All BSG requests will be blocked during the reset. If * controller reset is successful then the controller will be * reinitalized, otherwise the controller will be marked as not * recoverable @@ -4305,6 +4318,7 @@ int mpi3mr_soft_reset_handler(struct mpi3mr_ioc *mrioc, mpi3mr_reset_rc_name(reset_reason)); mrioc->reset_in_progress = 1; + mrioc->stop_bsgs = 1; mrioc->prev_reset_result = -1; if ((!snapdump) && (reset_reason != MPI3MR_RESET_FROM_FAULT_WATCH) && @@ -4377,6 +4391,7 @@ out: &mrioc->watchdog_work, msecs_to_jiffies(MPI3MR_WATCHDOG_INTERVAL)); spin_unlock_irqrestore(&mrioc->watchdog_lock, flags); + mrioc->stop_bsgs = 0; } else { mpi3mr_issue_reset(mrioc, MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT, reset_reason); diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index faf14a5f9123..a03e39083a42 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -3589,6 +3589,7 @@ static int mpi3mr_scan_finished(struct Scsi_Host *shost, mpi3mr_start_watchdog(mrioc); mrioc->is_driver_loading = 0; + mrioc->stop_bsgs = 0; return 1; } @@ -4259,6 +4260,7 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id) mutex_init(&mrioc->reset_mutex); mpi3mr_init_drv_cmd(&mrioc->init_cmds, MPI3MR_HOSTTAG_INITCMDS); mpi3mr_init_drv_cmd(&mrioc->host_tm_cmds, MPI3MR_HOSTTAG_BLK_TMS); + mpi3mr_init_drv_cmd(&mrioc->bsg_cmds, MPI3MR_HOSTTAG_BSG_CMDS); for (i = 0; i < MPI3MR_NUM_DEVRMCMD; i++) mpi3mr_init_drv_cmd(&mrioc->dev_rmhs_cmds[i], @@ -4271,6 +4273,7 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id) mrioc->logging_level = logging_level; mrioc->shost = shost; mrioc->pdev = pdev; + mrioc->stop_bsgs = 1; /* init shost parameters */ shost->max_cmd_len = MPI3MR_MAX_CDB_LENGTH; diff --git a/include/uapi/scsi/scsi_bsg_mpi3mr.h b/include/uapi/scsi/scsi_bsg_mpi3mr.h new file mode 100644 index 000000000000..66697d963f64 --- /dev/null +++ b/include/uapi/scsi/scsi_bsg_mpi3mr.h @@ -0,0 +1,457 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later WITH Linux-syscall-note */ +/* + * Driver for Broadcom MPI3 Storage Controllers + * + * Copyright (C) 2017-2022 Broadcom Inc. + * (mailto: mpi3mr-linuxdrv.pdl@broadcom.com) + * + */ + +#ifndef SCSI_BSG_MPI3MR_H_INCLUDED +#define SCSI_BSG_MPI3MR_H_INCLUDED + +#include + +/* Definitions for BSG commands */ +#define MPI3MR_IOCTL_VERSION 0x06 + +#define MPI3MR_APP_DEFAULT_TIMEOUT (60) /*seconds*/ + +#define MPI3MR_BSG_ADPTYPE_UNKNOWN 0 +#define MPI3MR_BSG_ADPTYPE_AVGFAMILY 1 + +#define MPI3MR_BSG_ADPSTATE_UNKNOWN 0 +#define MPI3MR_BSG_ADPSTATE_OPERATIONAL 1 +#define MPI3MR_BSG_ADPSTATE_FAULT 2 +#define MPI3MR_BSG_ADPSTATE_IN_RESET 3 +#define MPI3MR_BSG_ADPSTATE_UNRECOVERABLE 4 + +#define MPI3MR_BSG_ADPRESET_UNKNOWN 0 +#define MPI3MR_BSG_ADPRESET_SOFT 1 +#define MPI3MR_BSG_ADPRESET_DIAG_FAULT 2 + +#define MPI3MR_BSG_LOGDATA_MAX_ENTRIES 400 +#define MPI3MR_BSG_LOGDATA_ENTRY_HEADER_SZ 4 + +#define MPI3MR_DRVBSG_OPCODE_UNKNOWN 0 +#define MPI3MR_DRVBSG_OPCODE_ADPINFO 1 +#define MPI3MR_DRVBSG_OPCODE_ADPRESET 2 +#define MPI3MR_DRVBSG_OPCODE_ALLTGTDEVINFO 4 +#define MPI3MR_DRVBSG_OPCODE_GETCHGCNT 5 +#define MPI3MR_DRVBSG_OPCODE_LOGDATAENABLE 6 +#define MPI3MR_DRVBSG_OPCODE_PELENABLE 7 +#define MPI3MR_DRVBSG_OPCODE_GETLOGDATA 8 +#define MPI3MR_DRVBSG_OPCODE_QUERY_HDB 9 +#define MPI3MR_DRVBSG_OPCODE_REPOST_HDB 10 +#define MPI3MR_DRVBSG_OPCODE_UPLOAD_HDB 11 +#define MPI3MR_DRVBSG_OPCODE_REFRESH_HDB_TRIGGERS 12 + + +#define MPI3MR_BSG_BUFTYPE_UNKNOWN 0 +#define MPI3MR_BSG_BUFTYPE_RAIDMGMT_CMD 1 +#define MPI3MR_BSG_BUFTYPE_RAIDMGMT_RESP 2 +#define MPI3MR_BSG_BUFTYPE_DATA_IN 3 +#define MPI3MR_BSG_BUFTYPE_DATA_OUT 4 +#define MPI3MR_BSG_BUFTYPE_MPI_REPLY 5 +#define MPI3MR_BSG_BUFTYPE_ERR_RESPONSE 6 +#define MPI3MR_BSG_BUFTYPE_MPI_REQUEST 0xFE + +#define MPI3MR_BSG_MPI_REPLY_BUFTYPE_UNKNOWN 0 +#define MPI3MR_BSG_MPI_REPLY_BUFTYPE_STATUS 1 +#define MPI3MR_BSG_MPI_REPLY_BUFTYPE_ADDRESS 2 + +#define MPI3MR_HDB_BUFTYPE_UNKNOWN 0 +#define MPI3MR_HDB_BUFTYPE_TRACE 1 +#define MPI3MR_HDB_BUFTYPE_FIRMWARE 2 +#define MPI3MR_HDB_BUFTYPE_RESERVED 3 + +#define MPI3MR_HDB_BUFSTATUS_UNKNOWN 0 +#define MPI3MR_HDB_BUFSTATUS_NOT_ALLOCATED 1 +#define MPI3MR_HDB_BUFSTATUS_POSTED_UNPAUSED 2 +#define MPI3MR_HDB_BUFSTATUS_POSTED_PAUSED 3 +#define MPI3MR_HDB_BUFSTATUS_RELEASED 4 + +#define MPI3MR_HDB_TRIGGER_TYPE_UNKNOWN 0 +#define MPI3MR_HDB_TRIGGER_TYPE_DIAGFAULT 1 +#define MPI3MR_HDB_TRIGGER_TYPE_ELEMENT 2 +#define MPI3MR_HDB_TRIGGER_TYPE_MASTER 3 + + +/* Supported BSG commands */ +enum command { + MPI3MR_DRV_CMD = 1, + MPI3MR_MPT_CMD = 2, +}; + +/** + * struct mpi3_driver_info_layout - Information about driver + * + * @information_length: Length of this structure in bytes + * @driver_signature: Driver Vendor name + * @os_name: Operating System Name + * @driver_name: Driver name + * @driver_version: Driver version + * @driver_release_date: Driver release date + * @driver_capabilities: Driver capabilities + */ +struct mpi3_driver_info_layout { + __le32 information_length; + __u8 driver_signature[12]; + __u8 os_name[16]; + __u8 os_version[12]; + __u8 driver_name[20]; + __u8 driver_version[32]; + __u8 driver_release_date[20]; + __le32 driver_capabilities; +}; + +/** + * struct mpi3mr_bsg_in_adpinfo - Adapter information request + * data returned by the driver. + * + * @adp_type: Adapter type + * @rsvd1: Reserved + * @pci_dev_id: PCI device ID of the adapter + * @pci_dev_hw_rev: PCI revision of the adapter + * @pci_subsys_dev_id: PCI subsystem device ID of the adapter + * @pci_subsys_ven_id: PCI subsystem vendor ID of the adapter + * @pci_dev: PCI device + * @pci_func: PCI function + * @pci_bus: PCI bus + * @rsvd2: Reserved + * @pci_seg_id: PCI segment ID + * @app_intfc_ver: version of the application interface definition + * @rsvd3: Reserved + * @rsvd4: Reserved + * @rsvd5: Reserved + * @driver_info: Driver Information (Version/Name) + */ +struct mpi3mr_bsg_in_adpinfo { + __u32 adp_type; + __u32 rsvd1; + __u32 pci_dev_id; + __u32 pci_dev_hw_rev; + __u32 pci_subsys_dev_id; + __u32 pci_subsys_ven_id; + __u32 pci_dev:5; + __u32 pci_func:3; + __u32 pci_bus:8; + __u16 rsvd2; + __u32 pci_seg_id; + __u32 app_intfc_ver; + __u8 adp_state; + __u8 rsvd3; + __u16 rsvd4; + __u32 rsvd5[2]; + struct mpi3_driver_info_layout driver_info; +}; + +/** + * struct mpi3mr_bsg_adp_reset - Adapter reset request + * payload data to the driver. + * + * @reset_type: Reset type + * @rsvd1: Reserved + * @rsvd2: Reserved + */ +struct mpi3mr_bsg_adp_reset { + __u8 reset_type; + __u8 rsvd1; + __u16 rsvd2; +}; + +/** + * struct mpi3mr_change_count - Topology change count + * returned by the driver. + * + * @change_count: Topology change count + * @rsvd: Reserved + */ +struct mpi3mr_change_count { + __u16 change_count; + __u16 rsvd; +}; + +/** + * struct mpi3mr_device_map_info - Target device mapping + * information + * + * @handle: Firmware device handle + * @perst_id: Persistent ID assigned by the firmware + * @target_id: Target ID assigned by the driver + * @bus_id: Bus ID assigned by the driver + * @rsvd1: Reserved + * @rsvd2: Reserved + */ +struct mpi3mr_device_map_info { + __u16 handle; + __u16 perst_id; + __u32 target_id; + __u8 bus_id; + __u8 rsvd1; + __u16 rsvd2; +}; + +/** + * struct mpi3mr_all_tgt_info - Target device mapping + * information returned by the driver + * + * @num_devices: The number of devices in driver's inventory + * @rsvd1: Reserved + * @rsvd2: Reserved + * @dmi: Variable length array of mapping information of targets + */ +struct mpi3mr_all_tgt_info { + __u16 num_devices; + __u16 rsvd1; + __u32 rsvd2; + struct mpi3mr_device_map_info dmi[1]; +}; + +/** + * struct mpi3mr_logdata_enable - Number of log data + * entries saved by the driver returned as payload data for + * enable logdata BSG request by the driver. + * + * @max_entries: Number of log data entries cached by the driver + * @rsvd: Reserved + */ +struct mpi3mr_logdata_enable { + __u16 max_entries; + __u16 rsvd; +}; + +/** + * struct mpi3mr_bsg_out_pel_enable - PEL enable request payload + * data to the driver. + * + * @pel_locale: PEL locale to the firmware + * @pel_class: PEL class to the firmware + * @rsvd: Reserved + */ +struct mpi3mr_bsg_out_pel_enable { + __u16 pel_locale; + __u8 pel_class; + __u8 rsvd; +}; + +/** + * struct mpi3mr_logdata_entry - Log data entry cached by the + * driver. + * + * @valid_entry: Is the entry valid + * @rsvd1: Reserved + * @rsvd2: Reserved + * @data: Variable length Log entry data + */ +struct mpi3mr_logdata_entry { + __u8 valid_entry; + __u8 rsvd1; + __u16 rsvd2; + __u8 data[1]; /* Variable length Array */ +}; + +/** + * struct mpi3mr_bsg_in_log_data - Log data entries saved by + * the driver returned as payload data for Get logdata request + * by the driver. + * + * @entry: Variable length Log data entry array + */ +struct mpi3mr_bsg_in_log_data { + struct mpi3mr_logdata_entry entry[1]; +}; + +/** + * struct mpi3mr_hdb_entry - host diag buffer entry. + * + * @buf_type: Buffer type + * @status: Buffer status + * @trigger_type: Trigger type + * @rsvd1: Reserved + * @size: Buffer size + * @rsvd2: Reserved + * @trigger_data: Trigger specific data + * @rsvd3: Reserved + * @rsvd4: Reserved + */ +struct mpi3mr_hdb_entry { + __u8 buf_type; + __u8 status; + __u8 trigger_type; + __u8 rsvd1; + __u16 size; + __u16 rsvd2; + __u64 trigger_data; + __u32 rsvd3; + __u32 rsvd4; +}; + + +/** + * struct mpi3mr_bsg_in_hdb_status - This structure contains + * return data for the BSG request to retrieve the number of host + * diagnostic buffers supported by the driver and their current + * status and additional status specific data if any in forms of + * multiple hdb entries. + * + * @num_hdb_types: Number of host diag buffer types supported + * @rsvd1: Reserved + * @rsvd2: Reserved + * @rsvd3: Reserved + * @entry: Variable length Diag buffer status entry array + */ +struct mpi3mr_bsg_in_hdb_status { + __u8 num_hdb_types; + __u8 rsvd1; + __u16 rsvd2; + __u32 rsvd3; + struct mpi3mr_hdb_entry entry[1]; +}; + +/** + * struct mpi3mr_bsg_out_repost_hdb - Repost host diagnostic + * buffer request payload data to the driver. + * + * @buf_type: Buffer type + * @rsvd1: Reserved + * @rsvd2: Reserved + */ +struct mpi3mr_bsg_out_repost_hdb { + __u8 buf_type; + __u8 rsvd1; + __u16 rsvd2; +}; + +/** + * struct mpi3mr_bsg_out_upload_hdb - Upload host diagnostic + * buffer request payload data to the driver. + * + * @buf_type: Buffer type + * @rsvd1: Reserved + * @rsvd2: Reserved + * @start_offset: Start offset of the buffer from where to copy + * @length: Length of the buffer to copy + */ +struct mpi3mr_bsg_out_upload_hdb { + __u8 buf_type; + __u8 rsvd1; + __u16 rsvd2; + __u32 start_offset; + __u32 length; +}; + +/** + * struct mpi3mr_bsg_out_refresh_hdb_triggers - Refresh host + * diagnostic buffer triggers request payload data to the driver. + * + * @page_type: Page type + * @rsvd1: Reserved + * @rsvd2: Reserved + */ +struct mpi3mr_bsg_out_refresh_hdb_triggers { + __u8 page_type; + __u8 rsvd1; + __u16 rsvd2; +}; +/** + * struct mpi3mr_bsg_drv_cmd - Generic bsg data + * structure for all driver specific requests. + * + * @mrioc_id: Controller ID + * @opcode: Driver specific opcode + * @rsvd1: Reserved + * @rsvd2: Reserved + */ +struct mpi3mr_bsg_drv_cmd { + __u8 mrioc_id; + __u8 opcode; + __u16 rsvd1; + __u32 rsvd2[4]; +}; +/** + * struct mpi3mr_bsg_in_reply_buf - MPI reply buffer returned + * for MPI Passthrough request . + * + * @mpi_reply_type: Type of MPI reply + * @rsvd1: Reserved + * @rsvd2: Reserved + * @reply_buf: Variable Length buffer based on mpirep type + */ +struct mpi3mr_bsg_in_reply_buf { + __u8 mpi_reply_type; + __u8 rsvd1; + __u16 rsvd2; + __u8 reply_buf[1]; +}; + +/** + * struct mpi3mr_buf_entry - User buffer descriptor for MPI + * Passthrough requests. + * + * @buf_type: Buffer type + * @rsvd1: Reserved + * @rsvd2: Reserved + * @buf_len: Buffer length + */ +struct mpi3mr_buf_entry { + __u8 buf_type; + __u8 rsvd1; + __u16 rsvd2; + __u32 buf_len; +}; +/** + * struct mpi3mr_bsg_buf_entry_list - list of user buffer + * descriptor for MPI Passthrough requests. + * + * @num_of_entries: Number of buffer descriptors + * @rsvd1: Reserved + * @rsvd2: Reserved + * @rsvd3: Reserved + * @buf_entry: Variable length array of buffer descriptors + */ +struct mpi3mr_buf_entry_list { + __u8 num_of_entries; + __u8 rsvd1; + __u16 rsvd2; + __u32 rsvd3; + struct mpi3mr_buf_entry buf_entry[1]; +}; +/** + * struct mpi3mr_bsg_mptcmd - Generic bsg data + * structure for all MPI Passthrough requests . + * + * @mrioc_id: Controller ID + * @rsvd1: Reserved + * @timeout: MPI request timeout + * @buf_entry_list: Buffer descriptor list + */ +struct mpi3mr_bsg_mptcmd { + __u8 mrioc_id; + __u8 rsvd1; + __u16 timeout; + __u32 rsvd2; + struct mpi3mr_buf_entry_list buf_entry_list; +}; + +/** + * struct mpi3mr_bsg_packet - Generic bsg data + * structure for all supported requests . + * + * @cmd_type: represents drvrcmd or mptcmd + * @rsvd1: Reserved + * @rsvd2: Reserved + * @drvrcmd: driver request structure + * @mptcmd: mpt request structure + */ +struct mpi3mr_bsg_packet { + __u8 cmd_type; + __u8 rsvd1; + __u16 rsvd2; + __u32 rsvd3; + union { + struct mpi3mr_bsg_drv_cmd drvrcmd; + struct mpi3mr_bsg_mptcmd mptcmd; + } cmd; +}; +#endif From f3de4706c1e0c3b9fa39ec24a30c1996a33bc9e4 Mon Sep 17 00:00:00 2001 From: Sumit Saxena Date: Fri, 29 Apr 2022 17:16:36 -0400 Subject: [PATCH 120/177] scsi: mpi3mr: Move data structures/definitions from MPI headers to uapi header This patch moves the data structures/definitions which are used by userspace applications from MPI headers to uapi/scsi/scsi_bsg_mpi3mr.h Link: https://lore.kernel.org/r/20220429211641.642010-4-sumit.saxena@broadcom.com Reported by: Stephen Rothwell Reviewed-by: Himanshu Madhani Signed-off-by: Sumit Saxena Signed-off-by: Martin K. Petersen --- drivers/scsi/mpi3mr/mpi/mpi30_init.h | 53 ------------ drivers/scsi/mpi3mr/mpi/mpi30_ioc.h | 17 ---- drivers/scsi/mpi3mr/mpi/mpi30_pci.h | 31 +------ drivers/scsi/mpi3mr/mpi3mr.h | 1 + include/uapi/scsi/scsi_bsg_mpi3mr.h | 117 +++++++++++++++++++++++++++ 5 files changed, 119 insertions(+), 100 deletions(-) diff --git a/drivers/scsi/mpi3mr/mpi/mpi30_init.h b/drivers/scsi/mpi3mr/mpi/mpi30_init.h index e2e8b22e9122..aac11c58cca9 100644 --- a/drivers/scsi/mpi3mr/mpi/mpi30_init.h +++ b/drivers/scsi/mpi3mr/mpi/mpi30_init.h @@ -115,57 +115,4 @@ struct mpi3_scsi_io_reply { #define MPI3_SCSI_RSP_ARI0_MASK (0xff000000) #define MPI3_SCSI_RSP_ARI0_SHIFT (24) #define MPI3_SCSI_TASKTAG_UNKNOWN (0xffff) -struct mpi3_scsi_task_mgmt_request { - __le16 host_tag; - u8 ioc_use_only02; - u8 function; - __le16 ioc_use_only04; - u8 ioc_use_only06; - u8 msg_flags; - __le16 change_count; - __le16 dev_handle; - __le16 task_host_tag; - u8 task_type; - u8 reserved0f; - __le16 task_request_queue_id; - __le16 reserved12; - __le32 reserved14; - u8 lun[8]; -}; - -#define MPI3_SCSITASKMGMT_MSGFLAGS_DO_NOT_SEND_TASK_IU (0x08) -#define MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK (0x01) -#define MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK_SET (0x02) -#define MPI3_SCSITASKMGMT_TASKTYPE_TARGET_RESET (0x03) -#define MPI3_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET (0x05) -#define MPI3_SCSITASKMGMT_TASKTYPE_CLEAR_TASK_SET (0x06) -#define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_TASK (0x07) -#define MPI3_SCSITASKMGMT_TASKTYPE_CLEAR_ACA (0x08) -#define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_TASK_SET (0x09) -#define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_ASYNC_EVENT (0x0a) -#define MPI3_SCSITASKMGMT_TASKTYPE_I_T_NEXUS_RESET (0x0b) -struct mpi3_scsi_task_mgmt_reply { - __le16 host_tag; - u8 ioc_use_only02; - u8 function; - __le16 ioc_use_only04; - u8 ioc_use_only06; - u8 msg_flags; - __le16 ioc_use_only08; - __le16 ioc_status; - __le32 ioc_log_info; - __le32 termination_count; - __le32 response_data; - __le32 reserved18; -}; - -#define MPI3_SCSITASKMGMT_RSPCODE_TM_COMPLETE (0x00) -#define MPI3_SCSITASKMGMT_RSPCODE_INVALID_FRAME (0x02) -#define MPI3_SCSITASKMGMT_RSPCODE_TM_FUNCTION_NOT_SUPPORTED (0x04) -#define MPI3_SCSITASKMGMT_RSPCODE_TM_FAILED (0x05) -#define MPI3_SCSITASKMGMT_RSPCODE_TM_SUCCEEDED (0x08) -#define MPI3_SCSITASKMGMT_RSPCODE_TM_INVALID_LUN (0x09) -#define MPI3_SCSITASKMGMT_RSPCODE_TM_OVERLAPPED_TAG (0x0a) -#define MPI3_SCSITASKMGMT_RSPCODE_IO_QUEUED_ON_IOC (0x80) -#define MPI3_SCSITASKMGMT_RSPCODE_TM_NVME_DENIED (0x81) #endif diff --git a/drivers/scsi/mpi3mr/mpi/mpi30_ioc.h b/drivers/scsi/mpi3mr/mpi/mpi30_ioc.h index 33fc05f218d6..214e4c65e576 100644 --- a/drivers/scsi/mpi3mr/mpi/mpi30_ioc.h +++ b/drivers/scsi/mpi3mr/mpi/mpi30_ioc.h @@ -637,23 +637,6 @@ struct mpi3_event_data_diag_buffer_status_change { #define MPI3_EVENT_DIAG_BUFFER_STATUS_CHANGE_RC_RELEASED (0x01) #define MPI3_EVENT_DIAG_BUFFER_STATUS_CHANGE_RC_PAUSED (0x02) #define MPI3_EVENT_DIAG_BUFFER_STATUS_CHANGE_RC_RESUMED (0x03) -#define MPI3_PEL_LOCALE_FLAGS_NON_BLOCKING_BOOT_EVENT (0x0200) -#define MPI3_PEL_LOCALE_FLAGS_BLOCKING_BOOT_EVENT (0x0100) -#define MPI3_PEL_LOCALE_FLAGS_PCIE (0x0080) -#define MPI3_PEL_LOCALE_FLAGS_CONFIGURATION (0x0040) -#define MPI3_PEL_LOCALE_FLAGS_CONTROLER (0x0020) -#define MPI3_PEL_LOCALE_FLAGS_SAS (0x0010) -#define MPI3_PEL_LOCALE_FLAGS_EPACK (0x0008) -#define MPI3_PEL_LOCALE_FLAGS_ENCLOSURE (0x0004) -#define MPI3_PEL_LOCALE_FLAGS_PD (0x0002) -#define MPI3_PEL_LOCALE_FLAGS_VD (0x0001) -#define MPI3_PEL_CLASS_DEBUG (0x00) -#define MPI3_PEL_CLASS_PROGRESS (0x01) -#define MPI3_PEL_CLASS_INFORMATIONAL (0x02) -#define MPI3_PEL_CLASS_WARNING (0x03) -#define MPI3_PEL_CLASS_CRITICAL (0x04) -#define MPI3_PEL_CLASS_FATAL (0x05) -#define MPI3_PEL_CLASS_FAULT (0x06) #define MPI3_PEL_CLEARTYPE_CLEAR (0x00) #define MPI3_PEL_WAITTIME_INFINITE_WAIT (0x00) #define MPI3_PEL_ACTION_GET_SEQNUM (0x01) diff --git a/drivers/scsi/mpi3mr/mpi/mpi30_pci.h b/drivers/scsi/mpi3mr/mpi/mpi30_pci.h index 77270f577f90..901dbd788940 100644 --- a/drivers/scsi/mpi3mr/mpi/mpi30_pci.h +++ b/drivers/scsi/mpi3mr/mpi/mpi30_pci.h @@ -5,24 +5,6 @@ */ #ifndef MPI30_PCI_H #define MPI30_PCI_H 1 -#ifndef MPI3_NVME_ENCAP_CMD_MAX -#define MPI3_NVME_ENCAP_CMD_MAX (1) -#endif -struct mpi3_nvme_encapsulated_request { - __le16 host_tag; - u8 ioc_use_only02; - u8 function; - __le16 ioc_use_only04; - u8 ioc_use_only06; - u8 msg_flags; - __le16 change_count; - __le16 dev_handle; - __le16 encapsulated_command_length; - __le16 flags; - __le32 data_length; - __le32 reserved14[3]; - __le32 command[MPI3_NVME_ENCAP_CMD_MAX]; -}; #define MPI3_NVME_FLAGS_FORCE_ADMIN_ERR_REPLY_MASK (0x0002) #define MPI3_NVME_FLAGS_FORCE_ADMIN_ERR_REPLY_FAIL_ONLY (0x0000) @@ -30,16 +12,5 @@ struct mpi3_nvme_encapsulated_request { #define MPI3_NVME_FLAGS_SUBMISSIONQ_MASK (0x0001) #define MPI3_NVME_FLAGS_SUBMISSIONQ_IO (0x0000) #define MPI3_NVME_FLAGS_SUBMISSIONQ_ADMIN (0x0001) -struct mpi3_nvme_encapsulated_error_reply { - __le16 host_tag; - u8 ioc_use_only02; - u8 function; - __le16 ioc_use_only04; - u8 ioc_use_only06; - u8 msg_flags; - __le16 ioc_use_only08; - __le16 ioc_status; - __le32 ioc_log_info; - __le32 nvme_completion_entry[4]; -}; + #endif diff --git a/drivers/scsi/mpi3mr/mpi3mr.h b/drivers/scsi/mpi3mr/mpi3mr.h index b72a1df5c136..3b85e85b11bb 100644 --- a/drivers/scsi/mpi3mr/mpi3mr.h +++ b/drivers/scsi/mpi3mr/mpi3mr.h @@ -38,6 +38,7 @@ #include #include #include +#include #include "mpi/mpi30_transport.h" #include "mpi/mpi30_cnfg.h" diff --git a/include/uapi/scsi/scsi_bsg_mpi3mr.h b/include/uapi/scsi/scsi_bsg_mpi3mr.h index 66697d963f64..b2c88d5d9c4c 100644 --- a/include/uapi/scsi/scsi_bsg_mpi3mr.h +++ b/include/uapi/scsi/scsi_bsg_mpi3mr.h @@ -454,4 +454,121 @@ struct mpi3mr_bsg_packet { struct mpi3mr_bsg_mptcmd mptcmd; } cmd; }; + + +/* MPI3: NVMe Encasulation related definitions */ +#ifndef MPI3_NVME_ENCAP_CMD_MAX +#define MPI3_NVME_ENCAP_CMD_MAX (1) +#endif + +struct mpi3_nvme_encapsulated_request { + __le16 host_tag; + __u8 ioc_use_only02; + __u8 function; + __le16 ioc_use_only04; + __u8 ioc_use_only06; + __u8 msg_flags; + __le16 change_count; + __le16 dev_handle; + __le16 encapsulated_command_length; + __le16 flags; + __le32 data_length; + __le32 reserved14[3]; + __le32 command[MPI3_NVME_ENCAP_CMD_MAX]; +}; + +struct mpi3_nvme_encapsulated_error_reply { + __le16 host_tag; + __u8 ioc_use_only02; + __u8 function; + __le16 ioc_use_only04; + __u8 ioc_use_only06; + __u8 msg_flags; + __le16 ioc_use_only08; + __le16 ioc_status; + __le32 ioc_log_info; + __le32 nvme_completion_entry[4]; +}; + +/* MPI3: task management related definitions */ +struct mpi3_scsi_task_mgmt_request { + __le16 host_tag; + __u8 ioc_use_only02; + __u8 function; + __le16 ioc_use_only04; + __u8 ioc_use_only06; + __u8 msg_flags; + __le16 change_count; + __le16 dev_handle; + __le16 task_host_tag; + __u8 task_type; + __u8 reserved0f; + __le16 task_request_queue_id; + __le16 reserved12; + __le32 reserved14; + __u8 lun[8]; +}; + +#define MPI3_SCSITASKMGMT_MSGFLAGS_DO_NOT_SEND_TASK_IU (0x08) +#define MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK (0x01) +#define MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK_SET (0x02) +#define MPI3_SCSITASKMGMT_TASKTYPE_TARGET_RESET (0x03) +#define MPI3_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET (0x05) +#define MPI3_SCSITASKMGMT_TASKTYPE_CLEAR_TASK_SET (0x06) +#define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_TASK (0x07) +#define MPI3_SCSITASKMGMT_TASKTYPE_CLEAR_ACA (0x08) +#define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_TASK_SET (0x09) +#define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_ASYNC_EVENT (0x0a) +#define MPI3_SCSITASKMGMT_TASKTYPE_I_T_NEXUS_RESET (0x0b) +struct mpi3_scsi_task_mgmt_reply { + __le16 host_tag; + __u8 ioc_use_only02; + __u8 function; + __le16 ioc_use_only04; + __u8 ioc_use_only06; + __u8 msg_flags; + __le16 ioc_use_only08; + __le16 ioc_status; + __le32 ioc_log_info; + __le32 termination_count; + __le32 response_data; + __le32 reserved18; +}; + +#define MPI3_SCSITASKMGMT_RSPCODE_TM_COMPLETE (0x00) +#define MPI3_SCSITASKMGMT_RSPCODE_INVALID_FRAME (0x02) +#define MPI3_SCSITASKMGMT_RSPCODE_TM_FUNCTION_NOT_SUPPORTED (0x04) +#define MPI3_SCSITASKMGMT_RSPCODE_TM_FAILED (0x05) +#define MPI3_SCSITASKMGMT_RSPCODE_TM_SUCCEEDED (0x08) +#define MPI3_SCSITASKMGMT_RSPCODE_TM_INVALID_LUN (0x09) +#define MPI3_SCSITASKMGMT_RSPCODE_TM_OVERLAPPED_TAG (0x0a) +#define MPI3_SCSITASKMGMT_RSPCODE_IO_QUEUED_ON_IOC (0x80) +#define MPI3_SCSITASKMGMT_RSPCODE_TM_NVME_DENIED (0x81) + +/* MPI3: PEL related definitions */ +#define MPI3_PEL_LOCALE_FLAGS_NON_BLOCKING_BOOT_EVENT (0x0200) +#define MPI3_PEL_LOCALE_FLAGS_BLOCKING_BOOT_EVENT (0x0100) +#define MPI3_PEL_LOCALE_FLAGS_PCIE (0x0080) +#define MPI3_PEL_LOCALE_FLAGS_CONFIGURATION (0x0040) +#define MPI3_PEL_LOCALE_FLAGS_CONTROLER (0x0020) +#define MPI3_PEL_LOCALE_FLAGS_SAS (0x0010) +#define MPI3_PEL_LOCALE_FLAGS_EPACK (0x0008) +#define MPI3_PEL_LOCALE_FLAGS_ENCLOSURE (0x0004) +#define MPI3_PEL_LOCALE_FLAGS_PD (0x0002) +#define MPI3_PEL_LOCALE_FLAGS_VD (0x0001) +#define MPI3_PEL_CLASS_DEBUG (0x00) +#define MPI3_PEL_CLASS_PROGRESS (0x01) +#define MPI3_PEL_CLASS_INFORMATIONAL (0x02) +#define MPI3_PEL_CLASS_WARNING (0x03) +#define MPI3_PEL_CLASS_CRITICAL (0x04) +#define MPI3_PEL_CLASS_FATAL (0x05) +#define MPI3_PEL_CLASS_FAULT (0x06) + +/* MPI3: Function definitions */ +#define MPI3_BSG_FUNCTION_MGMT_PASSTHROUGH (0x0a) +#define MPI3_BSG_FUNCTION_SCSI_IO (0x20) +#define MPI3_BSG_FUNCTION_SCSI_TASK_MGMT (0x21) +#define MPI3_BSG_FUNCTION_SMP_PASSTHROUGH (0x22) +#define MPI3_BSG_FUNCTION_NVME_ENCAPSULATED (0x24) + #endif From 506bc1a0d6ba626492c06e5632a3fbe202770fd2 Mon Sep 17 00:00:00 2001 From: Sumit Saxena Date: Fri, 29 Apr 2022 17:16:37 -0400 Subject: [PATCH 121/177] scsi: mpi3mr: Add support for MPT commands There are certain management commands which require firmware intervention. These commands are termed MPT commands. Add support for them. Link: https://lore.kernel.org/r/20220429211641.642010-5-sumit.saxena@broadcom.com Reviewed-by: Himanshu Madhani Signed-off-by: Sumit Saxena Signed-off-by: Martin K. Petersen --- drivers/scsi/mpi3mr/mpi3mr.h | 29 ++ drivers/scsi/mpi3mr/mpi3mr_app.c | 519 ++++++++++++++++++++++++++++- drivers/scsi/mpi3mr/mpi3mr_debug.h | 25 ++ drivers/scsi/mpi3mr/mpi3mr_os.c | 4 +- 4 files changed, 574 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/mpi3mr/mpi3mr.h b/drivers/scsi/mpi3mr/mpi3mr.h index 3b85e85b11bb..fb4c1286b4ea 100644 --- a/drivers/scsi/mpi3mr/mpi3mr.h +++ b/drivers/scsi/mpi3mr/mpi3mr.h @@ -189,6 +189,27 @@ extern int prot_mask; */ #define MPI3MR_MAX_APP_XFER_SECTORS (2048 + 512) +/** + * struct mpi3mr_buf_map - local structure to + * track kernel and user buffers associated with an BSG + * structure. + * + * @bsg_buf: BSG buffer virtual address + * @bsg_buf_len: BSG buffer length + * @kern_buf: Kernel buffer virtual address + * @kern_buf_len: Kernel buffer length + * @kern_buf_dma: Kernel buffer DMA address + * @data_dir: Data direction. + */ +struct mpi3mr_buf_map { + void *bsg_buf; + u32 bsg_buf_len; + void *kern_buf; + u32 kern_buf_len; + dma_addr_t kern_buf_dma; + u8 data_dir; +}; + /* IOC State definitions */ enum mpi3mr_iocstate { MRIOC_STATE_READY = 1, @@ -557,6 +578,7 @@ struct mpi3mr_sdev_priv_data { * @ioc_status: IOC status from the firmware * @ioc_loginfo:IOC log info from the firmware * @is_waiting: Is the command issued in block mode + * @is_sense: Is Sense data present * @retry_count: Retry count for retriable commands * @host_tag: Host tag used by the command * @callback: Callback for non blocking commands @@ -572,6 +594,7 @@ struct mpi3mr_drv_cmd { u16 ioc_status; u32 ioc_loginfo; u8 is_waiting; + u8 is_sense; u8 retry_count; u16 host_tag; @@ -993,5 +1016,11 @@ int mpi3mr_process_op_reply_q(struct mpi3mr_ioc *mrioc, int mpi3mr_blk_mq_poll(struct Scsi_Host *shost, unsigned int queue_num); void mpi3mr_bsg_init(struct mpi3mr_ioc *mrioc); void mpi3mr_bsg_exit(struct mpi3mr_ioc *mrioc); +int mpi3mr_issue_tm(struct mpi3mr_ioc *mrioc, u8 tm_type, + u16 handle, uint lun, u16 htag, ulong timeout, + struct mpi3mr_drv_cmd *drv_cmd, + u8 *resp_code, struct scsi_cmnd *scmd); +struct mpi3mr_tgt_dev *mpi3mr_get_tgtdev_by_handle( + struct mpi3mr_ioc *mrioc, u16 handle); #endif /*MPI3MR_H_INCLUDED*/ diff --git a/drivers/scsi/mpi3mr/mpi3mr_app.c b/drivers/scsi/mpi3mr/mpi3mr_app.c index 0dcd64c8afea..633fd91dbea0 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_app.c +++ b/drivers/scsi/mpi3mr/mpi3mr_app.c @@ -194,7 +194,6 @@ out: kfree(alltgt_info); return rval; } - /** * mpi3mr_get_change_count - Get topology change count * @mrioc: Adapter instance reference @@ -383,6 +382,521 @@ static long mpi3mr_bsg_process_drv_cmds(struct bsg_job *job) return rval; } +/** + * mpi3mr_bsg_build_sgl - SGL construction for MPI commands + * @mpi_req: MPI request + * @sgl_offset: offset to start sgl in the MPI request + * @drv_bufs: DMA address of the buffers to be placed in sgl + * @bufcnt: Number of DMA buffers + * @is_rmc: Does the buffer list has management command buffer + * @is_rmr: Does the buffer list has management response buffer + * @num_datasges: Number of data buffers in the list + * + * This function places the DMA address of the given buffers in + * proper format as SGEs in the given MPI request. + * + * Return: Nothing + */ +static void mpi3mr_bsg_build_sgl(u8 *mpi_req, uint32_t sgl_offset, + struct mpi3mr_buf_map *drv_bufs, u8 bufcnt, u8 is_rmc, + u8 is_rmr, u8 num_datasges) +{ + u8 *sgl = (mpi_req + sgl_offset), count = 0; + struct mpi3_mgmt_passthrough_request *rmgmt_req = + (struct mpi3_mgmt_passthrough_request *)mpi_req; + struct mpi3mr_buf_map *drv_buf_iter = drv_bufs; + u8 sgl_flags, sgl_flags_last; + + sgl_flags = MPI3_SGE_FLAGS_ELEMENT_TYPE_SIMPLE | + MPI3_SGE_FLAGS_DLAS_SYSTEM | MPI3_SGE_FLAGS_END_OF_BUFFER; + sgl_flags_last = sgl_flags | MPI3_SGE_FLAGS_END_OF_LIST; + + if (is_rmc) { + mpi3mr_add_sg_single(&rmgmt_req->command_sgl, + sgl_flags_last, drv_buf_iter->kern_buf_len, + drv_buf_iter->kern_buf_dma); + sgl = (u8 *)drv_buf_iter->kern_buf + drv_buf_iter->bsg_buf_len; + drv_buf_iter++; + count++; + if (is_rmr) { + mpi3mr_add_sg_single(&rmgmt_req->response_sgl, + sgl_flags_last, drv_buf_iter->kern_buf_len, + drv_buf_iter->kern_buf_dma); + drv_buf_iter++; + count++; + } else + mpi3mr_build_zero_len_sge( + &rmgmt_req->response_sgl); + } + if (!num_datasges) { + mpi3mr_build_zero_len_sge(sgl); + return; + } + for (; count < bufcnt; count++, drv_buf_iter++) { + if (drv_buf_iter->data_dir == DMA_NONE) + continue; + if (num_datasges == 1 || !is_rmc) + mpi3mr_add_sg_single(sgl, sgl_flags_last, + drv_buf_iter->kern_buf_len, drv_buf_iter->kern_buf_dma); + else + mpi3mr_add_sg_single(sgl, sgl_flags, + drv_buf_iter->kern_buf_len, drv_buf_iter->kern_buf_dma); + sgl += sizeof(struct mpi3_sge_common); + num_datasges--; + } +} + +/** + * mpi3mr_bsg_process_mpt_cmds - MPI Pass through BSG handler + * @job: BSG job reference + * + * This function is the top level handler for MPI Pass through + * command, this does basic validation of the input data buffers, + * identifies the given buffer types and MPI command, allocates + * DMAable memory for user given buffers, construstcs SGL + * properly and passes the command to the firmware. + * + * Once the MPI command is completed the driver copies the data + * if any and reply, sense information to user provided buffers. + * If the command is timed out then issues controller reset + * prior to returning. + * + * Return: 0 on success and proper error codes on failure + */ + +static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job, unsigned int *reply_payload_rcv_len) +{ + long rval = -EINVAL; + + struct mpi3mr_ioc *mrioc = NULL; + u8 *mpi_req = NULL, *sense_buff_k = NULL; + u8 mpi_msg_size = 0; + struct mpi3mr_bsg_packet *bsg_req = NULL; + struct mpi3mr_bsg_mptcmd *karg; + struct mpi3mr_buf_entry *buf_entries = NULL; + struct mpi3mr_buf_map *drv_bufs = NULL, *drv_buf_iter = NULL; + u8 count, bufcnt = 0, is_rmcb = 0, is_rmrb = 0, din_cnt = 0, dout_cnt = 0; + u8 invalid_be = 0, erb_offset = 0xFF, mpirep_offset = 0xFF, sg_entries = 0; + u8 block_io = 0, resp_code = 0; + struct mpi3_request_header *mpi_header = NULL; + struct mpi3_status_reply_descriptor *status_desc; + struct mpi3_scsi_task_mgmt_request *tm_req; + u32 erbsz = MPI3MR_SENSE_BUF_SZ, tmplen; + u16 dev_handle; + struct mpi3mr_tgt_dev *tgtdev; + struct mpi3mr_stgt_priv_data *stgt_priv = NULL; + struct mpi3mr_bsg_in_reply_buf *bsg_reply_buf = NULL; + u32 din_size = 0, dout_size = 0; + u8 *din_buf = NULL, *dout_buf = NULL; + u8 *sgl_iter = NULL, *sgl_din_iter = NULL, *sgl_dout_iter = NULL; + + bsg_req = job->request; + karg = (struct mpi3mr_bsg_mptcmd *)&bsg_req->cmd.mptcmd; + + mrioc = mpi3mr_bsg_verify_adapter(karg->mrioc_id); + if (!mrioc) + return -ENODEV; + + if (karg->timeout < MPI3MR_APP_DEFAULT_TIMEOUT) + karg->timeout = MPI3MR_APP_DEFAULT_TIMEOUT; + + mpi_req = kzalloc(MPI3MR_ADMIN_REQ_FRAME_SZ, GFP_KERNEL); + if (!mpi_req) + return -ENOMEM; + mpi_header = (struct mpi3_request_header *)mpi_req; + + bufcnt = karg->buf_entry_list.num_of_entries; + drv_bufs = kzalloc((sizeof(*drv_bufs) * bufcnt), GFP_KERNEL); + if (!drv_bufs) { + rval = -ENOMEM; + goto out; + } + + dout_buf = kzalloc(job->request_payload.payload_len, + GFP_KERNEL); + if (!dout_buf) { + rval = -ENOMEM; + goto out; + } + + din_buf = kzalloc(job->reply_payload.payload_len, + GFP_KERNEL); + if (!din_buf) { + rval = -ENOMEM; + goto out; + } + + sg_copy_to_buffer(job->request_payload.sg_list, + job->request_payload.sg_cnt, + dout_buf, job->request_payload.payload_len); + + buf_entries = karg->buf_entry_list.buf_entry; + sgl_din_iter = din_buf; + sgl_dout_iter = dout_buf; + drv_buf_iter = drv_bufs; + + for (count = 0; count < bufcnt; count++, buf_entries++, drv_buf_iter++) { + + if (sgl_dout_iter > (dout_buf + job->request_payload.payload_len)) { + dprint_bsg_err(mrioc, "%s: data_out buffer length mismatch\n", + __func__); + rval = -EINVAL; + goto out; + } + if (sgl_din_iter > (din_buf + job->reply_payload.payload_len)) { + dprint_bsg_err(mrioc, "%s: data_in buffer length mismatch\n", + __func__); + rval = -EINVAL; + goto out; + } + + switch (buf_entries->buf_type) { + case MPI3MR_BSG_BUFTYPE_RAIDMGMT_CMD: + sgl_iter = sgl_dout_iter; + sgl_dout_iter += buf_entries->buf_len; + drv_buf_iter->data_dir = DMA_TO_DEVICE; + is_rmcb = 1; + if (count != 0) + invalid_be = 1; + break; + case MPI3MR_BSG_BUFTYPE_RAIDMGMT_RESP: + sgl_iter = sgl_din_iter; + sgl_din_iter += buf_entries->buf_len; + drv_buf_iter->data_dir = DMA_FROM_DEVICE; + is_rmrb = 1; + if (count != 1 || !is_rmcb) + invalid_be = 1; + break; + case MPI3MR_BSG_BUFTYPE_DATA_IN: + sgl_iter = sgl_din_iter; + sgl_din_iter += buf_entries->buf_len; + drv_buf_iter->data_dir = DMA_FROM_DEVICE; + din_cnt++; + din_size += drv_buf_iter->bsg_buf_len; + if ((din_cnt > 1) && !is_rmcb) + invalid_be = 1; + break; + case MPI3MR_BSG_BUFTYPE_DATA_OUT: + sgl_iter = sgl_dout_iter; + sgl_dout_iter += buf_entries->buf_len; + drv_buf_iter->data_dir = DMA_TO_DEVICE; + dout_cnt++; + dout_size += drv_buf_iter->bsg_buf_len; + if ((dout_cnt > 1) && !is_rmcb) + invalid_be = 1; + break; + case MPI3MR_BSG_BUFTYPE_MPI_REPLY: + sgl_iter = sgl_din_iter; + sgl_din_iter += buf_entries->buf_len; + drv_buf_iter->data_dir = DMA_NONE; + mpirep_offset = count; + break; + case MPI3MR_BSG_BUFTYPE_ERR_RESPONSE: + sgl_iter = sgl_din_iter; + sgl_din_iter += buf_entries->buf_len; + drv_buf_iter->data_dir = DMA_NONE; + erb_offset = count; + break; + case MPI3MR_BSG_BUFTYPE_MPI_REQUEST: + sgl_iter = sgl_dout_iter; + sgl_dout_iter += buf_entries->buf_len; + drv_buf_iter->data_dir = DMA_NONE; + mpi_msg_size = buf_entries->buf_len; + if ((!mpi_msg_size || (mpi_msg_size % 4)) || + (mpi_msg_size > MPI3MR_ADMIN_REQ_FRAME_SZ)) { + dprint_bsg_err(mrioc, "%s: invalid MPI message size\n", + __func__); + rval = -EINVAL; + goto out; + } + memcpy(mpi_req, sgl_iter, buf_entries->buf_len); + break; + default: + invalid_be = 1; + break; + } + if (invalid_be) { + dprint_bsg_err(mrioc, "%s: invalid buffer entries passed\n", + __func__); + rval = -EINVAL; + goto out; + } + + drv_buf_iter->bsg_buf = sgl_iter; + drv_buf_iter->bsg_buf_len = buf_entries->buf_len; + + } + if (!is_rmcb && (dout_cnt || din_cnt)) { + sg_entries = dout_cnt + din_cnt; + if (((mpi_msg_size) + (sg_entries * + sizeof(struct mpi3_sge_common))) > MPI3MR_ADMIN_REQ_FRAME_SZ) { + dprint_bsg_err(mrioc, + "%s:%d: invalid message size passed\n", + __func__, __LINE__); + rval = -EINVAL; + goto out; + } + } + if (din_size > MPI3MR_MAX_APP_XFER_SIZE) { + dprint_bsg_err(mrioc, + "%s:%d: invalid data transfer size passed for function 0x%x din_size=%d\n", + __func__, __LINE__, mpi_header->function, din_size); + rval = -EINVAL; + goto out; + } + if (dout_size > MPI3MR_MAX_APP_XFER_SIZE) { + dprint_bsg_err(mrioc, + "%s:%d: invalid data transfer size passed for function 0x%x dout_size = %d\n", + __func__, __LINE__, mpi_header->function, dout_size); + rval = -EINVAL; + goto out; + } + + drv_buf_iter = drv_bufs; + for (count = 0; count < bufcnt; count++, drv_buf_iter++) { + if (drv_buf_iter->data_dir == DMA_NONE) + continue; + + drv_buf_iter->kern_buf_len = drv_buf_iter->bsg_buf_len; + if (is_rmcb && !count) + drv_buf_iter->kern_buf_len += ((dout_cnt + din_cnt) * + sizeof(struct mpi3_sge_common)); + + if (!drv_buf_iter->kern_buf_len) + continue; + + drv_buf_iter->kern_buf = dma_alloc_coherent(&mrioc->pdev->dev, + drv_buf_iter->kern_buf_len, &drv_buf_iter->kern_buf_dma, + GFP_KERNEL); + if (!drv_buf_iter->kern_buf) { + rval = -ENOMEM; + goto out; + } + if (drv_buf_iter->data_dir == DMA_TO_DEVICE) { + tmplen = min(drv_buf_iter->kern_buf_len, + drv_buf_iter->bsg_buf_len); + memcpy(drv_buf_iter->kern_buf, drv_buf_iter->bsg_buf, tmplen); + } + } + + if (erb_offset != 0xFF) { + sense_buff_k = kzalloc(erbsz, GFP_KERNEL); + if (!sense_buff_k) { + rval = -ENOMEM; + goto out; + } + } + + if (mutex_lock_interruptible(&mrioc->bsg_cmds.mutex)) { + rval = -ERESTARTSYS; + goto out; + } + if (mrioc->bsg_cmds.state & MPI3MR_CMD_PENDING) { + rval = -EAGAIN; + dprint_bsg_err(mrioc, "%s: command is in use\n", __func__); + mutex_unlock(&mrioc->bsg_cmds.mutex); + goto out; + } + if (mrioc->unrecoverable) { + dprint_bsg_err(mrioc, "%s: unrecoverable controller\n", + __func__); + rval = -EFAULT; + mutex_unlock(&mrioc->bsg_cmds.mutex); + goto out; + } + if (mrioc->reset_in_progress) { + dprint_bsg_err(mrioc, "%s: reset in progress\n", __func__); + rval = -EAGAIN; + mutex_unlock(&mrioc->bsg_cmds.mutex); + goto out; + } + if (mrioc->stop_bsgs) { + dprint_bsg_err(mrioc, "%s: bsgs are blocked\n", __func__); + rval = -EAGAIN; + mutex_unlock(&mrioc->bsg_cmds.mutex); + goto out; + } + + if (mpi_header->function != MPI3_BSG_FUNCTION_NVME_ENCAPSULATED) { + mpi3mr_bsg_build_sgl(mpi_req, (mpi_msg_size), + drv_bufs, bufcnt, is_rmcb, is_rmrb, + (dout_cnt + din_cnt)); + } + + if (mpi_header->function == MPI3_BSG_FUNCTION_SCSI_TASK_MGMT) { + tm_req = (struct mpi3_scsi_task_mgmt_request *)mpi_req; + if (tm_req->task_type != + MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK) { + dev_handle = tm_req->dev_handle; + block_io = 1; + } + } + if (block_io) { + tgtdev = mpi3mr_get_tgtdev_by_handle(mrioc, dev_handle); + if (tgtdev && tgtdev->starget && tgtdev->starget->hostdata) { + stgt_priv = (struct mpi3mr_stgt_priv_data *) + tgtdev->starget->hostdata; + atomic_inc(&stgt_priv->block_io); + mpi3mr_tgtdev_put(tgtdev); + } + } + + mrioc->bsg_cmds.state = MPI3MR_CMD_PENDING; + mrioc->bsg_cmds.is_waiting = 1; + mrioc->bsg_cmds.callback = NULL; + mrioc->bsg_cmds.is_sense = 0; + mrioc->bsg_cmds.sensebuf = sense_buff_k; + memset(mrioc->bsg_cmds.reply, 0, mrioc->reply_sz); + mpi_header->host_tag = cpu_to_le16(MPI3MR_HOSTTAG_BSG_CMDS); + if (mrioc->logging_level & MPI3_DEBUG_BSG_INFO) { + dprint_bsg_info(mrioc, + "%s: posting bsg request to the controller\n", __func__); + dprint_dump(mpi_req, MPI3MR_ADMIN_REQ_FRAME_SZ, + "bsg_mpi3_req"); + if (mpi_header->function == MPI3_BSG_FUNCTION_MGMT_PASSTHROUGH) { + drv_buf_iter = &drv_bufs[0]; + dprint_dump(drv_buf_iter->kern_buf, + drv_buf_iter->kern_buf_len, "mpi3_mgmt_req"); + } + } + + init_completion(&mrioc->bsg_cmds.done); + rval = mpi3mr_admin_request_post(mrioc, mpi_req, + MPI3MR_ADMIN_REQ_FRAME_SZ, 0); + + + if (rval) { + mrioc->bsg_cmds.is_waiting = 0; + dprint_bsg_err(mrioc, + "%s: posting bsg request is failed\n", __func__); + rval = -EAGAIN; + goto out_unlock; + } + wait_for_completion_timeout(&mrioc->bsg_cmds.done, + (karg->timeout * HZ)); + if (block_io && stgt_priv) + atomic_dec(&stgt_priv->block_io); + if (!(mrioc->bsg_cmds.state & MPI3MR_CMD_COMPLETE)) { + mrioc->bsg_cmds.is_waiting = 0; + rval = -EAGAIN; + if (mrioc->bsg_cmds.state & MPI3MR_CMD_RESET) + goto out_unlock; + dprint_bsg_err(mrioc, + "%s: bsg request timedout after %d seconds\n", __func__, + karg->timeout); + if (mrioc->logging_level & MPI3_DEBUG_BSG_ERROR) { + dprint_dump(mpi_req, MPI3MR_ADMIN_REQ_FRAME_SZ, + "bsg_mpi3_req"); + if (mpi_header->function == + MPI3_BSG_FUNCTION_MGMT_PASSTHROUGH) { + drv_buf_iter = &drv_bufs[0]; + dprint_dump(drv_buf_iter->kern_buf, + drv_buf_iter->kern_buf_len, "mpi3_mgmt_req"); + } + } + + if (mpi_header->function == MPI3_BSG_FUNCTION_SCSI_IO) + mpi3mr_issue_tm(mrioc, + MPI3_SCSITASKMGMT_TASKTYPE_TARGET_RESET, + mpi_header->function_dependent, 0, + MPI3MR_HOSTTAG_BLK_TMS, MPI3MR_RESETTM_TIMEOUT, + &mrioc->host_tm_cmds, &resp_code, NULL); + if (!(mrioc->bsg_cmds.state & MPI3MR_CMD_COMPLETE) && + !(mrioc->bsg_cmds.state & MPI3MR_CMD_RESET)) + mpi3mr_soft_reset_handler(mrioc, + MPI3MR_RESET_FROM_APP_TIMEOUT, 1); + goto out_unlock; + } + dprint_bsg_info(mrioc, "%s: bsg request is completed\n", __func__); + + if ((mrioc->bsg_cmds.ioc_status & MPI3_IOCSTATUS_STATUS_MASK) + != MPI3_IOCSTATUS_SUCCESS) { + dprint_bsg_info(mrioc, + "%s: command failed, ioc_status(0x%04x) log_info(0x%08x)\n", + __func__, + (mrioc->bsg_cmds.ioc_status & MPI3_IOCSTATUS_STATUS_MASK), + mrioc->bsg_cmds.ioc_loginfo); + } + + if ((mpirep_offset != 0xFF) && + drv_bufs[mpirep_offset].bsg_buf_len) { + drv_buf_iter = &drv_bufs[mpirep_offset]; + drv_buf_iter->kern_buf_len = (sizeof(*bsg_reply_buf) - 1 + + mrioc->reply_sz); + bsg_reply_buf = kzalloc(drv_buf_iter->kern_buf_len, GFP_KERNEL); + + if (!bsg_reply_buf) { + rval = -ENOMEM; + goto out_unlock; + } + if (mrioc->bsg_cmds.state & MPI3MR_CMD_REPLY_VALID) { + bsg_reply_buf->mpi_reply_type = + MPI3MR_BSG_MPI_REPLY_BUFTYPE_ADDRESS; + memcpy(bsg_reply_buf->reply_buf, + mrioc->bsg_cmds.reply, mrioc->reply_sz); + } else { + bsg_reply_buf->mpi_reply_type = + MPI3MR_BSG_MPI_REPLY_BUFTYPE_STATUS; + status_desc = (struct mpi3_status_reply_descriptor *) + bsg_reply_buf->reply_buf; + status_desc->ioc_status = mrioc->bsg_cmds.ioc_status; + status_desc->ioc_log_info = mrioc->bsg_cmds.ioc_loginfo; + } + tmplen = min(drv_buf_iter->kern_buf_len, + drv_buf_iter->bsg_buf_len); + memcpy(drv_buf_iter->bsg_buf, bsg_reply_buf, tmplen); + } + + if (erb_offset != 0xFF && mrioc->bsg_cmds.sensebuf && + mrioc->bsg_cmds.is_sense) { + drv_buf_iter = &drv_bufs[erb_offset]; + tmplen = min(erbsz, drv_buf_iter->bsg_buf_len); + memcpy(drv_buf_iter->bsg_buf, sense_buff_k, tmplen); + } + + drv_buf_iter = drv_bufs; + for (count = 0; count < bufcnt; count++, drv_buf_iter++) { + if (drv_buf_iter->data_dir == DMA_NONE) + continue; + if (drv_buf_iter->data_dir == DMA_FROM_DEVICE) { + tmplen = min(drv_buf_iter->kern_buf_len, + drv_buf_iter->bsg_buf_len); + memcpy(drv_buf_iter->bsg_buf, + drv_buf_iter->kern_buf, tmplen); + } + } + +out_unlock: + if (din_buf) { + *reply_payload_rcv_len = + sg_copy_from_buffer(job->reply_payload.sg_list, + job->reply_payload.sg_cnt, + din_buf, job->reply_payload.payload_len); + } + mrioc->bsg_cmds.is_sense = 0; + mrioc->bsg_cmds.sensebuf = NULL; + mrioc->bsg_cmds.state = MPI3MR_CMD_NOTUSED; + mutex_unlock(&mrioc->bsg_cmds.mutex); +out: + kfree(sense_buff_k); + kfree(dout_buf); + kfree(din_buf); + kfree(mpi_req); + if (drv_bufs) { + drv_buf_iter = drv_bufs; + for (count = 0; count < bufcnt; count++, drv_buf_iter++) { + if (drv_buf_iter->kern_buf && drv_buf_iter->kern_buf_dma) + dma_free_coherent(&mrioc->pdev->dev, + drv_buf_iter->kern_buf_len, + drv_buf_iter->kern_buf, + drv_buf_iter->kern_buf_dma); + } + kfree(drv_bufs); + } + kfree(bsg_reply_buf); + return rval; +} + /** * mpi3mr_bsg_request - bsg request entry point * @job: BSG job reference @@ -402,6 +916,9 @@ static int mpi3mr_bsg_request(struct bsg_job *job) case MPI3MR_DRV_CMD: rval = mpi3mr_bsg_process_drv_cmds(job); break; + case MPI3MR_MPT_CMD: + rval = mpi3mr_bsg_process_mpt_cmds(job, &reply_payload_rcv_len); + break; default: pr_err("%s: unsupported BSG command(0x%08x)\n", MPI3MR_DRIVER_NAME, bsg_req->cmd_type); diff --git a/drivers/scsi/mpi3mr/mpi3mr_debug.h b/drivers/scsi/mpi3mr/mpi3mr_debug.h index 65bfac72948c..2464c400a5a4 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_debug.h +++ b/drivers/scsi/mpi3mr/mpi3mr_debug.h @@ -124,6 +124,31 @@ #endif /* MPT3SAS_DEBUG_H_INCLUDED */ +/** + * dprint_dump - print contents of a memory buffer + * @req: Pointer to a memory buffer + * @sz: Memory buffer size + * @namestr: Name String to identify the buffer type + */ +static inline void +dprint_dump(void *req, int sz, const char *name_string) +{ + int i; + __le32 *mfp = (__le32 *)req; + + sz = sz/4; + if (name_string) + pr_info("%s:\n\t", name_string); + else + pr_info("request:\n\t"); + for (i = 0; i < sz; i++) { + if (i && ((i % 8) == 0)) + pr_info("\n\t"); + pr_info("%08x ", le32_to_cpu(mfp[i])); + } + pr_info("\n"); +} + /** * dprint_dump_req - print message frame contents * @req: pointer to message frame diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index a03e39083a42..450574fc1fec 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -634,7 +634,7 @@ found_tgtdev: * * Return: Target device reference. */ -static struct mpi3mr_tgt_dev *mpi3mr_get_tgtdev_by_handle( +struct mpi3mr_tgt_dev *mpi3mr_get_tgtdev_by_handle( struct mpi3mr_ioc *mrioc, u16 handle) { struct mpi3mr_tgt_dev *tgtdev; @@ -2996,7 +2996,7 @@ inline void mpi3mr_poll_pend_io_completions(struct mpi3mr_ioc *mrioc) * * Return: 0 on success, non-zero on errors */ -static int mpi3mr_issue_tm(struct mpi3mr_ioc *mrioc, u8 tm_type, +int mpi3mr_issue_tm(struct mpi3mr_ioc *mrioc, u8 tm_type, u16 handle, uint lun, u16 htag, ulong timeout, struct mpi3mr_drv_cmd *drv_cmd, u8 *resp_code, struct scsi_cmnd *scmd) From 43ca110050988c7a0e581d24ce212ef34a4cdf29 Mon Sep 17 00:00:00 2001 From: Sumit Saxena Date: Fri, 29 Apr 2022 17:16:38 -0400 Subject: [PATCH 122/177] scsi: mpi3mr: Add support for PEL commands Implement driver support for management applications to enable persistent event log (PEL) notifications. Upon receipt of events, the driver will increment a sysfs variable named event_counter. The management application will poll for event_counter value changes and signal the application about events. Link: https://lore.kernel.org/r/20220429211641.642010-6-sumit.saxena@broadcom.com Reviewed-by: Himanshu Madhani Signed-off-by: Sumit Saxena Signed-off-by: Martin K. Petersen --- drivers/scsi/mpi3mr/mpi3mr.h | 36 +++- drivers/scsi/mpi3mr/mpi3mr_app.c | 205 ++++++++++++++++++++ drivers/scsi/mpi3mr/mpi3mr_fw.c | 310 +++++++++++++++++++++++++++++++ drivers/scsi/mpi3mr/mpi3mr_os.c | 42 +++++ 4 files changed, 592 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/mpi3mr/mpi3mr.h b/drivers/scsi/mpi3mr/mpi3mr.h index fb4c1286b4ea..ad1270cba280 100644 --- a/drivers/scsi/mpi3mr/mpi3mr.h +++ b/drivers/scsi/mpi3mr/mpi3mr.h @@ -53,6 +53,7 @@ extern spinlock_t mrioc_list_lock; extern struct list_head mrioc_list; extern int prot_mask; +extern atomic64_t event_counter; #define MPI3MR_DRIVER_VERSION "8.0.0.68.0" #define MPI3MR_DRIVER_RELDATE "10-February-2022" @@ -91,6 +92,8 @@ extern int prot_mask; #define MPI3MR_HOSTTAG_INVALID 0xFFFF #define MPI3MR_HOSTTAG_INITCMDS 1 #define MPI3MR_HOSTTAG_BSG_CMDS 2 +#define MPI3MR_HOSTTAG_PEL_ABORT 3 +#define MPI3MR_HOSTTAG_PEL_WAIT 4 #define MPI3MR_HOSTTAG_BLK_TMS 5 #define MPI3MR_NUM_DEVRMCMD 16 @@ -152,6 +155,7 @@ extern int prot_mask; /* Command retry count definitions */ #define MPI3MR_DEV_RMHS_RETRY_COUNT 3 +#define MPI3MR_PEL_RETRY_COUNT 3 /* Default target device queue depth */ #define MPI3MR_DEFAULT_SDEV_QD 32 @@ -748,6 +752,16 @@ struct scmd_priv { * @current_event: Firmware event currently in process * @driver_info: Driver, Kernel, OS information to firmware * @change_count: Topology change count + * @pel_enabled: Persistent Event Log(PEL) enabled or not + * @pel_abort_requested: PEL abort is requested or not + * @pel_class: PEL Class identifier + * @pel_locale: PEL Locale identifier + * @pel_cmds: Command tracker for PEL wait command + * @pel_abort_cmd: Command tracker for PEL abort command + * @pel_newest_seqnum: Newest PEL sequenece number + * @pel_seqnum_virt: PEL sequence number virtual address + * @pel_seqnum_dma: PEL sequence number DMA address + * @pel_seqnum_sz: PEL sequenece number size * @op_reply_q_offset: Operational reply queue offset with MSIx * @default_qcount: Total Default queues * @active_poll_qcount: Currently active poll queue count @@ -894,8 +908,20 @@ struct mpi3mr_ioc { struct mpi3mr_fwevt *current_event; struct mpi3_driver_info_layout driver_info; u16 change_count; - u16 op_reply_q_offset; + u8 pel_enabled; + u8 pel_abort_requested; + u8 pel_class; + u16 pel_locale; + struct mpi3mr_drv_cmd pel_cmds; + struct mpi3mr_drv_cmd pel_abort_cmd; + + u32 pel_newest_seqnum; + void *pel_seqnum_virt; + dma_addr_t pel_seqnum_dma; + u32 pel_seqnum_sz; + + u16 op_reply_q_offset; u16 default_qcount; u16 active_poll_qcount; u16 requested_poll_qcount; @@ -918,6 +944,7 @@ struct mpi3mr_ioc { * @send_ack: Event acknowledgment required or not * @process_evt: Bottomhalf processing required or not * @evt_ctx: Event context to send in Ack + * @event_data_size: size of the event data in bytes * @pending_at_sml: waiting for device add/remove API to complete * @discard: discard this event * @ref_count: kref count @@ -931,6 +958,7 @@ struct mpi3mr_fwevt { bool send_ack; bool process_evt; u32 evt_ctx; + u16 event_data_size; bool pending_at_sml; bool discard; struct kref ref_count; @@ -1022,5 +1050,11 @@ int mpi3mr_issue_tm(struct mpi3mr_ioc *mrioc, u8 tm_type, u8 *resp_code, struct scsi_cmnd *scmd); struct mpi3mr_tgt_dev *mpi3mr_get_tgtdev_by_handle( struct mpi3mr_ioc *mrioc, u16 handle); +void mpi3mr_pel_get_seqnum_complete(struct mpi3mr_ioc *mrioc, + struct mpi3mr_drv_cmd *drv_cmd); +int mpi3mr_pel_get_seqnum_post(struct mpi3mr_ioc *mrioc, + struct mpi3mr_drv_cmd *drv_cmd); +void mpi3mr_app_save_logdata(struct mpi3mr_ioc *mrioc, char *event_data, + u16 event_data_size); #endif /*MPI3MR_H_INCLUDED*/ diff --git a/drivers/scsi/mpi3mr/mpi3mr_app.c b/drivers/scsi/mpi3mr/mpi3mr_app.c index 633fd91dbea0..06a1e950bec4 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_app.c +++ b/drivers/scsi/mpi3mr/mpi3mr_app.c @@ -11,6 +11,95 @@ #include #include +/** + * mpi3mr_bsg_pel_abort - sends PEL abort request + * @mrioc: Adapter instance reference + * + * This function sends PEL abort request to the firmware through + * admin request queue. + * + * Return: 0 on success, -1 on failure + */ +static int mpi3mr_bsg_pel_abort(struct mpi3mr_ioc *mrioc) +{ + struct mpi3_pel_req_action_abort pel_abort_req; + struct mpi3_pel_reply *pel_reply; + int retval = 0; + u16 pe_log_status; + + if (mrioc->reset_in_progress) { + dprint_bsg_err(mrioc, "%s: reset in progress\n", __func__); + return -1; + } + if (mrioc->stop_bsgs) { + dprint_bsg_err(mrioc, "%s: bsgs are blocked\n", __func__); + return -1; + } + + memset(&pel_abort_req, 0, sizeof(pel_abort_req)); + mutex_lock(&mrioc->pel_abort_cmd.mutex); + if (mrioc->pel_abort_cmd.state & MPI3MR_CMD_PENDING) { + dprint_bsg_err(mrioc, "%s: command is in use\n", __func__); + mutex_unlock(&mrioc->pel_abort_cmd.mutex); + return -1; + } + mrioc->pel_abort_cmd.state = MPI3MR_CMD_PENDING; + mrioc->pel_abort_cmd.is_waiting = 1; + mrioc->pel_abort_cmd.callback = NULL; + pel_abort_req.host_tag = cpu_to_le16(MPI3MR_HOSTTAG_PEL_ABORT); + pel_abort_req.function = MPI3_FUNCTION_PERSISTENT_EVENT_LOG; + pel_abort_req.action = MPI3_PEL_ACTION_ABORT; + pel_abort_req.abort_host_tag = cpu_to_le16(MPI3MR_HOSTTAG_PEL_WAIT); + + mrioc->pel_abort_requested = 1; + init_completion(&mrioc->pel_abort_cmd.done); + retval = mpi3mr_admin_request_post(mrioc, &pel_abort_req, + sizeof(pel_abort_req), 0); + if (retval) { + retval = -1; + dprint_bsg_err(mrioc, "%s: admin request post failed\n", + __func__); + mrioc->pel_abort_requested = 0; + goto out_unlock; + } + + wait_for_completion_timeout(&mrioc->pel_abort_cmd.done, + (MPI3MR_INTADMCMD_TIMEOUT * HZ)); + if (!(mrioc->pel_abort_cmd.state & MPI3MR_CMD_COMPLETE)) { + mrioc->pel_abort_cmd.is_waiting = 0; + dprint_bsg_err(mrioc, "%s: command timedout\n", __func__); + if (!(mrioc->pel_abort_cmd.state & MPI3MR_CMD_RESET)) + mpi3mr_soft_reset_handler(mrioc, + MPI3MR_RESET_FROM_PELABORT_TIMEOUT, 1); + retval = -1; + goto out_unlock; + } + if ((mrioc->pel_abort_cmd.ioc_status & MPI3_IOCSTATUS_STATUS_MASK) + != MPI3_IOCSTATUS_SUCCESS) { + dprint_bsg_err(mrioc, + "%s: command failed, ioc_status(0x%04x) log_info(0x%08x)\n", + __func__, (mrioc->pel_abort_cmd.ioc_status & + MPI3_IOCSTATUS_STATUS_MASK), + mrioc->pel_abort_cmd.ioc_loginfo); + retval = -1; + goto out_unlock; + } + if (mrioc->pel_abort_cmd.state & MPI3MR_CMD_REPLY_VALID) { + pel_reply = (struct mpi3_pel_reply *)mrioc->pel_abort_cmd.reply; + pe_log_status = le16_to_cpu(pel_reply->pe_log_status); + if (pe_log_status != MPI3_PEL_STATUS_SUCCESS) { + dprint_bsg_err(mrioc, + "%s: command failed, pel_status(0x%04x)\n", + __func__, pe_log_status); + retval = -1; + } + } + +out_unlock: + mrioc->pel_abort_cmd.state = MPI3MR_CMD_NOTUSED; + mutex_unlock(&mrioc->pel_abort_cmd.mutex); + return retval; +} /** * mpi3mr_bsg_verify_adapter - verify adapter number is valid * @ioc_number: Adapter number @@ -107,6 +196,87 @@ static long mpi3mr_get_logdata(struct mpi3mr_ioc *mrioc, return -EINVAL; } +/** + * mpi3mr_bsg_pel_enable - Handler for PEL enable driver + * @mrioc: Adapter instance reference + * @job: BSG job pointer + * + * This function is the handler for PEL enable driver. + * Validates the application given class and locale and if + * requires aborts the existing PEL wait request and/or issues + * new PEL wait request to the firmware and returns. + * + * Return: 0 on success and proper error codes on failure. + */ +static long mpi3mr_bsg_pel_enable(struct mpi3mr_ioc *mrioc, + struct bsg_job *job) +{ + long rval = -EINVAL; + struct mpi3mr_bsg_out_pel_enable pel_enable; + u8 issue_pel_wait; + u8 tmp_class; + u16 tmp_locale; + + if (job->request_payload.payload_len != sizeof(pel_enable)) { + dprint_bsg_err(mrioc, "%s: invalid size argument\n", + __func__); + return rval; + } + + sg_copy_to_buffer(job->request_payload.sg_list, + job->request_payload.sg_cnt, + &pel_enable, sizeof(pel_enable)); + + if (pel_enable.pel_class > MPI3_PEL_CLASS_FAULT) { + dprint_bsg_err(mrioc, "%s: out of range class %d sent\n", + __func__, pel_enable.pel_class); + rval = 0; + goto out; + } + if (!mrioc->pel_enabled) + issue_pel_wait = 1; + else { + if ((mrioc->pel_class <= pel_enable.pel_class) && + !((mrioc->pel_locale & pel_enable.pel_locale) ^ + pel_enable.pel_locale)) { + issue_pel_wait = 0; + rval = 0; + } else { + pel_enable.pel_locale |= mrioc->pel_locale; + + if (mrioc->pel_class < pel_enable.pel_class) + pel_enable.pel_class = mrioc->pel_class; + + rval = mpi3mr_bsg_pel_abort(mrioc); + if (rval) { + dprint_bsg_err(mrioc, + "%s: pel_abort failed, status(%ld)\n", + __func__, rval); + goto out; + } + issue_pel_wait = 1; + } + } + if (issue_pel_wait) { + tmp_class = mrioc->pel_class; + tmp_locale = mrioc->pel_locale; + mrioc->pel_class = pel_enable.pel_class; + mrioc->pel_locale = pel_enable.pel_locale; + mrioc->pel_enabled = 1; + rval = mpi3mr_pel_get_seqnum_post(mrioc, NULL); + if (rval) { + mrioc->pel_class = tmp_class; + mrioc->pel_locale = tmp_locale; + mrioc->pel_enabled = 0; + dprint_bsg_err(mrioc, + "%s: pel get sequence number failed, status(%ld)\n", + __func__, rval); + } + } + +out: + return rval; +} /** * mpi3mr_get_all_tgt_info - Get all target information * @mrioc: Adapter instance reference @@ -372,6 +542,9 @@ static long mpi3mr_bsg_process_drv_cmds(struct bsg_job *job) case MPI3MR_DRVBSG_OPCODE_GETLOGDATA: rval = mpi3mr_get_logdata(mrioc, job); break; + case MPI3MR_DRVBSG_OPCODE_PELENABLE: + rval = mpi3mr_bsg_pel_enable(mrioc, job); + break; case MPI3MR_DRVBSG_OPCODE_UNKNOWN: default: pr_err("%s: unsupported driver command opcode %d\n", @@ -897,6 +1070,38 @@ out: return rval; } +/** + * mpi3mr_app_save_logdata - Save Log Data events + * @mrioc: Adapter instance reference + * @event_data: event data associated with log data event + * @event_data_size: event data size to copy + * + * If log data event caching is enabled by the applicatiobns, + * then this function saves the log data in the circular queue + * and Sends async signal SIGIO to indicate there is an async + * event from the firmware to the event monitoring applications. + * + * Return:Nothing + */ +void mpi3mr_app_save_logdata(struct mpi3mr_ioc *mrioc, char *event_data, + u16 event_data_size) +{ + u32 index = mrioc->logdata_buf_idx, sz; + struct mpi3mr_logdata_entry *entry; + + if (!(mrioc->logdata_buf)) + return; + + entry = (struct mpi3mr_logdata_entry *) + (mrioc->logdata_buf + (index * mrioc->logdata_entry_sz)); + entry->valid_entry = 1; + sz = min(mrioc->logdata_entry_sz, event_data_size); + memcpy(entry->data, event_data, sz); + mrioc->logdata_buf_idx = + ((++index) % MPI3MR_BSG_LOGDATA_MAX_ENTRIES); + atomic64_inc(&event_counter); +} + /** * mpi3mr_bsg_request - bsg request entry point * @job: BSG job reference diff --git a/drivers/scsi/mpi3mr/mpi3mr_fw.c b/drivers/scsi/mpi3mr/mpi3mr_fw.c index 480730721f50..74e09727a1b8 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_fw.c +++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c @@ -15,6 +15,8 @@ mpi3mr_issue_reset(struct mpi3mr_ioc *mrioc, u16 reset_type, u32 reset_reason); static int mpi3mr_setup_admin_qpair(struct mpi3mr_ioc *mrioc); static void mpi3mr_process_factsdata(struct mpi3mr_ioc *mrioc, struct mpi3_ioc_facts_data *facts_data); +static void mpi3mr_pel_wait_complete(struct mpi3mr_ioc *mrioc, + struct mpi3mr_drv_cmd *drv_cmd); static int poll_queues; module_param(poll_queues, int, 0444); @@ -301,6 +303,10 @@ mpi3mr_get_drv_cmd(struct mpi3mr_ioc *mrioc, u16 host_tag, return &mrioc->bsg_cmds; case MPI3MR_HOSTTAG_BLK_TMS: return &mrioc->host_tm_cmds; + case MPI3MR_HOSTTAG_PEL_ABORT: + return &mrioc->pel_abort_cmd; + case MPI3MR_HOSTTAG_PEL_WAIT: + return &mrioc->pel_cmds; case MPI3MR_HOSTTAG_INVALID: if (def_reply && def_reply->function == MPI3_FUNCTION_EVENT_NOTIFICATION) @@ -2837,6 +2843,14 @@ static int mpi3mr_alloc_reply_sense_bufs(struct mpi3mr_ioc *mrioc) if (!mrioc->host_tm_cmds.reply) goto out_failed; + mrioc->pel_cmds.reply = kzalloc(mrioc->reply_sz, GFP_KERNEL); + if (!mrioc->pel_cmds.reply) + goto out_failed; + + mrioc->pel_abort_cmd.reply = kzalloc(mrioc->reply_sz, GFP_KERNEL); + if (!mrioc->pel_abort_cmd.reply) + goto out_failed; + mrioc->dev_handle_bitmap_sz = mrioc->facts.max_devhandle / 8; if (mrioc->facts.max_devhandle % 8) mrioc->dev_handle_bitmap_sz++; @@ -3734,6 +3748,16 @@ retry_init: goto out_failed; } + if (!mrioc->pel_seqnum_virt) { + dprint_init(mrioc, "allocating memory for pel_seqnum_virt\n"); + mrioc->pel_seqnum_sz = sizeof(struct mpi3_pel_seq); + mrioc->pel_seqnum_virt = dma_alloc_coherent(&mrioc->pdev->dev, + mrioc->pel_seqnum_sz, &mrioc->pel_seqnum_dma, + GFP_KERNEL); + if (!mrioc->pel_seqnum_virt) + goto out_failed_noretry; + } + retval = mpi3mr_enable_events(mrioc); if (retval) { ioc_err(mrioc, "failed to enable events %d\n", @@ -3843,6 +3867,16 @@ retry_init: goto out_failed; } + if (!mrioc->pel_seqnum_virt) { + dprint_reset(mrioc, "allocating memory for pel_seqnum_virt\n"); + mrioc->pel_seqnum_sz = sizeof(struct mpi3_pel_seq); + mrioc->pel_seqnum_virt = dma_alloc_coherent(&mrioc->pdev->dev, + mrioc->pel_seqnum_sz, &mrioc->pel_seqnum_dma, + GFP_KERNEL); + if (!mrioc->pel_seqnum_virt) + goto out_failed_noretry; + } + if (mrioc->shost->nr_hw_queues > mrioc->num_op_reply_q) { ioc_err(mrioc, "cannot create minimum number of operational queues expected:%d created:%d\n", @@ -3958,6 +3992,10 @@ void mpi3mr_memset_buffers(struct mpi3mr_ioc *mrioc) sizeof(*mrioc->bsg_cmds.reply)); memset(mrioc->host_tm_cmds.reply, 0, sizeof(*mrioc->host_tm_cmds.reply)); + memset(mrioc->pel_cmds.reply, 0, + sizeof(*mrioc->pel_cmds.reply)); + memset(mrioc->pel_abort_cmd.reply, 0, + sizeof(*mrioc->pel_abort_cmd.reply)); for (i = 0; i < MPI3MR_NUM_DEVRMCMD; i++) memset(mrioc->dev_rmhs_cmds[i].reply, 0, sizeof(*mrioc->dev_rmhs_cmds[i].reply)); @@ -4064,6 +4102,12 @@ void mpi3mr_free_mem(struct mpi3mr_ioc *mrioc) kfree(mrioc->host_tm_cmds.reply); mrioc->host_tm_cmds.reply = NULL; + kfree(mrioc->pel_cmds.reply); + mrioc->pel_cmds.reply = NULL; + + kfree(mrioc->pel_abort_cmd.reply); + mrioc->pel_abort_cmd.reply = NULL; + for (i = 0; i < MPI3MR_NUM_EVTACKCMD; i++) { kfree(mrioc->evtack_cmds[i].reply); mrioc->evtack_cmds[i].reply = NULL; @@ -4112,6 +4156,16 @@ void mpi3mr_free_mem(struct mpi3mr_ioc *mrioc) mrioc->admin_req_base, mrioc->admin_req_dma); mrioc->admin_req_base = NULL; } + + if (mrioc->pel_seqnum_virt) { + dma_free_coherent(&mrioc->pdev->dev, mrioc->pel_seqnum_sz, + mrioc->pel_seqnum_virt, mrioc->pel_seqnum_dma); + mrioc->pel_seqnum_virt = NULL; + } + + kfree(mrioc->logdata_buf); + mrioc->logdata_buf = NULL; + } /** @@ -4260,6 +4314,254 @@ static void mpi3mr_flush_drv_cmds(struct mpi3mr_ioc *mrioc) cmdptr = &mrioc->evtack_cmds[i]; mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr); } + + cmdptr = &mrioc->pel_cmds; + mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr); + + cmdptr = &mrioc->pel_abort_cmd; + mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr); + +} + +/** + * mpi3mr_pel_wait_post - Issue PEL Wait + * @mrioc: Adapter instance reference + * @drv_cmd: Internal command tracker + * + * Issue PEL Wait MPI request through admin queue and return. + * + * Return: Nothing. + */ +static void mpi3mr_pel_wait_post(struct mpi3mr_ioc *mrioc, + struct mpi3mr_drv_cmd *drv_cmd) +{ + struct mpi3_pel_req_action_wait pel_wait; + + mrioc->pel_abort_requested = false; + + memset(&pel_wait, 0, sizeof(pel_wait)); + drv_cmd->state = MPI3MR_CMD_PENDING; + drv_cmd->is_waiting = 0; + drv_cmd->callback = mpi3mr_pel_wait_complete; + drv_cmd->ioc_status = 0; + drv_cmd->ioc_loginfo = 0; + pel_wait.host_tag = cpu_to_le16(MPI3MR_HOSTTAG_PEL_WAIT); + pel_wait.function = MPI3_FUNCTION_PERSISTENT_EVENT_LOG; + pel_wait.action = MPI3_PEL_ACTION_WAIT; + pel_wait.starting_sequence_number = cpu_to_le32(mrioc->pel_newest_seqnum); + pel_wait.locale = cpu_to_le16(mrioc->pel_locale); + pel_wait.class = cpu_to_le16(mrioc->pel_class); + pel_wait.wait_time = MPI3_PEL_WAITTIME_INFINITE_WAIT; + dprint_bsg_info(mrioc, "sending pel_wait seqnum(%d), class(%d), locale(0x%08x)\n", + mrioc->pel_newest_seqnum, mrioc->pel_class, mrioc->pel_locale); + + if (mpi3mr_admin_request_post(mrioc, &pel_wait, sizeof(pel_wait), 0)) { + dprint_bsg_err(mrioc, + "Issuing PELWait: Admin post failed\n"); + drv_cmd->state = MPI3MR_CMD_NOTUSED; + drv_cmd->callback = NULL; + drv_cmd->retry_count = 0; + mrioc->pel_enabled = false; + } +} + +/** + * mpi3mr_pel_get_seqnum_post - Issue PEL Get Sequence number + * @mrioc: Adapter instance reference + * @drv_cmd: Internal command tracker + * + * Issue PEL get sequence number MPI request through admin queue + * and return. + * + * Return: 0 on success, non-zero on failure. + */ +int mpi3mr_pel_get_seqnum_post(struct mpi3mr_ioc *mrioc, + struct mpi3mr_drv_cmd *drv_cmd) +{ + struct mpi3_pel_req_action_get_sequence_numbers pel_getseq_req; + u8 sgl_flags = MPI3MR_SGEFLAGS_SYSTEM_SIMPLE_END_OF_LIST; + int retval = 0; + + memset(&pel_getseq_req, 0, sizeof(pel_getseq_req)); + mrioc->pel_cmds.state = MPI3MR_CMD_PENDING; + mrioc->pel_cmds.is_waiting = 0; + mrioc->pel_cmds.ioc_status = 0; + mrioc->pel_cmds.ioc_loginfo = 0; + mrioc->pel_cmds.callback = mpi3mr_pel_get_seqnum_complete; + pel_getseq_req.host_tag = cpu_to_le16(MPI3MR_HOSTTAG_PEL_WAIT); + pel_getseq_req.function = MPI3_FUNCTION_PERSISTENT_EVENT_LOG; + pel_getseq_req.action = MPI3_PEL_ACTION_GET_SEQNUM; + mpi3mr_add_sg_single(&pel_getseq_req.sgl, sgl_flags, + mrioc->pel_seqnum_sz, mrioc->pel_seqnum_dma); + + retval = mpi3mr_admin_request_post(mrioc, &pel_getseq_req, + sizeof(pel_getseq_req), 0); + if (retval) { + if (drv_cmd) { + drv_cmd->state = MPI3MR_CMD_NOTUSED; + drv_cmd->callback = NULL; + drv_cmd->retry_count = 0; + } + mrioc->pel_enabled = false; + } + + return retval; +} + +/** + * mpi3mr_pel_wait_complete - PELWait Completion callback + * @mrioc: Adapter instance reference + * @drv_cmd: Internal command tracker + * + * This is a callback handler for the PELWait request and + * firmware completes a PELWait request when it is aborted or a + * new PEL entry is available. This sends AEN to the application + * and if the PELwait completion is not due to PELAbort then + * this will send a request for new PEL Sequence number + * + * Return: Nothing. + */ +static void mpi3mr_pel_wait_complete(struct mpi3mr_ioc *mrioc, + struct mpi3mr_drv_cmd *drv_cmd) +{ + struct mpi3_pel_reply *pel_reply = NULL; + u16 ioc_status, pe_log_status; + bool do_retry = false; + + if (drv_cmd->state & MPI3MR_CMD_RESET) + goto cleanup_drv_cmd; + + ioc_status = drv_cmd->ioc_status & MPI3_IOCSTATUS_STATUS_MASK; + if (ioc_status != MPI3_IOCSTATUS_SUCCESS) { + ioc_err(mrioc, "%s: Failed ioc_status(0x%04x) Loginfo(0x%08x)\n", + __func__, ioc_status, drv_cmd->ioc_loginfo); + dprint_bsg_err(mrioc, + "pel_wait: failed with ioc_status(0x%04x), log_info(0x%08x)\n", + ioc_status, drv_cmd->ioc_loginfo); + do_retry = true; + } + + if (drv_cmd->state & MPI3MR_CMD_REPLY_VALID) + pel_reply = (struct mpi3_pel_reply *)drv_cmd->reply; + + if (!pel_reply) { + dprint_bsg_err(mrioc, + "pel_wait: failed due to no reply\n"); + goto out_failed; + } + + pe_log_status = le16_to_cpu(pel_reply->pe_log_status); + if ((pe_log_status != MPI3_PEL_STATUS_SUCCESS) && + (pe_log_status != MPI3_PEL_STATUS_ABORTED)) { + ioc_err(mrioc, "%s: Failed pe_log_status(0x%04x)\n", + __func__, pe_log_status); + dprint_bsg_err(mrioc, + "pel_wait: failed due to pel_log_status(0x%04x)\n", + pe_log_status); + do_retry = true; + } + + if (do_retry) { + if (drv_cmd->retry_count < MPI3MR_PEL_RETRY_COUNT) { + drv_cmd->retry_count++; + dprint_bsg_err(mrioc, "pel_wait: retrying(%d)\n", + drv_cmd->retry_count); + mpi3mr_pel_wait_post(mrioc, drv_cmd); + return; + } + dprint_bsg_err(mrioc, + "pel_wait: failed after all retries(%d)\n", + drv_cmd->retry_count); + goto out_failed; + } + atomic64_inc(&event_counter); + if (!mrioc->pel_abort_requested) { + mrioc->pel_cmds.retry_count = 0; + mpi3mr_pel_get_seqnum_post(mrioc, &mrioc->pel_cmds); + } + + return; +out_failed: + mrioc->pel_enabled = false; +cleanup_drv_cmd: + drv_cmd->state = MPI3MR_CMD_NOTUSED; + drv_cmd->callback = NULL; + drv_cmd->retry_count = 0; +} + +/** + * mpi3mr_pel_get_seqnum_complete - PELGetSeqNum Completion callback + * @mrioc: Adapter instance reference + * @drv_cmd: Internal command tracker + * + * This is a callback handler for the PEL get sequence number + * request and a new PEL wait request will be issued to the + * firmware from this + * + * Return: Nothing. + */ +void mpi3mr_pel_get_seqnum_complete(struct mpi3mr_ioc *mrioc, + struct mpi3mr_drv_cmd *drv_cmd) +{ + struct mpi3_pel_reply *pel_reply = NULL; + struct mpi3_pel_seq *pel_seqnum_virt; + u16 ioc_status; + bool do_retry = false; + + pel_seqnum_virt = (struct mpi3_pel_seq *)mrioc->pel_seqnum_virt; + + if (drv_cmd->state & MPI3MR_CMD_RESET) + goto cleanup_drv_cmd; + + ioc_status = drv_cmd->ioc_status & MPI3_IOCSTATUS_STATUS_MASK; + if (ioc_status != MPI3_IOCSTATUS_SUCCESS) { + dprint_bsg_err(mrioc, + "pel_get_seqnum: failed with ioc_status(0x%04x), log_info(0x%08x)\n", + ioc_status, drv_cmd->ioc_loginfo); + do_retry = true; + } + + if (drv_cmd->state & MPI3MR_CMD_REPLY_VALID) + pel_reply = (struct mpi3_pel_reply *)drv_cmd->reply; + if (!pel_reply) { + dprint_bsg_err(mrioc, + "pel_get_seqnum: failed due to no reply\n"); + goto out_failed; + } + + if (le16_to_cpu(pel_reply->pe_log_status) != MPI3_PEL_STATUS_SUCCESS) { + dprint_bsg_err(mrioc, + "pel_get_seqnum: failed due to pel_log_status(0x%04x)\n", + le16_to_cpu(pel_reply->pe_log_status)); + do_retry = true; + } + + if (do_retry) { + if (drv_cmd->retry_count < MPI3MR_PEL_RETRY_COUNT) { + drv_cmd->retry_count++; + dprint_bsg_err(mrioc, + "pel_get_seqnum: retrying(%d)\n", + drv_cmd->retry_count); + mpi3mr_pel_get_seqnum_post(mrioc, drv_cmd); + return; + } + + dprint_bsg_err(mrioc, + "pel_get_seqnum: failed after all retries(%d)\n", + drv_cmd->retry_count); + goto out_failed; + } + mrioc->pel_newest_seqnum = le32_to_cpu(pel_seqnum_virt->newest) + 1; + drv_cmd->retry_count = 0; + mpi3mr_pel_wait_post(mrioc, drv_cmd); + + return; +out_failed: + mrioc->pel_enabled = false; +cleanup_drv_cmd: + drv_cmd->state = MPI3MR_CMD_NOTUSED; + drv_cmd->callback = NULL; + drv_cmd->retry_count = 0; } /** @@ -4383,6 +4685,12 @@ out: if (!retval) { mrioc->diagsave_timeout = 0; mrioc->reset_in_progress = 0; + mrioc->pel_abort_requested = 0; + if (mrioc->pel_enabled) { + mrioc->pel_cmds.retry_count = 0; + mpi3mr_pel_wait_post(mrioc, &mrioc->pel_cmds); + } + mpi3mr_rfresh_tgtdevs(mrioc); mrioc->ts_update_counter = 0; spin_lock_irqsave(&mrioc->watchdog_lock, flags); @@ -4392,6 +4700,8 @@ out: msecs_to_jiffies(MPI3MR_WATCHDOG_INTERVAL)); spin_unlock_irqrestore(&mrioc->watchdog_lock, flags); mrioc->stop_bsgs = 0; + if (mrioc->pel_enabled) + atomic64_inc(&event_counter); } else { mpi3mr_issue_reset(mrioc, MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT, reset_reason); diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index 450574fc1fec..19298136edb6 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -14,6 +14,7 @@ LIST_HEAD(mrioc_list); DEFINE_SPINLOCK(mrioc_list_lock); static int mrioc_ids; static int warn_non_secure_ctlr; +atomic64_t event_counter; MODULE_AUTHOR(MPI3MR_DRIVER_AUTHOR); MODULE_DESCRIPTION(MPI3MR_DRIVER_DESC); @@ -1415,6 +1416,23 @@ static void mpi3mr_pcietopochg_evt_bh(struct mpi3mr_ioc *mrioc, } } +/** + * mpi3mr_logdata_evt_bh - Log data event bottomhalf + * @mrioc: Adapter instance reference + * @fwevt: Firmware event reference + * + * Extracts the event data and calls application interfacing + * function to process the event further. + * + * Return: Nothing. + */ +static void mpi3mr_logdata_evt_bh(struct mpi3mr_ioc *mrioc, + struct mpi3mr_fwevt *fwevt) +{ + mpi3mr_app_save_logdata(mrioc, fwevt->event_data, + fwevt->event_data_size); +} + /** * mpi3mr_fwevt_bh - Firmware event bottomhalf handler * @mrioc: Adapter instance reference @@ -1467,6 +1485,11 @@ static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc, mpi3mr_pcietopochg_evt_bh(mrioc, fwevt); break; } + case MPI3_EVENT_LOG_DATA: + { + mpi3mr_logdata_evt_bh(mrioc, fwevt); + break; + } default: break; } @@ -2298,6 +2321,7 @@ void mpi3mr_os_handle_events(struct mpi3mr_ioc *mrioc, break; } case MPI3_EVENT_DEVICE_INFO_CHANGED: + case MPI3_EVENT_LOG_DATA: { process_evt_bh = 1; break; @@ -4568,6 +4592,12 @@ static struct pci_driver mpi3mr_pci_driver = { #endif }; +static ssize_t event_counter_show(struct device_driver *dd, char *buf) +{ + return sprintf(buf, "%llu\n", atomic64_read(&event_counter)); +} +static DRIVER_ATTR_RO(event_counter); + static int __init mpi3mr_init(void) { int ret_val; @@ -4576,6 +4606,16 @@ static int __init mpi3mr_init(void) MPI3MR_DRIVER_VERSION); ret_val = pci_register_driver(&mpi3mr_pci_driver); + if (ret_val) { + pr_err("%s failed to load due to pci register driver failure\n", + MPI3MR_DRIVER_NAME); + return ret_val; + } + + ret_val = driver_create_file(&mpi3mr_pci_driver.driver, + &driver_attr_event_counter); + if (ret_val) + pci_unregister_driver(&mpi3mr_pci_driver); return ret_val; } @@ -4590,6 +4630,8 @@ static void __exit mpi3mr_exit(void) pr_info("Unloading %s version %s\n", MPI3MR_DRIVER_NAME, MPI3MR_DRIVER_VERSION); + driver_remove_file(&mpi3mr_pci_driver.driver, + &driver_attr_event_counter); pci_unregister_driver(&mpi3mr_pci_driver); } From 986d6bad2103fb24bd886aad455245ace168c984 Mon Sep 17 00:00:00 2001 From: Sumit Saxena Date: Fri, 29 Apr 2022 17:16:39 -0400 Subject: [PATCH 123/177] scsi: mpi3mr: Expose adapter state to sysfs Link: https://lore.kernel.org/r/20220429211641.642010-7-sumit.saxena@broadcom.com Reviewed-by: Himanshu Madhani Signed-off-by: Sumit Saxena Signed-off-by: Martin K. Petersen --- drivers/scsi/mpi3mr/mpi3mr.h | 2 +- drivers/scsi/mpi3mr/mpi3mr_app.c | 46 ++++++++++++++++++++++++++++++++ drivers/scsi/mpi3mr/mpi3mr_os.c | 1 + 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/mpi3mr/mpi3mr.h b/drivers/scsi/mpi3mr/mpi3mr.h index ad1270cba280..0c6efb0eb063 100644 --- a/drivers/scsi/mpi3mr/mpi3mr.h +++ b/drivers/scsi/mpi3mr/mpi3mr.h @@ -1056,5 +1056,5 @@ int mpi3mr_pel_get_seqnum_post(struct mpi3mr_ioc *mrioc, struct mpi3mr_drv_cmd *drv_cmd); void mpi3mr_app_save_logdata(struct mpi3mr_ioc *mrioc, char *event_data, u16 event_data_size); - +extern const struct attribute_group *mpi3mr_host_groups[]; #endif /*MPI3MR_H_INCLUDED*/ diff --git a/drivers/scsi/mpi3mr/mpi3mr_app.c b/drivers/scsi/mpi3mr/mpi3mr_app.c index 06a1e950bec4..5221058e3d6b 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_app.c +++ b/drivers/scsi/mpi3mr/mpi3mr_app.c @@ -1215,3 +1215,49 @@ err_setup_queue: err_device_add: kfree(mrioc->bsg_dev); } + +/** + * adapter_state_show - SysFS callback for adapter state show + * @dev: class device + * @attr: Device attributes + * @buf: Buffer to copy + * + * Return: snprintf() return after copying adapter state + */ +static ssize_t +adp_state_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct Scsi_Host *shost = class_to_shost(dev); + struct mpi3mr_ioc *mrioc = shost_priv(shost); + enum mpi3mr_iocstate ioc_state; + uint8_t adp_state; + + ioc_state = mpi3mr_get_iocstate(mrioc); + if (ioc_state == MRIOC_STATE_UNRECOVERABLE) + adp_state = MPI3MR_BSG_ADPSTATE_UNRECOVERABLE; + else if ((mrioc->reset_in_progress) || (mrioc->stop_bsgs)) + adp_state = MPI3MR_BSG_ADPSTATE_IN_RESET; + else if (ioc_state == MRIOC_STATE_FAULT) + adp_state = MPI3MR_BSG_ADPSTATE_FAULT; + else + adp_state = MPI3MR_BSG_ADPSTATE_OPERATIONAL; + + return snprintf(buf, PAGE_SIZE, "%u\n", adp_state); +} + +static DEVICE_ATTR_RO(adp_state); + +static struct attribute *mpi3mr_host_attrs[] = { + &dev_attr_adp_state.attr, + NULL, +}; + +static const struct attribute_group mpi3mr_host_attr_group = { + .attrs = mpi3mr_host_attrs +}; + +const struct attribute_group *mpi3mr_host_groups[] = { + &mpi3mr_host_attr_group, + NULL, +}; diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index 19298136edb6..89a4918c4a9e 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -4134,6 +4134,7 @@ static struct scsi_host_template mpi3mr_driver_template = { .max_segment_size = 0xffffffff, .track_queue_depth = 1, .cmd_size = sizeof(struct scmd_priv), + .shost_groups = mpi3mr_host_groups, }; /** From 7dbd0dd8cde356d2a747d5c87dad7c2233dad8a4 Mon Sep 17 00:00:00 2001 From: Sumit Saxena Date: Fri, 29 Apr 2022 17:16:40 -0400 Subject: [PATCH 124/177] scsi: mpi3mr: Add support for NVMe passthrough Add support for management applications to send an MPI3 Encapsulated NVMe passthru command to the NVMe devices attached to an Avenger controller. Since the NVMe drives are exposed as SCSI devices by the controller, the standard NVMe applications cannot be used to interact with the drives and the command sets supported are also limited by the controller firmware. Special handling is required for MPI3 Encapsulated NVMe passthru commands for PRP/SGL setup in the commands. Link: https://lore.kernel.org/r/20220429211641.642010-8-sumit.saxena@broadcom.com Reviewed-by: Himanshu Madhani Signed-off-by: Sumit Saxena Signed-off-by: Martin K. Petersen --- drivers/scsi/mpi3mr/mpi3mr.h | 25 ++ drivers/scsi/mpi3mr/mpi3mr_app.c | 348 +++++++++++++++++++++++++++- include/uapi/scsi/scsi_bsg_mpi3mr.h | 8 + 3 files changed, 378 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/mpi3mr/mpi3mr.h b/drivers/scsi/mpi3mr/mpi3mr.h index 0c6efb0eb063..60e129603a77 100644 --- a/drivers/scsi/mpi3mr/mpi3mr.h +++ b/drivers/scsi/mpi3mr/mpi3mr.h @@ -193,6 +193,24 @@ extern atomic64_t event_counter; */ #define MPI3MR_MAX_APP_XFER_SECTORS (2048 + 512) +/** + * struct mpi3mr_nvme_pt_sge - Structure to store SGEs for NVMe + * Encapsulated commands. + * + * @base_addr: Physical address + * @length: SGE length + * @rsvd: Reserved + * @rsvd1: Reserved + * @sgl_type: sgl type + */ +struct mpi3mr_nvme_pt_sge { + u64 base_addr; + u32 length; + u16 rsvd; + u8 rsvd1; + u8 sgl_type; +}; + /** * struct mpi3mr_buf_map - local structure to * track kernel and user buffers associated with an BSG @@ -746,6 +764,9 @@ struct scmd_priv { * @reset_waitq: Controller reset wait queue * @prepare_for_reset: Prepare for reset event received * @prepare_for_reset_timeout_counter: Prepare for reset timeout + * @prp_list_virt: NVMe encapsulated PRP list virtual base + * @prp_list_dma: NVMe encapsulated PRP list DMA + * @prp_sz: NVME encapsulated PRP list size * @diagsave_timeout: Diagnostic information save timeout * @logging_level: Controller debug logging level * @flush_io_count: I/O count to flush after reset @@ -901,6 +922,10 @@ struct mpi3mr_ioc { u8 prepare_for_reset; u16 prepare_for_reset_timeout_counter; + void *prp_list_virt; + dma_addr_t prp_list_dma; + u32 prp_sz; + u16 diagsave_timeout; int logging_level; u16 flush_io_count; diff --git a/drivers/scsi/mpi3mr/mpi3mr_app.c b/drivers/scsi/mpi3mr/mpi3mr_app.c index 5221058e3d6b..73bb7992d5a8 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_app.c +++ b/drivers/scsi/mpi3mr/mpi3mr_app.c @@ -619,6 +619,314 @@ static void mpi3mr_bsg_build_sgl(u8 *mpi_req, uint32_t sgl_offset, } } +/** + * mpi3mr_get_nvme_data_fmt - returns the NVMe data format + * @nvme_encap_request: NVMe encapsulated MPI request + * + * This function returns the type of the data format specified + * in user provided NVMe command in NVMe encapsulated request. + * + * Return: Data format of the NVMe command (PRP/SGL etc) + */ +static unsigned int mpi3mr_get_nvme_data_fmt( + struct mpi3_nvme_encapsulated_request *nvme_encap_request) +{ + u8 format = 0; + + format = ((nvme_encap_request->command[0] & 0xc000) >> 14); + return format; + +} + +/** + * mpi3mr_build_nvme_sgl - SGL constructor for NVME + * encapsulated request + * @mrioc: Adapter instance reference + * @nvme_encap_request: NVMe encapsulated MPI request + * @drv_bufs: DMA address of the buffers to be placed in sgl + * @bufcnt: Number of DMA buffers + * + * This function places the DMA address of the given buffers in + * proper format as SGEs in the given NVMe encapsulated request. + * + * Return: 0 on success, -1 on failure + */ +static int mpi3mr_build_nvme_sgl(struct mpi3mr_ioc *mrioc, + struct mpi3_nvme_encapsulated_request *nvme_encap_request, + struct mpi3mr_buf_map *drv_bufs, u8 bufcnt) +{ + struct mpi3mr_nvme_pt_sge *nvme_sgl; + u64 sgl_ptr; + u8 count; + size_t length = 0; + struct mpi3mr_buf_map *drv_buf_iter = drv_bufs; + u64 sgemod_mask = ((u64)((mrioc->facts.sge_mod_mask) << + mrioc->facts.sge_mod_shift) << 32); + u64 sgemod_val = ((u64)(mrioc->facts.sge_mod_value) << + mrioc->facts.sge_mod_shift) << 32; + + /* + * Not all commands require a data transfer. If no data, just return + * without constructing any sgl. + */ + for (count = 0; count < bufcnt; count++, drv_buf_iter++) { + if (drv_buf_iter->data_dir == DMA_NONE) + continue; + sgl_ptr = (u64)drv_buf_iter->kern_buf_dma; + length = drv_buf_iter->kern_buf_len; + break; + } + if (!length) + return 0; + + if (sgl_ptr & sgemod_mask) { + dprint_bsg_err(mrioc, + "%s: SGL address collides with SGE modifier\n", + __func__); + return -1; + } + + sgl_ptr &= ~sgemod_mask; + sgl_ptr |= sgemod_val; + nvme_sgl = (struct mpi3mr_nvme_pt_sge *) + ((u8 *)(nvme_encap_request->command) + MPI3MR_NVME_CMD_SGL_OFFSET); + memset(nvme_sgl, 0, sizeof(struct mpi3mr_nvme_pt_sge)); + nvme_sgl->base_addr = sgl_ptr; + nvme_sgl->length = length; + return 0; +} + +/** + * mpi3mr_build_nvme_prp - PRP constructor for NVME + * encapsulated request + * @mrioc: Adapter instance reference + * @nvme_encap_request: NVMe encapsulated MPI request + * @drv_bufs: DMA address of the buffers to be placed in SGL + * @bufcnt: Number of DMA buffers + * + * This function places the DMA address of the given buffers in + * proper format as PRP entries in the given NVMe encapsulated + * request. + * + * Return: 0 on success, -1 on failure + */ +static int mpi3mr_build_nvme_prp(struct mpi3mr_ioc *mrioc, + struct mpi3_nvme_encapsulated_request *nvme_encap_request, + struct mpi3mr_buf_map *drv_bufs, u8 bufcnt) +{ + int prp_size = MPI3MR_NVME_PRP_SIZE; + __le64 *prp_entry, *prp1_entry, *prp2_entry; + __le64 *prp_page; + dma_addr_t prp_entry_dma, prp_page_dma, dma_addr; + u32 offset, entry_len, dev_pgsz; + u32 page_mask_result, page_mask; + size_t length = 0; + u8 count; + struct mpi3mr_buf_map *drv_buf_iter = drv_bufs; + u64 sgemod_mask = ((u64)((mrioc->facts.sge_mod_mask) << + mrioc->facts.sge_mod_shift) << 32); + u64 sgemod_val = ((u64)(mrioc->facts.sge_mod_value) << + mrioc->facts.sge_mod_shift) << 32; + u16 dev_handle = nvme_encap_request->dev_handle; + struct mpi3mr_tgt_dev *tgtdev; + + tgtdev = mpi3mr_get_tgtdev_by_handle(mrioc, dev_handle); + if (!tgtdev) { + dprint_bsg_err(mrioc, "%s: invalid device handle 0x%04x\n", + __func__, dev_handle); + return -1; + } + + if (tgtdev->dev_spec.pcie_inf.pgsz == 0) { + dprint_bsg_err(mrioc, + "%s: NVMe device page size is zero for handle 0x%04x\n", + __func__, dev_handle); + mpi3mr_tgtdev_put(tgtdev); + return -1; + } + + dev_pgsz = 1 << (tgtdev->dev_spec.pcie_inf.pgsz); + mpi3mr_tgtdev_put(tgtdev); + + /* + * Not all commands require a data transfer. If no data, just return + * without constructing any PRP. + */ + for (count = 0; count < bufcnt; count++, drv_buf_iter++) { + if (drv_buf_iter->data_dir == DMA_NONE) + continue; + dma_addr = drv_buf_iter->kern_buf_dma; + length = drv_buf_iter->kern_buf_len; + break; + } + + if (!length) + return 0; + + mrioc->prp_sz = 0; + mrioc->prp_list_virt = dma_alloc_coherent(&mrioc->pdev->dev, + dev_pgsz, &mrioc->prp_list_dma, GFP_KERNEL); + + if (!mrioc->prp_list_virt) + return -1; + mrioc->prp_sz = dev_pgsz; + + /* + * Set pointers to PRP1 and PRP2, which are in the NVMe command. + * PRP1 is located at a 24 byte offset from the start of the NVMe + * command. Then set the current PRP entry pointer to PRP1. + */ + prp1_entry = (__le64 *)((u8 *)(nvme_encap_request->command) + + MPI3MR_NVME_CMD_PRP1_OFFSET); + prp2_entry = (__le64 *)((u8 *)(nvme_encap_request->command) + + MPI3MR_NVME_CMD_PRP2_OFFSET); + prp_entry = prp1_entry; + /* + * For the PRP entries, use the specially allocated buffer of + * contiguous memory. + */ + prp_page = (__le64 *)mrioc->prp_list_virt; + prp_page_dma = mrioc->prp_list_dma; + + /* + * Check if we are within 1 entry of a page boundary we don't + * want our first entry to be a PRP List entry. + */ + page_mask = dev_pgsz - 1; + page_mask_result = (uintptr_t)((u8 *)prp_page + prp_size) & page_mask; + if (!page_mask_result) { + dprint_bsg_err(mrioc, "%s: PRP page is not page aligned\n", + __func__); + goto err_out; + } + + /* + * Set PRP physical pointer, which initially points to the current PRP + * DMA memory page. + */ + prp_entry_dma = prp_page_dma; + + + /* Loop while the length is not zero. */ + while (length) { + page_mask_result = (prp_entry_dma + prp_size) & page_mask; + if (!page_mask_result && (length > dev_pgsz)) { + dprint_bsg_err(mrioc, + "%s: single PRP page is not sufficient\n", + __func__); + goto err_out; + } + + /* Need to handle if entry will be part of a page. */ + offset = dma_addr & page_mask; + entry_len = dev_pgsz - offset; + + if (prp_entry == prp1_entry) { + /* + * Must fill in the first PRP pointer (PRP1) before + * moving on. + */ + *prp1_entry = cpu_to_le64(dma_addr); + if (*prp1_entry & sgemod_mask) { + dprint_bsg_err(mrioc, + "%s: PRP1 address collides with SGE modifier\n", + __func__); + goto err_out; + } + *prp1_entry &= ~sgemod_mask; + *prp1_entry |= sgemod_val; + + /* + * Now point to the second PRP entry within the + * command (PRP2). + */ + prp_entry = prp2_entry; + } else if (prp_entry == prp2_entry) { + /* + * Should the PRP2 entry be a PRP List pointer or just + * a regular PRP pointer? If there is more than one + * more page of data, must use a PRP List pointer. + */ + if (length > dev_pgsz) { + /* + * PRP2 will contain a PRP List pointer because + * more PRP's are needed with this command. The + * list will start at the beginning of the + * contiguous buffer. + */ + *prp2_entry = cpu_to_le64(prp_entry_dma); + if (*prp2_entry & sgemod_mask) { + dprint_bsg_err(mrioc, + "%s: PRP list address collides with SGE modifier\n", + __func__); + goto err_out; + } + *prp2_entry &= ~sgemod_mask; + *prp2_entry |= sgemod_val; + + /* + * The next PRP Entry will be the start of the + * first PRP List. + */ + prp_entry = prp_page; + continue; + } else { + /* + * After this, the PRP Entries are complete. + * This command uses 2 PRP's and no PRP list. + */ + *prp2_entry = cpu_to_le64(dma_addr); + if (*prp2_entry & sgemod_mask) { + dprint_bsg_err(mrioc, + "%s: PRP2 collides with SGE modifier\n", + __func__); + goto err_out; + } + *prp2_entry &= ~sgemod_mask; + *prp2_entry |= sgemod_val; + } + } else { + /* + * Put entry in list and bump the addresses. + * + * After PRP1 and PRP2 are filled in, this will fill in + * all remaining PRP entries in a PRP List, one per + * each time through the loop. + */ + *prp_entry = cpu_to_le64(dma_addr); + if (*prp1_entry & sgemod_mask) { + dprint_bsg_err(mrioc, + "%s: PRP address collides with SGE modifier\n", + __func__); + goto err_out; + } + *prp_entry &= ~sgemod_mask; + *prp_entry |= sgemod_val; + prp_entry++; + prp_entry_dma++; + } + + /* + * Bump the phys address of the command's data buffer by the + * entry_len. + */ + dma_addr += entry_len; + + /* decrement length accounting for last partial page. */ + if (entry_len > length) + length = 0; + else + length -= entry_len; + } + return 0; +err_out: + if (mrioc->prp_list_virt) { + dma_free_coherent(&mrioc->pdev->dev, mrioc->prp_sz, + mrioc->prp_list_virt, mrioc->prp_list_dma); + mrioc->prp_list_virt = NULL; + } + return -1; +} /** * mpi3mr_bsg_process_mpt_cmds - MPI Pass through BSG handler * @job: BSG job reference @@ -650,7 +958,7 @@ static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job, unsigned int *reply struct mpi3mr_buf_map *drv_bufs = NULL, *drv_buf_iter = NULL; u8 count, bufcnt = 0, is_rmcb = 0, is_rmrb = 0, din_cnt = 0, dout_cnt = 0; u8 invalid_be = 0, erb_offset = 0xFF, mpirep_offset = 0xFF, sg_entries = 0; - u8 block_io = 0, resp_code = 0; + u8 block_io = 0, resp_code = 0, nvme_fmt = 0; struct mpi3_request_header *mpi_header = NULL; struct mpi3_status_reply_descriptor *status_desc; struct mpi3_scsi_task_mgmt_request *tm_req; @@ -890,7 +1198,34 @@ static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job, unsigned int *reply goto out; } - if (mpi_header->function != MPI3_BSG_FUNCTION_NVME_ENCAPSULATED) { + if (mpi_header->function == MPI3_BSG_FUNCTION_NVME_ENCAPSULATED) { + nvme_fmt = mpi3mr_get_nvme_data_fmt( + (struct mpi3_nvme_encapsulated_request *)mpi_req); + if (nvme_fmt == MPI3MR_NVME_DATA_FORMAT_PRP) { + if (mpi3mr_build_nvme_prp(mrioc, + (struct mpi3_nvme_encapsulated_request *)mpi_req, + drv_bufs, bufcnt)) { + rval = -ENOMEM; + mutex_unlock(&mrioc->bsg_cmds.mutex); + goto out; + } + } else if (nvme_fmt == MPI3MR_NVME_DATA_FORMAT_SGL1 || + nvme_fmt == MPI3MR_NVME_DATA_FORMAT_SGL2) { + if (mpi3mr_build_nvme_sgl(mrioc, + (struct mpi3_nvme_encapsulated_request *)mpi_req, + drv_bufs, bufcnt)) { + rval = -EINVAL; + mutex_unlock(&mrioc->bsg_cmds.mutex); + goto out; + } + } else { + dprint_bsg_err(mrioc, + "%s:invalid NVMe command format\n", __func__); + rval = -EINVAL; + mutex_unlock(&mrioc->bsg_cmds.mutex); + goto out; + } + } else { mpi3mr_bsg_build_sgl(mpi_req, (mpi_msg_size), drv_bufs, bufcnt, is_rmcb, is_rmrb, (dout_cnt + din_cnt)); @@ -968,7 +1303,8 @@ static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job, unsigned int *reply } } - if (mpi_header->function == MPI3_BSG_FUNCTION_SCSI_IO) + if ((mpi_header->function == MPI3_BSG_FUNCTION_NVME_ENCAPSULATED) || + (mpi_header->function == MPI3_BSG_FUNCTION_SCSI_IO)) mpi3mr_issue_tm(mrioc, MPI3_SCSITASKMGMT_TASKTYPE_TARGET_RESET, mpi_header->function_dependent, 0, @@ -982,6 +1318,12 @@ static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job, unsigned int *reply } dprint_bsg_info(mrioc, "%s: bsg request is completed\n", __func__); + if (mrioc->prp_list_virt) { + dma_free_coherent(&mrioc->pdev->dev, mrioc->prp_sz, + mrioc->prp_list_virt, mrioc->prp_list_dma); + mrioc->prp_list_virt = NULL; + } + if ((mrioc->bsg_cmds.ioc_status & MPI3_IOCSTATUS_STATUS_MASK) != MPI3_IOCSTATUS_SUCCESS) { dprint_bsg_info(mrioc, diff --git a/include/uapi/scsi/scsi_bsg_mpi3mr.h b/include/uapi/scsi/scsi_bsg_mpi3mr.h index b2c88d5d9c4c..fdc3517f9e19 100644 --- a/include/uapi/scsi/scsi_bsg_mpi3mr.h +++ b/include/uapi/scsi/scsi_bsg_mpi3mr.h @@ -490,6 +490,14 @@ struct mpi3_nvme_encapsulated_error_reply { __le32 nvme_completion_entry[4]; }; +#define MPI3MR_NVME_PRP_SIZE 8 /* PRP size */ +#define MPI3MR_NVME_CMD_PRP1_OFFSET 24 /* PRP1 offset in NVMe cmd */ +#define MPI3MR_NVME_CMD_PRP2_OFFSET 32 /* PRP2 offset in NVMe cmd */ +#define MPI3MR_NVME_CMD_SGL_OFFSET 24 /* SGL offset in NVMe cmd */ +#define MPI3MR_NVME_DATA_FORMAT_PRP 0 +#define MPI3MR_NVME_DATA_FORMAT_SGL1 1 +#define MPI3MR_NVME_DATA_FORMAT_SGL2 2 + /* MPI3: task management related definitions */ struct mpi3_scsi_task_mgmt_request { __le16 host_tag; From f304d35e59958ea4be399f78e5be08d4a0c4db75 Mon Sep 17 00:00:00 2001 From: Sumit Saxena Date: Fri, 29 Apr 2022 17:16:41 -0400 Subject: [PATCH 125/177] scsi: mpi3mr: Update driver version to 8.0.0.69.0 Link: https://lore.kernel.org/r/20220429211641.642010-9-sumit.saxena@broadcom.com Signed-off-by: Sumit Saxena Signed-off-by: Martin K. Petersen --- drivers/scsi/mpi3mr/mpi3mr.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/mpi3mr/mpi3mr.h b/drivers/scsi/mpi3mr/mpi3mr.h index 60e129603a77..8612b66b7d03 100644 --- a/drivers/scsi/mpi3mr/mpi3mr.h +++ b/drivers/scsi/mpi3mr/mpi3mr.h @@ -55,8 +55,8 @@ extern struct list_head mrioc_list; extern int prot_mask; extern atomic64_t event_counter; -#define MPI3MR_DRIVER_VERSION "8.0.0.68.0" -#define MPI3MR_DRIVER_RELDATE "10-February-2022" +#define MPI3MR_DRIVER_VERSION "8.0.0.69.0" +#define MPI3MR_DRIVER_RELDATE "16-March-2022" #define MPI3MR_DRIVER_NAME "mpi3mr" #define MPI3MR_DRIVER_LICENSE "GPL" From 9b5387fe5af38116b452259d87cd66594b6277c1 Mon Sep 17 00:00:00 2001 From: Xiang Chen Date: Fri, 6 May 2022 20:25:39 +0800 Subject: [PATCH 126/177] scsi: hisi_sas: Undo RPM resume for failed notify phy event for v3 HW If we fail to notify the phy up event then undo the RPM resume, as the phy up notify event handling pairs with that RPM resume. Link: https://lore.kernel.org/r/1651839939-101188-1-git-send-email-john.garry@huawei.com Reported-by: Yihang Li Tested-by: Yihang Li Signed-off-by: Xiang Chen Signed-off-by: John Garry Signed-off-by: Martin K. Petersen --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 79f87d7c3e68..7d819fc0395e 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -1563,9 +1563,15 @@ static irqreturn_t phy_up_v3_hw(int phy_no, struct hisi_hba *hisi_hba) phy->port_id = port_id; - /* Call pm_runtime_put_sync() with pairs in hisi_sas_phyup_pm_work() */ + /* + * Call pm_runtime_get_noresume() which pairs with + * hisi_sas_phyup_pm_work() -> pm_runtime_put_sync(). + * For failure call pm_runtime_put() as we are in a hardirq context. + */ pm_runtime_get_noresume(dev); - hisi_sas_notify_phy_event(phy, HISI_PHYE_PHY_UP_PM); + res = hisi_sas_notify_phy_event(phy, HISI_PHYE_PHY_UP_PM); + if (!res) + pm_runtime_put(dev); res = IRQ_HANDLED; From 223b17ed76ebecba54f7857cd1a3205050d6257b Mon Sep 17 00:00:00 2001 From: Manivannan Sadhasivam Date: Wed, 4 May 2022 14:12:08 +0530 Subject: [PATCH 127/177] scsi: ufs: qcom: Fix acquiring the optional reset control line On Qcom UFS platforms, the reset control line seems to be optional (for SoCs like MSM8996 and probably for others too). The current logic tries to mimic the devm_reset_control_get_optional() API but it also continues the probe if there is an error with the declared reset line in DT/ACPI. In an ideal case, if the reset line is not declared in DT/ACPI, the probe should continue. But if there is problem in acquiring the declared reset line (like EPROBE_DEFER) it should fail and return the appropriate error code. Link: https://lore.kernel.org/r/20220504084212.11605-2-manivannan.sadhasivam@linaro.org Reviewed-by: Bjorn Andersson Reviewed-by: Andrew Halaney Signed-off-by: Manivannan Sadhasivam Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufs-qcom.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c index d18bc534c62d..47dd30e41b47 100644 --- a/drivers/scsi/ufs/ufs-qcom.c +++ b/drivers/scsi/ufs/ufs-qcom.c @@ -985,13 +985,12 @@ static int ufs_qcom_init(struct ufs_hba *hba) host->hba = hba; ufshcd_set_variant(hba, host); - /* Setup the reset control of HCI */ - host->core_reset = devm_reset_control_get(hba->dev, "rst"); + /* Setup the optional reset control of HCI */ + host->core_reset = devm_reset_control_get_optional(hba->dev, "rst"); if (IS_ERR(host->core_reset)) { - err = PTR_ERR(host->core_reset); - dev_warn(dev, "Failed to get reset control %d\n", err); - host->core_reset = NULL; - err = 0; + err = dev_err_probe(dev, PTR_ERR(host->core_reset), + "Failed to get reset control\n"); + goto out_variant_clear; } /* Fire up the reset controller. Failure here is non-fatal. */ From c9ed9a6c56af4142ce0da240451c207d8171e451 Mon Sep 17 00:00:00 2001 From: Manivannan Sadhasivam Date: Wed, 4 May 2022 14:12:09 +0530 Subject: [PATCH 128/177] scsi: ufs: qcom: Simplify handling of devm_phy_get() There is no need to call devm_phy_get() if ACPI is used, so skip it. The host->generic_phy pointer should already be NULL due to the kzalloc(), so no need to set it NULL again. While at it, also remove the comment that has no relationship with devm_phy_get(). Link: https://lore.kernel.org/r/20220504084212.11605-3-manivannan.sadhasivam@linaro.org Reviewed-by: Bjorn Andersson Reviewed-by: Andrew Halaney Signed-off-by: Manivannan Sadhasivam Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufs-qcom.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c index 47dd30e41b47..539caf3aa07f 100644 --- a/drivers/scsi/ufs/ufs-qcom.c +++ b/drivers/scsi/ufs/ufs-qcom.c @@ -1004,28 +1004,10 @@ static int ufs_qcom_init(struct ufs_hba *hba) err = 0; } - /* - * voting/devoting device ref_clk source is time consuming hence - * skip devoting it during aggressive clock gating. This clock - * will still be gated off during runtime suspend. - */ - host->generic_phy = devm_phy_get(dev, "ufsphy"); - - if (host->generic_phy == ERR_PTR(-EPROBE_DEFER)) { - /* - * UFS driver might be probed before the phy driver does. - * In that case we would like to return EPROBE_DEFER code. - */ - err = -EPROBE_DEFER; - dev_warn(dev, "%s: required phy device. hasn't probed yet. err = %d\n", - __func__, err); - goto out_variant_clear; - } else if (IS_ERR(host->generic_phy)) { - if (has_acpi_companion(dev)) { - host->generic_phy = NULL; - } else { - err = PTR_ERR(host->generic_phy); - dev_err(dev, "%s: PHY get failed %d\n", __func__, err); + if (!has_acpi_companion(dev)) { + host->generic_phy = devm_phy_get(dev, "ufsphy"); + if (IS_ERR(host->generic_phy)) { + err = dev_err_probe(dev, PTR_ERR(host->generic_phy), "Failed to get PHY\n"); goto out_variant_clear; } } From 8eecddfca30e1651dc1c74531ed5eef21dcce7e3 Mon Sep 17 00:00:00 2001 From: Manivannan Sadhasivam Date: Wed, 4 May 2022 14:12:10 +0530 Subject: [PATCH 129/177] scsi: ufs: qcom: Add a readl() to make sure ref_clk gets enabled In ufs_qcom_dev_ref_clk_ctrl(), it was noted that the ref_clk needs to be stable for at least 1us. Even though there is wmb() to make sure the write gets "completed", there is no guarantee that the write actually reached the UFS device. There is a good chance that the write could be stored in a Write Buffer (WB). In that case, even though the CPU waits for 1us, the ref_clk might not be stable for that period. So lets do a readl() to make sure that the previous write has reached the UFS device before udelay(). Also, the wmb() after writel_relaxed() is not really needed. Both writel() and readl() are ordered on all architectures and the CPU won't speculate instructions after readl() due to the in-built control dependency with read value on weakly ordered architectures. So it can be safely removed. Link: https://lore.kernel.org/r/20220504084212.11605-4-manivannan.sadhasivam@linaro.org Fixes: f06fcc7155dc ("scsi: ufs-qcom: add QUniPro hardware support and power optimizations") Cc: stable@vger.kernel.org Reviewed-by: Bjorn Andersson Signed-off-by: Manivannan Sadhasivam Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufs-qcom.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c index 539caf3aa07f..0ee0e9d62794 100644 --- a/drivers/scsi/ufs/ufs-qcom.c +++ b/drivers/scsi/ufs/ufs-qcom.c @@ -685,8 +685,11 @@ static void ufs_qcom_dev_ref_clk_ctrl(struct ufs_qcom_host *host, bool enable) writel_relaxed(temp, host->dev_ref_clk_ctrl_mmio); - /* ensure that ref_clk is enabled/disabled before we return */ - wmb(); + /* + * Make sure the write to ref_clk reaches the destination and + * not stored in a Write Buffer (WB). + */ + readl(host->dev_ref_clk_ctrl_mmio); /* * If we call hibern8 exit after this, we need to make sure that From 23803bacaab47eafcd3a13ab607b5aa7b0debaaf Mon Sep 17 00:00:00 2001 From: Manivannan Sadhasivam Date: Wed, 4 May 2022 14:12:11 +0530 Subject: [PATCH 130/177] scsi: ufs: core: Remove redundant wmb() in ufshcd_send_command() The wmb() inside ufshcd_send_command() is added to make sure that the doorbell is committed immediately. This leads to couple of expectations: 1. The doorbell write should complete before the function return. 2. The doorbell write should not cross the function boundary. 2nd expectation is fullfilled by the Linux memory model as there is a guarantee that the critical section won't cross the unlock (release) operation. 1st expectation is not really needed here as there is no following read/ write that depends on the doorbell to be complete implicitly. Even if the doorbell write is in a CPUs Write Buffer (WB), wmb() won't flush it. And there is no real need of a WB flush here as well. So let's get rid of the wmb() that seems redundant. Link: https://lore.kernel.org/r/20220504084212.11605-5-manivannan.sadhasivam@linaro.org Reviewed-by: Bart Van Assche Reviewed-by: Bjorn Andersson Acked-by: Bean Huo Signed-off-by: Manivannan Sadhasivam Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufshcd.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 2b4390a1106e..1f82590d153f 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -2143,9 +2143,6 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag) __set_bit(task_tag, &hba->outstanding_reqs); ufshcd_writel(hba, 1 << task_tag, REG_UTP_TRANSFER_REQ_DOOR_BELL); spin_unlock_irqrestore(&hba->outstanding_lock, flags); - - /* Make sure that doorbell is committed immediately */ - wmb(); } /** From 6f21d9274c779a6425bd5056005bc69b99c956a4 Mon Sep 17 00:00:00 2001 From: Manivannan Sadhasivam Date: Wed, 4 May 2022 14:12:12 +0530 Subject: [PATCH 131/177] scsi: ufs: qcom: Enable RPM_AUTOSUSPEND for runtime PM In order to allow the block devices to enter autosuspend mode during runtime, thereby allowing the ufshcd host driver to also runtime suspend, let's make use of the RPM_AUTOSUSPEND flag. Without this flag, userspace needs to enable the autosuspend feature of the block devices through sysfs. Link: https://lore.kernel.org/r/20220504084212.11605-6-manivannan.sadhasivam@linaro.org Reviewed-by: Bjorn Andersson Signed-off-by: Manivannan Sadhasivam Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufs-qcom.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c index 0ee0e9d62794..4dcb232facaa 100644 --- a/drivers/scsi/ufs/ufs-qcom.c +++ b/drivers/scsi/ufs/ufs-qcom.c @@ -874,6 +874,7 @@ static void ufs_qcom_set_caps(struct ufs_hba *hba) hba->caps |= UFSHCD_CAP_WB_EN; hba->caps |= UFSHCD_CAP_CRYPTO; hba->caps |= UFSHCD_CAP_AGGR_POWER_COLLAPSE; + hba->caps |= UFSHCD_CAP_RPM_AUTOSUSPEND; if (host->hw_ver.major >= 0x2) { host->caps = UFS_QCOM_CAP_QUNIPRO | From facc239c87b1d66e7fdadade4fba07f9cecca7d6 Mon Sep 17 00:00:00 2001 From: Bean Huo Date: Thu, 5 May 2022 15:47:02 +0200 Subject: [PATCH 132/177] scsi: ufs: ufshpb: Merge ufshpb_reset() and ufshpb_reset_host() There is no functional change in this patch, just merge ufshpb_reset() and ufshpb_reset_host() into one function ufshpb_toggle_state(). Link: https://lore.kernel.org/r/20220505134707.35929-2-huobean@gmail.com Reviewed-by: Keoseong Park Signed-off-by: Bean Huo Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufshcd.c | 4 ++-- drivers/scsi/ufs/ufshpb.c | 38 ++++++++++++++------------------------ drivers/scsi/ufs/ufshpb.h | 6 ++---- 3 files changed, 18 insertions(+), 30 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 1f82590d153f..1fb3a8b9b03e 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -7226,7 +7226,7 @@ static int ufshcd_host_reset_and_restore(struct ufs_hba *hba) * Stop the host controller and complete the requests * cleared by h/w */ - ufshpb_reset_host(hba); + ufshpb_toggle_state(hba, HPB_PRESENT, HPB_RESET); ufshcd_hba_stop(hba); hba->silence_err_logs = true; ufshcd_complete_requests(hba); @@ -8193,7 +8193,7 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params) /* Enable Auto-Hibernate if configured */ ufshcd_auto_hibern8_enable(hba); - ufshpb_reset(hba); + ufshpb_toggle_state(hba, HPB_RESET, HPB_PRESENT); out: spin_lock_irqsave(hba->host->host_lock, flags); if (ret) diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c index 6e5237a041b5..5412ce6309df 100644 --- a/drivers/scsi/ufs/ufshpb.c +++ b/drivers/scsi/ufs/ufshpb.c @@ -2272,38 +2272,28 @@ out: return flag_res; } -void ufshpb_reset(struct ufs_hba *hba) +/** + * ufshpb_toggle_state - switch HPB state of all LUs + * @hba: per-adapter instance + * @src: expected current HPB state + * @dest: target HPB state to switch to + */ +void ufshpb_toggle_state(struct ufs_hba *hba, enum UFSHPB_STATE src, enum UFSHPB_STATE dest) { struct ufshpb_lu *hpb; struct scsi_device *sdev; shost_for_each_device(sdev, hba->host) { hpb = ufshpb_get_hpb_data(sdev); - if (!hpb) + + if (!hpb || ufshpb_get_state(hpb) != src) continue; + ufshpb_set_state(hpb, dest); - if (ufshpb_get_state(hpb) != HPB_RESET) - continue; - - ufshpb_set_state(hpb, HPB_PRESENT); - } -} - -void ufshpb_reset_host(struct ufs_hba *hba) -{ - struct ufshpb_lu *hpb; - struct scsi_device *sdev; - - shost_for_each_device(sdev, hba->host) { - hpb = ufshpb_get_hpb_data(sdev); - if (!hpb) - continue; - - if (ufshpb_get_state(hpb) != HPB_PRESENT) - continue; - ufshpb_set_state(hpb, HPB_RESET); - ufshpb_cancel_jobs(hpb); - ufshpb_discard_rsp_lists(hpb); + if (dest == HPB_RESET) { + ufshpb_cancel_jobs(hpb); + ufshpb_discard_rsp_lists(hpb); + } } } diff --git a/drivers/scsi/ufs/ufshpb.h b/drivers/scsi/ufs/ufshpb.h index b475dbd78988..7aa0dc58ee9f 100644 --- a/drivers/scsi/ufs/ufshpb.h +++ b/drivers/scsi/ufs/ufshpb.h @@ -288,8 +288,7 @@ static int ufshpb_prep(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) { return 0; static void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) {} static void ufshpb_resume(struct ufs_hba *hba) {} static void ufshpb_suspend(struct ufs_hba *hba) {} -static void ufshpb_reset(struct ufs_hba *hba) {} -static void ufshpb_reset_host(struct ufs_hba *hba) {} +static void ufshpb_toggle_state(struct ufs_hba *hba, enum UFSHPB_STATE src, enum UFSHPB_STATE dest) {} static void ufshpb_init(struct ufs_hba *hba) {} static void ufshpb_init_hpb_lu(struct ufs_hba *hba, struct scsi_device *sdev) {} static void ufshpb_destroy_lu(struct ufs_hba *hba, struct scsi_device *sdev) {} @@ -303,8 +302,7 @@ int ufshpb_prep(struct ufs_hba *hba, struct ufshcd_lrb *lrbp); void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp); void ufshpb_resume(struct ufs_hba *hba); void ufshpb_suspend(struct ufs_hba *hba); -void ufshpb_reset(struct ufs_hba *hba); -void ufshpb_reset_host(struct ufs_hba *hba); +void ufshpb_toggle_state(struct ufs_hba *hba, enum UFSHPB_STATE src, enum UFSHPB_STATE dest); void ufshpb_init(struct ufs_hba *hba); void ufshpb_init_hpb_lu(struct ufs_hba *hba, struct scsi_device *sdev); void ufshpb_destroy_lu(struct ufs_hba *hba, struct scsi_device *sdev); From 6f341ed5e3771ea932b19377302ea97a0a02e0b5 Mon Sep 17 00:00:00 2001 From: Bean Huo Date: Thu, 5 May 2022 15:47:03 +0200 Subject: [PATCH 133/177] scsi: ufs: ufshpb: Remove enum initialization value If the first enumerator has no initializer, the value of the corresponding constant is zero. Link: https://lore.kernel.org/r/20220505134707.35929-3-huobean@gmail.com Reviewed-by: Keoseong Park Signed-off-by: Bean Huo Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufshpb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ufs/ufshpb.h b/drivers/scsi/ufs/ufshpb.h index 7aa0dc58ee9f..b83b9ec9044a 100644 --- a/drivers/scsi/ufs/ufshpb.h +++ b/drivers/scsi/ufs/ufshpb.h @@ -59,8 +59,8 @@ enum UFSHPB_MODE { }; enum UFSHPB_STATE { - HPB_INIT = 0, - HPB_PRESENT = 1, + HPB_INIT, + HPB_PRESENT, HPB_SUSPEND, HPB_FAILED, HPB_RESET, From a3f3c26d4df5475e601f18250a94232fedfa24b8 Mon Sep 17 00:00:00 2001 From: Bean Huo Date: Thu, 5 May 2022 15:47:04 +0200 Subject: [PATCH 134/177] scsi: ufs: ufshpb: Clean up the handler when device resets HPB information "When the device is powered off by the host, the device may restore L2P map data upon power up or build from the host's HPB READ command. In case device powered up and lost HPB information, device can signal to the host through HPB Sense data, by setting HPB Operation as '2' which will inform the host that device reset HPB information." Clean up the handler and make the intent of this handler more readable, no functional change. Link: https://lore.kernel.org/r/20220505134707.35929-4-huobean@gmail.com Reviewed-by: Keoseong Park Reviewed-by: Daejun Park Signed-off-by: Bean Huo Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufshpb.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c index 5412ce6309df..901e0a3d4836 100644 --- a/drivers/scsi/ufs/ufshpb.c +++ b/drivers/scsi/ufs/ufshpb.c @@ -1225,7 +1225,10 @@ out: queue_work(ufshpb_wq, &hpb->map_work); } -static void ufshpb_dev_reset_handler(struct ufshpb_lu *hpb) +/* + * Set the flags of all active regions to RGN_FLAG_UPDATE to let host side reload L2P entries later + */ +static void ufshpb_set_regions_update(struct ufshpb_lu *hpb) { struct victim_select_info *lru_info = &hpb->lru_info; struct ufshpb_region *rgn; @@ -1239,6 +1242,24 @@ static void ufshpb_dev_reset_handler(struct ufshpb_lu *hpb) spin_unlock_irqrestore(&hpb->rgn_state_lock, flags); } +static void ufshpb_dev_reset_handler(struct ufs_hba *hba) +{ + struct scsi_device *sdev; + struct ufshpb_lu *hpb; + + __shost_for_each_device(sdev, hba->host) { + hpb = ufshpb_get_hpb_data(sdev); + if (hpb && hpb->is_hcm) + /* + * For the HPB host mode, in case device powered up and lost HPB + * information, we will set the region flag to be RGN_FLAG_UPDATE, + * it will let host reload its L2P entries(re-activate the region + * in the UFS device). + */ + ufshpb_set_regions_update(hpb); + } +} + /* * This function will parse recommended active subregion information in sense * data field of response UPIU with SAM_STAT_GOOD state. @@ -1313,17 +1334,7 @@ void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) case HPB_RSP_DEV_RESET: dev_warn(&hpb->sdev_ufs_lu->sdev_dev, "UFS device lost HPB information during PM.\n"); - - if (hpb->is_hcm) { - struct scsi_device *sdev; - - __shost_for_each_device(sdev, hba->host) { - struct ufshpb_lu *h = sdev->hostdata; - - if (h) - ufshpb_dev_reset_handler(h); - } - } + ufshpb_dev_reset_handler(hba); break; default: From d4300c552bf8a64e7577ce17c973e51fc89dba7c Mon Sep 17 00:00:00 2001 From: Bean Huo Date: Thu, 5 May 2022 15:47:05 +0200 Subject: [PATCH 135/177] scsi: ufs: ufshpb: Change sysfs node hpb_stats/rb_* prefix to start with rcmd_* According to the documentation of the sysfs nodes rb_noti_cnt, rb_active_cnt and rb_inactive_cnt, these are all related to HPB recommendation in UPIU response packet. 'rcmd' (recommendation) should be the correct abbreviation. Change the sysfs documentation about these sysfs nodes to highlight what they mean under different HPB control modes. Link: https://lore.kernel.org/r/20220505134707.35929-5-huobean@gmail.com Reviewed-by: Keoseong Park Signed-off-by: Bean Huo Signed-off-by: Martin K. Petersen --- Documentation/ABI/testing/sysfs-driver-ufs | 18 +++++++++------- drivers/scsi/ufs/ufshpb.c | 24 +++++++++++----------- drivers/scsi/ufs/ufshpb.h | 6 +++--- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-driver-ufs b/Documentation/ABI/testing/sysfs-driver-ufs index a44ef8bfbadf..6b248abb1bd7 100644 --- a/Documentation/ABI/testing/sysfs-driver-ufs +++ b/Documentation/ABI/testing/sysfs-driver-ufs @@ -1518,7 +1518,7 @@ Description: This entry shows the number of reads that cannot be changed to The file is read only. -What: /sys/class/scsi_device/*/device/hpb_stats/rb_noti_cnt +What: /sys/class/scsi_device/*/device/hpb_stats/rcmd_noti_cnt Date: June 2021 Contact: Daejun Park Description: This entry shows the number of response UPIUs that has @@ -1526,19 +1526,23 @@ Description: This entry shows the number of response UPIUs that has The file is read only. -What: /sys/class/scsi_device/*/device/hpb_stats/rb_active_cnt +What: /sys/class/scsi_device/*/device/hpb_stats/rcmd_active_cnt Date: June 2021 Contact: Daejun Park -Description: This entry shows the number of active sub-regions recommended by - response UPIUs. +Description: For the HPB device control mode, this entry shows the number of + active sub-regions recommended by response UPIUs. For the HPB host control + mode, this entry shows the number of active sub-regions recommended by the + HPB host control mode heuristic algorithm. The file is read only. -What: /sys/class/scsi_device/*/device/hpb_stats/rb_inactive_cnt +What: /sys/class/scsi_device/*/device/hpb_stats/rcmd_inactive_cnt Date: June 2021 Contact: Daejun Park -Description: This entry shows the number of inactive regions recommended by - response UPIUs. +Description: For the HPB device control mode, this entry shows the number of + inactive regions recommended by response UPIUs. For the HPB host control + mode, this entry shows the number of inactive regions recommended by the + HPB host control mode heuristic algorithm. The file is read only. diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c index 901e0a3d4836..4833f20cc7d0 100644 --- a/drivers/scsi/ufs/ufshpb.c +++ b/drivers/scsi/ufs/ufshpb.c @@ -563,7 +563,7 @@ static void ufshpb_update_active_info(struct ufshpb_lu *hpb, int rgn_idx, if (list_empty(&srgn->list_act_srgn)) list_add_tail(&srgn->list_act_srgn, &hpb->lh_act_srgn); - hpb->stats.rb_active_cnt++; + hpb->stats.rcmd_active_cnt++; } static void ufshpb_update_inactive_info(struct ufshpb_lu *hpb, int rgn_idx) @@ -580,7 +580,7 @@ static void ufshpb_update_inactive_info(struct ufshpb_lu *hpb, int rgn_idx) if (list_empty(&rgn->list_inact_rgn)) list_add_tail(&rgn->list_inact_rgn, &hpb->lh_inact_rgn); - hpb->stats.rb_inactive_cnt++; + hpb->stats.rcmd_inactive_cnt++; } static void ufshpb_activate_subregion(struct ufshpb_lu *hpb, @@ -1321,7 +1321,7 @@ void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) if (!ufshpb_is_hpb_rsp_valid(hba, lrbp, rsp_field)) return; - hpb->stats.rb_noti_cnt++; + hpb->stats.rcmd_noti_cnt++; switch (rsp_field->hpb_op) { case HPB_RSP_REQ_REGION_UPDATE: @@ -1724,18 +1724,18 @@ static DEVICE_ATTR_RO(__name) ufshpb_sysfs_attr_show_func(hit_cnt); ufshpb_sysfs_attr_show_func(miss_cnt); -ufshpb_sysfs_attr_show_func(rb_noti_cnt); -ufshpb_sysfs_attr_show_func(rb_active_cnt); -ufshpb_sysfs_attr_show_func(rb_inactive_cnt); +ufshpb_sysfs_attr_show_func(rcmd_noti_cnt); +ufshpb_sysfs_attr_show_func(rcmd_active_cnt); +ufshpb_sysfs_attr_show_func(rcmd_inactive_cnt); ufshpb_sysfs_attr_show_func(map_req_cnt); ufshpb_sysfs_attr_show_func(umap_req_cnt); static struct attribute *hpb_dev_stat_attrs[] = { &dev_attr_hit_cnt.attr, &dev_attr_miss_cnt.attr, - &dev_attr_rb_noti_cnt.attr, - &dev_attr_rb_active_cnt.attr, - &dev_attr_rb_inactive_cnt.attr, + &dev_attr_rcmd_noti_cnt.attr, + &dev_attr_rcmd_active_cnt.attr, + &dev_attr_rcmd_inactive_cnt.attr, &dev_attr_map_req_cnt.attr, &dev_attr_umap_req_cnt.attr, NULL, @@ -2098,9 +2098,9 @@ static void ufshpb_stat_init(struct ufshpb_lu *hpb) { hpb->stats.hit_cnt = 0; hpb->stats.miss_cnt = 0; - hpb->stats.rb_noti_cnt = 0; - hpb->stats.rb_active_cnt = 0; - hpb->stats.rb_inactive_cnt = 0; + hpb->stats.rcmd_noti_cnt = 0; + hpb->stats.rcmd_active_cnt = 0; + hpb->stats.rcmd_inactive_cnt = 0; hpb->stats.map_req_cnt = 0; hpb->stats.umap_req_cnt = 0; } diff --git a/drivers/scsi/ufs/ufshpb.h b/drivers/scsi/ufs/ufshpb.h index b83b9ec9044a..0d6e6004d783 100644 --- a/drivers/scsi/ufs/ufshpb.h +++ b/drivers/scsi/ufs/ufshpb.h @@ -211,9 +211,9 @@ struct ufshpb_params { struct ufshpb_stats { u64 hit_cnt; u64 miss_cnt; - u64 rb_noti_cnt; - u64 rb_active_cnt; - u64 rb_inactive_cnt; + u64 rcmd_noti_cnt; + u64 rcmd_active_cnt; + u64 rcmd_inactive_cnt; u64 map_req_cnt; u64 pre_req_cnt; u64 umap_req_cnt; From 32d6eab31ac3bc7fecdec86541fa1458a2eb18a9 Mon Sep 17 00:00:00 2001 From: Bean Huo Date: Thu, 5 May 2022 15:47:06 +0200 Subject: [PATCH 136/177] scsi: ufs: ufshpb: Add handing of device reset regions in HPB device mode In UFS HPB Spec JESD220-3A, "5.8. Active and inactive information upon power cycle ... When the device is powered off by the host, the device may restore L2P map data upon power up or build from the host's HPB READ command. In case device powered up and lost HPB information, device can signal to the host through HPB Sense data, by setting HPB Operation as '2' which will inform the host that device reset HPB information." Therefore, for HPB device control mode, if the UFS device is reset via the RST_N pin, the active region information in the device will be reset. If the host side receives this notification from the device side, it is recommended to inactivate all active regions in the host's HPB cache. Link: https://lore.kernel.org/r/20220505134707.35929-6-huobean@gmail.com Reviewed-by: Keoseong Park Reviewed-by: Daejun Park Signed-off-by: Bean Huo Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufshpb.c | 82 +++++++++++++++++++++++++++------------ 1 file changed, 58 insertions(+), 24 deletions(-) diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c index 4833f20cc7d0..859e7ee7bf57 100644 --- a/drivers/scsi/ufs/ufshpb.c +++ b/drivers/scsi/ufs/ufshpb.c @@ -1137,6 +1137,39 @@ out: spin_unlock_irqrestore(&hpb->rgn_state_lock, flags); return ret; } +/** + *ufshpb_submit_region_inactive() - submit a region to be inactivated later + *@hpb: per-LU HPB instance + *@region_index: the index associated with the region that will be inactivated later + */ +static void ufshpb_submit_region_inactive(struct ufshpb_lu *hpb, int region_index) +{ + int subregion_index; + struct ufshpb_region *rgn; + struct ufshpb_subregion *srgn; + + /* + * Remove this region from active region list and add it to inactive list + */ + spin_lock(&hpb->rsp_list_lock); + ufshpb_update_inactive_info(hpb, region_index); + spin_unlock(&hpb->rsp_list_lock); + + rgn = hpb->rgn_tbl + region_index; + + /* + * Set subregion state to be HPB_SRGN_INVALID, there will no HPB read on this subregion + */ + spin_lock(&hpb->rgn_state_lock); + if (rgn->rgn_state != HPB_RGN_INACTIVE) { + for (subregion_index = 0; subregion_index < rgn->srgn_cnt; subregion_index++) { + srgn = rgn->srgn_tbl + subregion_index; + if (srgn->srgn_state == HPB_SRGN_VALID) + srgn->srgn_state = HPB_SRGN_INVALID; + } + } + spin_unlock(&hpb->rgn_state_lock); +} static void ufshpb_rsp_req_region_update(struct ufshpb_lu *hpb, struct utp_hpb_rsp *rsp_field) @@ -1196,25 +1229,8 @@ static void ufshpb_rsp_req_region_update(struct ufshpb_lu *hpb, for (i = 0; i < rsp_field->inactive_rgn_cnt; i++) { rgn_i = be16_to_cpu(rsp_field->hpb_inactive_field[i]); - dev_dbg(&hpb->sdev_ufs_lu->sdev_dev, - "inactivate(%d) region %d\n", i, rgn_i); - - spin_lock(&hpb->rsp_list_lock); - ufshpb_update_inactive_info(hpb, rgn_i); - spin_unlock(&hpb->rsp_list_lock); - - rgn = hpb->rgn_tbl + rgn_i; - - spin_lock(&hpb->rgn_state_lock); - if (rgn->rgn_state != HPB_RGN_INACTIVE) { - for (srgn_i = 0; srgn_i < rgn->srgn_cnt; srgn_i++) { - srgn = rgn->srgn_tbl + srgn_i; - if (srgn->srgn_state == HPB_SRGN_VALID) - srgn->srgn_state = HPB_SRGN_INVALID; - } - } - spin_unlock(&hpb->rgn_state_lock); - + dev_dbg(&hpb->sdev_ufs_lu->sdev_dev, "inactivate(%d) region %d\n", i, rgn_i); + ufshpb_submit_region_inactive(hpb, rgn_i); } out: @@ -1249,14 +1265,32 @@ static void ufshpb_dev_reset_handler(struct ufs_hba *hba) __shost_for_each_device(sdev, hba->host) { hpb = ufshpb_get_hpb_data(sdev); - if (hpb && hpb->is_hcm) + if (!hpb) + continue; + + if (hpb->is_hcm) { /* - * For the HPB host mode, in case device powered up and lost HPB - * information, we will set the region flag to be RGN_FLAG_UPDATE, - * it will let host reload its L2P entries(re-activate the region - * in the UFS device). + * For the HPB host control mode, in case device powered up and lost HPB + * information, we will set the region flag to be RGN_FLAG_UPDATE, it will + * let host reload its L2P entries(reactivate region in the UFS device). */ ufshpb_set_regions_update(hpb); + } else { + /* + * For the HPB device control mode, if host side receives 02h:HPB Operation + * in UPIU response, which means device recommends the host side should + * inactivate all active regions. Here we add all active regions to inactive + * list, they will be inactivated later in ufshpb_map_work_handler(). + */ + struct victim_select_info *lru_info = &hpb->lru_info; + struct ufshpb_region *rgn; + + list_for_each_entry(rgn, &lru_info->lh_lru_rgn, list_lru_rgn) + ufshpb_submit_region_inactive(hpb, rgn->rgn_idx); + + if (ufshpb_get_state(hpb) == HPB_PRESENT) + queue_work(ufshpb_wq, &hpb->map_work); + } } } From 18ebe2390c6197738cbe67aa26acabe7815060bd Mon Sep 17 00:00:00 2001 From: Bean Huo Date: Thu, 5 May 2022 15:47:07 +0200 Subject: [PATCH 137/177] scsi: ufs: ufshpb: Clean up ufshpb_suspend()/resume() ufshpb_resume() is only called when the HPB state is HPB_SUSPEND, so the check statement for "ufshpb_get_state(hpb) != HPB_PRESENT" is useless. Link: https://lore.kernel.org/r/20220505134707.35929-7-huobean@gmail.com Reviewed-by: Keoseong Park Signed-off-by: Bean Huo Signed-off-by: Martin K. Petersen --- drivers/scsi/ufs/ufshpb.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c index 859e7ee7bf57..f1f65383e97d 100644 --- a/drivers/scsi/ufs/ufshpb.c +++ b/drivers/scsi/ufs/ufshpb.c @@ -2349,11 +2349,9 @@ void ufshpb_suspend(struct ufs_hba *hba) shost_for_each_device(sdev, hba->host) { hpb = ufshpb_get_hpb_data(sdev); - if (!hpb) + if (!hpb || ufshpb_get_state(hpb) != HPB_PRESENT) continue; - if (ufshpb_get_state(hpb) != HPB_PRESENT) - continue; ufshpb_set_state(hpb, HPB_SUSPEND); ufshpb_cancel_jobs(hpb); } @@ -2366,20 +2364,15 @@ void ufshpb_resume(struct ufs_hba *hba) shost_for_each_device(sdev, hba->host) { hpb = ufshpb_get_hpb_data(sdev); - if (!hpb) + if (!hpb || ufshpb_get_state(hpb) != HPB_SUSPEND) continue; - if ((ufshpb_get_state(hpb) != HPB_PRESENT) && - (ufshpb_get_state(hpb) != HPB_SUSPEND)) - continue; ufshpb_set_state(hpb, HPB_PRESENT); ufshpb_kick_map_work(hpb); if (hpb->is_hcm) { - unsigned int poll = - hpb->params.timeout_polling_interval_ms; + unsigned int poll = hpb->params.timeout_polling_interval_ms; - schedule_delayed_work(&hpb->ufshpb_read_to_work, - msecs_to_jiffies(poll)); + schedule_delayed_work(&hpb->ufshpb_read_to_work, msecs_to_jiffies(poll)); } } } From 84c6f99e39074d45f75986e42ca28e27c140fd0d Mon Sep 17 00:00:00 2001 From: James Smart Date: Thu, 5 May 2022 20:55:08 -0700 Subject: [PATCH 138/177] scsi: lpfc: Fix element offset in __lpfc_sli_release_iocbq_s4() The prior commit that moved from iocb elements to explicit wqe elements missed a name change. Correct __lpfc_sli_release_iocbq_s4() to reference wqe rather than iocb. Link: https://lore.kernel.org/r/20220506035519.50908-2-jsmart2021@gmail.com Fixes: a680a9298e7b ("scsi: lpfc: SLI path split: Refactor lpfc_iocbq") Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_sli.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index aba06794146d..d2900ac8de9d 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -1373,7 +1373,7 @@ static void __lpfc_sli_release_iocbq_s4(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq) { struct lpfc_sglq *sglq; - size_t start_clean = offsetof(struct lpfc_iocbq, iocb); + size_t start_clean = offsetof(struct lpfc_iocbq, wqe); unsigned long iflag = 0; struct lpfc_sli_ring *pring; From ba3d58a1df460ba28bb5989ad7269ff48682375a Mon Sep 17 00:00:00 2001 From: James Smart Date: Thu, 5 May 2022 20:55:09 -0700 Subject: [PATCH 139/177] scsi: lpfc: Fill in missing ndlp kref puts in error paths Code review, following every lpfc_nlp_get() call vs calls during error handling, discovered cases of missing put calls. Correct by adding ndlp kref puts in the respective error paths. Also added comments to several of the error paths to record relationships to reference counts. Link: https://lore.kernel.org/r/20220506035519.50908-3-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_els.c | 11 +++++------ drivers/scsi/lpfc/lpfc_nportdisc.c | 15 +++++++++++++-- drivers/scsi/lpfc/lpfc_nvme.c | 5 +++++ drivers/scsi/lpfc/lpfc_sli.c | 6 +++++- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index 527f2c148e04..ace812ce857d 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -8725,19 +8725,18 @@ lpfc_issue_els_rrq(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, elsiocb->cmd_cmpl = lpfc_cmpl_els_rrq; elsiocb->ndlp = lpfc_nlp_get(ndlp); - if (!elsiocb->ndlp) { - lpfc_els_free_iocb(phba, elsiocb); - return 1; - } + if (!elsiocb->ndlp) + goto io_err; ret = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0); - if (ret == IOCB_ERROR) + if (ret == IOCB_ERROR) { + lpfc_nlp_put(ndlp); goto io_err; + } return 0; io_err: lpfc_els_free_iocb(phba, elsiocb); - lpfc_nlp_put(ndlp); return 1; } diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c index 5e4822bf54f4..639f86635127 100644 --- a/drivers/scsi/lpfc/lpfc_nportdisc.c +++ b/drivers/scsi/lpfc/lpfc_nportdisc.c @@ -513,6 +513,10 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, lpfc_config_link(phba, link_mbox); link_mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; link_mbox->vport = vport; + + /* The default completion handling for CONFIG_LINK + * does not require the ndlp so no reference is needed. + */ link_mbox->ctx_ndlp = ndlp; rc = lpfc_sli_issue_mbox(phba, link_mbox, MBX_NOWAIT); @@ -633,6 +637,9 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, */ login_mbox->mbox_cmpl = lpfc_defer_plogi_acc; login_mbox->ctx_ndlp = lpfc_nlp_get(ndlp); + if (!login_mbox->ctx_ndlp) + goto out; + login_mbox->context3 = save_iocb; /* For PLOGI ACC */ spin_lock_irq(&ndlp->lock); @@ -641,8 +648,10 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, /* Start the ball rolling by issuing REG_LOGIN here */ rc = lpfc_sli_issue_mbox(phba, login_mbox, MBX_NOWAIT); - if (rc == MBX_NOT_FINISHED) + if (rc == MBX_NOT_FINISHED) { + lpfc_nlp_put(ndlp); goto out; + } lpfc_nlp_set_state(vport, ndlp, NLP_STE_REG_LOGIN_ISSUE); return 1; @@ -1099,8 +1108,10 @@ lpfc_release_rpi(struct lpfc_hba *phba, struct lpfc_vport *vport, ndlp->nlp_rpi, ndlp->nlp_DID, ndlp->nlp_flag); rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); - if (rc == MBX_NOT_FINISHED) + if (rc == MBX_NOT_FINISHED) { + lpfc_nlp_put(ndlp); mempool_free(pmb, phba->mbox_mem_pool); + } } } diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c index 376f6c0265c0..3aebd01e07fd 100644 --- a/drivers/scsi/lpfc/lpfc_nvme.c +++ b/drivers/scsi/lpfc/lpfc_nvme.c @@ -2357,6 +2357,11 @@ lpfc_nvme_register_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) rpinfo.dev_loss_tmo = vport->cfg_devloss_tmo; spin_lock_irq(&ndlp->lock); + + /* If an oldrport exists, so does the ndlp reference. If not + * a new reference is needed because either the node has never + * been registered or it's been unregistered and getting deleted. + */ oldrport = lpfc_ndlp_get_nrport(ndlp); if (oldrport) { prev_ndlp = oldrport->ndlp; diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index d2900ac8de9d..fe4eb36426df 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -20684,8 +20684,12 @@ lpfc_cleanup_pending_mbox(struct lpfc_vport *vport) mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) { act_mbx_ndlp = (struct lpfc_nodelist *)mb->ctx_ndlp; - /* Put reference count for delayed processing */ + + /* This reference is local to this routine. The + * reference is removed at routine exit. + */ act_mbx_ndlp = lpfc_nlp_get(act_mbx_ndlp); + /* Unregister the RPI when mailbox complete */ mb->mbox_flag |= LPFC_MBX_IMED_UNREG; } From b7e952cbc63c8b98a7433f294321c3b89850305c Mon Sep 17 00:00:00 2001 From: James Smart Date: Thu, 5 May 2022 20:55:10 -0700 Subject: [PATCH 140/177] scsi: lpfc: Fix ndlp put following a LOGO completion During testing with repeated asynchronous resets of the target, an issue was found when the driver issues a LOGO to disconnect its login and recover all exchanges. The LOGO command takes a node reference but neglects to remove it, keeping the node reference count artifically high. Add a call to lpfc_nlp_put() to lpfc_nlp_logo_unreg() and move the mempool free call to the routine exit along with the needed put. This is always safe as this will not be the last reference removed as lpfc_unreg_rpi() ensures there is an additional reference on the ndlp. Link: https://lore.kernel.org/r/20220506035519.50908-4-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_hbadisc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index 2d846256990c..e4805101cd5c 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c @@ -5235,7 +5235,6 @@ lpfc_nlp_logo_unreg(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) if (!ndlp) return; lpfc_issue_els_logo(vport, ndlp, 0); - mempool_free(pmb, phba->mbox_mem_pool); /* Check to see if there are any deferred events to process */ if ((ndlp->nlp_flag & NLP_UNREG_INP) && @@ -5262,6 +5261,13 @@ lpfc_nlp_logo_unreg(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) ndlp->nlp_flag &= ~NLP_UNREG_INP; spin_unlock_irq(&ndlp->lock); } + + /* The node has an outstanding reference for the unreg. Now + * that the LOGO action and cleanup are finished, release + * resources. + */ + lpfc_nlp_put(ndlp); + mempool_free(pmb, phba->mbox_mem_pool); } /* From ead76d4c09b89f4c8d632648026a476a5a34fde8 Mon Sep 17 00:00:00 2001 From: James Smart Date: Thu, 5 May 2022 20:55:11 -0700 Subject: [PATCH 141/177] scsi: lpfc: Inhibit aborts if external loopback plug is inserted After running a short external loopback test, when the external loopback is removed and a normal cable inserted that is directly connected to a target device, the system oops in the llpfc_set_rrq_active() routine. When the loopback was inserted an FLOGI was transmit. As we're looped back, we receive the FLOGI request. The FLOGI is ABTS'd as we recognize the same wppn thus understand it's a loopback. However, as the ABTS sends address information the port is not set to (fffffe), the ABTS is dropped on the wire. A short 1 frame loopback test is run and completes before the ABTS times out. The looback is unplugged and the new cable plugged in, and the an FLOGI to the new device occurs and completes. Due to a mixup in ref counting the completion of the new FLOGI releases the fabric ndlp. Then the original ABTS completes and references the released ndlp generating the oops. Correct by no-op'ing the ABTS when in loopback mode (it will be dropped anyway). Added a flag to track the mode to recognize when it should be no-op'd. Link: https://lore.kernel.org/r/20220506035519.50908-5-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc.h | 1 + drivers/scsi/lpfc/lpfc_els.c | 12 ++++++++++++ drivers/scsi/lpfc/lpfc_hbadisc.c | 3 +++ drivers/scsi/lpfc/lpfc_sli.c | 8 +++++--- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h index 346661dc5bf2..405c8a8dd795 100644 --- a/drivers/scsi/lpfc/lpfc.h +++ b/drivers/scsi/lpfc/lpfc.h @@ -1025,6 +1025,7 @@ struct lpfc_hba { #define LS_MDS_LINK_DOWN 0x8 /* MDS Diagnostics Link Down */ #define LS_MDS_LOOPBACK 0x10 /* MDS Diagnostics Link Up (Loopback) */ #define LS_CT_VEN_RPA 0x20 /* Vendor RPA sent to switch */ +#define LS_EXTERNAL_LOOPBACK 0x40 /* External loopback plug inserted */ uint32_t hba_flag; /* hba generic flags */ #define HBA_ERATT_HANDLED 0x1 /* This flag is set when eratt handled */ diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index ace812ce857d..583a287b2d0c 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -1373,6 +1373,9 @@ lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, phba->hba_flag |= (HBA_FLOGI_ISSUED | HBA_FLOGI_OUTSTANDING); + /* Clear external loopback plug detected flag */ + phba->link_flag &= ~LS_EXTERNAL_LOOPBACK; + /* Check for a deferred FLOGI ACC condition */ if (phba->defer_flogi_acc_flag) { /* lookup ndlp for received FLOGI */ @@ -8128,6 +8131,9 @@ lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, uint32_t fc_flag = 0; uint32_t port_state = 0; + /* Clear external loopback plug detected flag */ + phba->link_flag &= ~LS_EXTERNAL_LOOPBACK; + cmd = *lp++; sp = (struct serv_parm *) lp; @@ -8179,6 +8185,12 @@ lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, return 1; } + /* External loopback plug insertion detected */ + phba->link_flag |= LS_EXTERNAL_LOOPBACK; + + lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS | LOG_LIBDFC, + "1119 External Loopback plug detected\n"); + /* abort the flogi coming back to ourselves * due to external loopback on the port. */ diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index e4805101cd5c..a833a493a3ee 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c @@ -1229,6 +1229,9 @@ lpfc_linkdown(struct lpfc_hba *phba) phba->defer_flogi_acc_flag = false; + /* Clear external loopback plug detected flag */ + phba->link_flag &= ~LS_EXTERNAL_LOOPBACK; + spin_lock_irq(&phba->hbalock); phba->fcf.fcf_flag &= ~(FCF_AVAILABLE | FCF_SCAN_DONE); spin_unlock_irq(&phba->hbalock); diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index fe4eb36426df..b509b3147759 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -12201,7 +12201,8 @@ lpfc_sli_issue_abort_iotag(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, if (phba->link_state < LPFC_LINK_UP || (phba->sli_rev == LPFC_SLI_REV4 && - phba->sli4_hba.link_state.status == LPFC_FC_LA_TYPE_LINK_DOWN)) + phba->sli4_hba.link_state.status == LPFC_FC_LA_TYPE_LINK_DOWN) || + (phba->link_flag & LS_EXTERNAL_LOOPBACK)) ia = true; else ia = false; @@ -12660,7 +12661,8 @@ lpfc_sli_abort_taskmgmt(struct lpfc_vport *vport, struct lpfc_sli_ring *pring, ndlp = lpfc_cmd->rdata->pnode; if (lpfc_is_link_up(phba) && - (ndlp && ndlp->nlp_state == NLP_STE_MAPPED_NODE)) + (ndlp && ndlp->nlp_state == NLP_STE_MAPPED_NODE) && + !(phba->link_flag & LS_EXTERNAL_LOOPBACK)) ia = false; else ia = true; @@ -21112,7 +21114,7 @@ lpfc_sli4_issue_abort_iotag(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, abtswqe = &abtsiocb->wqe; memset(abtswqe, 0, sizeof(*abtswqe)); - if (!lpfc_is_link_up(phba)) + if (!lpfc_is_link_up(phba) || (phba->link_flag & LS_EXTERNAL_LOOPBACK)) bf_set(abort_cmd_ia, &abtswqe->abort_cmd, 1); bf_set(abort_cmd_criteria, &abtswqe->abort_cmd, T_XRI_TAG); abtswqe->abort_cmd.rsrvd5 = 0; From 596fc8adb171dce3751a359018e2ade612af8d97 Mon Sep 17 00:00:00 2001 From: James Smart Date: Thu, 5 May 2022 20:55:12 -0700 Subject: [PATCH 142/177] scsi: lpfc: Fix dmabuf ptr assignment in lpfc_ct_reject_event() Upon driver receipt of a CT cmd for type = 0xFA (Management Server) and subtype = 0x11 (Fabric Device Management Interface), the driver is responding with garbage CT cmd data when it should send a properly formed RJT. The __lpfc_prep_xmit_seq64_s4() routine was using the wrong buffer for the reject. Fix by converting the routine to use the buffer specified in the bde within the wqe rather than the ill-set bmp element. Link: https://lore.kernel.org/r/20220506035519.50908-6-jsmart2021@gmail.com Fixes: 61910d6a5243 ("scsi: lpfc: SLI path split: Refactor CT paths") Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_sli.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index b509b3147759..573526f08baf 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -10808,24 +10808,15 @@ __lpfc_sli_prep_xmit_seq64_s4(struct lpfc_iocbq *cmdiocbq, { union lpfc_wqe128 *wqe; struct ulp_bde64 *bpl; - struct ulp_bde64_le *bde; wqe = &cmdiocbq->wqe; memset(wqe, 0, sizeof(*wqe)); /* Words 0 - 2 */ bpl = (struct ulp_bde64 *)bmp->virt; - if (cmdiocbq->cmd_flag & (LPFC_IO_LIBDFC | LPFC_IO_LOOPBACK)) { - wqe->xmit_sequence.bde.addrHigh = bpl->addrHigh; - wqe->xmit_sequence.bde.addrLow = bpl->addrLow; - wqe->xmit_sequence.bde.tus.w = bpl->tus.w; - } else { - bde = (struct ulp_bde64_le *)&wqe->xmit_sequence.bde; - bde->addr_low = cpu_to_le32(putPaddrLow(bmp->phys)); - bde->addr_high = cpu_to_le32(putPaddrHigh(bmp->phys)); - bde->type_size = cpu_to_le32(bpl->tus.f.bdeSize); - bde->type_size |= cpu_to_le32(ULP_BDE64_TYPE_BDE_64); - } + wqe->xmit_sequence.bde.addrHigh = bpl->addrHigh; + wqe->xmit_sequence.bde.addrLow = bpl->addrLow; + wqe->xmit_sequence.bde.tus.w = bpl->tus.w; /* Word 5 */ bf_set(wqe_ls, &wqe->xmit_sequence.wge_ctl, last_seq); From 4a0f4aff3ce5a3efdf674f3bc1ba7d2642fa55ea Mon Sep 17 00:00:00 2001 From: James Smart Date: Thu, 5 May 2022 20:55:13 -0700 Subject: [PATCH 143/177] scsi: lpfc: Use list_for_each_entry_safe() in rscn_recovery_check() In GID_PT mode with lpfc_ns_query=1, a race condition between iterating the vport->fc_nodes list in lpfc_rscn_recovery_check() and cleanup of an ndlp can trigger a crash while processing the RSCN of another initiator from the same zone. During iteration of the vport->fc_nodes list, an ndlp is cleaned up and released. lpfc_dequeue_node() is called from lpfc_cleanup_node() leading to a bad ndlp dereference in lpfc_rscn_recovery_check(). Change list_for_each_entry() to list_for_each_entry_safe() in lpfc_rscn_recovery_check() to protect against removal of an initiator ndlp, while walking the vport->fc_nodes list. Link: https://lore.kernel.org/r/20220506035519.50908-7-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_els.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index 583a287b2d0c..3671e0f8e041 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -7708,10 +7708,10 @@ return_did_out: static int lpfc_rscn_recovery_check(struct lpfc_vport *vport) { - struct lpfc_nodelist *ndlp = NULL; + struct lpfc_nodelist *ndlp = NULL, *n; /* Move all affected nodes by pending RSCNs to NPR state. */ - list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { + list_for_each_entry_safe(ndlp, n, &vport->fc_nodes, nlp_listp) { if ((ndlp->nlp_state == NLP_STE_UNUSED_NODE) || !lpfc_rscn_payload_check(vport, ndlp->nlp_DID)) continue; From dc8a71bd414fb550fd17164440c409f9ecf4b2a8 Mon Sep 17 00:00:00 2001 From: James Smart Date: Thu, 5 May 2022 20:55:14 -0700 Subject: [PATCH 144/177] scsi: lpfc: Decrement outstanding gidft_inp counter if lpfc_err_lost_link() During large NPIV port testing, it was sometimes seen that not all vports would log back in to the target device. There are instances when the fabric is slow to respond to a spam of GID_PT requests and as a result the SLI PORT may abort the GID_PT request because the fabric takes so long. lpfc_cmpl_ct_cmd_gid_pt() would enter the lpfc_err_lost_link() logic and attempt to lpfc_els_flush_rscn(), which is fine, but forgets to decrement the gidft_inp counter. This results in a vport->gidft_inp never reaching 0 and never restarting discovery again. Decrement vport->gidft_inp if lpfc_err_lost_link() is true for both lpfc_cmpl_ct_cmd_gid_pt() and lpfc_cmpl_ct_cmd_gid_ft(). Increase logging info during RSCN timeout and lpfc_err_lost_link() events. Link: https://lore.kernel.org/r/20220506035519.50908-8-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_ct.c | 16 ++++++++++++++-- drivers/scsi/lpfc/lpfc_hbadisc.c | 5 +++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c index 6cda8ee25d4f..094199d1006a 100644 --- a/drivers/scsi/lpfc/lpfc_ct.c +++ b/drivers/scsi/lpfc/lpfc_ct.c @@ -960,9 +960,15 @@ lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, } if (lpfc_error_lost_link(ulp_status, ulp_word4)) { lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, - "0226 NS query failed due to link event\n"); + "0226 NS query failed due to link event: " + "ulp_status x%x ulp_word4 x%x fc_flag x%x " + "port_state x%x gidft_inp x%x\n", + ulp_status, ulp_word4, vport->fc_flag, + vport->port_state, vport->gidft_inp); if (vport->fc_flag & FC_RSCN_MODE) lpfc_els_flush_rscn(vport); + if (vport->gidft_inp) + vport->gidft_inp--; goto out; } @@ -1177,9 +1183,15 @@ lpfc_cmpl_ct_cmd_gid_pt(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, } if (lpfc_error_lost_link(ulp_status, ulp_word4)) { lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, - "4166 NS query failed due to link event\n"); + "4166 NS query failed due to link event: " + "ulp_status x%x ulp_word4 x%x fc_flag x%x " + "port_state x%x gidft_inp x%x\n", + ulp_status, ulp_word4, vport->fc_flag, + vport->port_state, vport->gidft_inp); if (vport->fc_flag & FC_RSCN_MODE) lpfc_els_flush_rscn(vport); + if (vport->gidft_inp) + vport->gidft_inp--; goto out; } diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index a833a493a3ee..3ab22ac49e49 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c @@ -6355,8 +6355,9 @@ restart_disc: lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, "0231 RSCN timeout Data: x%x " - "x%x\n", - vport->fc_ns_retry, LPFC_MAX_NS_RETRY); + "x%x x%x x%x\n", + vport->fc_ns_retry, LPFC_MAX_NS_RETRY, + vport->port_state, vport->gidft_inp); /* Cleanup any outstanding ELS commands */ lpfc_els_flush_cmd(vport); From 5099478e436f0acd8c76495590c105668f2d8afc Mon Sep 17 00:00:00 2001 From: James Smart Date: Thu, 5 May 2022 20:55:15 -0700 Subject: [PATCH 145/177] scsi: lpfc: Change VMID registration to be based on fabric parameters Currently, VMID registration is configured via module parameters. This could lead to VMID compatibility issues if two ports are connected to different brands of switches, as the two brands implement VMID differently. Make logical changes so that VMID registration is based on common service parameters from FLOGI_ACC with fabric rather than module parameters. Link: https://lore.kernel.org/r/20220506035519.50908-9-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc.h | 1 + drivers/scsi/lpfc/lpfc_els.c | 3 ++- drivers/scsi/lpfc/lpfc_scsi.c | 17 +++++++++-------- drivers/scsi/lpfc/lpfc_sli.c | 4 ++-- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h index 405c8a8dd795..f8f5b4a2d523 100644 --- a/drivers/scsi/lpfc/lpfc.h +++ b/drivers/scsi/lpfc/lpfc.h @@ -714,6 +714,7 @@ struct lpfc_vport { #define LPFC_VMID_QFPA_CMPL 0x4 #define LPFC_VMID_QOS_ENABLED 0x8 #define LPFC_VMID_TIMER_ENBLD 0x10 +#define LPFC_VMID_TYPE_PRIO 0x20 struct fc_qfpa_res *qfpa_res; struct fc_vport *fc_vport; diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index 3671e0f8e041..33fac4401e8f 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -1105,7 +1105,8 @@ stop_rr_fcf_flogi: sp->cmn.priority_tagging, kref_read(&ndlp->kref)); if (sp->cmn.priority_tagging) - vport->vmid_flag |= LPFC_VMID_ISSUE_QFPA; + vport->phba->pport->vmid_flag |= (LPFC_VMID_ISSUE_QFPA | + LPFC_VMID_TYPE_PRIO); if (vport->port_state == LPFC_FLOGI) { /* diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index 1959c58d22f8..1d134a01ff3e 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -5344,9 +5344,9 @@ static void lpfc_vmid_update_entry(struct lpfc_vport *vport, struct scsi_cmnd { u64 *lta; - if (vport->vmid_priority_tagging) + if (vport->phba->pport->vmid_flag & LPFC_VMID_TYPE_PRIO) tag->cs_ctl_vmid = vmp->un.cs_ctl_vmid; - else + else if (vport->phba->cfg_vmid_app_header) tag->app_id = vmp->un.app_id; if (cmd->sc_data_direction == DMA_TO_DEVICE) @@ -5391,11 +5391,12 @@ static int lpfc_vmid_get_appid(struct lpfc_vport *vport, char *uuid, struct scsi_cmnd * cmd, union lpfc_vmid_io_tag *tag) { struct lpfc_vmid *vmp = NULL; - int hash, len, rc, i; + int hash, len, rc = -EPERM, i; /* check if QFPA is complete */ - if (lpfc_vmid_is_type_priority_tag(vport) && !(vport->vmid_flag & - LPFC_VMID_QFPA_CMPL)) { + if (lpfc_vmid_is_type_priority_tag(vport) && + !(vport->vmid_flag & LPFC_VMID_QFPA_CMPL) && + (vport->vmid_flag & LPFC_VMID_ISSUE_QFPA)) { vport->work_port_events |= WORKER_CHECK_VMID_ISSUE_QFPA; return -EAGAIN; } @@ -5469,7 +5470,7 @@ static int lpfc_vmid_get_appid(struct lpfc_vport *vport, char *uuid, struct vport->vmid_inactivity_timeout ? 1 : 0; /* if type priority tag, get next available VMID */ - if (lpfc_vmid_is_type_priority_tag(vport)) + if (vport->phba->pport->vmid_flag & LPFC_VMID_TYPE_PRIO) lpfc_vmid_assign_cs_ctl(vport, vmp); /* allocate the per cpu variable for holding */ @@ -5488,9 +5489,9 @@ static int lpfc_vmid_get_appid(struct lpfc_vport *vport, char *uuid, struct write_unlock(&vport->vmid_lock); /* complete transaction with switch */ - if (lpfc_vmid_is_type_priority_tag(vport)) + if (vport->phba->pport->vmid_flag & LPFC_VMID_TYPE_PRIO) rc = lpfc_vmid_uvem(vport, vmp, true); - else + else if (vport->phba->cfg_vmid_app_header) rc = lpfc_vmid_cmd(vport, SLI_CTAS_RAPP_IDENT, vmp); if (!rc) { write_lock(&vport->vmid_lock); diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index 573526f08baf..79d2ef5f0f05 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -10377,11 +10377,11 @@ lpfc_prep_embed_io(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) /* add the VMID tags as per switch response */ if (unlikely(piocb->cmd_flag & LPFC_IO_VMID)) { - if (phba->pport->vmid_priority_tagging) { + if (phba->pport->vmid_flag & LPFC_VMID_TYPE_PRIO) { bf_set(wqe_ccpe, &wqe->fcp_iwrite.wqe_com, 1); bf_set(wqe_ccp, &wqe->fcp_iwrite.wqe_com, (piocb->vmid_tag.cs_ctl_vmid)); - } else { + } else if (phba->cfg_vmid_app_header) { bf_set(wqe_appid, &wqe->fcp_iwrite.wqe_com, 1); bf_set(wqe_wqes, &wqe->fcp_iwrite.wqe_com, 1); wqe->words[31] = piocb->vmid_tag.app_id; From de3ec318fee32313092b609f88475f86e58f3fe5 Mon Sep 17 00:00:00 2001 From: James Smart Date: Thu, 5 May 2022 20:55:16 -0700 Subject: [PATCH 146/177] scsi: lpfc: Rework FDMI initialization after link up After a link up, it's possible for the switch to change FDMI support (e.g. FDMI1 vs FDMI2 vs SmartSAN). If the switch reverts to FDMI1, then the revert is currently not detected. Additionally, when NPIV is configured, it's possible the physical port's RHBA is unprocessed by the switch before reciept of an NPIV port issued RPRT. This causes some switches vendors to reject the NPIV's RPRT. Fix by reinitializing base FDMI mode on link up, and defer FDMI vport RPRT submission until after confirming physical port's RHBA is completed. Link: https://lore.kernel.org/r/20220506035519.50908-10-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc.h | 2 + drivers/scsi/lpfc/lpfc_crtn.h | 1 + drivers/scsi/lpfc/lpfc_ct.c | 98 +++++++++++++++++++++++++++++--- drivers/scsi/lpfc/lpfc_hbadisc.c | 5 +- drivers/scsi/lpfc/lpfc_init.c | 43 ++++++++++---- 5 files changed, 129 insertions(+), 20 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h index f8f5b4a2d523..da9070cdad91 100644 --- a/drivers/scsi/lpfc/lpfc.h +++ b/drivers/scsi/lpfc/lpfc.h @@ -612,6 +612,7 @@ struct lpfc_vport { #define FC_CT_RSNN_NN 0x4 /* RSNN_NN accepted by switch */ #define FC_CT_RSPN_ID 0x8 /* RSPN_ID accepted by switch */ #define FC_CT_RFT_ID 0x10 /* RFT_ID accepted by switch */ +#define FC_CT_RPRT_DEFER 0x20 /* Defer issuing FDMI RPRT */ struct list_head fc_nodes; @@ -1059,6 +1060,7 @@ struct lpfc_hba { #define HBA_HBEAT_INP 0x4000000 /* mbox HBEAT is in progress */ #define HBA_HBEAT_TMO 0x8000000 /* HBEAT initiated after timeout */ #define HBA_FLOGI_OUTSTANDING 0x10000000 /* FLOGI is outstanding */ +#define HBA_RHBA_CMPL 0x20000000 /* RHBA FDMI command is successful */ struct completion *fw_dump_cmpl; /* cmpl event tracker for fw_dump */ uint32_t fcp_ring_in_use; /* When polling test if intr-hndlr active*/ diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h index 6f88fd0df8b0..b0775be31d5c 100644 --- a/drivers/scsi/lpfc/lpfc_crtn.h +++ b/drivers/scsi/lpfc/lpfc_crtn.h @@ -434,6 +434,7 @@ void lpfc_nvmet_buf_free(struct lpfc_hba *phba, void *virtp, dma_addr_t dma); void lpfc_in_buf_free(struct lpfc_hba *, struct lpfc_dmabuf *); void lpfc_rq_buf_free(struct lpfc_hba *phba, struct lpfc_dmabuf *mp); +void lpfc_setup_fdmi_mask(struct lpfc_vport *vport); int lpfc_link_reset(struct lpfc_vport *vport); /* Function prototypes. */ diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c index 094199d1006a..9d36b20fb878 100644 --- a/drivers/scsi/lpfc/lpfc_ct.c +++ b/drivers/scsi/lpfc/lpfc_ct.c @@ -2167,6 +2167,41 @@ ns_cmd_exit: return 1; } +/** + * lpfc_fdmi_rprt_defer - Check for any deferred FDMI RPRT commands + * @phba: Pointer to HBA context object. + * @mask: Initial port attributes mask + * + * This function checks to see if any vports have deferred their FDMI RPRT. + * A vports RPRT may be deferred if it is issued before the primary ports + * RHBA completes. + */ +static void +lpfc_fdmi_rprt_defer(struct lpfc_hba *phba, uint32_t mask) +{ + struct lpfc_vport **vports; + struct lpfc_vport *vport; + struct lpfc_nodelist *ndlp; + int i; + + phba->hba_flag |= HBA_RHBA_CMPL; + vports = lpfc_create_vport_work_array(phba); + if (vports) { + for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { + vport = vports[i]; + ndlp = lpfc_findnode_did(phba->pport, FDMI_DID); + if (!ndlp) + continue; + if (vport->ct_flags & FC_CT_RPRT_DEFER) { + vport->ct_flags &= ~FC_CT_RPRT_DEFER; + vport->fdmi_port_mask = mask; + lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPRT, 0); + } + } + } + lpfc_destroy_vport_work_array(phba, vports); +} + /** * lpfc_cmpl_ct_disc_fdmi - Handle a discovery FDMI completion * @phba: Pointer to HBA context object. @@ -2255,8 +2290,12 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, switch (cmd) { case SLI_MGMT_RHBA: if (vport->fdmi_hba_mask == LPFC_FDMI2_HBA_ATTR) { - /* Fallback to FDMI-1 */ + /* Fallback to FDMI-1 for HBA attributes */ vport->fdmi_hba_mask = LPFC_FDMI1_HBA_ATTR; + + /* If HBA attributes are FDMI1, so should + * port attributes be for consistency. + */ vport->fdmi_port_mask = LPFC_FDMI1_PORT_ATTR; /* Start over */ lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DHBA, 0); @@ -2264,6 +2303,11 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, return; case SLI_MGMT_RPRT: + if (vport->port_type != LPFC_PHYSICAL_PORT) { + ndlp = lpfc_findnode_did(phba->pport, FDMI_DID); + if (!ndlp) + return; + } if (vport->fdmi_port_mask == LPFC_FDMI2_PORT_ATTR) { /* Fallback to FDMI-1 */ vport->fdmi_port_mask = LPFC_FDMI1_PORT_ATTR; @@ -2313,6 +2357,9 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, */ switch (cmd) { case SLI_MGMT_RHBA: + /* Check for any RPRTs deferred till after RHBA completes */ + lpfc_fdmi_rprt_defer(phba, vport->fdmi_port_mask); + lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPA, 0); break; @@ -2321,10 +2368,26 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, break; case SLI_MGMT_DPRT: - if (vport->port_type == LPFC_PHYSICAL_PORT) + if (vport->port_type == LPFC_PHYSICAL_PORT) { lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RHBA, 0); - else - lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPRT, 0); + } else { + ndlp = lpfc_findnode_did(phba->pport, FDMI_DID); + if (!ndlp) + return; + + /* Only issue a RPRT for the vport if the RHBA + * for the physical port completes successfully. + * We may have to defer the RPRT accordingly. + */ + if (phba->hba_flag & HBA_RHBA_CMPL) { + lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPRT, 0); + } else { + lpfc_printf_vlog(vport, KERN_INFO, + LOG_DISCOVERY, + "6078 RPRT deferred\n"); + vport->ct_flags |= FC_CT_RPRT_DEFER; + } + } break; case SLI_MGMT_RPA: if (vport->port_type == LPFC_PHYSICAL_PORT && @@ -2339,7 +2402,8 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, break; } - lpfc_printf_log(phba, KERN_INFO, LOG_CGN_MGMT, + lpfc_printf_log(phba, KERN_INFO, + LOG_DISCOVERY | LOG_CGN_MGMT, "6210 Issue Vendor MI FDMI %x\n", phba->sli4_hba.pc_sli4_params.mi_ver); @@ -2408,6 +2472,9 @@ lpfc_fdmi_change_check(struct lpfc_vport *vport) phba->link_flag &= ~LS_CT_VEN_RPA; lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DHBA, 0); } else { + ndlp = lpfc_findnode_did(phba->pport, FDMI_DID); + if (!ndlp) + return; lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DPRT, 0); } @@ -2429,6 +2496,9 @@ lpfc_fdmi_change_check(struct lpfc_vport *vport) lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPA, LPFC_FDMI_PORT_ATTR_num_disc); } else { + ndlp = lpfc_findnode_did(phba->pport, FDMI_DID); + if (!ndlp) + return; lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPRT, LPFC_FDMI_PORT_ATTR_num_disc); } @@ -3501,8 +3571,10 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, /* FDMI request */ lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY, - "0218 FDMI Request Data: x%x x%x x%x\n", - vport->fc_flag, vport->port_state, cmdcode); + "0218 FDMI Request x%x mask x%x Data: x%x x%x x%x\n", + cmdcode, new_mask, vport->fdmi_port_mask, + vport->fc_flag, vport->port_state); + CtReq = (struct lpfc_sli_ct_request *)mp->virt; /* First populate the CT_IU preamble */ @@ -3571,6 +3643,12 @@ hba_out: break; case SLI_MGMT_RPRT: + if (vport->port_type != LPFC_PHYSICAL_PORT) { + ndlp = lpfc_findnode_did(phba->pport, FDMI_DID); + if (!ndlp) + return 0; + } + fallthrough; case SLI_MGMT_RPA: pab = (struct lpfc_fdmi_reg_portattr *)&CtReq->un.PortID; if (cmdcode == SLI_MGMT_RPRT) { @@ -3635,6 +3713,12 @@ port_out: rsp_size = FC_MAX_NS_RSP; fallthrough; case SLI_MGMT_DPRT: + if (vport->port_type != LPFC_PHYSICAL_PORT) { + ndlp = lpfc_findnode_did(phba->pport, FDMI_DID); + if (!ndlp) + return 0; + } + fallthrough; case SLI_MGMT_DPA: pe = (struct lpfc_fdmi_port_entry *)&CtReq->un.PortID; memcpy((uint8_t *)&pe->PortName, diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index 3ab22ac49e49..fb36f26170e4 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c @@ -1359,6 +1359,7 @@ lpfc_linkup_port(struct lpfc_vport *vport) vport->fc_flag |= FC_NDISC_ACTIVE; vport->fc_ns_retry = 0; spin_unlock_irq(shost->host_lock); + lpfc_setup_fdmi_mask(vport); lpfc_linkup_cleanup_nodes(vport); } @@ -1390,8 +1391,8 @@ lpfc_linkup(struct lpfc_hba *phba) phba->pport->rcv_flogi_cnt = 0; spin_unlock_irq(shost->host_lock); - /* reinitialize initial FLOGI flag */ - phba->hba_flag &= ~(HBA_FLOGI_ISSUED); + /* reinitialize initial HBA flag */ + phba->hba_flag &= ~(HBA_FLOGI_ISSUED | HBA_RHBA_CMPL); phba->defer_flogi_acc_flag = false; return 0; diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 39267016f339..0dedb7cf621b 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -9002,6 +9002,36 @@ lpfc_hba_free(struct lpfc_hba *phba) return; } +/** + * lpfc_setup_fdmi_mask - Setup initial FDMI mask for HBA and Port attributes + * @vport: pointer to lpfc vport data structure. + * + * This routine is will setup initial FDMI attribute masks for + * FDMI2 or SmartSAN depending on module parameters. The driver will attempt + * to get these attributes first before falling back, the attribute + * fallback hierarchy is SmartSAN -> FDMI2 -> FMDI1 + **/ +void +lpfc_setup_fdmi_mask(struct lpfc_vport *vport) +{ + struct lpfc_hba *phba = vport->phba; + + vport->load_flag |= FC_ALLOW_FDMI; + if (phba->cfg_enable_SmartSAN || + phba->cfg_fdmi_on == LPFC_FDMI_SUPPORT) { + /* Setup appropriate attribute masks */ + vport->fdmi_hba_mask = LPFC_FDMI2_HBA_ATTR; + if (phba->cfg_enable_SmartSAN) + vport->fdmi_port_mask = LPFC_FDMI2_SMART_ATTR; + else + vport->fdmi_port_mask = LPFC_FDMI2_PORT_ATTR; + } + + lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, + "6077 Setup FDMI mask: hba x%x port x%x\n", + vport->fdmi_hba_mask, vport->fdmi_port_mask); +} + /** * lpfc_create_shost - Create hba physical port with associated scsi host. * @phba: pointer to lpfc hba data structure. @@ -9045,21 +9075,12 @@ lpfc_create_shost(struct lpfc_hba *phba) /* Put reference to SCSI host to driver's device private data */ pci_set_drvdata(phba->pcidev, shost); + lpfc_setup_fdmi_mask(vport); + /* * At this point we are fully registered with PSA. In addition, * any initial discovery should be completed. */ - vport->load_flag |= FC_ALLOW_FDMI; - if (phba->cfg_enable_SmartSAN || - (phba->cfg_fdmi_on == LPFC_FDMI_SUPPORT)) { - - /* Setup appropriate attribute masks */ - vport->fdmi_hba_mask = LPFC_FDMI2_HBA_ATTR; - if (phba->cfg_enable_SmartSAN) - vport->fdmi_port_mask = LPFC_FDMI2_SMART_ATTR; - else - vport->fdmi_port_mask = LPFC_FDMI2_PORT_ATTR; - } return 0; } From e6f51041450282a8668af3a8fc5c7744e81a447c Mon Sep 17 00:00:00 2001 From: James Smart Date: Thu, 5 May 2022 20:55:17 -0700 Subject: [PATCH 147/177] scsi: lpfc: Alter FPIN stat accounting logic When configuring CMF management based on signals instead of FPINs, FPIN alarm and warning statistics are not tracked. Change the behavior so that FPIN alarms and warnings are always tracked regardless of the configured mode. Similar changes are made in the CMF signal stat accounting logic. Upon receipt of a signal, only track signaled alarms and warnings. FPIN stats should not be incremented upon receipt of a signal. Link: https://lore.kernel.org/r/20220506035519.50908-11-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_els.c | 49 +++++++++++------------------------ drivers/scsi/lpfc/lpfc_init.c | 22 ++-------------- 2 files changed, 17 insertions(+), 54 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index 33fac4401e8f..51c505d15410 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -3854,9 +3854,6 @@ lpfc_least_capable_settings(struct lpfc_hba *phba, { u32 rsp_sig_cap = 0, drv_sig_cap = 0; u32 rsp_sig_freq_cyc = 0, rsp_sig_freq_scale = 0; - struct lpfc_cgn_info *cp; - u32 crc; - u16 sig_freq; /* Get rsp signal and frequency capabilities. */ rsp_sig_cap = be32_to_cpu(pcgd->xmt_signal_capability); @@ -3912,25 +3909,7 @@ lpfc_least_capable_settings(struct lpfc_hba *phba, } } - if (!phba->cgn_i) - return; - - /* Update signal frequency in congestion info buffer */ - cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; - - /* Frequency (in ms) Signal Warning/Signal Congestion Notifications - * are received by the HBA - */ - sig_freq = phba->cgn_sig_freq; - - if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ONLY) - cp->cgn_warn_freq = cpu_to_le16(sig_freq); - if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) { - cp->cgn_alarm_freq = cpu_to_le16(sig_freq); - cp->cgn_warn_freq = cpu_to_le16(sig_freq); - } - crc = lpfc_cgn_calc_crc32(cp, LPFC_CGN_INFO_SZ, LPFC_CGN_CRC32_SEED); - cp->cgn_info_crc = cpu_to_le32(crc); + /* We are NOT recording signal frequency in congestion info buffer */ return; out_no_support: @@ -9919,11 +9898,14 @@ lpfc_els_rcv_fpin_cgn(struct lpfc_hba *phba, struct fc_tlv_desc *tlv) /* Take action here for an Alarm event */ if (phba->cmf_active_mode != LPFC_CFG_OFF) { if (phba->cgn_reg_fpin & LPFC_CGN_FPIN_ALARM) { - /* Track of alarm cnt for cgn_info */ - atomic_inc(&phba->cgn_fabric_alarm_cnt); /* Track of alarm cnt for SYNC_WQE */ atomic_inc(&phba->cgn_sync_alarm_cnt); } + /* Track alarm cnt for cgn_info regardless + * of whether CMF is configured for Signals + * or FPINs. + */ + atomic_inc(&phba->cgn_fabric_alarm_cnt); goto cleanup; } break; @@ -9931,11 +9913,14 @@ lpfc_els_rcv_fpin_cgn(struct lpfc_hba *phba, struct fc_tlv_desc *tlv) /* Take action here for a Warning event */ if (phba->cmf_active_mode != LPFC_CFG_OFF) { if (phba->cgn_reg_fpin & LPFC_CGN_FPIN_WARN) { - /* Track of warning cnt for cgn_info */ - atomic_inc(&phba->cgn_fabric_warn_cnt); /* Track of warning cnt for SYNC_WQE */ atomic_inc(&phba->cgn_sync_warn_cnt); } + /* Track warning cnt and freq for cgn_info + * regardless of whether CMF is configured for + * Signals or FPINs. + */ + atomic_inc(&phba->cgn_fabric_warn_cnt); cleanup: /* Save frequency in ms */ phba->cgn_fpin_frequency = @@ -9944,14 +9929,10 @@ cleanup: if (phba->cgn_i) { cp = (struct lpfc_cgn_info *) phba->cgn_i->virt; - if (phba->cgn_reg_fpin & - LPFC_CGN_FPIN_ALARM) - cp->cgn_alarm_freq = - cpu_to_le16(value); - if (phba->cgn_reg_fpin & - LPFC_CGN_FPIN_WARN) - cp->cgn_warn_freq = - cpu_to_le16(value); + cp->cgn_alarm_freq = + cpu_to_le16(value); + cp->cgn_warn_freq = + cpu_to_le16(value); crc = lpfc_cgn_calc_crc32 (cp, LPFC_CGN_INFO_SZ, diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 0dedb7cf621b..2bffaa681fcc 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -5864,21 +5864,8 @@ lpfc_cgn_save_evt_cnt(struct lpfc_hba *phba) /* Use the frequency found in the last rcv'ed FPIN */ value = phba->cgn_fpin_frequency; - if (phba->cgn_reg_fpin & LPFC_CGN_FPIN_WARN) - cp->cgn_warn_freq = cpu_to_le16(value); - if (phba->cgn_reg_fpin & LPFC_CGN_FPIN_ALARM) - cp->cgn_alarm_freq = cpu_to_le16(value); - - /* Frequency (in ms) Signal Warning/Signal Congestion Notifications - * are received by the HBA - */ - value = phba->cgn_sig_freq; - - if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ONLY || - phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) - cp->cgn_warn_freq = cpu_to_le16(value); - if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) - cp->cgn_alarm_freq = cpu_to_le16(value); + cp->cgn_warn_freq = cpu_to_le16(value); + cp->cgn_alarm_freq = cpu_to_le16(value); lvalue = lpfc_cgn_calc_crc32(cp, LPFC_CGN_INFO_SZ, LPFC_CGN_CRC32_SEED); @@ -6585,9 +6572,6 @@ lpfc_sli4_async_sli_evt(struct lpfc_hba *phba, struct lpfc_acqe_sli *acqe_sli) /* Alarm overrides warning, so check that first */ if (cgn_signal->alarm_cnt) { if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) { - /* Keep track of alarm cnt for cgn_info */ - atomic_add(cgn_signal->alarm_cnt, - &phba->cgn_fabric_alarm_cnt); /* Keep track of alarm cnt for CMF_SYNC_WQE */ atomic_add(cgn_signal->alarm_cnt, &phba->cgn_sync_alarm_cnt); @@ -6596,8 +6580,6 @@ lpfc_sli4_async_sli_evt(struct lpfc_hba *phba, struct lpfc_acqe_sli *acqe_sli) /* signal action needs to be taken */ if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ONLY || phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) { - /* Keep track of warning cnt for cgn_info */ - atomic_add(cnt, &phba->cgn_fabric_warn_cnt); /* Keep track of warning cnt for CMF_SYNC_WQE */ atomic_add(cnt, &phba->cgn_sync_warn_cnt); } From a14396b6d139ff9335b4be25ba30ffa67cadd2e9 Mon Sep 17 00:00:00 2001 From: James Smart Date: Thu, 5 May 2022 20:55:18 -0700 Subject: [PATCH 148/177] scsi: lpfc: Use sg_dma_address() and sg_dma_len() macros for NVMe I/O NVMe I/O problems may be seen on IOMMU enabled platforms. Adapter I/Os failing with transfer length mismatches. The sg list processing routine for NVMe I/O is accessing the sg entry directly for the length and address fields. On some IOMMU platforms, contigous mappings are compressed to the first sg entry with the sum of the lengths set to the sg entry dma_length field. The length fields are left for later use by the unmap call. As such, the driver didn't see the actual dma_length value, just the first entries length value. Drivers are to use the sg_dma_length() and sg_dma_address() macros to reference the sg entry. The macros select the proper length field (dma_length or length) to reference. Fix the offending code to use the sg_dma_xxx macros. Link: https://lore.kernel.org/r/20220506035519.50908-12-jsmart2021@gmail.com Tested-by: Jerry Snitselaar Reviewed-by: Jerry Snitselaar Co-developed-by: Nigel Kirkland Signed-off-by: Nigel Kirkland Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_nvme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c index 3aebd01e07fd..5385f4de5523 100644 --- a/drivers/scsi/lpfc/lpfc_nvme.c +++ b/drivers/scsi/lpfc/lpfc_nvme.c @@ -1401,8 +1401,8 @@ lpfc_nvme_prep_io_dma(struct lpfc_vport *vport, if ((nseg - 1) == i) bf_set(lpfc_sli4_sge_last, sgl, 1); - physaddr = data_sg->dma_address; - dma_len = data_sg->length; + physaddr = sg_dma_address(data_sg); + dma_len = sg_dma_len(data_sg); sgl->addr_lo = cpu_to_le32( putPaddrLow(physaddr)); sgl->addr_hi = cpu_to_le32( From fcb9e738667c874cbff0b240b96a895901f09ee0 Mon Sep 17 00:00:00 2001 From: James Smart Date: Thu, 5 May 2022 20:55:19 -0700 Subject: [PATCH 149/177] scsi: lpfc: Update lpfc version to 14.2.0.3 Update lpfc version to 14.2.0.3 Link: https://lore.kernel.org/r/20220506035519.50908-13-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen --- drivers/scsi/lpfc/lpfc_version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/lpfc/lpfc_version.h b/drivers/scsi/lpfc/lpfc_version.h index a615011c282d..4fab79ed58ed 100644 --- a/drivers/scsi/lpfc/lpfc_version.h +++ b/drivers/scsi/lpfc/lpfc_version.h @@ -20,7 +20,7 @@ * included with this package. * *******************************************************************/ -#define LPFC_DRIVER_VERSION "14.2.0.2" +#define LPFC_DRIVER_VERSION "14.2.0.3" #define LPFC_DRIVER_NAME "lpfc" /* Used for SLI 2/3 */ From 1aa529d400253eda76733dbb95b62f6cca7b274a Mon Sep 17 00:00:00 2001 From: Sreekanth Reddy Date: Fri, 6 May 2022 00:18:08 +0530 Subject: [PATCH 150/177] scsi: mpi3mr: Increase I/O timeout value to 60s Set each SCSI device's default I/O timeout and default error handling I/O timeout to 60s. Link: https://lore.kernel.org/r/20220505184808.24049-3-sreekanth.reddy@broadcom.com Signed-off-by: Sreekanth Reddy Signed-off-by: Martin K. Petersen --- drivers/scsi/mpi3mr/mpi3mr.h | 3 +++ drivers/scsi/mpi3mr/mpi3mr_os.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/drivers/scsi/mpi3mr/mpi3mr.h b/drivers/scsi/mpi3mr/mpi3mr.h index 8612b66b7d03..584659e2c578 100644 --- a/drivers/scsi/mpi3mr/mpi3mr.h +++ b/drivers/scsi/mpi3mr/mpi3mr.h @@ -124,6 +124,9 @@ extern atomic64_t event_counter; #define MPI3MR_WATCHDOG_INTERVAL 1000 /* in milli seconds */ +#define MPI3MR_SCMD_TIMEOUT (60 * HZ) +#define MPI3MR_EH_SCMD_TIMEOUT (60 * HZ) + /* Internal admin command state definitions*/ #define MPI3MR_CMD_NOTUSED 0x8000 #define MPI3MR_CMD_COMPLETE 0x0001 diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index 89a4918c4a9e..3a46f8835f00 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -3725,6 +3725,10 @@ static int mpi3mr_slave_configure(struct scsi_device *sdev) return -ENXIO; mpi3mr_change_queue_depth(sdev, tgt_dev->q_depth); + + sdev->eh_timeout = MPI3MR_EH_SCMD_TIMEOUT; + blk_queue_rq_timeout(sdev->request_queue, MPI3MR_SCMD_TIMEOUT); + switch (tgt_dev->dev_type) { case MPI3_DEVICE_DEVFORM_PCIE: /*The block layer hw sector size = 512*/ From 2dd8389f96d6d00a24816888262e33a85d414c05 Mon Sep 17 00:00:00 2001 From: Sreekanth Reddy Date: Fri, 6 May 2022 00:18:07 +0530 Subject: [PATCH 151/177] scsi: mpi3mr: Hidden drives not removed during soft reset If any drive is missing during reset, the driver checks whether the device is exposed to the OS. If it is, then it removes the device from the OS and its own internal list. For hidden devices, even if they are found as missing during reset, the driver is not removing them from its internal list. Modify driver to remove hidden devices from the driver's target device list if they are missing during soft reset. Link: https://lore.kernel.org/r/20220505184808.24049-2-sreekanth.reddy@broadcom.com Signed-off-by: Sreekanth Reddy Signed-off-by: Martin K. Petersen --- drivers/scsi/mpi3mr/mpi3mr_os.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index 3a46f8835f00..70da6d8e7c3c 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -911,9 +911,11 @@ void mpi3mr_rfresh_tgtdevs(struct mpi3mr_ioc *mrioc) list_for_each_entry_safe(tgtdev, tgtdev_next, &mrioc->tgtdev_list, list) { - if ((tgtdev->dev_handle == MPI3MR_INVALID_DEV_HANDLE) && - tgtdev->host_exposed) { - mpi3mr_remove_tgtdev_from_host(mrioc, tgtdev); + if (tgtdev->dev_handle == MPI3MR_INVALID_DEV_HANDLE) { + dprint_reset(mrioc, "removing target device with perst_id(%d)\n", + tgtdev->perst_id); + if (tgtdev->host_exposed) + mpi3mr_remove_tgtdev_from_host(mrioc, tgtdev); mpi3mr_tgtdev_del_from_list(mrioc, tgtdev); mpi3mr_tgtdev_put(tgtdev); } From 256bd4f23d9cecaba2e6795f0058fa9c2362698c Mon Sep 17 00:00:00 2001 From: Sreekanth Reddy Date: Fri, 6 May 2022 00:18:06 +0530 Subject: [PATCH 152/177] scsi: mpi3mr: Return I/Os to an unrecoverable HBA with DID_ERROR Complete all new I/O requests issued to an unrecoverable controller with DID_ERROR status instead of returning the I/O requests with SCSI_MLQUEUE_HOST_BUSY. This will prevent the infinite retries of the new I/Os when a controller is in an unrecoverable state. Link: https://lore.kernel.org/r/20220505184808.24049-1-sreekanth.reddy@broadcom.com Signed-off-by: Sreekanth Reddy Signed-off-by: Martin K. Petersen --- drivers/scsi/mpi3mr/mpi3mr_os.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index 70da6d8e7c3c..f5c345d1ffa1 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -4002,6 +4002,12 @@ static int mpi3mr_qcmd(struct Scsi_Host *shost, int iprio_class; u8 is_pcie_dev = 0; + if (mrioc->unrecoverable) { + scmd->result = DID_ERROR << 16; + scsi_done(scmd); + goto out; + } + sdev_priv_data = scmd->device->hostdata; if (!sdev_priv_data || !sdev_priv_data->tgt_priv_data) { scmd->result = DID_NO_CONNECT << 16; From 66cd9d4ef74ae1ad459e3db3a3280182275c2ce9 Mon Sep 17 00:00:00 2001 From: Max Gurtovoy Date: Thu, 28 Apr 2022 12:29:37 +0300 Subject: [PATCH 153/177] scsi: target: iscsi: Rename iscsi_cmd to iscsit_cmd The structure iscsi_cmd naming is used by the iSCSI initiator driver. Rename the target cmd to iscsit_cmd to have more readable code. Link: https://lore.kernel.org/r/20220428092939.36768-1-mgurtovoy@nvidia.com Reviewed-by: Mike Christie Signed-off-by: Max Gurtovoy Signed-off-by: Martin K. Petersen --- drivers/infiniband/ulp/isert/ib_isert.c | 64 ++++---- drivers/infiniband/ulp/isert/ib_isert.h | 2 +- drivers/target/iscsi/cxgbit/cxgbit.h | 8 +- drivers/target/iscsi/cxgbit/cxgbit_ddp.c | 4 +- drivers/target/iscsi/cxgbit/cxgbit_target.c | 34 ++-- drivers/target/iscsi/iscsi_target.c | 150 +++++++++--------- drivers/target/iscsi/iscsi_target.h | 14 +- drivers/target/iscsi/iscsi_target_configfs.c | 14 +- .../target/iscsi/iscsi_target_datain_values.c | 18 +-- .../target/iscsi/iscsi_target_datain_values.h | 12 +- drivers/target/iscsi/iscsi_target_device.c | 2 +- drivers/target/iscsi/iscsi_target_device.h | 4 +- drivers/target/iscsi/iscsi_target_erl0.c | 30 ++-- drivers/target/iscsi/iscsi_target_erl0.h | 8 +- drivers/target/iscsi/iscsi_target_erl1.c | 42 ++--- drivers/target/iscsi/iscsi_target_erl1.h | 20 +-- drivers/target/iscsi/iscsi_target_erl2.c | 20 +-- drivers/target/iscsi/iscsi_target_erl2.h | 8 +- drivers/target/iscsi/iscsi_target_nego.c | 2 +- .../target/iscsi/iscsi_target_seq_pdu_list.c | 34 ++-- .../target/iscsi/iscsi_target_seq_pdu_list.h | 10 +- drivers/target/iscsi/iscsi_target_tmr.c | 38 ++--- drivers/target/iscsi/iscsi_target_tmr.h | 8 +- drivers/target/iscsi/iscsi_target_util.c | 66 ++++---- drivers/target/iscsi/iscsi_target_util.h | 48 +++--- include/target/iscsi/iscsi_target_core.h | 34 ++-- include/target/iscsi/iscsi_transport.h | 92 +++++------ 27 files changed, 393 insertions(+), 393 deletions(-) diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c index 636d590765f9..4cb746ab53be 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.c +++ b/drivers/infiniband/ulp/isert/ib_isert.c @@ -46,7 +46,7 @@ static struct workqueue_struct *isert_comp_wq; static struct workqueue_struct *isert_release_wq; static int -isert_put_response(struct iscsi_conn *conn, struct iscsi_cmd *cmd); +isert_put_response(struct iscsi_conn *conn, struct iscsit_cmd *cmd); static int isert_login_post_recv(struct isert_conn *isert_conn); static int @@ -1020,21 +1020,21 @@ isert_rx_login_req(struct isert_conn *isert_conn) schedule_delayed_work(&conn->login_work, 0); } -static struct iscsi_cmd +static struct iscsit_cmd *isert_allocate_cmd(struct iscsi_conn *conn, struct iser_rx_desc *rx_desc) { struct isert_conn *isert_conn = conn->context; struct isert_cmd *isert_cmd; - struct iscsi_cmd *cmd; + struct iscsit_cmd *cmd; cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE); if (!cmd) { - isert_err("Unable to allocate iscsi_cmd + isert_cmd\n"); + isert_err("Unable to allocate iscsit_cmd + isert_cmd\n"); return NULL; } isert_cmd = iscsit_priv_cmd(cmd); isert_cmd->conn = isert_conn; - isert_cmd->iscsi_cmd = cmd; + isert_cmd->iscsit_cmd = cmd; isert_cmd->rx_desc = rx_desc; return cmd; @@ -1042,7 +1042,7 @@ static struct iscsi_cmd static int isert_handle_scsi_cmd(struct isert_conn *isert_conn, - struct isert_cmd *isert_cmd, struct iscsi_cmd *cmd, + struct isert_cmd *isert_cmd, struct iscsit_cmd *cmd, struct iser_rx_desc *rx_desc, unsigned char *buf) { struct iscsi_conn *conn = isert_conn->conn; @@ -1115,7 +1115,7 @@ isert_handle_iscsi_dataout(struct isert_conn *isert_conn, { struct scatterlist *sg_start; struct iscsi_conn *conn = isert_conn->conn; - struct iscsi_cmd *cmd = NULL; + struct iscsit_cmd *cmd = NULL; struct iscsi_data *hdr = (struct iscsi_data *)buf; u32 unsol_data_len = ntoh24(hdr->dlength); int rc, sg_nents, sg_off, page_off; @@ -1171,7 +1171,7 @@ isert_handle_iscsi_dataout(struct isert_conn *isert_conn, static int isert_handle_nop_out(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd, - struct iscsi_cmd *cmd, struct iser_rx_desc *rx_desc, + struct iscsit_cmd *cmd, struct iser_rx_desc *rx_desc, unsigned char *buf) { struct iscsi_conn *conn = isert_conn->conn; @@ -1190,7 +1190,7 @@ isert_handle_nop_out(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd, static int isert_handle_text_cmd(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd, - struct iscsi_cmd *cmd, struct iser_rx_desc *rx_desc, + struct iscsit_cmd *cmd, struct iser_rx_desc *rx_desc, struct iscsi_text *hdr) { struct iscsi_conn *conn = isert_conn->conn; @@ -1221,7 +1221,7 @@ isert_rx_opcode(struct isert_conn *isert_conn, struct iser_rx_desc *rx_desc, { struct iscsi_hdr *hdr = isert_get_iscsi_hdr(rx_desc); struct iscsi_conn *conn = isert_conn->conn; - struct iscsi_cmd *cmd; + struct iscsit_cmd *cmd; struct isert_cmd *isert_cmd; int ret = -EINVAL; u8 opcode = (hdr->opcode & ISCSI_OPCODE_MASK); @@ -1404,7 +1404,7 @@ isert_login_recv_done(struct ib_cq *cq, struct ib_wc *wc) static void isert_rdma_rw_ctx_destroy(struct isert_cmd *cmd, struct isert_conn *conn) { - struct se_cmd *se_cmd = &cmd->iscsi_cmd->se_cmd; + struct se_cmd *se_cmd = &cmd->iscsit_cmd->se_cmd; enum dma_data_direction dir = target_reverse_dma_direction(se_cmd); if (!cmd->rw.nr_ops) @@ -1426,7 +1426,7 @@ isert_rdma_rw_ctx_destroy(struct isert_cmd *cmd, struct isert_conn *conn) static void isert_put_cmd(struct isert_cmd *isert_cmd, bool comp_err) { - struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd; + struct iscsit_cmd *cmd = isert_cmd->iscsit_cmd; struct isert_conn *isert_conn = isert_cmd->conn; struct iscsi_conn *conn = isert_conn->conn; struct iscsi_text_rsp *hdr; @@ -1575,7 +1575,7 @@ isert_rdma_write_done(struct ib_cq *cq, struct ib_wc *wc) struct isert_device *device = isert_conn->device; struct iser_tx_desc *desc = cqe_to_tx_desc(wc->wr_cqe); struct isert_cmd *isert_cmd = tx_desc_to_cmd(desc); - struct se_cmd *cmd = &isert_cmd->iscsi_cmd->se_cmd; + struct se_cmd *cmd = &isert_cmd->iscsit_cmd->se_cmd; int ret = 0; if (unlikely(wc->status != IB_WC_SUCCESS)) { @@ -1604,7 +1604,7 @@ isert_rdma_write_done(struct ib_cq *cq, struct ib_wc *wc) /* * XXX: isert_put_response() failure is not retried. */ - ret = isert_put_response(isert_conn->conn, isert_cmd->iscsi_cmd); + ret = isert_put_response(isert_conn->conn, isert_cmd->iscsit_cmd); if (ret) pr_warn_ratelimited("isert_put_response() ret: %d\n", ret); } @@ -1617,7 +1617,7 @@ isert_rdma_read_done(struct ib_cq *cq, struct ib_wc *wc) struct isert_device *device = isert_conn->device; struct iser_tx_desc *desc = cqe_to_tx_desc(wc->wr_cqe); struct isert_cmd *isert_cmd = tx_desc_to_cmd(desc); - struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd; + struct iscsit_cmd *cmd = isert_cmd->iscsit_cmd; struct se_cmd *se_cmd = &cmd->se_cmd; int ret = 0; @@ -1662,7 +1662,7 @@ isert_do_control_comp(struct work_struct *work) struct isert_cmd, comp_work); struct isert_conn *isert_conn = isert_cmd->conn; struct ib_device *ib_dev = isert_conn->cm_id->device; - struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd; + struct iscsit_cmd *cmd = isert_cmd->iscsit_cmd; isert_dbg("Cmd %p i_state %d\n", isert_cmd, cmd->i_state); @@ -1720,7 +1720,7 @@ isert_send_done(struct ib_cq *cq, struct ib_wc *wc) isert_dbg("Cmd %p\n", isert_cmd); - switch (isert_cmd->iscsi_cmd->i_state) { + switch (isert_cmd->iscsit_cmd->i_state) { case ISTATE_SEND_TASKMGTRSP: case ISTATE_SEND_LOGOUTRSP: case ISTATE_SEND_REJECT: @@ -1731,7 +1731,7 @@ isert_send_done(struct ib_cq *cq, struct ib_wc *wc) queue_work(isert_comp_wq, &isert_cmd->comp_work); return; default: - isert_cmd->iscsi_cmd->i_state = ISTATE_SENT_STATUS; + isert_cmd->iscsit_cmd->i_state = ISTATE_SENT_STATUS; isert_completion_put(tx_desc, isert_cmd, ib_dev, false); break; } @@ -1755,7 +1755,7 @@ isert_post_response(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd) } static int -isert_put_response(struct iscsi_conn *conn, struct iscsi_cmd *cmd) +isert_put_response(struct iscsi_conn *conn, struct iscsit_cmd *cmd) { struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); struct isert_conn *isert_conn = conn->context; @@ -1806,7 +1806,7 @@ isert_put_response(struct iscsi_conn *conn, struct iscsi_cmd *cmd) } static void -isert_aborted_task(struct iscsi_conn *conn, struct iscsi_cmd *cmd) +isert_aborted_task(struct iscsi_conn *conn, struct iscsit_cmd *cmd) { struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); struct isert_conn *isert_conn = conn->context; @@ -1842,7 +1842,7 @@ isert_get_sup_prot_ops(struct iscsi_conn *conn) } static int -isert_put_nopin(struct iscsi_cmd *cmd, struct iscsi_conn *conn, +isert_put_nopin(struct iscsit_cmd *cmd, struct iscsi_conn *conn, bool nopout_response) { struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); @@ -1862,7 +1862,7 @@ isert_put_nopin(struct iscsi_cmd *cmd, struct iscsi_conn *conn, } static int -isert_put_logout_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) +isert_put_logout_rsp(struct iscsit_cmd *cmd, struct iscsi_conn *conn) { struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); struct isert_conn *isert_conn = conn->context; @@ -1880,7 +1880,7 @@ isert_put_logout_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) } static int -isert_put_tm_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) +isert_put_tm_rsp(struct iscsit_cmd *cmd, struct iscsi_conn *conn) { struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); struct isert_conn *isert_conn = conn->context; @@ -1898,7 +1898,7 @@ isert_put_tm_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) } static int -isert_put_reject(struct iscsi_cmd *cmd, struct iscsi_conn *conn) +isert_put_reject(struct iscsit_cmd *cmd, struct iscsi_conn *conn) { struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); struct isert_conn *isert_conn = conn->context; @@ -1933,7 +1933,7 @@ isert_put_reject(struct iscsi_cmd *cmd, struct iscsi_conn *conn) } static int -isert_put_text_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) +isert_put_text_rsp(struct iscsit_cmd *cmd, struct iscsi_conn *conn) { struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); struct isert_conn *isert_conn = conn->context; @@ -2035,7 +2035,7 @@ static int isert_rdma_rw_ctx_post(struct isert_cmd *cmd, struct isert_conn *conn, struct ib_cqe *cqe, struct ib_send_wr *chain_wr) { - struct se_cmd *se_cmd = &cmd->iscsi_cmd->se_cmd; + struct se_cmd *se_cmd = &cmd->iscsit_cmd->se_cmd; enum dma_data_direction dir = target_reverse_dma_direction(se_cmd); u8 port_num = conn->cm_id->port_num; u64 addr; @@ -2048,7 +2048,7 @@ isert_rdma_rw_ctx_post(struct isert_cmd *cmd, struct isert_conn *conn, if (dir == DMA_FROM_DEVICE) { addr = cmd->write_va; rkey = cmd->write_stag; - offset = cmd->iscsi_cmd->write_data_done; + offset = cmd->iscsit_cmd->write_data_done; } else { addr = cmd->read_va; rkey = cmd->read_stag; @@ -2088,7 +2088,7 @@ rdma_ctx_post: } static int -isert_put_datain(struct iscsi_conn *conn, struct iscsi_cmd *cmd) +isert_put_datain(struct iscsi_conn *conn, struct iscsit_cmd *cmd) { struct se_cmd *se_cmd = &cmd->se_cmd; struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); @@ -2129,7 +2129,7 @@ isert_put_datain(struct iscsi_conn *conn, struct iscsi_cmd *cmd) } static int -isert_get_dataout(struct iscsi_conn *conn, struct iscsi_cmd *cmd, bool recovery) +isert_get_dataout(struct iscsi_conn *conn, struct iscsit_cmd *cmd, bool recovery) { struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); int ret; @@ -2147,7 +2147,7 @@ isert_get_dataout(struct iscsi_conn *conn, struct iscsi_cmd *cmd, bool recovery) } static int -isert_immediate_queue(struct iscsi_conn *conn, struct iscsi_cmd *cmd, int state) +isert_immediate_queue(struct iscsi_conn *conn, struct iscsit_cmd *cmd, int state) { struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); int ret = 0; @@ -2172,7 +2172,7 @@ isert_immediate_queue(struct iscsi_conn *conn, struct iscsi_cmd *cmd, int state) } static int -isert_response_queue(struct iscsi_conn *conn, struct iscsi_cmd *cmd, int state) +isert_response_queue(struct iscsi_conn *conn, struct iscsit_cmd *cmd, int state) { struct isert_conn *isert_conn = conn->context; int ret; @@ -2523,7 +2523,7 @@ isert_wait4cmds(struct iscsi_conn *conn) static void isert_put_unsol_pending_cmds(struct iscsi_conn *conn) { - struct iscsi_cmd *cmd, *tmp; + struct iscsit_cmd *cmd, *tmp; static LIST_HEAD(drop_cmd_list); spin_lock_bh(&conn->cmd_lock); diff --git a/drivers/infiniband/ulp/isert/ib_isert.h b/drivers/infiniband/ulp/isert/ib_isert.h index ca8cfebe26ca..a462834cb332 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.h +++ b/drivers/infiniband/ulp/isert/ib_isert.h @@ -146,7 +146,7 @@ struct isert_cmd { u64 pdu_buf_dma; u32 pdu_buf_len; struct isert_conn *conn; - struct iscsi_cmd *iscsi_cmd; + struct iscsit_cmd *iscsit_cmd; struct iser_tx_desc tx_desc; struct iser_rx_desc *rx_desc; struct rdma_rw_ctx rw; diff --git a/drivers/target/iscsi/cxgbit/cxgbit.h b/drivers/target/iscsi/cxgbit/cxgbit.h index 406903398dfd..b23edcb41489 100644 --- a/drivers/target/iscsi/cxgbit/cxgbit.h +++ b/drivers/target/iscsi/cxgbit/cxgbit.h @@ -327,9 +327,9 @@ int cxgbit_l2t_send(struct cxgbit_device *, struct sk_buff *, struct l2t_entry *); void cxgbit_push_tx_frames(struct cxgbit_sock *); int cxgbit_put_login_tx(struct iscsi_conn *, struct iscsi_login *, u32); -int cxgbit_xmit_pdu(struct iscsi_conn *, struct iscsi_cmd *, +int cxgbit_xmit_pdu(struct iscsi_conn *, struct iscsit_cmd *, struct iscsi_datain_req *, const void *, u32); -void cxgbit_get_r2t_ttt(struct iscsi_conn *, struct iscsi_cmd *, +void cxgbit_get_r2t_ttt(struct iscsi_conn *, struct iscsit_cmd *, struct iscsi_r2t *); u32 cxgbit_send_tx_flowc_wr(struct cxgbit_sock *); int cxgbit_ofld_send(struct cxgbit_device *, struct sk_buff *); @@ -340,8 +340,8 @@ struct cxgbit_device *cxgbit_find_device(struct net_device *, u8 *); /* DDP */ int cxgbit_ddp_init(struct cxgbit_device *); int cxgbit_setup_conn_pgidx(struct cxgbit_sock *, u32); -int cxgbit_reserve_ttt(struct cxgbit_sock *, struct iscsi_cmd *); -void cxgbit_unmap_cmd(struct iscsi_conn *, struct iscsi_cmd *); +int cxgbit_reserve_ttt(struct cxgbit_sock *, struct iscsit_cmd *); +void cxgbit_unmap_cmd(struct iscsi_conn *, struct iscsit_cmd *); static inline struct cxgbi_ppm *cdev2ppm(struct cxgbit_device *cdev) diff --git a/drivers/target/iscsi/cxgbit/cxgbit_ddp.c b/drivers/target/iscsi/cxgbit/cxgbit_ddp.c index 072afd070f3e..5feebb6c6de4 100644 --- a/drivers/target/iscsi/cxgbit/cxgbit_ddp.c +++ b/drivers/target/iscsi/cxgbit/cxgbit_ddp.c @@ -227,7 +227,7 @@ rel_ppods: } void -cxgbit_get_r2t_ttt(struct iscsi_conn *conn, struct iscsi_cmd *cmd, +cxgbit_get_r2t_ttt(struct iscsi_conn *conn, struct iscsit_cmd *cmd, struct iscsi_r2t *r2t) { struct cxgbit_sock *csk = conn->context; @@ -260,7 +260,7 @@ out: r2t->targ_xfer_tag = ttinfo->tag; } -void cxgbit_unmap_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd) +void cxgbit_unmap_cmd(struct iscsi_conn *conn, struct iscsit_cmd *cmd) { struct cxgbit_cmd *ccmd = iscsit_priv_cmd(cmd); diff --git a/drivers/target/iscsi/cxgbit/cxgbit_target.c b/drivers/target/iscsi/cxgbit/cxgbit_target.c index d314ee120a48..99901a8a3f64 100644 --- a/drivers/target/iscsi/cxgbit/cxgbit_target.c +++ b/drivers/target/iscsi/cxgbit/cxgbit_target.c @@ -337,7 +337,7 @@ unlock: } static int -cxgbit_map_skb(struct iscsi_cmd *cmd, struct sk_buff *skb, u32 data_offset, +cxgbit_map_skb(struct iscsit_cmd *cmd, struct sk_buff *skb, u32 data_offset, u32 data_length) { u32 i = 0, nr_frags = MAX_SKB_FRAGS; @@ -390,7 +390,7 @@ cxgbit_map_skb(struct iscsi_cmd *cmd, struct sk_buff *skb, u32 data_offset, } static int -cxgbit_tx_datain_iso(struct cxgbit_sock *csk, struct iscsi_cmd *cmd, +cxgbit_tx_datain_iso(struct cxgbit_sock *csk, struct iscsit_cmd *cmd, struct iscsi_datain_req *dr) { struct iscsi_conn *conn = csk->conn; @@ -481,7 +481,7 @@ out: } static int -cxgbit_tx_datain(struct cxgbit_sock *csk, struct iscsi_cmd *cmd, +cxgbit_tx_datain(struct cxgbit_sock *csk, struct iscsit_cmd *cmd, const struct iscsi_datain *datain) { struct sk_buff *skb; @@ -510,7 +510,7 @@ cxgbit_tx_datain(struct cxgbit_sock *csk, struct iscsi_cmd *cmd, } static int -cxgbit_xmit_datain_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd, +cxgbit_xmit_datain_pdu(struct iscsi_conn *conn, struct iscsit_cmd *cmd, struct iscsi_datain_req *dr, const struct iscsi_datain *datain) { @@ -530,7 +530,7 @@ cxgbit_xmit_datain_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd, } static int -cxgbit_xmit_nondatain_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd, +cxgbit_xmit_nondatain_pdu(struct iscsi_conn *conn, struct iscsit_cmd *cmd, const void *data_buf, u32 data_buf_len) { struct cxgbit_sock *csk = conn->context; @@ -560,7 +560,7 @@ cxgbit_xmit_nondatain_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd, } int -cxgbit_xmit_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd, +cxgbit_xmit_pdu(struct iscsi_conn *conn, struct iscsit_cmd *cmd, struct iscsi_datain_req *dr, const void *buf, u32 buf_len) { if (dr) @@ -832,16 +832,16 @@ cxgbit_skb_copy_to_sg(struct sk_buff *skb, struct scatterlist *sg, } } -static struct iscsi_cmd *cxgbit_allocate_cmd(struct cxgbit_sock *csk) +static struct iscsit_cmd *cxgbit_allocate_cmd(struct cxgbit_sock *csk) { struct iscsi_conn *conn = csk->conn; struct cxgbi_ppm *ppm = cdev2ppm(csk->com.cdev); struct cxgbit_cmd *ccmd; - struct iscsi_cmd *cmd; + struct iscsit_cmd *cmd; cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE); if (!cmd) { - pr_err("Unable to allocate iscsi_cmd + cxgbit_cmd\n"); + pr_err("Unable to allocate iscsit_cmd + cxgbit_cmd\n"); return NULL; } @@ -853,7 +853,7 @@ static struct iscsi_cmd *cxgbit_allocate_cmd(struct cxgbit_sock *csk) } static int -cxgbit_handle_immediate_data(struct iscsi_cmd *cmd, struct iscsi_scsi_req *hdr, +cxgbit_handle_immediate_data(struct iscsit_cmd *cmd, struct iscsi_scsi_req *hdr, u32 length) { struct iscsi_conn *conn = cmd->conn; @@ -910,7 +910,7 @@ cxgbit_handle_immediate_data(struct iscsi_cmd *cmd, struct iscsi_scsi_req *hdr, } static int -cxgbit_get_immediate_data(struct iscsi_cmd *cmd, struct iscsi_scsi_req *hdr, +cxgbit_get_immediate_data(struct iscsit_cmd *cmd, struct iscsi_scsi_req *hdr, bool dump_payload) { struct iscsi_conn *conn = cmd->conn; @@ -964,7 +964,7 @@ after_immediate_data: } static int -cxgbit_handle_scsi_cmd(struct cxgbit_sock *csk, struct iscsi_cmd *cmd) +cxgbit_handle_scsi_cmd(struct cxgbit_sock *csk, struct iscsit_cmd *cmd) { struct iscsi_conn *conn = csk->conn; struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb); @@ -996,7 +996,7 @@ static int cxgbit_handle_iscsi_dataout(struct cxgbit_sock *csk) { struct scatterlist *sg_start; struct iscsi_conn *conn = csk->conn; - struct iscsi_cmd *cmd = NULL; + struct iscsit_cmd *cmd = NULL; struct cxgbit_cmd *ccmd; struct cxgbi_task_tag_info *ttinfo; struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb); @@ -1084,7 +1084,7 @@ check_payload: return 0; } -static int cxgbit_handle_nop_out(struct cxgbit_sock *csk, struct iscsi_cmd *cmd) +static int cxgbit_handle_nop_out(struct cxgbit_sock *csk, struct iscsit_cmd *cmd) { struct iscsi_conn *conn = csk->conn; struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb); @@ -1134,7 +1134,7 @@ static int cxgbit_handle_nop_out(struct cxgbit_sock *csk, struct iscsi_cmd *cmd) ping_data[payload_length] = '\0'; /* - * Attach ping data to struct iscsi_cmd->buf_ptr. + * Attach ping data to struct iscsit_cmd->buf_ptr. */ cmd->buf_ptr = ping_data; cmd->buf_ptr_size = payload_length; @@ -1152,7 +1152,7 @@ out: } static int -cxgbit_handle_text_cmd(struct cxgbit_sock *csk, struct iscsi_cmd *cmd) +cxgbit_handle_text_cmd(struct cxgbit_sock *csk, struct iscsit_cmd *cmd) { struct iscsi_conn *conn = csk->conn; struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb); @@ -1210,7 +1210,7 @@ static int cxgbit_target_rx_opcode(struct cxgbit_sock *csk) struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb); struct iscsi_hdr *hdr = (struct iscsi_hdr *)pdu_cb->hdr; struct iscsi_conn *conn = csk->conn; - struct iscsi_cmd *cmd = NULL; + struct iscsit_cmd *cmd = NULL; u8 opcode = (hdr->opcode & ISCSI_OPCODE_MASK); int ret = -EINVAL; diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 6fe6a6bab3f4..4d71eb8fa6ab 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -59,7 +59,7 @@ struct kmem_cache *lio_dr_cache; struct kmem_cache *lio_ooo_cache; struct kmem_cache *lio_r2t_cache; -static int iscsit_handle_immediate_data(struct iscsi_cmd *, +static int iscsit_handle_immediate_data(struct iscsit_cmd *, struct iscsi_scsi_req *, u32); struct iscsi_tiqn *iscsit_get_tiqn_for_login(unsigned char *buf) @@ -474,13 +474,13 @@ int iscsit_del_np(struct iscsi_np *np) static void iscsit_get_rx_pdu(struct iscsi_conn *); -int iscsit_queue_rsp(struct iscsi_conn *conn, struct iscsi_cmd *cmd) +int iscsit_queue_rsp(struct iscsi_conn *conn, struct iscsit_cmd *cmd) { return iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state); } EXPORT_SYMBOL(iscsit_queue_rsp); -void iscsit_aborted_task(struct iscsi_conn *conn, struct iscsi_cmd *cmd) +void iscsit_aborted_task(struct iscsi_conn *conn, struct iscsit_cmd *cmd) { spin_lock_bh(&conn->cmd_lock); if (!list_empty(&cmd->i_conn_node)) @@ -496,7 +496,7 @@ static void iscsit_do_crypto_hash_buf(struct ahash_request *, const void *, static void iscsit_tx_thread_wait_for_tcp(struct iscsi_conn *); static int -iscsit_xmit_nondatain_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd, +iscsit_xmit_nondatain_pdu(struct iscsi_conn *conn, struct iscsit_cmd *cmd, const void *data_buf, u32 data_buf_len) { struct iscsi_hdr *hdr = (struct iscsi_hdr *)cmd->pdu; @@ -564,13 +564,13 @@ iscsit_xmit_nondatain_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd, return 0; } -static int iscsit_map_iovec(struct iscsi_cmd *cmd, struct kvec *iov, int nvec, +static int iscsit_map_iovec(struct iscsit_cmd *cmd, struct kvec *iov, int nvec, u32 data_offset, u32 data_length); -static void iscsit_unmap_iovec(struct iscsi_cmd *); -static u32 iscsit_do_crypto_hash_sg(struct ahash_request *, struct iscsi_cmd *, +static void iscsit_unmap_iovec(struct iscsit_cmd *); +static u32 iscsit_do_crypto_hash_sg(struct ahash_request *, struct iscsit_cmd *, u32, u32, u32, u8 *); static int -iscsit_xmit_datain_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd, +iscsit_xmit_datain_pdu(struct iscsi_conn *conn, struct iscsit_cmd *cmd, const struct iscsi_datain *datain) { struct kvec *iov; @@ -644,7 +644,7 @@ iscsit_xmit_datain_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd, return 0; } -static int iscsit_xmit_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd, +static int iscsit_xmit_pdu(struct iscsi_conn *conn, struct iscsit_cmd *cmd, struct iscsi_datain_req *dr, const void *buf, u32 buf_len) { @@ -800,7 +800,7 @@ int iscsit_add_reject( u8 reason, unsigned char *buf) { - struct iscsi_cmd *cmd; + struct iscsit_cmd *cmd; cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE); if (!cmd) @@ -828,7 +828,7 @@ int iscsit_add_reject( EXPORT_SYMBOL(iscsit_add_reject); static int iscsit_add_reject_from_cmd( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, u8 reason, bool add_to_conn, unsigned char *buf) @@ -872,13 +872,13 @@ static int iscsit_add_reject_from_cmd( return -1; } -static int iscsit_add_reject_cmd(struct iscsi_cmd *cmd, u8 reason, +static int iscsit_add_reject_cmd(struct iscsit_cmd *cmd, u8 reason, unsigned char *buf) { return iscsit_add_reject_from_cmd(cmd, reason, true, buf); } -int iscsit_reject_cmd(struct iscsi_cmd *cmd, u8 reason, unsigned char *buf) +int iscsit_reject_cmd(struct iscsit_cmd *cmd, u8 reason, unsigned char *buf) { return iscsit_add_reject_from_cmd(cmd, reason, false, buf); } @@ -888,7 +888,7 @@ EXPORT_SYMBOL(iscsit_reject_cmd); * Map some portion of the allocated scatterlist to an iovec, suitable for * kernel sockets to copy data in/out. */ -static int iscsit_map_iovec(struct iscsi_cmd *cmd, struct kvec *iov, int nvec, +static int iscsit_map_iovec(struct iscsit_cmd *cmd, struct kvec *iov, int nvec, u32 data_offset, u32 data_length) { u32 i = 0, orig_data_length = data_length; @@ -946,7 +946,7 @@ overflow: return -1; } -static void iscsit_unmap_iovec(struct iscsi_cmd *cmd) +static void iscsit_unmap_iovec(struct iscsit_cmd *cmd) { u32 i; struct scatterlist *sg; @@ -960,7 +960,7 @@ static void iscsit_unmap_iovec(struct iscsi_cmd *cmd) static void iscsit_ack_from_expstatsn(struct iscsi_conn *conn, u32 exp_statsn) { LIST_HEAD(ack_list); - struct iscsi_cmd *cmd, *cmd_p; + struct iscsit_cmd *cmd, *cmd_p; conn->exp_statsn = exp_statsn; @@ -987,7 +987,7 @@ static void iscsit_ack_from_expstatsn(struct iscsi_conn *conn, u32 exp_statsn) } } -static int iscsit_allocate_iovecs(struct iscsi_cmd *cmd) +static int iscsit_allocate_iovecs(struct iscsit_cmd *cmd) { u32 iov_count = max(1UL, DIV_ROUND_UP(cmd->se_cmd.data_length, PAGE_SIZE)); @@ -1000,7 +1000,7 @@ static int iscsit_allocate_iovecs(struct iscsi_cmd *cmd) return 0; } -int iscsit_setup_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, +int iscsit_setup_scsi_cmd(struct iscsi_conn *conn, struct iscsit_cmd *cmd, unsigned char *buf) { int data_direction, payload_length; @@ -1215,7 +1215,7 @@ attach_cmd: } EXPORT_SYMBOL(iscsit_setup_scsi_cmd); -void iscsit_set_unsolicited_dataout(struct iscsi_cmd *cmd) +void iscsit_set_unsolicited_dataout(struct iscsit_cmd *cmd) { iscsit_set_dataout_sequence_values(cmd); @@ -1225,7 +1225,7 @@ void iscsit_set_unsolicited_dataout(struct iscsi_cmd *cmd) } EXPORT_SYMBOL(iscsit_set_unsolicited_dataout); -int iscsit_process_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, +int iscsit_process_scsi_cmd(struct iscsi_conn *conn, struct iscsit_cmd *cmd, struct iscsi_scsi_req *hdr) { int cmdsn_ret = 0; @@ -1285,7 +1285,7 @@ int iscsit_process_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, EXPORT_SYMBOL(iscsit_process_scsi_cmd); static int -iscsit_get_immediate_data(struct iscsi_cmd *cmd, struct iscsi_scsi_req *hdr, +iscsit_get_immediate_data(struct iscsit_cmd *cmd, struct iscsi_scsi_req *hdr, bool dump_payload) { int cmdsn_ret = 0, immed_ret = IMMEDIATE_DATA_NORMAL_OPERATION; @@ -1349,7 +1349,7 @@ iscsit_get_immediate_data(struct iscsi_cmd *cmd, struct iscsi_scsi_req *hdr, } static int -iscsit_handle_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, +iscsit_handle_scsi_cmd(struct iscsi_conn *conn, struct iscsit_cmd *cmd, unsigned char *buf) { struct iscsi_scsi_req *hdr = (struct iscsi_scsi_req *)buf; @@ -1383,7 +1383,7 @@ iscsit_handle_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, static u32 iscsit_do_crypto_hash_sg( struct ahash_request *hash, - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, u32 data_offset, u32 data_length, u32 padding, @@ -1456,7 +1456,7 @@ static void iscsit_do_crypto_hash_buf(struct ahash_request *hash, int __iscsit_check_dataout_hdr(struct iscsi_conn *conn, void *buf, - struct iscsi_cmd *cmd, u32 payload_length, + struct iscsit_cmd *cmd, u32 payload_length, bool *success) { struct iscsi_data *hdr = buf; @@ -1560,10 +1560,10 @@ EXPORT_SYMBOL(__iscsit_check_dataout_hdr); int iscsit_check_dataout_hdr(struct iscsi_conn *conn, void *buf, - struct iscsi_cmd **out_cmd) + struct iscsit_cmd **out_cmd) { struct iscsi_data *hdr = buf; - struct iscsi_cmd *cmd; + struct iscsit_cmd *cmd; u32 payload_length = ntoh24(hdr->dlength); int rc; bool success = false; @@ -1594,7 +1594,7 @@ iscsit_check_dataout_hdr(struct iscsi_conn *conn, void *buf, EXPORT_SYMBOL(iscsit_check_dataout_hdr); static int -iscsit_get_dataout(struct iscsi_conn *conn, struct iscsi_cmd *cmd, +iscsit_get_dataout(struct iscsi_conn *conn, struct iscsit_cmd *cmd, struct iscsi_data *hdr) { struct kvec *iov; @@ -1662,7 +1662,7 @@ iscsit_get_dataout(struct iscsi_conn *conn, struct iscsi_cmd *cmd, } int -iscsit_check_dataout_payload(struct iscsi_cmd *cmd, struct iscsi_data *hdr, +iscsit_check_dataout_payload(struct iscsit_cmd *cmd, struct iscsi_data *hdr, bool data_crc_failed) { struct iscsi_conn *conn = cmd->conn; @@ -1702,7 +1702,7 @@ EXPORT_SYMBOL(iscsit_check_dataout_payload); static int iscsit_handle_data_out(struct iscsi_conn *conn, unsigned char *buf) { - struct iscsi_cmd *cmd = NULL; + struct iscsit_cmd *cmd = NULL; struct iscsi_data *hdr = (struct iscsi_data *)buf; int rc; bool data_crc_failed = false; @@ -1722,7 +1722,7 @@ static int iscsit_handle_data_out(struct iscsi_conn *conn, unsigned char *buf) return iscsit_check_dataout_payload(cmd, hdr, data_crc_failed); } -int iscsit_setup_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd, +int iscsit_setup_nop_out(struct iscsi_conn *conn, struct iscsit_cmd *cmd, struct iscsi_nopout *hdr) { u32 payload_length = ntoh24(hdr->dlength); @@ -1770,7 +1770,7 @@ int iscsit_setup_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd, * This is not a response to a Unsolicited NopIN, which means * it can either be a NOPOUT ping request (with a valid ITT), * or a NOPOUT not requesting a NOPIN (with a reserved ITT). - * Either way, make sure we allocate an struct iscsi_cmd, as both + * Either way, make sure we allocate an struct iscsit_cmd, as both * can contain ping data. */ if (hdr->ttt == cpu_to_be32(0xFFFFFFFF)) { @@ -1789,10 +1789,10 @@ int iscsit_setup_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd, } EXPORT_SYMBOL(iscsit_setup_nop_out); -int iscsit_process_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd, +int iscsit_process_nop_out(struct iscsi_conn *conn, struct iscsit_cmd *cmd, struct iscsi_nopout *hdr) { - struct iscsi_cmd *cmd_p = NULL; + struct iscsit_cmd *cmd_p = NULL; int cmdsn_ret = 0; /* * Initiator is expecting a NopIN ping reply.. @@ -1851,7 +1851,7 @@ int iscsit_process_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd, } EXPORT_SYMBOL(iscsit_process_nop_out); -static int iscsit_handle_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd, +static int iscsit_handle_nop_out(struct iscsi_conn *conn, struct iscsit_cmd *cmd, unsigned char *buf) { unsigned char *ping_data = NULL; @@ -1936,7 +1936,7 @@ static int iscsit_handle_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd, ping_data[payload_length] = '\0'; /* - * Attach ping data to struct iscsi_cmd->buf_ptr. + * Attach ping data to struct iscsit_cmd->buf_ptr. */ cmd->buf_ptr = ping_data; cmd->buf_ptr_size = payload_length; @@ -1978,7 +1978,7 @@ static enum tcm_tmreq_table iscsit_convert_tmf(u8 iscsi_tmf) } int -iscsit_handle_task_mgt_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, +iscsit_handle_task_mgt_cmd(struct iscsi_conn *conn, struct iscsit_cmd *cmd, unsigned char *buf) { struct se_tmr_req *se_tmr; @@ -2159,7 +2159,7 @@ EXPORT_SYMBOL(iscsit_handle_task_mgt_cmd); /* #warning FIXME: Support Text Command parameters besides SendTargets */ int -iscsit_setup_text_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, +iscsit_setup_text_cmd(struct iscsi_conn *conn, struct iscsit_cmd *cmd, struct iscsi_text *hdr) { u32 payload_length = ntoh24(hdr->dlength); @@ -2199,7 +2199,7 @@ iscsit_setup_text_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, EXPORT_SYMBOL(iscsit_setup_text_cmd); int -iscsit_process_text_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, +iscsit_process_text_cmd(struct iscsi_conn *conn, struct iscsit_cmd *cmd, struct iscsi_text *hdr) { unsigned char *text_in = cmd->text_in_ptr, *text_ptr; @@ -2258,7 +2258,7 @@ reject: EXPORT_SYMBOL(iscsit_process_text_cmd); static int -iscsit_handle_text_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, +iscsit_handle_text_cmd(struct iscsi_conn *conn, struct iscsit_cmd *cmd, unsigned char *buf) { struct iscsi_text *hdr = (struct iscsi_text *)buf; @@ -2347,7 +2347,7 @@ reject: return iscsit_reject_cmd(cmd, ISCSI_REASON_PROTOCOL_ERROR, buf); } -int iscsit_logout_closesession(struct iscsi_cmd *cmd, struct iscsi_conn *conn) +int iscsit_logout_closesession(struct iscsit_cmd *cmd, struct iscsi_conn *conn) { struct iscsi_conn *conn_p; struct iscsi_session *sess = conn->sess; @@ -2377,7 +2377,7 @@ int iscsit_logout_closesession(struct iscsi_cmd *cmd, struct iscsi_conn *conn) return 0; } -int iscsit_logout_closeconnection(struct iscsi_cmd *cmd, struct iscsi_conn *conn) +int iscsit_logout_closeconnection(struct iscsit_cmd *cmd, struct iscsi_conn *conn) { struct iscsi_conn *l_conn; struct iscsi_session *sess = conn->sess; @@ -2425,7 +2425,7 @@ int iscsit_logout_closeconnection(struct iscsi_cmd *cmd, struct iscsi_conn *conn return 0; } -int iscsit_logout_removeconnforrecovery(struct iscsi_cmd *cmd, struct iscsi_conn *conn) +int iscsit_logout_removeconnforrecovery(struct iscsit_cmd *cmd, struct iscsi_conn *conn) { struct iscsi_session *sess = conn->sess; @@ -2455,7 +2455,7 @@ int iscsit_logout_removeconnforrecovery(struct iscsi_cmd *cmd, struct iscsi_conn } int -iscsit_handle_logout_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, +iscsit_handle_logout_cmd(struct iscsi_conn *conn, struct iscsit_cmd *cmd, unsigned char *buf) { int cmdsn_ret, logout_remove = 0; @@ -2601,7 +2601,7 @@ static void iscsit_rx_thread_wait_for_tcp(struct iscsi_conn *conn) } static int iscsit_handle_immediate_data( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_scsi_req *hdr, u32 length) { @@ -2710,7 +2710,7 @@ static int iscsit_handle_immediate_data( with active network interface */ static void iscsit_build_conn_drop_async_message(struct iscsi_conn *conn) { - struct iscsi_cmd *cmd; + struct iscsit_cmd *cmd; struct iscsi_conn *conn_p; bool found = false; @@ -2750,7 +2750,7 @@ static void iscsit_build_conn_drop_async_message(struct iscsi_conn *conn) } static int iscsit_send_conn_drop_async_message( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_conn *conn) { struct iscsi_async *hdr; @@ -2790,7 +2790,7 @@ static void iscsit_tx_thread_wait_for_tcp(struct iscsi_conn *conn) } void -iscsit_build_datain_pdu(struct iscsi_cmd *cmd, struct iscsi_conn *conn, +iscsit_build_datain_pdu(struct iscsit_cmd *cmd, struct iscsi_conn *conn, struct iscsi_datain *datain, struct iscsi_data_rsp *hdr, bool set_statsn) { @@ -2835,7 +2835,7 @@ iscsit_build_datain_pdu(struct iscsi_cmd *cmd, struct iscsi_conn *conn, } EXPORT_SYMBOL(iscsit_build_datain_pdu); -static int iscsit_send_datain(struct iscsi_cmd *cmd, struct iscsi_conn *conn) +static int iscsit_send_datain(struct iscsit_cmd *cmd, struct iscsi_conn *conn) { struct iscsi_data_rsp *hdr = (struct iscsi_data_rsp *)&cmd->pdu[0]; struct iscsi_datain datain; @@ -2896,7 +2896,7 @@ static int iscsit_send_datain(struct iscsi_cmd *cmd, struct iscsi_conn *conn) } int -iscsit_build_logout_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn, +iscsit_build_logout_rsp(struct iscsit_cmd *cmd, struct iscsi_conn *conn, struct iscsi_logout_rsp *hdr) { struct iscsi_conn *logout_conn = NULL; @@ -2991,7 +2991,7 @@ iscsit_build_logout_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn, EXPORT_SYMBOL(iscsit_build_logout_rsp); static int -iscsit_send_logout(struct iscsi_cmd *cmd, struct iscsi_conn *conn) +iscsit_send_logout(struct iscsit_cmd *cmd, struct iscsi_conn *conn) { int rc; @@ -3004,7 +3004,7 @@ iscsit_send_logout(struct iscsi_cmd *cmd, struct iscsi_conn *conn) } void -iscsit_build_nopin_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn, +iscsit_build_nopin_rsp(struct iscsit_cmd *cmd, struct iscsi_conn *conn, struct iscsi_nopin *hdr, bool nopout_response) { hdr->opcode = ISCSI_OP_NOOP_IN; @@ -3035,7 +3035,7 @@ EXPORT_SYMBOL(iscsit_build_nopin_rsp); * Unsolicited NOPIN, either requesting a response or not. */ static int iscsit_send_unsolicited_nopin( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_conn *conn, int want_response) { @@ -3060,15 +3060,15 @@ static int iscsit_send_unsolicited_nopin( } static int -iscsit_send_nopin(struct iscsi_cmd *cmd, struct iscsi_conn *conn) +iscsit_send_nopin(struct iscsit_cmd *cmd, struct iscsi_conn *conn) { struct iscsi_nopin *hdr = (struct iscsi_nopin *)&cmd->pdu[0]; iscsit_build_nopin_rsp(cmd, conn, hdr, true); /* - * NOPOUT Ping Data is attached to struct iscsi_cmd->buf_ptr. - * NOPOUT DataSegmentLength is at struct iscsi_cmd->buf_ptr_size. + * NOPOUT Ping Data is attached to struct iscsit_cmd->buf_ptr. + * NOPOUT DataSegmentLength is at struct iscsit_cmd->buf_ptr_size. */ pr_debug("Echoing back %u bytes of ping data.\n", cmd->buf_ptr_size); @@ -3078,7 +3078,7 @@ iscsit_send_nopin(struct iscsi_cmd *cmd, struct iscsi_conn *conn) } static int iscsit_send_r2t( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_conn *conn) { struct iscsi_r2t *r2t; @@ -3136,7 +3136,7 @@ static int iscsit_send_r2t( */ int iscsit_build_r2ts_for_cmd( struct iscsi_conn *conn, - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, bool recovery) { int first_r2t = 1; @@ -3218,7 +3218,7 @@ int iscsit_build_r2ts_for_cmd( } EXPORT_SYMBOL(iscsit_build_r2ts_for_cmd); -void iscsit_build_rsp_pdu(struct iscsi_cmd *cmd, struct iscsi_conn *conn, +void iscsit_build_rsp_pdu(struct iscsit_cmd *cmd, struct iscsi_conn *conn, bool inc_stat_sn, struct iscsi_scsi_rsp *hdr) { if (inc_stat_sn) @@ -3252,7 +3252,7 @@ void iscsit_build_rsp_pdu(struct iscsi_cmd *cmd, struct iscsi_conn *conn, } EXPORT_SYMBOL(iscsit_build_rsp_pdu); -static int iscsit_send_response(struct iscsi_cmd *cmd, struct iscsi_conn *conn) +static int iscsit_send_response(struct iscsit_cmd *cmd, struct iscsi_conn *conn) { struct iscsi_scsi_rsp *hdr = (struct iscsi_scsi_rsp *)&cmd->pdu[0]; bool inc_stat_sn = (cmd->i_state == ISTATE_SEND_STATUS); @@ -3309,7 +3309,7 @@ static u8 iscsit_convert_tcm_tmr_rsp(struct se_tmr_req *se_tmr) } void -iscsit_build_task_mgt_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn, +iscsit_build_task_mgt_rsp(struct iscsit_cmd *cmd, struct iscsi_conn *conn, struct iscsi_tm_rsp *hdr) { struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req; @@ -3332,7 +3332,7 @@ iscsit_build_task_mgt_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn, EXPORT_SYMBOL(iscsit_build_task_mgt_rsp); static int -iscsit_send_task_mgt_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) +iscsit_send_task_mgt_rsp(struct iscsit_cmd *cmd, struct iscsi_conn *conn) { struct iscsi_tm_rsp *hdr = (struct iscsi_tm_rsp *)&cmd->pdu[0]; @@ -3344,7 +3344,7 @@ iscsit_send_task_mgt_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) #define SENDTARGETS_BUF_LIMIT 32768U static int -iscsit_build_sendtargets_response(struct iscsi_cmd *cmd, +iscsit_build_sendtargets_response(struct iscsit_cmd *cmd, enum iscsit_transport_type network_transport, int skip_bytes, bool *completed) { @@ -3494,7 +3494,7 @@ eob: } int -iscsit_build_text_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn, +iscsit_build_text_rsp(struct iscsit_cmd *cmd, struct iscsi_conn *conn, struct iscsi_text_rsp *hdr, enum iscsit_transport_type network_transport) { @@ -3544,7 +3544,7 @@ iscsit_build_text_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn, EXPORT_SYMBOL(iscsit_build_text_rsp); static int iscsit_send_text_rsp( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_conn *conn) { struct iscsi_text_rsp *hdr = (struct iscsi_text_rsp *)cmd->pdu; @@ -3561,7 +3561,7 @@ static int iscsit_send_text_rsp( } void -iscsit_build_reject(struct iscsi_cmd *cmd, struct iscsi_conn *conn, +iscsit_build_reject(struct iscsit_cmd *cmd, struct iscsi_conn *conn, struct iscsi_reject *hdr) { hdr->opcode = ISCSI_OP_REJECT; @@ -3578,7 +3578,7 @@ iscsit_build_reject(struct iscsi_cmd *cmd, struct iscsi_conn *conn, EXPORT_SYMBOL(iscsit_build_reject); static int iscsit_send_reject( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_conn *conn) { struct iscsi_reject *hdr = (struct iscsi_reject *)&cmd->pdu[0]; @@ -3681,7 +3681,7 @@ void iscsit_thread_check_cpumask( EXPORT_SYMBOL(iscsit_thread_check_cpumask); int -iscsit_immediate_queue(struct iscsi_conn *conn, struct iscsi_cmd *cmd, int state) +iscsit_immediate_queue(struct iscsi_conn *conn, struct iscsit_cmd *cmd, int state) { int ret; @@ -3729,7 +3729,7 @@ iscsit_handle_immediate_queue(struct iscsi_conn *conn) { struct iscsit_transport *t = conn->conn_transport; struct iscsi_queue_req *qr; - struct iscsi_cmd *cmd; + struct iscsit_cmd *cmd; u8 state; int ret; @@ -3748,7 +3748,7 @@ iscsit_handle_immediate_queue(struct iscsi_conn *conn) } int -iscsit_response_queue(struct iscsi_conn *conn, struct iscsi_cmd *cmd, int state) +iscsit_response_queue(struct iscsi_conn *conn, struct iscsit_cmd *cmd, int state) { int ret; @@ -3858,7 +3858,7 @@ static int iscsit_handle_response_queue(struct iscsi_conn *conn) { struct iscsit_transport *t = conn->conn_transport; struct iscsi_queue_req *qr; - struct iscsi_cmd *cmd; + struct iscsit_cmd *cmd; u8 state; int ret; @@ -3936,7 +3936,7 @@ out: static int iscsi_target_rx_opcode(struct iscsi_conn *conn, unsigned char *buf) { struct iscsi_hdr *hdr = (struct iscsi_hdr *)buf; - struct iscsi_cmd *cmd; + struct iscsit_cmd *cmd; int ret = 0; switch (hdr->opcode & ISCSI_OPCODE_MASK) { @@ -4144,7 +4144,7 @@ out: static void iscsit_release_commands_from_conn(struct iscsi_conn *conn) { LIST_HEAD(tmp_list); - struct iscsi_cmd *cmd = NULL, *cmd_tmp = NULL; + struct iscsit_cmd *cmd = NULL, *cmd_tmp = NULL; struct iscsi_session *sess = conn->sess; /* * We expect this function to only ever be called from either RX or TX @@ -4187,7 +4187,7 @@ static void iscsit_release_commands_from_conn(struct iscsi_conn *conn) static void iscsit_stop_timers_for_cmds( struct iscsi_conn *conn) { - struct iscsi_cmd *cmd; + struct iscsit_cmd *cmd; spin_lock_bh(&conn->cmd_lock); list_for_each_entry(cmd, &conn->conn_cmd_list, i_conn_node) { @@ -4252,7 +4252,7 @@ int iscsit_close_connection( * * During normal operation clear the out of order commands (but * do not free the struct iscsi_ooo_cmdsn's) and release all - * struct iscsi_cmds. + * struct iscsit_cmds. */ if (atomic_read(&conn->connection_recovery)) { iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(conn); @@ -4592,7 +4592,7 @@ static void iscsit_logout_post_handler_diffcid( * Return of 0 causes the TX thread to restart. */ int iscsit_logout_post_handler( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_conn *conn) { int ret = 0; diff --git a/drivers/target/iscsi/iscsi_target.h b/drivers/target/iscsi/iscsi_target.h index b35a96ded9c1..bfa3559cf823 100644 --- a/drivers/target/iscsi/iscsi_target.h +++ b/drivers/target/iscsi/iscsi_target.h @@ -5,7 +5,7 @@ #include #include -struct iscsi_cmd; +struct iscsit_cmd; struct iscsi_conn; struct iscsi_np; struct iscsi_portal_group; @@ -30,13 +30,13 @@ extern struct iscsi_np *iscsit_add_np(struct sockaddr_storage *, extern int iscsit_reset_np_thread(struct iscsi_np *, struct iscsi_tpg_np *, struct iscsi_portal_group *, bool); extern int iscsit_del_np(struct iscsi_np *); -extern int iscsit_reject_cmd(struct iscsi_cmd *cmd, u8, unsigned char *); -extern void iscsit_set_unsolicited_dataout(struct iscsi_cmd *); -extern int iscsit_logout_closesession(struct iscsi_cmd *, struct iscsi_conn *); -extern int iscsit_logout_closeconnection(struct iscsi_cmd *, struct iscsi_conn *); -extern int iscsit_logout_removeconnforrecovery(struct iscsi_cmd *, struct iscsi_conn *); +extern int iscsit_reject_cmd(struct iscsit_cmd *cmd, u8, unsigned char *); +extern void iscsit_set_unsolicited_dataout(struct iscsit_cmd *); +extern int iscsit_logout_closesession(struct iscsit_cmd *, struct iscsi_conn *); +extern int iscsit_logout_closeconnection(struct iscsit_cmd *, struct iscsi_conn *); +extern int iscsit_logout_removeconnforrecovery(struct iscsit_cmd *, struct iscsi_conn *); extern int iscsit_send_async_msg(struct iscsi_conn *, u16, u8, u8); -extern int iscsit_build_r2ts_for_cmd(struct iscsi_conn *, struct iscsi_cmd *, bool recovery); +extern int iscsit_build_r2ts_for_cmd(struct iscsi_conn *, struct iscsit_cmd *, bool recovery); extern void iscsit_thread_get_cpumask(struct iscsi_conn *); extern int iscsi_target_tx_thread(void *); extern int iscsi_target_rx_thread(void *); diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c index 0cedcfe207b5..0c1f4ad3e04a 100644 --- a/drivers/target/iscsi/iscsi_target_configfs.c +++ b/drivers/target/iscsi/iscsi_target_configfs.c @@ -1340,7 +1340,7 @@ static struct configfs_attribute *lio_target_discovery_auth_attrs[] = { static int iscsi_get_cmd_state(struct se_cmd *se_cmd) { - struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); + struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd); return cmd->i_state; } @@ -1366,7 +1366,7 @@ static u32 lio_sess_get_initiator_sid( static int lio_queue_data_in(struct se_cmd *se_cmd) { - struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); + struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd); struct iscsi_conn *conn = cmd->conn; cmd->i_state = ISTATE_SEND_DATAIN; @@ -1375,7 +1375,7 @@ static int lio_queue_data_in(struct se_cmd *se_cmd) static int lio_write_pending(struct se_cmd *se_cmd) { - struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); + struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd); struct iscsi_conn *conn = cmd->conn; if (!cmd->immediate_data && !cmd->unsolicited_data) @@ -1386,7 +1386,7 @@ static int lio_write_pending(struct se_cmd *se_cmd) static int lio_queue_status(struct se_cmd *se_cmd) { - struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); + struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd); struct iscsi_conn *conn = cmd->conn; cmd->i_state = ISTATE_SEND_STATUS; @@ -1399,7 +1399,7 @@ static int lio_queue_status(struct se_cmd *se_cmd) static void lio_queue_tm_rsp(struct se_cmd *se_cmd) { - struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); + struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd); cmd->i_state = ISTATE_SEND_TASKMGTRSP; iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state); @@ -1407,7 +1407,7 @@ static void lio_queue_tm_rsp(struct se_cmd *se_cmd) static void lio_aborted_task(struct se_cmd *se_cmd) { - struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); + struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd); cmd->conn->conn_transport->iscsit_aborted_task(cmd->conn, cmd); } @@ -1522,7 +1522,7 @@ static int lio_check_stop_free(struct se_cmd *se_cmd) static void lio_release_cmd(struct se_cmd *se_cmd) { - struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); + struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd); pr_debug("Entering lio_release_cmd for se_cmd: %p\n", se_cmd); iscsit_release_cmd(cmd); diff --git a/drivers/target/iscsi/iscsi_target_datain_values.c b/drivers/target/iscsi/iscsi_target_datain_values.c index 07a22cd36a4e..091a710eadb0 100644 --- a/drivers/target/iscsi/iscsi_target_datain_values.c +++ b/drivers/target/iscsi/iscsi_target_datain_values.c @@ -32,14 +32,14 @@ struct iscsi_datain_req *iscsit_allocate_datain_req(void) return dr; } -void iscsit_attach_datain_req(struct iscsi_cmd *cmd, struct iscsi_datain_req *dr) +void iscsit_attach_datain_req(struct iscsit_cmd *cmd, struct iscsi_datain_req *dr) { spin_lock(&cmd->datain_lock); list_add_tail(&dr->cmd_datain_node, &cmd->datain_list); spin_unlock(&cmd->datain_lock); } -void iscsit_free_datain_req(struct iscsi_cmd *cmd, struct iscsi_datain_req *dr) +void iscsit_free_datain_req(struct iscsit_cmd *cmd, struct iscsi_datain_req *dr) { spin_lock(&cmd->datain_lock); list_del(&dr->cmd_datain_node); @@ -48,7 +48,7 @@ void iscsit_free_datain_req(struct iscsi_cmd *cmd, struct iscsi_datain_req *dr) kmem_cache_free(lio_dr_cache, dr); } -void iscsit_free_all_datain_reqs(struct iscsi_cmd *cmd) +void iscsit_free_all_datain_reqs(struct iscsit_cmd *cmd) { struct iscsi_datain_req *dr, *dr_tmp; @@ -60,7 +60,7 @@ void iscsit_free_all_datain_reqs(struct iscsi_cmd *cmd) spin_unlock(&cmd->datain_lock); } -struct iscsi_datain_req *iscsit_get_datain_req(struct iscsi_cmd *cmd) +struct iscsi_datain_req *iscsit_get_datain_req(struct iscsit_cmd *cmd) { if (list_empty(&cmd->datain_list)) { pr_err("cmd->datain_list is empty for ITT:" @@ -76,7 +76,7 @@ struct iscsi_datain_req *iscsit_get_datain_req(struct iscsi_cmd *cmd) * For Normal and Recovery DataSequenceInOrder=Yes and DataPDUInOrder=Yes. */ static struct iscsi_datain_req *iscsit_set_datain_values_yes_and_yes( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_datain *datain) { u32 next_burst_len, read_data_done, read_data_left; @@ -174,7 +174,7 @@ static struct iscsi_datain_req *iscsit_set_datain_values_yes_and_yes( * For Normal and Recovery DataSequenceInOrder=No and DataPDUInOrder=Yes. */ static struct iscsi_datain_req *iscsit_set_datain_values_no_and_yes( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_datain *datain) { u32 offset, read_data_done, read_data_left, seq_send_order; @@ -295,7 +295,7 @@ static struct iscsi_datain_req *iscsit_set_datain_values_no_and_yes( * For Normal and Recovery DataSequenceInOrder=Yes and DataPDUInOrder=No. */ static struct iscsi_datain_req *iscsit_set_datain_values_yes_and_no( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_datain *datain) { u32 next_burst_len, read_data_done, read_data_left; @@ -394,7 +394,7 @@ static struct iscsi_datain_req *iscsit_set_datain_values_yes_and_no( * For Normal and Recovery DataSequenceInOrder=No and DataPDUInOrder=No. */ static struct iscsi_datain_req *iscsit_set_datain_values_no_and_no( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_datain *datain) { u32 read_data_done, read_data_left, seq_send_order; @@ -496,7 +496,7 @@ static struct iscsi_datain_req *iscsit_set_datain_values_no_and_no( } struct iscsi_datain_req *iscsit_get_datain_values( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_datain *datain) { struct iscsi_conn *conn = cmd->conn; diff --git a/drivers/target/iscsi/iscsi_target_datain_values.h b/drivers/target/iscsi/iscsi_target_datain_values.h index a420fbd37969..b28df886d828 100644 --- a/drivers/target/iscsi/iscsi_target_datain_values.h +++ b/drivers/target/iscsi/iscsi_target_datain_values.h @@ -2,15 +2,15 @@ #ifndef ISCSI_TARGET_DATAIN_VALUES_H #define ISCSI_TARGET_DATAIN_VALUES_H -struct iscsi_cmd; +struct iscsit_cmd; struct iscsi_datain; extern struct iscsi_datain_req *iscsit_allocate_datain_req(void); -extern void iscsit_attach_datain_req(struct iscsi_cmd *, struct iscsi_datain_req *); -extern void iscsit_free_datain_req(struct iscsi_cmd *, struct iscsi_datain_req *); -extern void iscsit_free_all_datain_reqs(struct iscsi_cmd *); -extern struct iscsi_datain_req *iscsit_get_datain_req(struct iscsi_cmd *); -extern struct iscsi_datain_req *iscsit_get_datain_values(struct iscsi_cmd *, +extern void iscsit_attach_datain_req(struct iscsit_cmd *, struct iscsi_datain_req *); +extern void iscsit_free_datain_req(struct iscsit_cmd *, struct iscsi_datain_req *); +extern void iscsit_free_all_datain_reqs(struct iscsit_cmd *); +extern struct iscsi_datain_req *iscsit_get_datain_req(struct iscsit_cmd *); +extern struct iscsi_datain_req *iscsit_get_datain_values(struct iscsit_cmd *, struct iscsi_datain *); #endif /*** ISCSI_TARGET_DATAIN_VALUES_H ***/ diff --git a/drivers/target/iscsi/iscsi_target_device.c b/drivers/target/iscsi/iscsi_target_device.c index 8bf36ec86e3f..d57041b860bd 100644 --- a/drivers/target/iscsi/iscsi_target_device.c +++ b/drivers/target/iscsi/iscsi_target_device.c @@ -42,7 +42,7 @@ void iscsit_determine_maxcmdsn(struct iscsi_session *sess) atomic_add(se_nacl->queue_depth - 1, &sess->max_cmd_sn); } -void iscsit_increment_maxcmdsn(struct iscsi_cmd *cmd, struct iscsi_session *sess) +void iscsit_increment_maxcmdsn(struct iscsit_cmd *cmd, struct iscsi_session *sess) { u32 max_cmd_sn; diff --git a/drivers/target/iscsi/iscsi_target_device.h b/drivers/target/iscsi/iscsi_target_device.h index ab2166f17785..b6a463847720 100644 --- a/drivers/target/iscsi/iscsi_target_device.h +++ b/drivers/target/iscsi/iscsi_target_device.h @@ -2,10 +2,10 @@ #ifndef ISCSI_TARGET_DEVICE_H #define ISCSI_TARGET_DEVICE_H -struct iscsi_cmd; +struct iscsit_cmd; struct iscsi_session; extern void iscsit_determine_maxcmdsn(struct iscsi_session *); -extern void iscsit_increment_maxcmdsn(struct iscsi_cmd *, struct iscsi_session *); +extern void iscsit_increment_maxcmdsn(struct iscsit_cmd *, struct iscsi_session *); #endif /* ISCSI_TARGET_DEVICE_H */ diff --git a/drivers/target/iscsi/iscsi_target_erl0.c b/drivers/target/iscsi/iscsi_target_erl0.c index 102c9cbf59f3..8ca910571ed3 100644 --- a/drivers/target/iscsi/iscsi_target_erl0.c +++ b/drivers/target/iscsi/iscsi_target_erl0.c @@ -24,12 +24,12 @@ #include "iscsi_target.h" /* - * Used to set values in struct iscsi_cmd that iscsit_dataout_check_sequence() + * Used to set values in struct iscsit_cmd that iscsit_dataout_check_sequence() * checks against to determine a PDU's Offset+Length is within the current * DataOUT Sequence. Used for DataSequenceInOrder=Yes only. */ void iscsit_set_dataout_sequence_values( - struct iscsi_cmd *cmd) + struct iscsit_cmd *cmd) { struct iscsi_conn *conn = cmd->conn; /* @@ -63,7 +63,7 @@ void iscsit_set_dataout_sequence_values( } static int iscsit_dataout_within_command_recovery_check( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, unsigned char *buf) { struct iscsi_conn *conn = cmd->conn; @@ -129,7 +129,7 @@ dump: } static int iscsit_dataout_check_unsolicited_sequence( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, unsigned char *buf) { u32 first_burst_len; @@ -204,7 +204,7 @@ out: } static int iscsit_dataout_check_sequence( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, unsigned char *buf) { u32 next_burst_len; @@ -333,7 +333,7 @@ out: } static int iscsit_dataout_check_datasn( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, unsigned char *buf) { u32 data_sn = 0; @@ -384,7 +384,7 @@ dump: } static int iscsit_dataout_pre_datapduinorder_yes( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, unsigned char *buf) { int dump = 0, recovery = 0; @@ -394,7 +394,7 @@ static int iscsit_dataout_pre_datapduinorder_yes( /* * For DataSequenceInOrder=Yes: If the offset is greater than the global - * DataPDUInOrder=Yes offset counter in struct iscsi_cmd a protcol error has + * DataPDUInOrder=Yes offset counter in struct iscsit_cmd a protcol error has * occurred and fail the connection. * * For DataSequenceInOrder=No: If the offset is greater than the per @@ -446,7 +446,7 @@ dump: } static int iscsit_dataout_pre_datapduinorder_no( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, unsigned char *buf) { struct iscsi_pdu *pdu; @@ -477,7 +477,7 @@ static int iscsit_dataout_pre_datapduinorder_no( return DATAOUT_NORMAL; } -static int iscsit_dataout_update_r2t(struct iscsi_cmd *cmd, u32 offset, u32 length) +static int iscsit_dataout_update_r2t(struct iscsit_cmd *cmd, u32 offset, u32 length) { struct iscsi_r2t *r2t; @@ -497,7 +497,7 @@ static int iscsit_dataout_update_r2t(struct iscsi_cmd *cmd, u32 offset, u32 leng } static int iscsit_dataout_update_datapduinorder_no( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, u32 data_sn, int f_bit) { @@ -530,7 +530,7 @@ static int iscsit_dataout_update_datapduinorder_no( } static int iscsit_dataout_post_crc_passed( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, unsigned char *buf) { int ret, send_r2t = 0; @@ -641,7 +641,7 @@ static int iscsit_dataout_post_crc_passed( } static int iscsit_dataout_post_crc_failed( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, unsigned char *buf) { struct iscsi_conn *conn = cmd->conn; @@ -679,7 +679,7 @@ recover: * and CRC computed. */ int iscsit_check_pre_dataout( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, unsigned char *buf) { int ret; @@ -717,7 +717,7 @@ int iscsit_check_pre_dataout( * and CRC computed. */ int iscsit_check_post_dataout( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, unsigned char *buf, u8 data_crc_failed) { diff --git a/drivers/target/iscsi/iscsi_target_erl0.h b/drivers/target/iscsi/iscsi_target_erl0.h index 883ebf6d36cf..d23a3041c325 100644 --- a/drivers/target/iscsi/iscsi_target_erl0.h +++ b/drivers/target/iscsi/iscsi_target_erl0.h @@ -4,13 +4,13 @@ #include -struct iscsi_cmd; +struct iscsit_cmd; struct iscsi_conn; struct iscsi_session; -extern void iscsit_set_dataout_sequence_values(struct iscsi_cmd *); -extern int iscsit_check_pre_dataout(struct iscsi_cmd *, unsigned char *); -extern int iscsit_check_post_dataout(struct iscsi_cmd *, unsigned char *, u8); +extern void iscsit_set_dataout_sequence_values(struct iscsit_cmd *); +extern int iscsit_check_pre_dataout(struct iscsit_cmd *, unsigned char *); +extern int iscsit_check_post_dataout(struct iscsit_cmd *, unsigned char *, u8); extern void iscsit_start_time2retain_handler(struct iscsi_session *); extern void iscsit_handle_time2retain_timeout(struct timer_list *t); extern int iscsit_stop_time2retain_timer(struct iscsi_session *); diff --git a/drivers/target/iscsi/iscsi_target_erl1.c b/drivers/target/iscsi/iscsi_target_erl1.c index 0dd52f484fec..d348a9af7789 100644 --- a/drivers/target/iscsi/iscsi_target_erl1.c +++ b/drivers/target/iscsi/iscsi_target_erl1.c @@ -87,7 +87,7 @@ int iscsit_dump_data_payload( * Used for retransmitting R2Ts from a R2T SNACK request. */ static int iscsit_send_recovery_r2t_for_snack( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_r2t *r2t) { /* @@ -109,7 +109,7 @@ static int iscsit_send_recovery_r2t_for_snack( } static int iscsit_handle_r2t_snack( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, unsigned char *buf, u32 begrun, u32 runlength) @@ -167,7 +167,7 @@ static int iscsit_handle_r2t_snack( * FIXME: How is this handled for a RData SNACK? */ int iscsit_create_recovery_datain_values_datasequenceinorder_yes( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_datain_req *dr) { u32 data_sn = 0, data_sn_count = 0; @@ -213,7 +213,7 @@ int iscsit_create_recovery_datain_values_datasequenceinorder_yes( * FIXME: How is this handled for a RData SNACK? */ int iscsit_create_recovery_datain_values_datasequenceinorder_no( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_datain_req *dr) { int found_seq = 0, i; @@ -224,7 +224,7 @@ int iscsit_create_recovery_datain_values_datasequenceinorder_no( struct iscsi_seq *first_seq = NULL, *seq = NULL; if (!cmd->seq_list) { - pr_err("struct iscsi_cmd->seq_list is NULL!\n"); + pr_err("struct iscsit_cmd->seq_list is NULL!\n"); return -1; } @@ -371,7 +371,7 @@ done: } static int iscsit_handle_recovery_datain( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, unsigned char *buf, u32 begrun, u32 runlength) @@ -439,7 +439,7 @@ int iscsit_handle_recovery_datain_or_r2t( u32 begrun, u32 runlength) { - struct iscsi_cmd *cmd; + struct iscsit_cmd *cmd; cmd = iscsit_find_cmd_from_itt(conn, init_task_tag); if (!cmd) @@ -471,7 +471,7 @@ int iscsit_handle_status_snack( u32 begrun, u32 runlength) { - struct iscsi_cmd *cmd = NULL; + struct iscsit_cmd *cmd = NULL; u32 last_statsn; int found_cmd; @@ -534,7 +534,7 @@ int iscsit_handle_data_ack( u32 begrun, u32 runlength) { - struct iscsi_cmd *cmd = NULL; + struct iscsit_cmd *cmd = NULL; cmd = iscsit_find_cmd_from_ttt(conn, targ_xfer_tag); if (!cmd) { @@ -565,7 +565,7 @@ int iscsit_handle_data_ack( } static int iscsit_send_recovery_r2t( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, u32 offset, u32 xfer_len) { @@ -579,7 +579,7 @@ static int iscsit_send_recovery_r2t( } int iscsit_dataout_datapduinorder_no_fbit( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_pdu *pdu) { int i, send_recovery_r2t = 0, recovery = 0; @@ -655,7 +655,7 @@ int iscsit_dataout_datapduinorder_no_fbit( } static int iscsit_recalculate_dataout_values( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, u32 pdu_offset, u32 pdu_length, u32 *r2t_offset, @@ -732,7 +732,7 @@ static int iscsit_recalculate_dataout_values( } int iscsit_recover_dataout_sequence( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, u32 pdu_offset, u32 pdu_length) { @@ -843,7 +843,7 @@ void iscsit_clear_ooo_cmdsns_for_conn(struct iscsi_conn *conn) int iscsit_execute_ooo_cmdsns(struct iscsi_session *sess) { int ooo_count = 0; - struct iscsi_cmd *cmd = NULL; + struct iscsit_cmd *cmd = NULL; struct iscsi_ooo_cmdsn *ooo_cmdsn, *ooo_cmdsn_tmp; lockdep_assert_held(&sess->cmdsn_mutex); @@ -884,7 +884,7 @@ int iscsit_execute_ooo_cmdsns(struct iscsi_session *sess) * 2. With no locks held directly from iscsi_handle_XXX_pdu() functions * for immediate commands. */ -int iscsit_execute_cmd(struct iscsi_cmd *cmd, int ooo) +int iscsit_execute_cmd(struct iscsit_cmd *cmd, int ooo) { struct se_cmd *se_cmd = &cmd->se_cmd; struct iscsi_conn *conn = cmd->conn; @@ -1010,7 +1010,7 @@ void iscsit_free_all_ooo_cmdsns(struct iscsi_session *sess) int iscsit_handle_ooo_cmdsn( struct iscsi_session *sess, - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, u32 cmdsn) { int batch = 0; @@ -1049,7 +1049,7 @@ int iscsit_handle_ooo_cmdsn( } static int iscsit_set_dataout_timeout_values( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, u32 *offset, u32 *length) { @@ -1095,7 +1095,7 @@ void iscsit_handle_dataout_timeout(struct timer_list *t) { u32 pdu_length = 0, pdu_offset = 0; u32 r2t_length = 0, r2t_offset = 0; - struct iscsi_cmd *cmd = from_timer(cmd, t, dataout_timer); + struct iscsit_cmd *cmd = from_timer(cmd, t, dataout_timer); struct iscsi_conn *conn = cmd->conn; struct iscsi_session *sess = NULL; struct iscsi_node_attrib *na; @@ -1179,7 +1179,7 @@ failure: iscsit_dec_conn_usage_count(conn); } -void iscsit_mod_dataout_timer(struct iscsi_cmd *cmd) +void iscsit_mod_dataout_timer(struct iscsit_cmd *cmd) { struct iscsi_conn *conn = cmd->conn; struct iscsi_session *sess = conn->sess; @@ -1199,7 +1199,7 @@ void iscsit_mod_dataout_timer(struct iscsi_cmd *cmd) } void iscsit_start_dataout_timer( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_conn *conn) { struct iscsi_session *sess = conn->sess; @@ -1218,7 +1218,7 @@ void iscsit_start_dataout_timer( mod_timer(&cmd->dataout_timer, jiffies + na->dataout_timeout * HZ); } -void iscsit_stop_dataout_timer(struct iscsi_cmd *cmd) +void iscsit_stop_dataout_timer(struct iscsit_cmd *cmd) { spin_lock_bh(&cmd->dataout_timeout_lock); if (!(cmd->dataout_timer_flags & ISCSI_TF_RUNNING)) { diff --git a/drivers/target/iscsi/iscsi_target_erl1.h b/drivers/target/iscsi/iscsi_target_erl1.h index 1f6973f87fea..48a13fc32e93 100644 --- a/drivers/target/iscsi/iscsi_target_erl1.h +++ b/drivers/target/iscsi/iscsi_target_erl1.h @@ -5,7 +5,7 @@ #include #include /* itt_t */ -struct iscsi_cmd; +struct iscsit_cmd; struct iscsi_conn; struct iscsi_datain_req; struct iscsi_ooo_cmdsn; @@ -14,25 +14,25 @@ struct iscsi_session; extern int iscsit_dump_data_payload(struct iscsi_conn *, u32, int); extern int iscsit_create_recovery_datain_values_datasequenceinorder_yes( - struct iscsi_cmd *, struct iscsi_datain_req *); + struct iscsit_cmd *, struct iscsi_datain_req *); extern int iscsit_create_recovery_datain_values_datasequenceinorder_no( - struct iscsi_cmd *, struct iscsi_datain_req *); + struct iscsit_cmd *, struct iscsi_datain_req *); extern int iscsit_handle_recovery_datain_or_r2t(struct iscsi_conn *, unsigned char *, itt_t, u32, u32, u32); extern int iscsit_handle_status_snack(struct iscsi_conn *, itt_t, u32, u32, u32); extern int iscsit_handle_data_ack(struct iscsi_conn *, u32, u32, u32); -extern int iscsit_dataout_datapduinorder_no_fbit(struct iscsi_cmd *, struct iscsi_pdu *); -extern int iscsit_recover_dataout_sequence(struct iscsi_cmd *, u32, u32); +extern int iscsit_dataout_datapduinorder_no_fbit(struct iscsit_cmd *, struct iscsi_pdu *); +extern int iscsit_recover_dataout_sequence(struct iscsit_cmd *, u32, u32); extern void iscsit_clear_ooo_cmdsns_for_conn(struct iscsi_conn *); extern void iscsit_free_all_ooo_cmdsns(struct iscsi_session *); extern int iscsit_execute_ooo_cmdsns(struct iscsi_session *); -extern int iscsit_execute_cmd(struct iscsi_cmd *, int); -extern int iscsit_handle_ooo_cmdsn(struct iscsi_session *, struct iscsi_cmd *, u32); +extern int iscsit_execute_cmd(struct iscsit_cmd *, int); +extern int iscsit_handle_ooo_cmdsn(struct iscsi_session *, struct iscsit_cmd *, u32); extern void iscsit_remove_ooo_cmdsn(struct iscsi_session *, struct iscsi_ooo_cmdsn *); extern void iscsit_handle_dataout_timeout(struct timer_list *t); -extern void iscsit_mod_dataout_timer(struct iscsi_cmd *); -extern void iscsit_start_dataout_timer(struct iscsi_cmd *, struct iscsi_conn *); -extern void iscsit_stop_dataout_timer(struct iscsi_cmd *); +extern void iscsit_mod_dataout_timer(struct iscsit_cmd *); +extern void iscsit_start_dataout_timer(struct iscsit_cmd *, struct iscsi_conn *); +extern void iscsit_stop_dataout_timer(struct iscsit_cmd *); #endif /* ISCSI_TARGET_ERL1_H */ diff --git a/drivers/target/iscsi/iscsi_target_erl2.c b/drivers/target/iscsi/iscsi_target_erl2.c index b1b7db9d1eda..f19ac2dbc062 100644 --- a/drivers/target/iscsi/iscsi_target_erl2.c +++ b/drivers/target/iscsi/iscsi_target_erl2.c @@ -26,7 +26,7 @@ * FIXME: Does RData SNACK apply here as well? */ void iscsit_create_conn_recovery_datain_values( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, __be32 exp_data_sn) { u32 data_sn = 0; @@ -54,7 +54,7 @@ void iscsit_create_conn_recovery_datain_values( } void iscsit_create_conn_recovery_dataout_values( - struct iscsi_cmd *cmd) + struct iscsit_cmd *cmd) { u32 write_data_done = 0; struct iscsi_conn *conn = cmd->conn; @@ -119,7 +119,7 @@ struct iscsi_conn_recovery *iscsit_get_inactive_connection_recovery_entry( void iscsit_free_connection_recovery_entries(struct iscsi_session *sess) { - struct iscsi_cmd *cmd, *cmd_tmp; + struct iscsit_cmd *cmd, *cmd_tmp; struct iscsi_conn_recovery *cr, *cr_tmp; spin_lock(&sess->cr_a_lock); @@ -197,7 +197,7 @@ static void iscsit_remove_inactive_connection_recovery_entry( * Called with cr->conn_recovery_cmd_lock help. */ int iscsit_remove_cmd_from_connection_recovery( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_session *sess) { struct iscsi_conn_recovery *cr; @@ -218,7 +218,7 @@ void iscsit_discard_cr_cmds_by_expstatsn( u32 exp_statsn) { u32 dropped_count = 0; - struct iscsi_cmd *cmd, *cmd_tmp; + struct iscsit_cmd *cmd, *cmd_tmp; struct iscsi_session *sess = cr->sess; spin_lock(&cr->conn_recovery_cmd_lock); @@ -266,7 +266,7 @@ void iscsit_discard_cr_cmds_by_expstatsn( int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(struct iscsi_conn *conn) { u32 dropped_count = 0; - struct iscsi_cmd *cmd, *cmd_tmp; + struct iscsit_cmd *cmd, *cmd_tmp; struct iscsi_ooo_cmdsn *ooo_cmdsn, *ooo_cmdsn_tmp; struct iscsi_session *sess = conn->sess; @@ -307,13 +307,13 @@ int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(struct iscsi_conn *conn) int iscsit_prepare_cmds_for_reallegiance(struct iscsi_conn *conn) { u32 cmd_count = 0; - struct iscsi_cmd *cmd, *cmd_tmp; + struct iscsit_cmd *cmd, *cmd_tmp; struct iscsi_conn_recovery *cr; /* * Allocate an struct iscsi_conn_recovery for this connection. - * Each struct iscsi_cmd contains an struct iscsi_conn_recovery pointer - * (struct iscsi_cmd->cr) so we need to allocate this before preparing the + * Each struct iscsit_cmd contains an struct iscsi_conn_recovery pointer + * (struct iscsit_cmd->cr) so we need to allocate this before preparing the * connection's command list for connection recovery. */ cr = kzalloc(sizeof(struct iscsi_conn_recovery), GFP_KERNEL); @@ -393,7 +393,7 @@ int iscsit_prepare_cmds_for_reallegiance(struct iscsi_conn *conn) transport_wait_for_tasks(&cmd->se_cmd); /* - * Add the struct iscsi_cmd to the connection recovery cmd list + * Add the struct iscsit_cmd to the connection recovery cmd list */ spin_lock(&cr->conn_recovery_cmd_lock); list_add_tail(&cmd->i_conn_node, &cr->conn_recovery_cmd_list); diff --git a/drivers/target/iscsi/iscsi_target_erl2.h b/drivers/target/iscsi/iscsi_target_erl2.h index a39b0caf2337..cf411375ad4c 100644 --- a/drivers/target/iscsi/iscsi_target_erl2.h +++ b/drivers/target/iscsi/iscsi_target_erl2.h @@ -4,19 +4,19 @@ #include -struct iscsi_cmd; +struct iscsit_cmd; struct iscsi_conn; struct iscsi_conn_recovery; struct iscsi_session; -extern void iscsit_create_conn_recovery_datain_values(struct iscsi_cmd *, __be32); -extern void iscsit_create_conn_recovery_dataout_values(struct iscsi_cmd *); +extern void iscsit_create_conn_recovery_datain_values(struct iscsit_cmd *, __be32); +extern void iscsit_create_conn_recovery_dataout_values(struct iscsit_cmd *); extern struct iscsi_conn_recovery *iscsit_get_inactive_connection_recovery_entry( struct iscsi_session *, u16); extern void iscsit_free_connection_recovery_entries(struct iscsi_session *); extern int iscsit_remove_active_connection_recovery_entry( struct iscsi_conn_recovery *, struct iscsi_session *); -extern int iscsit_remove_cmd_from_connection_recovery(struct iscsi_cmd *, +extern int iscsit_remove_cmd_from_connection_recovery(struct iscsit_cmd *, struct iscsi_session *); extern void iscsit_discard_cr_cmds_by_expstatsn(struct iscsi_conn_recovery *, u32); extern int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(struct iscsi_conn *); diff --git a/drivers/target/iscsi/iscsi_target_nego.c b/drivers/target/iscsi/iscsi_target_nego.c index c0ed6f8e5c5b..b0cc8e0a10e8 100644 --- a/drivers/target/iscsi/iscsi_target_nego.c +++ b/drivers/target/iscsi/iscsi_target_nego.c @@ -1272,7 +1272,7 @@ get_target: alloc_tags: tag_num = max_t(u32, ISCSIT_MIN_TAGS, queue_depth); tag_num = (tag_num * 2) + ISCSIT_EXTRA_TAGS; - tag_size = sizeof(struct iscsi_cmd) + conn->conn_transport->priv_size; + tag_size = sizeof(struct iscsit_cmd) + conn->conn_transport->priv_size; ret = transport_alloc_session_tags(sess->se_sess, tag_num, tag_size); if (ret < 0) { diff --git a/drivers/target/iscsi/iscsi_target_seq_pdu_list.c b/drivers/target/iscsi/iscsi_target_seq_pdu_list.c index ea2b02a93e45..98aee976d79c 100644 --- a/drivers/target/iscsi/iscsi_target_seq_pdu_list.c +++ b/drivers/target/iscsi/iscsi_target_seq_pdu_list.c @@ -18,7 +18,7 @@ #include "iscsi_target_seq_pdu_list.h" #ifdef DEBUG -static void iscsit_dump_seq_list(struct iscsi_cmd *cmd) +static void iscsit_dump_seq_list(struct iscsit_cmd *cmd) { int i; struct iscsi_seq *seq; @@ -36,7 +36,7 @@ static void iscsit_dump_seq_list(struct iscsi_cmd *cmd) } } -static void iscsit_dump_pdu_list(struct iscsi_cmd *cmd) +static void iscsit_dump_pdu_list(struct iscsit_cmd *cmd) { int i; struct iscsi_pdu *pdu; @@ -52,12 +52,12 @@ static void iscsit_dump_pdu_list(struct iscsi_cmd *cmd) } } #else -static void iscsit_dump_seq_list(struct iscsi_cmd *cmd) {} -static void iscsit_dump_pdu_list(struct iscsi_cmd *cmd) {} +static void iscsit_dump_seq_list(struct iscsit_cmd *cmd) {} +static void iscsit_dump_pdu_list(struct iscsit_cmd *cmd) {} #endif static void iscsit_ordered_seq_lists( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, u8 type) { u32 i, seq_count = 0; @@ -70,7 +70,7 @@ static void iscsit_ordered_seq_lists( } static void iscsit_ordered_pdu_lists( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, u8 type) { u32 i, pdu_send_order = 0, seq_no = 0; @@ -117,7 +117,7 @@ redo: } static int iscsit_randomize_pdu_lists( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, u8 type) { int i = 0; @@ -167,7 +167,7 @@ redo: } static int iscsit_randomize_seq_lists( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, u8 type) { int i, j = 0; @@ -199,7 +199,7 @@ static int iscsit_randomize_seq_lists( } static void iscsit_determine_counts_for_list( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_build_list *bl, u32 *seq_count, u32 *pdu_count) @@ -283,7 +283,7 @@ static void iscsit_determine_counts_for_list( * or DataPDUInOrder=No. */ static int iscsit_do_build_pdu_and_seq_lists( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_build_list *bl) { int check_immediate = 0, datapduinorder, datasequenceinorder; @@ -484,7 +484,7 @@ static int iscsit_do_build_pdu_and_seq_lists( } int iscsit_build_pdu_and_seq_lists( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, u32 immediate_data_length) { struct iscsi_build_list bl; @@ -559,7 +559,7 @@ int iscsit_build_pdu_and_seq_lists( } struct iscsi_pdu *iscsit_get_pdu_holder( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, u32 offset, u32 length) { @@ -567,7 +567,7 @@ struct iscsi_pdu *iscsit_get_pdu_holder( struct iscsi_pdu *pdu = NULL; if (!cmd->pdu_list) { - pr_err("struct iscsi_cmd->pdu_list is NULL!\n"); + pr_err("struct iscsit_cmd->pdu_list is NULL!\n"); return NULL; } @@ -583,7 +583,7 @@ struct iscsi_pdu *iscsit_get_pdu_holder( } struct iscsi_pdu *iscsit_get_pdu_holder_for_seq( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_seq *seq) { u32 i; @@ -591,7 +591,7 @@ struct iscsi_pdu *iscsit_get_pdu_holder_for_seq( struct iscsi_pdu *pdu = NULL; if (!cmd->pdu_list) { - pr_err("struct iscsi_cmd->pdu_list is NULL!\n"); + pr_err("struct iscsit_cmd->pdu_list is NULL!\n"); return NULL; } @@ -660,14 +660,14 @@ redo: } struct iscsi_seq *iscsit_get_seq_holder( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, u32 offset, u32 length) { u32 i; if (!cmd->seq_list) { - pr_err("struct iscsi_cmd->seq_list is NULL!\n"); + pr_err("struct iscsit_cmd->seq_list is NULL!\n"); return NULL; } diff --git a/drivers/target/iscsi/iscsi_target_seq_pdu_list.h b/drivers/target/iscsi/iscsi_target_seq_pdu_list.h index 5a0907027973..288298f9f1b4 100644 --- a/drivers/target/iscsi/iscsi_target_seq_pdu_list.h +++ b/drivers/target/iscsi/iscsi_target_seq_pdu_list.h @@ -82,11 +82,11 @@ struct iscsi_seq { u32 xfer_len; } ____cacheline_aligned; -struct iscsi_cmd; +struct iscsit_cmd; -extern int iscsit_build_pdu_and_seq_lists(struct iscsi_cmd *, u32); -extern struct iscsi_pdu *iscsit_get_pdu_holder(struct iscsi_cmd *, u32, u32); -extern struct iscsi_pdu *iscsit_get_pdu_holder_for_seq(struct iscsi_cmd *, struct iscsi_seq *); -extern struct iscsi_seq *iscsit_get_seq_holder(struct iscsi_cmd *, u32, u32); +extern int iscsit_build_pdu_and_seq_lists(struct iscsit_cmd *, u32); +extern struct iscsi_pdu *iscsit_get_pdu_holder(struct iscsit_cmd *, u32, u32); +extern struct iscsi_pdu *iscsit_get_pdu_holder_for_seq(struct iscsit_cmd *, struct iscsi_seq *); +extern struct iscsi_seq *iscsit_get_seq_holder(struct iscsit_cmd *, u32, u32); #endif /* ISCSI_SEQ_AND_PDU_LIST_H */ diff --git a/drivers/target/iscsi/iscsi_target_tmr.c b/drivers/target/iscsi/iscsi_target_tmr.c index 7d618db80c51..aa062c3166c2 100644 --- a/drivers/target/iscsi/iscsi_target_tmr.c +++ b/drivers/target/iscsi/iscsi_target_tmr.c @@ -28,10 +28,10 @@ #include "iscsi_target.h" u8 iscsit_tmr_abort_task( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, unsigned char *buf) { - struct iscsi_cmd *ref_cmd; + struct iscsit_cmd *ref_cmd; struct iscsi_conn *conn = cmd->conn; struct iscsi_tmr_req *tmr_req = cmd->tmr_req; struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req; @@ -103,10 +103,10 @@ int iscsit_tmr_task_cold_reset( } u8 iscsit_tmr_task_reassign( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, unsigned char *buf) { - struct iscsi_cmd *ref_cmd = NULL; + struct iscsit_cmd *ref_cmd = NULL; struct iscsi_conn *conn = cmd->conn; struct iscsi_conn_recovery *cr = NULL; struct iscsi_tmr_req *tmr_req = cmd->tmr_req; @@ -175,7 +175,7 @@ u8 iscsit_tmr_task_reassign( } static void iscsit_task_reassign_remove_cmd( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_conn_recovery *cr, struct iscsi_session *sess) { @@ -195,7 +195,7 @@ static int iscsit_task_reassign_complete_nop_out( struct iscsi_tmr_req *tmr_req, struct iscsi_conn *conn) { - struct iscsi_cmd *cmd = tmr_req->ref_cmd; + struct iscsit_cmd *cmd = tmr_req->ref_cmd; struct iscsi_conn_recovery *cr; if (!cmd->cr) { @@ -224,7 +224,7 @@ static int iscsit_task_reassign_complete_nop_out( } static int iscsit_task_reassign_complete_write( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_tmr_req *tmr_req) { int no_build_r2ts = 0; @@ -296,7 +296,7 @@ static int iscsit_task_reassign_complete_write( } static int iscsit_task_reassign_complete_read( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_tmr_req *tmr_req) { struct iscsi_conn *conn = cmd->conn; @@ -349,7 +349,7 @@ static int iscsit_task_reassign_complete_read( } static int iscsit_task_reassign_complete_none( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_tmr_req *tmr_req) { struct iscsi_conn *conn = cmd->conn; @@ -363,7 +363,7 @@ static int iscsit_task_reassign_complete_scsi_cmnd( struct iscsi_tmr_req *tmr_req, struct iscsi_conn *conn) { - struct iscsi_cmd *cmd = tmr_req->ref_cmd; + struct iscsit_cmd *cmd = tmr_req->ref_cmd; struct iscsi_conn_recovery *cr; if (!cmd->cr) { @@ -412,11 +412,11 @@ static int iscsit_task_reassign_complete( struct iscsi_tmr_req *tmr_req, struct iscsi_conn *conn) { - struct iscsi_cmd *cmd; + struct iscsit_cmd *cmd; int ret = 0; if (!tmr_req->ref_cmd) { - pr_err("TMR Request is missing a RefCmd struct iscsi_cmd.\n"); + pr_err("TMR Request is missing a RefCmd struct iscsit_cmd.\n"); return -1; } cmd = tmr_req->ref_cmd; @@ -451,7 +451,7 @@ static int iscsit_task_reassign_complete( * Right now the only one that its really needed for is * connection recovery releated TASK_REASSIGN. */ -int iscsit_tmr_post_handler(struct iscsi_cmd *cmd, struct iscsi_conn *conn) +int iscsit_tmr_post_handler(struct iscsit_cmd *cmd, struct iscsi_conn *conn) { struct iscsi_tmr_req *tmr_req = cmd->tmr_req; struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req; @@ -475,7 +475,7 @@ static int iscsit_task_reassign_prepare_read( } static void iscsit_task_reassign_prepare_unsolicited_dataout( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_conn *conn) { int i, j; @@ -546,7 +546,7 @@ static int iscsit_task_reassign_prepare_write( struct iscsi_tmr_req *tmr_req, struct iscsi_conn *conn) { - struct iscsi_cmd *cmd = tmr_req->ref_cmd; + struct iscsit_cmd *cmd = tmr_req->ref_cmd; struct iscsi_pdu *pdu = NULL; struct iscsi_r2t *r2t = NULL, *r2t_tmp; int first_incomplete_r2t = 1, i = 0; @@ -575,7 +575,7 @@ static int iscsit_task_reassign_prepare_write( * * If we have not received all DataOUT in question, we must * make sure to make the appropriate changes to values in - * struct iscsi_cmd (and elsewhere depending on session parameters) + * struct iscsit_cmd (and elsewhere depending on session parameters) * so iscsit_build_r2ts_for_cmd() in iscsit_task_reassign_complete_write() * will resend a new R2T for the DataOUT sequences in question. */ @@ -708,7 +708,7 @@ next: * to check that the Initiator is not requesting R2Ts for DataOUT * sequences it has already completed. * - * Free each R2T in question and adjust values in struct iscsi_cmd + * Free each R2T in question and adjust values in struct iscsit_cmd * accordingly so iscsit_build_r2ts_for_cmd() do the rest of * the work after the TMR TASK_REASSIGN Response is sent. */ @@ -773,13 +773,13 @@ drop_unacknowledged_r2ts: /* * Performs sanity checks TMR TASK_REASSIGN's ExpDataSN for - * a given struct iscsi_cmd. + * a given struct iscsit_cmd. */ int iscsit_check_task_reassign_expdatasn( struct iscsi_tmr_req *tmr_req, struct iscsi_conn *conn) { - struct iscsi_cmd *ref_cmd = tmr_req->ref_cmd; + struct iscsit_cmd *ref_cmd = tmr_req->ref_cmd; if (ref_cmd->iscsi_opcode != ISCSI_OP_SCSI_CMD) return 0; diff --git a/drivers/target/iscsi/iscsi_target_tmr.h b/drivers/target/iscsi/iscsi_target_tmr.h index 301f0936bd8e..60aac3a8f3c0 100644 --- a/drivers/target/iscsi/iscsi_target_tmr.h +++ b/drivers/target/iscsi/iscsi_target_tmr.h @@ -4,17 +4,17 @@ #include -struct iscsi_cmd; +struct iscsit_cmd; struct iscsi_conn; struct iscsi_tmr_req; -extern u8 iscsit_tmr_abort_task(struct iscsi_cmd *, unsigned char *); +extern u8 iscsit_tmr_abort_task(struct iscsit_cmd *, unsigned char *); extern int iscsit_tmr_task_warm_reset(struct iscsi_conn *, struct iscsi_tmr_req *, unsigned char *); extern int iscsit_tmr_task_cold_reset(struct iscsi_conn *, struct iscsi_tmr_req *, unsigned char *); -extern u8 iscsit_tmr_task_reassign(struct iscsi_cmd *, unsigned char *); -extern int iscsit_tmr_post_handler(struct iscsi_cmd *, struct iscsi_conn *); +extern u8 iscsit_tmr_task_reassign(struct iscsit_cmd *, unsigned char *); +extern int iscsit_tmr_post_handler(struct iscsit_cmd *, struct iscsi_conn *); extern int iscsit_check_task_reassign_expdatasn(struct iscsi_tmr_req *, struct iscsi_conn *); diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c index 6dd5810e2af1..39b705c34f95 100644 --- a/drivers/target/iscsi/iscsi_target_util.c +++ b/drivers/target/iscsi/iscsi_target_util.c @@ -32,7 +32,7 @@ extern struct list_head g_tiqn_list; extern spinlock_t tiqn_lock; int iscsit_add_r2t_to_list( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, u32 offset, u32 xfer_len, int recovery, @@ -65,7 +65,7 @@ int iscsit_add_r2t_to_list( } struct iscsi_r2t *iscsit_get_r2t_for_eos( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, u32 offset, u32 length) { @@ -86,7 +86,7 @@ struct iscsi_r2t *iscsit_get_r2t_for_eos( return NULL; } -struct iscsi_r2t *iscsit_get_r2t_from_list(struct iscsi_cmd *cmd) +struct iscsi_r2t *iscsit_get_r2t_from_list(struct iscsit_cmd *cmd) { struct iscsi_r2t *r2t; @@ -104,7 +104,7 @@ struct iscsi_r2t *iscsit_get_r2t_from_list(struct iscsi_cmd *cmd) return NULL; } -void iscsit_free_r2t(struct iscsi_r2t *r2t, struct iscsi_cmd *cmd) +void iscsit_free_r2t(struct iscsi_r2t *r2t, struct iscsit_cmd *cmd) { lockdep_assert_held(&cmd->r2t_lock); @@ -112,7 +112,7 @@ void iscsit_free_r2t(struct iscsi_r2t *r2t, struct iscsi_cmd *cmd) kmem_cache_free(lio_r2t_cache, r2t); } -void iscsit_free_r2ts_from_list(struct iscsi_cmd *cmd) +void iscsit_free_r2ts_from_list(struct iscsit_cmd *cmd) { struct iscsi_r2t *r2t, *r2t_tmp; @@ -152,9 +152,9 @@ static int iscsit_wait_for_tag(struct se_session *se_sess, int state, int *cpup) * May be called from software interrupt (timer) context for allocating * iSCSI NopINs. */ -struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *conn, int state) +struct iscsit_cmd *iscsit_allocate_cmd(struct iscsi_conn *conn, int state) { - struct iscsi_cmd *cmd; + struct iscsit_cmd *cmd; struct se_session *se_sess = conn->sess->se_sess; int size, tag, cpu; @@ -164,8 +164,8 @@ struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *conn, int state) if (tag < 0) return NULL; - size = sizeof(struct iscsi_cmd) + conn->conn_transport->priv_size; - cmd = (struct iscsi_cmd *)(se_sess->sess_cmd_map + (tag * size)); + size = sizeof(struct iscsit_cmd) + conn->conn_transport->priv_size; + cmd = (struct iscsit_cmd *)(se_sess->sess_cmd_map + (tag * size)); memset(cmd, 0, size); cmd->se_cmd.map_tag = tag; @@ -187,7 +187,7 @@ struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *conn, int state) EXPORT_SYMBOL(iscsit_allocate_cmd); struct iscsi_seq *iscsit_get_seq_holder_for_datain( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, u32 seq_send_order) { u32 i; @@ -199,12 +199,12 @@ struct iscsi_seq *iscsit_get_seq_holder_for_datain( return NULL; } -struct iscsi_seq *iscsit_get_seq_holder_for_r2t(struct iscsi_cmd *cmd) +struct iscsi_seq *iscsit_get_seq_holder_for_r2t(struct iscsit_cmd *cmd) { u32 i; if (!cmd->seq_list) { - pr_err("struct iscsi_cmd->seq_list is NULL!\n"); + pr_err("struct iscsit_cmd->seq_list is NULL!\n"); return NULL; } @@ -221,7 +221,7 @@ struct iscsi_seq *iscsit_get_seq_holder_for_r2t(struct iscsi_cmd *cmd) } struct iscsi_r2t *iscsit_get_holder_for_r2tsn( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, u32 r2t_sn) { struct iscsi_r2t *r2t; @@ -282,7 +282,7 @@ static inline int iscsit_check_received_cmdsn(struct iscsi_session *sess, u32 cm * Commands may be received out of order if MC/S is in use. * Ensure they are executed in CmdSN order. */ -int iscsit_sequence_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, +int iscsit_sequence_cmd(struct iscsi_conn *conn, struct iscsit_cmd *cmd, unsigned char *buf, __be32 cmdsn) { int ret, cmdsn_ret; @@ -333,7 +333,7 @@ int iscsit_sequence_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, } EXPORT_SYMBOL(iscsit_sequence_cmd); -int iscsit_check_unsolicited_dataout(struct iscsi_cmd *cmd, unsigned char *buf) +int iscsit_check_unsolicited_dataout(struct iscsit_cmd *cmd, unsigned char *buf) { struct iscsi_conn *conn = cmd->conn; struct se_cmd *se_cmd = &cmd->se_cmd; @@ -377,11 +377,11 @@ int iscsit_check_unsolicited_dataout(struct iscsi_cmd *cmd, unsigned char *buf) return 0; } -struct iscsi_cmd *iscsit_find_cmd_from_itt( +struct iscsit_cmd *iscsit_find_cmd_from_itt( struct iscsi_conn *conn, itt_t init_task_tag) { - struct iscsi_cmd *cmd; + struct iscsit_cmd *cmd; spin_lock_bh(&conn->cmd_lock); list_for_each_entry(cmd, &conn->conn_cmd_list, i_conn_node) { @@ -398,12 +398,12 @@ struct iscsi_cmd *iscsit_find_cmd_from_itt( } EXPORT_SYMBOL(iscsit_find_cmd_from_itt); -struct iscsi_cmd *iscsit_find_cmd_from_itt_or_dump( +struct iscsit_cmd *iscsit_find_cmd_from_itt_or_dump( struct iscsi_conn *conn, itt_t init_task_tag, u32 length) { - struct iscsi_cmd *cmd; + struct iscsit_cmd *cmd; spin_lock_bh(&conn->cmd_lock); list_for_each_entry(cmd, &conn->conn_cmd_list, i_conn_node) { @@ -425,11 +425,11 @@ struct iscsi_cmd *iscsit_find_cmd_from_itt_or_dump( } EXPORT_SYMBOL(iscsit_find_cmd_from_itt_or_dump); -struct iscsi_cmd *iscsit_find_cmd_from_ttt( +struct iscsit_cmd *iscsit_find_cmd_from_ttt( struct iscsi_conn *conn, u32 targ_xfer_tag) { - struct iscsi_cmd *cmd = NULL; + struct iscsit_cmd *cmd = NULL; spin_lock_bh(&conn->cmd_lock); list_for_each_entry(cmd, &conn->conn_cmd_list, i_conn_node) { @@ -447,11 +447,11 @@ struct iscsi_cmd *iscsit_find_cmd_from_ttt( int iscsit_find_cmd_for_recovery( struct iscsi_session *sess, - struct iscsi_cmd **cmd_ptr, + struct iscsit_cmd **cmd_ptr, struct iscsi_conn_recovery **cr_ptr, itt_t init_task_tag) { - struct iscsi_cmd *cmd = NULL; + struct iscsit_cmd *cmd = NULL; struct iscsi_conn_recovery *cr; /* * Scan through the inactive connection recovery list's command list. @@ -498,7 +498,7 @@ int iscsit_find_cmd_for_recovery( } void iscsit_add_cmd_to_immediate_queue( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_conn *conn, u8 state) { @@ -545,7 +545,7 @@ struct iscsi_queue_req *iscsit_get_cmd_from_immediate_queue(struct iscsi_conn *c } static void iscsit_remove_cmd_from_immediate_queue( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_conn *conn) { struct iscsi_queue_req *qr, *qr_tmp; @@ -574,7 +574,7 @@ static void iscsit_remove_cmd_from_immediate_queue( } int iscsit_add_cmd_to_response_queue( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_conn *conn, u8 state) { @@ -621,7 +621,7 @@ struct iscsi_queue_req *iscsit_get_cmd_from_response_queue(struct iscsi_conn *co } static void iscsit_remove_cmd_from_response_queue( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_conn *conn) { struct iscsi_queue_req *qr, *qr_tmp; @@ -694,7 +694,7 @@ void iscsit_free_queue_reqs_for_conn(struct iscsi_conn *conn) spin_unlock_bh(&conn->response_queue_lock); } -void iscsit_release_cmd(struct iscsi_cmd *cmd) +void iscsit_release_cmd(struct iscsit_cmd *cmd) { struct iscsi_session *sess; struct se_cmd *se_cmd = &cmd->se_cmd; @@ -720,7 +720,7 @@ void iscsit_release_cmd(struct iscsi_cmd *cmd) } EXPORT_SYMBOL(iscsit_release_cmd); -void __iscsit_free_cmd(struct iscsi_cmd *cmd, bool check_queues) +void __iscsit_free_cmd(struct iscsit_cmd *cmd, bool check_queues) { struct iscsi_conn *conn = cmd->conn; @@ -742,7 +742,7 @@ void __iscsit_free_cmd(struct iscsi_cmd *cmd, bool check_queues) conn->conn_transport->iscsit_unmap_cmd(conn, cmd); } -void iscsit_free_cmd(struct iscsi_cmd *cmd, bool shutdown) +void iscsit_free_cmd(struct iscsit_cmd *cmd, bool shutdown) { struct se_cmd *se_cmd = cmd->se_cmd.se_tfo ? &cmd->se_cmd : NULL; int rc; @@ -870,7 +870,7 @@ void iscsit_inc_conn_usage_count(struct iscsi_conn *conn) static int iscsit_add_nopin(struct iscsi_conn *conn, int want_response) { u8 state; - struct iscsi_cmd *cmd; + struct iscsit_cmd *cmd; cmd = iscsit_allocate_cmd(conn, TASK_RUNNING); if (!cmd) @@ -1041,7 +1041,7 @@ void iscsit_stop_nopin_timer(struct iscsi_conn *conn) } int iscsit_send_tx_data( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_conn *conn, int use_misc) { @@ -1074,7 +1074,7 @@ send_data: } int iscsit_fe_sendpage_sg( - struct iscsi_cmd *cmd, + struct iscsit_cmd *cmd, struct iscsi_conn *conn) { struct scatterlist *sg = cmd->first_data_sg; diff --git a/drivers/target/iscsi/iscsi_target_util.h b/drivers/target/iscsi/iscsi_target_util.h index 8ee1c133a9b7..dec142ed4704 100644 --- a/drivers/target/iscsi/iscsi_target_util.h +++ b/drivers/target/iscsi/iscsi_target_util.h @@ -7,39 +7,39 @@ #define MARKER_SIZE 8 -struct iscsi_cmd; +struct iscsit_cmd; struct iscsi_conn; struct iscsi_conn_recovery; struct iscsi_session; -extern int iscsit_add_r2t_to_list(struct iscsi_cmd *, u32, u32, int, u32); -extern struct iscsi_r2t *iscsit_get_r2t_for_eos(struct iscsi_cmd *, u32, u32); -extern struct iscsi_r2t *iscsit_get_r2t_from_list(struct iscsi_cmd *); -extern void iscsit_free_r2t(struct iscsi_r2t *, struct iscsi_cmd *); -extern void iscsit_free_r2ts_from_list(struct iscsi_cmd *); -extern struct iscsi_cmd *iscsit_alloc_cmd(struct iscsi_conn *, gfp_t); -extern struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *, int); -extern struct iscsi_seq *iscsit_get_seq_holder_for_datain(struct iscsi_cmd *, u32); -extern struct iscsi_seq *iscsit_get_seq_holder_for_r2t(struct iscsi_cmd *); -extern struct iscsi_r2t *iscsit_get_holder_for_r2tsn(struct iscsi_cmd *, u32); -extern int iscsit_sequence_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, +extern int iscsit_add_r2t_to_list(struct iscsit_cmd *, u32, u32, int, u32); +extern struct iscsi_r2t *iscsit_get_r2t_for_eos(struct iscsit_cmd *, u32, u32); +extern struct iscsi_r2t *iscsit_get_r2t_from_list(struct iscsit_cmd *); +extern void iscsit_free_r2t(struct iscsi_r2t *, struct iscsit_cmd *); +extern void iscsit_free_r2ts_from_list(struct iscsit_cmd *); +extern struct iscsit_cmd *iscsit_alloc_cmd(struct iscsi_conn *, gfp_t); +extern struct iscsit_cmd *iscsit_allocate_cmd(struct iscsi_conn *, int); +extern struct iscsi_seq *iscsit_get_seq_holder_for_datain(struct iscsit_cmd *, u32); +extern struct iscsi_seq *iscsit_get_seq_holder_for_r2t(struct iscsit_cmd *); +extern struct iscsi_r2t *iscsit_get_holder_for_r2tsn(struct iscsit_cmd *, u32); +extern int iscsit_sequence_cmd(struct iscsi_conn *conn, struct iscsit_cmd *cmd, unsigned char * ,__be32 cmdsn); -extern int iscsit_check_unsolicited_dataout(struct iscsi_cmd *, unsigned char *); -extern struct iscsi_cmd *iscsit_find_cmd_from_itt_or_dump(struct iscsi_conn *, +extern int iscsit_check_unsolicited_dataout(struct iscsit_cmd *, unsigned char *); +extern struct iscsit_cmd *iscsit_find_cmd_from_itt_or_dump(struct iscsi_conn *, itt_t, u32); -extern struct iscsi_cmd *iscsit_find_cmd_from_ttt(struct iscsi_conn *, u32); -extern int iscsit_find_cmd_for_recovery(struct iscsi_session *, struct iscsi_cmd **, +extern struct iscsit_cmd *iscsit_find_cmd_from_ttt(struct iscsi_conn *, u32); +extern int iscsit_find_cmd_for_recovery(struct iscsi_session *, struct iscsit_cmd **, struct iscsi_conn_recovery **, itt_t); -extern void iscsit_add_cmd_to_immediate_queue(struct iscsi_cmd *, struct iscsi_conn *, u8); +extern void iscsit_add_cmd_to_immediate_queue(struct iscsit_cmd *, struct iscsi_conn *, u8); extern struct iscsi_queue_req *iscsit_get_cmd_from_immediate_queue(struct iscsi_conn *); -extern int iscsit_add_cmd_to_response_queue(struct iscsi_cmd *, struct iscsi_conn *, u8); +extern int iscsit_add_cmd_to_response_queue(struct iscsit_cmd *, struct iscsi_conn *, u8); extern struct iscsi_queue_req *iscsit_get_cmd_from_response_queue(struct iscsi_conn *); -extern void iscsit_remove_cmd_from_tx_queues(struct iscsi_cmd *, struct iscsi_conn *); +extern void iscsit_remove_cmd_from_tx_queues(struct iscsit_cmd *, struct iscsi_conn *); extern bool iscsit_conn_all_queues_empty(struct iscsi_conn *); extern void iscsit_free_queue_reqs_for_conn(struct iscsi_conn *); -extern void iscsit_release_cmd(struct iscsi_cmd *); -extern void __iscsit_free_cmd(struct iscsi_cmd *, bool); -extern void iscsit_free_cmd(struct iscsi_cmd *, bool); +extern void iscsit_release_cmd(struct iscsit_cmd *); +extern void __iscsit_free_cmd(struct iscsit_cmd *, bool); +extern void iscsit_free_cmd(struct iscsit_cmd *, bool); extern bool iscsit_check_session_usage_count(struct iscsi_session *sess, bool can_sleep); extern void iscsit_dec_session_usage_count(struct iscsi_session *); extern void iscsit_inc_session_usage_count(struct iscsi_session *); @@ -56,8 +56,8 @@ extern void iscsit_handle_nopin_timeout(struct timer_list *t); extern void __iscsit_start_nopin_timer(struct iscsi_conn *); extern void iscsit_start_nopin_timer(struct iscsi_conn *); extern void iscsit_stop_nopin_timer(struct iscsi_conn *); -extern int iscsit_send_tx_data(struct iscsi_cmd *, struct iscsi_conn *, int); -extern int iscsit_fe_sendpage_sg(struct iscsi_cmd *, struct iscsi_conn *); +extern int iscsit_send_tx_data(struct iscsit_cmd *, struct iscsi_conn *, int); +extern int iscsit_fe_sendpage_sg(struct iscsit_cmd *, struct iscsi_conn *); extern int iscsit_tx_login_rsp(struct iscsi_conn *, u8, u8); extern void iscsit_print_session_params(struct iscsi_session *); extern int iscsit_print_dev_to_proc(char *, char **, off_t, int); diff --git a/include/target/iscsi/iscsi_target_core.h b/include/target/iscsi/iscsi_target_core.h index adc87de0362b..4f9ef2899488 100644 --- a/include/target/iscsi/iscsi_target_core.h +++ b/include/target/iscsi/iscsi_target_core.h @@ -143,7 +143,7 @@ enum tiqn_state_table { TIQN_STATE_SHUTDOWN = 2, }; -/* struct iscsi_cmd->cmd_flags */ +/* struct iscsit_cmd->cmd_flags */ enum cmd_flags_table { ICF_GOT_LAST_DATAOUT = 0x00000001, ICF_GOT_DATACK_SNACK = 0x00000002, @@ -157,7 +157,7 @@ enum cmd_flags_table { ICF_SENDTARGETS_SINGLE = 0x00000200, }; -/* struct iscsi_cmd->i_state */ +/* struct iscsit_cmd->i_state */ enum cmd_i_state_table { ISTATE_NO_STATE = 0, ISTATE_NEW_CMD = 1, @@ -297,7 +297,7 @@ struct iscsi_sess_ops { struct iscsi_queue_req { int state; - struct iscsi_cmd *cmd; + struct iscsit_cmd *cmd; struct list_head qr_list; }; @@ -327,7 +327,7 @@ struct iscsi_ooo_cmdsn { u32 batch_count; u32 cmdsn; u32 exp_cmdsn; - struct iscsi_cmd *cmd; + struct iscsit_cmd *cmd; struct list_head ooo_list; } ____cacheline_aligned; @@ -349,7 +349,7 @@ struct iscsi_r2t { struct list_head r2t_list; } ____cacheline_aligned; -struct iscsi_cmd { +struct iscsit_cmd { enum iscsi_timer_flags_table dataout_timer_flags; /* DataOUT timeout retries */ u8 dataout_timeout_retries; @@ -405,22 +405,22 @@ struct iscsi_cmd { u32 outstanding_r2ts; /* Next R2T Offset when DataSequenceInOrder=Yes */ u32 r2t_offset; - /* Iovec current and orig count for iscsi_cmd->iov_data */ + /* Iovec current and orig count for iscsit_cmd->iov_data */ u32 iov_data_count; u32 orig_iov_data_count; /* Number of miscellaneous iovecs used for IP stack calls */ u32 iov_misc_count; - /* Number of struct iscsi_pdu in struct iscsi_cmd->pdu_list */ + /* Number of struct iscsi_pdu in struct iscsit_cmd->pdu_list */ u32 pdu_count; - /* Next struct iscsi_pdu to send in struct iscsi_cmd->pdu_list */ + /* Next struct iscsi_pdu to send in struct iscsit_cmd->pdu_list */ u32 pdu_send_order; - /* Current struct iscsi_pdu in struct iscsi_cmd->pdu_list */ + /* Current struct iscsi_pdu in struct iscsit_cmd->pdu_list */ u32 pdu_start; - /* Next struct iscsi_seq to send in struct iscsi_cmd->seq_list */ + /* Next struct iscsi_seq to send in struct iscsit_cmd->seq_list */ u32 seq_send_order; - /* Number of struct iscsi_seq in struct iscsi_cmd->seq_list */ + /* Number of struct iscsi_seq in struct iscsit_cmd->seq_list */ u32 seq_count; - /* Current struct iscsi_seq in struct iscsi_cmd->seq_list */ + /* Current struct iscsi_seq in struct iscsit_cmd->seq_list */ u32 seq_no; /* Lowest offset in current DataOUT sequence */ u32 seq_start_offset; @@ -444,12 +444,12 @@ struct iscsi_cmd { enum dma_data_direction data_direction; /* iSCSI PDU Header + CRC */ unsigned char pdu[ISCSI_HDR_LEN + ISCSI_CRC_LEN]; - /* Number of times struct iscsi_cmd is present in immediate queue */ + /* Number of times struct iscsit_cmd is present in immediate queue */ atomic_t immed_queue_count; atomic_t response_queue_count; spinlock_t datain_lock; spinlock_t dataout_timeout_lock; - /* spinlock for protecting struct iscsi_cmd->i_state */ + /* spinlock for protecting struct iscsit_cmd->i_state */ spinlock_t istate_lock; /* spinlock for adding within command recovery entries */ spinlock_t error_lock; @@ -503,7 +503,7 @@ struct iscsi_cmd { struct iscsi_tmr_req { bool task_reassign:1; u32 exp_data_sn; - struct iscsi_cmd *ref_cmd; + struct iscsit_cmd *ref_cmd; struct iscsi_conn_recovery *conn_recovery; struct se_tmr_req *se_tmr_req; }; @@ -583,7 +583,7 @@ struct iscsi_conn { cpumask_var_t allowed_cpumask; unsigned int conn_rx_reset_cpumask:1; unsigned int conn_tx_reset_cpumask:1; - /* list_head of struct iscsi_cmd for this connection */ + /* list_head of struct iscsit_cmd for this connection */ struct list_head conn_cmd_list; struct list_head immed_queue_list; struct list_head response_queue_list; @@ -898,7 +898,7 @@ static inline u32 session_get_next_ttt(struct iscsi_session *session) return ttt; } -extern struct iscsi_cmd *iscsit_find_cmd_from_itt(struct iscsi_conn *, itt_t); +extern struct iscsit_cmd *iscsit_find_cmd_from_itt(struct iscsi_conn *, itt_t); extern void iscsit_thread_check_cpumask(struct iscsi_conn *conn, struct task_struct *p, diff --git a/include/target/iscsi/iscsi_transport.h b/include/target/iscsi/iscsi_transport.h index b8feba7ffebc..645de3542022 100644 --- a/include/target/iscsi/iscsi_transport.h +++ b/include/target/iscsi/iscsi_transport.h @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -#include "iscsi_target_core.h" /* struct iscsi_cmd */ +#include "iscsi_target_core.h" /* struct iscsit_cmd */ struct sockaddr_storage; @@ -18,23 +18,23 @@ struct iscsit_transport { void (*iscsit_free_conn)(struct iscsi_conn *); int (*iscsit_get_login_rx)(struct iscsi_conn *, struct iscsi_login *); int (*iscsit_put_login_tx)(struct iscsi_conn *, struct iscsi_login *, u32); - int (*iscsit_immediate_queue)(struct iscsi_conn *, struct iscsi_cmd *, int); - int (*iscsit_response_queue)(struct iscsi_conn *, struct iscsi_cmd *, int); - int (*iscsit_get_dataout)(struct iscsi_conn *, struct iscsi_cmd *, bool); - int (*iscsit_queue_data_in)(struct iscsi_conn *, struct iscsi_cmd *); - int (*iscsit_queue_status)(struct iscsi_conn *, struct iscsi_cmd *); - void (*iscsit_aborted_task)(struct iscsi_conn *, struct iscsi_cmd *); - int (*iscsit_xmit_pdu)(struct iscsi_conn *, struct iscsi_cmd *, + int (*iscsit_immediate_queue)(struct iscsi_conn *, struct iscsit_cmd *, int); + int (*iscsit_response_queue)(struct iscsi_conn *, struct iscsit_cmd *, int); + int (*iscsit_get_dataout)(struct iscsi_conn *, struct iscsit_cmd *, bool); + int (*iscsit_queue_data_in)(struct iscsi_conn *, struct iscsit_cmd *); + int (*iscsit_queue_status)(struct iscsi_conn *, struct iscsit_cmd *); + void (*iscsit_aborted_task)(struct iscsi_conn *, struct iscsit_cmd *); + int (*iscsit_xmit_pdu)(struct iscsi_conn *, struct iscsit_cmd *, struct iscsi_datain_req *, const void *, u32); - void (*iscsit_unmap_cmd)(struct iscsi_conn *, struct iscsi_cmd *); + void (*iscsit_unmap_cmd)(struct iscsi_conn *, struct iscsit_cmd *); void (*iscsit_get_rx_pdu)(struct iscsi_conn *); int (*iscsit_validate_params)(struct iscsi_conn *); - void (*iscsit_get_r2t_ttt)(struct iscsi_conn *, struct iscsi_cmd *, + void (*iscsit_get_r2t_ttt)(struct iscsi_conn *, struct iscsit_cmd *, struct iscsi_r2t *); enum target_prot_op (*iscsit_get_sup_prot_ops)(struct iscsi_conn *); }; -static inline void *iscsit_priv_cmd(struct iscsi_cmd *cmd) +static inline void *iscsit_priv_cmd(struct iscsit_cmd *cmd) { return (void *)(cmd + 1); } @@ -51,61 +51,61 @@ extern void iscsit_put_transport(struct iscsit_transport *); /* * From iscsi_target.c */ -extern int iscsit_setup_scsi_cmd(struct iscsi_conn *, struct iscsi_cmd *, +extern int iscsit_setup_scsi_cmd(struct iscsi_conn *, struct iscsit_cmd *, unsigned char *); -extern void iscsit_set_unsolicited_dataout(struct iscsi_cmd *); -extern int iscsit_process_scsi_cmd(struct iscsi_conn *, struct iscsi_cmd *, +extern void iscsit_set_unsolicited_dataout(struct iscsit_cmd *); +extern int iscsit_process_scsi_cmd(struct iscsi_conn *, struct iscsit_cmd *, struct iscsi_scsi_req *); extern int __iscsit_check_dataout_hdr(struct iscsi_conn *, void *, - struct iscsi_cmd *, u32, bool *); + struct iscsit_cmd *, u32, bool *); extern int iscsit_check_dataout_hdr(struct iscsi_conn *conn, void *buf, - struct iscsi_cmd **out_cmd); -extern int iscsit_check_dataout_payload(struct iscsi_cmd *, struct iscsi_data *, + struct iscsit_cmd **out_cmd); +extern int iscsit_check_dataout_payload(struct iscsit_cmd *, struct iscsi_data *, bool); -extern int iscsit_setup_nop_out(struct iscsi_conn *, struct iscsi_cmd *, +extern int iscsit_setup_nop_out(struct iscsi_conn *, struct iscsit_cmd *, struct iscsi_nopout *); -extern int iscsit_process_nop_out(struct iscsi_conn *, struct iscsi_cmd *, +extern int iscsit_process_nop_out(struct iscsi_conn *, struct iscsit_cmd *, struct iscsi_nopout *); -extern int iscsit_handle_logout_cmd(struct iscsi_conn *, struct iscsi_cmd *, +extern int iscsit_handle_logout_cmd(struct iscsi_conn *, struct iscsit_cmd *, unsigned char *); -extern int iscsit_handle_task_mgt_cmd(struct iscsi_conn *, struct iscsi_cmd *, +extern int iscsit_handle_task_mgt_cmd(struct iscsi_conn *, struct iscsit_cmd *, unsigned char *); -extern int iscsit_setup_text_cmd(struct iscsi_conn *, struct iscsi_cmd *, +extern int iscsit_setup_text_cmd(struct iscsi_conn *, struct iscsit_cmd *, struct iscsi_text *); -extern int iscsit_process_text_cmd(struct iscsi_conn *, struct iscsi_cmd *, +extern int iscsit_process_text_cmd(struct iscsi_conn *, struct iscsit_cmd *, struct iscsi_text *); -extern void iscsit_build_rsp_pdu(struct iscsi_cmd *, struct iscsi_conn *, +extern void iscsit_build_rsp_pdu(struct iscsit_cmd *, struct iscsi_conn *, bool, struct iscsi_scsi_rsp *); -extern void iscsit_build_nopin_rsp(struct iscsi_cmd *, struct iscsi_conn *, +extern void iscsit_build_nopin_rsp(struct iscsit_cmd *, struct iscsi_conn *, struct iscsi_nopin *, bool); -extern void iscsit_build_task_mgt_rsp(struct iscsi_cmd *, struct iscsi_conn *, +extern void iscsit_build_task_mgt_rsp(struct iscsit_cmd *, struct iscsi_conn *, struct iscsi_tm_rsp *); -extern int iscsit_build_text_rsp(struct iscsi_cmd *, struct iscsi_conn *, +extern int iscsit_build_text_rsp(struct iscsit_cmd *, struct iscsi_conn *, struct iscsi_text_rsp *, enum iscsit_transport_type); -extern void iscsit_build_reject(struct iscsi_cmd *, struct iscsi_conn *, +extern void iscsit_build_reject(struct iscsit_cmd *, struct iscsi_conn *, struct iscsi_reject *); -extern int iscsit_build_logout_rsp(struct iscsi_cmd *, struct iscsi_conn *, +extern int iscsit_build_logout_rsp(struct iscsit_cmd *, struct iscsi_conn *, struct iscsi_logout_rsp *); -extern int iscsit_logout_post_handler(struct iscsi_cmd *, struct iscsi_conn *); -extern int iscsit_queue_rsp(struct iscsi_conn *, struct iscsi_cmd *); -extern void iscsit_aborted_task(struct iscsi_conn *, struct iscsi_cmd *); +extern int iscsit_logout_post_handler(struct iscsit_cmd *, struct iscsi_conn *); +extern int iscsit_queue_rsp(struct iscsi_conn *, struct iscsit_cmd *); +extern void iscsit_aborted_task(struct iscsi_conn *, struct iscsit_cmd *); extern int iscsit_add_reject(struct iscsi_conn *, u8, unsigned char *); -extern int iscsit_reject_cmd(struct iscsi_cmd *, u8, unsigned char *); +extern int iscsit_reject_cmd(struct iscsit_cmd *, u8, unsigned char *); extern int iscsit_handle_snack(struct iscsi_conn *, unsigned char *); -extern void iscsit_build_datain_pdu(struct iscsi_cmd *, struct iscsi_conn *, +extern void iscsit_build_datain_pdu(struct iscsit_cmd *, struct iscsi_conn *, struct iscsi_datain *, struct iscsi_data_rsp *, bool); -extern int iscsit_build_r2ts_for_cmd(struct iscsi_conn *, struct iscsi_cmd *, +extern int iscsit_build_r2ts_for_cmd(struct iscsi_conn *, struct iscsit_cmd *, bool); -extern int iscsit_immediate_queue(struct iscsi_conn *, struct iscsi_cmd *, int); -extern int iscsit_response_queue(struct iscsi_conn *, struct iscsi_cmd *, int); +extern int iscsit_immediate_queue(struct iscsi_conn *, struct iscsit_cmd *, int); +extern int iscsit_response_queue(struct iscsi_conn *, struct iscsit_cmd *, int); /* * From iscsi_target_device.c */ -extern void iscsit_increment_maxcmdsn(struct iscsi_cmd *, struct iscsi_session *); +extern void iscsit_increment_maxcmdsn(struct iscsit_cmd *, struct iscsi_session *); /* * From iscsi_target_erl0.c */ @@ -113,24 +113,24 @@ extern void iscsit_cause_connection_reinstatement(struct iscsi_conn *, int); /* * From iscsi_target_erl1.c */ -extern void iscsit_stop_dataout_timer(struct iscsi_cmd *); +extern void iscsit_stop_dataout_timer(struct iscsit_cmd *); /* * From iscsi_target_tmr.c */ -extern int iscsit_tmr_post_handler(struct iscsi_cmd *, struct iscsi_conn *); +extern int iscsit_tmr_post_handler(struct iscsit_cmd *, struct iscsi_conn *); /* * From iscsi_target_util.c */ -extern struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *, int); -extern int iscsit_sequence_cmd(struct iscsi_conn *, struct iscsi_cmd *, +extern struct iscsit_cmd *iscsit_allocate_cmd(struct iscsi_conn *, int); +extern int iscsit_sequence_cmd(struct iscsi_conn *, struct iscsit_cmd *, unsigned char *, __be32); -extern void iscsit_release_cmd(struct iscsi_cmd *); -extern void iscsit_free_cmd(struct iscsi_cmd *, bool); -extern void iscsit_add_cmd_to_immediate_queue(struct iscsi_cmd *, +extern void iscsit_release_cmd(struct iscsit_cmd *); +extern void iscsit_free_cmd(struct iscsit_cmd *, bool); +extern void iscsit_add_cmd_to_immediate_queue(struct iscsit_cmd *, struct iscsi_conn *, u8); -extern struct iscsi_cmd * +extern struct iscsit_cmd * iscsit_find_cmd_from_itt_or_dump(struct iscsi_conn *conn, itt_t init_task_tag, u32 length); From be36d683fc29e74bbd29347717be72beb6a74219 Mon Sep 17 00:00:00 2001 From: Max Gurtovoy Date: Thu, 28 Apr 2022 12:29:38 +0300 Subject: [PATCH 154/177] scsi: target: iscsi: Rename iscsi_conn to iscsit_conn The structure iscsi_conn naming is used by the iSCSI initiator driver. Rename the target conn to iscsit_conn to have more readable code. Link: https://lore.kernel.org/r/20220428092939.36768-2-mgurtovoy@nvidia.com Reviewed-by: Mike Christie Signed-off-by: Max Gurtovoy Signed-off-by: Martin K. Petersen --- drivers/infiniband/ulp/isert/ib_isert.c | 64 +++---- drivers/infiniband/ulp/isert/ib_isert.h | 2 +- drivers/target/iscsi/cxgbit/cxgbit.h | 20 +-- drivers/target/iscsi/cxgbit/cxgbit_cm.c | 8 +- drivers/target/iscsi/cxgbit/cxgbit_ddp.c | 4 +- drivers/target/iscsi/cxgbit/cxgbit_main.c | 2 +- drivers/target/iscsi/cxgbit/cxgbit_target.c | 44 ++--- drivers/target/iscsi/iscsi_target.c | 162 +++++++++--------- drivers/target/iscsi/iscsi_target.h | 16 +- drivers/target/iscsi/iscsi_target_auth.c | 10 +- drivers/target/iscsi/iscsi_target_auth.h | 4 +- drivers/target/iscsi/iscsi_target_configfs.c | 8 +- .../target/iscsi/iscsi_target_datain_values.c | 10 +- drivers/target/iscsi/iscsi_target_erl0.c | 28 +-- drivers/target/iscsi/iscsi_target_erl0.h | 8 +- drivers/target/iscsi/iscsi_target_erl1.c | 30 ++-- drivers/target/iscsi/iscsi_target_erl1.h | 14 +- drivers/target/iscsi/iscsi_target_erl2.c | 10 +- drivers/target/iscsi/iscsi_target_erl2.h | 8 +- drivers/target/iscsi/iscsi_target_login.c | 58 +++---- drivers/target/iscsi/iscsi_target_login.h | 22 +-- drivers/target/iscsi/iscsi_target_nego.c | 52 +++--- drivers/target/iscsi/iscsi_target_nego.h | 12 +- .../target/iscsi/iscsi_target_nodeattrib.c | 2 +- .../target/iscsi/iscsi_target_parameters.c | 8 +- .../target/iscsi/iscsi_target_parameters.h | 8 +- .../target/iscsi/iscsi_target_seq_pdu_list.c | 8 +- drivers/target/iscsi/iscsi_target_tmr.c | 30 ++-- drivers/target/iscsi/iscsi_target_tmr.h | 10 +- drivers/target/iscsi/iscsi_target_util.c | 78 ++++----- drivers/target/iscsi/iscsi_target_util.h | 62 +++---- include/target/iscsi/iscsi_target_core.h | 10 +- include/target/iscsi/iscsi_transport.h | 100 +++++------ 33 files changed, 456 insertions(+), 456 deletions(-) diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c index 4cb746ab53be..48064bd8aa2c 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.c +++ b/drivers/infiniband/ulp/isert/ib_isert.c @@ -46,7 +46,7 @@ static struct workqueue_struct *isert_comp_wq; static struct workqueue_struct *isert_release_wq; static int -isert_put_response(struct iscsi_conn *conn, struct iscsit_cmd *cmd); +isert_put_response(struct iscsit_conn *conn, struct iscsit_cmd *cmd); static int isert_login_post_recv(struct isert_conn *isert_conn); static int @@ -909,7 +909,7 @@ isert_login_post_recv(struct isert_conn *isert_conn) } static int -isert_put_login_tx(struct iscsi_conn *conn, struct iscsi_login *login, +isert_put_login_tx(struct iscsit_conn *conn, struct iscsi_login *login, u32 length) { struct isert_conn *isert_conn = conn->context; @@ -976,7 +976,7 @@ isert_rx_login_req(struct isert_conn *isert_conn) { struct iser_rx_desc *rx_desc = isert_conn->login_desc; int rx_buflen = isert_conn->login_req_len; - struct iscsi_conn *conn = isert_conn->conn; + struct iscsit_conn *conn = isert_conn->conn; struct iscsi_login *login = conn->conn_login; int size; @@ -1021,7 +1021,7 @@ isert_rx_login_req(struct isert_conn *isert_conn) } static struct iscsit_cmd -*isert_allocate_cmd(struct iscsi_conn *conn, struct iser_rx_desc *rx_desc) +*isert_allocate_cmd(struct iscsit_conn *conn, struct iser_rx_desc *rx_desc) { struct isert_conn *isert_conn = conn->context; struct isert_cmd *isert_cmd; @@ -1045,7 +1045,7 @@ isert_handle_scsi_cmd(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd, struct iscsit_cmd *cmd, struct iser_rx_desc *rx_desc, unsigned char *buf) { - struct iscsi_conn *conn = isert_conn->conn; + struct iscsit_conn *conn = isert_conn->conn; struct iscsi_scsi_req *hdr = (struct iscsi_scsi_req *)buf; int imm_data, imm_data_len, unsol_data, sg_nents, rc; bool dump_payload = false; @@ -1114,7 +1114,7 @@ isert_handle_iscsi_dataout(struct isert_conn *isert_conn, struct iser_rx_desc *rx_desc, unsigned char *buf) { struct scatterlist *sg_start; - struct iscsi_conn *conn = isert_conn->conn; + struct iscsit_conn *conn = isert_conn->conn; struct iscsit_cmd *cmd = NULL; struct iscsi_data *hdr = (struct iscsi_data *)buf; u32 unsol_data_len = ntoh24(hdr->dlength); @@ -1174,7 +1174,7 @@ isert_handle_nop_out(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd, struct iscsit_cmd *cmd, struct iser_rx_desc *rx_desc, unsigned char *buf) { - struct iscsi_conn *conn = isert_conn->conn; + struct iscsit_conn *conn = isert_conn->conn; struct iscsi_nopout *hdr = (struct iscsi_nopout *)buf; int rc; @@ -1193,7 +1193,7 @@ isert_handle_text_cmd(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd struct iscsit_cmd *cmd, struct iser_rx_desc *rx_desc, struct iscsi_text *hdr) { - struct iscsi_conn *conn = isert_conn->conn; + struct iscsit_conn *conn = isert_conn->conn; u32 payload_length = ntoh24(hdr->dlength); int rc; unsigned char *text_in = NULL; @@ -1220,7 +1220,7 @@ isert_rx_opcode(struct isert_conn *isert_conn, struct iser_rx_desc *rx_desc, uint32_t write_stag, uint64_t write_va) { struct iscsi_hdr *hdr = isert_get_iscsi_hdr(rx_desc); - struct iscsi_conn *conn = isert_conn->conn; + struct iscsit_conn *conn = isert_conn->conn; struct iscsit_cmd *cmd; struct isert_cmd *isert_cmd; int ret = -EINVAL; @@ -1428,7 +1428,7 @@ isert_put_cmd(struct isert_cmd *isert_cmd, bool comp_err) { struct iscsit_cmd *cmd = isert_cmd->iscsit_cmd; struct isert_conn *isert_conn = isert_cmd->conn; - struct iscsi_conn *conn = isert_conn->conn; + struct iscsit_conn *conn = isert_conn->conn; struct iscsi_text_rsp *hdr; isert_dbg("Cmd %p\n", isert_cmd); @@ -1755,7 +1755,7 @@ isert_post_response(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd) } static int -isert_put_response(struct iscsi_conn *conn, struct iscsit_cmd *cmd) +isert_put_response(struct iscsit_conn *conn, struct iscsit_cmd *cmd) { struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); struct isert_conn *isert_conn = conn->context; @@ -1806,7 +1806,7 @@ isert_put_response(struct iscsi_conn *conn, struct iscsit_cmd *cmd) } static void -isert_aborted_task(struct iscsi_conn *conn, struct iscsit_cmd *cmd) +isert_aborted_task(struct iscsit_conn *conn, struct iscsit_cmd *cmd) { struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); struct isert_conn *isert_conn = conn->context; @@ -1822,7 +1822,7 @@ isert_aborted_task(struct iscsi_conn *conn, struct iscsit_cmd *cmd) } static enum target_prot_op -isert_get_sup_prot_ops(struct iscsi_conn *conn) +isert_get_sup_prot_ops(struct iscsit_conn *conn) { struct isert_conn *isert_conn = conn->context; struct isert_device *device = isert_conn->device; @@ -1842,7 +1842,7 @@ isert_get_sup_prot_ops(struct iscsi_conn *conn) } static int -isert_put_nopin(struct iscsit_cmd *cmd, struct iscsi_conn *conn, +isert_put_nopin(struct iscsit_cmd *cmd, struct iscsit_conn *conn, bool nopout_response) { struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); @@ -1862,7 +1862,7 @@ isert_put_nopin(struct iscsit_cmd *cmd, struct iscsi_conn *conn, } static int -isert_put_logout_rsp(struct iscsit_cmd *cmd, struct iscsi_conn *conn) +isert_put_logout_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn) { struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); struct isert_conn *isert_conn = conn->context; @@ -1880,7 +1880,7 @@ isert_put_logout_rsp(struct iscsit_cmd *cmd, struct iscsi_conn *conn) } static int -isert_put_tm_rsp(struct iscsit_cmd *cmd, struct iscsi_conn *conn) +isert_put_tm_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn) { struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); struct isert_conn *isert_conn = conn->context; @@ -1898,7 +1898,7 @@ isert_put_tm_rsp(struct iscsit_cmd *cmd, struct iscsi_conn *conn) } static int -isert_put_reject(struct iscsit_cmd *cmd, struct iscsi_conn *conn) +isert_put_reject(struct iscsit_cmd *cmd, struct iscsit_conn *conn) { struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); struct isert_conn *isert_conn = conn->context; @@ -1933,7 +1933,7 @@ isert_put_reject(struct iscsit_cmd *cmd, struct iscsi_conn *conn) } static int -isert_put_text_rsp(struct iscsit_cmd *cmd, struct iscsi_conn *conn) +isert_put_text_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn) { struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); struct isert_conn *isert_conn = conn->context; @@ -2088,7 +2088,7 @@ rdma_ctx_post: } static int -isert_put_datain(struct iscsi_conn *conn, struct iscsit_cmd *cmd) +isert_put_datain(struct iscsit_conn *conn, struct iscsit_cmd *cmd) { struct se_cmd *se_cmd = &cmd->se_cmd; struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); @@ -2129,7 +2129,7 @@ isert_put_datain(struct iscsi_conn *conn, struct iscsit_cmd *cmd) } static int -isert_get_dataout(struct iscsi_conn *conn, struct iscsit_cmd *cmd, bool recovery) +isert_get_dataout(struct iscsit_conn *conn, struct iscsit_cmd *cmd, bool recovery) { struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); int ret; @@ -2147,7 +2147,7 @@ isert_get_dataout(struct iscsi_conn *conn, struct iscsit_cmd *cmd, bool recovery } static int -isert_immediate_queue(struct iscsi_conn *conn, struct iscsit_cmd *cmd, int state) +isert_immediate_queue(struct iscsit_conn *conn, struct iscsit_cmd *cmd, int state) { struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); int ret = 0; @@ -2172,7 +2172,7 @@ isert_immediate_queue(struct iscsi_conn *conn, struct iscsit_cmd *cmd, int state } static int -isert_response_queue(struct iscsi_conn *conn, struct iscsit_cmd *cmd, int state) +isert_response_queue(struct iscsit_conn *conn, struct iscsit_cmd *cmd, int state) { struct isert_conn *isert_conn = conn->context; int ret; @@ -2332,7 +2332,7 @@ isert_rdma_accept(struct isert_conn *isert_conn) } static int -isert_get_login_rx(struct iscsi_conn *conn, struct iscsi_login *login) +isert_get_login_rx(struct iscsit_conn *conn, struct iscsi_login *login) { struct isert_conn *isert_conn = conn->context; int ret; @@ -2368,7 +2368,7 @@ isert_get_login_rx(struct iscsi_conn *conn, struct iscsi_login *login) } static void -isert_set_conn_info(struct iscsi_np *np, struct iscsi_conn *conn, +isert_set_conn_info(struct iscsi_np *np, struct iscsit_conn *conn, struct isert_conn *isert_conn) { struct rdma_cm_id *cm_id = isert_conn->cm_id; @@ -2381,7 +2381,7 @@ isert_set_conn_info(struct iscsi_np *np, struct iscsi_conn *conn, } static int -isert_accept_np(struct iscsi_np *np, struct iscsi_conn *conn) +isert_accept_np(struct iscsi_np *np, struct iscsit_conn *conn) { struct isert_np *isert_np = np->np_context; struct isert_conn *isert_conn; @@ -2489,7 +2489,7 @@ static void isert_release_work(struct work_struct *work) static void isert_wait4logout(struct isert_conn *isert_conn) { - struct iscsi_conn *conn = isert_conn->conn; + struct iscsit_conn *conn = isert_conn->conn; isert_info("conn %p\n", isert_conn); @@ -2501,9 +2501,9 @@ isert_wait4logout(struct isert_conn *isert_conn) } static void -isert_wait4cmds(struct iscsi_conn *conn) +isert_wait4cmds(struct iscsit_conn *conn) { - isert_info("iscsi_conn %p\n", conn); + isert_info("iscsit_conn %p\n", conn); if (conn->sess) { target_stop_session(conn->sess->se_sess); @@ -2521,7 +2521,7 @@ isert_wait4cmds(struct iscsi_conn *conn) * before blocking on the target_wait_for_session_cmds */ static void -isert_put_unsol_pending_cmds(struct iscsi_conn *conn) +isert_put_unsol_pending_cmds(struct iscsit_conn *conn) { struct iscsit_cmd *cmd, *tmp; static LIST_HEAD(drop_cmd_list); @@ -2546,7 +2546,7 @@ isert_put_unsol_pending_cmds(struct iscsi_conn *conn) } } -static void isert_wait_conn(struct iscsi_conn *conn) +static void isert_wait_conn(struct iscsit_conn *conn) { struct isert_conn *isert_conn = conn->context; @@ -2564,7 +2564,7 @@ static void isert_wait_conn(struct iscsi_conn *conn) queue_work(isert_release_wq, &isert_conn->release_work); } -static void isert_free_conn(struct iscsi_conn *conn) +static void isert_free_conn(struct iscsit_conn *conn) { struct isert_conn *isert_conn = conn->context; @@ -2572,7 +2572,7 @@ static void isert_free_conn(struct iscsi_conn *conn) isert_put_conn(isert_conn); } -static void isert_get_rx_pdu(struct iscsi_conn *conn) +static void isert_get_rx_pdu(struct iscsit_conn *conn) { struct completion comp; diff --git a/drivers/infiniband/ulp/isert/ib_isert.h b/drivers/infiniband/ulp/isert/ib_isert.h index a462834cb332..0b2dfd6e7e27 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.h +++ b/drivers/infiniband/ulp/isert/ib_isert.h @@ -173,7 +173,7 @@ struct isert_conn { u64 login_rsp_dma; struct iser_rx_desc *rx_descs; struct ib_recv_wr rx_wr[ISERT_QP_MAX_RECV_DTOS]; - struct iscsi_conn *conn; + struct iscsit_conn *conn; struct list_head node; struct completion login_comp; struct completion login_req_comp; diff --git a/drivers/target/iscsi/cxgbit/cxgbit.h b/drivers/target/iscsi/cxgbit/cxgbit.h index b23edcb41489..aff727629663 100644 --- a/drivers/target/iscsi/cxgbit/cxgbit.h +++ b/drivers/target/iscsi/cxgbit/cxgbit.h @@ -189,7 +189,7 @@ struct cxgbit_np { struct cxgbit_sock { struct cxgbit_sock_common com; struct cxgbit_np *cnp; - struct iscsi_conn *conn; + struct iscsit_conn *conn; struct l2t_entry *l2t; struct dst_entry *dst; struct list_head list; @@ -316,32 +316,32 @@ typedef void (*cxgbit_cplhandler_func)(struct cxgbit_device *, int cxgbit_setup_np(struct iscsi_np *, struct sockaddr_storage *); int cxgbit_setup_conn_digest(struct cxgbit_sock *); -int cxgbit_accept_np(struct iscsi_np *, struct iscsi_conn *); +int cxgbit_accept_np(struct iscsi_np *, struct iscsit_conn *); void cxgbit_free_np(struct iscsi_np *); void cxgbit_abort_conn(struct cxgbit_sock *csk); -void cxgbit_free_conn(struct iscsi_conn *); +void cxgbit_free_conn(struct iscsit_conn *); extern cxgbit_cplhandler_func cxgbit_cplhandlers[NUM_CPL_CMDS]; -int cxgbit_get_login_rx(struct iscsi_conn *, struct iscsi_login *); +int cxgbit_get_login_rx(struct iscsit_conn *, struct iscsi_login *); int cxgbit_rx_data_ack(struct cxgbit_sock *); int cxgbit_l2t_send(struct cxgbit_device *, struct sk_buff *, struct l2t_entry *); void cxgbit_push_tx_frames(struct cxgbit_sock *); -int cxgbit_put_login_tx(struct iscsi_conn *, struct iscsi_login *, u32); -int cxgbit_xmit_pdu(struct iscsi_conn *, struct iscsit_cmd *, +int cxgbit_put_login_tx(struct iscsit_conn *, struct iscsi_login *, u32); +int cxgbit_xmit_pdu(struct iscsit_conn *, struct iscsit_cmd *, struct iscsi_datain_req *, const void *, u32); -void cxgbit_get_r2t_ttt(struct iscsi_conn *, struct iscsit_cmd *, +void cxgbit_get_r2t_ttt(struct iscsit_conn *, struct iscsit_cmd *, struct iscsi_r2t *); u32 cxgbit_send_tx_flowc_wr(struct cxgbit_sock *); int cxgbit_ofld_send(struct cxgbit_device *, struct sk_buff *); -void cxgbit_get_rx_pdu(struct iscsi_conn *); -int cxgbit_validate_params(struct iscsi_conn *); +void cxgbit_get_rx_pdu(struct iscsit_conn *); +int cxgbit_validate_params(struct iscsit_conn *); struct cxgbit_device *cxgbit_find_device(struct net_device *, u8 *); /* DDP */ int cxgbit_ddp_init(struct cxgbit_device *); int cxgbit_setup_conn_pgidx(struct cxgbit_sock *, u32); int cxgbit_reserve_ttt(struct cxgbit_sock *, struct iscsit_cmd *); -void cxgbit_unmap_cmd(struct iscsi_conn *, struct iscsit_cmd *); +void cxgbit_unmap_cmd(struct iscsit_conn *, struct iscsit_cmd *); static inline struct cxgbi_ppm *cdev2ppm(struct cxgbit_device *cdev) diff --git a/drivers/target/iscsi/cxgbit/cxgbit_cm.c b/drivers/target/iscsi/cxgbit/cxgbit_cm.c index da31a308a064..3336d2b78bf7 100644 --- a/drivers/target/iscsi/cxgbit/cxgbit_cm.c +++ b/drivers/target/iscsi/cxgbit/cxgbit_cm.c @@ -465,7 +465,7 @@ int cxgbit_setup_np(struct iscsi_np *np, struct sockaddr_storage *ksockaddr) } static void -cxgbit_set_conn_info(struct iscsi_np *np, struct iscsi_conn *conn, +cxgbit_set_conn_info(struct iscsi_np *np, struct iscsit_conn *conn, struct cxgbit_sock *csk) { conn->login_family = np->np_sockaddr.ss_family; @@ -473,7 +473,7 @@ cxgbit_set_conn_info(struct iscsi_np *np, struct iscsi_conn *conn, conn->local_sockaddr = csk->com.local_addr; } -int cxgbit_accept_np(struct iscsi_np *np, struct iscsi_conn *conn) +int cxgbit_accept_np(struct iscsi_np *np, struct iscsit_conn *conn) { struct cxgbit_np *cnp = np->np_context; struct cxgbit_sock *csk; @@ -717,7 +717,7 @@ void cxgbit_abort_conn(struct cxgbit_sock *csk) static void __cxgbit_free_conn(struct cxgbit_sock *csk) { - struct iscsi_conn *conn = csk->conn; + struct iscsit_conn *conn = csk->conn; bool release = false; pr_debug("%s: state %d\n", @@ -751,7 +751,7 @@ static void __cxgbit_free_conn(struct cxgbit_sock *csk) cxgbit_put_csk(csk); } -void cxgbit_free_conn(struct iscsi_conn *conn) +void cxgbit_free_conn(struct iscsit_conn *conn) { __cxgbit_free_conn(conn->context); } diff --git a/drivers/target/iscsi/cxgbit/cxgbit_ddp.c b/drivers/target/iscsi/cxgbit/cxgbit_ddp.c index 5feebb6c6de4..17fd0d8cc490 100644 --- a/drivers/target/iscsi/cxgbit/cxgbit_ddp.c +++ b/drivers/target/iscsi/cxgbit/cxgbit_ddp.c @@ -227,7 +227,7 @@ rel_ppods: } void -cxgbit_get_r2t_ttt(struct iscsi_conn *conn, struct iscsit_cmd *cmd, +cxgbit_get_r2t_ttt(struct iscsit_conn *conn, struct iscsit_cmd *cmd, struct iscsi_r2t *r2t) { struct cxgbit_sock *csk = conn->context; @@ -260,7 +260,7 @@ out: r2t->targ_xfer_tag = ttinfo->tag; } -void cxgbit_unmap_cmd(struct iscsi_conn *conn, struct iscsit_cmd *cmd) +void cxgbit_unmap_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd) { struct cxgbit_cmd *ccmd = iscsit_priv_cmd(cmd); diff --git a/drivers/target/iscsi/cxgbit/cxgbit_main.c b/drivers/target/iscsi/cxgbit/cxgbit_main.c index c6678dc8dd41..2c1950df3b3e 100644 --- a/drivers/target/iscsi/cxgbit/cxgbit_main.c +++ b/drivers/target/iscsi/cxgbit/cxgbit_main.c @@ -657,7 +657,7 @@ cxgbit_dcbevent_notify(struct notifier_block *nb, unsigned long action, } #endif -static enum target_prot_op cxgbit_get_sup_prot_ops(struct iscsi_conn *conn) +static enum target_prot_op cxgbit_get_sup_prot_ops(struct iscsit_conn *conn) { return TARGET_PROT_NORMAL; } diff --git a/drivers/target/iscsi/cxgbit/cxgbit_target.c b/drivers/target/iscsi/cxgbit/cxgbit_target.c index 99901a8a3f64..acfc39683c87 100644 --- a/drivers/target/iscsi/cxgbit/cxgbit_target.c +++ b/drivers/target/iscsi/cxgbit/cxgbit_target.c @@ -393,7 +393,7 @@ static int cxgbit_tx_datain_iso(struct cxgbit_sock *csk, struct iscsit_cmd *cmd, struct iscsi_datain_req *dr) { - struct iscsi_conn *conn = csk->conn; + struct iscsit_conn *conn = csk->conn; struct sk_buff *skb; struct iscsi_datain datain; struct cxgbit_iso_info iso_info; @@ -510,7 +510,7 @@ cxgbit_tx_datain(struct cxgbit_sock *csk, struct iscsit_cmd *cmd, } static int -cxgbit_xmit_datain_pdu(struct iscsi_conn *conn, struct iscsit_cmd *cmd, +cxgbit_xmit_datain_pdu(struct iscsit_conn *conn, struct iscsit_cmd *cmd, struct iscsi_datain_req *dr, const struct iscsi_datain *datain) { @@ -530,7 +530,7 @@ cxgbit_xmit_datain_pdu(struct iscsi_conn *conn, struct iscsit_cmd *cmd, } static int -cxgbit_xmit_nondatain_pdu(struct iscsi_conn *conn, struct iscsit_cmd *cmd, +cxgbit_xmit_nondatain_pdu(struct iscsit_conn *conn, struct iscsit_cmd *cmd, const void *data_buf, u32 data_buf_len) { struct cxgbit_sock *csk = conn->context; @@ -560,7 +560,7 @@ cxgbit_xmit_nondatain_pdu(struct iscsi_conn *conn, struct iscsit_cmd *cmd, } int -cxgbit_xmit_pdu(struct iscsi_conn *conn, struct iscsit_cmd *cmd, +cxgbit_xmit_pdu(struct iscsit_conn *conn, struct iscsit_cmd *cmd, struct iscsi_datain_req *dr, const void *buf, u32 buf_len) { if (dr) @@ -569,7 +569,7 @@ cxgbit_xmit_pdu(struct iscsi_conn *conn, struct iscsit_cmd *cmd, return cxgbit_xmit_nondatain_pdu(conn, cmd, buf, buf_len); } -int cxgbit_validate_params(struct iscsi_conn *conn) +int cxgbit_validate_params(struct iscsit_conn *conn) { struct cxgbit_sock *csk = conn->context; struct cxgbit_device *cdev = csk->com.cdev; @@ -595,7 +595,7 @@ int cxgbit_validate_params(struct iscsi_conn *conn) static int cxgbit_set_digest(struct cxgbit_sock *csk) { - struct iscsi_conn *conn = csk->conn; + struct iscsit_conn *conn = csk->conn; struct iscsi_param *param; param = iscsi_find_param_from_key(HEADERDIGEST, conn->param_list); @@ -627,7 +627,7 @@ static int cxgbit_set_digest(struct cxgbit_sock *csk) static int cxgbit_set_iso_npdu(struct cxgbit_sock *csk) { - struct iscsi_conn *conn = csk->conn; + struct iscsit_conn *conn = csk->conn; struct iscsi_conn_ops *conn_ops = conn->conn_ops; struct iscsi_param *param; u32 mrdsl, mbl; @@ -678,7 +678,7 @@ static int cxgbit_set_iso_npdu(struct cxgbit_sock *csk) */ static int cxgbit_seq_pdu_inorder(struct cxgbit_sock *csk) { - struct iscsi_conn *conn = csk->conn; + struct iscsit_conn *conn = csk->conn; struct iscsi_param *param; if (conn->login->leading_connection) { @@ -712,7 +712,7 @@ static int cxgbit_seq_pdu_inorder(struct cxgbit_sock *csk) return 0; } -static int cxgbit_set_params(struct iscsi_conn *conn) +static int cxgbit_set_params(struct iscsit_conn *conn) { struct cxgbit_sock *csk = conn->context; struct cxgbit_device *cdev = csk->com.cdev; @@ -771,7 +771,7 @@ enable_ddp: } int -cxgbit_put_login_tx(struct iscsi_conn *conn, struct iscsi_login *login, +cxgbit_put_login_tx(struct iscsit_conn *conn, struct iscsi_login *login, u32 length) { struct cxgbit_sock *csk = conn->context; @@ -834,7 +834,7 @@ cxgbit_skb_copy_to_sg(struct sk_buff *skb, struct scatterlist *sg, static struct iscsit_cmd *cxgbit_allocate_cmd(struct cxgbit_sock *csk) { - struct iscsi_conn *conn = csk->conn; + struct iscsit_conn *conn = csk->conn; struct cxgbi_ppm *ppm = cdev2ppm(csk->com.cdev); struct cxgbit_cmd *ccmd; struct iscsit_cmd *cmd; @@ -856,7 +856,7 @@ static int cxgbit_handle_immediate_data(struct iscsit_cmd *cmd, struct iscsi_scsi_req *hdr, u32 length) { - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct cxgbit_sock *csk = conn->context; struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb); @@ -913,7 +913,7 @@ static int cxgbit_get_immediate_data(struct iscsit_cmd *cmd, struct iscsi_scsi_req *hdr, bool dump_payload) { - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; int cmdsn_ret = 0, immed_ret = IMMEDIATE_DATA_NORMAL_OPERATION; /* * Special case for Unsupported SAM WRITE Opcodes and ImmediateData=Yes. @@ -966,7 +966,7 @@ after_immediate_data: static int cxgbit_handle_scsi_cmd(struct cxgbit_sock *csk, struct iscsit_cmd *cmd) { - struct iscsi_conn *conn = csk->conn; + struct iscsit_conn *conn = csk->conn; struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb); struct iscsi_scsi_req *hdr = (struct iscsi_scsi_req *)pdu_cb->hdr; int rc; @@ -995,7 +995,7 @@ cxgbit_handle_scsi_cmd(struct cxgbit_sock *csk, struct iscsit_cmd *cmd) static int cxgbit_handle_iscsi_dataout(struct cxgbit_sock *csk) { struct scatterlist *sg_start; - struct iscsi_conn *conn = csk->conn; + struct iscsit_conn *conn = csk->conn; struct iscsit_cmd *cmd = NULL; struct cxgbit_cmd *ccmd; struct cxgbi_task_tag_info *ttinfo; @@ -1086,7 +1086,7 @@ check_payload: static int cxgbit_handle_nop_out(struct cxgbit_sock *csk, struct iscsit_cmd *cmd) { - struct iscsi_conn *conn = csk->conn; + struct iscsit_conn *conn = csk->conn; struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb); struct iscsi_nopout *hdr = (struct iscsi_nopout *)pdu_cb->hdr; unsigned char *ping_data = NULL; @@ -1154,7 +1154,7 @@ out: static int cxgbit_handle_text_cmd(struct cxgbit_sock *csk, struct iscsit_cmd *cmd) { - struct iscsi_conn *conn = csk->conn; + struct iscsit_conn *conn = csk->conn; struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb); struct iscsi_text *hdr = (struct iscsi_text *)pdu_cb->hdr; u32 payload_length = pdu_cb->dlen; @@ -1209,7 +1209,7 @@ static int cxgbit_target_rx_opcode(struct cxgbit_sock *csk) { struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb); struct iscsi_hdr *hdr = (struct iscsi_hdr *)pdu_cb->hdr; - struct iscsi_conn *conn = csk->conn; + struct iscsit_conn *conn = csk->conn; struct iscsit_cmd *cmd = NULL; u8 opcode = (hdr->opcode & ISCSI_OPCODE_MASK); int ret = -EINVAL; @@ -1286,7 +1286,7 @@ reject: static int cxgbit_rx_opcode(struct cxgbit_sock *csk) { struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb); - struct iscsi_conn *conn = csk->conn; + struct iscsit_conn *conn = csk->conn; struct iscsi_hdr *hdr = pdu_cb->hdr; u8 opcode; @@ -1321,7 +1321,7 @@ transport_err: static int cxgbit_rx_login_pdu(struct cxgbit_sock *csk) { - struct iscsi_conn *conn = csk->conn; + struct iscsit_conn *conn = csk->conn; struct iscsi_login *login = conn->login; struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb); struct iscsi_login_req *login_req; @@ -1626,7 +1626,7 @@ out: return -1; } -int cxgbit_get_login_rx(struct iscsi_conn *conn, struct iscsi_login *login) +int cxgbit_get_login_rx(struct iscsit_conn *conn, struct iscsi_login *login) { struct cxgbit_sock *csk = conn->context; int ret = -1; @@ -1642,7 +1642,7 @@ int cxgbit_get_login_rx(struct iscsi_conn *conn, struct iscsi_login *login) return ret; } -void cxgbit_get_rx_pdu(struct iscsi_conn *conn) +void cxgbit_get_rx_pdu(struct iscsit_conn *conn) { struct cxgbit_sock *csk = conn->context; diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 4d71eb8fa6ab..2c4f94b76061 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -472,15 +472,15 @@ int iscsit_del_np(struct iscsi_np *np) return 0; } -static void iscsit_get_rx_pdu(struct iscsi_conn *); +static void iscsit_get_rx_pdu(struct iscsit_conn *); -int iscsit_queue_rsp(struct iscsi_conn *conn, struct iscsit_cmd *cmd) +int iscsit_queue_rsp(struct iscsit_conn *conn, struct iscsit_cmd *cmd) { return iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state); } EXPORT_SYMBOL(iscsit_queue_rsp); -void iscsit_aborted_task(struct iscsi_conn *conn, struct iscsit_cmd *cmd) +void iscsit_aborted_task(struct iscsit_conn *conn, struct iscsit_cmd *cmd) { spin_lock_bh(&conn->cmd_lock); if (!list_empty(&cmd->i_conn_node)) @@ -493,10 +493,10 @@ EXPORT_SYMBOL(iscsit_aborted_task); static void iscsit_do_crypto_hash_buf(struct ahash_request *, const void *, u32, u32, const void *, void *); -static void iscsit_tx_thread_wait_for_tcp(struct iscsi_conn *); +static void iscsit_tx_thread_wait_for_tcp(struct iscsit_conn *); static int -iscsit_xmit_nondatain_pdu(struct iscsi_conn *conn, struct iscsit_cmd *cmd, +iscsit_xmit_nondatain_pdu(struct iscsit_conn *conn, struct iscsit_cmd *cmd, const void *data_buf, u32 data_buf_len) { struct iscsi_hdr *hdr = (struct iscsi_hdr *)cmd->pdu; @@ -570,7 +570,7 @@ static void iscsit_unmap_iovec(struct iscsit_cmd *); static u32 iscsit_do_crypto_hash_sg(struct ahash_request *, struct iscsit_cmd *, u32, u32, u32, u8 *); static int -iscsit_xmit_datain_pdu(struct iscsi_conn *conn, struct iscsit_cmd *cmd, +iscsit_xmit_datain_pdu(struct iscsit_conn *conn, struct iscsit_cmd *cmd, const struct iscsi_datain *datain) { struct kvec *iov; @@ -644,7 +644,7 @@ iscsit_xmit_datain_pdu(struct iscsi_conn *conn, struct iscsit_cmd *cmd, return 0; } -static int iscsit_xmit_pdu(struct iscsi_conn *conn, struct iscsit_cmd *cmd, +static int iscsit_xmit_pdu(struct iscsit_conn *conn, struct iscsit_cmd *cmd, struct iscsi_datain_req *dr, const void *buf, u32 buf_len) { @@ -654,7 +654,7 @@ static int iscsit_xmit_pdu(struct iscsi_conn *conn, struct iscsit_cmd *cmd, return iscsit_xmit_nondatain_pdu(conn, cmd, buf, buf_len); } -static enum target_prot_op iscsit_get_sup_prot_ops(struct iscsi_conn *conn) +static enum target_prot_op iscsit_get_sup_prot_ops(struct iscsit_conn *conn) { return TARGET_PROT_NORMAL; } @@ -796,7 +796,7 @@ static void __exit iscsi_target_cleanup_module(void) } int iscsit_add_reject( - struct iscsi_conn *conn, + struct iscsit_conn *conn, u8 reason, unsigned char *buf) { @@ -833,7 +833,7 @@ static int iscsit_add_reject_from_cmd( bool add_to_conn, unsigned char *buf) { - struct iscsi_conn *conn; + struct iscsit_conn *conn; const bool do_put = cmd->se_cmd.se_tfo != NULL; if (!cmd->conn) { @@ -957,7 +957,7 @@ static void iscsit_unmap_iovec(struct iscsit_cmd *cmd) kunmap(sg_page(&sg[i])); } -static void iscsit_ack_from_expstatsn(struct iscsi_conn *conn, u32 exp_statsn) +static void iscsit_ack_from_expstatsn(struct iscsit_conn *conn, u32 exp_statsn) { LIST_HEAD(ack_list); struct iscsit_cmd *cmd, *cmd_p; @@ -1000,7 +1000,7 @@ static int iscsit_allocate_iovecs(struct iscsit_cmd *cmd) return 0; } -int iscsit_setup_scsi_cmd(struct iscsi_conn *conn, struct iscsit_cmd *cmd, +int iscsit_setup_scsi_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, unsigned char *buf) { int data_direction, payload_length; @@ -1225,7 +1225,7 @@ void iscsit_set_unsolicited_dataout(struct iscsit_cmd *cmd) } EXPORT_SYMBOL(iscsit_set_unsolicited_dataout); -int iscsit_process_scsi_cmd(struct iscsi_conn *conn, struct iscsit_cmd *cmd, +int iscsit_process_scsi_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, struct iscsi_scsi_req *hdr) { int cmdsn_ret = 0; @@ -1349,7 +1349,7 @@ iscsit_get_immediate_data(struct iscsit_cmd *cmd, struct iscsi_scsi_req *hdr, } static int -iscsit_handle_scsi_cmd(struct iscsi_conn *conn, struct iscsit_cmd *cmd, +iscsit_handle_scsi_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, unsigned char *buf) { struct iscsi_scsi_req *hdr = (struct iscsi_scsi_req *)buf; @@ -1455,7 +1455,7 @@ static void iscsit_do_crypto_hash_buf(struct ahash_request *hash, } int -__iscsit_check_dataout_hdr(struct iscsi_conn *conn, void *buf, +__iscsit_check_dataout_hdr(struct iscsit_conn *conn, void *buf, struct iscsit_cmd *cmd, u32 payload_length, bool *success) { @@ -1559,7 +1559,7 @@ __iscsit_check_dataout_hdr(struct iscsi_conn *conn, void *buf, EXPORT_SYMBOL(__iscsit_check_dataout_hdr); int -iscsit_check_dataout_hdr(struct iscsi_conn *conn, void *buf, +iscsit_check_dataout_hdr(struct iscsit_conn *conn, void *buf, struct iscsit_cmd **out_cmd) { struct iscsi_data *hdr = buf; @@ -1594,7 +1594,7 @@ iscsit_check_dataout_hdr(struct iscsi_conn *conn, void *buf, EXPORT_SYMBOL(iscsit_check_dataout_hdr); static int -iscsit_get_dataout(struct iscsi_conn *conn, struct iscsit_cmd *cmd, +iscsit_get_dataout(struct iscsit_conn *conn, struct iscsit_cmd *cmd, struct iscsi_data *hdr) { struct kvec *iov; @@ -1665,7 +1665,7 @@ int iscsit_check_dataout_payload(struct iscsit_cmd *cmd, struct iscsi_data *hdr, bool data_crc_failed) { - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; int rc, ooo_cmdsn; /* * Increment post receive data and CRC values or perform @@ -1700,7 +1700,7 @@ iscsit_check_dataout_payload(struct iscsit_cmd *cmd, struct iscsi_data *hdr, } EXPORT_SYMBOL(iscsit_check_dataout_payload); -static int iscsit_handle_data_out(struct iscsi_conn *conn, unsigned char *buf) +static int iscsit_handle_data_out(struct iscsit_conn *conn, unsigned char *buf) { struct iscsit_cmd *cmd = NULL; struct iscsi_data *hdr = (struct iscsi_data *)buf; @@ -1722,7 +1722,7 @@ static int iscsit_handle_data_out(struct iscsi_conn *conn, unsigned char *buf) return iscsit_check_dataout_payload(cmd, hdr, data_crc_failed); } -int iscsit_setup_nop_out(struct iscsi_conn *conn, struct iscsit_cmd *cmd, +int iscsit_setup_nop_out(struct iscsit_conn *conn, struct iscsit_cmd *cmd, struct iscsi_nopout *hdr) { u32 payload_length = ntoh24(hdr->dlength); @@ -1789,7 +1789,7 @@ int iscsit_setup_nop_out(struct iscsi_conn *conn, struct iscsit_cmd *cmd, } EXPORT_SYMBOL(iscsit_setup_nop_out); -int iscsit_process_nop_out(struct iscsi_conn *conn, struct iscsit_cmd *cmd, +int iscsit_process_nop_out(struct iscsit_conn *conn, struct iscsit_cmd *cmd, struct iscsi_nopout *hdr) { struct iscsit_cmd *cmd_p = NULL; @@ -1851,7 +1851,7 @@ int iscsit_process_nop_out(struct iscsi_conn *conn, struct iscsit_cmd *cmd, } EXPORT_SYMBOL(iscsit_process_nop_out); -static int iscsit_handle_nop_out(struct iscsi_conn *conn, struct iscsit_cmd *cmd, +static int iscsit_handle_nop_out(struct iscsit_conn *conn, struct iscsit_cmd *cmd, unsigned char *buf) { unsigned char *ping_data = NULL; @@ -1978,7 +1978,7 @@ static enum tcm_tmreq_table iscsit_convert_tmf(u8 iscsi_tmf) } int -iscsit_handle_task_mgt_cmd(struct iscsi_conn *conn, struct iscsit_cmd *cmd, +iscsit_handle_task_mgt_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, unsigned char *buf) { struct se_tmr_req *se_tmr; @@ -2159,7 +2159,7 @@ EXPORT_SYMBOL(iscsit_handle_task_mgt_cmd); /* #warning FIXME: Support Text Command parameters besides SendTargets */ int -iscsit_setup_text_cmd(struct iscsi_conn *conn, struct iscsit_cmd *cmd, +iscsit_setup_text_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, struct iscsi_text *hdr) { u32 payload_length = ntoh24(hdr->dlength); @@ -2199,7 +2199,7 @@ iscsit_setup_text_cmd(struct iscsi_conn *conn, struct iscsit_cmd *cmd, EXPORT_SYMBOL(iscsit_setup_text_cmd); int -iscsit_process_text_cmd(struct iscsi_conn *conn, struct iscsit_cmd *cmd, +iscsit_process_text_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, struct iscsi_text *hdr) { unsigned char *text_in = cmd->text_in_ptr, *text_ptr; @@ -2258,7 +2258,7 @@ reject: EXPORT_SYMBOL(iscsit_process_text_cmd); static int -iscsit_handle_text_cmd(struct iscsi_conn *conn, struct iscsit_cmd *cmd, +iscsit_handle_text_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, unsigned char *buf) { struct iscsi_text *hdr = (struct iscsi_text *)buf; @@ -2347,9 +2347,9 @@ reject: return iscsit_reject_cmd(cmd, ISCSI_REASON_PROTOCOL_ERROR, buf); } -int iscsit_logout_closesession(struct iscsit_cmd *cmd, struct iscsi_conn *conn) +int iscsit_logout_closesession(struct iscsit_cmd *cmd, struct iscsit_conn *conn) { - struct iscsi_conn *conn_p; + struct iscsit_conn *conn_p; struct iscsi_session *sess = conn->sess; pr_debug("Received logout request CLOSESESSION on CID: %hu" @@ -2377,9 +2377,9 @@ int iscsit_logout_closesession(struct iscsit_cmd *cmd, struct iscsi_conn *conn) return 0; } -int iscsit_logout_closeconnection(struct iscsit_cmd *cmd, struct iscsi_conn *conn) +int iscsit_logout_closeconnection(struct iscsit_cmd *cmd, struct iscsit_conn *conn) { - struct iscsi_conn *l_conn; + struct iscsit_conn *l_conn; struct iscsi_session *sess = conn->sess; pr_debug("Received logout request CLOSECONNECTION for CID:" @@ -2425,7 +2425,7 @@ int iscsit_logout_closeconnection(struct iscsit_cmd *cmd, struct iscsi_conn *con return 0; } -int iscsit_logout_removeconnforrecovery(struct iscsit_cmd *cmd, struct iscsi_conn *conn) +int iscsit_logout_removeconnforrecovery(struct iscsit_cmd *cmd, struct iscsit_conn *conn) { struct iscsi_session *sess = conn->sess; @@ -2455,7 +2455,7 @@ int iscsit_logout_removeconnforrecovery(struct iscsit_cmd *cmd, struct iscsi_con } int -iscsit_handle_logout_cmd(struct iscsi_conn *conn, struct iscsit_cmd *cmd, +iscsit_handle_logout_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, unsigned char *buf) { int cmdsn_ret, logout_remove = 0; @@ -2536,7 +2536,7 @@ iscsit_handle_logout_cmd(struct iscsi_conn *conn, struct iscsit_cmd *cmd, EXPORT_SYMBOL(iscsit_handle_logout_cmd); int iscsit_handle_snack( - struct iscsi_conn *conn, + struct iscsit_conn *conn, unsigned char *buf) { struct iscsi_snack *hdr; @@ -2590,7 +2590,7 @@ int iscsit_handle_snack( } EXPORT_SYMBOL(iscsit_handle_snack); -static void iscsit_rx_thread_wait_for_tcp(struct iscsi_conn *conn) +static void iscsit_rx_thread_wait_for_tcp(struct iscsit_conn *conn) { if ((conn->sock->sk->sk_shutdown & SEND_SHUTDOWN) || (conn->sock->sk->sk_shutdown & RCV_SHUTDOWN)) { @@ -2607,7 +2607,7 @@ static int iscsit_handle_immediate_data( { int iov_ret, rx_got = 0, rx_size = 0; u32 checksum, iov_count = 0, padding = 0; - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct kvec *iov; void *overflow_buf = NULL; @@ -2708,10 +2708,10 @@ static int iscsit_handle_immediate_data( /* #warning iscsi_build_conn_drop_async_message() only sends out on connections with active network interface */ -static void iscsit_build_conn_drop_async_message(struct iscsi_conn *conn) +static void iscsit_build_conn_drop_async_message(struct iscsit_conn *conn) { struct iscsit_cmd *cmd; - struct iscsi_conn *conn_p; + struct iscsit_conn *conn_p; bool found = false; lockdep_assert_held(&conn->sess->conn_lock); @@ -2751,7 +2751,7 @@ static void iscsit_build_conn_drop_async_message(struct iscsi_conn *conn) static int iscsit_send_conn_drop_async_message( struct iscsit_cmd *cmd, - struct iscsi_conn *conn) + struct iscsit_conn *conn) { struct iscsi_async *hdr; @@ -2779,7 +2779,7 @@ static int iscsit_send_conn_drop_async_message( return conn->conn_transport->iscsit_xmit_pdu(conn, cmd, NULL, NULL, 0); } -static void iscsit_tx_thread_wait_for_tcp(struct iscsi_conn *conn) +static void iscsit_tx_thread_wait_for_tcp(struct iscsit_conn *conn) { if ((conn->sock->sk->sk_shutdown & SEND_SHUTDOWN) || (conn->sock->sk->sk_shutdown & RCV_SHUTDOWN)) { @@ -2790,7 +2790,7 @@ static void iscsit_tx_thread_wait_for_tcp(struct iscsi_conn *conn) } void -iscsit_build_datain_pdu(struct iscsit_cmd *cmd, struct iscsi_conn *conn, +iscsit_build_datain_pdu(struct iscsit_cmd *cmd, struct iscsit_conn *conn, struct iscsi_datain *datain, struct iscsi_data_rsp *hdr, bool set_statsn) { @@ -2835,7 +2835,7 @@ iscsit_build_datain_pdu(struct iscsit_cmd *cmd, struct iscsi_conn *conn, } EXPORT_SYMBOL(iscsit_build_datain_pdu); -static int iscsit_send_datain(struct iscsit_cmd *cmd, struct iscsi_conn *conn) +static int iscsit_send_datain(struct iscsit_cmd *cmd, struct iscsit_conn *conn) { struct iscsi_data_rsp *hdr = (struct iscsi_data_rsp *)&cmd->pdu[0]; struct iscsi_datain datain; @@ -2896,10 +2896,10 @@ static int iscsit_send_datain(struct iscsit_cmd *cmd, struct iscsi_conn *conn) } int -iscsit_build_logout_rsp(struct iscsit_cmd *cmd, struct iscsi_conn *conn, +iscsit_build_logout_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn, struct iscsi_logout_rsp *hdr) { - struct iscsi_conn *logout_conn = NULL; + struct iscsit_conn *logout_conn = NULL; struct iscsi_conn_recovery *cr = NULL; struct iscsi_session *sess = conn->sess; /* @@ -2991,7 +2991,7 @@ iscsit_build_logout_rsp(struct iscsit_cmd *cmd, struct iscsi_conn *conn, EXPORT_SYMBOL(iscsit_build_logout_rsp); static int -iscsit_send_logout(struct iscsit_cmd *cmd, struct iscsi_conn *conn) +iscsit_send_logout(struct iscsit_cmd *cmd, struct iscsit_conn *conn) { int rc; @@ -3004,7 +3004,7 @@ iscsit_send_logout(struct iscsit_cmd *cmd, struct iscsi_conn *conn) } void -iscsit_build_nopin_rsp(struct iscsit_cmd *cmd, struct iscsi_conn *conn, +iscsit_build_nopin_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn, struct iscsi_nopin *hdr, bool nopout_response) { hdr->opcode = ISCSI_OP_NOOP_IN; @@ -3036,7 +3036,7 @@ EXPORT_SYMBOL(iscsit_build_nopin_rsp); */ static int iscsit_send_unsolicited_nopin( struct iscsit_cmd *cmd, - struct iscsi_conn *conn, + struct iscsit_conn *conn, int want_response) { struct iscsi_nopin *hdr = (struct iscsi_nopin *)&cmd->pdu[0]; @@ -3060,7 +3060,7 @@ static int iscsit_send_unsolicited_nopin( } static int -iscsit_send_nopin(struct iscsit_cmd *cmd, struct iscsi_conn *conn) +iscsit_send_nopin(struct iscsit_cmd *cmd, struct iscsit_conn *conn) { struct iscsi_nopin *hdr = (struct iscsi_nopin *)&cmd->pdu[0]; @@ -3079,7 +3079,7 @@ iscsit_send_nopin(struct iscsit_cmd *cmd, struct iscsi_conn *conn) static int iscsit_send_r2t( struct iscsit_cmd *cmd, - struct iscsi_conn *conn) + struct iscsit_conn *conn) { struct iscsi_r2t *r2t; struct iscsi_r2t_rsp *hdr; @@ -3135,7 +3135,7 @@ static int iscsit_send_r2t( * connection recovery. */ int iscsit_build_r2ts_for_cmd( - struct iscsi_conn *conn, + struct iscsit_conn *conn, struct iscsit_cmd *cmd, bool recovery) { @@ -3218,7 +3218,7 @@ int iscsit_build_r2ts_for_cmd( } EXPORT_SYMBOL(iscsit_build_r2ts_for_cmd); -void iscsit_build_rsp_pdu(struct iscsit_cmd *cmd, struct iscsi_conn *conn, +void iscsit_build_rsp_pdu(struct iscsit_cmd *cmd, struct iscsit_conn *conn, bool inc_stat_sn, struct iscsi_scsi_rsp *hdr) { if (inc_stat_sn) @@ -3252,7 +3252,7 @@ void iscsit_build_rsp_pdu(struct iscsit_cmd *cmd, struct iscsi_conn *conn, } EXPORT_SYMBOL(iscsit_build_rsp_pdu); -static int iscsit_send_response(struct iscsit_cmd *cmd, struct iscsi_conn *conn) +static int iscsit_send_response(struct iscsit_cmd *cmd, struct iscsit_conn *conn) { struct iscsi_scsi_rsp *hdr = (struct iscsi_scsi_rsp *)&cmd->pdu[0]; bool inc_stat_sn = (cmd->i_state == ISTATE_SEND_STATUS); @@ -3309,7 +3309,7 @@ static u8 iscsit_convert_tcm_tmr_rsp(struct se_tmr_req *se_tmr) } void -iscsit_build_task_mgt_rsp(struct iscsit_cmd *cmd, struct iscsi_conn *conn, +iscsit_build_task_mgt_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn, struct iscsi_tm_rsp *hdr) { struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req; @@ -3332,7 +3332,7 @@ iscsit_build_task_mgt_rsp(struct iscsit_cmd *cmd, struct iscsi_conn *conn, EXPORT_SYMBOL(iscsit_build_task_mgt_rsp); static int -iscsit_send_task_mgt_rsp(struct iscsit_cmd *cmd, struct iscsi_conn *conn) +iscsit_send_task_mgt_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn) { struct iscsi_tm_rsp *hdr = (struct iscsi_tm_rsp *)&cmd->pdu[0]; @@ -3349,7 +3349,7 @@ iscsit_build_sendtargets_response(struct iscsit_cmd *cmd, int skip_bytes, bool *completed) { char *payload = NULL; - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct iscsi_portal_group *tpg; struct iscsi_tiqn *tiqn; struct iscsi_tpg_np *tpg_np; @@ -3494,7 +3494,7 @@ eob: } int -iscsit_build_text_rsp(struct iscsit_cmd *cmd, struct iscsi_conn *conn, +iscsit_build_text_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn, struct iscsi_text_rsp *hdr, enum iscsit_transport_type network_transport) { @@ -3545,7 +3545,7 @@ EXPORT_SYMBOL(iscsit_build_text_rsp); static int iscsit_send_text_rsp( struct iscsit_cmd *cmd, - struct iscsi_conn *conn) + struct iscsit_conn *conn) { struct iscsi_text_rsp *hdr = (struct iscsi_text_rsp *)cmd->pdu; int text_length; @@ -3561,7 +3561,7 @@ static int iscsit_send_text_rsp( } void -iscsit_build_reject(struct iscsit_cmd *cmd, struct iscsi_conn *conn, +iscsit_build_reject(struct iscsit_cmd *cmd, struct iscsit_conn *conn, struct iscsi_reject *hdr) { hdr->opcode = ISCSI_OP_REJECT; @@ -3579,7 +3579,7 @@ EXPORT_SYMBOL(iscsit_build_reject); static int iscsit_send_reject( struct iscsit_cmd *cmd, - struct iscsi_conn *conn) + struct iscsit_conn *conn) { struct iscsi_reject *hdr = (struct iscsi_reject *)&cmd->pdu[0]; @@ -3593,7 +3593,7 @@ static int iscsit_send_reject( ISCSI_HDR_LEN); } -void iscsit_thread_get_cpumask(struct iscsi_conn *conn) +void iscsit_thread_get_cpumask(struct iscsit_conn *conn) { int ord, cpu; cpumask_t conn_allowed_cpumask; @@ -3624,7 +3624,7 @@ void iscsit_thread_get_cpumask(struct iscsi_conn *conn) cpumask_setall(conn->conn_cpumask); } -static void iscsit_thread_reschedule(struct iscsi_conn *conn) +static void iscsit_thread_reschedule(struct iscsit_conn *conn) { /* * If iscsit_global->allowed_cpumask modified, reschedule iSCSI @@ -3641,7 +3641,7 @@ static void iscsit_thread_reschedule(struct iscsi_conn *conn) } void iscsit_thread_check_cpumask( - struct iscsi_conn *conn, + struct iscsit_conn *conn, struct task_struct *p, int mode) { @@ -3681,7 +3681,7 @@ void iscsit_thread_check_cpumask( EXPORT_SYMBOL(iscsit_thread_check_cpumask); int -iscsit_immediate_queue(struct iscsi_conn *conn, struct iscsit_cmd *cmd, int state) +iscsit_immediate_queue(struct iscsit_conn *conn, struct iscsit_cmd *cmd, int state) { int ret; @@ -3725,7 +3725,7 @@ err: EXPORT_SYMBOL(iscsit_immediate_queue); static int -iscsit_handle_immediate_queue(struct iscsi_conn *conn) +iscsit_handle_immediate_queue(struct iscsit_conn *conn) { struct iscsit_transport *t = conn->conn_transport; struct iscsi_queue_req *qr; @@ -3748,7 +3748,7 @@ iscsit_handle_immediate_queue(struct iscsi_conn *conn) } int -iscsit_response_queue(struct iscsi_conn *conn, struct iscsit_cmd *cmd, int state) +iscsit_response_queue(struct iscsit_conn *conn, struct iscsit_cmd *cmd, int state) { int ret; @@ -3854,7 +3854,7 @@ err: } EXPORT_SYMBOL(iscsit_response_queue); -static int iscsit_handle_response_queue(struct iscsi_conn *conn) +static int iscsit_handle_response_queue(struct iscsit_conn *conn) { struct iscsit_transport *t = conn->conn_transport; struct iscsi_queue_req *qr; @@ -3878,7 +3878,7 @@ static int iscsit_handle_response_queue(struct iscsi_conn *conn) int iscsi_target_tx_thread(void *arg) { int ret = 0; - struct iscsi_conn *conn = arg; + struct iscsit_conn *conn = arg; bool conn_freed = false; /* @@ -3933,7 +3933,7 @@ out: return 0; } -static int iscsi_target_rx_opcode(struct iscsi_conn *conn, unsigned char *buf) +static int iscsi_target_rx_opcode(struct iscsit_conn *conn, unsigned char *buf) { struct iscsi_hdr *hdr = (struct iscsi_hdr *)buf; struct iscsit_cmd *cmd; @@ -4010,7 +4010,7 @@ reject: return iscsit_add_reject(conn, ISCSI_REASON_BOOKMARK_NO_RESOURCES, buf); } -static bool iscsi_target_check_conn_state(struct iscsi_conn *conn) +static bool iscsi_target_check_conn_state(struct iscsit_conn *conn) { bool ret; @@ -4021,7 +4021,7 @@ static bool iscsi_target_check_conn_state(struct iscsi_conn *conn) return ret; } -static void iscsit_get_rx_pdu(struct iscsi_conn *conn) +static void iscsit_get_rx_pdu(struct iscsit_conn *conn) { int ret; u8 *buffer, opcode; @@ -4106,7 +4106,7 @@ static void iscsit_get_rx_pdu(struct iscsi_conn *conn) int iscsi_target_rx_thread(void *arg) { int rc; - struct iscsi_conn *conn = arg; + struct iscsit_conn *conn = arg; bool conn_freed = false; /* @@ -4141,7 +4141,7 @@ out: return 0; } -static void iscsit_release_commands_from_conn(struct iscsi_conn *conn) +static void iscsit_release_commands_from_conn(struct iscsit_conn *conn) { LIST_HEAD(tmp_list); struct iscsit_cmd *cmd = NULL, *cmd_tmp = NULL; @@ -4185,7 +4185,7 @@ static void iscsit_release_commands_from_conn(struct iscsi_conn *conn) } static void iscsit_stop_timers_for_cmds( - struct iscsi_conn *conn) + struct iscsit_conn *conn) { struct iscsit_cmd *cmd; @@ -4198,7 +4198,7 @@ static void iscsit_stop_timers_for_cmds( } int iscsit_close_connection( - struct iscsi_conn *conn) + struct iscsit_conn *conn) { int conn_logout = (conn->conn_state == TARG_CONN_STATE_IN_LOGOUT); struct iscsi_session *sess = conn->sess; @@ -4214,7 +4214,7 @@ int iscsit_close_connection( * However for iser-target, isert_wait4logout() is using conn_logout_comp * to signal logout response TX interrupt completion. Go ahead and skip * this for iser since isert_rx_opcode() does not wait on logout failure, - * and to avoid iscsi_conn pointer dereference in iser-target code. + * and to avoid iscsit_conn pointer dereference in iser-target code. */ if (!conn->conn_transport->rdma_shutdown) complete(&conn->conn_logout_comp); @@ -4506,7 +4506,7 @@ int iscsit_close_session(struct iscsi_session *sess, bool can_sleep) } static void iscsit_logout_post_handler_closesession( - struct iscsi_conn *conn) + struct iscsit_conn *conn) { struct iscsi_session *sess = conn->sess; int sleep = 1; @@ -4535,7 +4535,7 @@ static void iscsit_logout_post_handler_closesession( } static void iscsit_logout_post_handler_samecid( - struct iscsi_conn *conn) + struct iscsit_conn *conn) { int sleep = 1; @@ -4553,10 +4553,10 @@ static void iscsit_logout_post_handler_samecid( } static void iscsit_logout_post_handler_diffcid( - struct iscsi_conn *conn, + struct iscsit_conn *conn, u16 cid) { - struct iscsi_conn *l_conn; + struct iscsit_conn *l_conn; struct iscsi_session *sess = conn->sess; bool conn_found = false; @@ -4593,7 +4593,7 @@ static void iscsit_logout_post_handler_diffcid( */ int iscsit_logout_post_handler( struct iscsit_cmd *cmd, - struct iscsi_conn *conn) + struct iscsit_conn *conn) { int ret = 0; @@ -4651,7 +4651,7 @@ EXPORT_SYMBOL(iscsit_logout_post_handler); void iscsit_fail_session(struct iscsi_session *sess) { - struct iscsi_conn *conn; + struct iscsit_conn *conn; spin_lock_bh(&sess->conn_lock); list_for_each_entry(conn, &sess->sess_conn_list, conn_list) { @@ -4670,7 +4670,7 @@ void iscsit_stop_session( int connection_sleep) { u16 conn_count = atomic_read(&sess->nconn); - struct iscsi_conn *conn, *conn_tmp = NULL; + struct iscsit_conn *conn, *conn_tmp = NULL; int is_last; spin_lock_bh(&sess->conn_lock); diff --git a/drivers/target/iscsi/iscsi_target.h b/drivers/target/iscsi/iscsi_target.h index bfa3559cf823..314e29fcaa5a 100644 --- a/drivers/target/iscsi/iscsi_target.h +++ b/drivers/target/iscsi/iscsi_target.h @@ -6,7 +6,7 @@ #include struct iscsit_cmd; -struct iscsi_conn; +struct iscsit_conn; struct iscsi_np; struct iscsi_portal_group; struct iscsi_session; @@ -32,15 +32,15 @@ extern int iscsit_reset_np_thread(struct iscsi_np *, struct iscsi_tpg_np *, extern int iscsit_del_np(struct iscsi_np *); extern int iscsit_reject_cmd(struct iscsit_cmd *cmd, u8, unsigned char *); extern void iscsit_set_unsolicited_dataout(struct iscsit_cmd *); -extern int iscsit_logout_closesession(struct iscsit_cmd *, struct iscsi_conn *); -extern int iscsit_logout_closeconnection(struct iscsit_cmd *, struct iscsi_conn *); -extern int iscsit_logout_removeconnforrecovery(struct iscsit_cmd *, struct iscsi_conn *); -extern int iscsit_send_async_msg(struct iscsi_conn *, u16, u8, u8); -extern int iscsit_build_r2ts_for_cmd(struct iscsi_conn *, struct iscsit_cmd *, bool recovery); -extern void iscsit_thread_get_cpumask(struct iscsi_conn *); +extern int iscsit_logout_closesession(struct iscsit_cmd *, struct iscsit_conn *); +extern int iscsit_logout_closeconnection(struct iscsit_cmd *, struct iscsit_conn *); +extern int iscsit_logout_removeconnforrecovery(struct iscsit_cmd *, struct iscsit_conn *); +extern int iscsit_send_async_msg(struct iscsit_conn *, u16, u8, u8); +extern int iscsit_build_r2ts_for_cmd(struct iscsit_conn *, struct iscsit_cmd *, bool recovery); +extern void iscsit_thread_get_cpumask(struct iscsit_conn *); extern int iscsi_target_tx_thread(void *); extern int iscsi_target_rx_thread(void *); -extern int iscsit_close_connection(struct iscsi_conn *); +extern int iscsit_close_connection(struct iscsit_conn *); extern int iscsit_close_session(struct iscsi_session *, bool can_sleep); extern void iscsit_fail_session(struct iscsi_session *); extern void iscsit_stop_session(struct iscsi_session *, int, int); diff --git a/drivers/target/iscsi/iscsi_target_auth.c b/drivers/target/iscsi/iscsi_target_auth.c index 62d912b79c61..6e5611d8f51b 100644 --- a/drivers/target/iscsi/iscsi_target_auth.c +++ b/drivers/target/iscsi/iscsi_target_auth.c @@ -35,7 +35,7 @@ static char *chap_get_digest_name(const int digest_type) } static int chap_gen_challenge( - struct iscsi_conn *conn, + struct iscsit_conn *conn, int caller, char *c_str, unsigned int *c_len) @@ -128,14 +128,14 @@ out: return r; } -static void chap_close(struct iscsi_conn *conn) +static void chap_close(struct iscsit_conn *conn) { kfree(conn->auth_protocol); conn->auth_protocol = NULL; } static struct iscsi_chap *chap_server_open( - struct iscsi_conn *conn, + struct iscsit_conn *conn, struct iscsi_node_auth *auth, const char *a_str, char *aic_str, @@ -206,7 +206,7 @@ static struct iscsi_chap *chap_server_open( } static int chap_server_compute_hash( - struct iscsi_conn *conn, + struct iscsit_conn *conn, struct iscsi_node_auth *auth, char *nr_in_ptr, char *nr_out_ptr, @@ -497,7 +497,7 @@ out: } u32 chap_main_loop( - struct iscsi_conn *conn, + struct iscsit_conn *conn, struct iscsi_node_auth *auth, char *in_text, char *out_text, diff --git a/drivers/target/iscsi/iscsi_target_auth.h b/drivers/target/iscsi/iscsi_target_auth.h index fc75c1c20e23..ceb9b7754770 100644 --- a/drivers/target/iscsi/iscsi_target_auth.h +++ b/drivers/target/iscsi/iscsi_target_auth.h @@ -27,9 +27,9 @@ #define CHAP_STAGE_SERVER_NR 5 struct iscsi_node_auth; -struct iscsi_conn; +struct iscsit_conn; -extern u32 chap_main_loop(struct iscsi_conn *, struct iscsi_node_auth *, char *, char *, +extern u32 chap_main_loop(struct iscsit_conn *, struct iscsi_node_auth *, char *, char *, int *, int *); struct iscsi_chap { diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c index 0c1f4ad3e04a..aadc855f67fa 100644 --- a/drivers/target/iscsi/iscsi_target_configfs.c +++ b/drivers/target/iscsi/iscsi_target_configfs.c @@ -499,7 +499,7 @@ static ssize_t lio_target_nacl_info_show(struct config_item *item, char *page) { struct se_node_acl *se_nacl = acl_to_nacl(item); struct iscsi_session *sess; - struct iscsi_conn *conn; + struct iscsit_conn *conn; struct se_session *se_sess; ssize_t rb = 0; u32 max_cmd_sn; @@ -1367,7 +1367,7 @@ static u32 lio_sess_get_initiator_sid( static int lio_queue_data_in(struct se_cmd *se_cmd) { struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd); - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; cmd->i_state = ISTATE_SEND_DATAIN; return conn->conn_transport->iscsit_queue_data_in(conn, cmd); @@ -1376,7 +1376,7 @@ static int lio_queue_data_in(struct se_cmd *se_cmd) static int lio_write_pending(struct se_cmd *se_cmd) { struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd); - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; if (!cmd->immediate_data && !cmd->unsolicited_data) return conn->conn_transport->iscsit_get_dataout(conn, cmd, false); @@ -1387,7 +1387,7 @@ static int lio_write_pending(struct se_cmd *se_cmd) static int lio_queue_status(struct se_cmd *se_cmd) { struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd); - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; cmd->i_state = ISTATE_SEND_STATUS; diff --git a/drivers/target/iscsi/iscsi_target_datain_values.c b/drivers/target/iscsi/iscsi_target_datain_values.c index 091a710eadb0..2d44781be3c6 100644 --- a/drivers/target/iscsi/iscsi_target_datain_values.c +++ b/drivers/target/iscsi/iscsi_target_datain_values.c @@ -80,7 +80,7 @@ static struct iscsi_datain_req *iscsit_set_datain_values_yes_and_yes( struct iscsi_datain *datain) { u32 next_burst_len, read_data_done, read_data_left; - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct iscsi_datain_req *dr; dr = iscsit_get_datain_req(cmd); @@ -178,7 +178,7 @@ static struct iscsi_datain_req *iscsit_set_datain_values_no_and_yes( struct iscsi_datain *datain) { u32 offset, read_data_done, read_data_left, seq_send_order; - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct iscsi_datain_req *dr; struct iscsi_seq *seq; @@ -299,7 +299,7 @@ static struct iscsi_datain_req *iscsit_set_datain_values_yes_and_no( struct iscsi_datain *datain) { u32 next_burst_len, read_data_done, read_data_left; - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct iscsi_datain_req *dr; struct iscsi_pdu *pdu; @@ -398,7 +398,7 @@ static struct iscsi_datain_req *iscsit_set_datain_values_no_and_no( struct iscsi_datain *datain) { u32 read_data_done, read_data_left, seq_send_order; - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct iscsi_datain_req *dr; struct iscsi_pdu *pdu; struct iscsi_seq *seq = NULL; @@ -499,7 +499,7 @@ struct iscsi_datain_req *iscsit_get_datain_values( struct iscsit_cmd *cmd, struct iscsi_datain *datain) { - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; if (conn->sess->sess_ops->DataSequenceInOrder && conn->sess->sess_ops->DataPDUInOrder) diff --git a/drivers/target/iscsi/iscsi_target_erl0.c b/drivers/target/iscsi/iscsi_target_erl0.c index 8ca910571ed3..e21f6c6dfd99 100644 --- a/drivers/target/iscsi/iscsi_target_erl0.c +++ b/drivers/target/iscsi/iscsi_target_erl0.c @@ -31,7 +31,7 @@ void iscsit_set_dataout_sequence_values( struct iscsit_cmd *cmd) { - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; /* * Still set seq_start_offset and seq_end_offset for Unsolicited * DataOUT, even if DataSequenceInOrder=No. @@ -66,7 +66,7 @@ static int iscsit_dataout_within_command_recovery_check( struct iscsit_cmd *cmd, unsigned char *buf) { - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct iscsi_data *hdr = (struct iscsi_data *) buf; u32 payload_length = ntoh24(hdr->dlength); @@ -133,7 +133,7 @@ static int iscsit_dataout_check_unsolicited_sequence( unsigned char *buf) { u32 first_burst_len; - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct iscsi_data *hdr = (struct iscsi_data *) buf; u32 payload_length = ntoh24(hdr->dlength); @@ -208,7 +208,7 @@ static int iscsit_dataout_check_sequence( unsigned char *buf) { u32 next_burst_len; - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct iscsi_seq *seq = NULL; struct iscsi_data *hdr = (struct iscsi_data *) buf; u32 payload_length = ntoh24(hdr->dlength); @@ -337,7 +337,7 @@ static int iscsit_dataout_check_datasn( unsigned char *buf) { u32 data_sn = 0; - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct iscsi_data *hdr = (struct iscsi_data *) buf; u32 payload_length = ntoh24(hdr->dlength); @@ -388,7 +388,7 @@ static int iscsit_dataout_pre_datapduinorder_yes( unsigned char *buf) { int dump = 0, recovery = 0; - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct iscsi_data *hdr = (struct iscsi_data *) buf; u32 payload_length = ntoh24(hdr->dlength); @@ -534,7 +534,7 @@ static int iscsit_dataout_post_crc_passed( unsigned char *buf) { int ret, send_r2t = 0; - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct iscsi_seq *seq = NULL; struct iscsi_data *hdr = (struct iscsi_data *) buf; u32 payload_length = ntoh24(hdr->dlength); @@ -644,7 +644,7 @@ static int iscsit_dataout_post_crc_failed( struct iscsit_cmd *cmd, unsigned char *buf) { - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct iscsi_pdu *pdu; struct iscsi_data *hdr = (struct iscsi_data *) buf; u32 payload_length = ntoh24(hdr->dlength); @@ -683,7 +683,7 @@ int iscsit_check_pre_dataout( unsigned char *buf) { int ret; - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; ret = iscsit_dataout_within_command_recovery_check(cmd, buf); if ((ret == DATAOUT_WITHIN_COMMAND_RECOVERY) || @@ -721,7 +721,7 @@ int iscsit_check_post_dataout( unsigned char *buf, u8 data_crc_failed) { - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; cmd->dataout_timeout_retries = 0; @@ -819,7 +819,7 @@ int iscsit_stop_time2retain_timer(struct iscsi_session *sess) return 0; } -void iscsit_connection_reinstatement_rcfr(struct iscsi_conn *conn) +void iscsit_connection_reinstatement_rcfr(struct iscsit_conn *conn) { spin_lock_bh(&conn->state_lock); if (atomic_read(&conn->connection_exit)) { @@ -843,7 +843,7 @@ sleep: complete(&conn->conn_post_wait_comp); } -void iscsit_cause_connection_reinstatement(struct iscsi_conn *conn, int sleep) +void iscsit_cause_connection_reinstatement(struct iscsit_conn *conn, int sleep) { spin_lock_bh(&conn->state_lock); if (atomic_read(&conn->connection_exit)) { @@ -888,7 +888,7 @@ void iscsit_fall_back_to_erl0(struct iscsi_session *sess) atomic_set(&sess->session_fall_back_to_erl0, 1); } -static void iscsit_handle_connection_cleanup(struct iscsi_conn *conn) +static void iscsit_handle_connection_cleanup(struct iscsit_conn *conn) { struct iscsi_session *sess = conn->sess; @@ -904,7 +904,7 @@ static void iscsit_handle_connection_cleanup(struct iscsi_conn *conn) } } -void iscsit_take_action_for_connection_exit(struct iscsi_conn *conn, bool *conn_freed) +void iscsit_take_action_for_connection_exit(struct iscsit_conn *conn, bool *conn_freed) { *conn_freed = false; diff --git a/drivers/target/iscsi/iscsi_target_erl0.h b/drivers/target/iscsi/iscsi_target_erl0.h index d23a3041c325..9d34c1cd6b57 100644 --- a/drivers/target/iscsi/iscsi_target_erl0.h +++ b/drivers/target/iscsi/iscsi_target_erl0.h @@ -5,7 +5,7 @@ #include struct iscsit_cmd; -struct iscsi_conn; +struct iscsit_conn; struct iscsi_session; extern void iscsit_set_dataout_sequence_values(struct iscsit_cmd *); @@ -14,9 +14,9 @@ extern int iscsit_check_post_dataout(struct iscsit_cmd *, unsigned char *, u8); extern void iscsit_start_time2retain_handler(struct iscsi_session *); extern void iscsit_handle_time2retain_timeout(struct timer_list *t); extern int iscsit_stop_time2retain_timer(struct iscsi_session *); -extern void iscsit_connection_reinstatement_rcfr(struct iscsi_conn *); -extern void iscsit_cause_connection_reinstatement(struct iscsi_conn *, int); +extern void iscsit_connection_reinstatement_rcfr(struct iscsit_conn *); +extern void iscsit_cause_connection_reinstatement(struct iscsit_conn *, int); extern void iscsit_fall_back_to_erl0(struct iscsi_session *); -extern void iscsit_take_action_for_connection_exit(struct iscsi_conn *, bool *); +extern void iscsit_take_action_for_connection_exit(struct iscsit_conn *, bool *); #endif /*** ISCSI_TARGET_ERL0_H ***/ diff --git a/drivers/target/iscsi/iscsi_target_erl1.c b/drivers/target/iscsi/iscsi_target_erl1.c index d348a9af7789..2c3ac5986b45 100644 --- a/drivers/target/iscsi/iscsi_target_erl1.c +++ b/drivers/target/iscsi/iscsi_target_erl1.c @@ -36,7 +36,7 @@ * to be dumped. */ int iscsit_dump_data_payload( - struct iscsi_conn *conn, + struct iscsit_conn *conn, u32 buf_len, int dump_padding_digest) { @@ -173,7 +173,7 @@ int iscsit_create_recovery_datain_values_datasequenceinorder_yes( u32 data_sn = 0, data_sn_count = 0; u32 pdu_start = 0, seq_no = 0; u32 begrun = dr->begrun; - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; while (begrun > data_sn++) { data_sn_count++; @@ -220,7 +220,7 @@ int iscsit_create_recovery_datain_values_datasequenceinorder_no( u32 data_sn, read_data_done = 0, seq_send_order = 0; u32 begrun = dr->begrun; u32 runlength = dr->runlength; - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct iscsi_seq *first_seq = NULL, *seq = NULL; if (!cmd->seq_list) { @@ -376,7 +376,7 @@ static int iscsit_handle_recovery_datain( u32 begrun, u32 runlength) { - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct iscsi_datain_req *dr; struct se_cmd *se_cmd = &cmd->se_cmd; @@ -432,7 +432,7 @@ static int iscsit_handle_recovery_datain( } int iscsit_handle_recovery_datain_or_r2t( - struct iscsi_conn *conn, + struct iscsit_conn *conn, unsigned char *buf, itt_t init_task_tag, u32 targ_xfer_tag, @@ -465,7 +465,7 @@ int iscsit_handle_recovery_datain_or_r2t( /* #warning FIXME: Status SNACK needs to be dependent on OPCODE!!! */ int iscsit_handle_status_snack( - struct iscsi_conn *conn, + struct iscsit_conn *conn, itt_t init_task_tag, u32 targ_xfer_tag, u32 begrun, @@ -529,7 +529,7 @@ int iscsit_handle_status_snack( } int iscsit_handle_data_ack( - struct iscsi_conn *conn, + struct iscsit_conn *conn, u32 targ_xfer_tag, u32 begrun, u32 runlength) @@ -584,7 +584,7 @@ int iscsit_dataout_datapduinorder_no_fbit( { int i, send_recovery_r2t = 0, recovery = 0; u32 length = 0, offset = 0, pdu_count = 0, xfer_len = 0; - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct iscsi_pdu *first_pdu = NULL; /* @@ -662,7 +662,7 @@ static int iscsit_recalculate_dataout_values( u32 *r2t_length) { int i; - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct iscsi_pdu *pdu = NULL; if (conn->sess->sess_ops->DataSequenceInOrder) { @@ -825,7 +825,7 @@ void iscsit_remove_ooo_cmdsn( kmem_cache_free(lio_ooo_cache, ooo_cmdsn); } -void iscsit_clear_ooo_cmdsns_for_conn(struct iscsi_conn *conn) +void iscsit_clear_ooo_cmdsns_for_conn(struct iscsit_conn *conn) { struct iscsi_ooo_cmdsn *ooo_cmdsn; struct iscsi_session *sess = conn->sess; @@ -887,7 +887,7 @@ int iscsit_execute_ooo_cmdsns(struct iscsi_session *sess) int iscsit_execute_cmd(struct iscsit_cmd *cmd, int ooo) { struct se_cmd *se_cmd = &cmd->se_cmd; - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; int lr = 0; spin_lock_bh(&cmd->istate_lock); @@ -1053,7 +1053,7 @@ static int iscsit_set_dataout_timeout_values( u32 *offset, u32 *length) { - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct iscsi_r2t *r2t; if (cmd->unsolicited_data) { @@ -1096,7 +1096,7 @@ void iscsit_handle_dataout_timeout(struct timer_list *t) u32 pdu_length = 0, pdu_offset = 0; u32 r2t_length = 0, r2t_offset = 0; struct iscsit_cmd *cmd = from_timer(cmd, t, dataout_timer); - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct iscsi_session *sess = NULL; struct iscsi_node_attrib *na; @@ -1181,7 +1181,7 @@ failure: void iscsit_mod_dataout_timer(struct iscsit_cmd *cmd) { - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct iscsi_session *sess = conn->sess; struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess); @@ -1200,7 +1200,7 @@ void iscsit_mod_dataout_timer(struct iscsit_cmd *cmd) void iscsit_start_dataout_timer( struct iscsit_cmd *cmd, - struct iscsi_conn *conn) + struct iscsit_conn *conn) { struct iscsi_session *sess = conn->sess; struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess); diff --git a/drivers/target/iscsi/iscsi_target_erl1.h b/drivers/target/iscsi/iscsi_target_erl1.h index 48a13fc32e93..b1e60fb26d5f 100644 --- a/drivers/target/iscsi/iscsi_target_erl1.h +++ b/drivers/target/iscsi/iscsi_target_erl1.h @@ -6,25 +6,25 @@ #include /* itt_t */ struct iscsit_cmd; -struct iscsi_conn; +struct iscsit_conn; struct iscsi_datain_req; struct iscsi_ooo_cmdsn; struct iscsi_pdu; struct iscsi_session; -extern int iscsit_dump_data_payload(struct iscsi_conn *, u32, int); +extern int iscsit_dump_data_payload(struct iscsit_conn *, u32, int); extern int iscsit_create_recovery_datain_values_datasequenceinorder_yes( struct iscsit_cmd *, struct iscsi_datain_req *); extern int iscsit_create_recovery_datain_values_datasequenceinorder_no( struct iscsit_cmd *, struct iscsi_datain_req *); -extern int iscsit_handle_recovery_datain_or_r2t(struct iscsi_conn *, unsigned char *, +extern int iscsit_handle_recovery_datain_or_r2t(struct iscsit_conn *, unsigned char *, itt_t, u32, u32, u32); -extern int iscsit_handle_status_snack(struct iscsi_conn *, itt_t, u32, +extern int iscsit_handle_status_snack(struct iscsit_conn *, itt_t, u32, u32, u32); -extern int iscsit_handle_data_ack(struct iscsi_conn *, u32, u32, u32); +extern int iscsit_handle_data_ack(struct iscsit_conn *, u32, u32, u32); extern int iscsit_dataout_datapduinorder_no_fbit(struct iscsit_cmd *, struct iscsi_pdu *); extern int iscsit_recover_dataout_sequence(struct iscsit_cmd *, u32, u32); -extern void iscsit_clear_ooo_cmdsns_for_conn(struct iscsi_conn *); +extern void iscsit_clear_ooo_cmdsns_for_conn(struct iscsit_conn *); extern void iscsit_free_all_ooo_cmdsns(struct iscsi_session *); extern int iscsit_execute_ooo_cmdsns(struct iscsi_session *); extern int iscsit_execute_cmd(struct iscsit_cmd *, int); @@ -32,7 +32,7 @@ extern int iscsit_handle_ooo_cmdsn(struct iscsi_session *, struct iscsit_cmd *, extern void iscsit_remove_ooo_cmdsn(struct iscsi_session *, struct iscsi_ooo_cmdsn *); extern void iscsit_handle_dataout_timeout(struct timer_list *t); extern void iscsit_mod_dataout_timer(struct iscsit_cmd *); -extern void iscsit_start_dataout_timer(struct iscsit_cmd *, struct iscsi_conn *); +extern void iscsit_start_dataout_timer(struct iscsit_cmd *, struct iscsit_conn *); extern void iscsit_stop_dataout_timer(struct iscsit_cmd *); #endif /* ISCSI_TARGET_ERL1_H */ diff --git a/drivers/target/iscsi/iscsi_target_erl2.c b/drivers/target/iscsi/iscsi_target_erl2.c index f19ac2dbc062..1dbdf7937e29 100644 --- a/drivers/target/iscsi/iscsi_target_erl2.c +++ b/drivers/target/iscsi/iscsi_target_erl2.c @@ -30,7 +30,7 @@ void iscsit_create_conn_recovery_datain_values( __be32 exp_data_sn) { u32 data_sn = 0; - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; cmd->next_burst_len = 0; cmd->read_data_done = 0; @@ -57,7 +57,7 @@ void iscsit_create_conn_recovery_dataout_values( struct iscsit_cmd *cmd) { u32 write_data_done = 0; - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; cmd->data_sn = 0; cmd->next_burst_len = 0; @@ -263,7 +263,7 @@ void iscsit_discard_cr_cmds_by_expstatsn( } } -int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(struct iscsi_conn *conn) +int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(struct iscsit_conn *conn) { u32 dropped_count = 0; struct iscsit_cmd *cmd, *cmd_tmp; @@ -304,7 +304,7 @@ int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(struct iscsi_conn *conn) return 0; } -int iscsit_prepare_cmds_for_reallegiance(struct iscsi_conn *conn) +int iscsit_prepare_cmds_for_reallegiance(struct iscsit_conn *conn) { u32 cmd_count = 0; struct iscsit_cmd *cmd, *cmd_tmp; @@ -418,7 +418,7 @@ int iscsit_prepare_cmds_for_reallegiance(struct iscsi_conn *conn) return 0; } -int iscsit_connection_recovery_transport_reset(struct iscsi_conn *conn) +int iscsit_connection_recovery_transport_reset(struct iscsit_conn *conn) { atomic_set(&conn->connection_recovery, 1); diff --git a/drivers/target/iscsi/iscsi_target_erl2.h b/drivers/target/iscsi/iscsi_target_erl2.h index cf411375ad4c..5b311ed9ebc4 100644 --- a/drivers/target/iscsi/iscsi_target_erl2.h +++ b/drivers/target/iscsi/iscsi_target_erl2.h @@ -5,7 +5,7 @@ #include struct iscsit_cmd; -struct iscsi_conn; +struct iscsit_conn; struct iscsi_conn_recovery; struct iscsi_session; @@ -19,8 +19,8 @@ extern int iscsit_remove_active_connection_recovery_entry( extern int iscsit_remove_cmd_from_connection_recovery(struct iscsit_cmd *, struct iscsi_session *); extern void iscsit_discard_cr_cmds_by_expstatsn(struct iscsi_conn_recovery *, u32); -extern int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(struct iscsi_conn *); -extern int iscsit_prepare_cmds_for_reallegiance(struct iscsi_conn *); -extern int iscsit_connection_recovery_transport_reset(struct iscsi_conn *); +extern int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(struct iscsit_conn *); +extern int iscsit_prepare_cmds_for_reallegiance(struct iscsit_conn *); +extern int iscsit_connection_recovery_transport_reset(struct iscsit_conn *); #endif /*** ISCSI_TARGET_ERL2_H ***/ diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c index 9c01fb864585..a303ba7d20c3 100644 --- a/drivers/target/iscsi/iscsi_target_login.c +++ b/drivers/target/iscsi/iscsi_target_login.c @@ -35,7 +35,7 @@ #include -static struct iscsi_login *iscsi_login_init_conn(struct iscsi_conn *conn) +static struct iscsi_login *iscsi_login_init_conn(struct iscsit_conn *conn) { struct iscsi_login *login; @@ -73,9 +73,9 @@ out_login: /* * Used by iscsi_target_nego.c:iscsi_target_locate_portal() to setup - * per struct iscsi_conn libcrypto contexts for crc32c and crc32-intel + * per struct iscsit_conn libcrypto contexts for crc32c and crc32-intel */ -int iscsi_login_setup_crypto(struct iscsi_conn *conn) +int iscsi_login_setup_crypto(struct iscsit_conn *conn) { struct crypto_ahash *tfm; @@ -112,7 +112,7 @@ int iscsi_login_setup_crypto(struct iscsi_conn *conn) } static int iscsi_login_check_initiator_version( - struct iscsi_conn *conn, + struct iscsit_conn *conn, u8 version_max, u8 version_min) { @@ -128,7 +128,7 @@ static int iscsi_login_check_initiator_version( return 0; } -int iscsi_check_for_session_reinstatement(struct iscsi_conn *conn) +int iscsi_check_for_session_reinstatement(struct iscsit_conn *conn) { int sessiontype; struct iscsi_param *initiatorname_param = NULL, *sessiontype_param = NULL; @@ -205,7 +205,7 @@ int iscsi_check_for_session_reinstatement(struct iscsi_conn *conn) static int iscsi_login_set_conn_values( struct iscsi_session *sess, - struct iscsi_conn *conn, + struct iscsit_conn *conn, __be16 cid) { int ret; @@ -226,7 +226,7 @@ static int iscsi_login_set_conn_values( } __printf(2, 3) int iscsi_change_param_sprintf( - struct iscsi_conn *conn, + struct iscsit_conn *conn, const char *fmt, ...) { va_list args; @@ -253,7 +253,7 @@ EXPORT_SYMBOL(iscsi_change_param_sprintf); * or session reinstatement. */ static int iscsi_login_zero_tsih_s1( - struct iscsi_conn *conn, + struct iscsit_conn *conn, unsigned char *buf) { struct iscsi_session *sess = NULL; @@ -337,7 +337,7 @@ free_sess: } static int iscsi_login_zero_tsih_s2( - struct iscsi_conn *conn) + struct iscsit_conn *conn) { struct iscsi_node_attrib *na; struct iscsi_session *sess = conn->sess; @@ -458,7 +458,7 @@ check_prot: } static int iscsi_login_non_zero_tsih_s1( - struct iscsi_conn *conn, + struct iscsit_conn *conn, unsigned char *buf) { struct iscsi_login_req *pdu = (struct iscsi_login_req *)buf; @@ -470,7 +470,7 @@ static int iscsi_login_non_zero_tsih_s1( * Add a new connection to an existing session. */ static int iscsi_login_non_zero_tsih_s2( - struct iscsi_conn *conn, + struct iscsit_conn *conn, unsigned char *buf) { struct iscsi_portal_group *tpg = conn->tpg; @@ -546,11 +546,11 @@ static int iscsi_login_non_zero_tsih_s2( } int iscsi_login_post_auth_non_zero_tsih( - struct iscsi_conn *conn, + struct iscsit_conn *conn, u16 cid, u32 exp_statsn) { - struct iscsi_conn *conn_ptr = NULL; + struct iscsit_conn *conn_ptr = NULL; struct iscsi_conn_recovery *cr = NULL; struct iscsi_session *sess = conn->sess; @@ -612,7 +612,7 @@ int iscsi_login_post_auth_non_zero_tsih( return 0; } -static void iscsi_post_login_start_timers(struct iscsi_conn *conn) +static void iscsi_post_login_start_timers(struct iscsit_conn *conn) { struct iscsi_session *sess = conn->sess; /* @@ -625,7 +625,7 @@ static void iscsi_post_login_start_timers(struct iscsi_conn *conn) iscsit_start_nopin_timer(conn); } -int iscsit_start_kthreads(struct iscsi_conn *conn) +int iscsit_start_kthreads(struct iscsit_conn *conn) { int ret = 0; @@ -673,7 +673,7 @@ out_bitmap: void iscsi_post_login_handler( struct iscsi_np *np, - struct iscsi_conn *conn, + struct iscsit_conn *conn, u8 zero_tsih) { int stop_timer = 0; @@ -730,7 +730,7 @@ void iscsi_post_login_handler( conn->conn_tx_reset_cpumask = 1; /* * Wakeup the sleeping iscsi_target_rx_thread() now that - * iscsi_conn is in TARG_CONN_STATE_LOGGED_IN state. + * iscsit_conn is in TARG_CONN_STATE_LOGGED_IN state. */ complete(&conn->rx_login_comp); iscsit_dec_conn_usage_count(conn); @@ -792,7 +792,7 @@ void iscsi_post_login_handler( conn->conn_tx_reset_cpumask = 1; /* * Wakeup the sleeping iscsi_target_rx_thread() now that - * iscsi_conn is in TARG_CONN_STATE_LOGGED_IN state. + * iscsit_conn is in TARG_CONN_STATE_LOGGED_IN state. */ complete(&conn->rx_login_comp); iscsit_dec_conn_usage_count(conn); @@ -944,7 +944,7 @@ int iscsi_target_setup_login_socket( return 0; } -int iscsit_accept_np(struct iscsi_np *np, struct iscsi_conn *conn) +int iscsit_accept_np(struct iscsi_np *np, struct iscsit_conn *conn) { struct socket *new_sock, *sock = np->np_socket; struct sockaddr_in sock_in; @@ -1005,7 +1005,7 @@ int iscsit_accept_np(struct iscsi_np *np, struct iscsi_conn *conn) return 0; } -int iscsit_get_login_rx(struct iscsi_conn *conn, struct iscsi_login *login) +int iscsit_get_login_rx(struct iscsit_conn *conn, struct iscsi_login *login) { struct iscsi_login_req *login_req; u32 padding = 0, payload_length; @@ -1050,7 +1050,7 @@ int iscsit_get_login_rx(struct iscsi_conn *conn, struct iscsi_login *login) return 0; } -int iscsit_put_login_tx(struct iscsi_conn *conn, struct iscsi_login *login, +int iscsit_put_login_tx(struct iscsit_conn *conn, struct iscsi_login *login, u32 length) { if (iscsi_login_tx_data(conn, login->rsp, login->rsp_buf, length) < 0) @@ -1060,7 +1060,7 @@ int iscsit_put_login_tx(struct iscsi_conn *conn, struct iscsi_login *login, } static int -iscsit_conn_set_transport(struct iscsi_conn *conn, struct iscsit_transport *t) +iscsit_conn_set_transport(struct iscsit_conn *conn, struct iscsit_transport *t) { int rc; @@ -1079,11 +1079,11 @@ iscsit_conn_set_transport(struct iscsi_conn *conn, struct iscsit_transport *t) return 0; } -static struct iscsi_conn *iscsit_alloc_conn(struct iscsi_np *np) +static struct iscsit_conn *iscsit_alloc_conn(struct iscsi_np *np) { - struct iscsi_conn *conn; + struct iscsit_conn *conn; - conn = kzalloc(sizeof(struct iscsi_conn), GFP_KERNEL); + conn = kzalloc(sizeof(struct iscsit_conn), GFP_KERNEL); if (!conn) { pr_err("Could not allocate memory for new connection\n"); return NULL; @@ -1147,7 +1147,7 @@ free_conn: return NULL; } -void iscsit_free_conn(struct iscsi_conn *conn) +void iscsit_free_conn(struct iscsit_conn *conn) { free_cpumask_var(conn->allowed_cpumask); free_cpumask_var(conn->conn_cpumask); @@ -1156,7 +1156,7 @@ void iscsit_free_conn(struct iscsi_conn *conn) kfree(conn); } -void iscsi_target_login_sess_out(struct iscsi_conn *conn, +void iscsi_target_login_sess_out(struct iscsit_conn *conn, bool zero_tsih, bool new_sess) { if (!new_sess) @@ -1228,7 +1228,7 @@ static int __iscsi_target_login_thread(struct iscsi_np *np) { u8 *buffer, zero_tsih = 0; int ret = 0, rc; - struct iscsi_conn *conn = NULL; + struct iscsit_conn *conn = NULL; struct iscsi_login *login; struct iscsi_portal_group *tpg = NULL; struct iscsi_login_req *pdu; @@ -1371,7 +1371,7 @@ static int __iscsi_target_login_thread(struct iscsi_np *np) tpg = conn->tpg; if (!tpg) { - pr_err("Unable to locate struct iscsi_conn->tpg\n"); + pr_err("Unable to locate struct iscsit_conn->tpg\n"); goto new_sess_out; } diff --git a/drivers/target/iscsi/iscsi_target_login.h b/drivers/target/iscsi/iscsi_target_login.h index fc95e6150253..3ca2f232b387 100644 --- a/drivers/target/iscsi/iscsi_target_login.h +++ b/drivers/target/iscsi/iscsi_target_login.h @@ -4,25 +4,25 @@ #include -struct iscsi_conn; +struct iscsit_conn; struct iscsi_login; struct iscsi_np; struct sockaddr_storage; -extern int iscsi_login_setup_crypto(struct iscsi_conn *); -extern int iscsi_check_for_session_reinstatement(struct iscsi_conn *); -extern int iscsi_login_post_auth_non_zero_tsih(struct iscsi_conn *, u16, u32); +extern int iscsi_login_setup_crypto(struct iscsit_conn *); +extern int iscsi_check_for_session_reinstatement(struct iscsit_conn *); +extern int iscsi_login_post_auth_non_zero_tsih(struct iscsit_conn *, u16, u32); extern int iscsit_setup_np(struct iscsi_np *, struct sockaddr_storage *); extern int iscsi_target_setup_login_socket(struct iscsi_np *, struct sockaddr_storage *); -extern int iscsit_accept_np(struct iscsi_np *, struct iscsi_conn *); -extern int iscsit_get_login_rx(struct iscsi_conn *, struct iscsi_login *); -extern int iscsit_put_login_tx(struct iscsi_conn *, struct iscsi_login *, u32); -extern void iscsit_free_conn(struct iscsi_conn *); -extern int iscsit_start_kthreads(struct iscsi_conn *); -extern void iscsi_post_login_handler(struct iscsi_np *, struct iscsi_conn *, u8); -extern void iscsi_target_login_sess_out(struct iscsi_conn *, bool, bool); +extern int iscsit_accept_np(struct iscsi_np *, struct iscsit_conn *); +extern int iscsit_get_login_rx(struct iscsit_conn *, struct iscsi_login *); +extern int iscsit_put_login_tx(struct iscsit_conn *, struct iscsi_login *, u32); +extern void iscsit_free_conn(struct iscsit_conn *); +extern int iscsit_start_kthreads(struct iscsit_conn *); +extern void iscsi_post_login_handler(struct iscsi_np *, struct iscsit_conn *, u8); +extern void iscsi_target_login_sess_out(struct iscsit_conn *, bool, bool); extern int iscsi_target_login_thread(void *); extern void iscsi_handle_login_thread_timeout(struct timer_list *t); diff --git a/drivers/target/iscsi/iscsi_target_nego.c b/drivers/target/iscsi/iscsi_target_nego.c index b0cc8e0a10e8..b65c73fc6073 100644 --- a/drivers/target/iscsi/iscsi_target_nego.c +++ b/drivers/target/iscsi/iscsi_target_nego.c @@ -95,7 +95,7 @@ int extract_param( } static u32 iscsi_handle_authentication( - struct iscsi_conn *conn, + struct iscsit_conn *conn, char *in_buf, char *out_buf, int in_length, @@ -151,13 +151,13 @@ static u32 iscsi_handle_authentication( return 2; } -static void iscsi_remove_failed_auth_entry(struct iscsi_conn *conn) +static void iscsi_remove_failed_auth_entry(struct iscsit_conn *conn) { kfree(conn->auth_protocol); } int iscsi_target_check_login_request( - struct iscsi_conn *conn, + struct iscsit_conn *conn, struct iscsi_login *login) { int req_csg, req_nsg; @@ -248,7 +248,7 @@ int iscsi_target_check_login_request( EXPORT_SYMBOL(iscsi_target_check_login_request); static int iscsi_target_check_first_request( - struct iscsi_conn *conn, + struct iscsit_conn *conn, struct iscsi_login *login) { struct iscsi_param *param = NULL; @@ -315,7 +315,7 @@ static int iscsi_target_check_first_request( return 0; } -static int iscsi_target_do_tx_login_io(struct iscsi_conn *conn, struct iscsi_login *login) +static int iscsi_target_do_tx_login_io(struct iscsit_conn *conn, struct iscsi_login *login) { u32 padding = 0; struct iscsi_login_rsp *login_rsp; @@ -382,7 +382,7 @@ err: static void iscsi_target_sk_data_ready(struct sock *sk) { - struct iscsi_conn *conn = sk->sk_user_data; + struct iscsit_conn *conn = sk->sk_user_data; bool rc; pr_debug("Entering iscsi_target_sk_data_ready: conn: %p\n", conn); @@ -421,7 +421,7 @@ static void iscsi_target_sk_data_ready(struct sock *sk) static void iscsi_target_sk_state_change(struct sock *); -static void iscsi_target_set_sock_callbacks(struct iscsi_conn *conn) +static void iscsi_target_set_sock_callbacks(struct iscsit_conn *conn) { struct sock *sk; @@ -443,7 +443,7 @@ static void iscsi_target_set_sock_callbacks(struct iscsi_conn *conn) sk->sk_rcvtimeo = TA_LOGIN_TIMEOUT * HZ; } -static void iscsi_target_restore_sock_callbacks(struct iscsi_conn *conn) +static void iscsi_target_restore_sock_callbacks(struct iscsit_conn *conn) { struct sock *sk; @@ -467,7 +467,7 @@ static void iscsi_target_restore_sock_callbacks(struct iscsi_conn *conn) sk->sk_rcvtimeo = MAX_SCHEDULE_TIMEOUT; } -static int iscsi_target_do_login(struct iscsi_conn *, struct iscsi_login *); +static int iscsi_target_do_login(struct iscsit_conn *, struct iscsi_login *); static bool __iscsi_target_sk_check_close(struct sock *sk) { @@ -479,7 +479,7 @@ static bool __iscsi_target_sk_check_close(struct sock *sk) return false; } -static bool iscsi_target_sk_check_close(struct iscsi_conn *conn) +static bool iscsi_target_sk_check_close(struct iscsit_conn *conn) { bool state = false; @@ -494,7 +494,7 @@ static bool iscsi_target_sk_check_close(struct iscsi_conn *conn) return state; } -static bool iscsi_target_sk_check_flag(struct iscsi_conn *conn, unsigned int flag) +static bool iscsi_target_sk_check_flag(struct iscsit_conn *conn, unsigned int flag) { bool state = false; @@ -508,7 +508,7 @@ static bool iscsi_target_sk_check_flag(struct iscsi_conn *conn, unsigned int fla return state; } -static bool iscsi_target_sk_check_and_clear(struct iscsi_conn *conn, unsigned int flag) +static bool iscsi_target_sk_check_and_clear(struct iscsit_conn *conn, unsigned int flag) { bool state = false; @@ -525,7 +525,7 @@ static bool iscsi_target_sk_check_and_clear(struct iscsi_conn *conn, unsigned in return state; } -static void iscsi_target_login_drop(struct iscsi_conn *conn, struct iscsi_login *login) +static void iscsi_target_login_drop(struct iscsit_conn *conn, struct iscsi_login *login) { bool zero_tsih = login->zero_tsih; @@ -536,13 +536,13 @@ static void iscsi_target_login_drop(struct iscsi_conn *conn, struct iscsi_login struct conn_timeout { struct timer_list timer; - struct iscsi_conn *conn; + struct iscsit_conn *conn; }; static void iscsi_target_login_timeout(struct timer_list *t) { struct conn_timeout *timeout = from_timer(timeout, t, timer); - struct iscsi_conn *conn = timeout->conn; + struct iscsit_conn *conn = timeout->conn; pr_debug("Entering iscsi_target_login_timeout >>>>>>>>>>>>>>>>>>>\n"); @@ -555,8 +555,8 @@ static void iscsi_target_login_timeout(struct timer_list *t) static void iscsi_target_do_login_rx(struct work_struct *work) { - struct iscsi_conn *conn = container_of(work, - struct iscsi_conn, login_work.work); + struct iscsit_conn *conn = container_of(work, + struct iscsit_conn, login_work.work); struct iscsi_login *login = conn->login; struct iscsi_np *np = login->np; struct iscsi_portal_group *tpg = conn->tpg; @@ -662,7 +662,7 @@ err: static void iscsi_target_sk_state_change(struct sock *sk) { - struct iscsi_conn *conn; + struct iscsit_conn *conn; void (*orig_state_change)(struct sock *); bool state; @@ -741,7 +741,7 @@ static void iscsi_target_sk_state_change(struct sock *sk) * ISID/TSIH combinations. */ static int iscsi_target_check_for_existing_instances( - struct iscsi_conn *conn, + struct iscsit_conn *conn, struct iscsi_login *login) { if (login->checked_for_existing) @@ -757,7 +757,7 @@ static int iscsi_target_check_for_existing_instances( } static int iscsi_target_do_authentication( - struct iscsi_conn *conn, + struct iscsit_conn *conn, struct iscsi_login *login) { int authret; @@ -816,7 +816,7 @@ static int iscsi_target_do_authentication( } static int iscsi_target_handle_csg_zero( - struct iscsi_conn *conn, + struct iscsit_conn *conn, struct iscsi_login *login) { int ret; @@ -906,7 +906,7 @@ do_auth: return iscsi_target_do_authentication(conn, login); } -static int iscsi_target_handle_csg_one(struct iscsi_conn *conn, struct iscsi_login *login) +static int iscsi_target_handle_csg_one(struct iscsit_conn *conn, struct iscsi_login *login) { int ret; u32 payload_length; @@ -968,7 +968,7 @@ static int iscsi_target_handle_csg_one(struct iscsi_conn *conn, struct iscsi_log return 0; } -static int iscsi_target_do_login(struct iscsi_conn *conn, struct iscsi_login *login) +static int iscsi_target_do_login(struct iscsit_conn *conn, struct iscsi_login *login) { int pdu_count = 0; struct iscsi_login_req *login_req; @@ -1054,7 +1054,7 @@ static void iscsi_initiatorname_tolower( */ int iscsi_target_locate_portal( struct iscsi_np *np, - struct iscsi_conn *conn, + struct iscsit_conn *conn, struct iscsi_login *login) { char *i_buf = NULL, *s_buf = NULL, *t_buf = NULL; @@ -1287,7 +1287,7 @@ out: int iscsi_target_start_negotiation( struct iscsi_login *login, - struct iscsi_conn *conn) + struct iscsit_conn *conn) { int ret; @@ -1323,7 +1323,7 @@ int iscsi_target_start_negotiation( return ret; } -void iscsi_target_nego_release(struct iscsi_conn *conn) +void iscsi_target_nego_release(struct iscsit_conn *conn) { struct iscsi_login *login = conn->conn_login; diff --git a/drivers/target/iscsi/iscsi_target_nego.h b/drivers/target/iscsi/iscsi_target_nego.h index 835e1b769b3f..ed30b9ee75e6 100644 --- a/drivers/target/iscsi/iscsi_target_nego.h +++ b/drivers/target/iscsi/iscsi_target_nego.h @@ -5,21 +5,21 @@ #define DECIMAL 0 #define HEX 1 -struct iscsi_conn; +struct iscsit_conn; struct iscsi_login; struct iscsi_np; extern void convert_null_to_semi(char *, int); extern int extract_param(const char *, const char *, unsigned int, char *, unsigned char *); -extern int iscsi_target_check_login_request(struct iscsi_conn *, +extern int iscsi_target_check_login_request(struct iscsit_conn *, struct iscsi_login *); -extern int iscsi_target_get_initial_payload(struct iscsi_conn *, +extern int iscsi_target_get_initial_payload(struct iscsit_conn *, struct iscsi_login *); -extern int iscsi_target_locate_portal(struct iscsi_np *, struct iscsi_conn *, +extern int iscsi_target_locate_portal(struct iscsi_np *, struct iscsit_conn *, struct iscsi_login *); extern int iscsi_target_start_negotiation( - struct iscsi_login *, struct iscsi_conn *); -extern void iscsi_target_nego_release(struct iscsi_conn *); + struct iscsi_login *, struct iscsit_conn *); +extern void iscsi_target_nego_release(struct iscsit_conn *); #endif /* ISCSI_TARGET_NEGO_H */ diff --git a/drivers/target/iscsi/iscsi_target_nodeattrib.c b/drivers/target/iscsi/iscsi_target_nodeattrib.c index e3ac247bffe8..36671af6332f 100644 --- a/drivers/target/iscsi/iscsi_target_nodeattrib.c +++ b/drivers/target/iscsi/iscsi_target_nodeattrib.c @@ -97,7 +97,7 @@ int iscsit_na_nopin_timeout( { struct iscsi_node_attrib *a = &acl->node_attrib; struct iscsi_session *sess; - struct iscsi_conn *conn; + struct iscsit_conn *conn; struct se_node_acl *se_nacl = &a->nacl->se_node_acl; struct se_session *se_sess; u32 orig_nopin_timeout = a->nopin_timeout; diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c index 6bc3aaf655fc..2317fb077db0 100644 --- a/drivers/target/iscsi/iscsi_target_parameters.c +++ b/drivers/target/iscsi/iscsi_target_parameters.c @@ -15,7 +15,7 @@ #include "iscsi_target_parameters.h" int iscsi_login_rx_data( - struct iscsi_conn *conn, + struct iscsit_conn *conn, char *buf, int length) { @@ -37,7 +37,7 @@ int iscsi_login_rx_data( } int iscsi_login_tx_data( - struct iscsi_conn *conn, + struct iscsit_conn *conn, char *pdu_buf, char *text_buf, int text_length) @@ -955,7 +955,7 @@ out: } static int iscsi_check_acceptor_state(struct iscsi_param *param, char *value, - struct iscsi_conn *conn) + struct iscsit_conn *conn) { u8 acceptor_boolean_value = 0, proposer_boolean_value = 0; char *negotiated_value = NULL; @@ -1352,7 +1352,7 @@ int iscsi_decode_text_input( u8 sender, char *textbuf, u32 length, - struct iscsi_conn *conn) + struct iscsit_conn *conn) { struct iscsi_param_list *param_list = conn->param_list; char *tmpbuf, *start = NULL, *end = NULL; diff --git a/drivers/target/iscsi/iscsi_target_parameters.h b/drivers/target/iscsi/iscsi_target_parameters.h index 240c4c4344f6..00fbbebb8c75 100644 --- a/drivers/target/iscsi/iscsi_target_parameters.h +++ b/drivers/target/iscsi/iscsi_target_parameters.h @@ -25,13 +25,13 @@ struct iscsi_param { struct list_head p_list; } ____cacheline_aligned; -struct iscsi_conn; +struct iscsit_conn; struct iscsi_conn_ops; struct iscsi_param_list; struct iscsi_sess_ops; -extern int iscsi_login_rx_data(struct iscsi_conn *, char *, int); -extern int iscsi_login_tx_data(struct iscsi_conn *, char *, char *, int); +extern int iscsi_login_rx_data(struct iscsit_conn *, char *, int); +extern int iscsi_login_tx_data(struct iscsit_conn *, char *, char *, int); extern void iscsi_dump_conn_ops(struct iscsi_conn_ops *); extern void iscsi_dump_sess_ops(struct iscsi_sess_ops *); extern void iscsi_print_params(struct iscsi_param_list *); @@ -45,7 +45,7 @@ extern void iscsi_release_param_list(struct iscsi_param_list *); extern struct iscsi_param *iscsi_find_param_from_key(char *, struct iscsi_param_list *); extern int iscsi_extract_key_value(char *, char **, char **); extern int iscsi_update_param_value(struct iscsi_param *, char *); -extern int iscsi_decode_text_input(u8, u8, char *, u32, struct iscsi_conn *); +extern int iscsi_decode_text_input(u8, u8, char *, u32, struct iscsit_conn *); extern int iscsi_encode_text_output(u8, u8, char *, u32 *, struct iscsi_param_list *, bool); extern int iscsi_check_negotiated_keys(struct iscsi_param_list *); diff --git a/drivers/target/iscsi/iscsi_target_seq_pdu_list.c b/drivers/target/iscsi/iscsi_target_seq_pdu_list.c index 98aee976d79c..326efd762db0 100644 --- a/drivers/target/iscsi/iscsi_target_seq_pdu_list.c +++ b/drivers/target/iscsi/iscsi_target_seq_pdu_list.c @@ -208,7 +208,7 @@ static void iscsit_determine_counts_for_list( u32 burstlength = 0, offset = 0; u32 unsolicited_data_length = 0; u32 mdsl; - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; if (cmd->se_cmd.data_direction == DMA_TO_DEVICE) mdsl = cmd->conn->conn_ops->MaxXmitDataSegmentLength; @@ -289,7 +289,7 @@ static int iscsit_do_build_pdu_and_seq_lists( int check_immediate = 0, datapduinorder, datasequenceinorder; u32 burstlength = 0, offset = 0, i = 0, mdsl; u32 pdu_count = 0, seq_no = 0, unsolicited_data_length = 0; - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct iscsi_pdu *pdu = cmd->pdu_list; struct iscsi_seq *seq = cmd->seq_list; @@ -489,7 +489,7 @@ int iscsit_build_pdu_and_seq_lists( { struct iscsi_build_list bl; u32 pdu_count = 0, seq_count = 1; - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct iscsi_pdu *pdu = NULL; struct iscsi_seq *seq = NULL; @@ -587,7 +587,7 @@ struct iscsi_pdu *iscsit_get_pdu_holder_for_seq( struct iscsi_seq *seq) { u32 i; - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct iscsi_pdu *pdu = NULL; if (!cmd->pdu_list) { diff --git a/drivers/target/iscsi/iscsi_target_tmr.c b/drivers/target/iscsi/iscsi_target_tmr.c index aa062c3166c2..e3c3a08db1e0 100644 --- a/drivers/target/iscsi/iscsi_target_tmr.c +++ b/drivers/target/iscsi/iscsi_target_tmr.c @@ -32,7 +32,7 @@ u8 iscsit_tmr_abort_task( unsigned char *buf) { struct iscsit_cmd *ref_cmd; - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct iscsi_tmr_req *tmr_req = cmd->tmr_req; struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req; struct iscsi_tm *hdr = (struct iscsi_tm *) buf; @@ -63,7 +63,7 @@ u8 iscsit_tmr_abort_task( * Called from iscsit_handle_task_mgt_cmd(). */ int iscsit_tmr_task_warm_reset( - struct iscsi_conn *conn, + struct iscsit_conn *conn, struct iscsi_tmr_req *tmr_req, unsigned char *buf) { @@ -83,7 +83,7 @@ int iscsit_tmr_task_warm_reset( } int iscsit_tmr_task_cold_reset( - struct iscsi_conn *conn, + struct iscsit_conn *conn, struct iscsi_tmr_req *tmr_req, unsigned char *buf) { @@ -107,7 +107,7 @@ u8 iscsit_tmr_task_reassign( unsigned char *buf) { struct iscsit_cmd *ref_cmd = NULL; - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct iscsi_conn_recovery *cr = NULL; struct iscsi_tmr_req *tmr_req = cmd->tmr_req; struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req; @@ -193,7 +193,7 @@ static void iscsit_task_reassign_remove_cmd( static int iscsit_task_reassign_complete_nop_out( struct iscsi_tmr_req *tmr_req, - struct iscsi_conn *conn) + struct iscsit_conn *conn) { struct iscsit_cmd *cmd = tmr_req->ref_cmd; struct iscsi_conn_recovery *cr; @@ -229,7 +229,7 @@ static int iscsit_task_reassign_complete_write( { int no_build_r2ts = 0; u32 length = 0, offset = 0; - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct se_cmd *se_cmd = &cmd->se_cmd; /* * The Initiator must not send a R2T SNACK with a Begrun less than @@ -299,7 +299,7 @@ static int iscsit_task_reassign_complete_read( struct iscsit_cmd *cmd, struct iscsi_tmr_req *tmr_req) { - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct iscsi_datain_req *dr; struct se_cmd *se_cmd = &cmd->se_cmd; /* @@ -352,7 +352,7 @@ static int iscsit_task_reassign_complete_none( struct iscsit_cmd *cmd, struct iscsi_tmr_req *tmr_req) { - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; cmd->i_state = ISTATE_SEND_STATUS; iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state); @@ -361,7 +361,7 @@ static int iscsit_task_reassign_complete_none( static int iscsit_task_reassign_complete_scsi_cmnd( struct iscsi_tmr_req *tmr_req, - struct iscsi_conn *conn) + struct iscsit_conn *conn) { struct iscsit_cmd *cmd = tmr_req->ref_cmd; struct iscsi_conn_recovery *cr; @@ -410,7 +410,7 @@ static int iscsit_task_reassign_complete_scsi_cmnd( static int iscsit_task_reassign_complete( struct iscsi_tmr_req *tmr_req, - struct iscsi_conn *conn) + struct iscsit_conn *conn) { struct iscsit_cmd *cmd; int ret = 0; @@ -451,7 +451,7 @@ static int iscsit_task_reassign_complete( * Right now the only one that its really needed for is * connection recovery releated TASK_REASSIGN. */ -int iscsit_tmr_post_handler(struct iscsit_cmd *cmd, struct iscsi_conn *conn) +int iscsit_tmr_post_handler(struct iscsit_cmd *cmd, struct iscsit_conn *conn) { struct iscsi_tmr_req *tmr_req = cmd->tmr_req; struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req; @@ -469,14 +469,14 @@ EXPORT_SYMBOL(iscsit_tmr_post_handler); */ static int iscsit_task_reassign_prepare_read( struct iscsi_tmr_req *tmr_req, - struct iscsi_conn *conn) + struct iscsit_conn *conn) { return 0; } static void iscsit_task_reassign_prepare_unsolicited_dataout( struct iscsit_cmd *cmd, - struct iscsi_conn *conn) + struct iscsit_conn *conn) { int i, j; struct iscsi_pdu *pdu = NULL; @@ -544,7 +544,7 @@ static void iscsit_task_reassign_prepare_unsolicited_dataout( static int iscsit_task_reassign_prepare_write( struct iscsi_tmr_req *tmr_req, - struct iscsi_conn *conn) + struct iscsit_conn *conn) { struct iscsit_cmd *cmd = tmr_req->ref_cmd; struct iscsi_pdu *pdu = NULL; @@ -777,7 +777,7 @@ drop_unacknowledged_r2ts: */ int iscsit_check_task_reassign_expdatasn( struct iscsi_tmr_req *tmr_req, - struct iscsi_conn *conn) + struct iscsit_conn *conn) { struct iscsit_cmd *ref_cmd = tmr_req->ref_cmd; diff --git a/drivers/target/iscsi/iscsi_target_tmr.h b/drivers/target/iscsi/iscsi_target_tmr.h index 60aac3a8f3c0..3413d0f596c8 100644 --- a/drivers/target/iscsi/iscsi_target_tmr.h +++ b/drivers/target/iscsi/iscsi_target_tmr.h @@ -5,17 +5,17 @@ #include struct iscsit_cmd; -struct iscsi_conn; +struct iscsit_conn; struct iscsi_tmr_req; extern u8 iscsit_tmr_abort_task(struct iscsit_cmd *, unsigned char *); -extern int iscsit_tmr_task_warm_reset(struct iscsi_conn *, struct iscsi_tmr_req *, +extern int iscsit_tmr_task_warm_reset(struct iscsit_conn *, struct iscsi_tmr_req *, unsigned char *); -extern int iscsit_tmr_task_cold_reset(struct iscsi_conn *, struct iscsi_tmr_req *, +extern int iscsit_tmr_task_cold_reset(struct iscsit_conn *, struct iscsi_tmr_req *, unsigned char *); extern u8 iscsit_tmr_task_reassign(struct iscsit_cmd *, unsigned char *); -extern int iscsit_tmr_post_handler(struct iscsit_cmd *, struct iscsi_conn *); +extern int iscsit_tmr_post_handler(struct iscsit_cmd *, struct iscsit_conn *); extern int iscsit_check_task_reassign_expdatasn(struct iscsi_tmr_req *, - struct iscsi_conn *); + struct iscsit_conn *); #endif /* ISCSI_TARGET_TMR_H */ diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c index 39b705c34f95..be50f857d1b1 100644 --- a/drivers/target/iscsi/iscsi_target_util.c +++ b/drivers/target/iscsi/iscsi_target_util.c @@ -152,7 +152,7 @@ static int iscsit_wait_for_tag(struct se_session *se_sess, int state, int *cpup) * May be called from software interrupt (timer) context for allocating * iSCSI NopINs. */ -struct iscsit_cmd *iscsit_allocate_cmd(struct iscsi_conn *conn, int state) +struct iscsit_cmd *iscsit_allocate_cmd(struct iscsit_conn *conn, int state) { struct iscsit_cmd *cmd; struct se_session *se_sess = conn->sess->se_sess; @@ -282,7 +282,7 @@ static inline int iscsit_check_received_cmdsn(struct iscsi_session *sess, u32 cm * Commands may be received out of order if MC/S is in use. * Ensure they are executed in CmdSN order. */ -int iscsit_sequence_cmd(struct iscsi_conn *conn, struct iscsit_cmd *cmd, +int iscsit_sequence_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, unsigned char *buf, __be32 cmdsn) { int ret, cmdsn_ret; @@ -335,7 +335,7 @@ EXPORT_SYMBOL(iscsit_sequence_cmd); int iscsit_check_unsolicited_dataout(struct iscsit_cmd *cmd, unsigned char *buf) { - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; struct se_cmd *se_cmd = &cmd->se_cmd; struct iscsi_data *hdr = (struct iscsi_data *) buf; u32 payload_length = ntoh24(hdr->dlength); @@ -378,7 +378,7 @@ int iscsit_check_unsolicited_dataout(struct iscsit_cmd *cmd, unsigned char *buf) } struct iscsit_cmd *iscsit_find_cmd_from_itt( - struct iscsi_conn *conn, + struct iscsit_conn *conn, itt_t init_task_tag) { struct iscsit_cmd *cmd; @@ -399,7 +399,7 @@ struct iscsit_cmd *iscsit_find_cmd_from_itt( EXPORT_SYMBOL(iscsit_find_cmd_from_itt); struct iscsit_cmd *iscsit_find_cmd_from_itt_or_dump( - struct iscsi_conn *conn, + struct iscsit_conn *conn, itt_t init_task_tag, u32 length) { @@ -426,7 +426,7 @@ struct iscsit_cmd *iscsit_find_cmd_from_itt_or_dump( EXPORT_SYMBOL(iscsit_find_cmd_from_itt_or_dump); struct iscsit_cmd *iscsit_find_cmd_from_ttt( - struct iscsi_conn *conn, + struct iscsit_conn *conn, u32 targ_xfer_tag) { struct iscsit_cmd *cmd = NULL; @@ -499,7 +499,7 @@ int iscsit_find_cmd_for_recovery( void iscsit_add_cmd_to_immediate_queue( struct iscsit_cmd *cmd, - struct iscsi_conn *conn, + struct iscsit_conn *conn, u8 state) { struct iscsi_queue_req *qr; @@ -524,7 +524,7 @@ void iscsit_add_cmd_to_immediate_queue( } EXPORT_SYMBOL(iscsit_add_cmd_to_immediate_queue); -struct iscsi_queue_req *iscsit_get_cmd_from_immediate_queue(struct iscsi_conn *conn) +struct iscsi_queue_req *iscsit_get_cmd_from_immediate_queue(struct iscsit_conn *conn) { struct iscsi_queue_req *qr; @@ -546,7 +546,7 @@ struct iscsi_queue_req *iscsit_get_cmd_from_immediate_queue(struct iscsi_conn *c static void iscsit_remove_cmd_from_immediate_queue( struct iscsit_cmd *cmd, - struct iscsi_conn *conn) + struct iscsit_conn *conn) { struct iscsi_queue_req *qr, *qr_tmp; @@ -575,7 +575,7 @@ static void iscsit_remove_cmd_from_immediate_queue( int iscsit_add_cmd_to_response_queue( struct iscsit_cmd *cmd, - struct iscsi_conn *conn, + struct iscsit_conn *conn, u8 state) { struct iscsi_queue_req *qr; @@ -599,7 +599,7 @@ int iscsit_add_cmd_to_response_queue( return 0; } -struct iscsi_queue_req *iscsit_get_cmd_from_response_queue(struct iscsi_conn *conn) +struct iscsi_queue_req *iscsit_get_cmd_from_response_queue(struct iscsit_conn *conn) { struct iscsi_queue_req *qr; @@ -622,7 +622,7 @@ struct iscsi_queue_req *iscsit_get_cmd_from_response_queue(struct iscsi_conn *co static void iscsit_remove_cmd_from_response_queue( struct iscsit_cmd *cmd, - struct iscsi_conn *conn) + struct iscsit_conn *conn) { struct iscsi_queue_req *qr, *qr_tmp; @@ -650,7 +650,7 @@ static void iscsit_remove_cmd_from_response_queue( } } -bool iscsit_conn_all_queues_empty(struct iscsi_conn *conn) +bool iscsit_conn_all_queues_empty(struct iscsit_conn *conn) { bool empty; @@ -668,7 +668,7 @@ bool iscsit_conn_all_queues_empty(struct iscsi_conn *conn) return empty; } -void iscsit_free_queue_reqs_for_conn(struct iscsi_conn *conn) +void iscsit_free_queue_reqs_for_conn(struct iscsit_conn *conn) { struct iscsi_queue_req *qr, *qr_tmp; @@ -722,7 +722,7 @@ EXPORT_SYMBOL(iscsit_release_cmd); void __iscsit_free_cmd(struct iscsit_cmd *cmd, bool check_queues) { - struct iscsi_conn *conn = cmd->conn; + struct iscsit_conn *conn = cmd->conn; WARN_ON(!list_empty(&cmd->i_conn_node)); @@ -798,9 +798,9 @@ void iscsit_inc_session_usage_count(struct iscsi_session *sess) spin_unlock_bh(&sess->session_usage_lock); } -struct iscsi_conn *iscsit_get_conn_from_cid(struct iscsi_session *sess, u16 cid) +struct iscsit_conn *iscsit_get_conn_from_cid(struct iscsi_session *sess, u16 cid) { - struct iscsi_conn *conn; + struct iscsit_conn *conn; spin_lock_bh(&sess->conn_lock); list_for_each_entry(conn, &sess->sess_conn_list, conn_list) { @@ -816,9 +816,9 @@ struct iscsi_conn *iscsit_get_conn_from_cid(struct iscsi_session *sess, u16 cid) return NULL; } -struct iscsi_conn *iscsit_get_conn_from_cid_rcfr(struct iscsi_session *sess, u16 cid) +struct iscsit_conn *iscsit_get_conn_from_cid_rcfr(struct iscsi_session *sess, u16 cid) { - struct iscsi_conn *conn; + struct iscsit_conn *conn; spin_lock_bh(&sess->conn_lock); list_for_each_entry(conn, &sess->sess_conn_list, conn_list) { @@ -836,7 +836,7 @@ struct iscsi_conn *iscsit_get_conn_from_cid_rcfr(struct iscsi_session *sess, u16 return NULL; } -void iscsit_check_conn_usage_count(struct iscsi_conn *conn) +void iscsit_check_conn_usage_count(struct iscsit_conn *conn) { spin_lock_bh(&conn->conn_usage_lock); if (conn->conn_usage_count != 0) { @@ -849,7 +849,7 @@ void iscsit_check_conn_usage_count(struct iscsi_conn *conn) spin_unlock_bh(&conn->conn_usage_lock); } -void iscsit_dec_conn_usage_count(struct iscsi_conn *conn) +void iscsit_dec_conn_usage_count(struct iscsit_conn *conn) { spin_lock_bh(&conn->conn_usage_lock); conn->conn_usage_count--; @@ -860,14 +860,14 @@ void iscsit_dec_conn_usage_count(struct iscsi_conn *conn) spin_unlock_bh(&conn->conn_usage_lock); } -void iscsit_inc_conn_usage_count(struct iscsi_conn *conn) +void iscsit_inc_conn_usage_count(struct iscsit_conn *conn) { spin_lock_bh(&conn->conn_usage_lock); conn->conn_usage_count++; spin_unlock_bh(&conn->conn_usage_lock); } -static int iscsit_add_nopin(struct iscsi_conn *conn, int want_response) +static int iscsit_add_nopin(struct iscsit_conn *conn, int want_response) { u8 state; struct iscsit_cmd *cmd; @@ -895,7 +895,7 @@ static int iscsit_add_nopin(struct iscsi_conn *conn, int want_response) void iscsit_handle_nopin_response_timeout(struct timer_list *t) { - struct iscsi_conn *conn = from_timer(conn, t, nopin_response_timer); + struct iscsit_conn *conn = from_timer(conn, t, nopin_response_timer); struct iscsi_session *sess = conn->sess; iscsit_inc_conn_usage_count(conn); @@ -919,7 +919,7 @@ void iscsit_handle_nopin_response_timeout(struct timer_list *t) iscsit_dec_conn_usage_count(conn); } -void iscsit_mod_nopin_response_timer(struct iscsi_conn *conn) +void iscsit_mod_nopin_response_timer(struct iscsit_conn *conn) { struct iscsi_session *sess = conn->sess; struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess); @@ -935,7 +935,7 @@ void iscsit_mod_nopin_response_timer(struct iscsi_conn *conn) spin_unlock_bh(&conn->nopin_timer_lock); } -void iscsit_start_nopin_response_timer(struct iscsi_conn *conn) +void iscsit_start_nopin_response_timer(struct iscsit_conn *conn) { struct iscsi_session *sess = conn->sess; struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess); @@ -956,7 +956,7 @@ void iscsit_start_nopin_response_timer(struct iscsi_conn *conn) spin_unlock_bh(&conn->nopin_timer_lock); } -void iscsit_stop_nopin_response_timer(struct iscsi_conn *conn) +void iscsit_stop_nopin_response_timer(struct iscsit_conn *conn) { spin_lock_bh(&conn->nopin_timer_lock); if (!(conn->nopin_response_timer_flags & ISCSI_TF_RUNNING)) { @@ -975,7 +975,7 @@ void iscsit_stop_nopin_response_timer(struct iscsi_conn *conn) void iscsit_handle_nopin_timeout(struct timer_list *t) { - struct iscsi_conn *conn = from_timer(conn, t, nopin_timer); + struct iscsit_conn *conn = from_timer(conn, t, nopin_timer); iscsit_inc_conn_usage_count(conn); @@ -992,7 +992,7 @@ void iscsit_handle_nopin_timeout(struct timer_list *t) iscsit_dec_conn_usage_count(conn); } -void __iscsit_start_nopin_timer(struct iscsi_conn *conn) +void __iscsit_start_nopin_timer(struct iscsit_conn *conn) { struct iscsi_session *sess = conn->sess; struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess); @@ -1016,14 +1016,14 @@ void __iscsit_start_nopin_timer(struct iscsi_conn *conn) " interval\n", conn->cid, na->nopin_timeout); } -void iscsit_start_nopin_timer(struct iscsi_conn *conn) +void iscsit_start_nopin_timer(struct iscsit_conn *conn) { spin_lock_bh(&conn->nopin_timer_lock); __iscsit_start_nopin_timer(conn); spin_unlock_bh(&conn->nopin_timer_lock); } -void iscsit_stop_nopin_timer(struct iscsi_conn *conn) +void iscsit_stop_nopin_timer(struct iscsit_conn *conn) { spin_lock_bh(&conn->nopin_timer_lock); if (!(conn->nopin_timer_flags & ISCSI_TF_RUNNING)) { @@ -1042,7 +1042,7 @@ void iscsit_stop_nopin_timer(struct iscsi_conn *conn) int iscsit_send_tx_data( struct iscsit_cmd *cmd, - struct iscsi_conn *conn, + struct iscsit_conn *conn, int use_misc) { int tx_sent, tx_size; @@ -1075,7 +1075,7 @@ send_data: int iscsit_fe_sendpage_sg( struct iscsit_cmd *cmd, - struct iscsi_conn *conn) + struct iscsit_conn *conn) { struct scatterlist *sg = cmd->first_data_sg; struct kvec iov; @@ -1179,7 +1179,7 @@ send_datacrc: * Parameters: iSCSI Connection, Status Class, Status Detail. * Returns: 0 on success, -1 on error. */ -int iscsit_tx_login_rsp(struct iscsi_conn *conn, u8 status_class, u8 status_detail) +int iscsit_tx_login_rsp(struct iscsit_conn *conn, u8 status_class, u8 status_detail) { struct iscsi_login_rsp *hdr; struct iscsi_login *login = conn->conn_login; @@ -1200,7 +1200,7 @@ int iscsit_tx_login_rsp(struct iscsi_conn *conn, u8 status_class, u8 status_deta void iscsit_print_session_params(struct iscsi_session *sess) { - struct iscsi_conn *conn; + struct iscsit_conn *conn; pr_debug("-----------------------------[Session Params for" " SID: %u]-----------------------------\n", sess->sid); @@ -1213,7 +1213,7 @@ void iscsit_print_session_params(struct iscsi_session *sess) } int rx_data( - struct iscsi_conn *conn, + struct iscsit_conn *conn, struct kvec *iov, int iov_count, int data) @@ -1243,7 +1243,7 @@ int rx_data( } int tx_data( - struct iscsi_conn *conn, + struct iscsit_conn *conn, struct kvec *iov, int iov_count, int data) @@ -1279,7 +1279,7 @@ int tx_data( } void iscsit_collect_login_stats( - struct iscsi_conn *conn, + struct iscsit_conn *conn, u8 status_class, u8 status_detail) { @@ -1334,7 +1334,7 @@ void iscsit_collect_login_stats( spin_unlock(&ls->lock); } -struct iscsi_tiqn *iscsit_snmp_get_tiqn(struct iscsi_conn *conn) +struct iscsi_tiqn *iscsit_snmp_get_tiqn(struct iscsit_conn *conn) { struct iscsi_portal_group *tpg; diff --git a/drivers/target/iscsi/iscsi_target_util.h b/drivers/target/iscsi/iscsi_target_util.h index dec142ed4704..dcdcdfe4fd7e 100644 --- a/drivers/target/iscsi/iscsi_target_util.h +++ b/drivers/target/iscsi/iscsi_target_util.h @@ -8,7 +8,7 @@ #define MARKER_SIZE 8 struct iscsit_cmd; -struct iscsi_conn; +struct iscsit_conn; struct iscsi_conn_recovery; struct iscsi_session; @@ -17,56 +17,56 @@ extern struct iscsi_r2t *iscsit_get_r2t_for_eos(struct iscsit_cmd *, u32, u32); extern struct iscsi_r2t *iscsit_get_r2t_from_list(struct iscsit_cmd *); extern void iscsit_free_r2t(struct iscsi_r2t *, struct iscsit_cmd *); extern void iscsit_free_r2ts_from_list(struct iscsit_cmd *); -extern struct iscsit_cmd *iscsit_alloc_cmd(struct iscsi_conn *, gfp_t); -extern struct iscsit_cmd *iscsit_allocate_cmd(struct iscsi_conn *, int); +extern struct iscsit_cmd *iscsit_alloc_cmd(struct iscsit_conn *, gfp_t); +extern struct iscsit_cmd *iscsit_allocate_cmd(struct iscsit_conn *, int); extern struct iscsi_seq *iscsit_get_seq_holder_for_datain(struct iscsit_cmd *, u32); extern struct iscsi_seq *iscsit_get_seq_holder_for_r2t(struct iscsit_cmd *); extern struct iscsi_r2t *iscsit_get_holder_for_r2tsn(struct iscsit_cmd *, u32); -extern int iscsit_sequence_cmd(struct iscsi_conn *conn, struct iscsit_cmd *cmd, +extern int iscsit_sequence_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, unsigned char * ,__be32 cmdsn); extern int iscsit_check_unsolicited_dataout(struct iscsit_cmd *, unsigned char *); -extern struct iscsit_cmd *iscsit_find_cmd_from_itt_or_dump(struct iscsi_conn *, +extern struct iscsit_cmd *iscsit_find_cmd_from_itt_or_dump(struct iscsit_conn *, itt_t, u32); -extern struct iscsit_cmd *iscsit_find_cmd_from_ttt(struct iscsi_conn *, u32); +extern struct iscsit_cmd *iscsit_find_cmd_from_ttt(struct iscsit_conn *, u32); extern int iscsit_find_cmd_for_recovery(struct iscsi_session *, struct iscsit_cmd **, struct iscsi_conn_recovery **, itt_t); -extern void iscsit_add_cmd_to_immediate_queue(struct iscsit_cmd *, struct iscsi_conn *, u8); -extern struct iscsi_queue_req *iscsit_get_cmd_from_immediate_queue(struct iscsi_conn *); -extern int iscsit_add_cmd_to_response_queue(struct iscsit_cmd *, struct iscsi_conn *, u8); -extern struct iscsi_queue_req *iscsit_get_cmd_from_response_queue(struct iscsi_conn *); -extern void iscsit_remove_cmd_from_tx_queues(struct iscsit_cmd *, struct iscsi_conn *); -extern bool iscsit_conn_all_queues_empty(struct iscsi_conn *); -extern void iscsit_free_queue_reqs_for_conn(struct iscsi_conn *); +extern void iscsit_add_cmd_to_immediate_queue(struct iscsit_cmd *, struct iscsit_conn *, u8); +extern struct iscsi_queue_req *iscsit_get_cmd_from_immediate_queue(struct iscsit_conn *); +extern int iscsit_add_cmd_to_response_queue(struct iscsit_cmd *, struct iscsit_conn *, u8); +extern struct iscsi_queue_req *iscsit_get_cmd_from_response_queue(struct iscsit_conn *); +extern void iscsit_remove_cmd_from_tx_queues(struct iscsit_cmd *, struct iscsit_conn *); +extern bool iscsit_conn_all_queues_empty(struct iscsit_conn *); +extern void iscsit_free_queue_reqs_for_conn(struct iscsit_conn *); extern void iscsit_release_cmd(struct iscsit_cmd *); extern void __iscsit_free_cmd(struct iscsit_cmd *, bool); extern void iscsit_free_cmd(struct iscsit_cmd *, bool); extern bool iscsit_check_session_usage_count(struct iscsi_session *sess, bool can_sleep); extern void iscsit_dec_session_usage_count(struct iscsi_session *); extern void iscsit_inc_session_usage_count(struct iscsi_session *); -extern struct iscsi_conn *iscsit_get_conn_from_cid(struct iscsi_session *, u16); -extern struct iscsi_conn *iscsit_get_conn_from_cid_rcfr(struct iscsi_session *, u16); -extern void iscsit_check_conn_usage_count(struct iscsi_conn *); -extern void iscsit_dec_conn_usage_count(struct iscsi_conn *); -extern void iscsit_inc_conn_usage_count(struct iscsi_conn *); +extern struct iscsit_conn *iscsit_get_conn_from_cid(struct iscsi_session *, u16); +extern struct iscsit_conn *iscsit_get_conn_from_cid_rcfr(struct iscsi_session *, u16); +extern void iscsit_check_conn_usage_count(struct iscsit_conn *); +extern void iscsit_dec_conn_usage_count(struct iscsit_conn *); +extern void iscsit_inc_conn_usage_count(struct iscsit_conn *); extern void iscsit_handle_nopin_response_timeout(struct timer_list *t); -extern void iscsit_mod_nopin_response_timer(struct iscsi_conn *); -extern void iscsit_start_nopin_response_timer(struct iscsi_conn *); -extern void iscsit_stop_nopin_response_timer(struct iscsi_conn *); +extern void iscsit_mod_nopin_response_timer(struct iscsit_conn *); +extern void iscsit_start_nopin_response_timer(struct iscsit_conn *); +extern void iscsit_stop_nopin_response_timer(struct iscsit_conn *); extern void iscsit_handle_nopin_timeout(struct timer_list *t); -extern void __iscsit_start_nopin_timer(struct iscsi_conn *); -extern void iscsit_start_nopin_timer(struct iscsi_conn *); -extern void iscsit_stop_nopin_timer(struct iscsi_conn *); -extern int iscsit_send_tx_data(struct iscsit_cmd *, struct iscsi_conn *, int); -extern int iscsit_fe_sendpage_sg(struct iscsit_cmd *, struct iscsi_conn *); -extern int iscsit_tx_login_rsp(struct iscsi_conn *, u8, u8); +extern void __iscsit_start_nopin_timer(struct iscsit_conn *); +extern void iscsit_start_nopin_timer(struct iscsit_conn *); +extern void iscsit_stop_nopin_timer(struct iscsit_conn *); +extern int iscsit_send_tx_data(struct iscsit_cmd *, struct iscsit_conn *, int); +extern int iscsit_fe_sendpage_sg(struct iscsit_cmd *, struct iscsit_conn *); +extern int iscsit_tx_login_rsp(struct iscsit_conn *, u8, u8); extern void iscsit_print_session_params(struct iscsi_session *); extern int iscsit_print_dev_to_proc(char *, char **, off_t, int); extern int iscsit_print_sessions_to_proc(char *, char **, off_t, int); extern int iscsit_print_tpg_to_proc(char *, char **, off_t, int); -extern int rx_data(struct iscsi_conn *, struct kvec *, int, int); -extern int tx_data(struct iscsi_conn *, struct kvec *, int, int); -extern void iscsit_collect_login_stats(struct iscsi_conn *, u8, u8); -extern struct iscsi_tiqn *iscsit_snmp_get_tiqn(struct iscsi_conn *); +extern int rx_data(struct iscsit_conn *, struct kvec *, int, int); +extern int tx_data(struct iscsit_conn *, struct kvec *, int, int); +extern void iscsit_collect_login_stats(struct iscsit_conn *, u8, u8); +extern struct iscsi_tiqn *iscsit_snmp_get_tiqn(struct iscsit_conn *); extern void iscsit_fill_cxn_timeout_err_stats(struct iscsi_session *); #endif /*** ISCSI_TARGET_UTIL_H ***/ diff --git a/include/target/iscsi/iscsi_target_core.h b/include/target/iscsi/iscsi_target_core.h index 4f9ef2899488..76581e0f3d98 100644 --- a/include/target/iscsi/iscsi_target_core.h +++ b/include/target/iscsi/iscsi_target_core.h @@ -478,7 +478,7 @@ struct iscsit_cmd { /* TMR Request when iscsi_opcode == ISCSI_OP_SCSI_TMFUNC */ struct iscsi_tmr_req *tmr_req; /* Connection this command is alligient to */ - struct iscsi_conn *conn; + struct iscsit_conn *conn; /* Pointer to connection recovery entry */ struct iscsi_conn_recovery *cr; /* Session the command is part of, used for connection recovery */ @@ -508,7 +508,7 @@ struct iscsi_tmr_req { struct se_tmr_req *se_tmr_req; }; -struct iscsi_conn { +struct iscsit_conn { wait_queue_head_t queues_wq; /* Authentication Successful for this connection */ u8 auth_complete; @@ -710,7 +710,7 @@ struct iscsi_login { char rsp[ISCSI_HDR_LEN]; char *req_buf; char *rsp_buf; - struct iscsi_conn *conn; + struct iscsit_conn *conn; struct iscsi_np *np; } ____cacheline_aligned; @@ -898,9 +898,9 @@ static inline u32 session_get_next_ttt(struct iscsi_session *session) return ttt; } -extern struct iscsit_cmd *iscsit_find_cmd_from_itt(struct iscsi_conn *, itt_t); +extern struct iscsit_cmd *iscsit_find_cmd_from_itt(struct iscsit_conn *, itt_t); -extern void iscsit_thread_check_cpumask(struct iscsi_conn *conn, +extern void iscsit_thread_check_cpumask(struct iscsit_conn *conn, struct task_struct *p, int mode); diff --git a/include/target/iscsi/iscsi_transport.h b/include/target/iscsi/iscsi_transport.h index 645de3542022..2ab26bb6f808 100644 --- a/include/target/iscsi/iscsi_transport.h +++ b/include/target/iscsi/iscsi_transport.h @@ -12,26 +12,26 @@ struct iscsit_transport { struct module *owner; struct list_head t_node; int (*iscsit_setup_np)(struct iscsi_np *, struct sockaddr_storage *); - int (*iscsit_accept_np)(struct iscsi_np *, struct iscsi_conn *); + int (*iscsit_accept_np)(struct iscsi_np *, struct iscsit_conn *); void (*iscsit_free_np)(struct iscsi_np *); - void (*iscsit_wait_conn)(struct iscsi_conn *); - void (*iscsit_free_conn)(struct iscsi_conn *); - int (*iscsit_get_login_rx)(struct iscsi_conn *, struct iscsi_login *); - int (*iscsit_put_login_tx)(struct iscsi_conn *, struct iscsi_login *, u32); - int (*iscsit_immediate_queue)(struct iscsi_conn *, struct iscsit_cmd *, int); - int (*iscsit_response_queue)(struct iscsi_conn *, struct iscsit_cmd *, int); - int (*iscsit_get_dataout)(struct iscsi_conn *, struct iscsit_cmd *, bool); - int (*iscsit_queue_data_in)(struct iscsi_conn *, struct iscsit_cmd *); - int (*iscsit_queue_status)(struct iscsi_conn *, struct iscsit_cmd *); - void (*iscsit_aborted_task)(struct iscsi_conn *, struct iscsit_cmd *); - int (*iscsit_xmit_pdu)(struct iscsi_conn *, struct iscsit_cmd *, + void (*iscsit_wait_conn)(struct iscsit_conn *); + void (*iscsit_free_conn)(struct iscsit_conn *); + int (*iscsit_get_login_rx)(struct iscsit_conn *, struct iscsi_login *); + int (*iscsit_put_login_tx)(struct iscsit_conn *, struct iscsi_login *, u32); + int (*iscsit_immediate_queue)(struct iscsit_conn *, struct iscsit_cmd *, int); + int (*iscsit_response_queue)(struct iscsit_conn *, struct iscsit_cmd *, int); + int (*iscsit_get_dataout)(struct iscsit_conn *, struct iscsit_cmd *, bool); + int (*iscsit_queue_data_in)(struct iscsit_conn *, struct iscsit_cmd *); + int (*iscsit_queue_status)(struct iscsit_conn *, struct iscsit_cmd *); + void (*iscsit_aborted_task)(struct iscsit_conn *, struct iscsit_cmd *); + int (*iscsit_xmit_pdu)(struct iscsit_conn *, struct iscsit_cmd *, struct iscsi_datain_req *, const void *, u32); - void (*iscsit_unmap_cmd)(struct iscsi_conn *, struct iscsit_cmd *); - void (*iscsit_get_rx_pdu)(struct iscsi_conn *); - int (*iscsit_validate_params)(struct iscsi_conn *); - void (*iscsit_get_r2t_ttt)(struct iscsi_conn *, struct iscsit_cmd *, + void (*iscsit_unmap_cmd)(struct iscsit_conn *, struct iscsit_cmd *); + void (*iscsit_get_rx_pdu)(struct iscsit_conn *); + int (*iscsit_validate_params)(struct iscsit_conn *); + void (*iscsit_get_r2t_ttt)(struct iscsit_conn *, struct iscsit_cmd *, struct iscsi_r2t *); - enum target_prot_op (*iscsit_get_sup_prot_ops)(struct iscsi_conn *); + enum target_prot_op (*iscsit_get_sup_prot_ops)(struct iscsit_conn *); }; static inline void *iscsit_priv_cmd(struct iscsit_cmd *cmd) @@ -51,57 +51,57 @@ extern void iscsit_put_transport(struct iscsit_transport *); /* * From iscsi_target.c */ -extern int iscsit_setup_scsi_cmd(struct iscsi_conn *, struct iscsit_cmd *, +extern int iscsit_setup_scsi_cmd(struct iscsit_conn *, struct iscsit_cmd *, unsigned char *); extern void iscsit_set_unsolicited_dataout(struct iscsit_cmd *); -extern int iscsit_process_scsi_cmd(struct iscsi_conn *, struct iscsit_cmd *, +extern int iscsit_process_scsi_cmd(struct iscsit_conn *, struct iscsit_cmd *, struct iscsi_scsi_req *); extern int -__iscsit_check_dataout_hdr(struct iscsi_conn *, void *, +__iscsit_check_dataout_hdr(struct iscsit_conn *, void *, struct iscsit_cmd *, u32, bool *); extern int -iscsit_check_dataout_hdr(struct iscsi_conn *conn, void *buf, +iscsit_check_dataout_hdr(struct iscsit_conn *conn, void *buf, struct iscsit_cmd **out_cmd); extern int iscsit_check_dataout_payload(struct iscsit_cmd *, struct iscsi_data *, bool); -extern int iscsit_setup_nop_out(struct iscsi_conn *, struct iscsit_cmd *, +extern int iscsit_setup_nop_out(struct iscsit_conn *, struct iscsit_cmd *, struct iscsi_nopout *); -extern int iscsit_process_nop_out(struct iscsi_conn *, struct iscsit_cmd *, +extern int iscsit_process_nop_out(struct iscsit_conn *, struct iscsit_cmd *, struct iscsi_nopout *); -extern int iscsit_handle_logout_cmd(struct iscsi_conn *, struct iscsit_cmd *, +extern int iscsit_handle_logout_cmd(struct iscsit_conn *, struct iscsit_cmd *, unsigned char *); -extern int iscsit_handle_task_mgt_cmd(struct iscsi_conn *, struct iscsit_cmd *, +extern int iscsit_handle_task_mgt_cmd(struct iscsit_conn *, struct iscsit_cmd *, unsigned char *); -extern int iscsit_setup_text_cmd(struct iscsi_conn *, struct iscsit_cmd *, +extern int iscsit_setup_text_cmd(struct iscsit_conn *, struct iscsit_cmd *, struct iscsi_text *); -extern int iscsit_process_text_cmd(struct iscsi_conn *, struct iscsit_cmd *, +extern int iscsit_process_text_cmd(struct iscsit_conn *, struct iscsit_cmd *, struct iscsi_text *); -extern void iscsit_build_rsp_pdu(struct iscsit_cmd *, struct iscsi_conn *, +extern void iscsit_build_rsp_pdu(struct iscsit_cmd *, struct iscsit_conn *, bool, struct iscsi_scsi_rsp *); -extern void iscsit_build_nopin_rsp(struct iscsit_cmd *, struct iscsi_conn *, +extern void iscsit_build_nopin_rsp(struct iscsit_cmd *, struct iscsit_conn *, struct iscsi_nopin *, bool); -extern void iscsit_build_task_mgt_rsp(struct iscsit_cmd *, struct iscsi_conn *, +extern void iscsit_build_task_mgt_rsp(struct iscsit_cmd *, struct iscsit_conn *, struct iscsi_tm_rsp *); -extern int iscsit_build_text_rsp(struct iscsit_cmd *, struct iscsi_conn *, +extern int iscsit_build_text_rsp(struct iscsit_cmd *, struct iscsit_conn *, struct iscsi_text_rsp *, enum iscsit_transport_type); -extern void iscsit_build_reject(struct iscsit_cmd *, struct iscsi_conn *, +extern void iscsit_build_reject(struct iscsit_cmd *, struct iscsit_conn *, struct iscsi_reject *); -extern int iscsit_build_logout_rsp(struct iscsit_cmd *, struct iscsi_conn *, +extern int iscsit_build_logout_rsp(struct iscsit_cmd *, struct iscsit_conn *, struct iscsi_logout_rsp *); -extern int iscsit_logout_post_handler(struct iscsit_cmd *, struct iscsi_conn *); -extern int iscsit_queue_rsp(struct iscsi_conn *, struct iscsit_cmd *); -extern void iscsit_aborted_task(struct iscsi_conn *, struct iscsit_cmd *); -extern int iscsit_add_reject(struct iscsi_conn *, u8, unsigned char *); +extern int iscsit_logout_post_handler(struct iscsit_cmd *, struct iscsit_conn *); +extern int iscsit_queue_rsp(struct iscsit_conn *, struct iscsit_cmd *); +extern void iscsit_aborted_task(struct iscsit_conn *, struct iscsit_cmd *); +extern int iscsit_add_reject(struct iscsit_conn *, u8, unsigned char *); extern int iscsit_reject_cmd(struct iscsit_cmd *, u8, unsigned char *); -extern int iscsit_handle_snack(struct iscsi_conn *, unsigned char *); -extern void iscsit_build_datain_pdu(struct iscsit_cmd *, struct iscsi_conn *, +extern int iscsit_handle_snack(struct iscsit_conn *, unsigned char *); +extern void iscsit_build_datain_pdu(struct iscsit_cmd *, struct iscsit_conn *, struct iscsi_datain *, struct iscsi_data_rsp *, bool); -extern int iscsit_build_r2ts_for_cmd(struct iscsi_conn *, struct iscsit_cmd *, +extern int iscsit_build_r2ts_for_cmd(struct iscsit_conn *, struct iscsit_cmd *, bool); -extern int iscsit_immediate_queue(struct iscsi_conn *, struct iscsit_cmd *, int); -extern int iscsit_response_queue(struct iscsi_conn *, struct iscsit_cmd *, int); +extern int iscsit_immediate_queue(struct iscsit_conn *, struct iscsit_cmd *, int); +extern int iscsit_response_queue(struct iscsit_conn *, struct iscsit_cmd *, int); /* * From iscsi_target_device.c */ @@ -109,7 +109,7 @@ extern void iscsit_increment_maxcmdsn(struct iscsit_cmd *, struct iscsi_session /* * From iscsi_target_erl0.c */ -extern void iscsit_cause_connection_reinstatement(struct iscsi_conn *, int); +extern void iscsit_cause_connection_reinstatement(struct iscsit_conn *, int); /* * From iscsi_target_erl1.c */ @@ -118,33 +118,33 @@ extern void iscsit_stop_dataout_timer(struct iscsit_cmd *); /* * From iscsi_target_tmr.c */ -extern int iscsit_tmr_post_handler(struct iscsit_cmd *, struct iscsi_conn *); +extern int iscsit_tmr_post_handler(struct iscsit_cmd *, struct iscsit_conn *); /* * From iscsi_target_util.c */ -extern struct iscsit_cmd *iscsit_allocate_cmd(struct iscsi_conn *, int); -extern int iscsit_sequence_cmd(struct iscsi_conn *, struct iscsit_cmd *, +extern struct iscsit_cmd *iscsit_allocate_cmd(struct iscsit_conn *, int); +extern int iscsit_sequence_cmd(struct iscsit_conn *, struct iscsit_cmd *, unsigned char *, __be32); extern void iscsit_release_cmd(struct iscsit_cmd *); extern void iscsit_free_cmd(struct iscsit_cmd *, bool); extern void iscsit_add_cmd_to_immediate_queue(struct iscsit_cmd *, - struct iscsi_conn *, u8); + struct iscsit_conn *, u8); extern struct iscsit_cmd * -iscsit_find_cmd_from_itt_or_dump(struct iscsi_conn *conn, +iscsit_find_cmd_from_itt_or_dump(struct iscsit_conn *conn, itt_t init_task_tag, u32 length); /* * From iscsi_target_nego.c */ -extern int iscsi_target_check_login_request(struct iscsi_conn *, +extern int iscsi_target_check_login_request(struct iscsit_conn *, struct iscsi_login *); /* * From iscsi_target_login.c */ extern __printf(2, 3) int iscsi_change_param_sprintf( - struct iscsi_conn *, const char *, ...); + struct iscsit_conn *, const char *, ...); /* * From iscsi_target_parameters.c From 0873fe44e780eb8ff7932aed347de8dd4103cea7 Mon Sep 17 00:00:00 2001 From: Max Gurtovoy Date: Thu, 28 Apr 2022 12:29:39 +0300 Subject: [PATCH 155/177] scsi: target: iscsi: Rename iscsi_session to iscsit_session The structure iscsi_session naming is used by the iSCSI initiator driver. Rename the target session to iscsit_session to have more readable code. Link: https://lore.kernel.org/r/20220428092939.36768-3-mgurtovoy@nvidia.com Reviewed-by: Mike Christie Signed-off-by: Max Gurtovoy Signed-off-by: Martin K. Petersen --- drivers/target/iscsi/iscsi_target.c | 28 +++++++++---------- drivers/target/iscsi/iscsi_target.h | 8 +++--- drivers/target/iscsi/iscsi_target_configfs.c | 12 ++++---- drivers/target/iscsi/iscsi_target_device.c | 4 +-- drivers/target/iscsi/iscsi_target_device.h | 6 ++-- drivers/target/iscsi/iscsi_target_erl0.c | 10 +++---- drivers/target/iscsi/iscsi_target_erl0.h | 8 +++--- drivers/target/iscsi/iscsi_target_erl1.c | 20 ++++++------- drivers/target/iscsi/iscsi_target_erl1.h | 10 +++---- drivers/target/iscsi/iscsi_target_erl2.c | 18 ++++++------ drivers/target/iscsi/iscsi_target_erl2.h | 10 +++---- drivers/target/iscsi/iscsi_target_login.c | 20 ++++++------- drivers/target/iscsi/iscsi_target_nego.c | 6 ++-- .../target/iscsi/iscsi_target_nodeattrib.c | 2 +- .../target/iscsi/iscsi_target_seq_pdu_list.c | 2 +- drivers/target/iscsi/iscsi_target_stat.c | 16 +++++------ drivers/target/iscsi/iscsi_target_tmr.c | 6 ++-- drivers/target/iscsi/iscsi_target_tpg.c | 2 +- drivers/target/iscsi/iscsi_target_tpg.h | 4 +-- drivers/target/iscsi/iscsi_target_util.c | 28 +++++++++---------- drivers/target/iscsi/iscsi_target_util.h | 18 ++++++------ include/target/iscsi/iscsi_target_core.h | 10 +++---- include/target/iscsi/iscsi_transport.h | 2 +- 23 files changed, 125 insertions(+), 125 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 2c4f94b76061..d425cc386d87 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -2350,7 +2350,7 @@ reject: int iscsit_logout_closesession(struct iscsit_cmd *cmd, struct iscsit_conn *conn) { struct iscsit_conn *conn_p; - struct iscsi_session *sess = conn->sess; + struct iscsit_session *sess = conn->sess; pr_debug("Received logout request CLOSESESSION on CID: %hu" " for SID: %u.\n", conn->cid, conn->sess->sid); @@ -2380,7 +2380,7 @@ int iscsit_logout_closesession(struct iscsit_cmd *cmd, struct iscsit_conn *conn) int iscsit_logout_closeconnection(struct iscsit_cmd *cmd, struct iscsit_conn *conn) { struct iscsit_conn *l_conn; - struct iscsi_session *sess = conn->sess; + struct iscsit_session *sess = conn->sess; pr_debug("Received logout request CLOSECONNECTION for CID:" " %hu on CID: %hu.\n", cmd->logout_cid, conn->cid); @@ -2427,7 +2427,7 @@ int iscsit_logout_closeconnection(struct iscsit_cmd *cmd, struct iscsit_conn *co int iscsit_logout_removeconnforrecovery(struct iscsit_cmd *cmd, struct iscsit_conn *conn) { - struct iscsi_session *sess = conn->sess; + struct iscsit_session *sess = conn->sess; pr_debug("Received explicit REMOVECONNFORRECOVERY logout for" " CID: %hu on CID: %hu.\n", cmd->logout_cid, conn->cid); @@ -2901,7 +2901,7 @@ iscsit_build_logout_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn, { struct iscsit_conn *logout_conn = NULL; struct iscsi_conn_recovery *cr = NULL; - struct iscsi_session *sess = conn->sess; + struct iscsit_session *sess = conn->sess; /* * The actual shutting down of Sessions and/or Connections * for CLOSESESSION and CLOSECONNECTION Logout Requests @@ -4145,7 +4145,7 @@ static void iscsit_release_commands_from_conn(struct iscsit_conn *conn) { LIST_HEAD(tmp_list); struct iscsit_cmd *cmd = NULL, *cmd_tmp = NULL; - struct iscsi_session *sess = conn->sess; + struct iscsit_session *sess = conn->sess; /* * We expect this function to only ever be called from either RX or TX * thread context via iscsit_close_connection() once the other context @@ -4201,7 +4201,7 @@ int iscsit_close_connection( struct iscsit_conn *conn) { int conn_logout = (conn->conn_state == TARG_CONN_STATE_IN_LOGOUT); - struct iscsi_session *sess = conn->sess; + struct iscsit_session *sess = conn->sess; pr_debug("Closing iSCSI connection CID %hu on SID:" " %u\n", conn->cid, sess->sid); @@ -4438,7 +4438,7 @@ int iscsit_close_connection( * If the iSCSI Session for the iSCSI Initiator Node exists, * forcefully shutdown the iSCSI NEXUS. */ -int iscsit_close_session(struct iscsi_session *sess, bool can_sleep) +int iscsit_close_session(struct iscsit_session *sess, bool can_sleep) { struct iscsi_portal_group *tpg = sess->tpg; struct se_portal_group *se_tpg = &tpg->tpg_se_tpg; @@ -4508,7 +4508,7 @@ int iscsit_close_session(struct iscsi_session *sess, bool can_sleep) static void iscsit_logout_post_handler_closesession( struct iscsit_conn *conn) { - struct iscsi_session *sess = conn->sess; + struct iscsit_session *sess = conn->sess; int sleep = 1; /* * Traditional iscsi/tcp will invoke this logic from TX thread @@ -4557,7 +4557,7 @@ static void iscsit_logout_post_handler_diffcid( u16 cid) { struct iscsit_conn *l_conn; - struct iscsi_session *sess = conn->sess; + struct iscsit_session *sess = conn->sess; bool conn_found = false; if (!sess) @@ -4649,7 +4649,7 @@ int iscsit_logout_post_handler( } EXPORT_SYMBOL(iscsit_logout_post_handler); -void iscsit_fail_session(struct iscsi_session *sess) +void iscsit_fail_session(struct iscsit_session *sess) { struct iscsit_conn *conn; @@ -4665,7 +4665,7 @@ void iscsit_fail_session(struct iscsi_session *sess) } void iscsit_stop_session( - struct iscsi_session *sess, + struct iscsit_session *sess, int session_sleep, int connection_sleep) { @@ -4712,7 +4712,7 @@ void iscsit_stop_session( int iscsit_release_sessions_for_tpg(struct iscsi_portal_group *tpg, int force) { - struct iscsi_session *sess; + struct iscsit_session *sess; struct se_portal_group *se_tpg = &tpg->tpg_se_tpg; struct se_session *se_sess, *se_sess_tmp; LIST_HEAD(free_list); @@ -4726,7 +4726,7 @@ int iscsit_release_sessions_for_tpg(struct iscsi_portal_group *tpg, int force) list_for_each_entry_safe(se_sess, se_sess_tmp, &se_tpg->tpg_sess_list, sess_list) { - sess = (struct iscsi_session *)se_sess->fabric_sess_ptr; + sess = (struct iscsit_session *)se_sess->fabric_sess_ptr; spin_lock(&sess->conn_lock); if (atomic_read(&sess->session_fall_back_to_erl0) || @@ -4747,7 +4747,7 @@ int iscsit_release_sessions_for_tpg(struct iscsi_portal_group *tpg, int force) spin_unlock_bh(&se_tpg->session_lock); list_for_each_entry_safe(se_sess, se_sess_tmp, &free_list, sess_list) { - sess = (struct iscsi_session *)se_sess->fabric_sess_ptr; + sess = (struct iscsit_session *)se_sess->fabric_sess_ptr; list_del_init(&se_sess->sess_list); iscsit_stop_session(sess, 1, 1); diff --git a/drivers/target/iscsi/iscsi_target.h b/drivers/target/iscsi/iscsi_target.h index 314e29fcaa5a..0c997a08adec 100644 --- a/drivers/target/iscsi/iscsi_target.h +++ b/drivers/target/iscsi/iscsi_target.h @@ -9,7 +9,7 @@ struct iscsit_cmd; struct iscsit_conn; struct iscsi_np; struct iscsi_portal_group; -struct iscsi_session; +struct iscsit_session; struct iscsi_tpg_np; struct kref; struct sockaddr_storage; @@ -41,9 +41,9 @@ extern void iscsit_thread_get_cpumask(struct iscsit_conn *); extern int iscsi_target_tx_thread(void *); extern int iscsi_target_rx_thread(void *); extern int iscsit_close_connection(struct iscsit_conn *); -extern int iscsit_close_session(struct iscsi_session *, bool can_sleep); -extern void iscsit_fail_session(struct iscsi_session *); -extern void iscsit_stop_session(struct iscsi_session *, int, int); +extern int iscsit_close_session(struct iscsit_session *, bool can_sleep); +extern void iscsit_fail_session(struct iscsit_session *); +extern void iscsit_stop_session(struct iscsit_session *, int, int); extern int iscsit_release_sessions_for_tpg(struct iscsi_portal_group *, int); extern struct iscsit_global *iscsit_global; diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c index aadc855f67fa..72f5ff959636 100644 --- a/drivers/target/iscsi/iscsi_target_configfs.c +++ b/drivers/target/iscsi/iscsi_target_configfs.c @@ -443,7 +443,7 @@ static ssize_t iscsi_nacl_param_##name##_show(struct config_item *item, \ char *page) \ { \ struct se_node_acl *se_nacl = param_to_nacl(item); \ - struct iscsi_session *sess; \ + struct iscsit_session *sess; \ struct se_session *se_sess; \ ssize_t rb; \ \ @@ -498,7 +498,7 @@ static struct configfs_attribute *lio_target_nacl_param_attrs[] = { static ssize_t lio_target_nacl_info_show(struct config_item *item, char *page) { struct se_node_acl *se_nacl = acl_to_nacl(item); - struct iscsi_session *sess; + struct iscsit_session *sess; struct iscsit_conn *conn; struct se_session *se_sess; ssize_t rb = 0; @@ -1347,7 +1347,7 @@ static int iscsi_get_cmd_state(struct se_cmd *se_cmd) static u32 lio_sess_get_index(struct se_session *se_sess) { - struct iscsi_session *sess = se_sess->fabric_sess_ptr; + struct iscsit_session *sess = se_sess->fabric_sess_ptr; return sess->session_index; } @@ -1357,7 +1357,7 @@ static u32 lio_sess_get_initiator_sid( unsigned char *buf, u32 size) { - struct iscsi_session *sess = se_sess->fabric_sess_ptr; + struct iscsit_session *sess = se_sess->fabric_sess_ptr; /* * iSCSI Initiator Session Identifier from RFC-3720. */ @@ -1468,11 +1468,11 @@ static int lio_tpg_check_prot_fabric_only( /* * This function calls iscsit_inc_session_usage_count() on the - * struct iscsi_session in question. + * struct iscsit_session in question. */ static void lio_tpg_close_session(struct se_session *se_sess) { - struct iscsi_session *sess = se_sess->fabric_sess_ptr; + struct iscsit_session *sess = se_sess->fabric_sess_ptr; struct se_portal_group *se_tpg = &sess->tpg->tpg_se_tpg; spin_lock_bh(&se_tpg->session_lock); diff --git a/drivers/target/iscsi/iscsi_target_device.c b/drivers/target/iscsi/iscsi_target_device.c index d57041b860bd..b565ce3b2677 100644 --- a/drivers/target/iscsi/iscsi_target_device.c +++ b/drivers/target/iscsi/iscsi_target_device.c @@ -17,7 +17,7 @@ #include "iscsi_target_tpg.h" #include "iscsi_target_util.h" -void iscsit_determine_maxcmdsn(struct iscsi_session *sess) +void iscsit_determine_maxcmdsn(struct iscsit_session *sess) { struct se_node_acl *se_nacl; @@ -42,7 +42,7 @@ void iscsit_determine_maxcmdsn(struct iscsi_session *sess) atomic_add(se_nacl->queue_depth - 1, &sess->max_cmd_sn); } -void iscsit_increment_maxcmdsn(struct iscsit_cmd *cmd, struct iscsi_session *sess) +void iscsit_increment_maxcmdsn(struct iscsit_cmd *cmd, struct iscsit_session *sess) { u32 max_cmd_sn; diff --git a/drivers/target/iscsi/iscsi_target_device.h b/drivers/target/iscsi/iscsi_target_device.h index b6a463847720..366340120558 100644 --- a/drivers/target/iscsi/iscsi_target_device.h +++ b/drivers/target/iscsi/iscsi_target_device.h @@ -3,9 +3,9 @@ #define ISCSI_TARGET_DEVICE_H struct iscsit_cmd; -struct iscsi_session; +struct iscsit_session; -extern void iscsit_determine_maxcmdsn(struct iscsi_session *); -extern void iscsit_increment_maxcmdsn(struct iscsit_cmd *, struct iscsi_session *); +extern void iscsit_determine_maxcmdsn(struct iscsit_session *); +extern void iscsit_increment_maxcmdsn(struct iscsit_cmd *, struct iscsit_session *); #endif /* ISCSI_TARGET_DEVICE_H */ diff --git a/drivers/target/iscsi/iscsi_target_erl0.c b/drivers/target/iscsi/iscsi_target_erl0.c index e21f6c6dfd99..07e9cf431edd 100644 --- a/drivers/target/iscsi/iscsi_target_erl0.c +++ b/drivers/target/iscsi/iscsi_target_erl0.c @@ -743,7 +743,7 @@ int iscsit_check_post_dataout( void iscsit_handle_time2retain_timeout(struct timer_list *t) { - struct iscsi_session *sess = from_timer(sess, t, time2retain_timer); + struct iscsit_session *sess = from_timer(sess, t, time2retain_timer); struct iscsi_portal_group *tpg = sess->tpg; struct se_portal_group *se_tpg = &tpg->tpg_se_tpg; @@ -768,7 +768,7 @@ void iscsit_handle_time2retain_timeout(struct timer_list *t) iscsit_close_session(sess, false); } -void iscsit_start_time2retain_handler(struct iscsi_session *sess) +void iscsit_start_time2retain_handler(struct iscsit_session *sess) { int tpg_active; /* @@ -794,7 +794,7 @@ void iscsit_start_time2retain_handler(struct iscsi_session *sess) jiffies + sess->sess_ops->DefaultTime2Retain * HZ); } -int iscsit_stop_time2retain_timer(struct iscsi_session *sess) +int iscsit_stop_time2retain_timer(struct iscsit_session *sess) { struct iscsi_portal_group *tpg = sess->tpg; struct se_portal_group *se_tpg = &tpg->tpg_se_tpg; @@ -880,7 +880,7 @@ void iscsit_cause_connection_reinstatement(struct iscsit_conn *conn, int sleep) } EXPORT_SYMBOL(iscsit_cause_connection_reinstatement); -void iscsit_fall_back_to_erl0(struct iscsi_session *sess) +void iscsit_fall_back_to_erl0(struct iscsit_session *sess) { pr_debug("Falling back to ErrorRecoveryLevel=0 for SID:" " %u\n", sess->sid); @@ -890,7 +890,7 @@ void iscsit_fall_back_to_erl0(struct iscsi_session *sess) static void iscsit_handle_connection_cleanup(struct iscsit_conn *conn) { - struct iscsi_session *sess = conn->sess; + struct iscsit_session *sess = conn->sess; if ((sess->sess_ops->ErrorRecoveryLevel == 2) && !atomic_read(&sess->session_reinstatement) && diff --git a/drivers/target/iscsi/iscsi_target_erl0.h b/drivers/target/iscsi/iscsi_target_erl0.h index 9d34c1cd6b57..2a877d13977d 100644 --- a/drivers/target/iscsi/iscsi_target_erl0.h +++ b/drivers/target/iscsi/iscsi_target_erl0.h @@ -6,17 +6,17 @@ struct iscsit_cmd; struct iscsit_conn; -struct iscsi_session; +struct iscsit_session; extern void iscsit_set_dataout_sequence_values(struct iscsit_cmd *); extern int iscsit_check_pre_dataout(struct iscsit_cmd *, unsigned char *); extern int iscsit_check_post_dataout(struct iscsit_cmd *, unsigned char *, u8); -extern void iscsit_start_time2retain_handler(struct iscsi_session *); +extern void iscsit_start_time2retain_handler(struct iscsit_session *); extern void iscsit_handle_time2retain_timeout(struct timer_list *t); -extern int iscsit_stop_time2retain_timer(struct iscsi_session *); +extern int iscsit_stop_time2retain_timer(struct iscsit_session *); extern void iscsit_connection_reinstatement_rcfr(struct iscsit_conn *); extern void iscsit_cause_connection_reinstatement(struct iscsit_conn *, int); -extern void iscsit_fall_back_to_erl0(struct iscsi_session *); +extern void iscsit_fall_back_to_erl0(struct iscsit_session *); extern void iscsit_take_action_for_connection_exit(struct iscsit_conn *, bool *); #endif /*** ISCSI_TARGET_ERL0_H ***/ diff --git a/drivers/target/iscsi/iscsi_target_erl1.c b/drivers/target/iscsi/iscsi_target_erl1.c index 2c3ac5986b45..f460a66c0e7c 100644 --- a/drivers/target/iscsi/iscsi_target_erl1.c +++ b/drivers/target/iscsi/iscsi_target_erl1.c @@ -767,7 +767,7 @@ static struct iscsi_ooo_cmdsn *iscsit_allocate_ooo_cmdsn(void) } static int iscsit_attach_ooo_cmdsn( - struct iscsi_session *sess, + struct iscsit_session *sess, struct iscsi_ooo_cmdsn *ooo_cmdsn) { struct iscsi_ooo_cmdsn *ooo_tail, *ooo_tmp; @@ -815,10 +815,10 @@ static int iscsit_attach_ooo_cmdsn( /* * Removes an struct iscsi_ooo_cmdsn from a session's list, - * called with struct iscsi_session->cmdsn_mutex held. + * called with struct iscsit_session->cmdsn_mutex held. */ void iscsit_remove_ooo_cmdsn( - struct iscsi_session *sess, + struct iscsit_session *sess, struct iscsi_ooo_cmdsn *ooo_cmdsn) { list_del(&ooo_cmdsn->ooo_list); @@ -828,7 +828,7 @@ void iscsit_remove_ooo_cmdsn( void iscsit_clear_ooo_cmdsns_for_conn(struct iscsit_conn *conn) { struct iscsi_ooo_cmdsn *ooo_cmdsn; - struct iscsi_session *sess = conn->sess; + struct iscsit_session *sess = conn->sess; mutex_lock(&sess->cmdsn_mutex); list_for_each_entry(ooo_cmdsn, &sess->sess_ooo_cmdsn_list, ooo_list) { @@ -840,7 +840,7 @@ void iscsit_clear_ooo_cmdsns_for_conn(struct iscsit_conn *conn) mutex_unlock(&sess->cmdsn_mutex); } -int iscsit_execute_ooo_cmdsns(struct iscsi_session *sess) +int iscsit_execute_ooo_cmdsns(struct iscsit_session *sess) { int ooo_count = 0; struct iscsit_cmd *cmd = NULL; @@ -994,7 +994,7 @@ int iscsit_execute_cmd(struct iscsit_cmd *cmd, int ooo) return 0; } -void iscsit_free_all_ooo_cmdsns(struct iscsi_session *sess) +void iscsit_free_all_ooo_cmdsns(struct iscsit_session *sess) { struct iscsi_ooo_cmdsn *ooo_cmdsn, *ooo_cmdsn_tmp; @@ -1009,7 +1009,7 @@ void iscsit_free_all_ooo_cmdsns(struct iscsi_session *sess) } int iscsit_handle_ooo_cmdsn( - struct iscsi_session *sess, + struct iscsit_session *sess, struct iscsit_cmd *cmd, u32 cmdsn) { @@ -1097,7 +1097,7 @@ void iscsit_handle_dataout_timeout(struct timer_list *t) u32 r2t_length = 0, r2t_offset = 0; struct iscsit_cmd *cmd = from_timer(cmd, t, dataout_timer); struct iscsit_conn *conn = cmd->conn; - struct iscsi_session *sess = NULL; + struct iscsit_session *sess = NULL; struct iscsi_node_attrib *na; iscsit_inc_conn_usage_count(conn); @@ -1182,7 +1182,7 @@ failure: void iscsit_mod_dataout_timer(struct iscsit_cmd *cmd) { struct iscsit_conn *conn = cmd->conn; - struct iscsi_session *sess = conn->sess; + struct iscsit_session *sess = conn->sess; struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess); spin_lock_bh(&cmd->dataout_timeout_lock); @@ -1202,7 +1202,7 @@ void iscsit_start_dataout_timer( struct iscsit_cmd *cmd, struct iscsit_conn *conn) { - struct iscsi_session *sess = conn->sess; + struct iscsit_session *sess = conn->sess; struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess); lockdep_assert_held(&cmd->dataout_timeout_lock); diff --git a/drivers/target/iscsi/iscsi_target_erl1.h b/drivers/target/iscsi/iscsi_target_erl1.h index b1e60fb26d5f..12472eefe559 100644 --- a/drivers/target/iscsi/iscsi_target_erl1.h +++ b/drivers/target/iscsi/iscsi_target_erl1.h @@ -10,7 +10,7 @@ struct iscsit_conn; struct iscsi_datain_req; struct iscsi_ooo_cmdsn; struct iscsi_pdu; -struct iscsi_session; +struct iscsit_session; extern int iscsit_dump_data_payload(struct iscsit_conn *, u32, int); extern int iscsit_create_recovery_datain_values_datasequenceinorder_yes( @@ -25,11 +25,11 @@ extern int iscsit_handle_data_ack(struct iscsit_conn *, u32, u32, u32); extern int iscsit_dataout_datapduinorder_no_fbit(struct iscsit_cmd *, struct iscsi_pdu *); extern int iscsit_recover_dataout_sequence(struct iscsit_cmd *, u32, u32); extern void iscsit_clear_ooo_cmdsns_for_conn(struct iscsit_conn *); -extern void iscsit_free_all_ooo_cmdsns(struct iscsi_session *); -extern int iscsit_execute_ooo_cmdsns(struct iscsi_session *); +extern void iscsit_free_all_ooo_cmdsns(struct iscsit_session *); +extern int iscsit_execute_ooo_cmdsns(struct iscsit_session *); extern int iscsit_execute_cmd(struct iscsit_cmd *, int); -extern int iscsit_handle_ooo_cmdsn(struct iscsi_session *, struct iscsit_cmd *, u32); -extern void iscsit_remove_ooo_cmdsn(struct iscsi_session *, struct iscsi_ooo_cmdsn *); +extern int iscsit_handle_ooo_cmdsn(struct iscsit_session *, struct iscsit_cmd *, u32); +extern void iscsit_remove_ooo_cmdsn(struct iscsit_session *, struct iscsi_ooo_cmdsn *); extern void iscsit_handle_dataout_timeout(struct timer_list *t); extern void iscsit_mod_dataout_timer(struct iscsit_cmd *); extern void iscsit_start_dataout_timer(struct iscsit_cmd *, struct iscsit_conn *); diff --git a/drivers/target/iscsi/iscsi_target_erl2.c b/drivers/target/iscsi/iscsi_target_erl2.c index 1dbdf7937e29..18e88d2ea5fd 100644 --- a/drivers/target/iscsi/iscsi_target_erl2.c +++ b/drivers/target/iscsi/iscsi_target_erl2.c @@ -74,7 +74,7 @@ void iscsit_create_conn_recovery_dataout_values( } static int iscsit_attach_active_connection_recovery_entry( - struct iscsi_session *sess, + struct iscsit_session *sess, struct iscsi_conn_recovery *cr) { spin_lock(&sess->cr_a_lock); @@ -85,7 +85,7 @@ static int iscsit_attach_active_connection_recovery_entry( } static int iscsit_attach_inactive_connection_recovery_entry( - struct iscsi_session *sess, + struct iscsit_session *sess, struct iscsi_conn_recovery *cr) { spin_lock(&sess->cr_i_lock); @@ -100,7 +100,7 @@ static int iscsit_attach_inactive_connection_recovery_entry( } struct iscsi_conn_recovery *iscsit_get_inactive_connection_recovery_entry( - struct iscsi_session *sess, + struct iscsit_session *sess, u16 cid) { struct iscsi_conn_recovery *cr; @@ -117,7 +117,7 @@ struct iscsi_conn_recovery *iscsit_get_inactive_connection_recovery_entry( return NULL; } -void iscsit_free_connection_recovery_entries(struct iscsi_session *sess) +void iscsit_free_connection_recovery_entries(struct iscsit_session *sess) { struct iscsit_cmd *cmd, *cmd_tmp; struct iscsi_conn_recovery *cr, *cr_tmp; @@ -169,7 +169,7 @@ void iscsit_free_connection_recovery_entries(struct iscsi_session *sess) int iscsit_remove_active_connection_recovery_entry( struct iscsi_conn_recovery *cr, - struct iscsi_session *sess) + struct iscsit_session *sess) { spin_lock(&sess->cr_a_lock); list_del(&cr->cr_list); @@ -186,7 +186,7 @@ int iscsit_remove_active_connection_recovery_entry( static void iscsit_remove_inactive_connection_recovery_entry( struct iscsi_conn_recovery *cr, - struct iscsi_session *sess) + struct iscsit_session *sess) { spin_lock(&sess->cr_i_lock); list_del(&cr->cr_list); @@ -198,7 +198,7 @@ static void iscsit_remove_inactive_connection_recovery_entry( */ int iscsit_remove_cmd_from_connection_recovery( struct iscsit_cmd *cmd, - struct iscsi_session *sess) + struct iscsit_session *sess) { struct iscsi_conn_recovery *cr; @@ -219,7 +219,7 @@ void iscsit_discard_cr_cmds_by_expstatsn( { u32 dropped_count = 0; struct iscsit_cmd *cmd, *cmd_tmp; - struct iscsi_session *sess = cr->sess; + struct iscsit_session *sess = cr->sess; spin_lock(&cr->conn_recovery_cmd_lock); list_for_each_entry_safe(cmd, cmd_tmp, @@ -268,7 +268,7 @@ int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(struct iscsit_conn *conn) u32 dropped_count = 0; struct iscsit_cmd *cmd, *cmd_tmp; struct iscsi_ooo_cmdsn *ooo_cmdsn, *ooo_cmdsn_tmp; - struct iscsi_session *sess = conn->sess; + struct iscsit_session *sess = conn->sess; mutex_lock(&sess->cmdsn_mutex); list_for_each_entry_safe(ooo_cmdsn, ooo_cmdsn_tmp, diff --git a/drivers/target/iscsi/iscsi_target_erl2.h b/drivers/target/iscsi/iscsi_target_erl2.h index 5b311ed9ebc4..6655e4bcf893 100644 --- a/drivers/target/iscsi/iscsi_target_erl2.h +++ b/drivers/target/iscsi/iscsi_target_erl2.h @@ -7,17 +7,17 @@ struct iscsit_cmd; struct iscsit_conn; struct iscsi_conn_recovery; -struct iscsi_session; +struct iscsit_session; extern void iscsit_create_conn_recovery_datain_values(struct iscsit_cmd *, __be32); extern void iscsit_create_conn_recovery_dataout_values(struct iscsit_cmd *); extern struct iscsi_conn_recovery *iscsit_get_inactive_connection_recovery_entry( - struct iscsi_session *, u16); -extern void iscsit_free_connection_recovery_entries(struct iscsi_session *); + struct iscsit_session *, u16); +extern void iscsit_free_connection_recovery_entries(struct iscsit_session *); extern int iscsit_remove_active_connection_recovery_entry( - struct iscsi_conn_recovery *, struct iscsi_session *); + struct iscsi_conn_recovery *, struct iscsit_session *); extern int iscsit_remove_cmd_from_connection_recovery(struct iscsit_cmd *, - struct iscsi_session *); + struct iscsit_session *); extern void iscsit_discard_cr_cmds_by_expstatsn(struct iscsi_conn_recovery *, u32); extern int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(struct iscsit_conn *); extern int iscsit_prepare_cmds_for_reallegiance(struct iscsit_conn *); diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c index a303ba7d20c3..6b94eecc4790 100644 --- a/drivers/target/iscsi/iscsi_target_login.c +++ b/drivers/target/iscsi/iscsi_target_login.c @@ -133,7 +133,7 @@ int iscsi_check_for_session_reinstatement(struct iscsit_conn *conn) int sessiontype; struct iscsi_param *initiatorname_param = NULL, *sessiontype_param = NULL; struct iscsi_portal_group *tpg = conn->tpg; - struct iscsi_session *sess = NULL, *sess_p = NULL; + struct iscsit_session *sess = NULL, *sess_p = NULL; struct se_portal_group *se_tpg = &tpg->tpg_se_tpg; struct se_session *se_sess, *se_sess_tmp; @@ -204,7 +204,7 @@ int iscsi_check_for_session_reinstatement(struct iscsit_conn *conn) } static int iscsi_login_set_conn_values( - struct iscsi_session *sess, + struct iscsit_session *sess, struct iscsit_conn *conn, __be16 cid) { @@ -256,11 +256,11 @@ static int iscsi_login_zero_tsih_s1( struct iscsit_conn *conn, unsigned char *buf) { - struct iscsi_session *sess = NULL; + struct iscsit_session *sess = NULL; struct iscsi_login_req *pdu = (struct iscsi_login_req *)buf; int ret; - sess = kzalloc(sizeof(struct iscsi_session), GFP_KERNEL); + sess = kzalloc(sizeof(struct iscsit_session), GFP_KERNEL); if (!sess) { iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, ISCSI_LOGIN_STATUS_NO_RESOURCES); @@ -340,7 +340,7 @@ static int iscsi_login_zero_tsih_s2( struct iscsit_conn *conn) { struct iscsi_node_attrib *na; - struct iscsi_session *sess = conn->sess; + struct iscsit_session *sess = conn->sess; bool iser = false; sess->tpg = conn->tpg; @@ -474,7 +474,7 @@ static int iscsi_login_non_zero_tsih_s2( unsigned char *buf) { struct iscsi_portal_group *tpg = conn->tpg; - struct iscsi_session *sess = NULL, *sess_p = NULL; + struct iscsit_session *sess = NULL, *sess_p = NULL; struct se_portal_group *se_tpg = &tpg->tpg_se_tpg; struct se_session *se_sess, *se_sess_tmp; struct iscsi_login_req *pdu = (struct iscsi_login_req *)buf; @@ -484,7 +484,7 @@ static int iscsi_login_non_zero_tsih_s2( list_for_each_entry_safe(se_sess, se_sess_tmp, &se_tpg->tpg_sess_list, sess_list) { - sess_p = (struct iscsi_session *)se_sess->fabric_sess_ptr; + sess_p = (struct iscsit_session *)se_sess->fabric_sess_ptr; if (atomic_read(&sess_p->session_fall_back_to_erl0) || atomic_read(&sess_p->session_logout) || atomic_read(&sess_p->session_close) || @@ -552,7 +552,7 @@ int iscsi_login_post_auth_non_zero_tsih( { struct iscsit_conn *conn_ptr = NULL; struct iscsi_conn_recovery *cr = NULL; - struct iscsi_session *sess = conn->sess; + struct iscsit_session *sess = conn->sess; /* * By following item 5 in the login table, if we have found @@ -614,7 +614,7 @@ int iscsi_login_post_auth_non_zero_tsih( static void iscsi_post_login_start_timers(struct iscsit_conn *conn) { - struct iscsi_session *sess = conn->sess; + struct iscsit_session *sess = conn->sess; /* * FIXME: Unsolicited NopIN support for ISER */ @@ -677,7 +677,7 @@ void iscsi_post_login_handler( u8 zero_tsih) { int stop_timer = 0; - struct iscsi_session *sess = conn->sess; + struct iscsit_session *sess = conn->sess; struct se_session *se_sess = sess->se_sess; struct iscsi_portal_group *tpg = sess->tpg; struct se_portal_group *se_tpg = &tpg->tpg_se_tpg; diff --git a/drivers/target/iscsi/iscsi_target_nego.c b/drivers/target/iscsi/iscsi_target_nego.c index b65c73fc6073..b34ac9ecac31 100644 --- a/drivers/target/iscsi/iscsi_target_nego.c +++ b/drivers/target/iscsi/iscsi_target_nego.c @@ -102,7 +102,7 @@ static u32 iscsi_handle_authentication( int *out_length, unsigned char *authtype) { - struct iscsi_session *sess = conn->sess; + struct iscsit_session *sess = conn->sess; struct iscsi_node_auth *auth; struct iscsi_node_acl *iscsi_nacl; struct iscsi_portal_group *iscsi_tpg; @@ -1059,7 +1059,7 @@ int iscsi_target_locate_portal( { char *i_buf = NULL, *s_buf = NULL, *t_buf = NULL; char *tmpbuf, *start = NULL, *end = NULL, *key, *value; - struct iscsi_session *sess = conn->sess; + struct iscsit_session *sess = conn->sess; struct iscsi_tiqn *tiqn; struct iscsi_tpg_np *tpg_np = NULL; struct iscsi_login_req *login_req; @@ -1232,7 +1232,7 @@ get_target: /* * conn->sess->node_acl will be set when the referenced - * struct iscsi_session is located from received ISID+TSIH in + * struct iscsit_session is located from received ISID+TSIH in * iscsi_login_non_zero_tsih_s2(). */ if (!login->leading_connection) { diff --git a/drivers/target/iscsi/iscsi_target_nodeattrib.c b/drivers/target/iscsi/iscsi_target_nodeattrib.c index 36671af6332f..874cb33c9be0 100644 --- a/drivers/target/iscsi/iscsi_target_nodeattrib.c +++ b/drivers/target/iscsi/iscsi_target_nodeattrib.c @@ -96,7 +96,7 @@ int iscsit_na_nopin_timeout( u32 nopin_timeout) { struct iscsi_node_attrib *a = &acl->node_attrib; - struct iscsi_session *sess; + struct iscsit_session *sess; struct iscsit_conn *conn; struct se_node_acl *se_nacl = &a->nacl->se_node_acl; struct se_session *se_sess; diff --git a/drivers/target/iscsi/iscsi_target_seq_pdu_list.c b/drivers/target/iscsi/iscsi_target_seq_pdu_list.c index 326efd762db0..66de2b8de463 100644 --- a/drivers/target/iscsi/iscsi_target_seq_pdu_list.c +++ b/drivers/target/iscsi/iscsi_target_seq_pdu_list.c @@ -493,7 +493,7 @@ int iscsit_build_pdu_and_seq_lists( struct iscsi_pdu *pdu = NULL; struct iscsi_seq *seq = NULL; - struct iscsi_session *sess = conn->sess; + struct iscsit_session *sess = conn->sess; struct iscsi_node_attrib *na; /* diff --git a/drivers/target/iscsi/iscsi_target_stat.c b/drivers/target/iscsi/iscsi_target_stat.c index cce3a827059e..367c6468b8e1 100644 --- a/drivers/target/iscsi/iscsi_target_stat.c +++ b/drivers/target/iscsi/iscsi_target_stat.c @@ -599,7 +599,7 @@ static ssize_t iscsi_stat_sess_node_show(struct config_item *item, char *page) { struct iscsi_node_acl *acl = iscsi_stat_nacl(item); struct se_node_acl *se_nacl = &acl->se_node_acl; - struct iscsi_session *sess; + struct iscsit_session *sess; struct se_session *se_sess; ssize_t ret = 0; @@ -620,7 +620,7 @@ static ssize_t iscsi_stat_sess_indx_show(struct config_item *item, char *page) { struct iscsi_node_acl *acl = iscsi_stat_nacl(item); struct se_node_acl *se_nacl = &acl->se_node_acl; - struct iscsi_session *sess; + struct iscsit_session *sess; struct se_session *se_sess; ssize_t ret = 0; @@ -642,7 +642,7 @@ static ssize_t iscsi_stat_sess_cmd_pdus_show(struct config_item *item, { struct iscsi_node_acl *acl = iscsi_stat_nacl(item); struct se_node_acl *se_nacl = &acl->se_node_acl; - struct iscsi_session *sess; + struct iscsit_session *sess; struct se_session *se_sess; ssize_t ret = 0; @@ -664,7 +664,7 @@ static ssize_t iscsi_stat_sess_rsp_pdus_show(struct config_item *item, { struct iscsi_node_acl *acl = iscsi_stat_nacl(item); struct se_node_acl *se_nacl = &acl->se_node_acl; - struct iscsi_session *sess; + struct iscsit_session *sess; struct se_session *se_sess; ssize_t ret = 0; @@ -686,7 +686,7 @@ static ssize_t iscsi_stat_sess_txdata_octs_show(struct config_item *item, { struct iscsi_node_acl *acl = iscsi_stat_nacl(item); struct se_node_acl *se_nacl = &acl->se_node_acl; - struct iscsi_session *sess; + struct iscsit_session *sess; struct se_session *se_sess; ssize_t ret = 0; @@ -708,7 +708,7 @@ static ssize_t iscsi_stat_sess_rxdata_octs_show(struct config_item *item, { struct iscsi_node_acl *acl = iscsi_stat_nacl(item); struct se_node_acl *se_nacl = &acl->se_node_acl; - struct iscsi_session *sess; + struct iscsit_session *sess; struct se_session *se_sess; ssize_t ret = 0; @@ -730,7 +730,7 @@ static ssize_t iscsi_stat_sess_conn_digest_errors_show(struct config_item *item, { struct iscsi_node_acl *acl = iscsi_stat_nacl(item); struct se_node_acl *se_nacl = &acl->se_node_acl; - struct iscsi_session *sess; + struct iscsit_session *sess; struct se_session *se_sess; ssize_t ret = 0; @@ -752,7 +752,7 @@ static ssize_t iscsi_stat_sess_conn_timeout_errors_show( { struct iscsi_node_acl *acl = iscsi_stat_nacl(item); struct se_node_acl *se_nacl = &acl->se_node_acl; - struct iscsi_session *sess; + struct iscsit_session *sess; struct se_session *se_sess; ssize_t ret = 0; diff --git a/drivers/target/iscsi/iscsi_target_tmr.c b/drivers/target/iscsi/iscsi_target_tmr.c index e3c3a08db1e0..afc801f255f5 100644 --- a/drivers/target/iscsi/iscsi_target_tmr.c +++ b/drivers/target/iscsi/iscsi_target_tmr.c @@ -67,7 +67,7 @@ int iscsit_tmr_task_warm_reset( struct iscsi_tmr_req *tmr_req, unsigned char *buf) { - struct iscsi_session *sess = conn->sess; + struct iscsit_session *sess = conn->sess; struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess); if (!na->tmr_warm_reset) { @@ -87,7 +87,7 @@ int iscsit_tmr_task_cold_reset( struct iscsi_tmr_req *tmr_req, unsigned char *buf) { - struct iscsi_session *sess = conn->sess; + struct iscsit_session *sess = conn->sess; struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess); if (!na->tmr_cold_reset) { @@ -177,7 +177,7 @@ u8 iscsit_tmr_task_reassign( static void iscsit_task_reassign_remove_cmd( struct iscsit_cmd *cmd, struct iscsi_conn_recovery *cr, - struct iscsi_session *sess) + struct iscsit_session *sess) { int ret; diff --git a/drivers/target/iscsi/iscsi_target_tpg.c b/drivers/target/iscsi/iscsi_target_tpg.c index 2d5cf1714ae0..4339ee517434 100644 --- a/drivers/target/iscsi/iscsi_target_tpg.c +++ b/drivers/target/iscsi/iscsi_target_tpg.c @@ -390,7 +390,7 @@ int iscsit_tpg_disable_portal_group(struct iscsi_portal_group *tpg, int force) } struct iscsi_node_attrib *iscsit_tpg_get_node_attrib( - struct iscsi_session *sess) + struct iscsit_session *sess) { struct se_session *se_sess = sess->se_sess; struct se_node_acl *se_nacl = se_sess->se_node_acl; diff --git a/drivers/target/iscsi/iscsi_target_tpg.h b/drivers/target/iscsi/iscsi_target_tpg.h index 88576f5d0ca4..839e45362776 100644 --- a/drivers/target/iscsi/iscsi_target_tpg.h +++ b/drivers/target/iscsi/iscsi_target_tpg.h @@ -5,7 +5,7 @@ #include struct iscsi_np; -struct iscsi_session; +struct iscsit_session; struct iscsi_tiqn; struct iscsi_tpg_np; struct se_node_acl; @@ -28,7 +28,7 @@ extern struct iscsi_node_acl *iscsit_tpg_add_initiator_node_acl( struct iscsi_portal_group *, const char *, u32); extern void iscsit_tpg_del_initiator_node_acl(struct iscsi_portal_group *, struct se_node_acl *); -extern struct iscsi_node_attrib *iscsit_tpg_get_node_attrib(struct iscsi_session *); +extern struct iscsi_node_attrib *iscsit_tpg_get_node_attrib(struct iscsit_session *); extern void iscsit_tpg_del_external_nps(struct iscsi_tpg_np *); extern struct iscsi_tpg_np *iscsit_tpg_locate_child_np(struct iscsi_tpg_np *, int); extern struct iscsi_tpg_np *iscsit_tpg_add_network_portal(struct iscsi_portal_group *, diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c index be50f857d1b1..8d9f21372b67 100644 --- a/drivers/target/iscsi/iscsi_target_util.c +++ b/drivers/target/iscsi/iscsi_target_util.c @@ -238,7 +238,7 @@ struct iscsi_r2t *iscsit_get_holder_for_r2tsn( return NULL; } -static inline int iscsit_check_received_cmdsn(struct iscsi_session *sess, u32 cmdsn) +static inline int iscsit_check_received_cmdsn(struct iscsit_session *sess, u32 cmdsn) { u32 max_cmdsn; int ret; @@ -446,7 +446,7 @@ struct iscsit_cmd *iscsit_find_cmd_from_ttt( } int iscsit_find_cmd_for_recovery( - struct iscsi_session *sess, + struct iscsit_session *sess, struct iscsit_cmd **cmd_ptr, struct iscsi_conn_recovery **cr_ptr, itt_t init_task_tag) @@ -696,7 +696,7 @@ void iscsit_free_queue_reqs_for_conn(struct iscsit_conn *conn) void iscsit_release_cmd(struct iscsit_cmd *cmd) { - struct iscsi_session *sess; + struct iscsit_session *sess; struct se_cmd *se_cmd = &cmd->se_cmd; WARN_ON(!list_empty(&cmd->i_conn_node)); @@ -762,7 +762,7 @@ void iscsit_free_cmd(struct iscsit_cmd *cmd, bool shutdown) } EXPORT_SYMBOL(iscsit_free_cmd); -bool iscsit_check_session_usage_count(struct iscsi_session *sess, +bool iscsit_check_session_usage_count(struct iscsit_session *sess, bool can_sleep) { spin_lock_bh(&sess->session_usage_lock); @@ -780,7 +780,7 @@ bool iscsit_check_session_usage_count(struct iscsi_session *sess, return false; } -void iscsit_dec_session_usage_count(struct iscsi_session *sess) +void iscsit_dec_session_usage_count(struct iscsit_session *sess) { spin_lock_bh(&sess->session_usage_lock); sess->session_usage_count--; @@ -791,14 +791,14 @@ void iscsit_dec_session_usage_count(struct iscsi_session *sess) spin_unlock_bh(&sess->session_usage_lock); } -void iscsit_inc_session_usage_count(struct iscsi_session *sess) +void iscsit_inc_session_usage_count(struct iscsit_session *sess) { spin_lock_bh(&sess->session_usage_lock); sess->session_usage_count++; spin_unlock_bh(&sess->session_usage_lock); } -struct iscsit_conn *iscsit_get_conn_from_cid(struct iscsi_session *sess, u16 cid) +struct iscsit_conn *iscsit_get_conn_from_cid(struct iscsit_session *sess, u16 cid) { struct iscsit_conn *conn; @@ -816,7 +816,7 @@ struct iscsit_conn *iscsit_get_conn_from_cid(struct iscsi_session *sess, u16 cid return NULL; } -struct iscsit_conn *iscsit_get_conn_from_cid_rcfr(struct iscsi_session *sess, u16 cid) +struct iscsit_conn *iscsit_get_conn_from_cid_rcfr(struct iscsit_session *sess, u16 cid) { struct iscsit_conn *conn; @@ -896,7 +896,7 @@ static int iscsit_add_nopin(struct iscsit_conn *conn, int want_response) void iscsit_handle_nopin_response_timeout(struct timer_list *t) { struct iscsit_conn *conn = from_timer(conn, t, nopin_response_timer); - struct iscsi_session *sess = conn->sess; + struct iscsit_session *sess = conn->sess; iscsit_inc_conn_usage_count(conn); @@ -921,7 +921,7 @@ void iscsit_handle_nopin_response_timeout(struct timer_list *t) void iscsit_mod_nopin_response_timer(struct iscsit_conn *conn) { - struct iscsi_session *sess = conn->sess; + struct iscsit_session *sess = conn->sess; struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess); spin_lock_bh(&conn->nopin_timer_lock); @@ -937,7 +937,7 @@ void iscsit_mod_nopin_response_timer(struct iscsit_conn *conn) void iscsit_start_nopin_response_timer(struct iscsit_conn *conn) { - struct iscsi_session *sess = conn->sess; + struct iscsit_session *sess = conn->sess; struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess); spin_lock_bh(&conn->nopin_timer_lock); @@ -994,7 +994,7 @@ void iscsit_handle_nopin_timeout(struct timer_list *t) void __iscsit_start_nopin_timer(struct iscsit_conn *conn) { - struct iscsi_session *sess = conn->sess; + struct iscsit_session *sess = conn->sess; struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess); lockdep_assert_held(&conn->nopin_timer_lock); @@ -1198,7 +1198,7 @@ int iscsit_tx_login_rsp(struct iscsit_conn *conn, u8 status_class, u8 status_det return conn->conn_transport->iscsit_put_login_tx(conn, login, 0); } -void iscsit_print_session_params(struct iscsi_session *sess) +void iscsit_print_session_params(struct iscsit_session *sess) { struct iscsit_conn *conn; @@ -1351,7 +1351,7 @@ struct iscsi_tiqn *iscsit_snmp_get_tiqn(struct iscsit_conn *conn) return tpg->tpg_tiqn; } -void iscsit_fill_cxn_timeout_err_stats(struct iscsi_session *sess) +void iscsit_fill_cxn_timeout_err_stats(struct iscsit_session *sess) { struct iscsi_portal_group *tpg = sess->tpg; struct iscsi_tiqn *tiqn = tpg->tpg_tiqn; diff --git a/drivers/target/iscsi/iscsi_target_util.h b/drivers/target/iscsi/iscsi_target_util.h index dcdcdfe4fd7e..33ea799a0850 100644 --- a/drivers/target/iscsi/iscsi_target_util.h +++ b/drivers/target/iscsi/iscsi_target_util.h @@ -10,7 +10,7 @@ struct iscsit_cmd; struct iscsit_conn; struct iscsi_conn_recovery; -struct iscsi_session; +struct iscsit_session; extern int iscsit_add_r2t_to_list(struct iscsit_cmd *, u32, u32, int, u32); extern struct iscsi_r2t *iscsit_get_r2t_for_eos(struct iscsit_cmd *, u32, u32); @@ -28,7 +28,7 @@ extern int iscsit_check_unsolicited_dataout(struct iscsit_cmd *, unsigned char * extern struct iscsit_cmd *iscsit_find_cmd_from_itt_or_dump(struct iscsit_conn *, itt_t, u32); extern struct iscsit_cmd *iscsit_find_cmd_from_ttt(struct iscsit_conn *, u32); -extern int iscsit_find_cmd_for_recovery(struct iscsi_session *, struct iscsit_cmd **, +extern int iscsit_find_cmd_for_recovery(struct iscsit_session *, struct iscsit_cmd **, struct iscsi_conn_recovery **, itt_t); extern void iscsit_add_cmd_to_immediate_queue(struct iscsit_cmd *, struct iscsit_conn *, u8); extern struct iscsi_queue_req *iscsit_get_cmd_from_immediate_queue(struct iscsit_conn *); @@ -40,11 +40,11 @@ extern void iscsit_free_queue_reqs_for_conn(struct iscsit_conn *); extern void iscsit_release_cmd(struct iscsit_cmd *); extern void __iscsit_free_cmd(struct iscsit_cmd *, bool); extern void iscsit_free_cmd(struct iscsit_cmd *, bool); -extern bool iscsit_check_session_usage_count(struct iscsi_session *sess, bool can_sleep); -extern void iscsit_dec_session_usage_count(struct iscsi_session *); -extern void iscsit_inc_session_usage_count(struct iscsi_session *); -extern struct iscsit_conn *iscsit_get_conn_from_cid(struct iscsi_session *, u16); -extern struct iscsit_conn *iscsit_get_conn_from_cid_rcfr(struct iscsi_session *, u16); +extern bool iscsit_check_session_usage_count(struct iscsit_session *sess, bool can_sleep); +extern void iscsit_dec_session_usage_count(struct iscsit_session *); +extern void iscsit_inc_session_usage_count(struct iscsit_session *); +extern struct iscsit_conn *iscsit_get_conn_from_cid(struct iscsit_session *, u16); +extern struct iscsit_conn *iscsit_get_conn_from_cid_rcfr(struct iscsit_session *, u16); extern void iscsit_check_conn_usage_count(struct iscsit_conn *); extern void iscsit_dec_conn_usage_count(struct iscsit_conn *); extern void iscsit_inc_conn_usage_count(struct iscsit_conn *); @@ -59,7 +59,7 @@ extern void iscsit_stop_nopin_timer(struct iscsit_conn *); extern int iscsit_send_tx_data(struct iscsit_cmd *, struct iscsit_conn *, int); extern int iscsit_fe_sendpage_sg(struct iscsit_cmd *, struct iscsit_conn *); extern int iscsit_tx_login_rsp(struct iscsit_conn *, u8, u8); -extern void iscsit_print_session_params(struct iscsi_session *); +extern void iscsit_print_session_params(struct iscsit_session *); extern int iscsit_print_dev_to_proc(char *, char **, off_t, int); extern int iscsit_print_sessions_to_proc(char *, char **, off_t, int); extern int iscsit_print_tpg_to_proc(char *, char **, off_t, int); @@ -67,6 +67,6 @@ extern int rx_data(struct iscsit_conn *, struct kvec *, int, int); extern int tx_data(struct iscsit_conn *, struct kvec *, int, int); extern void iscsit_collect_login_stats(struct iscsit_conn *, u8, u8); extern struct iscsi_tiqn *iscsit_snmp_get_tiqn(struct iscsit_conn *); -extern void iscsit_fill_cxn_timeout_err_stats(struct iscsi_session *); +extern void iscsit_fill_cxn_timeout_err_stats(struct iscsit_session *); #endif /*** ISCSI_TARGET_UTIL_H ***/ diff --git a/include/target/iscsi/iscsi_target_core.h b/include/target/iscsi/iscsi_target_core.h index 76581e0f3d98..8e68ace428d9 100644 --- a/include/target/iscsi/iscsi_target_core.h +++ b/include/target/iscsi/iscsi_target_core.h @@ -482,7 +482,7 @@ struct iscsit_cmd { /* Pointer to connection recovery entry */ struct iscsi_conn_recovery *cr; /* Session the command is part of, used for connection recovery */ - struct iscsi_session *sess; + struct iscsit_session *sess; /* list_head for connection list */ struct list_head i_conn_node; /* The TCM I/O descriptor that is accessed via container_of() */ @@ -598,7 +598,7 @@ struct iscsit_conn { struct iscsi_portal_group *tpg; struct iscsi_tpg_np *tpg_np; /* Pointer to parent session */ - struct iscsi_session *sess; + struct iscsit_session *sess; int bitmap_id; int rx_thread_active; struct task_struct *rx_thread; @@ -618,11 +618,11 @@ struct iscsi_conn_recovery { struct list_head conn_recovery_cmd_list; spinlock_t conn_recovery_cmd_lock; struct timer_list time2retain_timer; - struct iscsi_session *sess; + struct iscsit_session *sess; struct list_head cr_list; } ____cacheline_aligned; -struct iscsi_session { +struct iscsit_session { u8 initiator_vendor; u8 isid[6]; enum iscsi_timer_flags_table time2retain_timer_flags; @@ -885,7 +885,7 @@ struct iscsit_global { struct iscsi_portal_group *discovery_tpg; }; -static inline u32 session_get_next_ttt(struct iscsi_session *session) +static inline u32 session_get_next_ttt(struct iscsit_session *session) { u32 ttt; diff --git a/include/target/iscsi/iscsi_transport.h b/include/target/iscsi/iscsi_transport.h index 2ab26bb6f808..42cfe02ea909 100644 --- a/include/target/iscsi/iscsi_transport.h +++ b/include/target/iscsi/iscsi_transport.h @@ -105,7 +105,7 @@ extern int iscsit_response_queue(struct iscsit_conn *, struct iscsit_cmd *, int) /* * From iscsi_target_device.c */ -extern void iscsit_increment_maxcmdsn(struct iscsit_cmd *, struct iscsi_session *); +extern void iscsit_increment_maxcmdsn(struct iscsit_cmd *, struct iscsit_session *); /* * From iscsi_target_erl0.c */ From 848b89778ed53e6c9f9e3ed01c90109ee970b3d1 Mon Sep 17 00:00:00 2001 From: Davidlohr Bueso Date: Fri, 6 May 2022 12:57:55 +0200 Subject: [PATCH 156/177] scsi: fcoe: Add a local_lock to fcoe_percpu fcoe_get_paged_crc_eof() relies on the caller having preemption disabled to ensure the per-CPU fcoe_percpu context remains valid throughout the call. This is done by either holding spinlocks (such as bnx2fc_global_lock or qedf_global_lock) or the get_cpu() from fcoe_alloc_paged_crc_eof(). This last one breaks PREEMPT_RT semantics as there can be memory allocation and end up sleeping in atomic contexts. Introduce a local_lock_t to struct fcoe_percpu that will keep the non-RT case the same, mapping to preempt_disable/enable, while RT will use a per-CPU spinlock allowing the region to be preemptible but still maintain CPU locality. The other users of fcoe_percpu are already safe in this regard and do not require local_lock()ing. Link: https://lore.kernel.org/r/20211117025956.79616-3-dave@stgolabs.net Link: https://lore.kernel.org/r/20220506105758.283887-2-bigeasy@linutronix.de Acked-by: Sebastian Andrzej Siewior Signed-off-by: Davidlohr Bueso Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Martin K. Petersen --- drivers/scsi/fcoe/fcoe.c | 6 ++++-- include/scsi/libfcoe.h | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c index 983e00135fea..af9b788823ac 100644 --- a/drivers/scsi/fcoe/fcoe.c +++ b/drivers/scsi/fcoe/fcoe.c @@ -1453,9 +1453,10 @@ static int fcoe_alloc_paged_crc_eof(struct sk_buff *skb, int tlen) struct fcoe_percpu_s *fps; int rc; - fps = &get_cpu_var(fcoe_percpu); + local_lock(&fcoe_percpu.lock); + fps = this_cpu_ptr(&fcoe_percpu); rc = fcoe_get_paged_crc_eof(skb, tlen, fps); - put_cpu_var(fcoe_percpu); + local_unlock(&fcoe_percpu.lock); return rc; } @@ -2488,6 +2489,7 @@ static int __init fcoe_init(void) p = per_cpu_ptr(&fcoe_percpu, cpu); INIT_WORK(&p->work, fcoe_receive_work); skb_queue_head_init(&p->fcoe_rx_list); + local_lock_init(&p->lock); } /* Setup link change notification */ diff --git a/include/scsi/libfcoe.h b/include/scsi/libfcoe.h index fac8e89aed81..6e79fb87fea2 100644 --- a/include/scsi/libfcoe.h +++ b/include/scsi/libfcoe.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -326,6 +327,7 @@ struct fcoe_percpu_s { struct sk_buff_head fcoe_rx_list; struct page *crc_eof_page; int crc_eof_offset; + local_lock_t lock; }; /** From a912460efafea8ba763717b083347d5b33495bfa Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Fri, 6 May 2022 12:57:56 +0200 Subject: [PATCH 157/177] scsi: fcoe: Use per-CPU API to update per-CPU statistics The per-CPU statistics (struct fc_stats) is updated by getting a stable per-CPU pointer via get_cpu() + per_cpu_ptr() and then performing the increment. This can be optimized by using this_cpu_*() which will do whatever is needed on the architecture to perform the update safe and efficient. The read out of the individual value (fc_get_host_stats()) should be done by using READ_ONCE() instead of a plain-C access. The difference is that READ_ONCE() will always perform a single access while the plain-C access can be split by the compiler into two loads if it appears beneficial. The usage of u64 has the side-effect that it is also 64bit wide on 32bit architectures and the read is always split into two loads. The can lead to strange values if the read happens during an update which alters both 32bit parts of the 64bit value. This can be circumvented by either using a 32bit variables on 32bit architecures or extending the statistics with a sequence counter. Use this_cpu_*() API to update the statistics and READ_ONCE() to read it. Link: https://lore.kernel.org/r/20220506105758.283887-3-bigeasy@linutronix.de Reviewed-by: Davidlohr Bueso Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Martin K. Petersen --- drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 22 +++++------------- drivers/scsi/bnx2fc/bnx2fc_io.c | 13 +++++------ drivers/scsi/fcoe/fcoe.c | 36 ++++++++++-------------------- drivers/scsi/fcoe/fcoe_ctlr.c | 26 ++++++++------------- drivers/scsi/fcoe/fcoe_transport.c | 6 ++--- drivers/scsi/libfc/fc_fcp.c | 29 +++++++++--------------- drivers/scsi/libfc/fc_lport.c | 30 ++++++++++++------------- drivers/scsi/qedf/qedf_main.c | 7 ++---- 8 files changed, 62 insertions(+), 107 deletions(-) diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c index d295867a9b46..05ddbb9bb7d8 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c @@ -273,7 +273,6 @@ static int bnx2fc_xmit(struct fc_lport *lport, struct fc_frame *fp) struct fcoe_port *port; struct fcoe_hdr *hp; struct bnx2fc_rport *tgt; - struct fc_stats *stats; u8 sof, eof; u32 crc; unsigned int hlen, tlen, elen; @@ -399,10 +398,8 @@ static int bnx2fc_xmit(struct fc_lport *lport, struct fc_frame *fp) } /*update tx stats */ - stats = per_cpu_ptr(lport->stats, get_cpu()); - stats->TxFrames++; - stats->TxWords += wlen; - put_cpu(); + this_cpu_inc(lport->stats->TxFrames); + this_cpu_add(lport->stats->TxWords, wlen); /* send down to lld */ fr_dev(fp) = lport; @@ -512,7 +509,6 @@ static void bnx2fc_recv_frame(struct sk_buff *skb) u32 fr_len, fr_crc; struct fc_lport *lport; struct fcoe_rcv_info *fr; - struct fc_stats *stats; struct fc_frame_header *fh; struct fcoe_crc_eof crc_eof; struct fc_frame *fp; @@ -543,10 +539,8 @@ static void bnx2fc_recv_frame(struct sk_buff *skb) skb_pull(skb, sizeof(struct fcoe_hdr)); fr_len = skb->len - sizeof(struct fcoe_crc_eof); - stats = per_cpu_ptr(lport->stats, get_cpu()); - stats->RxFrames++; - stats->RxWords += fr_len / FCOE_WORD_TO_BYTE; - put_cpu(); + this_cpu_inc(lport->stats->RxFrames); + this_cpu_add(lport->stats->RxWords, fr_len / FCOE_WORD_TO_BYTE); fp = (struct fc_frame *)skb; fc_frame_init(fp); @@ -633,9 +627,7 @@ static void bnx2fc_recv_frame(struct sk_buff *skb) fr_crc = le32_to_cpu(fr_crc(fp)); if (unlikely(fr_crc != ~crc32(~0, skb->data, fr_len))) { - stats = per_cpu_ptr(lport->stats, get_cpu()); - crc_err = (stats->InvalidCRCCount++); - put_cpu(); + crc_err = this_cpu_inc_return(lport->stats->InvalidCRCCount); if (crc_err < 5) printk(KERN_WARNING PFX "dropping frame with " "CRC error\n"); @@ -964,9 +956,7 @@ static void bnx2fc_indicate_netevent(void *context, unsigned long event, mutex_unlock(&lport->lp_mutex); fc_host_port_type(lport->host) = FC_PORTTYPE_UNKNOWN; - per_cpu_ptr(lport->stats, - get_cpu())->LinkFailureCount++; - put_cpu(); + this_cpu_inc(lport->stats->LinkFailureCount); fcoe_clean_pending_queue(lport); wait_for_upload = 1; } diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c index 962454f2e2b1..6a1fc35b832a 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_io.c +++ b/drivers/scsi/bnx2fc/bnx2fc_io.c @@ -2032,7 +2032,6 @@ int bnx2fc_post_io_req(struct bnx2fc_rport *tgt, struct bnx2fc_interface *interface = port->priv; struct bnx2fc_hba *hba = interface->hba; struct fc_lport *lport = port->lport; - struct fc_stats *stats; int task_idx, index; u16 xid; @@ -2045,20 +2044,18 @@ int bnx2fc_post_io_req(struct bnx2fc_rport *tgt, io_req->data_xfer_len = scsi_bufflen(sc_cmd); bnx2fc_priv(sc_cmd)->io_req = io_req; - stats = per_cpu_ptr(lport->stats, get_cpu()); if (sc_cmd->sc_data_direction == DMA_FROM_DEVICE) { io_req->io_req_flags = BNX2FC_READ; - stats->InputRequests++; - stats->InputBytes += io_req->data_xfer_len; + this_cpu_inc(lport->stats->InputRequests); + this_cpu_add(lport->stats->InputBytes, io_req->data_xfer_len); } else if (sc_cmd->sc_data_direction == DMA_TO_DEVICE) { io_req->io_req_flags = BNX2FC_WRITE; - stats->OutputRequests++; - stats->OutputBytes += io_req->data_xfer_len; + this_cpu_inc(lport->stats->OutputRequests); + this_cpu_add(lport->stats->OutputBytes, io_req->data_xfer_len); } else { io_req->io_req_flags = 0; - stats->ControlRequests++; + this_cpu_inc(lport->stats->ControlRequests); } - put_cpu(); xid = io_req->xid; diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c index af9b788823ac..8bff94b5474c 100644 --- a/drivers/scsi/fcoe/fcoe.c +++ b/drivers/scsi/fcoe/fcoe.c @@ -1434,8 +1434,7 @@ static int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev, return NET_RX_SUCCESS; err: - per_cpu_ptr(lport->stats, get_cpu())->ErrorFrames++; - put_cpu(); + this_cpu_inc(lport->stats->ErrorFrames); err2: kfree_skb(skb); return NET_RX_DROP; @@ -1475,7 +1474,6 @@ static int fcoe_xmit(struct fc_lport *lport, struct fc_frame *fp) struct ethhdr *eh; struct fcoe_crc_eof *cp; struct sk_buff *skb; - struct fc_stats *stats; struct fc_frame_header *fh; unsigned int hlen; /* header length implies the version */ unsigned int tlen; /* trailer length */ @@ -1586,10 +1584,8 @@ static int fcoe_xmit(struct fc_lport *lport, struct fc_frame *fp) skb_shinfo(skb)->gso_size = 0; } /* update tx stats: regardless if LLD fails */ - stats = per_cpu_ptr(lport->stats, get_cpu()); - stats->TxFrames++; - stats->TxWords += wlen; - put_cpu(); + this_cpu_inc(lport->stats->TxFrames); + this_cpu_add(lport->stats->TxWords, wlen); /* send down to lld */ fr_dev(fp) = lport; @@ -1611,7 +1607,6 @@ static inline int fcoe_filter_frames(struct fc_lport *lport, struct fcoe_interface *fcoe; struct fc_frame_header *fh; struct sk_buff *skb = (struct sk_buff *)fp; - struct fc_stats *stats; /* * We only check CRC if no offload is available and if it is @@ -1641,11 +1636,8 @@ static inline int fcoe_filter_frames(struct fc_lport *lport, return 0; } - stats = per_cpu_ptr(lport->stats, get_cpu()); - stats->InvalidCRCCount++; - if (stats->InvalidCRCCount < 5) + if (this_cpu_inc_return(lport->stats->InvalidCRCCount) < 5) printk(KERN_WARNING "fcoe: dropping frame with CRC error\n"); - put_cpu(); return -EINVAL; } @@ -1658,7 +1650,6 @@ static void fcoe_recv_frame(struct sk_buff *skb) u32 fr_len; struct fc_lport *lport; struct fcoe_rcv_info *fr; - struct fc_stats *stats; struct fcoe_crc_eof crc_eof; struct fc_frame *fp; struct fcoe_hdr *hp; @@ -1686,9 +1677,11 @@ static void fcoe_recv_frame(struct sk_buff *skb) */ hp = (struct fcoe_hdr *) skb_network_header(skb); - stats = per_cpu_ptr(lport->stats, get_cpu()); if (unlikely(FC_FCOE_DECAPS_VER(hp) != FC_FCOE_VER)) { - if (stats->ErrorFrames < 5) + struct fc_stats *stats; + + stats = per_cpu_ptr(lport->stats, raw_smp_processor_id()); + if (READ_ONCE(stats->ErrorFrames) < 5) printk(KERN_WARNING "fcoe: FCoE version " "mismatch: The frame has " "version %x, but the " @@ -1701,8 +1694,8 @@ static void fcoe_recv_frame(struct sk_buff *skb) skb_pull(skb, sizeof(struct fcoe_hdr)); fr_len = skb->len - sizeof(struct fcoe_crc_eof); - stats->RxFrames++; - stats->RxWords += fr_len / FCOE_WORD_TO_BYTE; + this_cpu_inc(lport->stats->RxFrames); + this_cpu_add(lport->stats->RxWords, fr_len / FCOE_WORD_TO_BYTE); fp = (struct fc_frame *)skb; fc_frame_init(fp); @@ -1718,13 +1711,11 @@ static void fcoe_recv_frame(struct sk_buff *skb) goto drop; if (!fcoe_filter_frames(lport, fp)) { - put_cpu(); fc_exch_recv(lport, fp); return; } drop: - stats->ErrorFrames++; - put_cpu(); + this_cpu_inc(lport->stats->ErrorFrames); kfree_skb(skb); } @@ -1848,7 +1839,6 @@ static int fcoe_device_notification(struct notifier_block *notifier, struct net_device *netdev = netdev_notifier_info_to_dev(ptr); struct fcoe_ctlr *ctlr; struct fcoe_interface *fcoe; - struct fc_stats *stats; u32 link_possible = 1; u32 mfs; int rc = NOTIFY_OK; @@ -1922,9 +1912,7 @@ static int fcoe_device_notification(struct notifier_block *notifier, break; case FCOE_CTLR_ENABLED: case FCOE_CTLR_UNUSED: - stats = per_cpu_ptr(lport->stats, get_cpu()); - stats->LinkFailureCount++; - put_cpu(); + this_cpu_inc(lport->stats->LinkFailureCount); fcoe_clean_pending_queue(lport); } } diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c index 1756a0ac6f08..8bf70659950d 100644 --- a/drivers/scsi/fcoe/fcoe_ctlr.c +++ b/drivers/scsi/fcoe/fcoe_ctlr.c @@ -824,22 +824,21 @@ static unsigned long fcoe_ctlr_age_fcfs(struct fcoe_ctlr *fip) unsigned long deadline; unsigned long sel_time = 0; struct list_head del_list; - struct fc_stats *stats; INIT_LIST_HEAD(&del_list); - stats = per_cpu_ptr(fip->lp->stats, get_cpu()); - list_for_each_entry_safe(fcf, next, &fip->fcfs, list) { deadline = fcf->time + fcf->fka_period + fcf->fka_period / 2; if (fip->sel_fcf == fcf) { if (time_after(jiffies, deadline)) { - stats->MissDiscAdvCount++; + u64 miss_cnt; + + miss_cnt = this_cpu_inc_return(fip->lp->stats->MissDiscAdvCount); printk(KERN_INFO "libfcoe: host%d: " "Missing Discovery Advertisement " "for fab %16.16llx count %lld\n", fip->lp->host->host_no, fcf->fabric_name, - stats->MissDiscAdvCount); + miss_cnt); } else if (time_after(next_timer, deadline)) next_timer = deadline; } @@ -855,7 +854,7 @@ static unsigned long fcoe_ctlr_age_fcfs(struct fcoe_ctlr *fip) */ list_del(&fcf->list); list_add(&fcf->list, &del_list); - stats->VLinkFailureCount++; + this_cpu_inc(fip->lp->stats->VLinkFailureCount); } else { if (time_after(next_timer, deadline)) next_timer = deadline; @@ -864,7 +863,6 @@ static unsigned long fcoe_ctlr_age_fcfs(struct fcoe_ctlr *fip) sel_time = fcf->time; } } - put_cpu(); list_for_each_entry_safe(fcf, next, &del_list, list) { /* Removes fcf from current list */ @@ -1142,7 +1140,6 @@ static void fcoe_ctlr_recv_els(struct fcoe_ctlr *fip, struct sk_buff *skb) struct fip_desc *desc; struct fip_encaps *els; struct fcoe_fcf *sel; - struct fc_stats *stats; enum fip_desc_type els_dtype = 0; u8 els_op; u8 sub; @@ -1286,10 +1283,8 @@ static void fcoe_ctlr_recv_els(struct fcoe_ctlr *fip, struct sk_buff *skb) fr_dev(fp) = lport; fr_encaps(fp) = els_dtype; - stats = per_cpu_ptr(lport->stats, get_cpu()); - stats->RxFrames++; - stats->RxWords += skb->len / FIP_BPW; - put_cpu(); + this_cpu_inc(lport->stats->RxFrames); + this_cpu_add(lport->stats->RxWords, skb->len / FIP_BPW); fc_exch_recv(lport, fp); return; @@ -1427,9 +1422,7 @@ static void fcoe_ctlr_recv_clr_vlink(struct fcoe_ctlr *fip, ntoh24(vp->fd_fc_id)); if (vn_port && (vn_port == lport)) { mutex_lock(&fip->ctlr_mutex); - per_cpu_ptr(lport->stats, - get_cpu())->VLinkFailureCount++; - put_cpu(); + this_cpu_inc(lport->stats->VLinkFailureCount); fcoe_ctlr_reset(fip); mutex_unlock(&fip->ctlr_mutex); } @@ -1457,8 +1450,7 @@ static void fcoe_ctlr_recv_clr_vlink(struct fcoe_ctlr *fip, * followed by physical port */ mutex_lock(&fip->ctlr_mutex); - per_cpu_ptr(lport->stats, get_cpu())->VLinkFailureCount++; - put_cpu(); + this_cpu_inc(lport->stats->VLinkFailureCount); fcoe_ctlr_reset(fip); mutex_unlock(&fip->ctlr_mutex); diff --git a/drivers/scsi/fcoe/fcoe_transport.c b/drivers/scsi/fcoe/fcoe_transport.c index 4d0e19e7c84b..62341c6353a7 100644 --- a/drivers/scsi/fcoe/fcoe_transport.c +++ b/drivers/scsi/fcoe/fcoe_transport.c @@ -183,9 +183,9 @@ void __fcoe_get_lesb(struct fc_lport *lport, memset(lesb, 0, sizeof(*lesb)); for_each_possible_cpu(cpu) { stats = per_cpu_ptr(lport->stats, cpu); - lfc += stats->LinkFailureCount; - vlfc += stats->VLinkFailureCount; - mdac += stats->MissDiscAdvCount; + lfc += READ_ONCE(stats->LinkFailureCount); + vlfc += READ_ONCE(stats->VLinkFailureCount); + mdac += READ_ONCE(stats->MissDiscAdvCount); } lesb->lesb_link_fail = htonl(lfc); lesb->lesb_vlink_fail = htonl(vlfc); diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c index bce90eb56c9c..945adca5e72f 100644 --- a/drivers/scsi/libfc/fc_fcp.c +++ b/drivers/scsi/libfc/fc_fcp.c @@ -143,8 +143,7 @@ static struct fc_fcp_pkt *fc_fcp_pkt_alloc(struct fc_lport *lport, gfp_t gfp) INIT_LIST_HEAD(&fsp->list); spin_lock_init(&fsp->scsi_pkt_lock); } else { - per_cpu_ptr(lport->stats, get_cpu())->FcpPktAllocFails++; - put_cpu(); + this_cpu_inc(lport->stats->FcpPktAllocFails); } return fsp; } @@ -266,8 +265,7 @@ static int fc_fcp_send_abort(struct fc_fcp_pkt *fsp) if (!fsp->seq_ptr) return -EINVAL; - per_cpu_ptr(fsp->lp->stats, get_cpu())->FcpPktAborts++; - put_cpu(); + this_cpu_inc(fsp->lp->stats->FcpPktAborts); fsp->state |= FC_SRB_ABORT_PENDING; rc = fc_seq_exch_abort(fsp->seq_ptr, 0); @@ -436,8 +434,7 @@ static inline struct fc_frame *fc_fcp_frame_alloc(struct fc_lport *lport, if (likely(fp)) return fp; - per_cpu_ptr(lport->stats, get_cpu())->FcpFrameAllocFails++; - put_cpu(); + this_cpu_inc(lport->stats->FcpFrameAllocFails); /* error case */ fc_fcp_can_queue_ramp_down(lport); shost_printk(KERN_ERR, lport->host, @@ -471,7 +468,6 @@ static void fc_fcp_recv_data(struct fc_fcp_pkt *fsp, struct fc_frame *fp) { struct scsi_cmnd *sc = fsp->cmd; struct fc_lport *lport = fsp->lp; - struct fc_stats *stats; struct fc_frame_header *fh; size_t start_offset; size_t offset; @@ -533,14 +529,12 @@ static void fc_fcp_recv_data(struct fc_fcp_pkt *fsp, struct fc_frame *fp) if (~crc != le32_to_cpu(fr_crc(fp))) { crc_err: - stats = per_cpu_ptr(lport->stats, get_cpu()); - stats->ErrorFrames++; + this_cpu_inc(lport->stats->ErrorFrames); /* per cpu count, not total count, but OK for limit */ - if (stats->InvalidCRCCount++ < FC_MAX_ERROR_CNT) + if (this_cpu_inc_return(lport->stats->InvalidCRCCount) < FC_MAX_ERROR_CNT) printk(KERN_WARNING "libfc: CRC error on data " "frame for port (%6.6x)\n", lport->port_id); - put_cpu(); /* * Assume the frame is total garbage. * We may have copied it over the good part @@ -1861,7 +1855,6 @@ int fc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc_cmd) struct fc_fcp_pkt *fsp; int rval; int rc = 0; - struct fc_stats *stats; rval = fc_remote_port_chkready(rport); if (rval) { @@ -1913,20 +1906,18 @@ int fc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc_cmd) /* * setup the data direction */ - stats = per_cpu_ptr(lport->stats, get_cpu()); if (sc_cmd->sc_data_direction == DMA_FROM_DEVICE) { fsp->req_flags = FC_SRB_READ; - stats->InputRequests++; - stats->InputBytes += fsp->data_len; + this_cpu_inc(lport->stats->InputRequests); + this_cpu_add(lport->stats->InputBytes, fsp->data_len); } else if (sc_cmd->sc_data_direction == DMA_TO_DEVICE) { fsp->req_flags = FC_SRB_WRITE; - stats->OutputRequests++; - stats->OutputBytes += fsp->data_len; + this_cpu_inc(lport->stats->OutputRequests); + this_cpu_add(lport->stats->OutputBytes, fsp->data_len); } else { fsp->req_flags = 0; - stats->ControlRequests++; + this_cpu_inc(lport->stats->ControlRequests); } - put_cpu(); /* * send it to the lower layer diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c index 19cd4a95d354..9c02c9523c4d 100644 --- a/drivers/scsi/libfc/fc_lport.c +++ b/drivers/scsi/libfc/fc_lport.c @@ -308,21 +308,21 @@ struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *shost) stats = per_cpu_ptr(lport->stats, cpu); - fc_stats->tx_frames += stats->TxFrames; - fc_stats->tx_words += stats->TxWords; - fc_stats->rx_frames += stats->RxFrames; - fc_stats->rx_words += stats->RxWords; - fc_stats->error_frames += stats->ErrorFrames; - fc_stats->invalid_crc_count += stats->InvalidCRCCount; - fc_stats->fcp_input_requests += stats->InputRequests; - fc_stats->fcp_output_requests += stats->OutputRequests; - fc_stats->fcp_control_requests += stats->ControlRequests; - fcp_in_bytes += stats->InputBytes; - fcp_out_bytes += stats->OutputBytes; - fc_stats->fcp_packet_alloc_failures += stats->FcpPktAllocFails; - fc_stats->fcp_packet_aborts += stats->FcpPktAborts; - fc_stats->fcp_frame_alloc_failures += stats->FcpFrameAllocFails; - fc_stats->link_failure_count += stats->LinkFailureCount; + fc_stats->tx_frames += READ_ONCE(stats->TxFrames); + fc_stats->tx_words += READ_ONCE(stats->TxWords); + fc_stats->rx_frames += READ_ONCE(stats->RxFrames); + fc_stats->rx_words += READ_ONCE(stats->RxWords); + fc_stats->error_frames += READ_ONCE(stats->ErrorFrames); + fc_stats->invalid_crc_count += READ_ONCE(stats->InvalidCRCCount); + fc_stats->fcp_input_requests += READ_ONCE(stats->InputRequests); + fc_stats->fcp_output_requests += READ_ONCE(stats->OutputRequests); + fc_stats->fcp_control_requests += READ_ONCE(stats->ControlRequests); + fcp_in_bytes += READ_ONCE(stats->InputBytes); + fcp_out_bytes += READ_ONCE(stats->OutputBytes); + fc_stats->fcp_packet_alloc_failures += READ_ONCE(stats->FcpPktAllocFails); + fc_stats->fcp_packet_aborts += READ_ONCE(stats->FcpPktAborts); + fc_stats->fcp_frame_alloc_failures += READ_ONCE(stats->FcpFrameAllocFails); + fc_stats->link_failure_count += READ_ONCE(stats->LinkFailureCount); } fc_stats->fcp_input_megabytes = div_u64(fcp_in_bytes, 1000000); fc_stats->fcp_output_megabytes = div_u64(fcp_out_bytes, 1000000); diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index cbe01915da8c..3d6b137314f3 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -1067,7 +1067,6 @@ static int qedf_xmit(struct fc_lport *lport, struct fc_frame *fp) u32 crc; unsigned int hlen, tlen, elen; int wlen; - struct fc_stats *stats; struct fc_lport *tmp_lport; struct fc_lport *vn_port = NULL; struct qedf_rport *fcport; @@ -1215,10 +1214,8 @@ static int qedf_xmit(struct fc_lport *lport, struct fc_frame *fp) hp->fcoe_sof = sof; /*update tx stats */ - stats = per_cpu_ptr(lport->stats, get_cpu()); - stats->TxFrames++; - stats->TxWords += wlen; - put_cpu(); + this_cpu_inc(lport->stats->TxFrames); + this_cpu_add(lport->stats->TxWords, wlen); /* Get VLAN ID from skb for printing purposes */ __vlan_hwaccel_get_tag(skb, &vlan_tci); From a0548edf852a8776dade1e511694b2980c674e2a Mon Sep 17 00:00:00 2001 From: Davidlohr Bueso Date: Fri, 6 May 2022 12:57:57 +0200 Subject: [PATCH 158/177] scsi: libfc: Remove get_cpu() semantics in fc_exch_em_alloc() The get_cpu() in fc_exch_em_alloc() was introduced in commit f018b73af6db ("[SCSI] libfc, libfcoe, fcoe: use smp_processor_id() only when preempt disabled") for no other reason than to simply use smp_processor_id() without getting a warning, because everything is done with the pool->lock held anyway. However, get_cpu(), by disabling preemption, does not play well with PREEMPT_RT, particularly when acquiring a regular (and thus sleepable) spinlock. Therefore remove the get_cpu() and just use the unstable value as we will have CPU locality guarantees next by taking the lock. The window of migration, as noted by Sebastian, is small and even if it happens the result is correct. Link: https://lore.kernel.org/r/20211117025956.79616-2-dave@stgolabs.net Link: https://lore.kernel.org/r/20220506105758.283887-4-bigeasy@linutronix.de Acked-by: Sebastian Andrzej Siewior Signed-off-by: Davidlohr Bueso Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Martin K. Petersen --- drivers/scsi/libfc/fc_exch.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c index aa223db4cf53..1d91c457527f 100644 --- a/drivers/scsi/libfc/fc_exch.c +++ b/drivers/scsi/libfc/fc_exch.c @@ -825,10 +825,9 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport, } memset(ep, 0, sizeof(*ep)); - cpu = get_cpu(); + cpu = raw_smp_processor_id(); pool = per_cpu_ptr(mp->pool, cpu); spin_lock_bh(&pool->lock); - put_cpu(); /* peek cache of free slot */ if (pool->left != FC_XID_UNKNOWN) { From 20f8932f979e7377a625f6e711bd4e84ec025d0b Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Fri, 6 May 2022 12:57:58 +0200 Subject: [PATCH 159/177] scsi: bnx2fc: Avoid using get_cpu() in bnx2fc_cmd_alloc() Using get_cpu() leads to disabling preemption and in this context it is not possible to acquire the following spinlock_t on PREEMPT_RT because it becomes a sleeping lock. Commit 0ea5c27583e1 ("[SCSI] bnx2fc: common free list for cleanup commands") says that it is using get_cpu() as a fix in case the CPU is preempted. While this might be true, the important part is that it is now using the same CPU for locking and unlocking while previously it always relied on smp_processor_id(). The date structure itself is protected with a lock so it does not rely on CPU-local access. Replace get_cpu() with raw_smp_processor_id() to obtain the current CPU number which is used as an index for the per-CPU resource. Link: https://lore.kernel.org/r/20220506105758.283887-5-bigeasy@linutronix.de Reviewed-by: Davidlohr Bueso Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Martin K. Petersen --- drivers/scsi/bnx2fc/bnx2fc_io.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c index 6a1fc35b832a..b42a9accb832 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_io.c +++ b/drivers/scsi/bnx2fc/bnx2fc_io.c @@ -472,7 +472,7 @@ struct bnx2fc_cmd *bnx2fc_cmd_alloc(struct bnx2fc_rport *tgt) u32 free_sqes; u32 max_sqes; u16 xid; - int index = get_cpu(); + int index = raw_smp_processor_id(); max_sqes = BNX2FC_SCSI_MAX_SQES; /* @@ -485,7 +485,6 @@ struct bnx2fc_cmd *bnx2fc_cmd_alloc(struct bnx2fc_rport *tgt) (tgt->num_active_ios.counter >= max_sqes) || (free_sqes + max_sqes <= BNX2FC_SQ_WQES_MAX)) { spin_unlock_bh(&cmd_mgr->free_list_lock[index]); - put_cpu(); return NULL; } @@ -498,7 +497,6 @@ struct bnx2fc_cmd *bnx2fc_cmd_alloc(struct bnx2fc_rport *tgt) atomic_inc(&tgt->num_active_ios); atomic_dec(&tgt->free_sqes); spin_unlock_bh(&cmd_mgr->free_list_lock[index]); - put_cpu(); INIT_LIST_HEAD(&io_req->link); From a25eafd13e5f79d9bbada5a4a4a4224cc5f6d14c Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 6 May 2022 16:17:33 +0300 Subject: [PATCH 160/177] scsi: mpi3mr: Fix a NULL vs IS_ERR() bug in mpi3mr_bsg_init() The bsg_setup_queue() function does not return NULL. It returns error pointers. Fix the check accordingly. Link: https://lore.kernel.org/r/YnUf7RQl+A3tigWh@kili Fixes: 4268fa751365 ("scsi: mpi3mr: Add bsg device support") Signed-off-by: Dan Carpenter Signed-off-by: Martin K. Petersen --- drivers/scsi/mpi3mr/mpi3mr_app.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/mpi3mr/mpi3mr_app.c b/drivers/scsi/mpi3mr/mpi3mr_app.c index 73bb7992d5a8..8138a728d1ab 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_app.c +++ b/drivers/scsi/mpi3mr/mpi3mr_app.c @@ -1540,7 +1540,7 @@ void mpi3mr_bsg_init(struct mpi3mr_ioc *mrioc) mrioc->bsg_queue = bsg_setup_queue(mrioc->bsg_dev, dev_name(mrioc->bsg_dev), mpi3mr_bsg_request, NULL, 0); - if (!mrioc->bsg_queue) { + if (IS_ERR(mrioc->bsg_queue)) { ioc_err(mrioc, "%s: bsg registration failed\n", dev_name(mrioc->bsg_dev)); goto err_setup_queue; From aabd5fea49461c7b3a70d7aaa965e8cb3f19b7e7 Mon Sep 17 00:00:00 2001 From: Minghao Chi Date: Tue, 10 May 2022 10:51:13 +0000 Subject: [PATCH 161/177] scsi: ipr: Use kobj_to_dev() Use kobj_to_dev() instead of open-coding it. Link: https://lore.kernel.org/r/20220510105113.1351891-1-chi.minghao@zte.com.cn Reported-by: Zeal Robot Acked-by: Brian King Signed-off-by: Minghao Chi Signed-off-by: Martin K. Petersen --- drivers/scsi/ipr.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index 353cf47db79c..256ec6d08c16 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c @@ -3456,7 +3456,7 @@ static ssize_t ipr_read_trace(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { - struct device *dev = container_of(kobj, struct device, kobj); + struct device *dev = kobj_to_dev(kobj); struct Scsi_Host *shost = class_to_shost(dev); struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; unsigned long lock_flags = 0; @@ -4182,7 +4182,7 @@ static ssize_t ipr_read_async_err_log(struct file *filep, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { - struct device *cdev = container_of(kobj, struct device, kobj); + struct device *cdev = kobj_to_dev(kobj); struct Scsi_Host *shost = class_to_shost(cdev); struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; struct ipr_hostrcb *hostrcb; @@ -4206,7 +4206,7 @@ static ssize_t ipr_next_async_err_log(struct file *filep, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { - struct device *cdev = container_of(kobj, struct device, kobj); + struct device *cdev = kobj_to_dev(kobj); struct Scsi_Host *shost = class_to_shost(cdev); struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; struct ipr_hostrcb *hostrcb; @@ -4267,7 +4267,7 @@ static ssize_t ipr_read_dump(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { - struct device *cdev = container_of(kobj, struct device, kobj); + struct device *cdev = kobj_to_dev(kobj); struct Scsi_Host *shost = class_to_shost(cdev); struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; struct ipr_dump *dump; @@ -4456,7 +4456,7 @@ static ssize_t ipr_write_dump(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { - struct device *cdev = container_of(kobj, struct device, kobj); + struct device *cdev = kobj_to_dev(kobj); struct Scsi_Host *shost = class_to_shost(cdev); struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata; int rc; From 8e129add48e0c35a8f1bf5df91f50a438dd75ba6 Mon Sep 17 00:00:00 2001 From: Sreekanth Reddy Date: Wed, 11 May 2022 12:56:20 +0530 Subject: [PATCH 162/177] scsi: mpt3sas: Fix junk chars displayed while printing ChipName Terminate string after copying 16 bytes of ChipName data from Manufacturing Page0 to prevent %s from printing junk characters. Link: https://lore.kernel.org/r/20220511072621.30657-1-sreekanth.reddy@broadcom.com Signed-off-by: Sreekanth Reddy Signed-off-by: Martin K. Petersen --- drivers/scsi/mpt3sas/mpt3sas_base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 4961be5d527b..37d46ae5c61d 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -4753,7 +4753,7 @@ static void _base_display_ioc_capabilities(struct MPT3SAS_ADAPTER *ioc) { int i = 0; - char desc[16]; + char desc[17] = {0}; u32 iounit_pg1_flags; u32 bios_version; From 53d5088deff64c526ac52b39ce1244ce10372367 Mon Sep 17 00:00:00 2001 From: Sreekanth Reddy Date: Wed, 11 May 2022 12:56:21 +0530 Subject: [PATCH 163/177] scsi: mpt3sas: Update driver version to 42.100.00.00 Update driver version to 42.100.00.00. Link: https://lore.kernel.org/r/20220511072621.30657-2-sreekanth.reddy@broadcom.com Signed-off-by: Sreekanth Reddy Signed-off-by: Martin K. Petersen --- drivers/scsi/mpt3sas/mpt3sas_base.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h index 209f8680c01d..e584cf0ffc23 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h @@ -77,8 +77,8 @@ #define MPT3SAS_DRIVER_NAME "mpt3sas" #define MPT3SAS_AUTHOR "Avago Technologies " #define MPT3SAS_DESCRIPTION "LSI MPT Fusion SAS 3.0 Device Driver" -#define MPT3SAS_DRIVER_VERSION "40.100.00.00" -#define MPT3SAS_MAJOR_VERSION 40 +#define MPT3SAS_DRIVER_VERSION "42.100.00.00" +#define MPT3SAS_MAJOR_VERSION 42 #define MPT3SAS_MINOR_VERSION 100 #define MPT3SAS_BUILD_VERSION 0 #define MPT3SAS_RELEASE_VERSION 00 From 057e5fc03369f8f2ed9b2ca884754b1d80b83620 Mon Sep 17 00:00:00 2001 From: John Garry Date: Thu, 12 May 2022 19:15:32 +0800 Subject: [PATCH 164/177] scsi: libsas: Refactor sas_ata_hard_reset() Create function sas_ata_wait_after_reset() from sas_ata_hard_reset() as some LLDDs may want to check for a remote ATA phy is up after reset. Link: https://lore.kernel.org/r/1652354134-171343-2-git-send-email-john.garry@huawei.com Tested-by: Yihang Li Reviewed-by: Xiang Chen Signed-off-by: John Garry Signed-off-by: Martin K. Petersen --- drivers/scsi/libsas/sas_ata.c | 41 +++++++++++++++++++++++------------ include/scsi/sas_ata.h | 7 ++++++ 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c index d34c82e24d9a..d35c9296f738 100644 --- a/drivers/scsi/libsas/sas_ata.c +++ b/drivers/scsi/libsas/sas_ata.c @@ -358,22 +358,14 @@ static int sas_ata_printk(const char *level, const struct domain_device *ddev, return r; } -static int sas_ata_hard_reset(struct ata_link *link, unsigned int *class, - unsigned long deadline) +int sas_ata_wait_after_reset(struct domain_device *dev, unsigned long deadline) { - int ret = 0, res; - struct sas_phy *phy; - struct ata_port *ap = link->ap; + struct sata_device *sata_dev = &dev->sata_dev; int (*check_ready)(struct ata_link *link); - struct domain_device *dev = ap->private_data; - struct sas_internal *i = dev_to_sas_internal(dev); - - res = i->dft->lldd_I_T_nexus_reset(dev); - if (res == -ENODEV) - return res; - - if (res != TMF_RESP_FUNC_COMPLETE) - sas_ata_printk(KERN_DEBUG, dev, "Unable to reset ata device?\n"); + struct ata_port *ap = sata_dev->ap; + struct ata_link *link = &ap->link; + struct sas_phy *phy; + int ret; phy = sas_get_local_phy(dev); if (scsi_is_sas_phy_local(phy)) @@ -386,6 +378,27 @@ static int sas_ata_hard_reset(struct ata_link *link, unsigned int *class, if (ret && ret != -EAGAIN) sas_ata_printk(KERN_ERR, dev, "reset failed (errno=%d)\n", ret); + return ret; +} +EXPORT_SYMBOL_GPL(sas_ata_wait_after_reset); + +static int sas_ata_hard_reset(struct ata_link *link, unsigned int *class, + unsigned long deadline) +{ + struct ata_port *ap = link->ap; + struct domain_device *dev = ap->private_data; + struct sas_internal *i = dev_to_sas_internal(dev); + int ret; + + ret = i->dft->lldd_I_T_nexus_reset(dev); + if (ret == -ENODEV) + return ret; + + if (ret != TMF_RESP_FUNC_COMPLETE) + sas_ata_printk(KERN_DEBUG, dev, "Unable to reset ata device?\n"); + + ret = sas_ata_wait_after_reset(dev, deadline); + *class = dev->sata_dev.class; ap->cbl = ATA_CBL_SATA; diff --git a/include/scsi/sas_ata.h b/include/scsi/sas_ata.h index d47dea70855d..a1df4f9d57a3 100644 --- a/include/scsi/sas_ata.h +++ b/include/scsi/sas_ata.h @@ -34,6 +34,7 @@ void sas_resume_sata(struct asd_sas_port *port); void sas_ata_end_eh(struct ata_port *ap); int sas_execute_ata_cmd(struct domain_device *device, u8 *fis, int force_phy_id); +int sas_ata_wait_after_reset(struct domain_device *dev, unsigned long deadline); #else @@ -91,6 +92,12 @@ static inline int sas_execute_ata_cmd(struct domain_device *device, u8 *fis, { return 0; } + +static inline int sas_ata_wait_after_reset(struct domain_device *dev, + unsigned long deadline) +{ + return -ETIMEDOUT; +} #endif #endif /* _SAS_ATA_H_ */ From 71453bd9d1bfa2a75f742ac8ad75c084097e9a50 Mon Sep 17 00:00:00 2001 From: John Garry Date: Thu, 12 May 2022 19:15:33 +0800 Subject: [PATCH 165/177] scsi: hisi_sas: Use sas_ata_wait_after_reset() in IT nexus reset We have seen errors like this when a SATA device is probed: [524.566298] hisi_sas_v3_hw 0000L74:02.0: erroneous completion iptt=4096 ... [524.582827] sas: TMF task open reject failed 500e004aaaaaaaa00 Since commit 21c7e972475e ("scsi: hisi_sas: Disable SATA disk phy for severe I_T nexus reset failure"), we issue an ATA softreset to disks after a phy reset to ensure that they are in sound working order. If the softreset is issued before the remote phy has come back up then the softreset will fail (errors as above). Remedy this by waiting for the phy to come back up after the reset. Link: https://lore.kernel.org/r/1652354134-171343-3-git-send-email-john.garry@huawei.com Tested-by: Yihang Li Reviewed-by: Xiang Chen Signed-off-by: John Garry Signed-off-by: Martin K. Petersen --- drivers/scsi/hisi_sas/hisi_sas_main.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 4bda2f6cb352..997f27e2f1e5 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -1710,13 +1710,18 @@ static int hisi_sas_debug_I_T_nexus_reset(struct domain_device *device) /* report PHY down if timed out */ if (rc == -ETIMEDOUT) hisi_sas_phy_down(hisi_hba, sas_phy->id, 0, GFP_KERNEL); - } else if (sas_dev->dev_status != HISI_SAS_DEV_INIT) { - /* - * If in init state, we rely on caller to wait for link to be - * ready; otherwise, except phy reset is fail, delay. - */ - if (!rc) - msleep(2000); + return rc; + } + + if (rc) + return rc; + + /* Remote phy */ + if (dev_is_sata(device)) { + rc = sas_ata_wait_after_reset(device, + HISI_SAS_WAIT_PHYUP_TIMEOUT); + } else { + msleep(2000); } return rc; From e9dedc13bb11bc553754abecb322e5e41d1b4fef Mon Sep 17 00:00:00 2001 From: John Garry Date: Thu, 12 May 2022 19:15:34 +0800 Subject: [PATCH 166/177] scsi: hisi_sas: Fix rescan after deleting a disk Removing an ATA device via sysfs means that the device may not be found through re-scanning: root@ubuntu:/home/john# lsscsi [0:0:0:0] disk SanDisk LT0200MO P404 /dev/sda [0:0:1:0] disk ATA HGST HUS724040AL A8B0 /dev/sdb [0:0:8:0] enclosu 12G SAS Expander RevB - root@ubuntu:/home/john# echo 1 > /sys/block/sdb/device/delete root@ubuntu:/home/john# echo "- - -" > /sys/class/scsi_host/host0/scan root@ubuntu:/home/john# lsscsi [0:0:0:0] disk SanDisk LT0200MO P404 /dev/sda [0:0:8:0] enclosu 12G SAS Expander RevB - root@ubuntu:/home/john# The problem is that the rescan of the device may conflict with the device in being re-initialized, as follows: - In the rescan we call hisi_sas_slave_alloc() in store_scan() -> sas_user_scan() -> [__]scsi_scan_target() -> scsi_probe_and_add_lunc() -> scsi_alloc_sdev() -> hisi_sas_slave_alloc() -> hisi_sas_init_device() In hisi_sas_init_device() we issue an IT nexus reset for ATA devices - That IT nexus causes the remote PHY to go down and this triggers a bcast event - In parallel libsas processes the bcast event, finds that the phy is down and marks the device as gone The hard reset issued in hisi_sas_init_device() is unncessary - as described in the code comment - so remove it. Also set dev status as HISI_SAS_DEV_NORMAL as the hisi_sas_init_device() call. Link: https://lore.kernel.org/r/1652354134-171343-4-git-send-email-john.garry@huawei.com Fixes: 36c6b7613ef1 ("scsi: hisi_sas: Initialise devices in .slave_alloc callback") Tested-by: Yihang Li Reviewed-by: Xiang Chen Signed-off-by: John Garry Signed-off-by: Martin K. Petersen --- drivers/scsi/hisi_sas/hisi_sas_main.c | 47 ++++++++++----------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 997f27e2f1e5..f81e74fd6263 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -709,8 +709,6 @@ static int hisi_sas_init_device(struct domain_device *device) struct scsi_lun lun; int retry = HISI_SAS_DISK_RECOVER_CNT; struct hisi_hba *hisi_hba = dev_to_hisi_hba(device); - struct device *dev = hisi_hba->dev; - struct sas_phy *local_phy; switch (device->dev_type) { case SAS_END_DEVICE: @@ -729,30 +727,18 @@ static int hisi_sas_init_device(struct domain_device *device) case SAS_SATA_PM_PORT: case SAS_SATA_PENDING: /* - * send HARD RESET to clear previous affiliation of - * STP target port + * If an expander is swapped when a SATA disk is attached then + * we should issue a hard reset to clear previous affiliation + * of STP target port, see SPL (chapter 6.19.4). + * + * However we don't need to issue a hard reset here for these + * reasons: + * a. When probing the device, libsas/libata already issues a + * hard reset in sas_probe_sata() -> ata_sas_async_probe(). + * Note that in hisi_sas_debug_I_T_nexus_reset() we take care + * to issue a hard reset by checking the dev status (== INIT). + * b. When resetting the controller, this is simply unnecessary. */ - local_phy = sas_get_local_phy(device); - if (!scsi_is_sas_phy_local(local_phy) && - !test_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags)) { - unsigned long deadline = ata_deadline(jiffies, 20000); - struct sata_device *sata_dev = &device->sata_dev; - struct ata_host *ata_host = sata_dev->ata_host; - struct ata_port_operations *ops = ata_host->ops; - struct ata_port *ap = sata_dev->ap; - struct ata_link *link; - unsigned int classes; - - ata_for_each_link(link, ap, EDGE) - rc = ops->hardreset(link, &classes, - deadline); - } - sas_put_local_phy(local_phy); - if (rc) { - dev_warn(dev, "SATA disk hardreset fail: %d\n", rc); - return rc; - } - while (retry-- > 0) { rc = hisi_sas_softreset_ata_disk(device); if (!rc) @@ -768,15 +754,19 @@ static int hisi_sas_init_device(struct domain_device *device) int hisi_sas_slave_alloc(struct scsi_device *sdev) { - struct domain_device *ddev; + struct domain_device *ddev = sdev_to_domain_dev(sdev); + struct hisi_sas_device *sas_dev = ddev->lldd_dev; int rc; rc = sas_slave_alloc(sdev); if (rc) return rc; - ddev = sdev_to_domain_dev(sdev); - return hisi_sas_init_device(ddev); + rc = hisi_sas_init_device(ddev); + if (rc) + return rc; + sas_dev->dev_status = HISI_SAS_DEV_NORMAL; + return 0; } EXPORT_SYMBOL_GPL(hisi_sas_slave_alloc); @@ -826,7 +816,6 @@ static int hisi_sas_dev_found(struct domain_device *device) dev_info(dev, "dev[%d:%x] found\n", sas_dev->device_id, sas_dev->dev_type); - sas_dev->dev_status = HISI_SAS_DEV_NORMAL; return 0; err_out: From bc7896d31a922ee9caabb10dc07509f65d41dc0e Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 5 May 2022 13:25:52 +0300 Subject: [PATCH 167/177] scsi: mpi3mr: Return error if dma_alloc_coherent() fails Return -ENOMEM instead of success if dma_alloc_coherent() fails. Link: https://lore.kernel.org/r/YnOmMGHqCOtUCYQ1@kili Fixes: 43ca11005098 ("scsi: mpi3mr: Add support for PEL commands") Signed-off-by: Dan Carpenter Signed-off-by: Martin K. Petersen --- drivers/scsi/mpi3mr/mpi3mr_fw.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/mpi3mr/mpi3mr_fw.c b/drivers/scsi/mpi3mr/mpi3mr_fw.c index 74e09727a1b8..f1d4ea8ba989 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_fw.c +++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c @@ -3754,8 +3754,10 @@ retry_init: mrioc->pel_seqnum_virt = dma_alloc_coherent(&mrioc->pdev->dev, mrioc->pel_seqnum_sz, &mrioc->pel_seqnum_dma, GFP_KERNEL); - if (!mrioc->pel_seqnum_virt) + if (!mrioc->pel_seqnum_virt) { + retval = -ENOMEM; goto out_failed_noretry; + } } retval = mpi3mr_enable_events(mrioc); @@ -3873,8 +3875,10 @@ retry_init: mrioc->pel_seqnum_virt = dma_alloc_coherent(&mrioc->pdev->dev, mrioc->pel_seqnum_sz, &mrioc->pel_seqnum_dma, GFP_KERNEL); - if (!mrioc->pel_seqnum_virt) + if (!mrioc->pel_seqnum_virt) { + retval = -ENOMEM; goto out_failed_noretry; + } } if (mrioc->shost->nr_hw_queues > mrioc->num_op_reply_q) { From 2f9e9a7b0ce38471c6f22a762adca6a977edfa7d Mon Sep 17 00:00:00 2001 From: Harshit Mogalapalli Date: Thu, 5 May 2022 07:32:13 -0700 Subject: [PATCH 168/177] scsi: megaraid_sas: Remove redundant memset() statement As memset() of scmd->sense_buffer is immediately followed by a memcpy() where scmd->sense_buffer is the destination. The memset() is redundant. Link: https://lore.kernel.org/r/20220505143214.44908-1-harshit.m.mogalapalli@oracle.com Signed-off-by: Harshit Mogalapalli Signed-off-by: Martin K. Petersen --- drivers/scsi/megaraid/megaraid_sas_fusion.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index 54fde2661952..5b5885d9732b 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -2047,8 +2047,6 @@ map_cmd_status(struct fusion_context *fusion, scmd->result = (DID_OK << 16) | ext_status; if (ext_status == SAM_STAT_CHECK_CONDITION) { - memset(scmd->sense_buffer, 0, - SCSI_SENSE_BUFFERSIZE); memcpy(scmd->sense_buffer, sense, SCSI_SENSE_BUFFERSIZE); } From e79aaa9cc02dd39061eb4e2c7d156532a31da975 Mon Sep 17 00:00:00 2001 From: Harshit Mogalapalli Date: Thu, 5 May 2022 07:36:57 -0700 Subject: [PATCH 169/177] scsi: elx: efct: Remove redundant memset() statement As memset() of bmbx is immediately followed by a memcpy() where bmbx is the destination, the memset() is redundant. Link: https://lore.kernel.org/r/20220505143703.45441-1-harshit.m.mogalapalli@oracle.com Signed-off-by: Harshit Mogalapalli Signed-off-by: Martin K. Petersen --- drivers/scsi/elx/efct/efct_hw.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/elx/efct/efct_hw.c b/drivers/scsi/elx/efct/efct_hw.c index d4bb37960a3c..5a5525054d71 100644 --- a/drivers/scsi/elx/efct/efct_hw.c +++ b/drivers/scsi/elx/efct/efct_hw.c @@ -1402,7 +1402,6 @@ efct_hw_command(struct efct_hw *hw, u8 *cmd, u32 opts, void *cb, void *arg) mutex_lock(&hw->bmbx_lock); bmbx = hw->sli.bmbx.virt; - memset(bmbx, 0, SLI4_BMBX_SIZE); memcpy(bmbx, cmd, SLI4_BMBX_SIZE); if (sli_bmbx_command(&hw->sli) == 0) { From e51e76edddb10867f95df0c24a9769d6d97afeb0 Mon Sep 17 00:00:00 2001 From: Sreekanth Reddy Date: Tue, 17 May 2022 17:23:09 +0530 Subject: [PATCH 170/177] scsi: mpi3mr: Add shost related sysfs attributes Add shost related sysfs attributes to display the controller's firmware version, queue depth, number of requests, and number of reply queues. Also add an attribute to set & get the logging_level. Link: https://lore.kernel.org/r/20220517115310.13062-2-sreekanth.reddy@broadcom.com Reviewed-by: Himanshu Madhani Signed-off-by: Sreekanth Reddy Signed-off-by: Martin K. Petersen --- drivers/scsi/mpi3mr/mpi3mr_app.c | 143 ++++++++++++++++++++++++++++++- 1 file changed, 141 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/mpi3mr/mpi3mr_app.c b/drivers/scsi/mpi3mr/mpi3mr_app.c index 8138a728d1ab..33bad2fdc28e 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_app.c +++ b/drivers/scsi/mpi3mr/mpi3mr_app.c @@ -1558,13 +1558,147 @@ err_device_add: kfree(mrioc->bsg_dev); } +/** + * version_fw_show - SysFS callback for firmware version read + * @dev: class device + * @attr: Device attributes + * @buf: Buffer to copy + * + * Return: sysfs_emit() return after copying firmware version + */ +static ssize_t +version_fw_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct Scsi_Host *shost = class_to_shost(dev); + struct mpi3mr_ioc *mrioc = shost_priv(shost); + struct mpi3mr_compimg_ver *fwver = &mrioc->facts.fw_ver; + + return sysfs_emit(buf, "%d.%d.%d.%d.%05d-%05d\n", + fwver->gen_major, fwver->gen_minor, fwver->ph_major, + fwver->ph_minor, fwver->cust_id, fwver->build_num); +} +static DEVICE_ATTR_RO(version_fw); + +/** + * fw_queue_depth_show - SysFS callback for firmware max cmds + * @dev: class device + * @attr: Device attributes + * @buf: Buffer to copy + * + * Return: sysfs_emit() return after copying firmware max commands + */ +static ssize_t +fw_queue_depth_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct Scsi_Host *shost = class_to_shost(dev); + struct mpi3mr_ioc *mrioc = shost_priv(shost); + + return sysfs_emit(buf, "%d\n", mrioc->facts.max_reqs); +} +static DEVICE_ATTR_RO(fw_queue_depth); + +/** + * op_req_q_count_show - SysFS callback for request queue count + * @dev: class device + * @attr: Device attributes + * @buf: Buffer to copy + * + * Return: sysfs_emit() return after copying request queue count + */ +static ssize_t +op_req_q_count_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct Scsi_Host *shost = class_to_shost(dev); + struct mpi3mr_ioc *mrioc = shost_priv(shost); + + return sysfs_emit(buf, "%d\n", mrioc->num_op_req_q); +} +static DEVICE_ATTR_RO(op_req_q_count); + +/** + * reply_queue_count_show - SysFS callback for reply queue count + * @dev: class device + * @attr: Device attributes + * @buf: Buffer to copy + * + * Return: sysfs_emit() return after copying reply queue count + */ +static ssize_t +reply_queue_count_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct Scsi_Host *shost = class_to_shost(dev); + struct mpi3mr_ioc *mrioc = shost_priv(shost); + + return sysfs_emit(buf, "%d\n", mrioc->num_op_reply_q); +} + +static DEVICE_ATTR_RO(reply_queue_count); + +/** + * logging_level_show - Show controller debug level + * @dev: class device + * @attr: Device attributes + * @buf: Buffer to copy + * + * A sysfs 'read/write' shost attribute, to show the current + * debug log level used by the driver for the specific + * controller. + * + * Return: sysfs_emit() return + */ +static ssize_t +logging_level_show(struct device *dev, + struct device_attribute *attr, char *buf) + +{ + struct Scsi_Host *shost = class_to_shost(dev); + struct mpi3mr_ioc *mrioc = shost_priv(shost); + + return sysfs_emit(buf, "%08xh\n", mrioc->logging_level); +} + +/** + * logging_level_store- Change controller debug level + * @dev: class device + * @attr: Device attributes + * @buf: Buffer to copy + * @count: size of the buffer + * + * A sysfs 'read/write' shost attribute, to change the current + * debug log level used by the driver for the specific + * controller. + * + * Return: strlen() return + */ +static ssize_t +logging_level_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct Scsi_Host *shost = class_to_shost(dev); + struct mpi3mr_ioc *mrioc = shost_priv(shost); + int val = 0; + + if (kstrtoint(buf, 0, &val) != 0) + return -EINVAL; + + mrioc->logging_level = val; + ioc_info(mrioc, "logging_level=%08xh\n", mrioc->logging_level); + return strlen(buf); +} +static DEVICE_ATTR_RW(logging_level); + /** * adapter_state_show - SysFS callback for adapter state show * @dev: class device * @attr: Device attributes * @buf: Buffer to copy * - * Return: snprintf() return after copying adapter state + * Return: sysfs_emit() return after copying adapter state */ static ssize_t adp_state_show(struct device *dev, struct device_attribute *attr, @@ -1585,12 +1719,17 @@ adp_state_show(struct device *dev, struct device_attribute *attr, else adp_state = MPI3MR_BSG_ADPSTATE_OPERATIONAL; - return snprintf(buf, PAGE_SIZE, "%u\n", adp_state); + return sysfs_emit(buf, "%u\n", adp_state); } static DEVICE_ATTR_RO(adp_state); static struct attribute *mpi3mr_host_attrs[] = { + &dev_attr_version_fw.attr, + &dev_attr_fw_queue_depth.attr, + &dev_attr_op_req_q_count.attr, + &dev_attr_reply_queue_count.attr, + &dev_attr_logging_level.attr, &dev_attr_adp_state.attr, NULL, }; From 9feb5c4c3f95ec42fc12dc92f7216c2603b1a571 Mon Sep 17 00:00:00 2001 From: Sreekanth Reddy Date: Tue, 17 May 2022 17:23:10 +0530 Subject: [PATCH 171/177] scsi: mpi3mr: Add target device related sysfs attributes Add sysfs attributes for exposing target device details such as SAS address, firmware device handle, and persistent ID for the controller-attached devices and RAID volumes. Link: https://lore.kernel.org/r/20220517115310.13062-3-sreekanth.reddy@broadcom.com Reviewed-by: Himanshu Madhani Signed-off-by: Sreekanth Reddy Signed-off-by: Martin K. Petersen --- drivers/scsi/mpi3mr/mpi3mr.h | 1 + drivers/scsi/mpi3mr/mpi3mr_app.c | 120 +++++++++++++++++++++++++++++++ drivers/scsi/mpi3mr/mpi3mr_os.c | 1 + 3 files changed, 122 insertions(+) diff --git a/drivers/scsi/mpi3mr/mpi3mr.h b/drivers/scsi/mpi3mr/mpi3mr.h index 584659e2c578..01cd01787b0f 100644 --- a/drivers/scsi/mpi3mr/mpi3mr.h +++ b/drivers/scsi/mpi3mr/mpi3mr.h @@ -1085,4 +1085,5 @@ int mpi3mr_pel_get_seqnum_post(struct mpi3mr_ioc *mrioc, void mpi3mr_app_save_logdata(struct mpi3mr_ioc *mrioc, char *event_data, u16 event_data_size); extern const struct attribute_group *mpi3mr_host_groups[]; +extern const struct attribute_group *mpi3mr_dev_groups[]; #endif /*MPI3MR_H_INCLUDED*/ diff --git a/drivers/scsi/mpi3mr/mpi3mr_app.c b/drivers/scsi/mpi3mr/mpi3mr_app.c index 33bad2fdc28e..9ab1762468ad 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_app.c +++ b/drivers/scsi/mpi3mr/mpi3mr_app.c @@ -1742,3 +1742,123 @@ const struct attribute_group *mpi3mr_host_groups[] = { &mpi3mr_host_attr_group, NULL, }; + + +/* + * SCSI Device attributes under sysfs + */ + +/** + * sas_address_show - SysFS callback for dev SASaddress display + * @dev: class device + * @attr: Device attributes + * @buf: Buffer to copy + * + * Return: sysfs_emit() return after copying SAS address of the + * specific SAS/SATA end device. + */ +static ssize_t +sas_address_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct scsi_device *sdev = to_scsi_device(dev); + struct mpi3mr_sdev_priv_data *sdev_priv_data; + struct mpi3mr_stgt_priv_data *tgt_priv_data; + struct mpi3mr_tgt_dev *tgtdev; + + sdev_priv_data = sdev->hostdata; + if (!sdev_priv_data) + return 0; + + tgt_priv_data = sdev_priv_data->tgt_priv_data; + if (!tgt_priv_data) + return 0; + tgtdev = tgt_priv_data->tgt_dev; + if (!tgtdev || tgtdev->dev_type != MPI3_DEVICE_DEVFORM_SAS_SATA) + return 0; + return sysfs_emit(buf, "0x%016llx\n", + (unsigned long long)tgtdev->dev_spec.sas_sata_inf.sas_address); +} + +static DEVICE_ATTR_RO(sas_address); + +/** + * device_handle_show - SysFS callback for device handle display + * @dev: class device + * @attr: Device attributes + * @buf: Buffer to copy + * + * Return: sysfs_emit() return after copying firmware internal + * device handle of the specific device. + */ +static ssize_t +device_handle_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct scsi_device *sdev = to_scsi_device(dev); + struct mpi3mr_sdev_priv_data *sdev_priv_data; + struct mpi3mr_stgt_priv_data *tgt_priv_data; + struct mpi3mr_tgt_dev *tgtdev; + + sdev_priv_data = sdev->hostdata; + if (!sdev_priv_data) + return 0; + + tgt_priv_data = sdev_priv_data->tgt_priv_data; + if (!tgt_priv_data) + return 0; + tgtdev = tgt_priv_data->tgt_dev; + if (!tgtdev) + return 0; + return sysfs_emit(buf, "0x%04x\n", tgtdev->dev_handle); +} + +static DEVICE_ATTR_RO(device_handle); + +/** + * persistent_id_show - SysFS callback for persisten ID display + * @dev: class device + * @attr: Device attributes + * @buf: Buffer to copy + * + * Return: sysfs_emit() return after copying persistent ID of the + * of the specific device. + */ +static ssize_t +persistent_id_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct scsi_device *sdev = to_scsi_device(dev); + struct mpi3mr_sdev_priv_data *sdev_priv_data; + struct mpi3mr_stgt_priv_data *tgt_priv_data; + struct mpi3mr_tgt_dev *tgtdev; + + sdev_priv_data = sdev->hostdata; + if (!sdev_priv_data) + return 0; + + tgt_priv_data = sdev_priv_data->tgt_priv_data; + if (!tgt_priv_data) + return 0; + tgtdev = tgt_priv_data->tgt_dev; + if (!tgtdev) + return 0; + return sysfs_emit(buf, "%d\n", tgtdev->perst_id); +} +static DEVICE_ATTR_RO(persistent_id); + +static struct attribute *mpi3mr_dev_attrs[] = { + &dev_attr_sas_address.attr, + &dev_attr_device_handle.attr, + &dev_attr_persistent_id.attr, + NULL, +}; + +static const struct attribute_group mpi3mr_dev_attr_group = { + .attrs = mpi3mr_dev_attrs +}; + +const struct attribute_group *mpi3mr_dev_groups[] = { + &mpi3mr_dev_attr_group, + NULL, +}; diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index f5c345d1ffa1..d8c195b7ca57 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -4147,6 +4147,7 @@ static struct scsi_host_template mpi3mr_driver_template = { .track_queue_depth = 1, .cmd_size = sizeof(struct scmd_priv), .shost_groups = mpi3mr_host_groups, + .sdev_groups = mpi3mr_dev_groups, }; /** From b559b99a5c08194c14dc271e69ca786771b353dc Mon Sep 17 00:00:00 2001 From: Karan Tilak Kumar Date: Fri, 13 May 2022 13:56:05 -0700 Subject: [PATCH 172/177] scsi: fnic: Replace DMA mask of 64 bits with 47 bits Cisco VIC supports only 47 bits. If the host sends DMA addresses that are greater than 47 bits, it causes work queue (WQ) errors in the VIC. Link: https://lore.kernel.org/r/20220513205605.81788-1-kartilak@cisco.com Tested-by: Karan Tilak Kumar Co-developed-by: Dhanraj Jhawar Signed-off-by: Dhanraj Jhawar Co-developed-by: Sesidhar Baddela Signed-off-by: Sesidhar Baddela Signed-off-by: Arulprabhu Ponnusamy Signed-off-by: Karan Tilak Kumar Signed-off-by: Martin K. Petersen --- drivers/scsi/fnic/fnic.h | 2 +- drivers/scsi/fnic/fnic_main.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h index aa07189fb5fb..85ec6163ddab 100644 --- a/drivers/scsi/fnic/fnic.h +++ b/drivers/scsi/fnic/fnic.h @@ -39,7 +39,7 @@ #define DRV_NAME "fnic" #define DRV_DESCRIPTION "Cisco FCoE HBA Driver" -#define DRV_VERSION "1.6.0.53" +#define DRV_VERSION "1.6.0.54" #define PFX DRV_NAME ": " #define DFX DRV_NAME "%d: " diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c index 460e03a55096..51e7c344ddc3 100644 --- a/drivers/scsi/fnic/fnic_main.c +++ b/drivers/scsi/fnic/fnic_main.c @@ -612,10 +612,10 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) pci_set_master(pdev); /* Query PCI controller on system for DMA addressing - * limitation for the device. Try 64-bit first, and - * fail to 32-bit. + * limitation for the device. Try 47-bit first, and + * fail to 32-bit. Cisco VIC supports 47 bits only. */ - err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); + err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(47)); if (err) { err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); if (err) { From 6c6ac8b7773f05f93dc4e4044686e059d1f78dea Mon Sep 17 00:00:00 2001 From: John Garry Date: Tue, 17 May 2022 16:04:21 +0800 Subject: [PATCH 173/177] scsi: hisi_sas: Fix memory ordering in hisi_sas_task_deliver() The memories for the slot should be observed to be written prior to observing the slot as ready. Prior to commit 26fc0ea74fcb ("scsi: libsas: Drop SAS_TASK_AT_INITIATOR"), we had a spin_lock() + spin_unlock() immediately before marking the slot as ready. The spin_unlock() - with release semantics - caused the slot memory to be observed to be written. Now that the spin_lock() + spin_unlock() is gone, use a smp_wmb(). Link: https://lore.kernel.org/r/1652774661-12935-1-git-send-email-john.garry@huawei.com Fixes: 26fc0ea74fcb ("scsi: libsas: Drop SAS_TASK_AT_INITIATOR") Reported-by: Yihang Li Tested-by: Yihang Li Signed-off-by: John Garry Signed-off-by: Martin K. Petersen --- drivers/scsi/hisi_sas/hisi_sas_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index f81e74fd6263..764e859d0106 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -446,6 +446,8 @@ void hisi_sas_task_deliver(struct hisi_hba *hisi_hba, return; } + /* Make slot memories observable before marking as ready */ + smp_wmb(); WRITE_ONCE(slot->ready, 1); spin_lock(&dq->lock); From fc65df48c88ea0b7d4bcbccdc59ffeedc64222c2 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Tue, 17 May 2022 10:25:18 +0100 Subject: [PATCH 174/177] scsi: qedf: Remove redundant variable op The variable 'op' is assigned a value and is never read. The variable is not used and is redundant, remove it. Link: https://lore.kernel.org/r/20220517092518.93159-1-colin.i.king@gmail.com Signed-off-by: Colin Ian King Signed-off-by: Martin K. Petersen --- drivers/scsi/qedf/qedf_io.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c index 2ec1f710fd1d..e57cc22453d0 100644 --- a/drivers/scsi/qedf/qedf_io.c +++ b/drivers/scsi/qedf/qedf_io.c @@ -804,7 +804,6 @@ static void qedf_trace_io(struct qedf_rport *fcport, struct qedf_ioreq *io_req, struct qedf_io_log *io_log; struct scsi_cmnd *sc_cmd = io_req->sc_cmd; unsigned long flags; - uint8_t op; spin_lock_irqsave(&qedf->io_trace_lock, flags); @@ -813,7 +812,7 @@ static void qedf_trace_io(struct qedf_rport *fcport, struct qedf_ioreq *io_req, io_log->task_id = io_req->xid; io_log->port_id = fcport->rdata->ids.port_id; io_log->lun = sc_cmd->device->lun; - io_log->op = op = sc_cmd->cmnd[0]; + io_log->op = sc_cmd->cmnd[0]; io_log->lba[0] = sc_cmd->cmnd[2]; io_log->lba[1] = sc_cmd->cmnd[3]; io_log->lba[2] = sc_cmd->cmnd[4]; From 91fdd0788878862581128c86025c8a6262aeb868 Mon Sep 17 00:00:00 2001 From: Haowen Bai Date: Tue, 10 May 2022 17:47:03 +0800 Subject: [PATCH 175/177] scsi: dpt_i2o: Drop redundant spinlock initialization adpt_post_wait_lock was declared and initialized by DEFINE_SPINLOCK so we don't need to call spin_lock_init(). Drop the call. Link: https://lore.kernel.org/r/1652176024-3981-1-git-send-email-baihaowen@meizu.com Signed-off-by: Haowen Bai Signed-off-by: Martin K. Petersen --- drivers/scsi/dpt_i2o.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c index 93227c04ef59..2e9155ba7408 100644 --- a/drivers/scsi/dpt_i2o.c +++ b/drivers/scsi/dpt_i2o.c @@ -1000,7 +1000,6 @@ static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev // Initializing the spinlocks spin_lock_init(&pHba->state_lock); - spin_lock_init(&adpt_post_wait_lock); if(raptorFlag == 0){ printk(KERN_INFO "Adaptec I2O RAID controller" From d627660c22b51121262c03dfa1a51bf54361f5a9 Mon Sep 17 00:00:00 2001 From: Haowen Bai Date: Tue, 17 May 2022 09:25:36 +0800 Subject: [PATCH 176/177] scsi: elx: efct: Remove NULL check after calling container_of() container_of() will never return NULL. Link: https://lore.kernel.org/r/1652750737-22673-1-git-send-email-baihaowen@meizu.com Signed-off-by: Haowen Bai Signed-off-by: Martin K. Petersen --- drivers/scsi/elx/efct/efct_lio.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/scsi/elx/efct/efct_lio.c b/drivers/scsi/elx/efct/efct_lio.c index 8b004a5818d6..be4b5c1ee32d 100644 --- a/drivers/scsi/elx/efct/efct_lio.c +++ b/drivers/scsi/elx/efct/efct_lio.c @@ -370,9 +370,6 @@ static int efct_lio_get_cmd_state(struct se_cmd *cmd) container_of(cmd, struct efct_scsi_tgt_io, cmd); struct efct_io *io = container_of(ocp, struct efct_io, tgt_io); - if (!io) - return 0; - return io->tgt_io.state; } From 325d5c5fb216674296f3902a8902b942da3adc5b Mon Sep 17 00:00:00 2001 From: Bodo Stroesser Date: Tue, 17 May 2022 21:29:13 +0200 Subject: [PATCH 177/177] scsi: target: tcmu: Avoid holding XArray lock when calling lock_page In tcmu_blocks_release(), lock_page() is called to prevent a race causing possible data corruption. Since lock_page() might sleep, calling it while holding XArray lock is a bug. To fix this, replace the xas_for_each() call with xa_for_each_range(). Since the latter does its own handling of XArray locking, the xas_lock() and xas_unlock() calls around the original loop are no longer necessary. The switch to xa_for_each_range() slows down the loop slightly. This is acceptable since tcmu_blocks_release() is not relevant for performance. Link: https://lore.kernel.org/r/20220517192913.21405-1-bostroesser@gmail.com Fixes: bb9b9eb0ae2e ("scsi: target: tcmu: Fix possible data corruption") Reported-by: Dan Carpenter Signed-off-by: Bodo Stroesser Signed-off-by: Martin K. Petersen --- drivers/target/target_core_user.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index b1fd06edea59..3deaeecb712e 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -1661,13 +1661,14 @@ static int tcmu_check_and_free_pending_cmd(struct tcmu_cmd *cmd) static u32 tcmu_blocks_release(struct tcmu_dev *udev, unsigned long first, unsigned long last) { - XA_STATE(xas, &udev->data_pages, first * udev->data_pages_per_blk); struct page *page; + unsigned long dpi; u32 pages_freed = 0; - xas_lock(&xas); - xas_for_each(&xas, page, (last + 1) * udev->data_pages_per_blk - 1) { - xas_store(&xas, NULL); + first = first * udev->data_pages_per_blk; + last = (last + 1) * udev->data_pages_per_blk - 1; + xa_for_each_range(&udev->data_pages, dpi, page, first, last) { + xa_erase(&udev->data_pages, dpi); /* * While reaching here there may be page faults occurring on * the to-be-released pages. A race condition may occur if @@ -1691,7 +1692,6 @@ static u32 tcmu_blocks_release(struct tcmu_dev *udev, unsigned long first, __free_page(page); pages_freed++; } - xas_unlock(&xas); atomic_sub(pages_freed, &global_page_count);