Skip to content

Commit 9fccced

Browse files
committed
Merge tag 'thunderbolt-for-v6.16-rc4' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt into usb-linus
Mika writes: thunderbolt: Fixes for v6.16-rc4 This includes following USB4/Thunderbolt fixes for v6.16-rc4: - Fix wake on connect during runtime suspend - Fix bit masking in tb_dp_port_set_hops(). Both have been in linux-next with no reported issues. * tag 'thunderbolt-for-v6.16-rc4' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt: thunderbolt: Fix bit masking in tb_dp_port_set_hops() thunderbolt: Fix wake on connect at runtime
2 parents 3c2bd25 + 2cdde91 commit 9fccced

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

drivers/thunderbolt/switch.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,7 +1450,7 @@ int tb_dp_port_set_hops(struct tb_port *port, unsigned int video,
14501450
return ret;
14511451

14521452
data[0] &= ~ADP_DP_CS_0_VIDEO_HOPID_MASK;
1453-
data[1] &= ~ADP_DP_CS_1_AUX_RX_HOPID_MASK;
1453+
data[1] &= ~ADP_DP_CS_1_AUX_TX_HOPID_MASK;
14541454
data[1] &= ~ADP_DP_CS_1_AUX_RX_HOPID_MASK;
14551455

14561456
data[0] |= (video << ADP_DP_CS_0_VIDEO_HOPID_SHIFT) &
@@ -3437,15 +3437,15 @@ void tb_sw_set_unplugged(struct tb_switch *sw)
34373437
}
34383438
}
34393439

3440-
static int tb_switch_set_wake(struct tb_switch *sw, unsigned int flags)
3440+
static int tb_switch_set_wake(struct tb_switch *sw, unsigned int flags, bool runtime)
34413441
{
34423442
if (flags)
34433443
tb_sw_dbg(sw, "enabling wakeup: %#x\n", flags);
34443444
else
34453445
tb_sw_dbg(sw, "disabling wakeup\n");
34463446

34473447
if (tb_switch_is_usb4(sw))
3448-
return usb4_switch_set_wake(sw, flags);
3448+
return usb4_switch_set_wake(sw, flags, runtime);
34493449
return tb_lc_set_wake(sw, flags);
34503450
}
34513451

@@ -3521,7 +3521,7 @@ int tb_switch_resume(struct tb_switch *sw, bool runtime)
35213521
tb_switch_check_wakes(sw);
35223522

35233523
/* Disable wakes */
3524-
tb_switch_set_wake(sw, 0);
3524+
tb_switch_set_wake(sw, 0, true);
35253525

35263526
err = tb_switch_tmu_init(sw);
35273527
if (err)
@@ -3603,7 +3603,7 @@ void tb_switch_suspend(struct tb_switch *sw, bool runtime)
36033603
flags |= TB_WAKE_ON_USB4 | TB_WAKE_ON_USB3 | TB_WAKE_ON_PCIE;
36043604
}
36053605

3606-
tb_switch_set_wake(sw, flags);
3606+
tb_switch_set_wake(sw, flags, runtime);
36073607

36083608
if (tb_switch_is_usb4(sw))
36093609
usb4_switch_set_sleep(sw);

drivers/thunderbolt/tb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,7 @@ int usb4_switch_read_uid(struct tb_switch *sw, u64 *uid);
13171317
int usb4_switch_drom_read(struct tb_switch *sw, unsigned int address, void *buf,
13181318
size_t size);
13191319
bool usb4_switch_lane_bonding_possible(struct tb_switch *sw);
1320-
int usb4_switch_set_wake(struct tb_switch *sw, unsigned int flags);
1320+
int usb4_switch_set_wake(struct tb_switch *sw, unsigned int flags, bool runtime);
13211321
int usb4_switch_set_sleep(struct tb_switch *sw);
13221322
int usb4_switch_nvm_sector_size(struct tb_switch *sw);
13231323
int usb4_switch_nvm_read(struct tb_switch *sw, unsigned int address, void *buf,

drivers/thunderbolt/usb4.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -403,12 +403,12 @@ bool usb4_switch_lane_bonding_possible(struct tb_switch *sw)
403403
* usb4_switch_set_wake() - Enabled/disable wake
404404
* @sw: USB4 router
405405
* @flags: Wakeup flags (%0 to disable)
406+
* @runtime: Wake is being programmed during system runtime
406407
*
407408
* Enables/disables router to wake up from sleep.
408409
*/
409-
int usb4_switch_set_wake(struct tb_switch *sw, unsigned int flags)
410+
int usb4_switch_set_wake(struct tb_switch *sw, unsigned int flags, bool runtime)
410411
{
411-
struct usb4_port *usb4;
412412
struct tb_port *port;
413413
u64 route = tb_route(sw);
414414
u32 val;
@@ -438,13 +438,11 @@ int usb4_switch_set_wake(struct tb_switch *sw, unsigned int flags)
438438
val |= PORT_CS_19_WOU4;
439439
} else {
440440
bool configured = val & PORT_CS_19_PC;
441-
usb4 = port->usb4;
441+
bool wakeup = runtime || device_may_wakeup(&port->usb4->dev);
442442

443-
if (((flags & TB_WAKE_ON_CONNECT) &&
444-
device_may_wakeup(&usb4->dev)) && !configured)
443+
if ((flags & TB_WAKE_ON_CONNECT) && wakeup && !configured)
445444
val |= PORT_CS_19_WOC;
446-
if (((flags & TB_WAKE_ON_DISCONNECT) &&
447-
device_may_wakeup(&usb4->dev)) && configured)
445+
if ((flags & TB_WAKE_ON_DISCONNECT) && wakeup && configured)
448446
val |= PORT_CS_19_WOD;
449447
if ((flags & TB_WAKE_ON_USB4) && configured)
450448
val |= PORT_CS_19_WOU4;

0 commit comments

Comments
 (0)