summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-10-05 15:53:27 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-10-05 15:53:27 -0400
commit126195c972a2adba8cae12a65cdee155440a4525 (patch)
tree375106a3d36e171670d6c4b7ed91f5851b57f0ac
parent4f11918ab93bc113ec0831ed2ab7b88847d44dd7 (diff)
parent0aabb6b699f72dca96988d3f428e222f932dc889 (diff)
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull SCSI fixes from James Bottomley: "Twelve patches mostly small but obvious fixes or cosmetic but small updates" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: qla2xxx: Fix Nport ID display value scsi: qla2xxx: Fix N2N link up fail scsi: qla2xxx: Fix N2N link reset scsi: qla2xxx: Optimize NPIV tear down process scsi: qla2xxx: Fix stale mem access on driver unload scsi: qla2xxx: Fix unbound sleep in fcport delete path. scsi: qla2xxx: Silence fwdump template message scsi: hisi_sas: Make three functions static scsi: megaraid: disable device when probe failed after enabled device scsi: storvsc: setup 1:1 mapping between hardware queue and CPU queue scsi: qedf: Remove always false 'tmp_prio < 0' statement scsi: ufs: skip shutdown if hba is not powered scsi: bnx2fc: Handle scope bits when array returns BUSY or TSF
-rw-r--r--drivers/scsi/bnx2fc/bnx2fc_io.c29
-rw-r--r--drivers/scsi/hisi_sas/hisi_sas_main.c6
-rw-r--r--drivers/scsi/megaraid.c4
-rw-r--r--drivers/scsi/qedf/qedf_main.c2
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c2
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h4
-rw-r--r--drivers/scsi/qla2xxx/qla_gs.c3
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c109
-rw-r--r--drivers/scsi/qla2xxx/qla_iocb.c7
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c25
-rw-r--r--drivers/scsi/qla2xxx/qla_mid.c32
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c18
-rw-r--r--drivers/scsi/qla2xxx/qla_target.c26
-rw-r--r--drivers/scsi/storvsc_drv.c3
-rw-r--r--drivers/scsi/ufs/ufshcd.c3
15 files changed, 193 insertions, 80 deletions
diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
index da00ca5fa5dc..401743e2b429 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
@@ -1923,6 +1923,7 @@ void bnx2fc_process_scsi_cmd_compl(struct bnx2fc_cmd *io_req,
1923 struct fcoe_fcp_rsp_payload *fcp_rsp; 1923 struct fcoe_fcp_rsp_payload *fcp_rsp;
1924 struct bnx2fc_rport *tgt = io_req->tgt; 1924 struct bnx2fc_rport *tgt = io_req->tgt;
1925 struct scsi_cmnd *sc_cmd; 1925 struct scsi_cmnd *sc_cmd;
1926 u16 scope = 0, qualifier = 0;
1926 1927
1927 /* scsi_cmd_cmpl is called with tgt lock held */ 1928 /* scsi_cmd_cmpl is called with tgt lock held */
1928 1929
@@ -1990,12 +1991,30 @@ void bnx2fc_process_scsi_cmd_compl(struct bnx2fc_cmd *io_req,
1990 1991
1991 if (io_req->cdb_status == SAM_STAT_TASK_SET_FULL || 1992 if (io_req->cdb_status == SAM_STAT_TASK_SET_FULL ||
1992 io_req->cdb_status == SAM_STAT_BUSY) { 1993 io_req->cdb_status == SAM_STAT_BUSY) {
1993 /* Set the jiffies + retry_delay_timer * 100ms 1994 /* Newer array firmware with BUSY or
1994 for the rport/tgt */ 1995 * TASK_SET_FULL may return a status that needs
1995 tgt->retry_delay_timestamp = jiffies + 1996 * the scope bits masked.
1996 fcp_rsp->retry_delay_timer * HZ / 10; 1997 * Or a huge delay timestamp up to 27 minutes
1998 * can result.
1999 */
2000 if (fcp_rsp->retry_delay_timer) {
2001 /* Upper 2 bits */
2002 scope = fcp_rsp->retry_delay_timer
2003 & 0xC000;
2004 /* Lower 14 bits */
2005 qualifier = fcp_rsp->retry_delay_timer
2006 & 0x3FFF;
2007 }
2008 if (scope > 0 && qualifier > 0 &&
2009 qualifier <= 0x3FEF) {
2010 /* Set the jiffies +
2011 * retry_delay_timer * 100ms
2012 * for the rport/tgt
2013 */
2014 tgt->retry_delay_timestamp = jiffies +
2015 (qualifier * HZ / 10);
2016 }
1997 } 2017 }
1998
1999 } 2018 }
2000 if (io_req->fcp_resid) 2019 if (io_req->fcp_resid)
2001 scsi_set_resid(sc_cmd, io_req->fcp_resid); 2020 scsi_set_resid(sc_cmd, io_req->fcp_resid);
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
index d1513fdf1e00..0847e682797b 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -3683,7 +3683,7 @@ void hisi_sas_debugfs_work_handler(struct work_struct *work)
3683} 3683}
3684EXPORT_SYMBOL_GPL(hisi_sas_debugfs_work_handler); 3684EXPORT_SYMBOL_GPL(hisi_sas_debugfs_work_handler);
3685 3685
3686void hisi_sas_debugfs_release(struct hisi_hba *hisi_hba) 3686static void hisi_sas_debugfs_release(struct hisi_hba *hisi_hba)
3687{ 3687{
3688 struct device *dev = hisi_hba->dev; 3688 struct device *dev = hisi_hba->dev;
3689 int i; 3689 int i;
@@ -3705,7 +3705,7 @@ void hisi_sas_debugfs_release(struct hisi_hba *hisi_hba)
3705 devm_kfree(dev, hisi_hba->debugfs_port_reg[i]); 3705 devm_kfree(dev, hisi_hba->debugfs_port_reg[i]);
3706} 3706}
3707 3707
3708int hisi_sas_debugfs_alloc(struct hisi_hba *hisi_hba) 3708static int hisi_sas_debugfs_alloc(struct hisi_hba *hisi_hba)
3709{ 3709{
3710 const struct hisi_sas_hw *hw = hisi_hba->hw; 3710 const struct hisi_sas_hw *hw = hisi_hba->hw;
3711 struct device *dev = hisi_hba->dev; 3711 struct device *dev = hisi_hba->dev;
@@ -3796,7 +3796,7 @@ fail:
3796 return -ENOMEM; 3796 return -ENOMEM;
3797} 3797}
3798 3798
3799void hisi_sas_debugfs_bist_init(struct hisi_hba *hisi_hba) 3799static void hisi_sas_debugfs_bist_init(struct hisi_hba *hisi_hba)
3800{ 3800{
3801 hisi_hba->debugfs_bist_dentry = 3801 hisi_hba->debugfs_bist_dentry =
3802 debugfs_create_dir("bist", hisi_hba->debugfs_dir); 3802 debugfs_create_dir("bist", hisi_hba->debugfs_dir);
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 45a66048801b..ff6d4aa92421 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -4183,11 +4183,11 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
4183 */ 4183 */
4184 if (pdev->subsystem_vendor == PCI_VENDOR_ID_COMPAQ && 4184 if (pdev->subsystem_vendor == PCI_VENDOR_ID_COMPAQ &&
4185 pdev->subsystem_device == 0xC000) 4185 pdev->subsystem_device == 0xC000)
4186 return -ENODEV; 4186 goto out_disable_device;
4187 /* Now check the magic signature byte */ 4187 /* Now check the magic signature byte */
4188 pci_read_config_word(pdev, PCI_CONF_AMISIG, &magic); 4188 pci_read_config_word(pdev, PCI_CONF_AMISIG, &magic);
4189 if (magic != HBA_SIGNATURE_471 && magic != HBA_SIGNATURE) 4189 if (magic != HBA_SIGNATURE_471 && magic != HBA_SIGNATURE)
4190 return -ENODEV; 4190 goto out_disable_device;
4191 /* Ok it is probably a megaraid */ 4191 /* Ok it is probably a megaraid */
4192 } 4192 }
4193 4193
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 1659d35cd37b..59ca98f12afd 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -596,7 +596,7 @@ static void qedf_dcbx_handler(void *dev, struct qed_dcbx_get *get, u32 mib_type)
596 tmp_prio = get->operational.app_prio.fcoe; 596 tmp_prio = get->operational.app_prio.fcoe;
597 if (qedf_default_prio > -1) 597 if (qedf_default_prio > -1)
598 qedf->prio = qedf_default_prio; 598 qedf->prio = qedf_default_prio;
599 else if (tmp_prio < 0 || tmp_prio > 7) { 599 else if (tmp_prio > 7) {
600 QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC, 600 QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC,
601 "FIP/FCoE prio %d out of range, setting to %d.\n", 601 "FIP/FCoE prio %d out of range, setting to %d.\n",
602 tmp_prio, QEDF_DEFAULT_PRIO); 602 tmp_prio, QEDF_DEFAULT_PRIO);
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 8190c2a27584..30bafd9d21e9 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -2920,6 +2920,8 @@ qla24xx_vport_delete(struct fc_vport *fc_vport)
2920 struct qla_hw_data *ha = vha->hw; 2920 struct qla_hw_data *ha = vha->hw;
2921 uint16_t id = vha->vp_idx; 2921 uint16_t id = vha->vp_idx;
2922 2922
2923 set_bit(VPORT_DELETE, &vha->dpc_flags);
2924
2923 while (test_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags) || 2925 while (test_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags) ||
2924 test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags)) 2926 test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags))
2925 msleep(1000); 2927 msleep(1000);
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 873a6aef1c5c..6ffa9877c28b 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -2396,6 +2396,7 @@ typedef struct fc_port {
2396 unsigned int query:1; 2396 unsigned int query:1;
2397 unsigned int id_changed:1; 2397 unsigned int id_changed:1;
2398 unsigned int scan_needed:1; 2398 unsigned int scan_needed:1;
2399 unsigned int n2n_flag:1;
2399 2400
2400 struct completion nvme_del_done; 2401 struct completion nvme_del_done;
2401 uint32_t nvme_prli_service_param; 2402 uint32_t nvme_prli_service_param;
@@ -2446,7 +2447,6 @@ typedef struct fc_port {
2446 uint8_t fc4_type; 2447 uint8_t fc4_type;
2447 uint8_t fc4f_nvme; 2448 uint8_t fc4f_nvme;
2448 uint8_t scan_state; 2449 uint8_t scan_state;
2449 uint8_t n2n_flag;
2450 2450
2451 unsigned long last_queue_full; 2451 unsigned long last_queue_full;
2452 unsigned long last_ramp_up; 2452 unsigned long last_ramp_up;
@@ -3036,6 +3036,7 @@ enum scan_flags_t {
3036enum fc4type_t { 3036enum fc4type_t {
3037 FS_FC4TYPE_FCP = BIT_0, 3037 FS_FC4TYPE_FCP = BIT_0,
3038 FS_FC4TYPE_NVME = BIT_1, 3038 FS_FC4TYPE_NVME = BIT_1,
3039 FS_FCP_IS_N2N = BIT_7,
3039}; 3040};
3040 3041
3041struct fab_scan_rp { 3042struct fab_scan_rp {
@@ -4394,6 +4395,7 @@ typedef struct scsi_qla_host {
4394#define IOCB_WORK_ACTIVE 31 4395#define IOCB_WORK_ACTIVE 31
4395#define SET_ZIO_THRESHOLD_NEEDED 32 4396#define SET_ZIO_THRESHOLD_NEEDED 32
4396#define ISP_ABORT_TO_ROM 33 4397#define ISP_ABORT_TO_ROM 33
4398#define VPORT_DELETE 34
4397 4399
4398 unsigned long pci_flags; 4400 unsigned long pci_flags;
4399#define PFLG_DISCONNECTED 0 /* PCI device removed */ 4401#define PFLG_DISCONNECTED 0 /* PCI device removed */
diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
index dc0e36676313..5298ed10059f 100644
--- a/drivers/scsi/qla2xxx/qla_gs.c
+++ b/drivers/scsi/qla2xxx/qla_gs.c
@@ -3102,7 +3102,8 @@ int qla24xx_post_gpnid_work(struct scsi_qla_host *vha, port_id_t *id)
3102{ 3102{
3103 struct qla_work_evt *e; 3103 struct qla_work_evt *e;
3104 3104
3105 if (test_bit(UNLOADING, &vha->dpc_flags)) 3105 if (test_bit(UNLOADING, &vha->dpc_flags) ||
3106 (vha->vp_idx && test_bit(VPORT_DELETE, &vha->dpc_flags)))
3106 return 0; 3107 return 0;
3107 3108
3108 e = qla2x00_alloc_work(vha, QLA_EVT_GPNID); 3109 e = qla2x00_alloc_work(vha, QLA_EVT_GPNID);
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 643d2324082e..1d041313ec52 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -746,12 +746,15 @@ static void qla24xx_handle_gnl_done_event(scsi_qla_host_t *vha,
746 break; 746 break;
747 default: 747 default:
748 if ((id.b24 != fcport->d_id.b24 && 748 if ((id.b24 != fcport->d_id.b24 &&
749 fcport->d_id.b24) || 749 fcport->d_id.b24 &&
750 fcport->loop_id != FC_NO_LOOP_ID) ||
750 (fcport->loop_id != FC_NO_LOOP_ID && 751 (fcport->loop_id != FC_NO_LOOP_ID &&
751 fcport->loop_id != loop_id)) { 752 fcport->loop_id != loop_id)) {
752 ql_dbg(ql_dbg_disc, vha, 0x20e3, 753 ql_dbg(ql_dbg_disc, vha, 0x20e3,
753 "%s %d %8phC post del sess\n", 754 "%s %d %8phC post del sess\n",
754 __func__, __LINE__, fcport->port_name); 755 __func__, __LINE__, fcport->port_name);
756 if (fcport->n2n_flag)
757 fcport->d_id.b24 = 0;
755 qlt_schedule_sess_for_deletion(fcport); 758 qlt_schedule_sess_for_deletion(fcport);
756 return; 759 return;
757 } 760 }
@@ -759,6 +762,8 @@ static void qla24xx_handle_gnl_done_event(scsi_qla_host_t *vha,
759 } 762 }
760 763
761 fcport->loop_id = loop_id; 764 fcport->loop_id = loop_id;
765 if (fcport->n2n_flag)
766 fcport->d_id.b24 = id.b24;
762 767
763 wwn = wwn_to_u64(fcport->port_name); 768 wwn = wwn_to_u64(fcport->port_name);
764 qlt_find_sess_invalidate_other(vha, wwn, 769 qlt_find_sess_invalidate_other(vha, wwn,
@@ -972,7 +977,7 @@ static void qla24xx_async_gnl_sp_done(srb_t *sp, int res)
972 wwn = wwn_to_u64(e->port_name); 977 wwn = wwn_to_u64(e->port_name);
973 978
974 ql_dbg(ql_dbg_disc + ql_dbg_verbose, vha, 0x20e8, 979 ql_dbg(ql_dbg_disc + ql_dbg_verbose, vha, 0x20e8,
975 "%s %8phC %02x:%02x:%02x state %d/%d lid %x \n", 980 "%s %8phC %02x:%02x:%02x CLS %x/%x lid %x \n",
976 __func__, (void *)&wwn, e->port_id[2], e->port_id[1], 981 __func__, (void *)&wwn, e->port_id[2], e->port_id[1],
977 e->port_id[0], e->current_login_state, e->last_login_state, 982 e->port_id[0], e->current_login_state, e->last_login_state,
978 (loop_id & 0x7fff)); 983 (loop_id & 0x7fff));
@@ -1499,7 +1504,8 @@ int qla24xx_fcport_handle_login(struct scsi_qla_host *vha, fc_port_t *fcport)
1499 (fcport->fw_login_state == DSC_LS_PRLI_PEND))) 1504 (fcport->fw_login_state == DSC_LS_PRLI_PEND)))
1500 return 0; 1505 return 0;
1501 1506
1502 if (fcport->fw_login_state == DSC_LS_PLOGI_COMP) { 1507 if (fcport->fw_login_state == DSC_LS_PLOGI_COMP &&
1508 !N2N_TOPO(vha->hw)) {
1503 if (time_before_eq(jiffies, fcport->plogi_nack_done_deadline)) { 1509 if (time_before_eq(jiffies, fcport->plogi_nack_done_deadline)) {
1504 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); 1510 set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
1505 return 0; 1511 return 0;
@@ -1570,8 +1576,9 @@ int qla24xx_fcport_handle_login(struct scsi_qla_host *vha, fc_port_t *fcport)
1570 qla24xx_post_gpdb_work(vha, fcport, 0); 1576 qla24xx_post_gpdb_work(vha, fcport, 0);
1571 } else { 1577 } else {
1572 ql_dbg(ql_dbg_disc, vha, 0x2118, 1578 ql_dbg(ql_dbg_disc, vha, 0x2118,
1573 "%s %d %8phC post NVMe PRLI\n", 1579 "%s %d %8phC post %s PRLI\n",
1574 __func__, __LINE__, fcport->port_name); 1580 __func__, __LINE__, fcport->port_name,
1581 fcport->fc4f_nvme ? "NVME" : "FC");
1575 qla24xx_post_prli_work(vha, fcport); 1582 qla24xx_post_prli_work(vha, fcport);
1576 } 1583 }
1577 break; 1584 break;
@@ -1853,17 +1860,38 @@ qla24xx_handle_prli_done_event(struct scsi_qla_host *vha, struct event_arg *ea)
1853 break; 1860 break;
1854 } 1861 }
1855 1862
1856 if (ea->fcport->n2n_flag) { 1863 if (ea->fcport->fc4f_nvme) {
1857 ql_dbg(ql_dbg_disc, vha, 0x2118, 1864 ql_dbg(ql_dbg_disc, vha, 0x2118,
1858 "%s %d %8phC post fc4 prli\n", 1865 "%s %d %8phC post fc4 prli\n",
1859 __func__, __LINE__, ea->fcport->port_name); 1866 __func__, __LINE__, ea->fcport->port_name);
1860 ea->fcport->fc4f_nvme = 0; 1867 ea->fcport->fc4f_nvme = 0;
1861 ea->fcport->n2n_flag = 0;
1862 qla24xx_post_prli_work(vha, ea->fcport); 1868 qla24xx_post_prli_work(vha, ea->fcport);
1869 return;
1870 }
1871
1872 /* at this point both PRLI NVME & PRLI FCP failed */
1873 if (N2N_TOPO(vha->hw)) {
1874 if (ea->fcport->n2n_link_reset_cnt < 3) {
1875 ea->fcport->n2n_link_reset_cnt++;
1876 /*
1877 * remote port is not sending Plogi. Reset
1878 * link to kick start his state machine
1879 */
1880 set_bit(N2N_LINK_RESET, &vha->dpc_flags);
1881 } else {
1882 ql_log(ql_log_warn, vha, 0x2119,
1883 "%s %d %8phC Unable to reconnect\n",
1884 __func__, __LINE__, ea->fcport->port_name);
1885 }
1886 } else {
1887 /*
1888 * switch connect. login failed. Take connection
1889 * down and allow relogin to retrigger
1890 */
1891 ea->fcport->flags &= ~FCF_ASYNC_SENT;
1892 ea->fcport->keep_nport_handle = 0;
1893 qlt_schedule_sess_for_deletion(ea->fcport);
1863 } 1894 }
1864 ql_dbg(ql_dbg_disc, vha, 0x2119,
1865 "%s %d %8phC unhandle event of %x\n",
1866 __func__, __LINE__, ea->fcport->port_name, ea->data[0]);
1867 break; 1895 break;
1868 } 1896 }
1869} 1897}
@@ -3190,7 +3218,7 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *vha)
3190 3218
3191 for (j = 0; j < 2; j++, fwdt++) { 3219 for (j = 0; j < 2; j++, fwdt++) {
3192 if (!fwdt->template) { 3220 if (!fwdt->template) {
3193 ql_log(ql_log_warn, vha, 0x00ba, 3221 ql_dbg(ql_dbg_init, vha, 0x00ba,
3194 "-> fwdt%u no template\n", j); 3222 "-> fwdt%u no template\n", j);
3195 continue; 3223 continue;
3196 } 3224 }
@@ -4986,28 +5014,47 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)
4986 unsigned long flags; 5014 unsigned long flags;
4987 5015
4988 /* Inititae N2N login. */ 5016 /* Inititae N2N login. */
4989 if (test_and_clear_bit(N2N_LOGIN_NEEDED, &vha->dpc_flags)) { 5017 if (N2N_TOPO(ha)) {
4990 /* borrowing */ 5018 if (test_and_clear_bit(N2N_LOGIN_NEEDED, &vha->dpc_flags)) {
4991 u32 *bp, i, sz; 5019 /* borrowing */
4992 5020 u32 *bp, i, sz;
4993 memset(ha->init_cb, 0, ha->init_cb_size); 5021
4994 sz = min_t(int, sizeof(struct els_plogi_payload), 5022 memset(ha->init_cb, 0, ha->init_cb_size);
4995 ha->init_cb_size); 5023 sz = min_t(int, sizeof(struct els_plogi_payload),
4996 rval = qla24xx_get_port_login_templ(vha, ha->init_cb_dma, 5024 ha->init_cb_size);
4997 (void *)ha->init_cb, sz); 5025 rval = qla24xx_get_port_login_templ(vha,
4998 if (rval == QLA_SUCCESS) { 5026 ha->init_cb_dma, (void *)ha->init_cb, sz);
4999 bp = (uint32_t *)ha->init_cb; 5027 if (rval == QLA_SUCCESS) {
5000 for (i = 0; i < sz/4 ; i++, bp++) 5028 bp = (uint32_t *)ha->init_cb;
5001 *bp = cpu_to_be32(*bp); 5029 for (i = 0; i < sz/4 ; i++, bp++)
5030 *bp = cpu_to_be32(*bp);
5002 5031
5003 memcpy(&ha->plogi_els_payld.data, (void *)ha->init_cb, 5032 memcpy(&ha->plogi_els_payld.data,
5004 sizeof(ha->plogi_els_payld.data)); 5033 (void *)ha->init_cb,
5005 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); 5034 sizeof(ha->plogi_els_payld.data));
5006 } else { 5035 set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
5007 ql_dbg(ql_dbg_init, vha, 0x00d1, 5036 } else {
5008 "PLOGI ELS param read fail.\n"); 5037 ql_dbg(ql_dbg_init, vha, 0x00d1,
5038 "PLOGI ELS param read fail.\n");
5039 goto skip_login;
5040 }
5041 }
5042
5043 list_for_each_entry(fcport, &vha->vp_fcports, list) {
5044 if (fcport->n2n_flag) {
5045 qla24xx_fcport_handle_login(vha, fcport);
5046 return QLA_SUCCESS;
5047 }
5048 }
5049skip_login:
5050 spin_lock_irqsave(&vha->work_lock, flags);
5051 vha->scan.scan_retry++;
5052 spin_unlock_irqrestore(&vha->work_lock, flags);
5053
5054 if (vha->scan.scan_retry < MAX_SCAN_RETRIES) {
5055 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags);
5056 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags);
5009 } 5057 }
5010 return QLA_SUCCESS;
5011 } 5058 }
5012 5059
5013 found_devs = 0; 5060 found_devs = 0;
diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
index e92e52aa6e9b..518eb954cf42 100644
--- a/drivers/scsi/qla2xxx/qla_iocb.c
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -2656,9 +2656,10 @@ qla24xx_els_logo_iocb(srb_t *sp, struct els_entry_24xx *els_iocb)
2656 els_iocb->port_id[0] = sp->fcport->d_id.b.al_pa; 2656 els_iocb->port_id[0] = sp->fcport->d_id.b.al_pa;
2657 els_iocb->port_id[1] = sp->fcport->d_id.b.area; 2657 els_iocb->port_id[1] = sp->fcport->d_id.b.area;
2658 els_iocb->port_id[2] = sp->fcport->d_id.b.domain; 2658 els_iocb->port_id[2] = sp->fcport->d_id.b.domain;
2659 els_iocb->s_id[0] = vha->d_id.b.al_pa; 2659 /* For SID the byte order is different than DID */
2660 els_iocb->s_id[1] = vha->d_id.b.area; 2660 els_iocb->s_id[1] = vha->d_id.b.al_pa;
2661 els_iocb->s_id[2] = vha->d_id.b.domain; 2661 els_iocb->s_id[2] = vha->d_id.b.area;
2662 els_iocb->s_id[0] = vha->d_id.b.domain;
2662 2663
2663 if (elsio->u.els_logo.els_cmd == ELS_DCMD_PLOGI) { 2664 if (elsio->u.els_logo.els_cmd == ELS_DCMD_PLOGI) {
2664 els_iocb->control_flags = 0; 2665 els_iocb->control_flags = 0;
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 4c858e2d0ea8..1cc6913f76c4 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -2249,7 +2249,7 @@ qla2x00_lip_reset(scsi_qla_host_t *vha)
2249 mbx_cmd_t mc; 2249 mbx_cmd_t mc;
2250 mbx_cmd_t *mcp = &mc; 2250 mbx_cmd_t *mcp = &mc;
2251 2251
2252 ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x105a, 2252 ql_dbg(ql_dbg_disc, vha, 0x105a,
2253 "Entered %s.\n", __func__); 2253 "Entered %s.\n", __func__);
2254 2254
2255 if (IS_CNA_CAPABLE(vha->hw)) { 2255 if (IS_CNA_CAPABLE(vha->hw)) {
@@ -3883,14 +3883,24 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *vha,
3883 case TOPO_N2N: 3883 case TOPO_N2N:
3884 ha->current_topology = ISP_CFG_N; 3884 ha->current_topology = ISP_CFG_N;
3885 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); 3885 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags);
3886 list_for_each_entry(fcport, &vha->vp_fcports, list) {
3887 fcport->scan_state = QLA_FCPORT_SCAN;
3888 fcport->n2n_flag = 0;
3889 }
3890
3886 fcport = qla2x00_find_fcport_by_wwpn(vha, 3891 fcport = qla2x00_find_fcport_by_wwpn(vha,
3887 rptid_entry->u.f1.port_name, 1); 3892 rptid_entry->u.f1.port_name, 1);
3888 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); 3893 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags);
3889 3894
3890 if (fcport) { 3895 if (fcport) {
3891 fcport->plogi_nack_done_deadline = jiffies + HZ; 3896 fcport->plogi_nack_done_deadline = jiffies + HZ;
3892 fcport->dm_login_expire = jiffies + 3*HZ; 3897 fcport->dm_login_expire = jiffies + 2*HZ;
3893 fcport->scan_state = QLA_FCPORT_FOUND; 3898 fcport->scan_state = QLA_FCPORT_FOUND;
3899 fcport->n2n_flag = 1;
3900 fcport->keep_nport_handle = 1;
3901 if (vha->flags.nvme_enabled)
3902 fcport->fc4f_nvme = 1;
3903
3894 switch (fcport->disc_state) { 3904 switch (fcport->disc_state) {
3895 case DSC_DELETED: 3905 case DSC_DELETED:
3896 set_bit(RELOGIN_NEEDED, 3906 set_bit(RELOGIN_NEEDED,
@@ -3924,7 +3934,7 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *vha,
3924 rptid_entry->u.f1.port_name, 3934 rptid_entry->u.f1.port_name,
3925 rptid_entry->u.f1.node_name, 3935 rptid_entry->u.f1.node_name,
3926 NULL, 3936 NULL,
3927 FC4_TYPE_UNKNOWN); 3937 FS_FCP_IS_N2N);
3928 } 3938 }
3929 3939
3930 /* if our portname is higher then initiate N2N login */ 3940 /* if our portname is higher then initiate N2N login */
@@ -4023,6 +4033,7 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *vha,
4023 4033
4024 list_for_each_entry(fcport, &vha->vp_fcports, list) { 4034 list_for_each_entry(fcport, &vha->vp_fcports, list) {
4025 fcport->scan_state = QLA_FCPORT_SCAN; 4035 fcport->scan_state = QLA_FCPORT_SCAN;
4036 fcport->n2n_flag = 0;
4026 } 4037 }
4027 4038
4028 fcport = qla2x00_find_fcport_by_wwpn(vha, 4039 fcport = qla2x00_find_fcport_by_wwpn(vha,
@@ -4032,6 +4043,14 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *vha,
4032 fcport->login_retry = vha->hw->login_retry_count; 4043 fcport->login_retry = vha->hw->login_retry_count;
4033 fcport->plogi_nack_done_deadline = jiffies + HZ; 4044 fcport->plogi_nack_done_deadline = jiffies + HZ;
4034 fcport->scan_state = QLA_FCPORT_FOUND; 4045 fcport->scan_state = QLA_FCPORT_FOUND;
4046 fcport->keep_nport_handle = 1;
4047 fcport->n2n_flag = 1;
4048 fcport->d_id.b.domain =
4049 rptid_entry->u.f2.remote_nport_id[2];
4050 fcport->d_id.b.area =
4051 rptid_entry->u.f2.remote_nport_id[1];
4052 fcport->d_id.b.al_pa =
4053 rptid_entry->u.f2.remote_nport_id[0];
4035 } 4054 }
4036 } 4055 }
4037} 4056}
diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c
index 1a9a11ae7285..6afad68e5ba2 100644
--- a/drivers/scsi/qla2xxx/qla_mid.c
+++ b/drivers/scsi/qla2xxx/qla_mid.c
@@ -66,6 +66,7 @@ qla24xx_deallocate_vp_id(scsi_qla_host_t *vha)
66 uint16_t vp_id; 66 uint16_t vp_id;
67 struct qla_hw_data *ha = vha->hw; 67 struct qla_hw_data *ha = vha->hw;
68 unsigned long flags = 0; 68 unsigned long flags = 0;
69 u8 i;
69 70
70 mutex_lock(&ha->vport_lock); 71 mutex_lock(&ha->vport_lock);
71 /* 72 /*
@@ -75,8 +76,9 @@ qla24xx_deallocate_vp_id(scsi_qla_host_t *vha)
75 * ensures no active vp_list traversal while the vport is removed 76 * ensures no active vp_list traversal while the vport is removed
76 * from the queue) 77 * from the queue)
77 */ 78 */
78 wait_event_timeout(vha->vref_waitq, !atomic_read(&vha->vref_count), 79 for (i = 0; i < 10 && atomic_read(&vha->vref_count); i++)
79 10*HZ); 80 wait_event_timeout(vha->vref_waitq,
81 atomic_read(&vha->vref_count), HZ);
80 82
81 spin_lock_irqsave(&ha->vport_slock, flags); 83 spin_lock_irqsave(&ha->vport_slock, flags);
82 if (atomic_read(&vha->vref_count)) { 84 if (atomic_read(&vha->vref_count)) {
@@ -262,6 +264,9 @@ qla2x00_alert_all_vps(struct rsp_que *rsp, uint16_t *mb)
262 spin_lock_irqsave(&ha->vport_slock, flags); 264 spin_lock_irqsave(&ha->vport_slock, flags);
263 list_for_each_entry(vha, &ha->vp_list, list) { 265 list_for_each_entry(vha, &ha->vp_list, list) {
264 if (vha->vp_idx) { 266 if (vha->vp_idx) {
267 if (test_bit(VPORT_DELETE, &vha->dpc_flags))
268 continue;
269
265 atomic_inc(&vha->vref_count); 270 atomic_inc(&vha->vref_count);
266 spin_unlock_irqrestore(&ha->vport_slock, flags); 271 spin_unlock_irqrestore(&ha->vport_slock, flags);
267 272
@@ -300,6 +305,20 @@ qla2x00_alert_all_vps(struct rsp_que *rsp, uint16_t *mb)
300int 305int
301qla2x00_vp_abort_isp(scsi_qla_host_t *vha) 306qla2x00_vp_abort_isp(scsi_qla_host_t *vha)
302{ 307{
308 fc_port_t *fcport;
309
310 /*
311 * To exclusively reset vport, we need to log it out first.
312 * Note: This control_vp can fail if ISP reset is already
313 * issued, this is expected, as the vp would be already
314 * logged out due to ISP reset.
315 */
316 if (!test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) {
317 qla24xx_control_vp(vha, VCE_COMMAND_DISABLE_VPS_LOGO_ALL);
318 list_for_each_entry(fcport, &vha->vp_fcports, list)
319 fcport->logout_on_delete = 0;
320 }
321
303 /* 322 /*
304 * Physical port will do most of the abort and recovery work. We can 323 * Physical port will do most of the abort and recovery work. We can
305 * just treat it as a loop down 324 * just treat it as a loop down
@@ -312,16 +331,9 @@ qla2x00_vp_abort_isp(scsi_qla_host_t *vha)
312 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); 331 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME);
313 } 332 }
314 333
315 /*
316 * To exclusively reset vport, we need to log it out first. Note: this
317 * control_vp can fail if ISP reset is already issued, this is
318 * expected, as the vp would be already logged out due to ISP reset.
319 */
320 if (!test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))
321 qla24xx_control_vp(vha, VCE_COMMAND_DISABLE_VPS_LOGO_ALL);
322
323 ql_dbg(ql_dbg_taskm, vha, 0x801d, 334 ql_dbg(ql_dbg_taskm, vha, 0x801d,
324 "Scheduling enable of Vport %d.\n", vha->vp_idx); 335 "Scheduling enable of Vport %d.\n", vha->vp_idx);
336
325 return qla24xx_enable_vp(vha); 337 return qla24xx_enable_vp(vha);
326} 338}
327 339
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 73db01e3b4e4..3568031c6504 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -1115,9 +1115,15 @@ static inline int test_fcport_count(scsi_qla_host_t *vha)
1115void 1115void
1116qla2x00_wait_for_sess_deletion(scsi_qla_host_t *vha) 1116qla2x00_wait_for_sess_deletion(scsi_qla_host_t *vha)
1117{ 1117{
1118 u8 i;
1119
1118 qla2x00_mark_all_devices_lost(vha, 0); 1120 qla2x00_mark_all_devices_lost(vha, 0);
1119 1121
1120 wait_event_timeout(vha->fcport_waitQ, test_fcport_count(vha), 10*HZ); 1122 for (i = 0; i < 10; i++)
1123 wait_event_timeout(vha->fcport_waitQ, test_fcport_count(vha),
1124 HZ);
1125
1126 flush_workqueue(vha->hw->wq);
1121} 1127}
1122 1128
1123/* 1129/*
@@ -5036,6 +5042,10 @@ void qla24xx_create_new_sess(struct scsi_qla_host *vha, struct qla_work_evt *e)
5036 5042
5037 memcpy(fcport->port_name, e->u.new_sess.port_name, 5043 memcpy(fcport->port_name, e->u.new_sess.port_name,
5038 WWN_SIZE); 5044 WWN_SIZE);
5045
5046 if (e->u.new_sess.fc4_type & FS_FCP_IS_N2N)
5047 fcport->n2n_flag = 1;
5048
5039 } else { 5049 } else {
5040 ql_dbg(ql_dbg_disc, vha, 0xffff, 5050 ql_dbg(ql_dbg_disc, vha, 0xffff,
5041 "%s %8phC mem alloc fail.\n", 5051 "%s %8phC mem alloc fail.\n",
@@ -5134,11 +5144,9 @@ void qla24xx_create_new_sess(struct scsi_qla_host *vha, struct qla_work_evt *e)
5134 if (dfcp) 5144 if (dfcp)
5135 qlt_schedule_sess_for_deletion(tfcp); 5145 qlt_schedule_sess_for_deletion(tfcp);
5136 5146
5137
5138 if (N2N_TOPO(vha->hw))
5139 fcport->flags &= ~FCF_FABRIC_DEVICE;
5140
5141 if (N2N_TOPO(vha->hw)) { 5147 if (N2N_TOPO(vha->hw)) {
5148 fcport->flags &= ~FCF_FABRIC_DEVICE;
5149 fcport->keep_nport_handle = 1;
5142 if (vha->flags.nvme_enabled) { 5150 if (vha->flags.nvme_enabled) {
5143 fcport->fc4f_nvme = 1; 5151 fcport->fc4f_nvme = 1;
5144 fcport->n2n_flag = 1; 5152 fcport->n2n_flag = 1;
diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
index 0ffda6171614..a06e56224a55 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -953,7 +953,7 @@ void qlt_free_session_done(struct work_struct *work)
953 struct qla_hw_data *ha = vha->hw; 953 struct qla_hw_data *ha = vha->hw;
954 unsigned long flags; 954 unsigned long flags;
955 bool logout_started = false; 955 bool logout_started = false;
956 scsi_qla_host_t *base_vha; 956 scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
957 struct qlt_plogi_ack_t *own = 957 struct qlt_plogi_ack_t *own =
958 sess->plogi_link[QLT_PLOGI_LINK_SAME_WWN]; 958 sess->plogi_link[QLT_PLOGI_LINK_SAME_WWN];
959 959
@@ -1020,6 +1020,7 @@ void qlt_free_session_done(struct work_struct *work)
1020 1020
1021 if (logout_started) { 1021 if (logout_started) {
1022 bool traced = false; 1022 bool traced = false;
1023 u16 cnt = 0;
1023 1024
1024 while (!READ_ONCE(sess->logout_completed)) { 1025 while (!READ_ONCE(sess->logout_completed)) {
1025 if (!traced) { 1026 if (!traced) {
@@ -1029,6 +1030,9 @@ void qlt_free_session_done(struct work_struct *work)
1029 traced = true; 1030 traced = true;
1030 } 1031 }
1031 msleep(100); 1032 msleep(100);
1033 cnt++;
1034 if (cnt > 200)
1035 break;
1032 } 1036 }
1033 1037
1034 ql_dbg(ql_dbg_disc, vha, 0xf087, 1038 ql_dbg(ql_dbg_disc, vha, 0xf087,
@@ -1101,6 +1105,7 @@ void qlt_free_session_done(struct work_struct *work)
1101 } 1105 }
1102 1106
1103 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); 1107 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags);
1108 sess->free_pending = 0;
1104 1109
1105 ql_dbg(ql_dbg_tgt_mgt, vha, 0xf001, 1110 ql_dbg(ql_dbg_tgt_mgt, vha, 0xf001,
1106 "Unregistration of sess %p %8phC finished fcp_cnt %d\n", 1111 "Unregistration of sess %p %8phC finished fcp_cnt %d\n",
@@ -1109,17 +1114,9 @@ void qlt_free_session_done(struct work_struct *work)
1109 if (tgt && (tgt->sess_count == 0)) 1114 if (tgt && (tgt->sess_count == 0))
1110 wake_up_all(&tgt->waitQ); 1115 wake_up_all(&tgt->waitQ);
1111 1116
1112 if (vha->fcport_count == 0) 1117 if (!test_bit(PFLG_DRIVER_REMOVING, &base_vha->pci_flags) &&
1113 wake_up_all(&vha->fcport_waitQ); 1118 !(vha->vp_idx && test_bit(VPORT_DELETE, &vha->dpc_flags)) &&
1114 1119 (!tgt || !tgt->tgt_stop) && !LOOP_TRANSITION(vha)) {
1115 base_vha = pci_get_drvdata(ha->pdev);
1116
1117 sess->free_pending = 0;
1118
1119 if (test_bit(PFLG_DRIVER_REMOVING, &base_vha->pci_flags))
1120 return;
1121
1122 if ((!tgt || !tgt->tgt_stop) && !LOOP_TRANSITION(vha)) {
1123 switch (vha->host->active_mode) { 1120 switch (vha->host->active_mode) {
1124 case MODE_INITIATOR: 1121 case MODE_INITIATOR:
1125 case MODE_DUAL: 1122 case MODE_DUAL:
@@ -1132,6 +1129,9 @@ void qlt_free_session_done(struct work_struct *work)
1132 break; 1129 break;
1133 } 1130 }
1134 } 1131 }
1132
1133 if (vha->fcport_count == 0)
1134 wake_up_all(&vha->fcport_waitQ);
1135} 1135}
1136 1136
1137/* ha->tgt.sess_lock supposed to be held on entry */ 1137/* ha->tgt.sess_lock supposed to be held on entry */
@@ -1161,7 +1161,7 @@ void qlt_unreg_sess(struct fc_port *sess)
1161 sess->last_login_gen = sess->login_gen; 1161 sess->last_login_gen = sess->login_gen;
1162 1162
1163 INIT_WORK(&sess->free_work, qlt_free_session_done); 1163 INIT_WORK(&sess->free_work, qlt_free_session_done);
1164 schedule_work(&sess->free_work); 1164 queue_work(sess->vha->hw->wq, &sess->free_work);
1165} 1165}
1166EXPORT_SYMBOL(qlt_unreg_sess); 1166EXPORT_SYMBOL(qlt_unreg_sess);
1167 1167
diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index ed8b9ac805e6..542d2bac2922 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -1837,8 +1837,7 @@ static int storvsc_probe(struct hv_device *device,
1837 /* 1837 /*
1838 * Set the number of HW queues we are supporting. 1838 * Set the number of HW queues we are supporting.
1839 */ 1839 */
1840 if (stor_device->num_sc != 0) 1840 host->nr_hw_queues = num_present_cpus();
1841 host->nr_hw_queues = stor_device->num_sc + 1;
1842 1841
1843 /* 1842 /*
1844 * Set the error handler work queue. 1843 * Set the error handler work queue.
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 034dd9cb9ec8..11a87f51c442 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -8143,6 +8143,9 @@ int ufshcd_shutdown(struct ufs_hba *hba)
8143{ 8143{
8144 int ret = 0; 8144 int ret = 0;
8145 8145
8146 if (!hba->is_powered)
8147 goto out;
8148
8146 if (ufshcd_is_ufs_dev_poweroff(hba) && ufshcd_is_link_off(hba)) 8149 if (ufshcd_is_ufs_dev_poweroff(hba) && ufshcd_is_link_off(hba))
8147 goto out; 8150 goto out;
8148 8151