Re: Thunderbolt hotplug not working on MacMini7,1

From: Adam Goode
Date: Sat Apr 25 2015 - 22:42:31 EST


On Sat, Apr 25, 2015 at 12:58 AM, Adam Goode <adam@xxxxxxxxxxxxx> wrote:
> On Fri, Apr 24, 2015 at 2:39 PM, Adam Goode <adam@xxxxxxxxxxxxx> wrote:
>> On Fri, Apr 24, 2015 at 7:46 AM, Andreas Noever
>> <andreas.noever@xxxxxxxxx> wrote:
>>> On Fri, Apr 24, 2015 at 6:50 AM, Adam Goode <adam@xxxxxxxxxxxxx> wrote:
>>>> On Thu, Apr 23, 2015 at 1:15 PM, Adam Goode <adam@xxxxxxxxxxxxx> wrote:
>>>>> On Thu, Apr 23, 2015 at 12:12 PM, Andreas Noever
>>>>> <andreas.noever@xxxxxxxxx> wrote:
>>>>>> On Thu, Apr 23, 2015 at 5:10 PM, Adam Goode <adam@xxxxxxxxxxxxx> wrote:
>>>>>>> On Thu, Apr 23, 2015 at 9:28 AM, Adam Goode <adam@xxxxxxxxxxxxx> wrote:
>>>>>>>>
>>>>>>>> On Thu, Apr 23, 2015 at 6:08 AM, Andreas Noever
>>>>>>>> <andreas.noever@xxxxxxxxx> wrote:
>>>>>>>> > Hi Adam,
>>>>>>>> >
>>>>>>>> > On my system (MacBookPro10,1 - 4 channel TB1) the bridges and the
>>>>>>>> > controller both use 0x1547 and are only differentiated by
>>>>>>>> > subvendor/subdevice.
>>>>>>>> >
>>>>>>>> > 0x156c is the 4 channel TB2 controller and was originally added by
>>>>>>>> > Matthew. Judging from his patch it looks like the subvendor/subdevice
>>>>>>>> > is set on his system:
>>>>>>>> > http://patchwork.ozlabs.org/patch/354626/
>>>>>>>> >
>>>>>>>> > But it also indicates that the bridges already use different ids. If
>>>>>>>> > that is the case then we can drop the subvendor/subdevice for 0x156c.
>>>>>>>> > Matthew can you confirm that on your system 0x156c is used only for
>>>>>>>> > the controller?
>>>>>>>> >
>>>>>>>> > Adam, could you check that suspend/resume works properly? Also your
>>>>>>>> > bugzilla report suggest that hotplug might now work without the
>>>>>>>> > driver. Could you try to revert the _OSI check (and disable the
>>>>>>>> > driver) and check whether everything "just works"?
>>>>>>>> >
>>>>>>>>
>>>>>>>> In _OSI("Darwin") mode, suspend/resume doesn't work. It failed to come
>>>>>>>> back from suspend.
>>>>>>>>
>>>>>>>> I have to rebuild the kernel and remove Darwin again, but I will test
>>>>>>>> suspend/resume in "Windows 2012" mode later.
>>>>>>>>
>>>>>>>> From previous testing, hotplug doesn't automatically work in "Windows
>>>>>>>> 2012" mode. It exhibits the standard no-driver behavior where devices
>>>>>>>> are not detected after boot. But even in "Windows 2012" mode I still
>>>>>>>> do get the 0x156c device, which I think used to be hidden if !Darwin.
>>>>>>>>
>>>>>>>> More testing coming...
>>>>>>>>
>>>>>>>
>>>>>>> I've booted into _OSI(Windows 2012) mode. I am not physically at the
>>>>>>> device right now, but here is the current dmesg with 1 thunderbolt
>>>>>>> device plugged in:
>>>>>>>
>>>>>>> [ 15.576766] thunderbolt 0000:06:00.0: NHI initialized, starting thunderbolt
>>>>>>> [ 15.577868] thunderbolt 0000:06:00.0: allocating TX ring 0 of size 10
>>>>>>> [ 15.578939] thunderbolt 0000:06:00.0: allocating RX ring 0 of size 10
>>>>>>> [ 15.580008] thunderbolt 0000:06:00.0: control channel created
>>>>>>> [ 15.581068] thunderbolt 0000:06:00.0: control channel starting...
>>>>>>> [ 15.582122] thunderbolt 0000:06:00.0: starting TX ring 0
>>>>>>> [ 15.583173] thunderbolt 0000:06:00.0: enabling interrupt at
>>>>>>> register 0x38200 bit 0 (0x0 -> 0x1)
>>>>>>> [ 15.584228] thunderbolt 0000:06:00.0: starting RX ring 0
>>>>>>> [ 15.585281] thunderbolt 0000:06:00.0: enabling interrupt at
>>>>>>> register 0x38200 bit 12 (0x1 -> 0x1001)
>>>>>>> [ 15.586463] thunderbolt 0000:06:00.0: initializing Switch at 0x0
>>>>>>> (depth: 0, up port: 5)
>>>>>>> [ 15.587526] thunderbolt 0000:06:00.0: old switch config:
>>>>>>> [ 15.588569] thunderbolt 0000:06:00.0: Switch: 8086:156d (Revision:
>>>>>>> 0, TB Version: 2)
>>>>>>> [ 15.589581] thunderbolt 0000:06:00.0: Max Port Number: 12
>>>>>>> [ 15.590557] thunderbolt 0000:06:00.0: Config:
>>>>>>> [ 15.591532] thunderbolt 0000:06:00.0: Upstream Port Number: 5
>>>>>>> Depth: 0 Route String: 0x0 Enabled: 1, PlugEventsDelay: 255ms
>>>>>>> [ 15.592530] thunderbolt 0000:06:00.0: unknown1: 0x0 unknown4: 0x0
>>>>>>> [ 15.593530] thunderbolt 0000:06:00.0: 0: unsupported switch device id 0x156d
>>>>>>> [ 15.625612] thunderbolt 0000:06:00.0: 0: uid: 0x1001500947a60
>>>>>>> [ 15.626919] thunderbolt 0000:06:00.0: Port 0: 8086:156d (Revision:
>>>>>>> 0, TB Version: 1, Type: Port (0x1))
>>>>>>> [ 15.628028] thunderbolt 0000:06:00.0: Max hop id (in/out): 7/7
>>>>>>> [ 15.629050] thunderbolt 0000:06:00.0: Max counters: 8
>>>>>>> [ 15.630156] thunderbolt 0000:06:00.0: NFC Credits: 0x700000
>>>>>>> [ 15.631685] thunderbolt 0000:06:00.0: Port 1: 8086:156d (Revision:
>>>>>>> 0, TB Version: 1, Type: Port (0x1))
>>>>>>> [ 15.632896] thunderbolt 0000:06:00.0: Max hop id (in/out): 15/15
>>>>>>> [ 15.634000] thunderbolt 0000:06:00.0: Max counters: 16
>>>>>>> [ 15.635001] thunderbolt 0000:06:00.0: NFC Credits: 0x3c00000
>>>>>>> [ 15.636582] thunderbolt 0000:06:00.0: Port 2: 8086:156d (Revision:
>>>>>>> 0, TB Version: 1, Type: Port (0x1))
>>>>>>> [ 15.637737] thunderbolt 0000:06:00.0: Max hop id (in/out): 15/15
>>>>>>> [ 15.638862] thunderbolt 0000:06:00.0: Max counters: 16
>>>>>>> [ 15.639875] thunderbolt 0000:06:00.0: NFC Credits: 0x3c00000
>>>>>>> [ 15.641452] thunderbolt 0000:06:00.0: Port 3: 8086:156d (Revision:
>>>>>>> 0, TB Version: 1, Type: Port (0x1))
>>>>>>> [ 15.642572] thunderbolt 0000:06:00.0: Max hop id (in/out): 15/15
>>>>>>> [ 15.643702] thunderbolt 0000:06:00.0: Max counters: 16
>>>>>>> [ 15.644683] thunderbolt 0000:06:00.0: NFC Credits: 0x3c00000
>>>>>>> [ 15.646250] thunderbolt 0000:06:00.0: Port 4: 8086:156d (Revision:
>>>>>>> 0, TB Version: 1, Type: Port (0x1))
>>>>>>> [ 15.647285] thunderbolt 0000:06:00.0: Max hop id (in/out): 15/15
>>>>>>> [ 15.648370] thunderbolt 0000:06:00.0: Max counters: 16
>>>>>>> [ 15.649460] thunderbolt 0000:06:00.0: NFC Credits: 0x3c00000
>>>>>>> [ 15.650539] thunderbolt 0000:06:00.0: Port 5: 8086:156d (Revision:
>>>>>>> 0, TB Version: 1, Type: NHI (0x2))
>>>>>>> [ 15.651517] thunderbolt 0000:06:00.0: Max hop id (in/out): 11/11
>>>>>>> [ 15.652578] thunderbolt 0000:06:00.0: Max counters: 16
>>>>>>> [ 15.653553] thunderbolt 0000:06:00.0: NFC Credits: 0xf00000
>>>>>>> [ 15.654712] thunderbolt 0000:06:00.0: Port 6: 8086:156d (Revision:
>>>>>>> 0, TB Version: 1, Type: PCIe (0x100101))
>>>>>>> [ 15.655667] thunderbolt 0000:06:00.0: Max hop id (in/out): 8/8
>>>>>>> [ 15.656681] thunderbolt 0000:06:00.0: Max counters: 2
>>>>>>> [ 15.657595] thunderbolt 0000:06:00.0: NFC Credits: 0x700000
>>>>>>> [ 15.658696] thunderbolt 0000:06:00.0: Port 7: 8086:156d (Revision:
>>>>>>> 0, TB Version: 1, Type: PCIe (0x100101))
>>>>>>> [ 15.659614] thunderbolt 0000:06:00.0: Max hop id (in/out): 8/8
>>>>>>> [ 15.660574] thunderbolt 0000:06:00.0: Max counters: 2
>>>>>>> [ 15.661414] thunderbolt 0000:06:00.0: NFC Credits: 0x700000
>>>>>>> [ 15.662444] thunderbolt 0000:06:00.0: Port 8: 8086:156d (Revision:
>>>>>>> 0, TB Version: 1, Type: PCIe (0x100101))
>>>>>>> [ 15.663289] thunderbolt 0000:06:00.0: Max hop id (in/out): 8/8
>>>>>>> [ 15.664194] thunderbolt 0000:06:00.0: Max counters: 2
>>>>>>> [ 15.664995] thunderbolt 0000:06:00.0: NFC Credits: 0x700000
>>>>>>> [ 15.665982] thunderbolt 0000:06:00.0: Port 9: 8086:156d (Revision:
>>>>>>> 0, TB Version: 1, Type: PCIe (0x100101))
>>>>>>> [ 15.666867] thunderbolt 0000:06:00.0: Max hop id (in/out): 8/8
>>>>>>> [ 15.667701] thunderbolt 0000:06:00.0: Max counters: 2
>>>>>>> [ 15.668454] thunderbolt 0000:06:00.0: NFC Credits: 0x700000
>>>>>>> [ 15.669318] thunderbolt 0000:06:00.0: Port 10: 8086:156d
>>>>>>> (Revision: 0, TB Version: 1, Type: DP/HDMI (0xe0102))
>>>>>>> [ 15.670092] thunderbolt 0000:06:00.0: Max hop id (in/out): 9/9
>>>>>>> [ 15.670863] thunderbolt 0000:06:00.0: Max counters: 2
>>>>>>> [ 15.671624] thunderbolt 0000:06:00.0: NFC Credits: 0x700000
>>>>>>> [ 15.672488] thunderbolt 0000:06:00.0: Port 11: 8086:156d
>>>>>>> (Revision: 0, TB Version: 1, Type: DP/HDMI (0xe0101))
>>>>>>> [ 15.673255] thunderbolt 0000:06:00.0: Max hop id (in/out): 9/9
>>>>>>> [ 15.674015] thunderbolt 0000:06:00.0: Max counters: 2
>>>>>>> [ 15.674758] thunderbolt 0000:06:00.0: NFC Credits: 0xf00000
>>>>>>> [ 15.675617] thunderbolt 0000:06:00.0: Port 12: 8086:156d
>>>>>>> (Revision: 0, TB Version: 1, Type: DP/HDMI (0xe0101))
>>>>>>> [ 15.676370] thunderbolt 0000:06:00.0: Max hop id (in/out): 9/9
>>>>>>> [ 15.677115] thunderbolt 0000:06:00.0: Max counters: 2
>>>>>>> [ 15.677844] thunderbolt 0000:06:00.0: NFC Credits: 0xf00000
>>>>>>> [ 15.678887] thunderbolt 0000:06:00.0: 0:1: is unplugged (state: 7)
>>>>>>> [ 15.679624] thunderbolt 0000:06:00.0: 0:3: is unplugged (state: 7)
>>>>>> Strange... it does not detect the device. Does the TB device show up in lspci?
>>>>>>
>>>>>
>>>>> This may be my fault. I am not sure if I reconnected the device when I
>>>>> was debugging. Almost certainly not, actually. I left it while I was
>>>>> compiling a new kernel and forgot. I'll let you know tonight when I
>>>>> get back.
>>>>>
>>>>>
>>>>> Adam
>>>>
>>>>
>>>> Yes, definitely was unplugged. Hotplugging seems to work fine in
>>>> either "Windows 2012" or "Darwin" mode.
>>>>
>>>> Suspend works, resume brings up video and then invariably freezes (in
>>>> either _OSI condition).
>>>>
>>>>
>>>> Adam
>>>
>>> Hm, it seems strange that hotplug would not work without the driver in
>>> win2012 mode. If it works under windows (without additional drivers? -
>>> maybe bootcamp includes a windows TB driver?) then it should also work
>>> for us.
>>>
>>> Andreas
>>
>>
>> I am planning to try Windows 8 or 10 on this hardware to see.
>>
>> I inspected the Boot Camp driver image and did not see and Thunderbolt
>> drivers. But I will see for sure once I have Windows running.
>>
>> I did find other Thunderbolt drivers:
>> https://downloadcenter.intel.com/download/23742/Thunderbolt-Intel-Thunderbolt-driver
>> If you download and inspect the various .inf files (no need to install
>> anything), you'll see the PCI matching logic they use.
>>
>
> Windows 10 has functioning hotplug on this hardware without any
> Thunderbolt drivers. In fact, the 8086:156c device shows up in the
> device manager as a device that Windows can't find the driver for.
>
> So there might be some ACPI or other bug that is keeping this from
> working on Linux as transparently as Windows.
>
>
> Adam


