All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] thunderbolt: fix PCI device class after powering up
@ 2022-07-29  9:40 Łukasz Bartosik
  2022-08-01 10:24 ` Mika Westerberg
  0 siblings, 1 reply; 9+ messages in thread
From: Łukasz Bartosik @ 2022-07-29  9:40 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Andreas Noever, Michael Jamet,
	Mika Westerberg, Yehezkel Bernat
  Cc: linux-usb, upstream

A thunderbolt
lspci -d 8086:9a1b -vmmknn
Slot:	00:0d.2
Class:	System peripheral [0880]
Vendor:	Intel Corporation [8086]
Device:	Tiger Lake-LP Thunderbolt 4 NHI #0 [9a1b]

presents itself with PCI class 0x088000 after Chromebook boots.
lspci -s 00:0d.2 -xxx
00:0d.2 System peripheral: Intel Corporation Tiger Lake-LP Thunderbolt 4
NHI #0 (rev 01)
00: 86 80 1b 9a 00 00 10 00 01 00 80 08 00 00 00 00
...

However after thunderbolt is powered up in nhi_probe()
its class changes to 0x0c0340
lspci -s 00:0d.2 -xxx
00:0d.2 System peripheral: Intel Corporation Tiger Lake-LP Thunderbolt 4
NHI #0 (rev 01)
00: 86 80 1b 9a 06 04 10 00 01 40 03 0c 00 00 00 00
...

which leaves pci_dev structure with old class value
cat /sys/bus/pci/devices/0000:00:0d.2/class
0x088000

This fix updates PCI device class in pci_dev structure after
thunderbolt is powered up.

Fixes: 3cdb9446a117 ("thunderbolt: Add support for Intel Ice Lake")
Signed-off-by: Łukasz Bartosik <lb@semihalf.com>
---
Changelog v1->v2
* Add restoration of PCI revision id
---
 drivers/thunderbolt/nhi_ops.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/thunderbolt/nhi_ops.c b/drivers/thunderbolt/nhi_ops.c
index 96da07e88c52..7aba47e5b3bd 100644
--- a/drivers/thunderbolt/nhi_ops.c
+++ b/drivers/thunderbolt/nhi_ops.c
@@ -160,12 +160,18 @@ static int icl_nhi_suspend_noirq(struct tb_nhi *nhi, bool wakeup)
 
 static int icl_nhi_resume(struct tb_nhi *nhi)
 {
+	u32 class;
 	int ret;
 
 	ret = icl_nhi_force_power(nhi, true);
 	if (ret)
 		return ret;
 
+	/* Set device class & rev as it might have changed after powering up */
+	pci_read_config_dword(nhi->pdev, PCI_CLASS_REVISION, &class);
+	nhi->pdev->class = class >> 8;
+	nhi->pdev->revision = class & 0xff;
+
 	icl_nhi_set_ltr(nhi);
 	return 0;
 }
-- 
2.37.1.455.g008518b4e5-goog


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-08-03 10:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-29  9:40 [PATCH v2] thunderbolt: fix PCI device class after powering up Łukasz Bartosik
2022-08-01 10:24 ` Mika Westerberg
2022-08-02 12:27   ` Łukasz Bartosik
2022-08-02 13:07     ` Mika Westerberg
2022-08-02 15:06       ` Łukasz Bartosik
2022-08-03  8:29         ` Mika Westerberg
2022-08-03  9:30           ` Łukasz Bartosik
2022-08-03  9:46             ` Mika Westerberg
2022-08-03 10:41               ` Łukasz Bartosik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.