From: Greg Kroah-Hartman Date: Mon, 5 Jun 2023 15:38:08 +0000 (+0200) Subject: 5.10-stable patches X-Git-Tag: v4.14.317~74 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=86376630269b604d977a5d7f28fd378968c88b1e;p=thirdparty%2Fkernel%2Fstable-queue.git 5.10-stable patches added patches: ata-libata-scsi-use-correct-device-no-in-ata_find_dev.patch scsi-stex-fix-gcc-13-warnings.patch --- diff --git a/queue-5.10/ata-libata-scsi-use-correct-device-no-in-ata_find_dev.patch b/queue-5.10/ata-libata-scsi-use-correct-device-no-in-ata_find_dev.patch new file mode 100644 index 00000000000..39650b7032b --- /dev/null +++ b/queue-5.10/ata-libata-scsi-use-correct-device-no-in-ata_find_dev.patch @@ -0,0 +1,96 @@ +From 7f875850f20a42f488840c9df7af91ef7db2d576 Mon Sep 17 00:00:00 2001 +From: Damien Le Moal +Date: Mon, 22 May 2023 20:09:57 +0900 +Subject: ata: libata-scsi: Use correct device no in ata_find_dev() + +From: Damien Le Moal + +commit 7f875850f20a42f488840c9df7af91ef7db2d576 upstream. + +For devices not attached to a port multiplier and managed directly by +libata, the device number passed to ata_find_dev() must always be lower +than the maximum number of devices returned by ata_link_max_devices(). +That is 1 for SATA devices or 2 for an IDE link with master+slave +devices. This device number is the SCSI device ID which matches these +constraints as the IDs are generated per port and so never exceed the +maximum number of devices for the link being used. + +However, for libsas managed devices, SCSI device IDs are assigned per +struct scsi_host, leading to device IDs for SATA devices that can be +well in excess of libata per-link maximum number of devices. This +results in ata_find_dev() to always return NULL for libsas managed +devices except for the first device of the target scsi_host with ID +(device number) equal to 0. This issue is visible by executing the +hdparm utility, which fails. E.g.: + +hdparm -i /dev/sdX +/dev/sdX: + HDIO_GET_IDENTITY failed: No message of desired type + +Fix this by rewriting ata_find_dev() to ignore the device number for +non-PMP attached devices with a link with at most 1 device, that is SATA +devices. For these, the device number 0 is always used to +return the correct pointer to the struct ata_device of the port link. +This change excludes IDE master/slave setups (maximum number of devices +per link is 2) and port-multiplier attached devices. Also, to be +consistant with the fact that SCSI device IDs and channel numbers used +as device numbers are both unsigned int, change the devno argument of +ata_find_dev() to unsigned int. + +Reported-by: Xingui Yang +Fixes: 41bda9c98035 ("libata-link: update hotplug to handle PMP links") +Cc: stable@vger.kernel.org +Signed-off-by: Damien Le Moal +Reviewed-by: Jason Yan +Signed-off-by: Greg Kroah-Hartman +--- + drivers/ata/libata-scsi.c | 34 ++++++++++++++++++++++++++-------- + 1 file changed, 26 insertions(+), 8 deletions(-) + +--- a/drivers/ata/libata-scsi.c ++++ b/drivers/ata/libata-scsi.c +@@ -2742,18 +2742,36 @@ static unsigned int atapi_xlat(struct at + return 0; + } + +-static struct ata_device *ata_find_dev(struct ata_port *ap, int devno) ++static struct ata_device *ata_find_dev(struct ata_port *ap, unsigned int devno) + { +- if (!sata_pmp_attached(ap)) { +- if (likely(devno >= 0 && +- devno < ata_link_max_devices(&ap->link))) ++ /* ++ * For the non-PMP case, ata_link_max_devices() returns 1 (SATA case), ++ * or 2 (IDE master + slave case). However, the former case includes ++ * libsas hosted devices which are numbered per scsi host, leading ++ * to devno potentially being larger than 0 but with each struct ++ * ata_device having its own struct ata_port and struct ata_link. ++ * To accommodate these, ignore devno and always use device number 0. ++ */ ++ if (likely(!sata_pmp_attached(ap))) { ++ int link_max_devices = ata_link_max_devices(&ap->link); ++ ++ if (link_max_devices == 1) ++ return &ap->link.device[0]; ++ ++ if (devno < link_max_devices) + return &ap->link.device[devno]; +- } else { +- if (likely(devno >= 0 && +- devno < ap->nr_pmp_links)) +- return &ap->pmp_link[devno].device[0]; ++ ++ return NULL; + } + ++ /* ++ * For PMP-attached devices, the device number corresponds to C ++ * (channel) of SCSI [H:C:I:L], indicating the port pmp link ++ * for the device. ++ */ ++ if (devno < ap->nr_pmp_links) ++ return &ap->pmp_link[devno].device[0]; ++ + return NULL; + } + diff --git a/queue-5.10/scsi-stex-fix-gcc-13-warnings.patch b/queue-5.10/scsi-stex-fix-gcc-13-warnings.patch new file mode 100644 index 00000000000..c3f47c3d75d --- /dev/null +++ b/queue-5.10/scsi-stex-fix-gcc-13-warnings.patch @@ -0,0 +1,66 @@ +From 6d074ce231772c66e648a61f6bd2245e7129d1f5 Mon Sep 17 00:00:00 2001 +From: Bart Van Assche +Date: Mon, 29 May 2023 12:50:34 -0700 +Subject: scsi: stex: Fix gcc 13 warnings +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Bart Van Assche + +commit 6d074ce231772c66e648a61f6bd2245e7129d1f5 upstream. + +gcc 13 may assign another type to enumeration constants than gcc 12. Split +the large enum at the top of source file stex.c such that the type of the +constants used in time expressions is changed back to the same type chosen +by gcc 12. This patch suppresses compiler warnings like this one: + +In file included from ./include/linux/bitops.h:7, + from ./include/linux/kernel.h:22, + from drivers/scsi/stex.c:13: +drivers/scsi/stex.c: In function ‘stex_common_handshake’: +./include/linux/typecheck.h:12:25: error: comparison of distinct pointer types lacks a cast [-Werror] + 12 | (void)(&__dummy == &__dummy2); \ + | ^~ +./include/linux/jiffies.h:106:10: note: in expansion of macro ‘typecheck’ + 106 | typecheck(unsigned long, b) && \ + | ^~~~~~~~~ +drivers/scsi/stex.c:1035:29: note: in expansion of macro ‘time_after’ + 1035 | if (time_after(jiffies, before + MU_MAX_DELAY * HZ)) { + | ^~~~~~~~~~ + +See also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107405. + +Cc: stable@vger.kernel.org +Acked-by: Randy Dunlap +Tested-by: Randy Dunlap # build-tested +Signed-off-by: Bart Van Assche +Link: https://lore.kernel.org/r/20230529195034.3077-1-bvanassche@acm.org +Signed-off-by: Martin K. Petersen +Signed-off-by: Greg Kroah-Hartman +--- + drivers/scsi/stex.c | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/drivers/scsi/stex.c ++++ b/drivers/scsi/stex.c +@@ -109,7 +109,9 @@ enum { + TASK_ATTRIBUTE_HEADOFQUEUE = 0x1, + TASK_ATTRIBUTE_ORDERED = 0x2, + TASK_ATTRIBUTE_ACA = 0x4, ++}; + ++enum { + SS_STS_NORMAL = 0x80000000, + SS_STS_DONE = 0x40000000, + SS_STS_HANDSHAKE = 0x20000000, +@@ -121,7 +123,9 @@ enum { + SS_I2H_REQUEST_RESET = 0x2000, + + SS_MU_OPERATIONAL = 0x80000000, ++}; + ++enum { + STEX_CDB_LENGTH = 16, + STATUS_VAR_LEN = 128, + diff --git a/queue-5.10/series b/queue-5.10/series index 2af40a6fb00..89974780d4b 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -85,3 +85,5 @@ net-usb-qmi_wwan-set-dtr-quirk-for-broadmobi-bm818.patch usb-gadget-f_fs-add-unbind-event-before-functionfs_unbind.patch misc-fastrpc-return-epipe-to-invocations-on-device-removal.patch misc-fastrpc-reject-new-invocations-during-device-removal.patch +scsi-stex-fix-gcc-13-warnings.patch +ata-libata-scsi-use-correct-device-no-in-ata_find_dev.patch