diff mbox

sparc64 PCI BAR allocation is still problematic

Message ID 20180410185610.GD24642@bhelgaas-glaptop.roam.corp.google.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Bjorn Helgaas April 10, 2018, 6:56 p.m. UTC
On Tue, Apr 10, 2018 at 09:45:09PM +0300, Meelis Roos wrote:
> > commit bc270e0028cd0856d5689cab38f0071f0d07b3be
> > Author: Bjorn Helgaas <bhelgaas@google.com>
> > Date:   Tue Apr 10 08:47:34 2018 -0500
> > 
> >     sparc/PCI: Request legacy VGA framebuffer only for VGA devices
> 
> Thank you.
> 
> It does not seem to compile for me:
> 
>   CC      arch/sparc/kernel/pci.o
> arch/sparc/kernel/pci.c: In function ‘pci_claim_legacy_resources’:
> arch/sparc/kernel/pci.c:644:26: error: ‘bus’ undeclared (first use in this function)
>   pcibios_bus_to_resource(bus, p, &region);

Oops, sorry, I can't easily compile test it.  Here's an updated patch:

commit a9ded309cbf3f57e9979848fd0aa0ffacdf11f1a
Author: Bjorn Helgaas <bhelgaas@google.com>
Date:   Tue Apr 10 08:47:34 2018 -0500

    sparc/PCI: Request legacy VGA framebuffer only for VGA devices
    
    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 that overlapped the framebuffer area,
    we complained about not being able to claim the BAR, e.g.,
    
      pci_bus 0002:00: root bus resource [mem 0x7ff00000000-0x7ffffffffff] (bus address [0x00000000-0xffffffff])
      pci 0002:00:07.0: can't claim BAR 1 [mem 0x7ff00000000-0x7ff000fffff]: address conflict with Video RAM area [??? 0x7ff000a0000-0x7ff000bffff flags 0x80000000]
    
    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.  This is not sparc-specific and could be made more generic in the
    PCI core eventually.
    
    Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=117191
    Reported-by: Meelis Roos <mroos@linux.ee>

Comments

Meelis Roos April 11, 2018, 7:59 a.m. UTC | #1
> Oops, sorry, I can't easily compile test it.  Here's an updated patch:
> 
> commit a9ded309cbf3f57e9979848fd0aa0ffacdf11f1a
> Author: Bjorn Helgaas <bhelgaas@google.com>
> Date:   Tue Apr 10 08:47:34 2018 -0500

Thanks, this patch compiles and works - Video RAM related BAR allocation 
errors are gone.

Hera are the /proc/iomem's but unfortunately the physical 
addresses have been censored by security:

Netra X1: no BAR errors
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
  00000000-00000000 : Kernel code
  00000000-00000000 : Kernel data
  00000000-00000000 : Kernel bss
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : /pci@1f,0
  00000000-00000000 : 0000:00:0c.0
    00000000-00000000 : tulip
  00000000-00000000 : 0000:00:05.0
    00000000-00000000 : tulip
  00000000-00000000 : 0000:00:0c.0
  00000000-00000000 : 0000:00:05.0
  00000000-00000000 : 0000:00:0a.0
    00000000-00000000 : ohci_hcd
  00000000-00000000 : IOMMU

Fire V100: no BAR errors
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
  00000000-00000000 : Kernel code
  00000000-00000000 : Kernel data
  00000000-00000000 : Kernel bss
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : /pci@1f,0
  00000000-00000000 : 0000:00:0c.0
    00000000-00000000 : tulip
  00000000-00000000 : 0000:00:05.0
    00000000-00000000 : tulip
  00000000-00000000 : 0000:00:0c.0
  00000000-00000000 : 0000:00:05.0
  00000000-00000000 : 0000:00:0a.0
  00000000-00000000 : IOMMU

