Mainline kernel PCIE part still missing

Hi I would like to use mainline kernel 5.4
are there any chance that we will see PCIE part integrated soon?

I know that I can cherry pick this :slight_smile:
https://git.linaro.org/people/manivannan.sadhasivam/96b-common.git/log/?h=hikey970_pcie

but it will be nice to have it.
Or are there any problems?

@Mani

I am building(on board)
git clone --single-branch --branch hikey970_pcie https://git.linaro.org/people/manivannan.sadhasivam/96b-common.git hikey970
with this defconfig https://raw.githubusercontent.com/Bigcountry907/linux/hikey970-v4.9-Debain-Working/arch/arm64/configs/hikey970_defconfig

and this
CONFIG_PCIE_DW=y
CONFIG_PCIE_DW_HOST=y
CONFIG_PCIE_DW_PLAT=y
CONFIG_PCIE_DW_PLAT_HOST=y
CONFIG_PCI_HOST_COMMON=y
CONFIG_PCI_HOST_GENERIC=y
CONFIG_PCI_HISI=y
CONFIG_PCI_KIRIN=y

but I still don’t see anything with sudo lspci -v
00:00.0 PCI bridge: Huawei Technologies Co., Ltd. Device 3670 (rev 01) (prog-if 00 [Normal decode])
Flags: bus master, fast devsel, latency 0, IRQ 255
[virtual] Memory at f6000000 (64-bit, non-prefetchable) [size=16M]
Bus: primary=00, secondary=01, subordinate=ff, sec-latency=0
I/O behind bridge: None
Memory behind bridge: None
Prefetchable memory behind bridge: None
Capabilities: [40] Power Management version 3
Capabilities: [50] MSI: Enable- Count=1/1 Maskable+ 64bit+
Capabilities: [70] Express Root Port (Slot-), MSI 00
Capabilities: [100] Advanced Error Reporting
Capabilities: [148] Power Budgeting <?>
Capabilities: [158] Secondary PCI Express <?>
Capabilities: [170] L1 PM Substates

[ 0.428936] kirin-pcie f4000000.pcie: host bridge /soc/pcie@f4000000 ranges:
[ 0.428944] kirin-pcie f4000000.pcie: Parsing ranges property…
[ 0.428953] kirin-pcie f4000000.pcie: MEM 0xf6000000…0xf7ffffff -> 0x00000000
[ 1.434086] kirin-pcie f4000000.pcie: Link Fail
[ 1.438772] kirin-pcie f4000000.pcie: PCI host bridge to bus 0000:00

Any idea how can I fix it ?@Mani

so I added
CONFIG_PCIEPORTBUS=y
CONFIG_PCIEAER=y
CONFIG_PCI_SYSCALL=y
CONFIG_PCIE_ECRC=y
CONFIG_PCIE_DPC=y
CONFIG_PCIE_PTM=y

And now I have some more

[ 1.440877] pci_bus 0000:00: root bus resource [bus 00-01]
[ 1.440882] pci_bus 0000:00: root bus resource [mem 0xf6000000-0xf7ffffff] (bus address [0x00000000-0x01ffffff])
[ 1.440886] pci_bus 0000:00: scanning bus
[ 1.440922] pci 0000:00:00.0: [19e5:3670] type 01 class 0x060400
[ 1.440973] pci 0000:00:00.0: reg 0x10: [mem 0xf6000000-0xf6ffffff 64bit]
[ 1.441116] pci 0000:00:00.0: supports D1 D2
[ 1.441119] pci 0000:00:00.0: PME# supported from D0 D1 D2 D3hot
[ 1.441128] pci 0000:00:00.0: PME# disabled
[ 1.441975] pci_bus 0000:00: fixups for bus
[ 1.441982] pci 0000:00:00.0: scanning [bus 01-ff] behind bridge, pass 0
[ 1.442056] pci_bus 0000:01: busn_res: can not insert [bus 01-ff] under [bus 00-01] (conflicts with (null) [bus 00-01])
[ 1.442059] pci_bus 0000:01: scanning bus
[ 1.442658] pci_bus 0000:01: fixups for bus
[ 1.442663] pci_bus 0000:01: bus scan returning with max=01
[ 1.442671] pci 0000:00:00.0: scanning [bus 01-ff] behind bridge, pass 1
[ 1.442680] pci_bus 0000:00: bus scan returning with max=ff
[ 1.442705] pci 0000:00:00.0: BAR 0: assigned [mem 0xf6000000-0xf6ffffff 64bit]
[ 1.442724] pci 0000:00:00.0: PCI bridge to [bus 01-ff]
[ 1.442849] pcieport 0000:00:00.0: assign IRQ: got 42
[ 1.443040] pcieport 0000:00:00.0: Signaling PME with IRQ 43
[ 1.443204] aer 0000:00:00.0:pcie002: AER enabled with IRQ 43

