Skip to contentSkip to conversation

fbdev: list all pci memory bars as conflicting apertures

PATCH In review Gerd Hoffmann 3 participants 7 messages Mar 14, 2019 – Apr 3, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/video/fbdev/core/fbmem.c | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)
drivers/video/fbdev/core/fbmem.c +25 -4
index cb43a2258c51..e4e5c129a0f5 100644
@@ -1879,14 +1879,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;
 
-	ap = alloc_apertures(1);
+	for (idx = 0, bar = 0; bar < PCI_ROM_RESOURCE; bar++) {
+		if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM))
+			continue;
+		idx++;
+	}
+
+	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;
Signature · 1 line
2.18.1
#1 lore raw
Quoted 9 lines · Gerd Hoffmann

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.

Patch queued for v5.2, thanks.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

#2 lore raw
Quoted 7 lines · Bartlomiej Zolnierkiewicz
Quoted 4 lines · Gerd Hoffmann

Simply add all pci memory bars to struct apertures_struct in remove_conflicting_pci_framebuffers(), without depending on the res_id parameter.

Quoted 7 lines
Quoted 5 lines

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.

Patch queued for v5.2, thanks.

Might be good to also stuff this into drm (double merge or topic branch, whatever you prefer), since that's where all the users are. Gerd also has some follow-up patches to apply on top of this one iirc. -Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#3 lore raw
Quoted 12 lines · Daniel Vetter
Quoted 10 lines · Bartlomiej Zolnierkiewicz
Quoted 7 lines · Gerd Hoffmann

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.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Patch queued for v5.2, thanks.

Might be good to also stuff this into drm (double merge or topic branch, whatever you prefer), since that's where all the users are. Gerd also has some follow-up patches to apply on top of this one iirc.

No follow-up patches yet. Plan is to wait a bit, see if the sanity-checks trigger, and if all goes well go drop the res_id parameter in 5.3 ...

cheers,
Gerd

#4 lore raw
Quoted 19 lines · Gerd Hoffmann
Quoted 17 lines · Daniel Vetter
Quoted 14 lines · Bartlomiej Zolnierkiewicz
Quoted 9 lines · Gerd Hoffmann

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.

Patch queued for v5.2, thanks.

Quoted 7 lines
Quoted 3 lines

Might be good to also stuff this into drm (double merge or topic branch, whatever you prefer), since that's where all the users are. Gerd also has some follow-up patches to apply on top of this one iirc.

No follow-up patches yet. Plan is to wait a bit, see if the sanity-checks trigger, and if all goes well go drop the res_id parameter in 5.3 ...

Hm I thought you had a patch to convert i915 over. Or did that land already? -Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#5 lore raw
Quoted 24 lines · Daniel Vetter
Quoted 23 lines · Gerd Hoffmann
Quoted 20 lines · Daniel Vetter
Quoted 7 lines · Bartlomiej Zolnierkiewicz
Quoted 4 lines · Gerd Hoffmann

Simply add all pci memory bars to struct apertures_struct in remove_conflicting_pci_framebuffers(), without depending on the res_id parameter.

Quoted 7 lines
Quoted 5 lines

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.

Patch queued for v5.2, thanks.

Might be good to also stuff this into drm (double merge or topic branch, whatever you prefer), since that's where all the users are. Gerd also has some follow-up patches to apply on top of this one iirc.

Quoted 5 lines
Quoted 3 lines

No follow-up patches yet. Plan is to wait a bit, see if the sanity-checks trigger, and if all goes well go drop the res_id parameter in 5.3 ...

Hm I thought you had a patch to convert i915 over. Or did that land already?

Ah, *that* one. Yep, that is still sitting in a branch here. Didn't rebase it yet. But I suspect it will be easier to first drop res_id and then rebase the i915 patch on top of *that*, so I don't have to figure which i915 revision needs which res_id ...

cheers,
Gerd

#6 lore raw
Quoted 30 lines · Gerd Hoffmann
Quoted 28 lines · Daniel Vetter
Quoted 26 lines · Gerd Hoffmann
Quoted 12 lines · Daniel Vetter
Quoted 10 lines · Bartlomiej Zolnierkiewicz
Quoted 7 lines · Gerd Hoffmann

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.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Patch queued for v5.2, thanks.

Might be good to also stuff this into drm (double merge or topic branch, whatever you prefer), since that's where all the users are. Gerd also has some follow-up patches to apply on top of this one iirc.

No follow-up patches yet. Plan is to wait a bit, see if the sanity-checks trigger, and if all goes well go drop the res_id parameter in 5.3 ...

Quoted 6 lines
Quoted 1 line

Hm I thought you had a patch to convert i915 over. Or did that land already?

Ah, *that* one. Yep, that is still sitting in a branch here. Didn't rebase it yet. But I suspect it will be easier to first drop res_id and then rebase the i915 patch on top of *that*, so I don't have to figure which i915 revision needs which res_id ...

Ok, sounds like a plan for 5.3 somewhen.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch