--- /dev/null
+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
+@@ -3036,18 +3036,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;
+ }
+
--- /dev/null
+From 0af413bd3e2de73bcf0742ed556be4af83c71964 Mon Sep 17 00:00:00 2001
+From: Arnd Bergmann <arnd@arndb.de>
+Date: Fri, 29 May 2020 22:13:58 +0200
+Subject: flow_dissector: work around stack frame size warning
+
+From: Arnd Bergmann <arnd@arndb.de>
+
+commit 0af413bd3e2de73bcf0742ed556be4af83c71964 upstream.
+
+The fl_flow_key structure is around 500 bytes, so having two of them
+on the stack in one function now exceeds the warning limit after an
+otherwise correct change:
+
+net/sched/cls_flower.c:298:12: error: stack frame size of 1056 bytes in function 'fl_classify' [-Werror,-Wframe-larger-than=]
+
+I suspect the fl_classify function could be reworked to only have one
+of them on the stack and modify it in place, but I could not work out
+how to do that.
+
+As a somewhat hacky workaround, move one of them into an out-of-line
+function to reduce its scope. This does not necessarily reduce the stack
+usage of the outer function, but at least the second copy is removed
+from the stack during most of it and does not add up to whatever is
+called from there.
+
+I now see 552 bytes of stack usage for fl_classify(), plus 528 bytes
+for fl_mask_lookup().
+
+Fixes: 58cff782cc55 ("flow_dissector: Parse multiple MPLS Label Stack Entries")
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Acked-by: Cong Wang <xiyou.wangcong@gmail.com>
+Acked-by: Guillaume Nault <gnault@redhat.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/sched/cls_flower.c | 17 ++++++++---------
+ 1 file changed, 8 insertions(+), 9 deletions(-)
+
+--- a/net/sched/cls_flower.c
++++ b/net/sched/cls_flower.c
+@@ -270,14 +270,16 @@ static struct cls_fl_filter *fl_lookup_r
+ return NULL;
+ }
+
+-static struct cls_fl_filter *fl_lookup(struct fl_flow_mask *mask,
+- struct fl_flow_key *mkey,
+- struct fl_flow_key *key)
++static noinline_for_stack
++struct cls_fl_filter *fl_mask_lookup(struct fl_flow_mask *mask, struct fl_flow_key *key)
+ {
++ struct fl_flow_key mkey;
++
++ fl_set_masked_key(&mkey, key, mask);
+ if ((mask->flags & TCA_FLOWER_MASK_FLAGS_RANGE))
+- return fl_lookup_range(mask, mkey, key);
++ return fl_lookup_range(mask, &mkey, key);
+
+- return __fl_lookup(mask, mkey);
++ return __fl_lookup(mask, &mkey);
+ }
+
+ static u16 fl_ct_info_to_flower_map[] = {
+@@ -297,7 +299,6 @@ static int fl_classify(struct sk_buff *s
+ struct tcf_result *res)
+ {
+ struct cls_fl_head *head = rcu_dereference_bh(tp->root);
+- struct fl_flow_key skb_mkey;
+ struct fl_flow_key skb_key;
+ struct fl_flow_mask *mask;
+ struct cls_fl_filter *f;
+@@ -317,9 +318,7 @@ static int fl_classify(struct sk_buff *s
+ ARRAY_SIZE(fl_ct_info_to_flower_map));
+ skb_flow_dissect(skb, &mask->dissector, &skb_key, 0);
+
+- fl_set_masked_key(&skb_mkey, &skb_key, mask);
+-
+- f = fl_lookup(mask, &skb_mkey, &skb_key);
++ f = fl_mask_lookup(mask, &skb_key);
+ if (f && !tc_skip_sw(f->flags)) {
+ *res = f->res;
+ return tcf_exts_exec(skb, &f->exts, res);
--- /dev/null
+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
+@@ -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,
+
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
+flow_dissector-work-around-stack-frame-size-warning.patch