Netra T1-105: no BAR errors, qla1280 loads fine.
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
  00000000-00000000 : Kernel code
  00000000-00000000 : Kernel data
  00000000-00000000 : Kernel bss
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : /pci@1f,0
  00000000-00000000 : PCI Bus 0000:02
    00000000-00000000 : PCI Bus 0000:03
      00000000-00000000 : PCI Bus 0000:04
        00000000-00000000 : 0000:04:00.0
        00000000-00000000 : 0000:04:00.0
        00000000-00000000 : 0000:04:00.1
          00000000-00000000 : sunhme
        00000000-00000000 : 0000:04:04.0
        00000000-00000000 : 0000:04:04.0
  00000000-00000000 : IOMMU
  00000000-00000000 : PCI Bus 0000:01
    00000000-00000000 : 0000:01:01.1
      00000000-00000000 : sunhme
    00000000-00000000 : 0000:01:02.0
      00000000-00000000 : sym53c8xx
    00000000-00000000 : 0000:01:02.0
      00000000-00000000 : sym53c8xx
    00000000-00000000 : 0000:01:03.1
      00000000-00000000 : sunhme
    00000000-00000000 : eeprom
    00000000-00000000 : su
    00000000-00000000 : su
    00000000-00000000 : power
    00000000-00000000 : auxio

Netra T1-200: no BAR errors
00000000-00000000 : System RAM
00000000-00000000 : System RAM
  00000000-00000000 : Kernel code
  00000000-00000000 : Kernel data
  00000000-00000000 : Kernel bss
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : /pci@1f,0
  00000000-00000000 : PCI Bus 0000:02
    00000000-00000000 : 0000:02:08.0
      00000000-00000000 : sym53c8xx
    00000000-00000000 : 0000:02:08.0
      00000000-00000000 : sym53c8xx
    00000000-00000000 : 0000:02:08.1
      00000000-00000000 : sym53c8xx
    00000000-00000000 : 0000:02:08.1
      00000000-00000000 : sym53c8xx
    00000000-00000000 : 0000:02:05.0
      00000000-00000000 : qla2xxx
    00000000-00000000 : 0000:02:05.0
  00000000-00000000 : IOMMU
  00000000-00000000 : PCI Bus 0000:01
    00000000-00000000 : 0000:01:0c.1
      00000000-00000000 : sungem
    00000000-00000000 : 0000:01:05.1
      00000000-00000000 : sungem
    00000000-00000000 : 0000:01:0c.1
    00000000-00000000 : 0000:01:0c.3
    00000000-00000000 : 0000:01:0c.3
      00000000-00000000 : ohci_hcd
    00000000-00000000 : 0000:01:05.1
    00000000-00000000 : 0000:01:05.3
    00000000-00000000 : 0000:01:05.3
      00000000-00000000 : ohci_hcd
    00000000-00000000 : eeprom

Fire V120: no BAR errors
00000000-00000000 : System RAM
  00000000-00000000 : Kernel code
  00000000-00000000 : Kernel data
  00000000-00000000 : Kernel bss
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : /pci@1f,0
  00000000-00000000 : PCI Bus 0000:02
    00000000-00000000 : 0000:02:08.0
      00000000-00000000 : sym53c8xx
    00000000-00000000 : 0000:02:08.0
      00000000-00000000 : sym53c8xx
    00000000-00000000 : 0000:02:08.1
      00000000-00000000 : sym53c8xx
    00000000-00000000 : 0000:02:08.1
      00000000-00000000 : sym53c8xx
  00000000-00000000 : IOMMU
  00000000-00000000 : PCI Bus 0000:01
    00000000-00000000 : 0000:01:0c.1
      00000000-00000000 : sungem
    00000000-00000000 : 0000:01:05.1
      00000000-00000000 : sungem
    00000000-00000000 : 0000:01:0c.1
    00000000-00000000 : 0000:01:0c.3
    00000000-00000000 : 0000:01:0c.3
      00000000-00000000 : ohci_hcd
    00000000-00000000 : 0000:01:05.1
    00000000-00000000 : 0000:01:05.3
    00000000-00000000 : 0000:01:05.3
      00000000-00000000 : ohci_hcd
    00000000-00000000 : eeprom