still no device with lspci -v

btw I have working Ethernet when I use 4.9 kernel with UEFI
git clone --single-branch --branch hikey970-v4.9-Debain-Working https://github.com/Bigcountry907/linux.git -b hikey970-v4.9-Debain-Working

ok it started to work after I did some update
http://people.linaro.org/~manivannan.sadhasivam/hikey970_images/

sudo python hisi-idt.py -d /dev/ttyUSB0 --img1 ./sec_usb_xloader.img --img2 ./sec_usb_xloader2.img --img3 ./l-loader.bin
$ sudo fastboot flash fastboot l-loader.bin
$ sudo fastboot flash fip fip.bin

@xlazom00 Sorry for not responding earlier. And you did the right thing. Those bootloader changes are necessary for enabling the LDO of the PCI-E switch. The commit is here: https://github.com/Mani-Sadhasivam/OpenPlatformPkg/commit/32e59f8f6848b09fddaf549c08b1363a66abc400

Mainlining PCI-E changes for hikey970 requires some documentation of the register settings used. Since we don’t have any open doc for that, I don’t think there is any road ahead for mainlining.

@Mani
When I do
sudo fastboot flash fastboot l-loader.bin
sudo fastboot flash fip fip.bin
from your http://people.linaro.org/~manivannan.sadhasivam/hikey970_images/
I can’t control GRUB with arrows only enter is working fine and arrows are switched to v and ^ characters
any idea ?
everything was fine with
files from https://github.com/Bigcountry907/Bionic-Builder/tree/master/Install

@xlazom00

I haven’t experienced any issues like this. But you can try changing the keyboard layout in grub to see if it fixes.

@Mani
From time to time I have a issue with booting OS. It looks like some deadlock. And sometimes network can’t connect :frowning: So it looks like some pci driver problem

I added coherent_pool=4M to kernel boot
And I cherry picked your changes to 5.4 kernel

Btw I am looking on pci driver and it is dw based driver. And kirin pci driver looks like it don’t reuse a lots of code from dw sources. quallcom drivers looks better :slight_smile:
There are like lots functions that can be reused I think so the kirin pci driver should be much smaller :slight_smile:

Can the binaries from Mani be written to their respective partitions using dd when logged in on the hikey970?

I ask because that would allow updates while running linux on the Hikey970.
Also it helps if we don’t need an external PC for upgrading the bootloaders etc.

Second question: is there a repository (github?) with a 5.x kernel that has all the patches required to build a kernel for the hikey970?

Best regards,
Jan Rinze.

using the binaries from Mani I cannot use the side USB-C for serial.
I does give output but does not accept any input.

@janrinze THe Hikey970 board uses XR21V1410 UART to USB converter chip. The driver for this chip is not upstreamed and hence some distros don’t package it. So, for typing onto the console, you need to use ttyXRUSB0 port and not ttyACM0 which can only be provided by XRUSB serial driver. There are some sources available on net which you can try to compile and install it as a module on your host system.

I will try to see if this driver can be submitted for mainline to ease the process.

I can use serial console with a 1.8 v USB to serial converter.
That allows access to the boot process and grub.
However the USB-C port does show the output but it’s not possible to type anything.
I have not been able to find out why some other people can use the USB-C port on the side of the hikey970 for bi-directional traffic.

There is a lot of confusion around this issue. This is not a kernel issue. The bootloaders run way before any kernel runs.

Hi Mani, I have just experienced the same issue with xlazom00 after flashing the fip.bin. Either the binary file you provide or the file complied from your sources code works fine with grub.

It seems the grub can detect up and down characters, and stop counting down. However, other keys or key-bindings works fine. For example, I can still switch grub menu by using ctrl+p and ctrl+n.

Any idea?