]> Git Repo - J-linux.git/commitdiff
Merge tag 'thunderbolt-for-v6.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel...
authorGreg Kroah-Hartman <[email protected]>
Fri, 10 May 2024 09:25:22 +0000 (10:25 +0100)
committerGreg Kroah-Hartman <[email protected]>
Fri, 10 May 2024 09:25:22 +0000 (10:25 +0100)
Mika writes:

thunderbolt: Changes for v6.10 merge window

This includes following USB4/Thunderbolt changes for the v6.10 merge
window:

  - Enable NVM firmare upgrade on Intel Maple Ridge Thunderbolt 4
    controller
  - Improve USB3 tunnel bandwidth calculation
  - Improve sideband access
  - Minor cleanups and fixes.

All these have been in linux-next with no reported issues.

* tag 'thunderbolt-for-v6.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt:
  thunderbolt: Correct trace output of firmware connection manager packets
  thunderbolt: Fix kernel-doc for tb_tunnel_alloc_dp()
  thunderbolt: Fix uninitialized variable in tb_tunnel_alloc_usb3()
  thunderbolt: There are only 5 basic router registers in pre-USB4 routers
  thunderbolt: No need to loop over all retimers if access fails
  thunderbolt: Increase sideband access polling delay
  thunderbolt: Get rid of TB_CFG_PKG_PREPARE_TO_SLEEP
  thunderbolt: Use correct error code with ERROR_NOT_SUPPORTED
  thunderbolt: Allow USB3 bandwidth to be lower than maximum supported
  thunderbolt: Fix calculation of consumed USB3 bandwidth on a path
  thunderbolt: Enable NVM upgrade support on Intel Maple Ridge

1  2 
drivers/thunderbolt/tb.c
drivers/thunderbolt/usb4.c

diff --combined drivers/thunderbolt/tb.c
index 3e44c78ac40929289bb745584a232ca1913ad3ab,ec8c4ef5e3ba8b2411dc481c2f804df892b739a7..10e719dd837cec7646f49b37af739016559cbc02
@@@ -498,8 -498,9 +498,9 @@@ static struct tb_tunnel *tb_find_first_
   * @consumed_down: Consumed downstream bandwidth (Mb/s)
   *
   * Calculates consumed USB3 and PCIe bandwidth at @port between path