Fire V210: Video RAM BAR error is gone, these are still here:
[    5.061083] pci 0001:00:07.0: can't claim BAR 0 [io  0x7fe01000000-0x7fe0100ffff]: address conflict with 0001:00:06.0 [io  0x7fe01000600-0x7fe0100061f]
[    5.061334] pci 0001:00:07.0: can't claim BAR 2 [mem 0x7ff00000000-0x7ff000fffff]: address conflict with 0001:00:07.0 [mem 0x7ff00000000-0x7ff000fffff]

00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
  00000000-00000000 : Kernel code
  00000000-00000000 : Kernel data
  00000000-00000000 : Kernel bss
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : jbusmc
00000000-00000000 : jbusmc
00000000-00000000 : /pci@1d,700000
  00000000-00000000 : 0003:00:02.0
    00000000-00000000 : tg3
  00000000-00000000 : 0003:00:02.1
    00000000-00000000 : tg3
  00000000-00000000 : 0003:00:02.0
    00000000-00000000 : tg3
  00000000-00000000 : 0003:00:02.1
    00000000-00000000 : tg3
  00000000-00000000 : IOMMU
00000000-00000000 : /pci@1c,600000
  00000000-00000000 : 0002:00:02.0
    00000000-00000000 : sym53c8xx
  00000000-00000000 : 0002:00:02.0
    00000000-00000000 : sym53c8xx
  00000000-00000000 : 0002:00:02.1
    00000000-00000000 : sym53c8xx
  00000000-00000000 : 0002:00:02.1
    00000000-00000000 : sym53c8xx
  00000000-00000000 : IOMMU
00000000-00000000 : /pci@1f,700000
  00000000-00000000 : 0000:00:02.0
    00000000-00000000 : tg3
  00000000-00000000 : 0000:00:02.1
    00000000-00000000 : tg3
  00000000-00000000 : 0000:00:02.0
    00000000-00000000 : tg3
  00000000-00000000 : 0000:00:02.1
    00000000-00000000 : tg3
  00000000-00000000 : IOMMU
00000000-00000000 : /pci@1e,600000
  00000000-00000000 : 0001:00:07.0
  00000000-00000000 : 0001:00:0a.0
  00000000-00000000 : IOMMU

Fire V240: Video RAM BAR errors is gone, these are still here:
[    5.530237] pci 0001:00:07.0: can't claim BAR 0 [io  0x7fe01000000-0x7fe0100ffff]: address conflict with 0001:00:06.0 [io  0x7fe01000600-0x7fe0100061f]
[    5.530389] pci 0001:00:07.0: can't claim BAR 2 [mem 0x7ff00000000-0x7ff000fffff]: address conflict with 0001:00:07.0 [mem 0x7ff00000000-0x7ff000fffff]

00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
  00000000-00000000 : Kernel code
  00000000-00000000 : Kernel data
  00000000-00000000 : Kernel bss
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : jbusmc
00000000-00000000 : jbusmc
00000000-00000000 : /pci@1d,700000
  00000000-00000000 : 0003:00:02.0
    00000000-00000000 : tg3
  00000000-00000000 : 0003:00:02.1
    00000000-00000000 : tg3
  00000000-00000000 : 0003:00:02.0
    00000000-00000000 : tg3
  00000000-00000000 : 0003:00:02.1
    00000000-00000000 : tg3
  00000000-00000000 : IOMMU
00000000-00000000 : /pci@1c,600000
  00000000-00000000 : 0002:00:02.0
    00000000-00000000 : sym53c8xx
  00000000-00000000 : 0002:00:02.0
    00000000-00000000 : sym53c8xx
  00000000-00000000 : 0002:00:02.1
    00000000-00000000 : sym53c8xx
  00000000-00000000 : 0002:00:02.1
    00000000-00000000 : sym53c8xx
  00000000-00000000 : IOMMU
