Skip to content

Commit 1b62f3c

Browse files
committed
Merge tag 'thunderbolt-for-v6.13-rc4' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt into usb-linus
Mika writes: thunderbolt: Fixes for v6.13-rc4 This includes following USB4/Thunderbolt fixes for v6.13-rc4: - Add Intel Panther Lake PCI IDs - Do not show nvm_version for retimers that are not supported - Fix redrive mode handling. All these have been in linux-next with no reported issues. * tag 'thunderbolt-for-v6.13-rc4' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt: thunderbolt: Improve redrive mode handling thunderbolt: Don't display nvm_version unless upgrade supported thunderbolt: Add support for Intel Panther Lake-M/P
2 parents b9252f8 + 2474038 commit 1b62f3c

File tree

4 files changed

+68
-4
lines changed

4 files changed

+68
-4
lines changed

drivers/thunderbolt/nhi.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,6 +1520,14 @@ static struct pci_device_id nhi_ids[] = {
15201520
.driver_data = (kernel_ulong_t)&icl_nhi_ops },
15211521
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_LNL_NHI1),
15221522
.driver_data = (kernel_ulong_t)&icl_nhi_ops },
1523+
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_PTL_M_NHI0),
1524+
.driver_data = (kernel_ulong_t)&icl_nhi_ops },
1525+
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_PTL_M_NHI1),
1526+
.driver_data = (kernel_ulong_t)&icl_nhi_ops },
1527+
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_PTL_P_NHI0),
1528+
.driver_data = (kernel_ulong_t)&icl_nhi_ops },
1529+
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_PTL_P_NHI1),
1530+
.driver_data = (kernel_ulong_t)&icl_nhi_ops },
15231531
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HOST_80G_NHI) },
15241532
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HOST_40G_NHI) },
15251533

drivers/thunderbolt/nhi.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ extern const struct tb_nhi_ops icl_nhi_ops;
9292
#define PCI_DEVICE_ID_INTEL_RPL_NHI1 0xa76d
9393
#define PCI_DEVICE_ID_INTEL_LNL_NHI0 0xa833
9494
#define PCI_DEVICE_ID_INTEL_LNL_NHI1 0xa834
95+
#define PCI_DEVICE_ID_INTEL_PTL_M_NHI0 0xe333
96+
#define PCI_DEVICE_ID_INTEL_PTL_M_NHI1 0xe334
97+
#define PCI_DEVICE_ID_INTEL_PTL_P_NHI0 0xe433
98+
#define PCI_DEVICE_ID_INTEL_PTL_P_NHI1 0xe434
9599

96100
#define PCI_CLASS_SERIAL_USB_USB4 0x0c0340
97101

drivers/thunderbolt/retimer.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ static int tb_retimer_nvm_add(struct tb_retimer *rt)
103103

104104
err_nvm:
105105
dev_dbg(&rt->dev, "NVM upgrade disabled\n");
106+
rt->no_nvm_upgrade = true;
106107
if (!IS_ERR(nvm))
107108
tb_nvm_free(nvm);
108109

