• Bjorn Helgaas's avatar
    sparc/PCI: Request legacy VGA framebuffer only for VGA devices · c2eead05
    Bjorn Helgaas authored
    Previously we unconditionally requested the legacy VGA framebuffer (bus
    address 0xa0000-0xbffff) before we even know what PCI devices are present,
    in these paths:
    
      pci_fire_pbm_init, schizo_pbm_init, pci_sun4v_pbm_init, psycho_pbm_init_common
        pci_determine_mem_io_space
          pci_register_legacy_regions
            p->start = mem_res->start + 0xa0000
            request_resource(mem_res, p)    # claim VGA framebuffer
        pci_scan_one_pbm
          pci_of_scan_bus                   # scan DT for PCI devices
          pci_claim_bus_resources           # claim PCI device BARs
    
    If we found a PCI device with a BAR or bridge window that overlapped the
    framebuffer area, we complained about not being able to claim the BAR,
    e.g.,
    
      pci 0000:00:01.0: can't claim BAR 8 [mem 0x1ff00000000-0x1ffbfffffff]: address conflict with Video RAM area [??? 0x1ff000a0000-0x1ff000bffff flags 0x80000000]
      pci 0000:02:01.0: can't claim BAR 8 [mem 0x1ff00100000-0x1ff028fffff]: no compatible bridge window
      pci 0000:03:0f.0: can't claim BAR 8 [mem 0x1ff00100000-0x1ff028fffff]: no compatible bridge window
      pci 0000:04:04.0: can't claim BAR 1 [mem 0x1ff02808000-0x1ff02808fff]: no compatible bridge window
    
    This may make the conflicting device unusable because we try not to enable
    devices that have unassigned or conflicting BARs, e.g.,
    
      qla1280 0000:04:04.0: can't ioremap BAR 1: [mem size 0x00001000]
      qla1280: Unable to map I/O memory
    
    If there is no VGA device in the same PCI segment, there's no reason to
    reserve the framebuffer and there's no conflict.  If there *is* a VGA
    device in the same segment, both the VGA device and the device with an
    overlapping BAR may respond to the framebuffer addresses, which may cause
    bus errors.
    
    Request the legacy framebuffer area only when we actually find a VGA
    device.  The fact that VGA devices use the legacy framebuffer even though
    it's not reported in a BAR is not sparc-specific, so the reservation of
    that area could be made more generic in the PCI core eventually.
    
    Note that on some systems, e.g., Blade 100, we still report a conflict
    between an ISA bridge (00:07.0) and a VGA device (00:13.0):
    
      pci_bus 0000:00: root bus resource [mem 0x1ff00000000-0x1ffffffffff] (bus address [0x00000000-0xffffffff])
      pci 0000:00:07.0: reg 0x14: [mem 0x1ff00000000-0x1ff000fffff]
      pci 0000:00:13.0: can't claim VGA legacy [mem 0x1ff000a0000-0x1ff000bffff]: address conflict with 0000:00:07.0 [mem 0x1ff00000000-0x1ff000fffff]
    
    This is probably harmless, but if the VGA device and something behind the
    ISA bridge both responded to reads of the framebuffer, it would cause a bus
    error.
    
    Link: https://lkml.kernel.org/r/alpine.LRH.2.21.1804112323170.25495@math.ut.ee
    Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=117191#c35Reported-by: default avatarMeelis Roos <mroos@linux.ee>
    Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
    c2eead05
pci.c 29.1 KB