00000000-00000000 : /pci@1f,700000
  00000000-00000000 : 0000:00:02.0
    00000000-00000000 : tg3
  00000000-00000000 : 0000:00:02.1
    00000000-00000000 : tg3
  00000000-00000000 : 0000:00:02.0
    00000000-00000000 : tg3
  00000000-00000000 : 0000:00:02.1
    00000000-00000000 : tg3
  00000000-00000000 : IOMMU
00000000-00000000 : /pci@1e,600000
  00000000-00000000 : 0001:00:07.0
  00000000-00000000 : 0001:00:03.0
    00000000-00000000 : skge
  00000000-00000000 : 0001:00:03.0
  00000000-00000000 : 0001:00:0a.0
  00000000-00000000 : IOMMU

Fire V440: Video RAM BAR error is gone, these are still here:
[    5.082920] pci 0002:00:07.0: can't claim BAR 0 [io  0x7fe01000000-0x7fe0100ffff]: address conflict with 0002:00:06.0 [io  0x7fe01000600-0x7fe0100061f]
[    5.082945] pci 0002:00:07.0: can't claim BAR 2 [mem 0x7ff00000000-0x7ff000fffff]: address conflict with 0002:00:07.0 [mem 0x7ff00000000-0x7ff000fffff]

00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
  00000000-00000000 : Kernel code
  00000000-00000000 : Kernel data
  00000000-00000000 : Kernel bss
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : jbusmc
00000000-00000000 : jbusmc
00000000-00000000 : jbusmc
00000000-00000000 : jbusmc
00000000-00000000 : /pci@1d,700000
  00000000-00000000 : IOMMU
00000000-00000000 : /pci@1c,600000
  00000000-00000000 : 0000:00:02.0
  00000000-00000000 : 0000:00:02.0
    00000000-00000000 : eth0
  00000000-00000000 : IOMMU
00000000-00000000 : /pci@1f,700000
  00000000-00000000 : 0003:00:01.0
  00000000-00000000 : 0003:00:01.0
    00000000-00000000 : eth1
  00000000-00000000 : 0003:00:02.0
    00000000-00000000 : mpt
  00000000-00000000 : 0003:00:02.0
    00000000-00000000 : mpt
  00000000-00000000 : 0003:00:02.1
    00000000-00000000 : mpt
  00000000-00000000 : 0003:00:02.1
    00000000-00000000 : mpt
  00000000-00000000 : 0003:00:02.0
  00000000-00000000 : 0003:00:02.1
  00000000-00000000 : IOMMU
00000000-00000000 : /pci@1e,600000
  00000000-00000000 : 0002:00:07.0
  00000000-00000000 : 0002:00:0a.0
  00000000-00000000 : 0002:00:0b.0
  00000000-00000000 : IOMMU

Blade 100: Video RAM related BAR error is gnone, this is still here:
[    6.131499] pci 0000:00:07.0: can't claim BAR 0 [io  0x1fe02000000-0x1fe0200ffff]: address conflict with 0000:00:03.0 [io  0x1fe02000600-0x1fe0200061f]

00000000-00000000 : System RAM
  00000000-00000000 : Kernel code
  00000000-00000000 : Kernel data
  00000000-00000000 : Kernel bss
00000000-00000000 : System RAM
00000000-00000000 : System RAM
00000000-00000000 : /pci@1f,0
  00000000-00000000 : 0000:00:07.0
  00000000-00000000 : 0000:00:0c.1
    00000000-00000000 : sungem
  00000000-00000000 : 0000:00:0c.2
  00000000-00000000 : 0000:00:0c.2
  00000000-00000000 : 0000:00:08.0
  00000000-00000000 : 0000:00:13.0
  00000000-00000000 : 0000:00:13.0
  00000000-00000000 : 0000:00:0c.1
  00000000-00000000 : 0000:00:0c.2
  00000000-00000000 : 0000:00:0c.3
  00000000-00000000 : 0000:00:0c.3
    00000000-00000000 : ohci_hcd
  00000000-00000000 : PCI Bus 0000:01
    00000000-00000000 : 0000:01:00.0
      00000000-00000000 : sym53c8xx
    00000000-00000000 : 0000:01:02.0
    00000000-00000000 : 0000:01:02.0
  00000000-00000000 : 0000:00:13.0
    00000000-00000000 : atyfb
  00000000-00000000 : IOMMU
  00000000-00000000 : eeprom
