Skip to content
  • Russell King's avatar
    8fe55ef2
    PCI: Dynamically map ECAM regions · 8fe55ef2
    Russell King authored
    
    
    Attempting to boot 32-bit ARM kernels under QEMU's 3.x virt models fails
    when we have more than 512M of RAM in the model as we run out of vmalloc
    space for the PCI ECAM regions. This failure will be silent when running
    libvirt, as the console in that situation is a PCI device.
    
    In this configuration, the kernel maps the whole ECAM, which QEMU sets up
    for 256 buses, even when maybe only seven buses are in use.  Each bus uses
    1M of ECAM space, and ioremap() adds an additional guard page between
    allocations. The kernel vmap allocator will align these regions to 512K,
    resulting in each mapping eating 1.5M of vmalloc space. This means we need
    384M of vmalloc space just to map all of these, which is very wasteful of
    resources.
    
    Fix this by only mapping the ECAM for buses we are going to be using.  In
    my setups, this is around seven buses in most guests, which is 10.5M of
    vmalloc space - way smaller than the 384M that would otherwise be required.
    This also means that the kernel can boot without forcing extra RAM into
    highmem with the vmalloc= argument, or decreasing the virtual RAM available
    to the guest.
    
    Suggested-by: default avatarArnd Bergmann <arnd@arndb.de>
    Link: https://lore.kernel.org/r/E1lhCAV-0002yb-50@rmk-PC.armlinux.org.uk
    
    
    Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
    Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
    Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
    8fe55ef2
    PCI: Dynamically map ECAM regions
    Russell King authored
    
    
    Attempting to boot 32-bit ARM kernels under QEMU's 3.x virt models fails
    when we have more than 512M of RAM in the model as we run out of vmalloc
    space for the PCI ECAM regions. This failure will be silent when running
    libvirt, as the console in that situation is a PCI device.
    
    In this configuration, the kernel maps the whole ECAM, which QEMU sets up
    for 256 buses, even when maybe only seven buses are in use.  Each bus uses
    1M of ECAM space, and ioremap() adds an additional guard page between
    allocations. The kernel vmap allocator will align these regions to 512K,
    resulting in each mapping eating 1.5M of vmalloc space. This means we need
    384M of vmalloc space just to map all of these, which is very wasteful of
    resources.
    
    Fix this by only mapping the ECAM for buses we are going to be using.  In
    my setups, this is around seven buses in most guests, which is 10.5M of
    vmalloc space - way smaller than the 384M that would otherwise be required.
    This also means that the kernel can boot without forcing extra RAM into
    highmem with the vmalloc= argument, or decreasing the virtual RAM available
    to the guest.
    
    Suggested-by: default avatarArnd Bergmann <arnd@arndb.de>
    Link: https://lore.kernel.org/r/E1lhCAV-0002yb-50@rmk-PC.armlinux.org.uk
    
    
    Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
    Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
    Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
Loading