• Jia He's avatar
    dma-mapping: fix dma_addressing_limited() if dma_range_map can't cover all system RAM · a409d960
    Jia He authored
    There is an unusual case that the range map covers right up to the top
    of system RAM, but leaves a hole somewhere lower down. Then it prevents
    the nvme device dma mapping in the checking path of phys_to_dma() and
    causes the hangs at boot.
    
    E.g. On an Armv8 Ampere server, the dsdt ACPI table is:
     Method (_DMA, 0, Serialized)  // _DMA: Direct Memory Access
                {
                    Name (RBUF, ResourceTemplate ()
                    {
                        QWordMemory (ResourceConsumer, PosDecode, MinFixed,
    MaxFixed, Cacheable, ReadWrite,
                            0x0000000000000000, // Granularity
                            0x0000000000000000, // Range Minimum
                            0x00000000FFFFFFFF, // Range Maximum
                            0x0000000000000000, // Translation Offset
                            0x0000000100000000, // Length
                            ,, , AddressRangeMemory, TypeStatic)
                        QWordMemory (ResourceConsumer, PosDecode, MinFixed,
    MaxFixed, Cacheable, ReadWrite,
                            0x0000000000000000, // Granularity
                            0x0000006010200000, // Range Minimum
                            0x000000602FFFFFFF, // Range Maximum
                            0x0000000000000000, // Translation Offset
                            0x000000001FE00000, // Length
                            ,, , AddressRangeMemory, TypeStatic)
                        QWordMemory (ResourceConsumer, PosDecode, MinFixed,
    MaxFixed, Cacheable, ReadWrite,
                            0x0000000000000000, // Granularity
                            0x00000060F0000000, // Range Minimum
                            0x00000060FFFFFFFF, // Range Maximum
                            0x0000000000000000, // Translation Offset
                            0x0000000010000000, // Length
                            ,, , AddressRangeMemory, TypeStatic)
                        QWordMemory (ResourceConsumer, PosDecode, MinFixed,
    MaxFixed, Cacheable, ReadWrite,
                            0x0000000000000000, // Granularity
                            0x0000007000000000, // Range Minimum
                            0x000003FFFFFFFFFF, // Range Maximum
                            0x0000000000000000, // Translation Offset
                            0x0000039000000000, // Length
                            ,, , AddressRangeMemory, TypeStatic)
                    })
    
    But the System RAM ranges are:
    cat /proc/iomem |grep -i ram
    90000000-91ffffff : System RAM
    92900000-fffbffff : System RAM
    880000000-fffffffff : System RAM
    8800000000-bff5990fff : System RAM
    bff59d0000-bff5a4ffff : System RAM
    bff8000000-bfffffffff : System RAM
    So some RAM ranges are out of dma_range_map.
    
    Fix it by checking whether each of the system RAM resources can be
    properly encompassed within the dma_range_map.
    Signed-off-by: default avatarJia He <justin.he@arm.com>
    Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
    a409d960
mapping.c 25.1 KB