From: Lennert Buytenhek Date: Wed, 23 Dec 2009 15:19:56 +0000 (+0100) Subject: [ARM] Orion: fix PCIe inbound window programming when RAM size is not a power of two X-Git-Tag: firefly_0821_release~9833^2~3285^2~2^2~3 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7788cd5557766d49343088b2edc544b186e2fe53;p=firefly-linux-kernel-4.4.55.git [ARM] Orion: fix PCIe inbound window programming when RAM size is not a power of two The PCIe inbound window size is supposed to be a power of two. If the total amount of RAM installed in the system is not a power of two, round it up such that it is. Signed-off-by: Lennert Buytenhek Signed-off-by: Nicolas Pitre --- diff --git a/arch/arm/plat-orion/pcie.c b/arch/arm/plat-orion/pcie.c index d41d41d78ad9..54c84a492a0f 100644 --- a/arch/arm/plat-orion/pcie.c +++ b/arch/arm/plat-orion/pcie.c @@ -132,6 +132,12 @@ static void __init orion_pcie_setup_wins(void __iomem *base, size += cs->size; } + /* + * Round up 'size' to the nearest power of two. + */ + if ((size & (size - 1)) != 0) + size = 1 << fls(size); + /* * Setup BAR[1] to all DRAM banks. */