@@ -182,8 +183,6 @@ static ssize_t nvm_authenticate_show(struct device *dev,
182183

183184
if (!rt->nvm)
184185
ret = -EAGAIN;
185-
else if (rt->no_nvm_upgrade)
186-
ret = -EOPNOTSUPP;
187186
else
188187
ret = sysfs_emit(buf, "%#x\n", rt->auth_status);
189188

@@ -323,8 +322,6 @@ static ssize_t nvm_version_show(struct device *dev,
323322

324323
if (!rt->nvm)
325324
ret = -EAGAIN;
326-
else if (rt->no_nvm_upgrade)
327-
ret = -EOPNOTSUPP;
328325
else
329326
ret = sysfs_emit(buf, "%x.%x\n", rt->nvm->major, rt->nvm->minor);
330327

@@ -342,6 +339,19 @@ static ssize_t vendor_show(struct device *dev, struct device_attribute *attr,
342339
}
343340
static DEVICE_ATTR_RO(vendor);
344341

342+
static umode_t retimer_is_visible(struct kobject *kobj, struct attribute *attr,
343+
int n)
344+
{
345+
struct device *dev = kobj_to_dev(kobj);
346+
struct tb_retimer *rt = tb_to_retimer(dev);
347+
348+
if (attr == &dev_attr_nvm_authenticate.attr ||
349+
attr == &dev_attr_nvm_version.attr)
350+
return rt->no_nvm_upgrade ? 0 : attr->mode;
351+
352+
return attr->mode;
353+
}
354+
345355
static struct attribute *retimer_attrs[] = {
346356
&dev_attr_device.attr,
347357
&dev_attr_nvm_authenticate.attr,
@@ -351,6 +361,7 @@ static struct attribute *retimer_attrs[] = {
351361
};
352362

353363
static const struct attribute_group retimer_group = {
364+
.is_visible = retimer_is_visible,
354365
.attrs = retimer_attrs,
355366
};
356367

drivers/thunderbolt/tb.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,6 +2059,37 @@ static void tb_exit_redrive(struct tb_port *port)
20592059
}
20602060
}
20612061

2062+
static void tb_switch_enter_redrive(struct tb_switch *sw)
2063+
{
2064+
struct tb_port *port;
2065+
2066+
tb_switch_for_each_port(sw, port)
2067+
tb_enter_redrive(port);
2068+
}
2069+
2070+
/*
2071+
* Called during system and runtime suspend to forcefully exit redrive
2072+
* mode without querying whether the resource is available.
2073+
*/
2074+
static void tb_switch_exit_redrive(struct tb_switch *sw)
2075+
{
2076+
struct tb_port *port;
2077+
2078+
if (!(sw->quirks & QUIRK_KEEP_POWER_IN_DP_REDRIVE))
2079+
return;
2080+
2081+
tb_switch_for_each_port(sw, port) {
2082+
if (!tb_port_is_dpin(port))
2083+
continue;
2084+
2085+
if (port->redrive) {
2086+
port->redrive = false;
2087+
pm_runtime_put(&sw->dev);
2088+
tb_port_dbg(port, "exit redrive mode\n");
2089+
}
2090+
}
2091+
}
2092+
20622093
static void tb_dp_resource_unavailable(struct tb *tb, struct tb_port *port)
20632094
{
20642095
struct tb_port *in, *out;
@@ -2909,6 +2940,7 @@ static int tb_start(struct tb *tb, bool reset)
29092940
tb_create_usb3_tunnels(tb->root_switch);
29102941
/* Add DP IN resources for the root switch */
29112942
tb_add_dp_resources(tb->root_switch);
2943+
tb_switch_enter_redrive(tb->root_switch);
29122944
/* Make the discovered switches available to the userspace */
29132945
device_for_each_child(&tb->root_switch->dev, NULL,
29142946
tb_scan_finalize_switch);
@@ -2924,6 +2956,7 @@ static int tb_suspend_noirq(struct tb *tb)
29242956

29252957
tb_dbg(tb, "suspending...\n");
29262958
tb_disconnect_and_release_dp(tb);
2959+
tb_switch_exit_redrive(tb->root_switch);
29272960
tb_switch_suspend(tb->root_switch, false);
29282961
tcm->hotplug_active = false; /* signal tb_handle_hotplug to quit */
29292962
tb_dbg(tb, "suspend finished\n");
@@ -3016,6 +3049,7 @@ static int tb_resume_noirq(struct tb *tb)
30163049
tb_dbg(tb, "tunnels restarted, sleeping for 100ms\n");
30173050
msleep(100);
30183051
}
3052+
tb_switch_enter_redrive(tb->root_switch);
30193053
/* Allow tb_handle_hotplug to progress events */
30203054
tcm->hotplug_active = true;
30213055
tb_dbg(tb, "resume finished\n");
@@ -3079,6 +3113,12 @@ static int tb_runtime_suspend(struct tb *tb)
30793113
struct tb_cm *tcm = tb_priv(tb);
30803114

30813115
mutex_lock(&tb->lock);
3116+
/*
3117+
* The below call only releases DP resources to allow exiting and
3118+
* re-entering redrive mode.
3119+
*/
3120+
tb_disconnect_and_release_dp(tb);
3121+
tb_switch_exit_redrive(tb->root_switch);
30823122
tb_switch_suspend(tb->root_switch, true);
30833123
tcm->hotplug_active = false;
30843124
mutex_unlock(&tb->lock);
@@ -3110,6 +3150,7 @@ static int tb_runtime_resume(struct tb *tb)
31103150
tb_restore_children(tb->root_switch);
31113151
list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list)
31123152
tb_tunnel_restart(tunnel);
3153+
tb_switch_enter_redrive(tb->root_switch);
31133154
tcm->hotplug_active = true;
31143155
mutex_unlock(&tb->lock);
31153156

0 commit comments

Comments
 (0)