Hikey960 not detecting PCIe devices in AOSP

I’ve been trying to get PCIe working on Android on the Hikey960.

I’ve been building off the master branch and have tried a variety of kernels including android-hikey-linaro-4.14, android-hikey-linaro-4.4, and android-hikey-linaro-4.9.

Here is what I’ve been seeing from dmesg regardless of whether a PCIe device is plugged in or not:

hikey960:/ # dmesg | grep pci
[ 1.692840] OF: PCI: host bridge /soc/pcie@f4000000 ranges:
[ 2.699256] kirin-pcie f4000000.pcie: Link Fail
[ 2.699385] kirin-pcie f4000000.pcie: PCI host bridge to bus 0000:00
[ 2.699396] pci_bus 0000:00: root bus resource [bus 00-01]
[ 2.699405] pci_bus 0000:00: root bus resource [mem 0xf6000000-0xf7ffffff] (bus address [0x00000000-0x01ffffff])
[ 2.699438] pci 0000:00:00.0: [19e5:3660] type 01 class 0x060400
[ 2.699486] pci 0000:00:00.0: reg 0x10: [mem 0xf6000000-0xf6ffffff 64bit]
[ 2.699581] pci 0000:00:00.0: supports D1 D2
[ 2.699588] pci 0000:00:00.0: PME# supported from D0 D1 D2 D3hot
[ 2.699845] pci_bus 0000:01: busn_res: can not insert [bus 01-ff] under [bus 00-01] (conflicts with (null) [bus 00-01])
[ 2.699890] pci 0000:00:00.0: BAR 0: assigned [mem 0xf6000000-0xf6ffffff 64bit]
[ 2.699908] pci 0000:00:00.0: PCI bridge to [bus 01-ff]
[ 2.700163] pcieport 0000:00:00.0: Signaling PME with IRQ 69
[ 2.700315] pcieport 0000:00:00.0: AER enabled with IRQ 69
[ 2.782024] ehci-pci: EHCI PCI platform driver
[ 2.782143] ohci-pci: OHCI PCI platform driver
[ 6.212595] tcpci_timer_init : init OK

How can I get PCIe working on AOSP on the hikey960?

Thanks!

For kernel 4.14, @jstultz has one patch for PCI-E has been merged [1] recently, could you check if this is helpful or not?

[1] https://android-review.googlesource.com/c/kernel/hikey-linaro/+/789599

I have tried with that commit - also previously I had manually applied that change.

It fixed the PCIe controller recognition (19e5:3660) but did not help with detecting connected PCIe devices.

Just remind, which booting images are you using? If you are using ARM-TF + UEFI, could you check if ARM-TF has included this fixing [1]?

If you want to use prebuilt booting images, you could try snapshot binaries [2].

[1] https://github.com/ARM-software/arm-trusted-firmware/commit/16bec9c25bdd37779ea0bc8e5c6ce3ab26e58106
[2] https://snapshots.linaro.org/96boards/reference-platform/components/uefi-staging/76/hikey960/debug/

I have not tried using ARM-TF+UEFI.
I tried flashing the snapshot binaries - this did not change the PCIe issue.

I have tried using the latest ARM-TF+UEFI snapshot binaries with the kernel from hikey-linaro-4.14.
I am still experiencing the same issue with the same output:

[ 1.693800] OF: PCI: host bridge /soc/pcie@f4000000 ranges:
[ 2.700009] kirin-pcie f4000000.pcie: Link Fail
[ 2.700136] kirin-pcie f4000000.pcie: PCI host bridge to bus 0000:00
[ 2.700146] pci_bus 0000:00: root bus resource [bus 00-01]
[ 2.700155] pci_bus 0000:00: root bus resource [mem 0xf6000000-0xf7ffffff] (bus address [0x00000000-0x01ffffff])
[ 2.700189] pci 0000:00:00.0: [19e5:3660] type 01 class 0x060400
[ 2.700237] pci 0000:00:00.0: reg 0x10: [mem 0xf6000000-0xf6ffffff 64bit]
[ 2.700332] pci 0000:00:00.0: supports D1 D2
[ 2.700339] pci 0000:00:00.0: PME# supported from D0 D1 D2 D3hot
[ 2.700589] pci_bus 0000:01: busn_res: can not insert [bus 01-ff] under [bus 00-01] (conflicts with (null) [bus 00-01])
[ 2.700633] pci 0000:00:00.0: BAR 0: assigned [mem 0xf6000000-0xf6ffffff 64bit]
[ 2.700653] pci 0000:00:00.0: PCI bridge to [bus 01-ff]
[ 2.700905] pcieport 0000:00:00.0: Signaling PME with IRQ 69
[ 2.701053] pcieport 0000:00:00.0: AER enabled with IRQ 69
[ 2.781772] ehci-pci: EHCI PCI platform driver
[ 2.781894] ohci-pci: OHCI PCI platform driver
[ 6.175548] tcpci_timer_init : init OK

At last week I checked internally and get some feedback is the Hikey960 PCIE can work with some devices and verified by some users, but it might have compatibility issue with PCIe devices (one known issue is related with nvme pcie card). Could you give more info for what device are you using?

I use dmesg with my 4.14 kernel and doesn’t find the link Fail error, I am building with latest 4.14 kernel code base and will update soon for this.

I am checking this issue firstly, from the code this reports the phy is not enabled as expected. I can see this error with latest 4.14 kernel code base.

Do you mind if we move this discussion to a bug so we can more easily track this issue?

I’ve duplicated the report here:
https://bugs.96boards.org/show_bug.cgi?id=785