-  * from @src_port to @dst_port. Does not take tunnel starting from
-  * @src_port and ending from @src_port into account.
+  * from @src_port to @dst_port. Does not take USB3 tunnel starting from
+  * @src_port and ending on @src_port into account because that bandwidth is
+  * already included in as part of the "first hop" USB3 tunnel.
   */
  static int tb_consumed_usb3_pcie_bandwidth(struct tb *tb,
                                           struct tb_port *src_port,
        *consumed_up = *consumed_down = 0;
  
        tunnel = tb_find_first_usb3_tunnel(tb, src_port, dst_port);
-       if (tunnel && tunnel->src_port != src_port &&
-           tunnel->dst_port != dst_port) {
+       if (tunnel && !tb_port_is_usb3_down(src_port) &&
+           !tb_port_is_usb3_up(dst_port)) {
                int ret;
  
                ret = tb_tunnel_consumed_bandwidth(tunnel, consumed_up,
@@@ -1801,12 -1802,6 +1802,12 @@@ static struct tb_port *tb_find_dp_out(s
                        continue;
                }
  
 +              /* Needs to be on different routers */
 +              if (in->sw == port->sw) {
 +                      tb_port_dbg(port, "skipping DP OUT on same router\n");
 +                      continue;
 +              }
 +
                tb_port_dbg(port, "DP OUT available\n");
  
                /*
@@@ -2942,7 -2937,7 +2943,7 @@@ static int tb_resume_noirq(struct tb *t
        if (!tb_switch_is_usb4(tb->root_switch))
                tb_switch_reset(tb->root_switch);
  
 -      tb_switch_resume(tb->root_switch);
 +      tb_switch_resume(tb->root_switch, false);
        tb_free_invalid_tunnels(tb);
        tb_free_unplugged_children(tb->root_switch);
        tb_restore_children(tb->root_switch);
@@@ -3068,7 -3063,7 +3069,7 @@@ static int tb_runtime_resume(struct tb 
        struct tb_tunnel *tunnel, *n;
  
        mutex_lock(&tb->lock);
 -      tb_switch_resume(tb->root_switch);
 +      tb_switch_resume(tb->root_switch, true);
        tb_free_invalid_tunnels(tb);
        tb_restore_children(tb->root_switch);
        list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list)
index 78b06e922fdace678239dae417183219b0ae2007,cc62587736e5b2be034dfcc1e83fe75ee747f413..de480bf2a53def9813ccb5f54a7e99f759ea558f
@@@ -52,6 -52,10 +52,10 @@@ enum usb4_ba_index 
  #define USB4_BA_VALUE_MASK            GENMASK(31, 16)
  #define USB4_BA_VALUE_SHIFT           16
  
+ /* Delays in us used with usb4_port_wait_for_bit() */
+ #define USB4_PORT_DELAY                       50
+ #define USB4_PORT_SB_DELAY            5000
  static int usb4_native_switch_op(struct tb_switch *sw, u16 opcode,
                                 u32 *metadata, u8 *status,
                                 const void *tx_data, size_t tx_dwords,
@@@ -155,13 -159,7 +159,13 @@@ static inline int usb4_switch_op_data(s
                                tx_dwords, rx_data, rx_dwords);
  }
  
 -static void usb4_switch_check_wakes(struct tb_switch *sw)
 +/**
 + * usb4_switch_check_wakes() - Check for wakes and notify PM core about them
 + * @sw: Router whose wakes to check
 + *
 + * Checks wakes occurred during suspend and notify the PM core about them.
 + */
 +void usb4_switch_check_wakes(struct tb_switch *sw)
  {
        bool wakeup_usb4 = false;
        struct usb4_port *usb4;
        bool wakeup = false;
        u32 val;
  
 -      if (!device_may_wakeup(&sw->dev))
 -              return;
 -
        if (tb_route(sw)) {
                if (tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_6, 1))
                        return;
@@@ -247,6 -248,8 +251,6 @@@ int usb4_switch_setup(struct tb_switch 
        u32 val = 0;
        int ret;
  
 -      usb4_switch_check_wakes(sw);
 -
        if (!tb_route(sw))
                return 0;
  
@@@ -1245,7 -1248,7 +1249,7 @@@ void usb4_port_unconfigure_xdomain(stru
  }
  
  static int usb4_port_wait_for_bit(struct tb_port *port, u32 offset, u32 bit,
-                                 u32 value, int timeout_msec)
+                         u32 value, int timeout_msec, unsigned long delay_usec)
  {
        ktime_t timeout = ktime_add_ms(ktime_get(), timeout_msec);
  
                if ((val & bit) == value)
                        return 0;
  
-               usleep_range(50, 100);
+               fsleep(delay_usec);
        } while (ktime_before(ktime_get(), timeout));
  
        return -ETIMEDOUT;
@@@ -1308,7 -1311,7 +1312,7 @@@ static int usb4_port_sb_read(struct tb_
                return ret;
  
        ret = usb4_port_wait_for_bit(port, port->cap_usb4 + PORT_CS_1,
-                                    PORT_CS_1_PND, 0, 500);
+                                    PORT_CS_1_PND, 0, 500, USB4_PORT_SB_DELAY);
        if (ret)
                return ret;
  
@@@ -1355,7 -1358,7 +1359,7 @@@ static int usb4_port_sb_write(struct tb
                return ret;
  
        ret = usb4_port_wait_for_bit(port, port->cap_usb4 + PORT_CS_1,
-                                    PORT_CS_1_PND, 0, 500);
+                                    PORT_CS_1_PND, 0, 500, USB4_PORT_SB_DELAY);
        if (ret)
                return ret;
  
@@@ -1410,6 -1413,8 +1414,8 @@@ static int usb4_port_sb_op(struct tb_po
  
                if (val != opcode)
                        return usb4_port_sb_opcode_err_to_errno(val);
+               fsleep(USB4_PORT_SB_DELAY);
        } while (ktime_before(ktime_get(), timeout));
  
        return -ETIMEDOUT;
@@@ -1591,13 -1596,14 +1597,14 @@@ int usb4_port_asym_start(struct tb_por
         * port started the symmetry transition.
         */
        ret = usb4_port_wait_for_bit(port, port->cap_usb4 + PORT_CS_19,
-                                    PORT_CS_19_START_ASYM, 0, 1000);
+                                    PORT_CS_19_START_ASYM, 0, 1000,
+                                    USB4_PORT_DELAY);
        if (ret)
                return ret;
  
        /* Then wait for the transtion to be completed */
        return usb4_port_wait_for_bit(port, port->cap_usb4 + PORT_CS_18,
-                                     PORT_CS_18_TIP, 0, 5000);
+                                     PORT_CS_18_TIP, 0, 5000, USB4_PORT_DELAY);
  }
  
  /**
@@@ -2123,7 -2129,8 +2130,8 @@@ static int usb4_usb3_port_cm_request(st
         */
        val &= ADP_USB3_CS_2_CMR;
        return usb4_port_wait_for_bit(port, port->cap_adap + ADP_USB3_CS_1,
-                                     ADP_USB3_CS_1_HCA, val, 1500);
+                                     ADP_USB3_CS_1_HCA, val, 1500,
+                                     USB4_PORT_DELAY);
  }
  
  static inline int usb4_usb3_port_set_cm_request(struct tb_port *port)
This page took 0.0996 seconds and 4 git commands to generate.