Bjorn Helgaas April 11, 2018, 1:33 p.m. UTC | #2
On Wed, Apr 11, 2018 at 10:59:19AM +0300, Meelis Roos wrote:
> > Oops, sorry, I can't easily compile test it.  Here's an updated patch:
> > 
> > commit a9ded309cbf3f57e9979848fd0aa0ffacdf11f1a
> > Author: Bjorn Helgaas <bhelgaas@google.com>
> > Date:   Tue Apr 10 08:47:34 2018 -0500
> 
> Thanks, this patch compiles and works - Video RAM related BAR allocation 
> errors are gone.

Great, thanks!  I didn't mean to take up so much of your time testing
*all* of your systems :)

> Hera are the /proc/iomem's but unfortunately the physical 
> addresses have been censored by security:

If you look at /proc/iomem as root, you should see the actual
addresses.

If you have any systems with VGA, it would be useful to test one of
them.  

I took a quick look through your lspci logs, and it *looks* like the
Blade 100 has a VGA at 00:13.0, but I don't see the "Video RAM area"
entry in /proc/iomem that I expected:

> Blade 100: Video RAM related BAR error is gnone, this is still here:
> [    6.131499] pci 0000:00:07.0: can't claim BAR 0 [io  0x1fe02000000-0x1fe0200ffff]: address conflict with 0000:00:03.0 [io  0x1fe02000600-0x1fe0200061f]
> 
> 00000000-00000000 : System RAM
>   00000000-00000000 : Kernel code
>   00000000-00000000 : Kernel data
>   00000000-00000000 : Kernel bss
> 00000000-00000000 : System RAM
> 00000000-00000000 : System RAM
> 00000000-00000000 : /pci@1f,0
>   00000000-00000000 : 0000:00:07.0
>   00000000-00000000 : 0000:00:0c.1
>     00000000-00000000 : sungem
>   00000000-00000000 : 0000:00:0c.2
>   00000000-00000000 : 0000:00:0c.2
>   00000000-00000000 : 0000:00:08.0
>   00000000-00000000 : 0000:00:13.0
>   00000000-00000000 : 0000:00:13.0
>   00000000-00000000 : 0000:00:0c.1
>   00000000-00000000 : 0000:00:0c.2
>   00000000-00000000 : 0000:00:0c.3
>   00000000-00000000 : 0000:00:0c.3
>     00000000-00000000 : ohci_hcd
>   00000000-00000000 : PCI Bus 0000:01
>     00000000-00000000 : 0000:01:00.0
>       00000000-00000000 : sym53c8xx
>     00000000-00000000 : 0000:01:02.0
>     00000000-00000000 : 0000:01:02.0
>   00000000-00000000 : 0000:00:13.0
>     00000000-00000000 : atyfb
>   00000000-00000000 : IOMMU
>   00000000-00000000 : eeprom
Meelis Roos April 11, 2018, 2:40 p.m. UTC | #3
> On Wed, Apr 11, 2018 at 10:59:19AM +0300, Meelis Roos wrote:
> > > Oops, sorry, I can't easily compile test it.  Here's an updated patch:
> > > 
> > > commit a9ded309cbf3f57e9979848fd0aa0ffacdf11f1a
> > > Author: Bjorn Helgaas <bhelgaas@google.com>
> > > Date:   Tue Apr 10 08:47:34 2018 -0500
> > 
> > Thanks, this patch compiles and works - Video RAM related BAR allocation 
> > errors are gone.
> 
> Great, thanks!  I didn't mean to take up so much of your time testing
> *all* of your systems :)