Pretty sure it's some ACPI problem. I've always wanted to learn ACPI.

>From the debug output, I know it starts executing these lines in \_SB.PCI0._INI:

Debug = "OSYS="
Debug = OSYS /* \OSYS */
Debug = \_SB.PCI0.LPCB.RTC.ISWI
If (!OSDW ())
{
If ((OSYS >= 0x07DC))
{
Debug = "Save Ridge Config on Boot"
R118 = UP18 /* External reference */
R119 = UP19 /* External reference */
...

The 3rd Debug line is where it all goes wrong. Pity, since the next
thing it's about to do is set up Thunderbolt:

[ 0.125244] ACPI: BIOS _OSI("Darwin") is not supported
[ 0.125250] [Firmware Bug]: ACPI: BIOS _OSI(Linux) query ignored
[ 0.125251] ACPI: BIOS _OSI("Linux") is not supported
[ 0.125257] ACPI: BIOS _OSI("Windows 2009") is supported
[ 0.125261] exregion-0206 ex_system_memory_space: System-Memory
(width 8) R/W 1 Address=0000000088D3AA90
[ 0.125263] exregion-0206 ex_system_memory_space: System-Memory
(width 8) R/W 1 Address=0000000088D3AA91
[ 0.125274] exregion-0206 ex_system_memory_space: System-Memory
(width 8) R/W 0 Address=0000000088D3AA90
[ 0.125276] exregion-0206 ex_system_memory_space: System-Memory
(width 8) R/W 0 Address=0000000088D3AA91
[ 0.125288] exregion-0206 ex_system_memory_space: System-Memory
(width 8) R/W 1 Address=0000000088D3AA9F
[ 0.125298] exregion-0206 ex_system_memory_space: System-Memory
(width 8) R/W 1 Address=0000000088D1433C
[ 0.125300] exregion-0206 ex_system_memory_space: System-Memory
(width 8) R/W 1 Address=0000000088D1433D
[ 0.125301] exregion-0206 ex_system_memory_space: System-Memory
(width 8) R/W 1 Address=0000000088D1433E
[ 0.125303] exregion-0206 ex_system_memory_space: System-Memory
(width 8) R/W 1 Address=0000000088D1433F
[ 0.125315] exregion-0206 ex_system_memory_space: System-Memory
(width 8) R/W 1 Address=0000000088D3AA90
[ 0.125317] exregion-0206 ex_system_memory_space: System-Memory
(width 8) R/W 1 Address=0000000088D3AA91
[ 0.125327] ACPI: BIOS _OSI("Darwin") is not supported
[ 0.125332] ACPI: BIOS _OSI("Linux") is not supported
[ 0.125337] ACPI: BIOS _OSI("Windows 2009") is supported
[ 0.125342] exregion-0206 ex_system_memory_space: System-Memory
(width 8) R/W 1 Address=0000000088D3AA90
[ 0.125343] exregion-0206 ex_system_memory_space: System-Memory
(width 8) R/W 1 Address=0000000088D3AA91
[ 0.125349] ACPI: BIOS _OSI("Windows 2012") is supported
[ 0.125354] exregion-0206 ex_system_memory_space: System-Memory
(width 8) R/W 1 Address=0000000088D3AA90
[ 0.125356] exregion-0206 ex_system_memory_space: System-Memory
(width 8) R/W 1 Address=0000000088D3AA91
[ 0.125366] exregion-0321 ex_system_io_space_han: System-IO (width
8) R/W 0 Address=0000000000000B90
[ 0.125369] exregion-0321 ex_system_io_space_han: System-IO (width
8) R/W 1 Address=0000000000000B90
[ 0.125376] [ACPI Debug 00110000] String [0x05] "OSYS="
[ 0.125382] exregion-0206 ex_system_memory_space: System-Memory
(width 8) R/W 0 Address=0000000088D3AA90
[ 0.125383] exregion-0206 ex_system_memory_space: System-Memory
(width 8) R/W 0 Address=0000000088D3AA91
[ 0.125387] [ACPI Debug 00110000] Integer 0x00000000000007DC
[ 0.125392] ACPI Error: No handler for Region [CMS0]
(ffff8802658a0438) [SystemCMOS] (20150410/evregion-163)
[ 0.125395] ACPI Error: Region SystemCMOS (ID=5) has no handler
(20150410/exfldio-297)
[ 0.125398] ACPI Error: Method parse/execution failed
[\_SB_.PCI0._INI] (Node ffff8802658ac500), AE_NOT_EXIST
(20150410/psparse-536)
[ 0.125403] ACPI Exception: AE_NOT_EXIST, during
\_SB_.PCI0._INI._INI execution (20150410/nsinit-588)

Still debugging...



Adam
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/