devicetree-org / dt-schema

Devicetree schema tools
http://www.devicetree.org
BSD 2-Clause "Simplified" License
67 stars 67 forks source link

KeyError: 0 on MIPS loongson64 DTS #100

Open krzk opened 1 year ago

krzk commented 1 year ago

dtschema-2023.2.dev3+gbb4b09d439b4 Python 3.10.6

dtbs_check on Loongson MIPS tree produces exception:

ARCH="mips" CROSS_COMPILE="mips64-linux-gnuabi64-" KBUILD_OUTPUT="out/" make loongson2k_defconfig
touch arch/mips/boot/dts/loongson/loongson64-2k1000.dtsi
ARCH="mips" CROSS_COMPILE="mips64-linux-gnuabi64-" KBUILD_OUTPUT="out/" make dtbs_check 

make[1]: Entering directory '/home/krzk/dev/linux/linux/out'
  DTC_CHK arch/mips/boot/dts/loongson/loongson64_2core_2k1000.dtb
Traceback (most recent call last):
  File "/home/krzk/.local/bin/dt-validate", line 164, in <module>
    testtree = dtschema.load(filename)
  File "/home/krzk/.local/lib/python3.10/site-packages/dtschema/lib.py", line 1023, in load
    return [ dtschema.dtb.fdt_unflatten(f.read()) ]
  File "/home/krzk/.local/lib/python3.10/site-packages/dtschema/dtb.py", line 485, in fdt_unflatten
    fixup_interrupts(dt, 1)
  File "/home/krzk/.local/lib/python3.10/site-packages/dtschema/dtb.py", line 414, in fixup_interrupts
    fixup_interrupts(v, icells)
  File "/home/krzk/.local/lib/python3.10/site-packages/dtschema/dtb.py", line 414, in fixup_interrupts
    fixup_interrupts(v, icells)
  File "/home/krzk/.local/lib/python3.10/site-packages/dtschema/dtb.py", line 414, in fixup_interrupts
    fixup_interrupts(v, icells)
  File "/home/krzk/.local/lib/python3.10/site-packages/dtschema/dtb.py", line 440, in fixup_interrupts
    p_icells = _get_cells_size(phandles[phandle], '#interrupt-cells')
KeyError: 0
make[1]: Leaving directory '/home/krzk/dev/linux/linux/out'
robherring commented 1 year ago

The 'pci_bridge' nodes aren't valid. They are missing #address-cells which interrupt-map depends on. They also need 'device_type = "pci";'. 'interrupt-parent' in those nodes doesn't make sense either.

Should we handle this better? Yes, but crap in, crap out.