Well, they compiled in parallel :)

> > Hera are the /proc/iomem's but unfortunately the physical 
> > addresses have been censored by security:
> 
> If you look at /proc/iomem as root, you should see the actual
> addresses.

Yes, that was it.

> If you have any systems with VGA, it would be useful to test one of
> them.  

This is Blade 100, with atyfb frame buffer:

# cat /proc/iomem 
00000000-7effdfff : System RAM
  00404000-0085aadf : Kernel code
  0085aae0-009b8a8f : Kernel data
  009f2000-00a37a37 : Kernel bss
7f000000-7fee5fff : System RAM
7ff04000-7ff0bfff : System RAM
1ff00000000-1ffffffffff : /pci@1f,0
  1ff00000000-1ff000fffff : 0000:00:07.0
  1ff00400000-1ff0041ffff : 0000:00:0c.1
    1ff00400000-1ff0041ffff : sungem
  1ff00420000-1ff00421fff : 0000:00:0c.2
  1ff00422000-1ff00423fff : 0000:00:0c.2
  1ff00424000-1ff00425fff : 0000:00:08.0
  1ff00426000-1ff00427fff : 0000:00:13.0
  1ff00440000-1ff0045ffff : 0000:00:13.0
  1ff00800000-1ff00bfffff : 0000:00:0c.1
  1ff00c00000-1ff00ffffff : 0000:00:0c.2
  1ff01000000-1ff013fffff : 0000:00:0c.3
  1ff02000000-1ff02ffffff : 0000:00:0c.3
    1ff02000000-1ff02ffffff : ohci_hcd
  1ff03000000-1ff030fffff : PCI Bus 0000:01
    1ff03000000-1ff03001fff : 0000:01:00.0
      1ff03000000-1ff03001fff : sym53c8xx
    1ff03002000-1ff03003fff : 0000:01:02.0
    1ff03010000-1ff0301ffff : 0000:01:02.0
  1ff04000000-1ff04ffffff : 0000:00:13.0
    1ff04000000-1ff04ffffff : atyfb
  1ffc0000000-1ffdfffffff : IOMMU
  1fff1000000-1fff1001fff : eeprom
 
> I took a quick look through your lspci logs, and it *looks* like the
> Blade 100 has a VGA at 00:13.0, but I don't see the "Video RAM area"
> entry in /proc/iomem that I expected:
> 
> > Blade 100: Video RAM related BAR error is gnone, this is still here:
> > [    6.131499] pci 0000:00:07.0: can't claim BAR 0 [io  0x1fe02000000-0x1fe0200ffff]: address conflict with 0000:00:03.0 [io  0x1fe02000600-0x1fe0200061f]
> > 
> > 00000000-00000000 : System RAM
> >   00000000-00000000 : Kernel code
> >   00000000-00000000 : Kernel data
> >   00000000-00000000 : Kernel bss
> > 00000000-00000000 : System RAM
> > 00000000-00000000 : System RAM
> > 00000000-00000000 : /pci@1f,0
> >   00000000-00000000 : 0000:00:07.0
> >   00000000-00000000 : 0000:00:0c.1
> >     00000000-00000000 : sungem
> >   00000000-00000000 : 0000:00:0c.2
> >   00000000-00000000 : 0000:00:0c.2
> >   00000000-00000000 : 0000:00:08.0
> >   00000000-00000000 : 0000:00:13.0
> >   00000000-00000000 : 0000:00:13.0
> >   00000000-00000000 : 0000:00:0c.1
> >   00000000-00000000 : 0000:00:0c.2
> >   00000000-00000000 : 0000:00:0c.3
> >   00000000-00000000 : 0000:00:0c.3
> >     00000000-00000000 : ohci_hcd
> >   00000000-00000000 : PCI Bus 0000:01
> >     00000000-00000000 : 0000:01:00.0
> >       00000000-00000000 : sym53c8xx
> >     00000000-00000000 : 0000:01:02.0
> >     00000000-00000000 : 0000:01:02.0
> >   00000000-00000000 : 0000:00:13.0
> >     00000000-00000000 : atyfb
> >   00000000-00000000 : IOMMU
> >   00000000-00000000 : eeprom
>
Bjorn Helgaas May 21, 2018, 8:10 p.m. UTC | #4
On Wed, Apr 11, 2018 at 10:59:19AM +0300, Meelis Roos wrote:
> Fire V210: Video RAM BAR error is gone, these are still here:
> [    5.061083] pci 0001:00:07.0: can't claim BAR 0 [io  0x7fe01000000-0x7fe0100ffff]: address conflict with 0001:00:06.0 [io  0x7fe01000600-0x7fe0100061f]
> [    5.061334] pci 0001:00:07.0: can't claim BAR 2 [mem 0x7ff00000000-0x7ff000fffff]: address conflict with 0001:00:07.0 [mem 0x7ff00000000-0x7ff000fffff]

