diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2019-04-01 17:46:57 +0200 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> | 2019-04-01 17:46:57 +0200 |
commit | b0e999c9558194a7b8908c41eaa7903e27fdb8c8 (patch) | |
tree | a703305c645b648b1df5c80fe070834e0d335b7a /drivers/video | |
parent | drivers: video: fbdev: Kconfig: pedantic cleanups (diff) | |
download | linux-b0e999c9558194a7b8908c41eaa7903e27fdb8c8.tar.xz linux-b0e999c9558194a7b8908c41eaa7903e27fdb8c8.zip |
fbdev: list all pci memory bars as conflicting apertures
Simply add all pci memory bars to struct apertures_struct in
remove_conflicting_pci_framebuffers(), without depending on the
res_id parameter.
The plan is to drop the res_id parameter later on. For now keep the
parameter, use it for sanity-checking and warn on inconsistencies.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/fbdev/core/fbmem.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 4721491e6c8c..d1949c92be98 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1882,14 +1882,35 @@ int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, int res_id, const { struct apertures_struct *ap; bool primary = false; - int err; + int err, idx, bar; + bool res_id_found = false; + + for (idx = 0, bar = 0; bar < PCI_ROM_RESOURCE; bar++) { + if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) + continue; + idx++; + } - ap = alloc_apertures(1); + ap = alloc_apertures(idx); if (!ap) return -ENOMEM; - ap->ranges[0].base = pci_resource_start(pdev, res_id); - ap->ranges[0].size = pci_resource_len(pdev, res_id); + for (idx = 0, bar = 0; bar < PCI_ROM_RESOURCE; bar++) { + if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) + continue; + ap->ranges[idx].base = pci_resource_start(pdev, bar); + ap->ranges[idx].size = pci_resource_len(pdev, bar); + pci_info(pdev, "%s: bar %d: 0x%lx -> 0x%lx\n", __func__, bar, + (unsigned long)pci_resource_start(pdev, bar), + (unsigned long)pci_resource_end(pdev, bar)); + idx++; + if (res_id == bar) + res_id_found = true; + } + if (!res_id_found) + pci_warn(pdev, "%s: passed res_id (%d) is not a memory bar\n", + __func__, res_id); + #ifdef CONFIG_X86 primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; |