Bug 198557

Summary: USB-C Devices only show up if connected at boot
Product: Drivers Reporter: Mike Lothian (mike)
Component: USBAssignee: Greg Kroah-Hartman (greg)
Status: RESOLVED CODE_FIX    
Severity: normal CC: mika.westerberg
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 4.15-rc4 Subsystem:
Regression: No Bisected commit-id:
Attachments: Dmesg
Updated Dmesg (CONFIG_HOTPLUG_PCI_ACPI=y)
Kernel Config
Dmesg with dyn debug
Add more debugging to ACPIphp
Dmesg with extra debugging
ACPIphp debugging and read dvid of upstream port
Dmesg which shows it working
ACPI / hotplug / PCI: Check presence of slot itself in get_slot_status()

Description Mike Lothian 2018-01-23 00:31:53 UTC
Created attachment 273801 [details]
Dmesg

If the device is disconnected the following message appears in the dmesg:

[  100.814687] usb 3-1: USB disconnect, device number 3
[  100.882840] xhci_hcd 0000:39:00.0: xHCI host controller not responding, assume dead
[  100.882843] xhci_hcd 0000:39:00.0: HC died; cleaning up

No further connections or disconnections display anything further in the dmesg, the device works fine if connected via USB-A
Comment 1 Mike Lothian 2018-01-23 00:38:43 UTC
This isn't a regression, I've had this issue since getting the laptop at the end of 2015
Comment 2 Greg Kroah-Hartman 2018-01-23 06:13:47 UTC
On Tue, Jan 23, 2018 at 12:31:53AM +0000, bugzilla-daemon@bugzilla.kernel.org wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=198557
> 
>             Bug ID: 198557
>            Summary: USB-C Devices only show up if connected at boot
>            Product: Drivers
>            Version: 2.5
>     Kernel Version: 4.15-rc4

All USB bugs should be sent to the linux-usb@vger.kernel.org mailing
list, and not entered into bugzilla.  Please bring this issue up there,
if it is still a problem in the latest kernel release.
Comment 3 Mike Lothian 2018-01-26 09:38:51 UTC
Created attachment 273869 [details]
Updated Dmesg (CONFIG_HOTPLUG_PCI_ACPI=y)
Comment 4 Mike Lothian 2018-01-26 09:46:07 UTC
Created attachment 273871 [details]
Kernel Config
Comment 5 Mike Lothian 2018-01-26 09:46:51 UTC
All the ACPI dump stuff can be found at https://bugzilla.kernel.org/show_bug.cgi?id=198051
Comment 6 Mika Westerberg 2018-01-26 09:53:54 UTC
Thanks, can you still do one more test?

Add "acpiphp.dyndbg" to your kernel command line. Then boot the system so that you don't have anything connected to the USB-C port. Once the system is fully booted, plug in the USB-C device. Don't do manual rescan or anything. Then attach full dmesg to this bug and also output of lspci.
Comment 7 Mike Lothian 2018-01-26 09:59:06 UTC
I'll do that when I'm home tonight, if there's anything I can do remotely before then let me know.
Comment 8 Mike Lothian 2018-01-27 11:25:07 UTC
Created attachment 273889 [details]
Dmesg with dyn debug

Here's the plug and unplug events

[   26.988174] ACPI: \_SB_.PCI0.RP01: acpiphp_glue: Bus check in hotplug_event()
[  129.086070] ACPI: \_SB_.PCI0.RP01: acpiphp_glue: Bus check in hotplug_event()
Comment 9 Mika Westerberg 2018-01-29 09:46:17 UTC
Created attachment 273907 [details]
Add more debugging to ACPIphp

It seems that for some reason ACPIphp does not detect there is a new device in th slot. Could you apply the attached patch and try again the same steps? Then attach dmesg.
Comment 10 Mike Lothian 2018-01-29 18:46:27 UTC
Created attachment 273917 [details]
Dmesg with extra debugging

Here's the useful lines:

[   25.472180] ACPI: \_SB_.PCI0.RP01: acpiphp_glue: Bus check in hotplug_event()
[   25.472185] pcieport 0000:00:1c.0: ACPIphp scanning bridge
[   25.472202] pci_bus 0000:02: 0x2 dvid 0xffffffff
[   25.472203] acpiphp_glue: get_slot_status() returns: 0x0
[   25.472204] acpiphp_glue: ACPIphp disabling slot
[   25.472205] pcieport 0000:00:1c.0: ACPIphp bridge scanned
Comment 11 Mike Lothian 2018-01-29 18:50:10 UTC
And the disconnect:

[  342.209521] ACPI: \_SB_.PCI0.RP01: acpiphp_glue: Bus check in hotplug_event()
[  342.209525] pcieport 0000:00:1c.0: ACPIphp scanning bridge
[  342.209551] pci_bus 0000:02: 0x2 dvid 0xffffffff
[  342.209551] acpiphp_glue: get_slot_status() returns: 0x0
[  342.209552] acpiphp_glue: ACPIphp disabling slot
[  342.209554] pcieport 0000:00:1c.0: ACPIphp bridge scanned
Comment 12 Mika Westerberg 2018-01-29 21:02:08 UTC
Created attachment 273919 [details]
ACPIphp debugging and read dvid of upstream port

ACPI tables of that system list PXSX device with 2 as an address:

Device (PXSX)
{
    Name (_ADR, 0x02)  // _ADR: Address

and ACPIphp then uses that address to check for the device presence. I think that is not correct because we get Notify() directly to the root port. Could you apply the attached patch (remove the previous one) and try again the same steps? Then attach dmesg.
Comment 13 Mike Lothian 2018-01-29 21:20:44 UTC
Created attachment 273923 [details]
Dmesg which shows it working

That seems to work now
Comment 14 Mike Lothian 2018-01-29 21:22:39 UTC
It also seems to fix my disappearing disk during suspend
Comment 15 Mika Westerberg 2018-01-30 10:29:35 UTC
Great, thanks for testing. I'll make a proper patch and send it upstream soon.
Comment 16 Mike Lothian 2018-01-31 10:10:52 UTC
Would you mind attaching the final patch here? I'm not subscribed to the LKML or Linux PCI

Also would this fix be back ported to older kernels?
Comment 17 Mika Westerberg 2018-01-31 10:48:44 UTC
Sure, I'll attach it here and CC you as well when it will be submitted upstream. Since it is fix it most likely will be included in stable releases.
Comment 18 Greg Kroah-Hartman 2018-01-31 11:00:38 UTC
On Wed, Jan 31, 2018 at 10:48:44AM +0000, bugzilla-daemon@bugzilla.kernel.org wrote:
> Sure, I'll attach it here and CC you as well when it will be submitted
> upstream. Since it is fix it most likely will be included in stable releases.

Please also cc: me, and properly tag the patch for stable inclusion so
it gets added to those trees automagically.

thanks,

greg k-h
Comment 19 Mika Westerberg 2018-02-12 10:58:39 UTC
Created attachment 274125 [details]
ACPI / hotplug / PCI: Check presence of slot itself in get_slot_status()

Attaching the patch here as well. I just sent it upstream for review.