linux/arch/arm
Thomas Petazzoni d7d5a43c0d ARM: mvebu: fix overlap of Crypto SRAM with PCIe memory window
When the Crypto SRAM mappings were added to the Device Tree files
describing the Armada XP boards in commit c466d997bb ("ARM: mvebu:
define crypto SRAM ranges for all armada-xp boards"), the fact that
those mappings were overlaping with the PCIe memory aperture was
overlooked. Due to this, we currently have for all Armada XP platforms
a situation that looks like this:

Memory mapping on Armada XP boards with internal registers at
0xf1000000:

 - 0x00000000 -> 0xf0000000	3.75G 	RAM
 - 0xf0000000 -> 0xf1000000	16M	NOR flashes (AXP GP / AXP DB)
 - 0xf1000000 -> 0xf1100000	1M	internal registers
 - 0xf8000000 -> 0xffe0000	126M	PCIe memory aperture
 - 0xf8100000 -> 0xf8110000	64KB	Crypto SRAM #0	=> OVERLAPS WITH PCIE !
 - 0xf8110000 -> 0xf8120000	64KB	Crypto SRAM #1	=> OVERLAPS WITH PCIE !
 - 0xffe00000 -> 0xfff00000	1M	PCIe I/O aperture
 - 0xfff0000  -> 0xffffffff	1M	BootROM

The overlap means that when PCIe devices are added, depending on their
memory window needs, they might or might not be mapped into the
physical address space. Indeed, they will not be mapped if the area
allocated in the PCIe memory aperture by the PCI core overlaps with
one of the Crypto SRAM. Typically, a Intel IGB PCIe NIC that needs 8MB
of PCIe memory will see its PCIe memory window allocated from
0xf80000000 for 8MB, which overlaps with the Crypto SRAM windows. Due
to this, the PCIe window is not created, and any attempt to access the
PCIe window makes the kernel explode:

[    3.302213] igb: Copyright (c) 2007-2014 Intel Corporation.
[    3.307841] pci 0000:00:09.0: enabling device (0140 -> 0143)
[    3.313539] mvebu_mbus: cannot add window '4:f8', conflicts with another window
[    3.320870] mvebu-pcie soc:pcie-controller: Could not create MBus window at [mem 0xf8000000-0xf87fffff]: -22
[    3.330811] Unhandled fault: external abort on non-linefetch (0x1008) at 0xf08c0018

This problem does not occur on Armada 370 boards, because we use the
following memory mapping (for boards that have internal registers at
0xf1000000):

 - 0x00000000 -> 0xf0000000	3.75G 	RAM
 - 0xf0000000 -> 0xf1000000	16M	NOR flashes (AXP GP / AXP DB)
 - 0xf1000000 -> 0xf1100000	1M	internal registers
 - 0xf1100000 -> 0xf1110000	64KB	Crypto SRAM #0 => OK !
 - 0xf8000000 -> 0xffe0000	126M	PCIe memory
 - 0xffe00000 -> 0xfff00000	1M	PCIe I/O
 - 0xfff0000  -> 0xffffffff	1M	BootROM

Obviously, the solution is to align the location of the Crypto SRAM
mappings of Armada XP to be similar with the ones on Armada 370, i.e
have them between the "internal registers" area and the beginning of
the PCIe aperture.

However, we have a special case with the OpenBlocks AX3-4 platform,
which has a 128 MB NOR flash. Currently, this NOR flash is mapped from
0xf0000000 to 0xf8000000. This is possible because on OpenBlocks
AX3-4, the internal registers are not at 0xf1000000. And this explains
why the Crypto SRAM mappings were not configured at the same place on
Armada XP.

Hence, the solution is two-fold:

 (1) Move the NOR flash mapping on Armada XP OpenBlocks AX3-4 from
     0xe8000000 to 0xf0000000. This frees the 0xf0000000 ->
     0xf80000000 space.

 (2) Move the Crypto SRAM mappings on Armada XP to be similar to
     Armada 370 (except of course that Armada XP has two Crypto SRAM
     and not one).

After this patch, the memory mapping on Armada XP boards with
registers at 0xf1 is:

 - 0x00000000 -> 0xf0000000	3.75G 	RAM
 - 0xf0000000 -> 0xf1000000	16M	NOR flashes (AXP GP / AXP DB)
 - 0xf1000000 -> 0xf1100000	1M	internal registers
 - 0xf1100000 -> 0xf1110000	64KB	Crypto SRAM #0
 - 0xf1110000 -> 0xf1120000	64KB	Crypto SRAM #1
 - 0xf8000000 -> 0xffe0000	126M	PCIe memory
 - 0xffe00000 -> 0xfff00000	1M	PCIe I/O
 - 0xfff0000  -> 0xffffffff	1M	BootROM

And the memory mapping for the special case of the OpenBlocks AX3-4
(internal registers at 0xd0000000, NOR of 128 MB):

 - 0x00000000 -> 0xc0000000	3G 	RAM
 - 0xd0000000 -> 0xd1000000	1M	internal registers
 - 0xe800000  -> 0xf0000000	128M	NOR flash
 - 0xf1100000 -> 0xf1110000	64KB	Crypto SRAM #0
 - 0xf1110000 -> 0xf1120000	64KB	Crypto SRAM #1
 - 0xf8000000 -> 0xffe0000	126M	PCIe memory
 - 0xffe00000 -> 0xfff00000	1M	PCIe I/O
 - 0xfff0000  -> 0xffffffff	1M	BootROM

Fixes: c466d997bb ("ARM: mvebu: define crypto SRAM ranges for all armada-xp boards")
Reported-by: Phil Sutter <phil@nwl.cc>
Cc: Phil Sutter <phil@nwl.cc>
Cc: <stable@vger.kernel.org>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Olof Johansson <olof@lixom.net>
2016-03-11 11:49:55 -08:00
..
boot ARM: mvebu: fix overlap of Crypto SRAM with PCIe memory window 2016-03-11 11:49:55 -08:00
common ARM: 8519/1: ICST: try other dividends than 1 2016-02-11 14:12:33 +00:00
configs fbdev fixes for v4.5 2016-02-12 09:39:34 -08:00
crypto arm/arm64: crypto: assure that ECB modes don't require an IV 2016-02-15 15:48:29 +00:00
firmware
include Merge branch 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2016-02-28 07:45:58 -08:00
kernel ARM: wire up copy_file_range() syscall 2016-01-27 18:14:46 +00:00
kvm arm/arm64: KVM: Feed initialized memory to MMIO accesses 2016-02-24 11:53:09 +00:00
lib arm, thp: remove infrastructure for handling splitting PMDs 2016-01-15 17:56:32 -08:00
mach-alpine
mach-asm9260
mach-at91 ARM: SoC cleanups for v4.5 2016-01-20 17:55:20 -08:00
mach-axxia
mach-bcm Merge tag 'bcm2835-soc-next-2015-12-28' of http://github.com/anholt/linux into next/soc 2015-12-31 17:37:12 +01:00
mach-berlin
mach-clps711x gpio: generic: factor into gpio_chip struct 2016-01-05 11:21:00 +01:00
mach-cns3xxx
mach-davinci ARM: SoC multiplatform code changes for v4.5 2016-01-20 18:03:56 -08:00
mach-digicolor
mach-dove
mach-ebsa110
mach-efm32
mach-ep93xx
mach-exynos ARM: SoC platform updates for v4.5 2016-01-20 18:10:05 -08:00
mach-footbridge ARM: debug-ll: rework footbridge handling 2015-12-15 23:43:29 +01:00
mach-gemini
mach-highbank
mach-hisi
mach-imx ARM: SoC platform updates for v4.5 2016-01-20 18:10:05 -08:00
mach-integrator Merge branch 'treewide/cleanup' into next/multiplatform 2015-12-18 17:07:52 +01:00
mach-iop13xx
mach-iop32x
mach-iop33x
mach-ixp4xx MTD updates for v4.5: 2016-01-13 11:25:54 -08:00
mach-keystone
mach-ks8695
mach-lpc18xx
mach-lpc32xx
mach-mediatek ARM: DT updates for v4.5 2016-01-20 18:16:29 -08:00
mach-meson
mach-mmp
mach-moxart
mach-mv78xx0
mach-mvebu
mach-mxs
mach-netx
mach-nomadik
mach-nspire
mach-omap1 ARM: SoC platform updates for v4.5 2016-01-20 18:10:05 -08:00
mach-omap2 ARM: OMAP2+: critical DRA7xx fix for v4.5-rc 2016-03-09 14:15:31 -08:00
mach-orion5x ARM: SoC multiplatform code changes for v4.5 2016-01-20 18:03:56 -08:00
mach-picoxcell
mach-prima2
mach-pxa ARM: SoC multiplatform code changes for v4.5 2016-01-20 18:03:56 -08:00
mach-qcom
mach-realview ARM: realview: use "depends on" instead of "if" after prompt 2016-02-01 12:19:10 -08:00
mach-rockchip Merge branch 'treewide/cleanup' into next/soc 2015-12-22 13:10:00 -08:00
mach-rpc
mach-s3c24xx ARM: s3c: simplify s3c_irqwake_{e,}intallow definition 2015-12-31 17:26:18 +01:00
mach-s3c64xx ARM: SoC multiplatform code changes for v4.5 2016-01-20 18:03:56 -08:00
mach-s5pv210
mach-sa1100 ARM: sa1100/simpad: Be sure to clamp return value 2015-12-22 14:57:50 -08:00
mach-shmobile ARM: shmobile: Remove shmobile_boot_arg 2016-02-17 18:27:21 +09:00
mach-socfpga
mach-spear
mach-sti ARM: SoC cleanups for v4.5 2016-01-20 17:55:20 -08:00
mach-stm32
mach-sunxi
mach-tango ARM: tango: use "depends on" instead of "if" after prompt 2016-02-01 12:18:49 -08:00
mach-tegra ARM: tegra: Core SoC changes for v4.5-rc1 2016-01-12 10:14:52 -08:00
mach-u300
mach-uniphier Merge branch 'treewide/cleanup' into next/soc 2015-12-22 13:10:00 -08:00
mach-ux500 ARM: SoC cleanups for v4.5 2016-01-20 17:55:20 -08:00
mach-versatile ARM: versatile: convert to multi-platform 2015-12-15 23:54:48 +01:00
mach-vexpress
mach-vt8500
mach-w90x900
mach-zx
mach-zynq Merge branch 'treewide/cleanup' into next/soc 2015-12-22 13:10:00 -08:00
mm mm: ASLR: use get_random_long() 2016-02-27 10:28:52 -08:00
net ARM: net: bpf: fix zero right shift 2016-01-06 01:32:09 -05:00
nwfpe
oprofile
plat-iop
plat-omap
plat-orion
plat-pxa
plat-samsung ARM: SoC multiplatform code changes for v4.5 2016-01-20 18:03:56 -08:00
plat-versatile
probes
tools
vdso
vfp
xen xen/arm: set the system time in Xen via the XENPF_settime64 hypercall 2015-12-21 14:40:58 +00:00
Kconfig Merge branch 'akpm' (patches from Andrew) 2016-01-21 12:32:08 -08:00
Kconfig-nommu
Kconfig.debug ARM: SoC fixes for v4.5 merge window 2016-01-22 17:26:00 -08:00
Makefile ARM: SoC defconfig updates for v4.5 2016-01-20 18:29:13 -08:00