From a92568cb16662302efaa2fe23185b271972156f0 Mon Sep 17 00:00:00 2001 From: xiabing Date: Thu, 31 Aug 2023 09:32:45 +0800 Subject: [PATCH 01/12] scsi: hisi_sas: Revert "Increase-debugfs_dump_index-after-dump" driver inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I7WQZ1 CVE: NA ---------------------------------------------------------------------- This reverts commit 82a092921515d1acf3990c57faf34cef2c50d6f7. Signed-off-by: xiabing --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 5a5957834924..9274ecfc518d 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -3812,6 +3812,7 @@ static void debugfs_snapshot_regs_v3_hw(struct hisi_hba *hisi_hba) do_div(timestamp, NSEC_PER_MSEC); hisi_hba->debugfs_timestamp[debugfs_dump_index] = timestamp; + hisi_hba->debugfs_dump_index++; debugfs_snapshot_prepare_v3_hw(hisi_hba); @@ -3827,7 +3828,6 @@ static void debugfs_snapshot_regs_v3_hw(struct hisi_hba *hisi_hba) debugfs_create_files_v3_hw(hisi_hba); debugfs_snapshot_restore_v3_hw(hisi_hba); - hisi_hba->debugfs_dump_index++; } static ssize_t debugfs_trigger_dump_v3_hw_write(struct file *file, -- Gitee From 038f5fd0c82158d23c2bdcb3b2482c44df30ef0c Mon Sep 17 00:00:00 2001 From: xiabing Date: Thu, 31 Aug 2023 09:32:46 +0800 Subject: [PATCH 02/12] scsi: libsas: Revert "Export-sas_phy_enable" driver inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I7WQZ1 CVE: NA ---------------------------------------------------------------------- This reverts commit 798b261ba08c3e51fd84b313f9f17c2e6f43e6e3. Signed-off-by: xiabing --- drivers/scsi/libsas/sas_init.c | 3 +-- include/scsi/libsas.h | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/scsi/libsas/sas_init.c b/drivers/scsi/libsas/sas_init.c index 58ffcecf1a2f..2f344f355ae6 100644 --- a/drivers/scsi/libsas/sas_init.c +++ b/drivers/scsi/libsas/sas_init.c @@ -252,7 +252,7 @@ static int transport_sas_phy_reset(struct sas_phy *phy, int hard_reset) } } -int sas_phy_enable(struct sas_phy *phy, int enable) +static int sas_phy_enable(struct sas_phy *phy, int enable) { int ret; enum phy_func cmd; @@ -284,7 +284,6 @@ int sas_phy_enable(struct sas_phy *phy, int enable) } return ret; } -EXPORT_SYMBOL_GPL(sas_phy_enable); int sas_phy_reset(struct sas_phy *phy, int hard_reset) { diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index 698f2032807b..85159b66f41e 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -666,7 +666,6 @@ extern void sas_suspend_ha(struct sas_ha_struct *sas_ha); int sas_set_phy_speed(struct sas_phy *phy, struct sas_phy_linkrates *rates); int sas_phy_reset(struct sas_phy *phy, int hard_reset); -int sas_phy_enable(struct sas_phy *phy, int enable); extern int sas_queuecommand(struct Scsi_Host *, struct scsi_cmnd *); extern int sas_target_alloc(struct scsi_target *); extern int sas_slave_configure(struct scsi_device *); -- Gitee From 240c6525e673c38cd6b72666a52178d4d7a4cb0f Mon Sep 17 00:00:00 2001 From: xiabing Date: Thu, 31 Aug 2023 09:32:47 +0800 Subject: [PATCH 03/12] scsi: hisi_sas: Revert "Revert "scsi: hisi_sas: Disable SATA disk phy for severe I_T nexus reset failure"" driver inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I7WQZ1 CVE: NA ---------------------------------------------------------------------- This reverts commit afa6401df1f74ccb914b57fd930b4ea3662fb0fe. Signed-off-by: xiabing --- drivers/scsi/hisi_sas/hisi_sas_main.c | 29 ++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 2a1b08244d1f..283d18f91ed6 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -1947,14 +1947,33 @@ static int hisi_sas_I_T_nexus_reset(struct domain_device *device) } hisi_sas_dereg_device(hisi_hba, device); - if (dev_is_sata(device)) { + rc = hisi_sas_debug_I_T_nexus_reset(device); + if (rc == TMF_RESP_FUNC_COMPLETE && dev_is_sata(device)) { + struct sas_phy *local_phy; + rc = hisi_sas_softreset_ata_disk(device); - if (rc == TMF_RESP_FUNC_FAILED) - dev_err(dev, "ata disk %016llx reset (%d)\n", - SAS_ADDR(device->sas_addr), rc); + switch (rc) { + case -ECOMM: + rc = -ENODEV; + break; + case TMF_RESP_FUNC_FAILED: + case -EMSGSIZE: + case -EIO: + local_phy = sas_get_local_phy(device); + rc = sas_phy_enable(local_phy, 0); + if (!rc) { + local_phy->enabled = 0; + dev_err(dev, "Disabled local phy of ATA disk %016llx due to softreset fail (%d)\n", + SAS_ADDR(device->sas_addr), rc); + rc = -ENODEV; + } + sas_put_local_phy(local_phy); + break; + default: + break; + } } - rc = hisi_sas_debug_I_T_nexus_reset(device); if ((rc == TMF_RESP_FUNC_COMPLETE) || (rc == -ENODEV)) hisi_sas_release_task(hisi_hba, device); -- Gitee From ff15883c0c6edf60ce4df971d806cdc07b7f57d8 Mon Sep 17 00:00:00 2001 From: xiabing Date: Thu, 31 Aug 2023 09:32:48 +0800 Subject: [PATCH 04/12] scsi: hisi_sas: Revert "Disable-SATA-disk-phy-for-severe-I_T-nexus reset failure" driver inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I7WQZ1 CVE: NA ---------------------------------------------------------------------- This reverts commit c723ada86707c6afe524b51126c301d689c64d8e. Signed-off-by: xiabing --- drivers/scsi/hisi_sas/hisi_sas_main.c | 29 +++++---------------------- 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 283d18f91ed6..7e14cd8f82dd 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -1947,33 +1947,14 @@ static int hisi_sas_I_T_nexus_reset(struct domain_device *device) } hisi_sas_dereg_device(hisi_hba, device); - rc = hisi_sas_debug_I_T_nexus_reset(device); - if (rc == TMF_RESP_FUNC_COMPLETE && dev_is_sata(device)) { - struct sas_phy *local_phy; - + if (dev_is_sata(device)) { rc = hisi_sas_softreset_ata_disk(device); - switch (rc) { - case -ECOMM: - rc = -ENODEV; - break; - case TMF_RESP_FUNC_FAILED: - case -EMSGSIZE: - case -EIO: - local_phy = sas_get_local_phy(device); - rc = sas_phy_enable(local_phy, 0); - if (!rc) { - local_phy->enabled = 0; - dev_err(dev, "Disabled local phy of ATA disk %016llx due to softreset fail (%d)\n", - SAS_ADDR(device->sas_addr), rc); - rc = -ENODEV; - } - sas_put_local_phy(local_phy); - break; - default: - break; - } + if (rc == TMF_RESP_FUNC_FAILED) + return TMF_RESP_FUNC_FAILED; } + rc = hisi_sas_debug_I_T_nexus_reset(device); + if ((rc == TMF_RESP_FUNC_COMPLETE) || (rc == -ENODEV)) hisi_sas_release_task(hisi_hba, device); -- Gitee From 8e49b13ca753141ab2637673f5afb92d192843ef Mon Sep 17 00:00:00 2001 From: xiabing Date: Thu, 31 Aug 2023 09:32:49 +0800 Subject: [PATCH 05/12] scsi: hisi_sas: Revert "scsi: hisi_sas: Revert "scsi: hisi_sas: Limit max hw sectors for v3 HW"" driver inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I7WQZ1 CVE: NA ---------------------------------------------------------------------- This reverts commit 6df5eee6f3168339df286c6e4203a52d6e35c7a7. Signed-off-by: xiabing --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 9274ecfc518d..12cff3c4f47e 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -2860,6 +2860,7 @@ static int slave_configure_v3_hw(struct scsi_device *sdev) struct hisi_hba *hisi_hba = shost_priv(shost); struct device *dev = hisi_hba->dev; int ret = sas_slave_configure(sdev); + unsigned int max_sectors; if (ret) return ret; @@ -2878,6 +2879,12 @@ static int slave_configure_v3_hw(struct scsi_device *sdev) } } + /* Set according to IOMMU IOVA caching limit */ + max_sectors = min_t(size_t, queue_max_hw_sectors(sdev->request_queue), + (PAGE_SIZE * 32) >> SECTOR_SHIFT); + + blk_queue_max_hw_sectors(sdev->request_queue, max_sectors); + return 0; } -- Gitee From 87045e39d093f0529f8d10f2ae90d27ea92a4aa2 Mon Sep 17 00:00:00 2001 From: xiabing Date: Thu, 31 Aug 2023 09:32:50 +0800 Subject: [PATCH 06/12] scsi: hisi_sas: Revert "scsi: hisi_sas: Configure the initialization registers according to HBA model" driver inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I7WQZ1 CVE: NA ---------------------------------------------------------------------- This reverts commit 6e7c968e081d89e52753eb176514452f134bfb92. Signed-off-by: xiabing --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 12cff3c4f47e..ecb45f69a1a8 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -620,12 +620,12 @@ static void interrupt_enable_v3_hw(struct hisi_hba *hisi_hba) static void init_reg_v3_hw(struct hisi_hba *hisi_hba) { - struct pci_dev *pdev = hisi_hba->pci_dev; int i, j; /* Global registers init */ hisi_sas_write32(hisi_hba, DLVRY_QUEUE_ENABLE, (u32)((1ULL << hisi_hba->queue_count) - 1)); + hisi_sas_write32(hisi_hba, SAS_AXI_USER3, 0); hisi_sas_write32(hisi_hba, CFG_MAX_TAG, 0xfff0400); /* time / CLK_AHB = 2.5s / 2ns = 0x4A817C80 */ hisi_sas_write32(hisi_hba, TRANS_LOCK_ICT_TIME, 0x4A817C80); @@ -647,9 +647,6 @@ static void init_reg_v3_hw(struct hisi_hba *hisi_hba) hisi_sas_write32(hisi_hba, ARQOS_ARCACHE_CFG, 0xf0f0); hisi_sas_write32(hisi_hba, HYPER_STREAM_ID_EN_CFG, 1); - if (pdev->revision < 0x30) - hisi_sas_write32(hisi_hba, SAS_AXI_USER3, 0); - interrupt_enable_v3_hw(hisi_hba); for (i = 0; i < hisi_hba->n_phy; i++) { enum sas_linkrate max; @@ -667,6 +664,7 @@ static void init_reg_v3_hw(struct hisi_hba *hisi_hba) prog_phy_link_rate |= hisi_sas_get_prog_phy_linkrate_mask(max); hisi_sas_phy_write32(hisi_hba, i, PROG_PHY_LINK_RATE, prog_phy_link_rate); + hisi_sas_phy_write32(hisi_hba, i, SERDES_CFG, 0xffc00); hisi_sas_phy_write32(hisi_hba, i, SAS_RX_TRAIN_TIMER, 0x13e80); hisi_sas_phy_write32(hisi_hba, i, CHL_INT0, 0xffffffff); hisi_sas_phy_write32(hisi_hba, i, CHL_INT1, 0xffffffff); @@ -677,18 +675,13 @@ static void init_reg_v3_hw(struct hisi_hba *hisi_hba) hisi_sas_phy_write32(hisi_hba, i, PHYCTRL_OOB_RESTART_MSK, 0x1); hisi_sas_phy_write32(hisi_hba, i, STP_LINK_TIMER, 0x7f7a120); hisi_sas_phy_write32(hisi_hba, i, CON_CFG_DRIVER, 0x2a0a01); + hisi_sas_phy_write32(hisi_hba, i, SAS_SSP_CON_TIMER_CFG, 0x32); hisi_sas_phy_write32(hisi_hba, i, SAS_EC_INT_COAL_TIME, 0x30f4240); + /* used for 12G negotiate */ + hisi_sas_phy_write32(hisi_hba, i, COARSETUNE_TIME, 0x1e); hisi_sas_phy_write32(hisi_hba, i, AIP_LIMIT, 0x2ffff); - /* set value through firmware for the latest HBA */ - if (pdev->revision < 0x30) { - hisi_sas_phy_write32(hisi_hba, i, SAS_SSP_CON_TIMER_CFG, 0x32); - hisi_sas_phy_write32(hisi_hba, i, SERDES_CFG, 0xffc00); - /* used for 12G negotiate */ - hisi_sas_phy_write32(hisi_hba, i, COARSETUNE_TIME, 0x1e); - } - /* get default FFE configuration for BIST */ for (j = 0; j < FFE_CFG_MAX; j++) { u32 val = hisi_sas_phy_read32(hisi_hba, i, -- Gitee From 001a9b454379ecd2e4d5b39138c8c64e929497e3 Mon Sep 17 00:00:00 2001 From: Luo Jiaxing Date: Thu, 31 Aug 2023 09:32:51 +0800 Subject: [PATCH 07/12] scsi: hisi_sas: Increase debugfs_dump_index after dump is completed mainline inclusion from mainline-v5.16-rc1 commit 9aec5ffa6e39926cff1a6b576c815a9cee90e259 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I7X774 CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9aec5ffa6e39926cff1a6b576c815a9cee90e259 ---------------------------------------------------------------------- The hisi_hba debugfs_dump_index member should increased after a dump insertion completed, and not before it has started, so fix the code to do so. Link: https://lore.kernel.org/r/1629799260-120116-6-git-send-email-john.garry@huawei.com Signed-off-by: Luo Jiaxing Signed-off-by: John Garry Signed-off-by: Martin K. Petersen Signed-off-by: xiabing --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index ecb45f69a1a8..67304286eef2 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -3812,7 +3812,6 @@ static void debugfs_snapshot_regs_v3_hw(struct hisi_hba *hisi_hba) do_div(timestamp, NSEC_PER_MSEC); hisi_hba->debugfs_timestamp[debugfs_dump_index] = timestamp; - hisi_hba->debugfs_dump_index++; debugfs_snapshot_prepare_v3_hw(hisi_hba); @@ -3828,6 +3827,7 @@ static void debugfs_snapshot_regs_v3_hw(struct hisi_hba *hisi_hba) debugfs_create_files_v3_hw(hisi_hba); debugfs_snapshot_restore_v3_hw(hisi_hba); + hisi_hba->debugfs_dump_index++; } static ssize_t debugfs_trigger_dump_v3_hw_write(struct file *file, -- Gitee From 8e29fbb6be432d59fa1e28628bb1ffd96624b5d2 Mon Sep 17 00:00:00 2001 From: Luo Jiaxing Date: Thu, 31 Aug 2023 09:32:52 +0800 Subject: [PATCH 08/12] scsi: libsas: Export sas_phy_enable() mainline inclusion from mainline-v5.16-rc1 commit 00aeaf329a3a1ea3d3606fefa1d29 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I7X774 CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=00aeaf329a3a1ea3d3606fefa1d29 ---------------------------------------------------------------------- Export sas_phy_enable() so LLDDs can directly use it to control remote phys. We already do this for companion function sas_phy_reset(). Link: https://lore.kernel.org/r/1634041588-74824-4-git-send-email-john.garry@huawei.com Signed-off-by: Luo Jiaxing Signed-off-by: John Garry Signed-off-by: Martin K. Petersen Signed-off-by: xiabing --- drivers/scsi/libsas/sas_init.c | 3 ++- include/scsi/libsas.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/libsas/sas_init.c b/drivers/scsi/libsas/sas_init.c index 2f344f355ae6..58ffcecf1a2f 100644 --- a/drivers/scsi/libsas/sas_init.c +++ b/drivers/scsi/libsas/sas_init.c @@ -252,7 +252,7 @@ static int transport_sas_phy_reset(struct sas_phy *phy, int hard_reset) } } -static int sas_phy_enable(struct sas_phy *phy, int enable) +int sas_phy_enable(struct sas_phy *phy, int enable) { int ret; enum phy_func cmd; @@ -284,6 +284,7 @@ static int sas_phy_enable(struct sas_phy *phy, int enable) } return ret; } +EXPORT_SYMBOL_GPL(sas_phy_enable); int sas_phy_reset(struct sas_phy *phy, int hard_reset) { diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index 85159b66f41e..698f2032807b 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -666,6 +666,7 @@ extern void sas_suspend_ha(struct sas_ha_struct *sas_ha); int sas_set_phy_speed(struct sas_phy *phy, struct sas_phy_linkrates *rates); int sas_phy_reset(struct sas_phy *phy, int hard_reset); +int sas_phy_enable(struct sas_phy *phy, int enable); extern int sas_queuecommand(struct Scsi_Host *, struct scsi_cmnd *); extern int sas_target_alloc(struct scsi_target *); extern int sas_slave_configure(struct scsi_device *); -- Gitee From 82caf8bf6fcaa4c4b5e0159367164636244eaa6a Mon Sep 17 00:00:00 2001 From: Luo Jiaxing Date: Thu, 31 Aug 2023 09:32:53 +0800 Subject: [PATCH 09/12] scsi: hisi_sas: Disable SATA disk phy for severe I_T nexus reset failure mainline inclusion from mainline-v5.16-rc1 commit 21c7e972475e6a975fbe97f8974c96fe47130 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I7X774 CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=21c7e972475e6a975fbe97f8974c96fe47130 ---------------------------------------------------------------------- If the softreset fails in the I_T reset, libsas will then continue to issue a controller reset to try to recover. However a faulty disk may cause the softreset to fail, and resetting the controller will not help this scenario. Indeed, we will just continue the cycle of error handle handling to try to recover. So if the softreset fails upon certain conditions, just disable the phy associated with the disk. The user needs to handle this problem. Link: https://lore.kernel.org/r/1634041588-74824-5-git-send-email-john.garry@huawei.com Signed-off-by: Luo Jiaxing Signed-off-by: John Garry Signed-off-by: Martin K. Petersen Signed-off-by: xiabing --- drivers/scsi/hisi_sas/hisi_sas_main.c | 29 ++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 7e14cd8f82dd..283d18f91ed6 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -1947,14 +1947,33 @@ static int hisi_sas_I_T_nexus_reset(struct domain_device *device) } hisi_sas_dereg_device(hisi_hba, device); - if (dev_is_sata(device)) { + rc = hisi_sas_debug_I_T_nexus_reset(device); + if (rc == TMF_RESP_FUNC_COMPLETE && dev_is_sata(device)) { + struct sas_phy *local_phy; + rc = hisi_sas_softreset_ata_disk(device); - if (rc == TMF_RESP_FUNC_FAILED) - return TMF_RESP_FUNC_FAILED; + switch (rc) { + case -ECOMM: + rc = -ENODEV; + break; + case TMF_RESP_FUNC_FAILED: + case -EMSGSIZE: + case -EIO: + local_phy = sas_get_local_phy(device); + rc = sas_phy_enable(local_phy, 0); + if (!rc) { + local_phy->enabled = 0; + dev_err(dev, "Disabled local phy of ATA disk %016llx due to softreset fail (%d)\n", + SAS_ADDR(device->sas_addr), rc); + rc = -ENODEV; + } + sas_put_local_phy(local_phy); + break; + default: + break; + } } - rc = hisi_sas_debug_I_T_nexus_reset(device); - if ((rc == TMF_RESP_FUNC_COMPLETE) || (rc == -ENODEV)) hisi_sas_release_task(hisi_hba, device); -- Gitee From 360b9243fbedd8a6e1e0e2b9bf8ca78a9a450e98 Mon Sep 17 00:00:00 2001 From: Yihang Li Date: Thu, 31 Aug 2023 09:32:54 +0800 Subject: [PATCH 10/12] scsi: hisi_sas: Revert "scsi: hisi_sas: Disable SATA disk phy for severe I_T nexus reset failure" driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7X774 CVE: NA ---------------------------------------------------------------------- In that commit, if the softreset fails upon certain conditions, just disable the PHY associated with the disk. The user needs to restore the PHY. SATA disks do not support simultaneous connection of multiple hosts. Therefore, when multiple controllers are connected to a SATA disk at the same time, the controller which is connected later failed to issue an ATA softreset to the SATA disk. As a result, the PHY associated with the disk is disabled and cannot be automatically recovered. Now that, we will not focus on the execution result of softreset. No matter whether the execution is successful or not, we will directly carry out I_T_nexus_reset. Fixes: c723ada86707 ("scsi: hisi_sas: Disable SATA disk phy for severe I_T nexus reset failure") Signed-off-by: Yihang Li Signed-off-by: xiabing --- drivers/scsi/hisi_sas/hisi_sas_main.c | 29 +++++---------------------- 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 283d18f91ed6..2a1b08244d1f 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -1947,33 +1947,14 @@ static int hisi_sas_I_T_nexus_reset(struct domain_device *device) } hisi_sas_dereg_device(hisi_hba, device); - rc = hisi_sas_debug_I_T_nexus_reset(device); - if (rc == TMF_RESP_FUNC_COMPLETE && dev_is_sata(device)) { - struct sas_phy *local_phy; - + if (dev_is_sata(device)) { rc = hisi_sas_softreset_ata_disk(device); - switch (rc) { - case -ECOMM: - rc = -ENODEV; - break; - case TMF_RESP_FUNC_FAILED: - case -EMSGSIZE: - case -EIO: - local_phy = sas_get_local_phy(device); - rc = sas_phy_enable(local_phy, 0); - if (!rc) { - local_phy->enabled = 0; - dev_err(dev, "Disabled local phy of ATA disk %016llx due to softreset fail (%d)\n", - SAS_ADDR(device->sas_addr), rc); - rc = -ENODEV; - } - sas_put_local_phy(local_phy); - break; - default: - break; - } + if (rc == TMF_RESP_FUNC_FAILED) + dev_err(dev, "ata disk %016llx reset (%d)\n", + SAS_ADDR(device->sas_addr), rc); } + rc = hisi_sas_debug_I_T_nexus_reset(device); if ((rc == TMF_RESP_FUNC_COMPLETE) || (rc == -ENODEV)) hisi_sas_release_task(hisi_hba, device); -- Gitee From fbe45ec2c1008e4bab893889d83a9ac1b7556631 Mon Sep 17 00:00:00 2001 From: John Garry Date: Thu, 31 Aug 2023 09:32:55 +0800 Subject: [PATCH 11/12] scsi: hisi_sas: Revert change to limit max hw sectors for v3 HW mainline inclusion from mainline-v6.1-rc1 commit 245050af5d15 category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7X774 CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=245050af5d15 ---------------------------------------------------------------------- Now that libsas and the SCSI core code limits the default sectors from commit 4cbfca5f7750 ("scsi: scsi_transport_sas: cap shost opt_sectors according to DMA optimal limit") and commit 608128d391fa ("scsi: sd: allow max_sectors be capped at DMA optimal size limit"), there is no need for the hack to limit the max HW sectors. Link: https://lore.kernel.org/r/1662378529-101489-2-git-send-email-john.garry@huawei.com Signed-off-by: John Garry Signed-off-by: Martin K. Petersen Signed-off-by: xiabing --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 67304286eef2..974f9d8454cb 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -2853,7 +2853,6 @@ static int slave_configure_v3_hw(struct scsi_device *sdev) struct hisi_hba *hisi_hba = shost_priv(shost); struct device *dev = hisi_hba->dev; int ret = sas_slave_configure(sdev); - unsigned int max_sectors; if (ret) return ret; @@ -2872,12 +2871,6 @@ static int slave_configure_v3_hw(struct scsi_device *sdev) } } - /* Set according to IOMMU IOVA caching limit */ - max_sectors = min_t(size_t, queue_max_hw_sectors(sdev->request_queue), - (PAGE_SIZE * 32) >> SECTOR_SHIFT); - - blk_queue_max_hw_sectors(sdev->request_queue, max_sectors); - return 0; } -- Gitee From 48877aada8b79ca1795db6cb99e60aa8c33f21ac Mon Sep 17 00:00:00 2001 From: Yihang Li Date: Thu, 31 Aug 2023 09:32:56 +0800 Subject: [PATCH 12/12] scsi: hisi_sas: Configure initial value of some registers according to HBA model mainline inclusion from mainline-v6.5-rc1 commit b68daae9660b category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7X774 CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b68daae9660b ---------------------------------------------------------------------- For SAS HBAs of 920 and previous version, we use init_reg_v3_hw() to set some registers which are related to HW boards. For SAS HBAs of 920B and later version, those HW registers are set through firmware. And different HBA models are distinguished through pci_dev->revision. Signed-off-by: Yihang Li Signed-off-by: Xiang Chen Link: https://lore.kernel.org/r/1684118481-95908-2-git-send-email-chenxiang66@hisilicon.com Signed-off-by: Martin K. Petersen Signed-off-by: xiabing --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 974f9d8454cb..88425eccc103 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -620,12 +620,12 @@ static void interrupt_enable_v3_hw(struct hisi_hba *hisi_hba) static void init_reg_v3_hw(struct hisi_hba *hisi_hba) { + struct pci_dev *pdev = hisi_hba->pci_dev; int i, j; /* Global registers init */ hisi_sas_write32(hisi_hba, DLVRY_QUEUE_ENABLE, (u32)((1ULL << hisi_hba->queue_count) - 1)); - hisi_sas_write32(hisi_hba, SAS_AXI_USER3, 0); hisi_sas_write32(hisi_hba, CFG_MAX_TAG, 0xfff0400); /* time / CLK_AHB = 2.5s / 2ns = 0x4A817C80 */ hisi_sas_write32(hisi_hba, TRANS_LOCK_ICT_TIME, 0x4A817C80); @@ -647,6 +647,9 @@ static void init_reg_v3_hw(struct hisi_hba *hisi_hba) hisi_sas_write32(hisi_hba, ARQOS_ARCACHE_CFG, 0xf0f0); hisi_sas_write32(hisi_hba, HYPER_STREAM_ID_EN_CFG, 1); + if (pdev->revision < 0x30) + hisi_sas_write32(hisi_hba, SAS_AXI_USER3, 0); + interrupt_enable_v3_hw(hisi_hba); for (i = 0; i < hisi_hba->n_phy; i++) { enum sas_linkrate max; @@ -664,7 +667,6 @@ static void init_reg_v3_hw(struct hisi_hba *hisi_hba) prog_phy_link_rate |= hisi_sas_get_prog_phy_linkrate_mask(max); hisi_sas_phy_write32(hisi_hba, i, PROG_PHY_LINK_RATE, prog_phy_link_rate); - hisi_sas_phy_write32(hisi_hba, i, SERDES_CFG, 0xffc00); hisi_sas_phy_write32(hisi_hba, i, SAS_RX_TRAIN_TIMER, 0x13e80); hisi_sas_phy_write32(hisi_hba, i, CHL_INT0, 0xffffffff); hisi_sas_phy_write32(hisi_hba, i, CHL_INT1, 0xffffffff); @@ -675,13 +677,18 @@ static void init_reg_v3_hw(struct hisi_hba *hisi_hba) hisi_sas_phy_write32(hisi_hba, i, PHYCTRL_OOB_RESTART_MSK, 0x1); hisi_sas_phy_write32(hisi_hba, i, STP_LINK_TIMER, 0x7f7a120); hisi_sas_phy_write32(hisi_hba, i, CON_CFG_DRIVER, 0x2a0a01); - hisi_sas_phy_write32(hisi_hba, i, SAS_SSP_CON_TIMER_CFG, 0x32); hisi_sas_phy_write32(hisi_hba, i, SAS_EC_INT_COAL_TIME, 0x30f4240); - /* used for 12G negotiate */ - hisi_sas_phy_write32(hisi_hba, i, COARSETUNE_TIME, 0x1e); hisi_sas_phy_write32(hisi_hba, i, AIP_LIMIT, 0x2ffff); + /* set value through firmware for 920B and later version */ + if (pdev->revision < 0x30) { + hisi_sas_phy_write32(hisi_hba, i, SAS_SSP_CON_TIMER_CFG, 0x32); + hisi_sas_phy_write32(hisi_hba, i, SERDES_CFG, 0xffc00); + /* used for 12G negotiate */ + hisi_sas_phy_write32(hisi_hba, i, COARSETUNE_TIME, 0x1e); + } + /* get default FFE configuration for BIST */ for (j = 0; j < FFE_CFG_MAX; j++) { u32 val = hisi_sas_phy_read32(hisi_hba, i, -- Gitee