]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.14-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 5 Jun 2023 15:37:36 +0000 (17:37 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 5 Jun 2023 15:37:36 +0000 (17:37 +0200)
added patches:
ata-libata-scsi-use-correct-device-no-in-ata_find_dev.patch
scsi-stex-fix-gcc-13-warnings.patch

queue-4.14/ata-libata-scsi-use-correct-device-no-in-ata_find_dev.patch [new file with mode: 0644]
queue-4.14/scsi-stex-fix-gcc-13-warnings.patch [new file with mode: 0644]
queue-4.14/series

diff --git a/queue-4.14/ata-libata-scsi-use-correct-device-no-in-ata_find_dev.patch b/queue-4.14/ata-libata-scsi-use-correct-device-no-in-ata_find_dev.patch
new file mode 100644 (file)
index 0000000..18d1d79
--- /dev/null
@@ -0,0 +1,96 @@
+From 7f875850f20a42f488840c9df7af91ef7db2d576 Mon Sep 17 00:00:00 2001
+From: Damien Le Moal <dlemoal@kernel.org>
+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 <dlemoal@kernel.org>
+
+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 <yangxingui@huawei.com>
+Fixes: 41bda9c98035 ("libata-link: update hotplug to handle PMP links")
+Cc: stable@vger.kernel.org
+Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
+Reviewed-by: Jason Yan <yanaijie@huawei.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ 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
+@@ -3054,18 +3054,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-4.14/scsi-stex-fix-gcc-13-warnings.patch b/queue-4.14/scsi-stex-fix-gcc-13-warnings.patch
new file mode 100644 (file)
index 0000000..d096f3e
--- /dev/null
@@ -0,0 +1,66 @@
+From 6d074ce231772c66e648a61f6bd2245e7129d1f5 Mon Sep 17 00:00:00 2001
+From: Bart Van Assche <bvanassche@acm.org>
+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 <bvanassche@acm.org>
+
+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 <rdunlap@infradead.org>
+Tested-by: Randy Dunlap <rdunlap@infradead.org> # build-tested
+Signed-off-by: Bart Van Assche <bvanassche@acm.org>
+Link: https://lore.kernel.org/r/20230529195034.3077-1-bvanassche@acm.org
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/scsi/stex.c |    4 ++++
+ 1 file changed, 4 insertions(+)
+
+--- a/drivers/scsi/stex.c
++++ b/drivers/scsi/stex.c
+@@ -114,7 +114,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,
+@@ -126,7 +128,9 @@ enum {
+       SS_I2H_REQUEST_RESET                    = 0x2000,
+       SS_MU_OPERATIONAL                       = 0x80000000,
++};
++enum {
+       STEX_CDB_LENGTH                         = 16,
+       STATUS_VAR_LEN                          = 128,
index d961db2492d6003c87c93a4e72b3fd1c3e26a6c4..7b11ef562515385881a8f2f50d030e128adbdf2a 100644 (file)
@@ -37,3 +37,5 @@ hid-wacom-avoid-integer-overflow-in-wacom_intuos_inout.patch
 iio-dac-mcp4725-fix-i2c_master_send-return-value-handling.patch
 net-usb-qmi_wwan-set-dtr-quirk-for-broadmobi-bm818.patch
 usb-gadget-f_fs-add-unbind-event-before-functionfs_unbind.patch
+scsi-stex-fix-gcc-13-warnings.patch
+ata-libata-scsi-use-correct-device-no-in-ata_find_dev.patch