From lspci (https://bugzilla.kernel.org/attachment.cgi?id=275239):

  0001:00:06.0 ULi Electronics Inc. M7101 Power Management Controller
    Region 0: [virtual] I/O ports at <unassigned> [size=16]
  0001:00:07.0 ISA bridge: ULi Electronics Inc. M1533/M1535/M1543 PCI to ISA Bridge
    Region 0: [virtual] I/O ports at 7fe01000000 [size=64K]
    Region 1: [virtual] Memory at 7ff00000000 (32-bit, non-prefetchable) [size=1M]
    Region 2: [virtual] Memory at 7ff00000000 (32-bit, non-prefetchable) [size=1M]

From dmesg log (https://bugzilla.kernel.org/attachment.cgi?id=275237):

  pci 0001:00:06.0: quirk: [io  0x7fe01000800-0x7fe0100083f] claimed by ali7101 ACPI
  pci 0001:00:06.0: quirk: [io  0x7fe01000600-0x7fe0100061f] claimed by ali7101 SMB

The 0001:00:07.0 BAR 0 conflict is with the ali7101 quirk.  I don't
know how to fix that.  The quirk doesn't match up with the M1543/M7101
docs I can find, but the quirk has been there forever and I don't
think we can safely change it.

The BAR 2 conflict is with 0001:00:07.0's own BAR 1.  I think those
come from OF, not directly from the hardware, and it looks like an OF
error that BAR 1 and BAR 2 are the same.

We could filter out duplicates like this if they cause a problem.  But
I'm not sure whether anything actually breaks because of this
conflict.

After the VGA framebuffer change, do you see anything that's still
broken (besides the "can't claim" messages, I mean)?

> Fire V240: Video RAM BAR errors is gone, these are still here:
> [    5.530237] pci 0001:00:07.0: can't claim BAR 0 [io  0x7fe01000000-0x7fe0100ffff]: address conflict with 0001:00:06.0 [io  0x7fe01000600-0x7fe0100061f]
> [    5.530389] pci 0001:00:07.0: can't claim BAR 2 [mem 0x7ff00000000-0x7ff000fffff]: address conflict with 0001:00:07.0 [mem 0x7ff00000000-0x7ff000fffff]

Looks the same as V210.

> Fire V440: Video RAM BAR error is gone, these are still here:
> [    5.082920] pci 0002:00:07.0: can't claim BAR 0 [io  0x7fe01000000-0x7fe0100ffff]: address conflict with 0002:00:06.0 [io  0x7fe01000600-0x7fe0100061f]
> [    5.082945] pci 0002:00:07.0: can't claim BAR 2 [mem 0x7ff00000000-0x7ff000fffff]: address conflict with 0002:00:07.0 [mem 0x7ff00000000-0x7ff000fffff]

Looks the same as V210.

> Blade 100: Video RAM related BAR error is gnone, this is still here:
> [    6.131499] pci 0000:00:07.0: can't claim BAR 0 [io  0x1fe02000000-0x1fe0200ffff]: address conflict with 0000:00:03.0 [io  0x1fe02000600-0x1fe0200061f]

Looks the same as V210, except that the firmware apparently doesn't
have the duplicate BAR 1/2 that the other boxes have.
diff mbox

Patch

diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 41b20edb427d..d5360e941620 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -624,6 +624,44 @@  static void pci_bus_register_of_sysfs(struct pci_bus *bus)
 		pci_bus_register_of_sysfs(child_bus);
 }
 
+static void pci_claim_legacy_resources(struct pci_dev *dev)
+{
+	struct pci_bus_region region;
+	struct resource *p, *root, *conflict;
+
+	if ((dev->class >> 8) != PCI_CLASS_DISPLAY_VGA)
+		return;
+
+	p = kzalloc(sizeof(*p), GFP_KERNEL);
+	if (!p)
+		return;
+
+	p->name = "Video RAM area";
+	p->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+
+	region.start = 0xa0000UL;
+	region.end = region.start + 0x1ffffUL;
+	pcibios_bus_to_resource(dev->bus, p, &region);
+
+	root = pci_find_parent_resource(dev, p);
+	if (!root) {
+		pci_info(dev, "can't claim VGA legacy %pR: no compatible bridge window\n", p);
+		goto err;
+	}
+
+	conflict = request_resource_conflict(root, p);
+	if (conflict) {
+		pci_info(dev, "can't claim VGA legacy %pR: address conflict with %s %pR\n",
+			 p, conflict->name, conflict);
+		goto err;
+	}
+
+	return;
+
+err:
+	kfree(p);
+}
+
 static void pci_claim_bus_resources(struct pci_bus *bus)
 {
 	struct pci_bus *child_bus;
@@ -648,6 +686,8 @@  static void pci_claim_bus_resources(struct pci_bus *bus)
 
 			pci_claim_resource(dev, i);
 		}
+
+		pci_claim_legacy_resources(dev);
 	}
 
 	list_for_each_entry(child_bus, &bus->children, node)
