• Vladimir Murzin's avatar
    ARM: 8712/1: NOMMU: Use more MPU regions to cover memory · 5c9d9a1b
    Vladimir Murzin authored
    PMSAv7 defines curious alignment requirements to the regions:
    - size must be power of 2, and
    - region start must be aligned to the region size
    
    Because of that we currently adjust lowmem bounds plus we assign
    only one MPU region to cover memory all these lead to significant amount of
    memory could be wasted. As an example, consider 64Mb of memory at
    0x70000000 - it fits alignment requirements nicely; now, imagine that
    2Mb of memory is reserved for coherent DMA allocation, so now Linux is
    expected to see 62Mb of memory... and here annoying thing happens -
    memory gets truncated to 32Mb (we've lost 30Mb!), i.e. MPU layout
    looks like:
    
    0: base 0x70000000, size 0x2000000
    
    This patch tries to allocate as much as possible MPU slots to minimise
    amount of truncated memory. Moreover, with this patch MPU subregions
    starting to get used. MPU subregions allow us reduce the number of MPU
    slots used. For example given above, MPU layout looks like:
    
    0: base 0x70000000, size 0x2000000
    1: base 0x72000000, size 0x1000000
    2: base 0x73000000, size 0x1000000, disable subreg 7 (0x73e00000 - 0x73ffffff)
    
    Where without subregions we'd get:
    
    0: base 0x70000000, size 0x2000000
    1: base 0x72000000, size 0x1000000
    2: base 0x73000000, size 0x800000
    3: base 0x73800000, size 0x400000
    4: base 0x73c00000, size 0x200000
    
    To achieve better layout we fist try to cover specified memory as is
    (maybe with help of subregions) and if we failed, we truncate memory
    to fit alignment requirements (so it occupies one MPU slot) and
    perform one more attempt with the reminder, and so on till we either
    cover all memory or run out of MPU slots.
    Tested-by: default avatarSzemző András <sza@esh.hu>
    Tested-by: default avatarAlexandre TORGUE <alexandre.torgue@st.com>
    Tested-by: default avatarBenjamin Gaignard <benjamin.gaignard@linaro.org>
    Signed-off-by: default avatarVladimir Murzin <vladimir.murzin@arm.com>
    Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
    5c9d9a1b
mpu.h 2.08 KB