u-boot/arch
Pali Rohár 1fd54253bc arm: a37xx: pci: Fix a3700_fdt_fix_pcie_regions() function again
The a3700_fdt_fix_pcie_regions() function still computes nonsense.

It computes the fixup offset from the PCI address taken from the first
row of the "ranges" array, which means that:
- PCI address must equal CPU address (otherwise the computed fix offset
  will be wrong),
- the first row must contain the lowest address.

This is the case for the default device-tree, which is why we didn't
notice it.

It also adds the fixup offset to all PCI and CPU addresses, which is
wrong.

Instead:
1) The fixup offset must be computed from the CPU address, not PCI
   address.

2) The fixup offset must be computed from the row containing the lowest
   CPU address, which is not necessarily contained in the first row.

3) The PCI address - the address to which the PCIe controller remaps the
   address space as seen from the point of view of the PCIe device -
   must be fixed by the fix offset in the same way as the CPU address
   only in the special case when the CPU adn PCI addresses are the same.
   Same addresses means that remapping is disabled, and thus if we
   change the CPU address, we need also to change the PCI address so
   that the remapping is still disabled afterwards.

Consider an example:
  The ranges entries contain:
    PCI address   CPU address
    70000000      EA000000
    E9000000      E9000000
    EB000000      EB000000

  By default CPU PCIe window is at:        E8000000 - F0000000
  Consider the case when TF-A moves it to: F2000000 - FA000000

  Until now the function would take the PCI address of the first entry:
  70000000, and the new base, F2000000, to compute the fix offset:
  F2000000 - 70000000 = 82000000, and then add 8200000 to all addresses,
  resulting in
    PCI address   CPU address
    F2000000      6C000000
    6B000000      6B000000
    6D000000      6D000000
  which is complete nonsense - none of the CPU addresses is in the
  requested window.

  Now it will take the lowest CPU address, which is in second row,
  E9000000, and compute the fix offset F2000000 - E9000000 = 09000000,
  and then add it to all CPU addresses and those PCI addresses which
  equal to their corresponding CPU addresses, resulting in
    PCI address   CPU address
    70000000      F3000000
    F2000000      F2000000
    F4000000      F4000000
  where all of the CPU addresses are in the needed window.

Fixes: 4a82fca8e3 ("arm: a37xx: pci: Fix a3700_fdt_fix_pcie_regions() function")
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
2022-03-04 08:38:05 +01:00
..
arc dts: automatically build necessary .dtb files 2022-02-09 12:26:12 -07:00
arm arm: a37xx: pci: Fix a3700_fdt_fix_pcie_regions() function again 2022-03-04 08:38:05 +01:00
m68k dts: automatically build necessary .dtb files 2022-02-09 12:26:12 -07:00
microblaze Xilinx changes for v2022.04-rc3 2022-02-21 08:32:02 -05:00
mips dts: automatically build necessary .dtb files 2022-02-09 12:26:12 -07:00
nds32 dts: automatically build necessary .dtb files 2022-02-09 12:26:12 -07:00
nios2 dts: automatically build necessary .dtb files 2022-02-09 12:26:12 -07:00
powerpc powerpc: mpc8xx: drop CONFIG_SYS_RESET_ADDRESS 2022-02-10 16:44:23 -05:00
riscv dts: automatically build necessary .dtb files 2022-02-09 12:26:12 -07:00
sandbox acpi: Move acpi_write_tables() to a generic header 2022-02-11 11:29:23 -05:00
sh dts: automatically build necessary .dtb files 2022-02-09 12:26:12 -07:00
x86 spl: x86: Correct the binman symbols for SPL 2022-02-22 10:05:44 -07:00
xtensa dts: automatically build necessary .dtb files 2022-02-09 12:26:12 -07:00
.gitignore
Kconfig Convert CONFIG_SCSI_AHCI_PLAT et al to Kconfig 2022-02-09 09:16:48 -05:00
u-boot-elf.lds arch: Add explicit linker script for u-boot-elf 2020-04-03 11:52:55 -04:00