]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.15-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 27 Mar 2023 17:02:18 +0000 (19:02 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 27 Mar 2023 17:02:18 +0000 (19:02 +0200)
added patches:
thunderbolt-add-missing-unset_inbound_sbtx-for-retimer-access.patch
thunderbolt-call-tb_check_quirks-after-initializing-adapters.patch
thunderbolt-disable-interrupt-auto-clear-for-rings.patch
thunderbolt-rename-shadowed-variables-bit-to-interrupt_bit-and-auto_clear_bit.patch
thunderbolt-use-const-qualifier-for-ring_interrupt_index.patch
thunderbolt-use-scale-field-when-allocating-usb3-bandwidth.patch
uas-add-us_fl_no_report_opcodes-for-jmicron-jms583gen-2.patch

queue-5.15/series
queue-5.15/thunderbolt-add-missing-unset_inbound_sbtx-for-retimer-access.patch [new file with mode: 0644]
queue-5.15/thunderbolt-call-tb_check_quirks-after-initializing-adapters.patch [new file with mode: 0644]
queue-5.15/thunderbolt-disable-interrupt-auto-clear-for-rings.patch [new file with mode: 0644]
queue-5.15/thunderbolt-rename-shadowed-variables-bit-to-interrupt_bit-and-auto_clear_bit.patch [new file with mode: 0644]
queue-5.15/thunderbolt-use-const-qualifier-for-ring_interrupt_index.patch [new file with mode: 0644]
queue-5.15/thunderbolt-use-scale-field-when-allocating-usb3-bandwidth.patch [new file with mode: 0644]
queue-5.15/uas-add-us_fl_no_report_opcodes-for-jmicron-jms583gen-2.patch [new file with mode: 0644]

index e8e3b3a746ed6ce99a9fdb863d63c6792a810052..e612290d87559510ebf40d1e18b75c48c2962833 100644 (file)
@@ -74,3 +74,10 @@ hwmon-fix-potential-sensor-registration-fail-if-of_n.patch
 hwmon-it87-fix-voltage-scaling-for-chips-with-10.9mv.patch
 scsi-qla2xxx-synchronize-the-iocb-count-to-be-in-order.patch
 scsi-qla2xxx-perform-lockless-command-completion-in-abort-path.patch
+uas-add-us_fl_no_report_opcodes-for-jmicron-jms583gen-2.patch
+thunderbolt-use-scale-field-when-allocating-usb3-bandwidth.patch
+thunderbolt-call-tb_check_quirks-after-initializing-adapters.patch
+thunderbolt-disable-interrupt-auto-clear-for-rings.patch
+thunderbolt-add-missing-unset_inbound_sbtx-for-retimer-access.patch
+thunderbolt-use-const-qualifier-for-ring_interrupt_index.patch
+thunderbolt-rename-shadowed-variables-bit-to-interrupt_bit-and-auto_clear_bit.patch
diff --git a/queue-5.15/thunderbolt-add-missing-unset_inbound_sbtx-for-retimer-access.patch b/queue-5.15/thunderbolt-add-missing-unset_inbound_sbtx-for-retimer-access.patch
new file mode 100644 (file)
index 0000000..1829d59
--- /dev/null
@@ -0,0 +1,140 @@
+From cd0c1e582b055dea615001b8bd8eccaf6f69f7ce Mon Sep 17 00:00:00 2001
+From: Gil Fine <gil.fine@linux.intel.com>
+Date: Fri, 3 Mar 2023 00:17:24 +0200
+Subject: thunderbolt: Add missing UNSET_INBOUND_SBTX for retimer access
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Gil Fine <gil.fine@linux.intel.com>
+
+commit cd0c1e582b055dea615001b8bd8eccaf6f69f7ce upstream.
+
+According to USB4 retimer specification, the process of firmware update
+sequence requires issuing a SET_INBOUND_SBTX port operation that later
+shall be followed by UNSET_INBOUND_SBTX port operation. This last step
+is not currently issued by the driver but it is necessary to make sure
+the retimers are put back to passthrough mode even during enumeration.
+
+If this step is missing the link may not come up properly after
+soft-reboot for example.
+
+For this reason issue UNSET_INBOUND_SBTX after SET_INBOUND_SBTX for
+enumeration and also when the NVM upgrade is run.
+
+Reported-by: Christian Schaubschläger <christian.schaubschlaeger@gmx.at>
+Link: https://lore.kernel.org/linux-usb/b556f5ed-5ee8-9990-9910-afd60db93310@gmx.at/
+Cc: stable@vger.kernel.org
+Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
+Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/thunderbolt/retimer.c |   23 +++++++++++++++++++++--
+ drivers/thunderbolt/sb_regs.h |    1 +
+ drivers/thunderbolt/tb.h      |    1 +
+ drivers/thunderbolt/usb4.c    |   14 ++++++++++++++
+ 4 files changed, 37 insertions(+), 2 deletions(-)
+
+--- a/drivers/thunderbolt/retimer.c
++++ b/drivers/thunderbolt/retimer.c
+@@ -208,6 +208,22 @@ static ssize_t nvm_authenticate_show(str
+       return ret;
+ }
++static void tb_retimer_set_inbound_sbtx(struct tb_port *port)
++{
++      int i;
++
++      for (i = 1; i <= TB_MAX_RETIMER_INDEX; i++)
++              usb4_port_retimer_set_inbound_sbtx(port, i);
++}
++
++static void tb_retimer_unset_inbound_sbtx(struct tb_port *port)
++{
++      int i;
++
++      for (i = TB_MAX_RETIMER_INDEX; i >= 1; i--)
++              usb4_port_retimer_unset_inbound_sbtx(port, i);
++}
++
+ static ssize_t nvm_authenticate_store(struct device *dev,
+       struct device_attribute *attr, const char *buf, size_t count)
+ {
+@@ -234,6 +250,7 @@ static ssize_t nvm_authenticate_store(st
+       rt->auth_status = 0;
+       if (val) {
++              tb_retimer_set_inbound_sbtx(rt->port);
+               if (val == AUTHENTICATE_ONLY) {
+                       ret = tb_retimer_nvm_authenticate(rt, true);
+               } else {
+@@ -253,6 +270,7 @@ static ssize_t nvm_authenticate_store(st
+       }
+ exit_unlock:
++      tb_retimer_unset_inbound_sbtx(rt->port);
+       mutex_unlock(&rt->tb->lock);
+ exit_rpm:
+       pm_runtime_mark_last_busy(&rt->dev);
+@@ -466,8 +484,7 @@ int tb_retimer_scan(struct tb_port *port
+        * Enable sideband channel for each retimer. We can do this
+        * regardless whether there is device connected or not.
+        */
+-      for (i = 1; i <= TB_MAX_RETIMER_INDEX; i++)
+-              usb4_port_retimer_set_inbound_sbtx(port, i);
++      tb_retimer_set_inbound_sbtx(port);
+       /*
+        * Before doing anything else, read the authentication status.
+@@ -490,6 +507,8 @@ int tb_retimer_scan(struct tb_port *port
+                       break;
+       }
++      tb_retimer_unset_inbound_sbtx(port);
++
+       if (!last_idx)
+               return 0;
+--- a/drivers/thunderbolt/sb_regs.h
++++ b/drivers/thunderbolt/sb_regs.h
+@@ -20,6 +20,7 @@ enum usb4_sb_opcode {
+       USB4_SB_OPCODE_ROUTER_OFFLINE = 0x4e45534c,             /* "LSEN" */
+       USB4_SB_OPCODE_ENUMERATE_RETIMERS = 0x4d554e45,         /* "ENUM" */
+       USB4_SB_OPCODE_SET_INBOUND_SBTX = 0x5055534c,           /* "LSUP" */
++      USB4_SB_OPCODE_UNSET_INBOUND_SBTX = 0x50555355,         /* "USUP" */
+       USB4_SB_OPCODE_QUERY_LAST_RETIMER = 0x5453414c,         /* "LAST" */
+       USB4_SB_OPCODE_GET_NVM_SECTOR_SIZE = 0x53534e47,        /* "GNSS" */
+       USB4_SB_OPCODE_NVM_SET_OFFSET = 0x53504f42,             /* "BOPS" */
+--- a/drivers/thunderbolt/tb.h
++++ b/drivers/thunderbolt/tb.h
+@@ -1080,6 +1080,7 @@ int usb4_port_router_online(struct tb_po
+ int usb4_port_enumerate_retimers(struct tb_port *port);
+ int usb4_port_retimer_set_inbound_sbtx(struct tb_port *port, u8 index);
++int usb4_port_retimer_unset_inbound_sbtx(struct tb_port *port, u8 index);
+ int usb4_port_retimer_read(struct tb_port *port, u8 index, u8 reg, void *buf,
+                          u8 size);
+ int usb4_port_retimer_write(struct tb_port *port, u8 index, u8 reg,
+--- a/drivers/thunderbolt/usb4.c
++++ b/drivers/thunderbolt/usb4.c
+@@ -1442,6 +1442,20 @@ int usb4_port_retimer_set_inbound_sbtx(s
+ }
+ /**
++ * usb4_port_retimer_unset_inbound_sbtx() - Disable sideband channel transactions
++ * @port: USB4 port
++ * @index: Retimer index
++ *
++ * Disables sideband channel transations on SBTX. The reverse of
++ * usb4_port_retimer_set_inbound_sbtx().
++ */
++int usb4_port_retimer_unset_inbound_sbtx(struct tb_port *port, u8 index)
++{
++      return usb4_port_retimer_op(port, index,
++                                  USB4_SB_OPCODE_UNSET_INBOUND_SBTX, 500);
++}
++
++/**
+  * usb4_port_retimer_read() - Read from retimer sideband registers
+  * @port: USB4 port
+  * @index: Retimer index
diff --git a/queue-5.15/thunderbolt-call-tb_check_quirks-after-initializing-adapters.patch b/queue-5.15/thunderbolt-call-tb_check_quirks-after-initializing-adapters.patch
new file mode 100644 (file)
index 0000000..501cce3
--- /dev/null
@@ -0,0 +1,40 @@
+From d2d6ddf188f609861489d5d188d545856a3ed399 Mon Sep 17 00:00:00 2001
+From: Mika Westerberg <mika.westerberg@linux.intel.com>
+Date: Fri, 3 Feb 2023 15:55:41 +0200
+Subject: thunderbolt: Call tb_check_quirks() after initializing adapters
+
+From: Mika Westerberg <mika.westerberg@linux.intel.com>
+
+commit d2d6ddf188f609861489d5d188d545856a3ed399 upstream.
+
+In order to apply quirks based on certain adapter types move call to
+tb_check_quirks() happen after the adapters are initialized. This should
+not affect the existing quirks.
+
+Cc: stable@vger.kernel.org
+Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/thunderbolt/switch.c |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/thunderbolt/switch.c
++++ b/drivers/thunderbolt/switch.c
+@@ -2750,8 +2750,6 @@ int tb_switch_add(struct tb_switch *sw)
+               }
+               tb_sw_dbg(sw, "uid: %#llx\n", sw->uid);
+-              tb_check_quirks(sw);
+-
+               ret = tb_switch_set_uuid(sw);
+               if (ret) {
+                       dev_err(&sw->dev, "failed to set UUID\n");
+@@ -2770,6 +2768,8 @@ int tb_switch_add(struct tb_switch *sw)
+                       }
+               }
++              tb_check_quirks(sw);
++
+               tb_switch_default_link_ports(sw);
+               ret = tb_switch_update_link_attributes(sw);
diff --git a/queue-5.15/thunderbolt-disable-interrupt-auto-clear-for-rings.patch b/queue-5.15/thunderbolt-disable-interrupt-auto-clear-for-rings.patch
new file mode 100644 (file)
index 0000000..2da8bbc
--- /dev/null
@@ -0,0 +1,125 @@
+From 468c49f44759720a312e52d44a71c3949ed63d7c Mon Sep 17 00:00:00 2001
+From: Mario Limonciello <mario.limonciello@amd.com>
+Date: Fri, 10 Mar 2023 11:20:50 -0600
+Subject: thunderbolt: Disable interrupt auto clear for rings
+
+From: Mario Limonciello <mario.limonciello@amd.com>
+
+commit 468c49f44759720a312e52d44a71c3949ed63d7c upstream.
+
+When interrupt auto clear is programmed, any read to the interrupt
+status register will clear all interrupts.  If two interrupts have
+come in before one can be serviced then this will cause lost interrupts.
+
+On AMD USB4 routers this has manifested in odd problems particularly
+with long strings of control tranfers such as reading the DROM via bit
+banging.
+
+Instead of clearing interrupts automatically, clear the bit corresponding
+to the given ring's interrupt in the ISR.
+
+Fixes: 7a1808f82a37 ("thunderbolt: Handle ring interrupt by reading interrupt status register")
+Cc: Sanju Mehta <Sanju.Mehta@amd.com>
+Cc: stable@vger.kernel.org
+Tested-by: Anson Tsao <anson.tsao@amd.com>
+Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
+Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/thunderbolt/nhi.c      |   40 +++++++++++++++++++++++++---------------
+ drivers/thunderbolt/nhi_regs.h |    6 ++++--
+ 2 files changed, 29 insertions(+), 17 deletions(-)
+
+--- a/drivers/thunderbolt/nhi.c
++++ b/drivers/thunderbolt/nhi.c
+@@ -68,24 +68,31 @@ static void ring_interrupt_active(struct
+               u32 step, shift, ivr, misc;
+               void __iomem *ivr_base;
+               int index;
++              int bit;
+               if (ring->is_tx)
+                       index = ring->hop;
+               else
+                       index = ring->hop + ring->nhi->hop_count;
+-              if (ring->nhi->quirks & QUIRK_AUTO_CLEAR_INT) {
+-                      /*
+-                       * Ask the hardware to clear interrupt status
+-                       * bits automatically since we already know
+-                       * which interrupt was triggered.
+-                       */
+-                      misc = ioread32(ring->nhi->iobase + REG_DMA_MISC);
+-                      if (!(misc & REG_DMA_MISC_INT_AUTO_CLEAR)) {
+-                              misc |= REG_DMA_MISC_INT_AUTO_CLEAR;
+-                              iowrite32(misc, ring->nhi->iobase + REG_DMA_MISC);
+-                      }
+-              }
++              /*
++               * Intel routers support a bit that isn't part of
++               * the USB4 spec to ask the hardware to clear
++               * interrupt status bits automatically since
++               * we already know which interrupt was triggered.
++               *
++               * Other routers explicitly disable auto-clear
++               * to prevent conditions that may occur where two
++               * MSIX interrupts are simultaneously active and
++               * reading the register clears both of them.
++               */
++              misc = ioread32(ring->nhi->iobase + REG_DMA_MISC);
++              if (ring->nhi->quirks & QUIRK_AUTO_CLEAR_INT)
++                      bit = REG_DMA_MISC_INT_AUTO_CLEAR;
++              else
++                      bit = REG_DMA_MISC_DISABLE_AUTO_CLEAR;
++              if (!(misc & bit))
++                      iowrite32(misc | bit, ring->nhi->iobase + REG_DMA_MISC);
+               ivr_base = ring->nhi->iobase + REG_INT_VEC_ALLOC_BASE;
+               step = index / REG_INT_VEC_ALLOC_REGS * REG_INT_VEC_ALLOC_BITS;
+@@ -390,14 +397,17 @@ EXPORT_SYMBOL_GPL(tb_ring_poll_complete)
+ static void ring_clear_msix(const struct tb_ring *ring)
+ {
++      int bit;
++
+       if (ring->nhi->quirks & QUIRK_AUTO_CLEAR_INT)
+               return;
++      bit = ring_interrupt_index(ring) & 31;
+       if (ring->is_tx)
+-              ioread32(ring->nhi->iobase + REG_RING_NOTIFY_BASE);
++              iowrite32(BIT(bit), ring->nhi->iobase + REG_RING_INT_CLEAR);
+       else
+-              ioread32(ring->nhi->iobase + REG_RING_NOTIFY_BASE +
+-                       4 * (ring->nhi->hop_count / 32));
++              iowrite32(BIT(bit), ring->nhi->iobase + REG_RING_INT_CLEAR +
++                        4 * (ring->nhi->hop_count / 32));
+ }
+ static irqreturn_t ring_msix(int irq, void *data)
+--- a/drivers/thunderbolt/nhi_regs.h
++++ b/drivers/thunderbolt/nhi_regs.h
+@@ -77,12 +77,13 @@ struct ring_desc {
+ /*
+  * three bitfields: tx, rx, rx overflow
+- * Every bitfield contains one bit for every hop (REG_HOP_COUNT). Registers are
+- * cleared on read. New interrupts are fired only after ALL registers have been
++ * Every bitfield contains one bit for every hop (REG_HOP_COUNT).
++ * New interrupts are fired only after ALL registers have been
+  * read (even those containing only disabled rings).
+  */
+ #define REG_RING_NOTIFY_BASE  0x37800
+ #define RING_NOTIFY_REG_COUNT(nhi) ((31 + 3 * nhi->hop_count) / 32)
++#define REG_RING_INT_CLEAR    0x37808
+ /*
+  * two bitfields: rx, tx
+@@ -105,6 +106,7 @@ struct ring_desc {
+ #define REG_DMA_MISC                  0x39864
+ #define REG_DMA_MISC_INT_AUTO_CLEAR     BIT(2)
++#define REG_DMA_MISC_DISABLE_AUTO_CLEAR       BIT(17)
+ #define REG_INMAIL_DATA                       0x39900
diff --git a/queue-5.15/thunderbolt-rename-shadowed-variables-bit-to-interrupt_bit-and-auto_clear_bit.patch b/queue-5.15/thunderbolt-rename-shadowed-variables-bit-to-interrupt_bit-and-auto_clear_bit.patch
new file mode 100644 (file)
index 0000000..70cdecf
--- /dev/null
@@ -0,0 +1,78 @@
+From 58cdfe6f58b35f17f56386f5fcf937168a423ad1 Mon Sep 17 00:00:00 2001
+From: Tom Rix <trix@redhat.com>
+Date: Wed, 15 Mar 2023 18:04:50 -0400
+Subject: thunderbolt: Rename shadowed variables bit to interrupt_bit and auto_clear_bit
+
+From: Tom Rix <trix@redhat.com>
+
+commit 58cdfe6f58b35f17f56386f5fcf937168a423ad1 upstream.
+
+cppcheck reports
+drivers/thunderbolt/nhi.c:74:7: style: Local variable 'bit' shadows outer variable [shadowVariable]
+  int bit;
+      ^
+drivers/thunderbolt/nhi.c:66:6: note: Shadowed declaration
+ int bit = ring_interrupt_index(ring) & 31;
+     ^
+drivers/thunderbolt/nhi.c:74:7: note: Shadow variable
+  int bit;
+      ^
+For readablity rename the outer to interrupt_bit and the innner
+to auto_clear_bit.
+
+Fixes: 468c49f44759 ("thunderbolt: Disable interrupt auto clear for ring")
+Cc: stable@vger.kernel.org
+Signed-off-by: Tom Rix <trix@redhat.com>
+Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/thunderbolt/nhi.c |   17 +++++++++--------
+ 1 file changed, 9 insertions(+), 8 deletions(-)
+
+--- a/drivers/thunderbolt/nhi.c
++++ b/drivers/thunderbolt/nhi.c
+@@ -60,15 +60,15 @@ static void ring_interrupt_active(struct
+ {
+       int reg = REG_RING_INTERRUPT_BASE +
+                 ring_interrupt_index(ring) / 32 * 4;
+-      int bit = ring_interrupt_index(ring) & 31;
+-      int mask = 1 << bit;
++      int interrupt_bit = ring_interrupt_index(ring) & 31;
++      int mask = 1 << interrupt_bit;
+       u32 old, new;
+       if (ring->irq > 0) {
+               u32 step, shift, ivr, misc;
+               void __iomem *ivr_base;
++              int auto_clear_bit;
+               int index;
+-              int bit;
+               if (ring->is_tx)
+                       index = ring->hop;
+@@ -88,11 +88,12 @@ static void ring_interrupt_active(struct
+                */
+               misc = ioread32(ring->nhi->iobase + REG_DMA_MISC);
+               if (ring->nhi->quirks & QUIRK_AUTO_CLEAR_INT)
+-                      bit = REG_DMA_MISC_INT_AUTO_CLEAR;
++                      auto_clear_bit = REG_DMA_MISC_INT_AUTO_CLEAR;
+               else
+-                      bit = REG_DMA_MISC_DISABLE_AUTO_CLEAR;
+-              if (!(misc & bit))
+-                      iowrite32(misc | bit, ring->nhi->iobase + REG_DMA_MISC);
++                      auto_clear_bit = REG_DMA_MISC_DISABLE_AUTO_CLEAR;
++              if (!(misc & auto_clear_bit))
++                      iowrite32(misc | auto_clear_bit,
++                                ring->nhi->iobase + REG_DMA_MISC);
+               ivr_base = ring->nhi->iobase + REG_INT_VEC_ALLOC_BASE;
+               step = index / REG_INT_VEC_ALLOC_REGS * REG_INT_VEC_ALLOC_BITS;
+@@ -112,7 +113,7 @@ static void ring_interrupt_active(struct
+       dev_dbg(&ring->nhi->pdev->dev,
+               "%s interrupt at register %#x bit %d (%#x -> %#x)\n",
+-              active ? "enabling" : "disabling", reg, bit, old, new);
++              active ? "enabling" : "disabling", reg, interrupt_bit, old, new);
+       if (new == old)
+               dev_WARN(&ring->nhi->pdev->dev,
diff --git a/queue-5.15/thunderbolt-use-const-qualifier-for-ring_interrupt_index.patch b/queue-5.15/thunderbolt-use-const-qualifier-for-ring_interrupt_index.patch
new file mode 100644 (file)
index 0000000..442e20d
--- /dev/null
@@ -0,0 +1,33 @@
+From 1716efdb07938bd6510e1127d02012799112c433 Mon Sep 17 00:00:00 2001
+From: Mario Limonciello <mario.limonciello@amd.com>
+Date: Fri, 10 Mar 2023 11:20:49 -0600
+Subject: thunderbolt: Use const qualifier for `ring_interrupt_index`
+
+From: Mario Limonciello <mario.limonciello@amd.com>
+
+commit 1716efdb07938bd6510e1127d02012799112c433 upstream.
+
+`ring_interrupt_index` doesn't change the data for `ring` so mark it as
+const. This is needed by the following patch that disables interrupt
+auto clear for rings.
+
+Cc: Sanju Mehta <Sanju.Mehta@amd.com>
+Cc: stable@vger.kernel.org
+Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
+Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/thunderbolt/nhi.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/thunderbolt/nhi.c
++++ b/drivers/thunderbolt/nhi.c
+@@ -43,7 +43,7 @@
+ #define QUIRK_AUTO_CLEAR_INT  BIT(0)
+ #define QUIRK_E2E             BIT(1)
+-static int ring_interrupt_index(struct tb_ring *ring)
++static int ring_interrupt_index(const struct tb_ring *ring)
+ {
+       int bit = ring->hop;
+       if (!ring->is_tx)
diff --git a/queue-5.15/thunderbolt-use-scale-field-when-allocating-usb3-bandwidth.patch b/queue-5.15/thunderbolt-use-scale-field-when-allocating-usb3-bandwidth.patch
new file mode 100644 (file)
index 0000000..d6f64c5
--- /dev/null
@@ -0,0 +1,60 @@
+From c82510b1d87bdebfe916048857d2ef46f1778aa5 Mon Sep 17 00:00:00 2001
+From: Mika Westerberg <mika.westerberg@linux.intel.com>
+Date: Tue, 27 Dec 2022 11:55:26 +0200
+Subject: thunderbolt: Use scale field when allocating USB3 bandwidth
+
+From: Mika Westerberg <mika.westerberg@linux.intel.com>
+
+commit c82510b1d87bdebfe916048857d2ef46f1778aa5 upstream.
+
+When tunneling aggregated USB3 (20 Gb/s) the bandwidth values that are
+programmed to the ADP_USB3_CS_2 go higher than 4096 and that does not
+fit anymore to the 12-bit field. Fix this by scaling the value using
+the scale field accordingly.
+
+Fixes: 3b1d8d577ca8 ("thunderbolt: Implement USB3 bandwidth negotiation routines")
+Cc: stable@vger.kernel.org
+Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/thunderbolt/usb4.c |   22 +++++++++++++++++-----
+ 1 file changed, 17 insertions(+), 5 deletions(-)
+
+--- a/drivers/thunderbolt/usb4.c
++++ b/drivers/thunderbolt/usb4.c
+@@ -1930,18 +1930,30 @@ static int usb4_usb3_port_write_allocate
+                                                   int downstream_bw)
+ {
+       u32 val, ubw, dbw, scale;
+-      int ret;
++      int ret, max_bw;
+-      /* Read the used scale, hardware default is 0 */
+-      ret = tb_port_read(port, &scale, TB_CFG_PORT,
+-                         port->cap_adap + ADP_USB3_CS_3, 1);
++      /* Figure out suitable scale */
++      scale = 0;
++      max_bw = max(upstream_bw, downstream_bw);
++      while (scale < 64) {
++              if (mbps_to_usb3_bw(max_bw, scale) < 4096)
++                      break;
++              scale++;
++      }
++
++      if (WARN_ON(scale >= 64))
++              return -EINVAL;
++
++      ret = tb_port_write(port, &scale, TB_CFG_PORT,
++                          port->cap_adap + ADP_USB3_CS_3, 1);
+       if (ret)
+               return ret;
+-      scale &= ADP_USB3_CS_3_SCALE_MASK;
+       ubw = mbps_to_usb3_bw(upstream_bw, scale);
+       dbw = mbps_to_usb3_bw(downstream_bw, scale);
++      tb_port_dbg(port, "scaled bandwidth %u/%u, scale %u\n", ubw, dbw, scale);
++
+       ret = tb_port_read(port, &val, TB_CFG_PORT,
+                          port->cap_adap + ADP_USB3_CS_2, 1);
+       if (ret)
diff --git a/queue-5.15/uas-add-us_fl_no_report_opcodes-for-jmicron-jms583gen-2.patch b/queue-5.15/uas-add-us_fl_no_report_opcodes-for-jmicron-jms583gen-2.patch
new file mode 100644 (file)
index 0000000..72b55ea
--- /dev/null
@@ -0,0 +1,36 @@
+From a37eb61b6ec064ac794b8a1e89fd33eb582fe51d Mon Sep 17 00:00:00 2001
+From: Yaroslav Furman <yaro330@gmail.com>
+Date: Sun, 12 Mar 2023 11:07:45 +0200
+Subject: uas: Add US_FL_NO_REPORT_OPCODES for JMicron JMS583Gen 2
+
+From: Yaroslav Furman <yaro330@gmail.com>
+
+commit a37eb61b6ec064ac794b8a1e89fd33eb582fe51d upstream.
+
+Just like other JMicron JMS5xx enclosures, it chokes on report-opcodes,
+let's avoid them.
+
+Signed-off-by: Yaroslav Furman <yaro330@gmail.com>
+Cc: stable <stable@kernel.org>
+Link: https://lore.kernel.org/r/20230312090745.47962-1-yaro330@gmail.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/usb/storage/unusual_uas.h |    7 +++++++
+ 1 file changed, 7 insertions(+)
+
+--- a/drivers/usb/storage/unusual_uas.h
++++ b/drivers/usb/storage/unusual_uas.h
+@@ -111,6 +111,13 @@ UNUSUAL_DEV(0x152d, 0x0578, 0x0000, 0x99
+               USB_SC_DEVICE, USB_PR_DEVICE, NULL,
+               US_FL_BROKEN_FUA),
++/* Reported by: Yaroslav Furman <yaro330@gmail.com> */
++UNUSUAL_DEV(0x152d, 0x0583, 0x0000, 0x9999,
++              "JMicron",
++              "JMS583Gen 2",
++              USB_SC_DEVICE, USB_PR_DEVICE, NULL,
++              US_FL_NO_REPORT_OPCODES),
++
+ /* Reported-by: Thinh Nguyen <thinhn@synopsys.com> */
+ UNUSUAL_DEV(0x154b, 0xf00b, 0x0000, 0x9999,
+               "PNY",