From d88a5a969abc1fcdb3f69ec9dcd4cc7b2f005642 Mon Sep 17 00:00:00 2001 From: YunYi Yang Date: Sat, 2 Dec 2023 20:37:08 +0800 Subject: [PATCH] Add some bugfix of libsas and hisi sas driver --- kernel.spec | 10 +- ...e-sas_ata_wait_after_reset-in-IT-nex.patch | 75 ++++++++ ...-libsas-Add-smp_ata_check_ready_type.patch | 123 +++++++++++++ ...x-SATA-devices-missing-issue-during-.patch | 84 +++++++++ ...te-SATA-dev-FIS-in-sas_ata_task_done.patch | 48 +++++ ...ze-DIF-DIX-code-to-avoid-calling-rev.patch | 170 ++++++++++++++++++ ...IX-config-every-time-sd_revalidate_d.patch | 116 ++++++++++++ series.conf | 6 + 8 files changed, 631 insertions(+), 1 deletion(-) create mode 100644 patches/0760-scsi-hisi_sas-Use-sas_ata_wait_after_reset-in-IT-nex.patch create mode 100644 patches/0761-scsi-libsas-Add-smp_ata_check_ready_type.patch create mode 100644 patches/0762-scsi-hisi_sas-Fix-SATA-devices-missing-issue-during-.patch create mode 100644 patches/0763-scsi-libsas-Update-SATA-dev-FIS-in-sas_ata_task_done.patch create mode 100644 patches/0764-scsi-sd-Reorganize-DIF-DIX-code-to-avoid-calling-rev.patch create mode 100644 patches/0765-scsi-sd-Update-DIX-config-every-time-sd_revalidate_d.patch diff --git a/kernel.spec b/kernel.spec index 7a06c2c6..55def8df 100644 --- a/kernel.spec +++ b/kernel.spec @@ -32,7 +32,7 @@ Name: kernel Version: 4.19.90 -Release: %{hulkrelease}.0253 +Release: %{hulkrelease}.0254 Summary: Linux Kernel License: GPLv2 URL: http://www.kernel.org/ @@ -849,6 +849,14 @@ fi %endif %changelog +* Tue Dec 02 2023 YunYi Yang - 4.19.90-2311.5.0.0254 +- scsi: sd: Update DIX config every time sd_revalidate_disk() is called +- scsi: sd: Reorganize DIF/DIX code to avoid calling revalidate twice +- scsi: libsas: Update SATA dev FIS in sas_ata_task_done() +- scsi: hisi_sas: Fix SATA devices missing issue during I_T nexus reset +- scsi: libsas: Add smp_ata_check_ready_type() +- scsi: hisi_sas: Use sas_ata_wait_after_reset() in IT nexus reset + * Tue Nov 28 2023 Yuan Zhang - 4.19.90-2311.5.0.0253 - arm64: cpufeature: Extract capped perfmon fields - KVM: arm64: limit PMU version to PMUv3 for ARMv8.1 diff --git a/patches/0760-scsi-hisi_sas-Use-sas_ata_wait_after_reset-in-IT-nex.patch b/patches/0760-scsi-hisi_sas-Use-sas_ata_wait_after_reset-in-IT-nex.patch new file mode 100644 index 00000000..3d63a6fb --- /dev/null +++ b/patches/0760-scsi-hisi_sas-Use-sas_ata_wait_after_reset-in-IT-nex.patch @@ -0,0 +1,75 @@ +From 9bd522008341c9d3eacf94ba377fd834905ce066 Mon Sep 17 00:00:00 2001 +From: John Garry +Date: Tue, 15 Nov 2022 23:03:47 +0800 +Subject: [PATCH 1/6] scsi: hisi_sas: Use sas_ata_wait_after_reset() in IT + nexus reset + +mainline inclusion +from mainline-v5.19-rc1 +commit 71453bd9d1bfa2a75f742ac8ad75c084097e9a50 +category: feature +bugzilla: https://gitee.com/src-openeuler/kernel/issues/I8F85H + +Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=71453bd9d1bfa2a75f742ac8ad75c084097e9a50 + +---------------------------------------------------------------------- + +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 +Signed-off-by: xiabing +Reviewed-by: Jason Yan +Signed-off-by: Zheng Zengkai +Signed-off-by: YunYi Yang + + Conflicts: + drivers/scsi/hisi_sas/hisi_sas_main.c +--- + drivers/scsi/hisi_sas/hisi_sas_main.c | 17 +++++++++++++---- + 1 file changed, 13 insertions(+), 4 deletions(-) + +diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c +index 6bccd36556f2..af87730e2014 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_main.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_main.c +@@ -1843,10 +1843,19 @@ static int hisi_sas_debug_I_T_nexus_reset(struct domain_device *device) + dev_warn(dev, "phy%d reset timeout\n", sas_phy->id); + hisi_sas_phy_down(hisi_hba, sas_phy->id, 0); + } +- } else if (sas_dev->dev_status != HISI_SAS_DEV_INIT) +- /* Sleep 2s, wait for I_T reset at expander env except fail */ +- 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; + } +-- +2.27.0 + diff --git a/patches/0761-scsi-libsas-Add-smp_ata_check_ready_type.patch b/patches/0761-scsi-libsas-Add-smp_ata_check_ready_type.patch new file mode 100644 index 00000000..b391f3ff --- /dev/null +++ b/patches/0761-scsi-libsas-Add-smp_ata_check_ready_type.patch @@ -0,0 +1,123 @@ +From 4a46c1b4aad4b36763c680dafe9d3020079c55ec Mon Sep 17 00:00:00 2001 +From: Jie Zhan +Date: Fri, 14 Apr 2023 16:20:37 +0800 +Subject: [PATCH 2/6] scsi: libsas: Add smp_ata_check_ready_type() + +mainline inclusion +from mainline-v6.2-rc1 +commit 9181ce3cb5d96f0ee28246a857ca651830fa3746 +category: feature +bugzilla: https://gitee.com/src-openeuler/kernel/issues/I8F85H + +Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9181ce3cb5d96f0ee28246a857ca651830fa3746 + +---------------------------------------------------------------------- + +Create function smp_ata_check_ready_type() for LLDDs to wait for SATA +devices to come up after a link reset. + +Signed-off-by: Jie Zhan +Link: https://lore.kernel.org/r/20221118083714.4034612-4-zhanjie9@hisilicon.com +Signed-off-by: Martin K. Petersen +Signed-off-by: xiabing +Signed-off-by: YunYi Yang + + Conflicts: + include/scsi/sas_ata.h +--- + drivers/scsi/libsas/sas_ata.c | 25 +++++++++++++++++++++++++ + drivers/scsi/libsas/sas_expander.c | 4 ++-- + drivers/scsi/libsas/sas_internal.h | 2 ++ + include/scsi/sas_ata.h | 5 +++++ + 4 files changed, 34 insertions(+), 2 deletions(-) + +diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c +index 19a2b17876f5..6db5e09dfe92 100644 +--- a/drivers/scsi/libsas/sas_ata.c ++++ b/drivers/scsi/libsas/sas_ata.c +@@ -314,6 +314,31 @@ static int sas_ata_clear_pending(struct domain_device *dev, struct ex_phy *phy) + return 1; + } + ++int smp_ata_check_ready_type(struct ata_link *link) ++{ ++ struct domain_device *dev = link->ap->private_data; ++ struct sas_phy *phy = sas_get_local_phy(dev); ++ struct domain_device *ex_dev = dev->parent; ++ enum sas_device_type type = SAS_PHY_UNUSED; ++ u8 sas_addr[SAS_ADDR_SIZE]; ++ int res; ++ ++ res = sas_get_phy_attached_dev(ex_dev, phy->number, sas_addr, &type); ++ sas_put_local_phy(phy); ++ if (res) ++ return res; ++ ++ switch (type) { ++ case SAS_SATA_PENDING: ++ return 0; ++ case SAS_END_DEVICE: ++ return 1; ++ default: ++ return -ENODEV; ++ } ++} ++EXPORT_SYMBOL_GPL(smp_ata_check_ready_type); ++ + static int smp_ata_check_ready(struct ata_link *link) + { + int res; +diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c +index 911d0e1e8e3f..4743ace09f89 100644 +--- a/drivers/scsi/libsas/sas_expander.c ++++ b/drivers/scsi/libsas/sas_expander.c +@@ -1770,8 +1770,8 @@ static int sas_get_phy_change_count(struct domain_device *dev, + return res; + } + +-static int sas_get_phy_attached_dev(struct domain_device *dev, int phy_id, +- u8 *sas_addr, enum sas_device_type *type) ++int sas_get_phy_attached_dev(struct domain_device *dev, int phy_id, ++ u8 *sas_addr, enum sas_device_type *type) + { + int res; + struct smp_resp *disc_resp; +diff --git a/drivers/scsi/libsas/sas_internal.h b/drivers/scsi/libsas/sas_internal.h +index 50e12d662ffe..12d57e0f0ae5 100644 +--- a/drivers/scsi/libsas/sas_internal.h ++++ b/drivers/scsi/libsas/sas_internal.h +@@ -97,6 +97,8 @@ struct domain_device *sas_ex_to_ata(struct domain_device *ex_dev, int phy_id); + int sas_ex_phy_discover(struct domain_device *dev, int single); + int sas_get_report_phy_sata(struct domain_device *dev, int phy_id, + struct smp_resp *rps_resp); ++int sas_get_phy_attached_dev(struct domain_device *dev, int phy_id, ++ u8 *sas_addr, enum sas_device_type *type); + int sas_try_ata_reset(struct asd_sas_phy *phy); + void sas_hae_reset(struct work_struct *work); + +diff --git a/include/scsi/sas_ata.h b/include/scsi/sas_ata.h +index 6eac6f2f38ca..b995a17f6411 100644 +--- a/include/scsi/sas_ata.h ++++ b/include/scsi/sas_ata.h +@@ -56,6 +56,7 @@ void sas_suspend_sata(struct asd_sas_port *port); + void sas_resume_sata(struct asd_sas_port *port); + void sas_ata_end_eh(struct ata_port *ap); + void sas_ata_check_topology(struct asd_sas_port *port); ++int smp_ata_check_ready_type(struct ata_link *link); + #else + + +@@ -113,6 +114,10 @@ static inline void sas_ata_check_topology(struct asd_sas_port *port) + { + } + ++static inline int smp_ata_check_ready_type(struct ata_link *link) ++{ ++ return 0; ++} + #endif + + #endif /* _SAS_ATA_H_ */ +-- +2.27.0 + diff --git a/patches/0762-scsi-hisi_sas-Fix-SATA-devices-missing-issue-during-.patch b/patches/0762-scsi-hisi_sas-Fix-SATA-devices-missing-issue-during-.patch new file mode 100644 index 00000000..4ba97046 --- /dev/null +++ b/patches/0762-scsi-hisi_sas-Fix-SATA-devices-missing-issue-during-.patch @@ -0,0 +1,84 @@ +From 8bffc89e9062dd5c4594b3e6cf263a16603026a5 Mon Sep 17 00:00:00 2001 +From: Jie Zhan +Date: Fri, 14 Apr 2023 16:20:38 +0800 +Subject: [PATCH 3/6] scsi: hisi_sas: Fix SATA devices missing issue during I_T + nexus reset + +mainline inclusion +from mainline-v6.2-rc1 +commit 3c2673a09cf1181318c07b7dbc1bc532ba3d33e3 +category: bugfix +bugzilla: https://gitee.com/src-openeuler/kernel/issues/I8F85H + +Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3c2673a09cf1181318c07b7dbc1bc532ba3d33e3 + +---------------------------------------------------------------------- + +SATA devices on an expander may be removed and not be found again when I_T +nexus reset and revalidation are processed simultaneously. + +The issue comes from: + + - Revalidation can remove SATA devices in link reset, e.g. in + hisi_sas_clear_nexus_ha(). + + - However, hisi_sas_debug_I_T_nexus_reset() polls the state of a SATA + device on an expander after sending link_reset, where it calls: + hisi_sas_debug_I_T_nexus_reset + sas_ata_wait_after_reset + ata_wait_after_reset + ata_wait_ready + smp_ata_check_ready + sas_ex_phy_discover + sas_ex_phy_discover_helper + sas_set_ex_phy + + The ex_phy's change count is updated in sas_set_ex_phy(), so SATA + devices after a link reset may not be found later through revalidation. + +A similar issue was reported in: +commit 0f3fce5cc77e ("[SCSI] libsas: fix ata_eh clobbering ex_phys via +smp_ata_check_ready") +commit 87c8331fcf72 ("[SCSI] libsas: prevent domain rediscovery competing +with ata error handling"). + +To address this issue, in hisi_sas_debug_I_T_nexus_reset(), we now call +smp_ata_check_ready_type() that only polls the device type while not +updating the ex_phy's data of libsas. + +Fixes: 71453bd9d1bf ("scsi: hisi_sas: Use sas_ata_wait_after_reset() in IT nexus reset") +Signed-off-by: Jie Zhan +Link: https://lore.kernel.org/r/20221118083714.4034612-5-zhanjie9@hisilicon.com +Signed-off-by: Martin K. Petersen +Signed-off-by: xiabing +Signed-off-by: YunYi Yang +--- + drivers/scsi/hisi_sas/hisi_sas_main.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c +index af87730e2014..0ab92a3c4fc5 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_main.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_main.c +@@ -1846,13 +1846,15 @@ static int hisi_sas_debug_I_T_nexus_reset(struct domain_device *device) + return rc; + } + ++ /* Remote phy */ + if (rc) + return rc; + +- /* Remote phy */ + if (dev_is_sata(device)) { +- rc = sas_ata_wait_after_reset(device, +- HISI_SAS_WAIT_PHYUP_TIMEOUT); ++ struct ata_link *link = &device->sata_dev.ap->link; ++ ++ rc = ata_wait_after_reset(link, HISI_SAS_WAIT_PHYUP_TIMEOUT, ++ smp_ata_check_ready_type); + } else { + msleep(2000); + } +-- +2.27.0 + diff --git a/patches/0763-scsi-libsas-Update-SATA-dev-FIS-in-sas_ata_task_done.patch b/patches/0763-scsi-libsas-Update-SATA-dev-FIS-in-sas_ata_task_done.patch new file mode 100644 index 00000000..d13f2292 --- /dev/null +++ b/patches/0763-scsi-libsas-Update-SATA-dev-FIS-in-sas_ata_task_done.patch @@ -0,0 +1,48 @@ +From 7a430b4d026507224b2878448be030ebaba192f9 Mon Sep 17 00:00:00 2001 +From: John Garry +Date: Thu, 16 Mar 2023 20:21:40 +0800 +Subject: [PATCH 4/6] scsi: libsas: Update SATA dev FIS in sas_ata_task_done() + +mainline inclusion +from mainline-v6.2-rc1 +commit cc22efbec0110181725b1f5f6778155a2e352522 +category: feature +bugzilla: https://gitee.com/src-openeuler/kernel/issues/I8F82P + +Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=cc22efbec0110181725b1f5f6778155a2e352522 + +---------------------------------------------------------------------- + +In sas_ata_task_done(), for commands which complete with error we set the +SATA dev FIS status field with ATA_ERR. In ata_eh_analyze_tf() this would +be interpreted as a HSM error. Set ATA_DRDY, which will lead libata to +judge as a device error, which is a safer bet. + +Signed-off-by: John Garry +Link: https://lore.kernel.org/r/1665998435-199946-9-git-send-email-john.garry@huawei.com +Reviewed-by: Niklas Cassel +Signed-off-by: Martin K. Petersen +Signed-off-by: xiabing +Signed-off-by: YunYi Yang +--- + drivers/scsi/libsas/sas_ata.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c +index 6db5e09dfe92..4925bc0da743 100644 +--- a/drivers/scsi/libsas/sas_ata.c ++++ b/drivers/scsi/libsas/sas_ata.c +@@ -161,8 +161,8 @@ static void sas_ata_task_done(struct sas_task *task) + qc->flags |= ATA_QCFLAG_FAILED; + } + +- dev->sata_dev.fis[3] = 0x04; /* status err */ +- dev->sata_dev.fis[2] = ATA_ERR; ++ dev->sata_dev.fis[2] = ATA_ERR | ATA_DRDY; /* tf status */ ++ dev->sata_dev.fis[3] = ATA_ABORTED; /* tf error */ + } + } + +-- +2.27.0 + diff --git a/patches/0764-scsi-sd-Reorganize-DIF-DIX-code-to-avoid-calling-rev.patch b/patches/0764-scsi-sd-Reorganize-DIF-DIX-code-to-avoid-calling-rev.patch new file mode 100644 index 00000000..173a8511 --- /dev/null +++ b/patches/0764-scsi-sd-Reorganize-DIF-DIX-code-to-avoid-calling-rev.patch @@ -0,0 +1,170 @@ +From 28713504e536f1ac9e742b1e63bd0e6b5ebbfa2e Mon Sep 17 00:00:00 2001 +From: "Martin K. Petersen" +Date: Fri, 14 Apr 2023 16:20:43 +0800 +Subject: [PATCH 5/6] scsi: sd: Reorganize DIF/DIX code to avoid calling + revalidate twice + +mainline inclusion +from mainline-v5.19-rc1 +commit 1e029397d12f9085840691f4f12991a80d89888c +category: feature +bugzilla: https://gitee.com/src-openeuler/kernel/issues/I8F85N + +Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1e029397d12f9085840691f4f12991a80d89888c + +---------------------------------------------------------------------- + +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 +Signed-off-by: xiabing +Signed-off-by: YunYi Yang + + Conflicts: + drivers/scsi/sd.c +--- + drivers/scsi/sd.c | 61 +++++++++++++++++++++++-------------------- + drivers/scsi/sd_dif.c | 8 +++--- + 2 files changed, 36 insertions(+), 33 deletions(-) + +diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c +index e674565ae488..08df4779d576 100644 +--- a/drivers/scsi/sd.c ++++ b/drivers/scsi/sd.c +@@ -2212,40 +2212,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, +@@ -3197,6 +3205,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); + } + + /* +@@ -3355,10 +3364,6 @@ static void sd_probe_async(void *data, async_cookie_t cookie) + blk_pm_runtime_init(sdp->request_queue, dev); + device_add_disk(dev, gd); + blk_delete_region(disk_devt(sdkp->disk), SD_MINORS, sd_default_probe); +- if (sdkp->capacity) +- sd_dif_config_host(sdkp); +- +- sd_revalidate_disk(gd); + + if (sdkp->security) { + sdkp->opal_dev = init_opal_dev(sdp, &sd_sec_submit); +diff --git a/drivers/scsi/sd_dif.c b/drivers/scsi/sd_dif.c +index db72c82486e3..61b9f935604a 100644 +--- a/drivers/scsi/sd_dif.c ++++ b/drivers/scsi/sd_dif.c +@@ -73,8 +73,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; +@@ -86,11 +84,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); + } +-- +2.27.0 + diff --git a/patches/0765-scsi-sd-Update-DIX-config-every-time-sd_revalidate_d.patch b/patches/0765-scsi-sd-Update-DIX-config-every-time-sd_revalidate_d.patch new file mode 100644 index 00000000..b819d803 --- /dev/null +++ b/patches/0765-scsi-sd-Update-DIX-config-every-time-sd_revalidate_d.patch @@ -0,0 +1,116 @@ +From f05d2d07822ca82d21467d9226ff16be0926704b Mon Sep 17 00:00:00 2001 +From: Xingui Yang +Date: Fri, 14 Apr 2023 16:20:44 +0800 +Subject: [PATCH 6/6] scsi: sd: Update DIX config every time + sd_revalidate_disk() is called + +mainline inclusion +from mainline-v6.3-rc1 +commit 26a02d972bad946ecbaa12131736c8b6d28893f8 +category: feature +bugzilla: https://gitee.com/src-openeuler/kernel/issues/I8F85N + +Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=26a02d972bad946ecbaa12131736c8b6d28893f8 + +---------------------------------------------------------------------- + +If a controller has DIX is enabled and an attached disk is formatted using +a protection type supported by the controller, a block integrity profile is +registered to enable protected transfers. + +If the disk is subsequently reformatted to disable PI, and the controller +does not support DIX Type 0, this can lead to failures such as this: + +[142829.032340] hisi_sas_v3_hw 0000:b4:04.0: erroneous completion iptt=2375 task=00000000bea0970c dev id=5 direct-attached phy4 addr=51c20dbaf642a000 CQ hdr: 0x1023 0x50947 0x0 0x20000 Error info: 0x0 0x0 0x4 0x0 +[142829.073883] sas: Enter sas_scsi_recover_host busy: 1 failed: 1 +[142829.079783] sas: sas_scsi_find_task: aborting task 0x00000000bea0970c +[142829.102342] sas: Internal abort: task to dev 51c20dbaf642a000 response: 0x0 status 0x5 +[142829.110319] sas: sas_eh_handle_sas_errors: task 0x00000000bea0970c is done +[142829.117275] sd 7:0:5:0: [sdc] tag#2375 UNKNOWN(0x2003) Result: hostbyte=0x05 driverbyte=DRIVER_OK cmd_age=0s +[142829.127171] sd 7:0:5:0: [sdc] tag#2375 CDB: opcode=0x2a 2a 00 00 00 00 00 00 00 08 00 +[142829.135059] I/O error, dev sdc, sector 0 op 0x1:(WRITE) flags 0x18800 phys_seg 1 prio class 2 + +This is because the block layer integrity profile is currently only set up +the first time a disk is discovered. + +To address this, remove the first_scan check when configuring protection +information during revalidate. Also unregister the block integrity profile +if DIX is not supported with a given protection type. + +[mkp: commit description + printk dedup] + +Link: https://lore.kernel.org/r/20230221081026.24736-1-yangxingui@huawei.com +Signed-off-by: Xingui Yang +Signed-off-by: Martin K. Petersen +Signed-off-by: xiabing +Signed-off-by: YunYi Yang +--- + drivers/scsi/sd.c | 13 +++++-------- + drivers/scsi/sd_dif.c | 10 ++++++---- + 2 files changed, 11 insertions(+), 12 deletions(-) + +diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c +index 08df4779d576..6e0a1aacc458 100644 +--- a/drivers/scsi/sd.c ++++ b/drivers/scsi/sd.c +@@ -2237,23 +2237,20 @@ 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); ++ sd_first_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); ++ sd_first_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, +diff --git a/drivers/scsi/sd_dif.c b/drivers/scsi/sd_dif.c +index 61b9f935604a..a620e0c002aa 100644 +--- a/drivers/scsi/sd_dif.c ++++ b/drivers/scsi/sd_dif.c +@@ -53,8 +53,10 @@ void sd_dif_config_host(struct scsi_disk *sdkp) + dif = 0; dix = 1; + } + +- if (!dix) ++ if (!dix) { ++ blk_integrity_unregister(disk); + return; ++ } + + memset(&bi, 0, sizeof(bi)); + +@@ -86,9 +88,9 @@ void sd_dif_config_host(struct scsi_disk *sdkp) + bi.tag_size = sizeof(u16); + } + +- sd_printk(KERN_NOTICE, sdkp, +- "Enabling DIX %s, application tag size %u bytes\n", +- bi.profile->name, bi.tag_size); ++ sd_first_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); + } +-- +2.27.0 + diff --git a/series.conf b/series.conf index b8e15c3e..cf2b7024 100644 --- a/series.conf +++ b/series.conf @@ -760,3 +760,9 @@ patches/0756-crypto-hisilicon-Add-value-profile-support-for-kerne.patch patches/0757-Revert-genirq-Increase-the-number-of-IRQ-descriptors.patch patches/0758-arm64-cpufeature-Extract-capped-perfmon-fields.patch patches/0759-KVM-arm64-limit-PMU-version-to-PMUv3-for-ARMv8.1.patch +patches/0760-scsi-hisi_sas-Use-sas_ata_wait_after_reset-in-IT-nex.patch +patches/0761-scsi-libsas-Add-smp_ata_check_ready_type.patch +patches/0762-scsi-hisi_sas-Fix-SATA-devices-missing-issue-during-.patch +patches/0763-scsi-libsas-Update-SATA-dev-FIS-in-sas_ata_task_done.patch +patches/0764-scsi-sd-Reorganize-DIF-DIX-code-to-avoid-calling-rev.patch +patches/0765-scsi-sd-Update-DIX-config-every-time-sd_revalidate_d.patch -- Gitee