@@ -687,6 +727,7 @@  struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
 	pci_bus_register_of_sysfs(bus);
 
 	pci_claim_bus_resources(bus);
+
 	pci_bus_add_devices(bus);
 	return bus;
 }
diff --git a/arch/sparc/kernel/pci_common.c b/arch/sparc/kernel/pci_common.c
index 38d46bcc8634..9bb6a192ef3f 100644
--- a/arch/sparc/kernel/pci_common.c
+++ b/arch/sparc/kernel/pci_common.c
@@ -329,23 +329,6 @@  void pci_get_pbm_props(struct pci_pbm_info *pbm)
 	}
 }
 
-static void pci_register_legacy_regions(struct resource *io_res,
-					struct resource *mem_res)
-{
-	struct resource *p;
-
-	/* VGA Video RAM. */
-	p = kzalloc(sizeof(*p), GFP_KERNEL);
-	if (!p)
-		return;
-
-	p->name = "Video RAM area";
-	p->start = mem_res->start + 0xa0000UL;
-	p->end = p->start + 0x1ffffUL;
-	p->flags = IORESOURCE_BUSY;
-	request_resource(mem_res, p);
-}
-
 static void pci_register_iommu_region(struct pci_pbm_info *pbm)
 {
 	const u32 *vdma = of_get_property(pbm->op->dev.of_node, "virtual-dma",
@@ -487,8 +470,6 @@  void pci_determine_mem_io_space(struct pci_pbm_info *pbm)
 	if (pbm->mem64_space.flags)
 		request_resource(&iomem_resource, &pbm->mem64_space);
 
-	pci_register_legacy_regions(&pbm->io_space,
-				    &pbm->mem_space);
 	pci_register_iommu_region(pbm);
 }