]> git.karo-electronics.de Git - karo-tx-linux.git/commit
ARM: cns3xxx: pci: avoid potential stack overflow
authorArnd Bergmann <arnd@arndb.de>
Wed, 7 Oct 2015 20:05:49 +0000 (22:05 +0200)
committerArnd Bergmann <arnd@arndb.de>
Thu, 8 Oct 2015 14:32:48 +0000 (16:32 +0200)
commit498a92d42596a7a32c042319eb62a4c3d8081cf1
treefa0a3daef1c40033e224400de2a9ef4d9bc54ed9
parent049e6dde7e57f0054fdc49102e7ef4830c698b46
ARM: cns3xxx: pci: avoid potential stack overflow

The cns3xxx_pcie_hw_init function uses excessive kernel
stack space because of a hack that puts a fake struct
pci_sys_data and struct pci_bus on the stack in order to
call the generic pci_bus_read_config accessors, which causes
a warning in ARM allmodconfig builds:

arch/arm/mach-cns3xxx/pcie.c:266:1: warning: the frame size of 1080 bytes is larger than 1024 bytes

I've spent a few hours trying to find out what exactly this
code is wants to achieve here. The obvious part is setting
up the host_regs using config space accessors, and this can
simply be changed to use direct MMIO accesses, as I do
in this patch.

The second part is how the driver sets up the Max_Read_Request_Size
value for the first device/function on bus 1, i.e. the device
plugged directly into the PCIe root port.
For all I can tell, this is in fact incomplete, as it does not
perform the same setting on devices attached to a PCIe switch,
or multi-function devices.
The solution for this part fortunately is even easier: if we
just set the global pcie_bus_config variable to PCIE_BUS_PEER2PEER,
all PCIe devices in the system are limited to 128 byte MPS, which
in turn limits the MRRS to 128 bytes for all devices, and we
no longer even need to touch any devices.

With those two changes in place, we no longer need the fake
pci_sys_data/pci_bus structures for faking config space writes,
and the stack usage goes down as well.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Krzysztof Halasa <khalasa@piap.pl>
arch/arm/mach-cns3xxx/pcie.c