Skip to contentSkip to conversation

fbdev: Maintain device ownership with aperture helpers

PATCH Superseded Thomas Zimmermann 2 participants 33 messages Jul 7, 2022 – Jul 15, 2022

Subsystems (17)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Thomas Zimmermann

author maintainer
#0 lore raw

cover fbdev: Maintain device ownership with aperture helpers

Fbdev firmware drivers acquire ownership of framebuffer I/O ranges and hand them over to native drivers during the boot process. Re-implement this mechanism with aperture helpers and remove the respective fbdev code.

This change allows to perform hand-over from DRM firmware drivers. In a later patchset, device ownership can be moved from DRM and fbdev entirely into aperture helpers.

Patches 1 and 4 are cleanups.

Patches 2 and 3 integrate EGA/VGA support into sysfb, although it's not clear if the x86 architecture code actually still supports VGA graphics mode.

Patches 5 to 10 replace fbdev's ownership management with aperture helpers. This includes removal of conflicting framebuffer drivers, removal of conflicting VGA drivers and registration of fbdev firmware devices. Notably, many PCI-based fbdev drivers failed to remove firmware devices until now; and therefore probably haven't worked correctly for some time.

Patch 11 removes the implementation of fbdev ownership management.

The patchset has been tested by handing over device ownership between firmware and native drivers of DRM and fbdev in various combinations.

Thomas Zimmermann (11):
fbdev: Remove trailing whitespaces
fbdev/vga16fb: Create EGA/VGA devices in sysfb code fbdev/vga16fb: Auto-generate module init/exit code fbdev/core: Remove remove_conflicting_pci_framebuffers()
fbdev: Convert drivers to aperture helpers
fbdev: Remove conflicting devices on PCI bus video/aperture: Disable and unregister sysfb devices via aperture
helpers
video: Provide constants for VGA I/O range video/aperture: Remove conflicting VGA devices, if any
fbdev: Acquire framebuffer apertures for firmware devices
fbdev: Remove conflict-handling code

 drivers/firmware/sysfb.c                     |   4 +
 drivers/staging/sm750fb/sm750.c              |  15 +-
 drivers/video/aperture.c                     |  69 ++--
 drivers/video/fbdev/arkfb.c                  |   5 +
 drivers/video/fbdev/asiliantfb.c             |   5 +
 drivers/video/fbdev/aty/aty128fb.c           |  57 ++--
 drivers/video/fbdev/aty/atyfb_base.c         |   7 +-
 drivers/video/fbdev/aty/radeon_base.c        |  83 +++--
 drivers/video/fbdev/carminefb.c              |   5 +
 drivers/video/fbdev/chipsfb.c                |  13 +-
 drivers/video/fbdev/cirrusfb.c               |   5 +
 drivers/video/fbdev/core/fbmem.c             | 176 ++---------
 drivers/video/fbdev/cyber2000fb.c            |   5 +
 drivers/video/fbdev/geode/gx1fb_core.c       |   5 +
 drivers/video/fbdev/geode/gxfb_core.c        |   5 +
 drivers/video/fbdev/geode/lxfb_core.c        |   5 +
 drivers/video/fbdev/gxt4500.c                |   5 +
 drivers/video/fbdev/hyperv_fb.c              |   6 +-
 drivers/video/fbdev/i740fb.c                 |   5 +
 drivers/video/fbdev/i810/i810_main.c         | 315 ++++++++++---------
 drivers/video/fbdev/imsttfb.c                |  36 ++-
 drivers/video/fbdev/intelfb/intelfbdrv.c     |   5 +
 drivers/video/fbdev/kyro/fbdev.c             |   5 +
 drivers/video/fbdev/matrox/matroxfb_base.c   |   5 +
 drivers/video/fbdev/mb862xx/mb862xxfbdrv.c   |   5 +
 drivers/video/fbdev/neofb.c                  |  41 +--
 drivers/video/fbdev/nvidia/nvidia.c          |   7 +-
 drivers/video/fbdev/pm2fb.c                  |   5 +
 drivers/video/fbdev/pm3fb.c                  |   5 +
 drivers/video/fbdev/pvr2fb.c                 |   5 +
 drivers/video/fbdev/riva/fbdev.c             |  67 ++--
 drivers/video/fbdev/s3fb.c                   |   5 +
 drivers/video/fbdev/savage/savagefb_driver.c |   5 +
 drivers/video/fbdev/sis/sis_main.c           |   5 +
 drivers/video/fbdev/skeletonfb.c             | 210 +++++++------
 drivers/video/fbdev/sm712fb.c                |   5 +
 drivers/video/fbdev/sstfb.c                  |  43 +--
 drivers/video/fbdev/sunxvr2500.c             |   5 +
 drivers/video/fbdev/sunxvr500.c              |   5 +
 drivers/video/fbdev/tdfxfb.c                 |   5 +
 drivers/video/fbdev/tgafb.c                  |  17 +-
 drivers/video/fbdev/tridentfb.c              |   5 +
 drivers/video/fbdev/vermilion/vermilion.c    |   7 +-
 drivers/video/fbdev/vga16fb.c                | 191 +++++------
 drivers/video/fbdev/via/via-core.c           |   5 +
 drivers/video/fbdev/vt8623fb.c               |   5 +
 include/linux/fb.h                           |   4 -
 include/video/vga.h                          |  20 +-
 48 files changed, 788 insertions(+), 735 deletions(-)

base-commit: 11d480026e922adacd274306728adb6df6dd262a
prerequisite-patch-id: c2b2f08f0eccc9f5df0c0da49fa1d36267deb11d
prerequisite-patch-id: c67e5d886a47b7d0266d81100837557fda34cb24

Signature · 1 line
2.36.1
author maintainer
#3 lore raw

PATCH 2/11 fbdev/vga16fb: Create EGA/VGA devices in sysfb code

Move the device-creation from vga16fb to sysfb code. Move the few extra videomode checks into vga16fb's probe function.

The vga16fb driver requires a screen_info for type VIDEO_TYPE_VGAC or VIDEO_TYPE_EGAC. Such code is nowhere present in the kernel, except for some MIPS systems. It's not clear if the vga16fb driver actually works in practice.

---
 drivers/firmware/sysfb.c      |  4 +++
 drivers/video/fbdev/vga16fb.c | 59 +++++++++++++++++------------------
 2 files changed, 32 insertions(+), 31 deletions(-)
drivers/firmware/sysfb.c +4 -0
index 1f276f108cc9..3fd3563d962b 100644
@@ -94,6 +94,10 @@ static __init int sysfb_init(void)
 		name = "efi-framebuffer";
 	else if (si->orig_video_isVGA == VIDEO_TYPE_VLFB)
 		name = "vesa-framebuffer";
+	else if (si->orig_video_isVGA == VIDEO_TYPE_VGAC)
+		name = "vga-framebuffer";
+	else if (si->orig_video_isVGA == VIDEO_TYPE_EGAC)
+		name = "ega-framebuffer";
 	else
 		name = "platform-framebuffer";
 
drivers/video/fbdev/vga16fb.c +28 -31

116 lines not on this page · raw message

Signature · 1 line
2.36.1
author maintainer
#9 lore raw

PATCH 3/11 fbdev/vga16fb: Auto-generate module init/exit code

In reply to Thomas Zimmermann

Move vgag16fb's option parsing into the driver's probe function and generate the rest of the module's init/exit functions from macros. Keep the options code, although there are no options defined.

---
 drivers/video/fbdev/vga16fb.c | 35 ++++++++++-------------------------
 1 file changed, 10 insertions(+), 25 deletions(-)
drivers/video/fbdev/vga16fb.c +10 -25
index f7c1bb018843..e7767ed50c5b 100644
@@ -1321,12 +1321,21 @@ static int __init vga16fb_setup(char *options)
 
 static int vga16fb_probe(struct platform_device *dev)
 {
+#ifndef MODULE
+	char *option = NULL;
+#endif
 	struct screen_info *si;
 	struct fb_info *info;
 	struct vga16fb_par *par;
 	int i;
 	int ret = 0;
 
+#ifndef MODULE
+	if (fb_get_options("vga16fb", &option))
+		return -ENODEV;
+	vga16fb_setup(option);
+#endif
+
 	si = dev_get_platdata(&dev->dev);
 	if (!si)
 		return -ENODEV;
@@ -1449,31 +1458,7 @@ static struct platform_driver vga16fb_driver = {
 	.id_table = vga16fb_driver_id_table,
 };
 
-static int __init vga16fb_init(void)
-{
-	int ret;
-#ifndef MODULE
-	char *option = NULL;
-
-	if (fb_get_options("vga16fb", &option))
-		return -ENODEV;
-
-	vga16fb_setup(option);
-#endif
-
-	ret = platform_driver_register(&vga16fb_driver);
-	if (ret)
-		return ret;
-
-	return 0;
-}
-
-static void __exit vga16fb_exit(void)
-{
-	platform_driver_unregister(&vga16fb_driver);
-}
+module_platform_driver(vga16fb_driver);
 
 MODULE_DESCRIPTION("Legacy VGA framebuffer device driver");
 MODULE_LICENSE("GPL");
-module_init(vga16fb_init);
-module_exit(vga16fb_exit);
Signature · 1 line
2.36.1
author maintainer
#13 lore raw

PATCH 4/11 fbdev/core: Remove remove_conflicting_pci_framebuffers()

In reply to Thomas Zimmermann

Remove remove_conflicting_pci_framebuffers() and implement similar functionality in aperture_remove_conflicting_pci_device(), which was the only caller. Removes an otherwise unused interface and streamlines the aperture helper. No functional changes.

---
 drivers/video/aperture.c         | 30 ++++++++++++--------
 drivers/video/fbdev/core/fbmem.c | 48 --------------------------------
 include/linux/fb.h               |  2 --
 3 files changed, 18 insertions(+), 62 deletions(-)
drivers/video/aperture.c +18 -12
index 538f2d40acda..f42a0d8bc211 100644
@@ -321,30 +321,36 @@ EXPORT_SYMBOL(aperture_remove_conflicting_devices);
  */
 int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const char *name)
 {
+	bool primary = false;
 	resource_size_t base, size;
 	int bar, ret;
 
-	/*
-	 * WARNING: Apparently we must kick fbdev drivers before vgacon,
-	 * otherwise the vga fbdev driver falls over.
-	 */
-#if IS_REACHABLE(CONFIG_FB)
-	ret = remove_conflicting_pci_framebuffers(pdev, name);
-	if (ret)
-		return ret;
+#ifdef CONFIG_X86
+	primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
 #endif
-	ret = vga_remove_vgacon(pdev);
-	if (ret)
-		return ret;
 
 	for (bar = 0; bar < PCI_STD_NUM_BARS; ++bar) {
 		if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM))
 			continue;
+
 		base = pci_resource_start(pdev, bar);
 		size = pci_resource_len(pdev, bar);
-		aperture_detach_devices(base, size);
+		ret = aperture_remove_conflicting_devices(base, size, primary, name);
+		if (ret)
+			break;
 	}
 
+	if (ret)
+		return ret;
+
+	/*
+	 * WARNING: Apparently we must kick fbdev drivers before vgacon,
+	 * otherwise the vga fbdev driver falls over.
+	 */
+	ret = vga_remove_vgacon(pdev);
+	if (ret)
+		return ret;
+
 	return 0;
 
 }
drivers/video/fbdev/core/fbmem.c +0 -48

54 lines not on this page · raw message

include/linux/fb.h +0 -2
index 07fcd0e56682..b91c77016560 100644
@@ -615,8 +615,6 @@ extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
 /* drivers/video/fbmem.c */
 extern int register_framebuffer(struct fb_info *fb_info);
 extern void unregister_framebuffer(struct fb_info *fb_info);
-extern int remove_conflicting_pci_framebuffers(struct pci_dev *pdev,
-					       const char *name);
 extern int remove_conflicting_framebuffers(struct apertures_struct *a,
 					   const char *name, bool primary);
 extern int fb_prepare_logo(struct fb_info *fb_info, int rotate);
Signature · 1 line
2.36.1
author maintainer
#15 lore raw

PATCH 5/11 fbdev: Convert drivers to aperture helpers

In reply to Thomas Zimmermann

Convert fbdev drivers from fbdev's remove_conflicting_framebuffers() to the framework-independent aperture_remove_conflicting_devices(). Calling this function will also remove conflicting DRM drivers.

---
 drivers/staging/sm750fb/sm750.c       | 15 +++++----------
 drivers/video/fbdev/aty/radeon_base.c | 17 ++++-------------
 drivers/video/fbdev/hyperv_fb.c       |  6 ++++--
 3 files changed, 13 insertions(+), 25 deletions(-)
drivers/staging/sm750fb/sm750.c +5 -10
index dbd1159a2ef0..ce04c38f6afd 100644
@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
+#include <linux/aperture.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/errno.h>
@@ -987,22 +988,16 @@ static int sm750fb_framebuffer_alloc(struct sm750_dev *sm750_dev, int fbidx)
 
 static int lynxfb_kick_out_firmware_fb(struct pci_dev *pdev)
 {
-	struct apertures_struct *ap;
+	resource_size_t base = pci_resource_start(pdev, 0);
+	resource_size_t size = pci_resource_len(pdev, 0);
 	bool primary = false;
 
-	ap = alloc_apertures(1);
-	if (!ap)
-		return -ENOMEM;
-
-	ap->ranges[0].base = pci_resource_start(pdev, 0);
-	ap->ranges[0].size = pci_resource_len(pdev, 0);
 #ifdef CONFIG_X86
 	primary = pdev->resource[PCI_ROM_RESOURCE].flags &
 					IORESOURCE_ROM_SHADOW;
 #endif
-	remove_conflicting_framebuffers(ap, "sm750_fb1", primary);
-	kfree(ap);
-	return 0;
+
+	return aperture_remove_conflicting_devices(base, size, primary, "sm750_fb1");
 }
 
 static int lynxfb_pci_probe(struct pci_dev *pdev,
drivers/video/fbdev/aty/radeon_base.c +4 -13
index b311c07fe66d..e5e362b8c9da 100644
@@ -54,6 +54,7 @@
 
 #include "radeonfb.h"
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/kernel.h>
@@ -2239,20 +2240,10 @@ static const struct bin_attribute edid2_attr = {
 
 static int radeon_kick_out_firmware_fb(struct pci_dev *pdev)
 {
-	struct apertures_struct *ap;
+	resource_size_t base = pci_resource_start(pdev, 0);
+	resource_size_t size = pci_resource_len(pdev, 0);
 
-	ap = alloc_apertures(1);
-	if (!ap)
-		return -ENOMEM;
-
-	ap->ranges[0].base = pci_resource_start(pdev, 0);
-	ap->ranges[0].size = pci_resource_len(pdev, 0);
-
-	remove_conflicting_framebuffers(ap, KBUILD_MODNAME, false);
-
-	kfree(ap);
-
-	return 0;
+	return aperture_remove_conflicting_devices(base, size, KBUILD_MODNAME, false);
 }
 
 static int radeonfb_pci_register(struct pci_dev *pdev,
drivers/video/fbdev/hyperv_fb.c +4 -2
index 886c564787f1..a944a6620527 100644
@@ -45,6 +45,7 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/vmalloc.h>
@@ -1074,8 +1075,9 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info)
 	info->screen_size = dio_fb_size;
 
 getmem_done:
-	remove_conflicting_framebuffers(info->apertures,
-					KBUILD_MODNAME, false);
+	aperture_remove_conflicting_devices(info->apertures->ranges[0].base,
+					    info->apertures->ranges[0].size,
+					    KBUILD_MODNAME, false);
 
 	if (gen2vm) {
 		/* framebuffer is reallocated, clear screen_info to avoid misuse from kexec */
Signature · 1 line
2.36.1
author maintainer
#22 lore raw

PATCH 7/11 video/aperture: Disable and unregister sysfb devices via aperture helpers

In reply to Thomas Zimmermann

Call sysfb_disable() before removing conflicting devices in aperture helpers. Fixes sysfb state if fbdev has been disabled.

Fixes fb84efa28a48 ("drm/aperture: Run fbdev removal before internal helpers")
Cc Zack Rusin <[email protected]>
Cc Thomas Zimmermann <[email protected]>
Cc Javier Martinez Canillas <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Sam Ravnborg <[email protected]>
Cc Helge Deller <[email protected]>
Cc Alex Deucher <[email protected]>
Cc Zhen Lei <[email protected]>
Cc Changcheng Deng <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
---
 drivers/video/aperture.c         | 14 ++++++++++++++
 drivers/video/fbdev/core/fbmem.c | 12 ------------
 2 files changed, 14 insertions(+), 12 deletions(-)
drivers/video/aperture.c +14 -0
index f42a0d8bc211..101e13c2cf41 100644
@@ -8,6 +8,7 @@
 #include <linux/pci.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
+#include <linux/sysfb.h>
 #include <linux/types.h>
 #include <linux/vgaarb.h>
 
@@ -286,7 +287,20 @@ int aperture_remove_conflicting_devices(resource_size_t base, resource_size_t si
 #if IS_REACHABLE(CONFIG_FB)
 	struct apertures_struct *a;
 	int ret;
+#endif
+
+	/*
+	 * If a driver asked to unregister a platform device registered by
+	 * sysfb, then can be assumed that this is a driver for a display
+	 * that is set up by the system firmware and has a generic driver.
+	 *
+	 * Drivers for devices that don't have a generic driver will never
+	 * ask for this, so let's assume that a real driver for the display
+	 * was already probed and prevent sysfb to register devices later.
+	 */
+	sysfb_disable();
 
+#if IS_REACHABLE(CONFIG_FB)
 	a = alloc_apertures(1);
 	if (!a)
 		return -ENOMEM;
drivers/video/fbdev/core/fbmem.c +0 -12
index 877de85309f3..3ee3ea018245 100644
@@ -19,7 +19,6 @@
 #include <linux/kernel.h>
 #include <linux/major.h>
 #include <linux/slab.h>
-#include <linux/sysfb.h>
 #include <linux/mm.h>
 #include <linux/mman.h>
 #include <linux/vt.h>
@@ -1765,17 +1764,6 @@ int remove_conflicting_framebuffers(struct apertures_struct *a,
 		do_free = true;
 	}
 
-	/*
-	 * If a driver asked to unregister a platform device registered by
-	 * sysfb, then can be assumed that this is a driver for a display
-	 * that is set up by the system firmware and has a generic driver.
-	 *
-	 * Drivers for devices that don't have a generic driver will never
-	 * ask for this, so let's assume that a real driver for the display
-	 * was already probed and prevent sysfb to register devices later.
-	 */
-	sysfb_disable();
-
 	mutex_lock(&registration_lock);
 	do_remove_conflicting_framebuffers(a, name, primary);
 	mutex_unlock(&registration_lock);
Signature · 1 line
2.36.1
author maintainer
#19 lore raw

PATCH 6/11 fbdev: Remove conflicting devices on PCI bus

In reply to Thomas Zimmermann

Remove firmware devices on the PCI bus, by calling aperture_remove_conflicting_pci_devices() in the probe function of each related fbdev driver. iSo far, most of these drivers did not remove conflicting VESA or EFI devices, or outride failed for resource conflicts (i.e., matroxfb.) This must have been broken for quite some time.

---
 drivers/video/fbdev/arkfb.c                  | 5 +++++
 drivers/video/fbdev/asiliantfb.c             | 5 +++++
 drivers/video/fbdev/aty/aty128fb.c           | 5 +++++
 drivers/video/fbdev/aty/atyfb_base.c         | 7 ++++++-
 drivers/video/fbdev/carminefb.c              | 5 +++++
 drivers/video/fbdev/chipsfb.c                | 7 ++++++-
 drivers/video/fbdev/cirrusfb.c               | 5 +++++
 drivers/video/fbdev/cyber2000fb.c            | 5 +++++
 drivers/video/fbdev/geode/gx1fb_core.c       | 5 +++++
 drivers/video/fbdev/geode/gxfb_core.c        | 5 +++++
 drivers/video/fbdev/geode/lxfb_core.c        | 5 +++++
 drivers/video/fbdev/gxt4500.c                | 5 +++++
 drivers/video/fbdev/i740fb.c                 | 5 +++++
 drivers/video/fbdev/i810/i810_main.c         | 5 +++++
 drivers/video/fbdev/imsttfb.c                | 8 +++++++-
 drivers/video/fbdev/intelfb/intelfbdrv.c     | 5 +++++
 drivers/video/fbdev/kyro/fbdev.c             | 5 +++++
 drivers/video/fbdev/matrox/matroxfb_base.c   | 5 +++++
 drivers/video/fbdev/mb862xx/mb862xxfbdrv.c   | 5 +++++
 drivers/video/fbdev/neofb.c                  | 5 +++++
 drivers/video/fbdev/nvidia/nvidia.c          | 7 ++++++-
 drivers/video/fbdev/pm2fb.c                  | 5 +++++
 drivers/video/fbdev/pm3fb.c                  | 5 +++++
 drivers/video/fbdev/pvr2fb.c                 | 5 +++++
 drivers/video/fbdev/riva/fbdev.c             | 5 +++++
 drivers/video/fbdev/s3fb.c                   | 5 +++++
 drivers/video/fbdev/savage/savagefb_driver.c | 5 +++++
 drivers/video/fbdev/sis/sis_main.c           | 5 +++++
 drivers/video/fbdev/skeletonfb.c             | 8 ++++++++
 drivers/video/fbdev/sm712fb.c                | 5 +++++
 drivers/video/fbdev/sstfb.c                  | 5 +++++
 drivers/video/fbdev/sunxvr2500.c             | 5 +++++
 drivers/video/fbdev/sunxvr500.c              | 5 +++++
 drivers/video/fbdev/tdfxfb.c                 | 5 +++++
 drivers/video/fbdev/tgafb.c                  | 7 +++++++
 drivers/video/fbdev/tridentfb.c              | 5 +++++
 drivers/video/fbdev/vermilion/vermilion.c    | 7 ++++++-
 drivers/video/fbdev/via/via-core.c           | 5 +++++
 drivers/video/fbdev/vt8623fb.c               | 5 +++++
 39 files changed, 206 insertions(+), 5 deletions(-)
drivers/video/fbdev/arkfb.c +5 -0
index eb3e47c58c5f..453daa072f53 100644
@@ -11,6 +11,7 @@
  *  Code is based on s3fb
  */
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -949,6 +950,10 @@ static int ark_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 	int rc;
 	u8 regval;
 
+	rc = aperture_remove_conflicting_pci_devices(dev, "arkfb");
+	if (rc < 0)
+		return rc;
+
 	/* Ignore secondary VGA device because there is no VGA arbitration */
 	if (! svga_primary_device(dev)) {
 		dev_info(&(dev->dev), "ignoring secondary device\n");
drivers/video/fbdev/asiliantfb.c +5 -0
index f8ef62542f7f..3818437a8f69 100644
@@ -29,6 +29,7 @@
  *  more details.
  */
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -545,6 +546,10 @@ static int asiliantfb_pci_init(struct pci_dev *dp,
 	struct fb_info *p;
 	int err;
 
+	err = aperture_remove_conflicting_pci_devices(dp, "asiliantfb");
+	if (err)
+		return err;
+
 	if ((dp->resource[0].flags & IORESOURCE_MEM) == 0)
 		return -ENODEV;
 	addr = pci_resource_start(dp, 0);
drivers/video/fbdev/aty/aty128fb.c +5 -0
index 5cdbbba2a013..57e398fe7a81 100644
@@ -47,6 +47,7 @@
  */
 
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/kernel.h>
@@ -2055,6 +2056,10 @@ static int aty128_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	void __iomem *bios = NULL;
 #endif
 
+	err = aperture_remove_conflicting_pci_devices(pdev, "aty128fb");
+	if (err)
+		return err;
+
 	/* Enable device in PCI config */
 	if ((err = pci_enable_device(pdev))) {
 		printk(KERN_ERR "aty128fb: Cannot enable PCI device: %d\n",
drivers/video/fbdev/aty/atyfb_base.c +6 -1
index a3e6faed7745..4804b6e9f3f4 100644
@@ -48,6 +48,7 @@
 
 ******************************************************************************/
 
+#include <linux/aperture.h>
 #include <linux/compat.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
@@ -3533,7 +3534,11 @@ static int atyfb_pci_probe(struct pci_dev *pdev,
 	struct fb_info *info;
 	struct resource *rp;
 	struct atyfb_par *par;
-	int rc = -ENOMEM;
+	int rc;
+
+	rc = aperture_remove_conflicting_pci_devices(pdev, "atyfb");
+	if (rc)
+		return rc;
 
 	/* Enable device in PCI config */
 	if (pci_enable_device(pdev)) {
drivers/video/fbdev/carminefb.c +5 -0
index 3a1c2e0739a1..4651b48a87f9 100644
@@ -7,6 +7,7 @@
  * - FB1 is display 1 with unique memory area
  * - both display use 32 bit colors
  */
+#include <linux/aperture.h>
 #include <linux/delay.h>
 #include <linux/errno.h>
 #include <linux/fb.h>
@@ -614,6 +615,10 @@ static int carminefb_probe(struct pci_dev *dev, const struct pci_device_id *ent)
 	struct fb_info *info;
 	int ret;
 
+	ret = aperture_remove_conflicting_pci_devices(dev, "carminefb");
+	if (ret)
+		return ret;
+
 	ret = pci_enable_device(dev);
 	if (ret)
 		return ret;
drivers/video/fbdev/chipsfb.c +6 -1
index 618fb6dbbedb..5ad64714d39e 100644
@@ -14,6 +14,7 @@
  *  more details.
  */
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -351,7 +352,11 @@ static int chipsfb_pci_init(struct pci_dev *dp, const struct pci_device_id *ent)
 	struct fb_info *p;
 	unsigned long addr;
 	unsigned short cmd;
-	int rc = -ENODEV;
+	int rc;
+
+	rc = aperture_remove_conflicting_pci_devices(dp, "chipsfb");
+	if (rc)
+		return rc;
 
 	if (pci_enable_device(dp) < 0) {
 		dev_err(&dp->dev, "Cannot enable PCI device\n");
drivers/video/fbdev/cirrusfb.c +5 -0
index 51e072c03e1c..4ff6f624f912 100644
@@ -34,6 +34,7 @@
  *
  */
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -2085,6 +2086,10 @@ static int cirrusfb_pci_register(struct pci_dev *pdev,
 	unsigned long board_addr, board_size;
 	int ret;
 
+	ret = aperture_remove_conflicting_pci_devices(pdev, "cirrusfb");
+	if (ret)
+		return ret;
+
 	ret = pci_enable_device(pdev);
 	if (ret < 0) {
 		printk(KERN_ERR "cirrusfb: Cannot enable PCI device\n");
drivers/video/fbdev/cyber2000fb.c +5 -0
index d45355b9a58c..be7bcf95c96a 100644
@@ -33,6 +33,7 @@
  * (which, incidentally, is about the same saving as a 2.5in hard disk
  * entering standby mode.)
  */
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -1720,6 +1721,10 @@ static int cyberpro_pci_probe(struct pci_dev *dev,
 
 	sprintf(name, "CyberPro%4X", id->device);
 
+	err = aperture_remove_conflicting_pci_devices(dev, name);
+	if (err)
+		return err;
+
 	err = pci_enable_device(dev);
 	if (err)
 		return err;
drivers/video/fbdev/geode/gx1fb_core.c +5 -0
index 5d34d89fb665..4cac7e3bb1a0 100644
@@ -6,6 +6,7 @@
  * Copyright (C) 2005 Arcom Control Systems Ltd.
  */
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -320,6 +321,10 @@ static int gx1fb_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	struct fb_info *info;
 	int ret;
 
+	ret = aperture_remove_conflicting_pci_devices(pdev, "gx1fb");
+	if (ret)
+		return ret;
+
 	info = gx1fb_init_fbinfo(&pdev->dev);
 	if (!info)
 		return -ENOMEM;
drivers/video/fbdev/geode/gxfb_core.c +5 -0
index 44089b331f91..2527bd80ec5f 100644
@@ -15,6 +15,7 @@
  *
  * 16 MiB of framebuffer memory is assumed to be available.
  */
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -364,6 +365,10 @@ static int gxfb_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	struct fb_videomode *modedb_ptr;
 	unsigned int modedb_size;
 
+	ret = aperture_remove_conflicting_pci_devices(pdev, "gxfb");
+	if (ret)
+		return ret;
+
 	info = gxfb_init_fbinfo(&pdev->dev);
 	if (!info)
 		return -ENOMEM;
drivers/video/fbdev/geode/lxfb_core.c +5 -0
index 66c81262d18f..9d26592dbfce 100644
@@ -6,6 +6,7 @@
  * Built from gxfb (which is Copyright (C) 2006 Arcom Control Systems Ltd.)
  */
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -484,6 +485,10 @@ static int lxfb_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	struct fb_videomode *modedb_ptr;
 	unsigned int modedb_size;
 
+	ret = aperture_remove_conflicting_pci_devices(pdev, "lxfb");
+	if (ret)
+		return ret;
+
 	info = lxfb_init_fbinfo(&pdev->dev);
 
 	if (info == NULL)
drivers/video/fbdev/gxt4500.c +5 -0
index e5475ae1e158..f0d36a4fdaef 100644
@@ -6,6 +6,7 @@
  * Copyright (C) 2006 Paul Mackerras, IBM Corp. <[email protected]>
  */
 
+#include <linux/aperture.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/fb.h>
@@ -621,6 +622,10 @@ static int gxt4500_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	struct fb_var_screeninfo var;
 	enum gxt_cards cardtype;
 
+	err = aperture_remove_conflicting_pci_devices(pdev, "gxt4500fb");
+	if (err)
+		return err;
+
 	err = pci_enable_device(pdev);
 	if (err) {
 		dev_err(&pdev->dev, "gxt4500: cannot enable PCI device: %d\n",
drivers/video/fbdev/i740fb.c +5 -0
index 09dd85553d4f..23329de28e77 100644
@@ -12,6 +12,7 @@
  *  i740fb by Patrick LERDA, v0.9
  */
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -1008,6 +1009,10 @@ static int i740fb_probe(struct pci_dev *dev, const struct pci_device_id *ent)
 	bool found = false;
 	u8 *edid;
 
+	ret = aperture_remove_conflicting_pci_devices(dev, "i740fb");
+	if (ret)
+		return ret;
+
 	info = framebuffer_alloc(sizeof(struct i740fb_par), &(dev->dev));
 	if (!info)
 		return -ENOMEM;
drivers/video/fbdev/i810/i810_main.c +5 -0
index 41a86efca516..ff09f8c20bfc 100644
@@ -28,6 +28,7 @@
  *  more details.
  */
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -2016,6 +2017,10 @@ static int i810fb_init_pci(struct pci_dev *dev,
 	struct fb_videomode mode;
 	int err = -1, vfreq, hfreq, pixclock;
 
+	err = aperture_remove_conflicting_pci_devices(dev, "i810fb");
+	if (err)
+		return err;
+
 	info = framebuffer_alloc(sizeof(struct i810fb_par), &dev->dev);
 	if (!info)
 		return -ENOMEM;
drivers/video/fbdev/imsttfb.c +7 -1
index f489386855c0..d7edb9c5d3a3 100644
@@ -16,6 +16,7 @@
  *  more details.
  */
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -1469,7 +1470,12 @@ static int imsttfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	struct imstt_par *par;
 	struct fb_info *info;
 	struct device_node *dp;
-	int ret = -ENOMEM;
+	int ret;
+
+	ret = aperture_remove_conflicting_pci_devices(pdev, "imsttfb");
+	if (ret)
+		return ret;
+	ret = -ENOMEM;
 
 	dp = pci_device_to_OF_node(pdev);
 	if(dp)
drivers/video/fbdev/intelfb/intelfbdrv.c +5 -0
index 5647fca8c49a..d4a2891a9a7a 100644
@@ -107,6 +107,7 @@
  *              Add support for 945GME. (Phil Endecott <[email protected]>)
  */
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -483,6 +484,10 @@ static int intelfb_pci_register(struct pci_dev *pdev,
 
 	DBG_MSG("intelfb_pci_register\n");
 
+	err = aperture_remove_conflicting_pci_devices(pdev, "intelfb");
+	if (err)
+		return err;
+
 	num_registered++;
 	if (num_registered != 1) {
 		ERR_MSG("Attempted to register %d devices "
drivers/video/fbdev/kyro/fbdev.c +5 -0
index d57772f96ad2..b4b93054c520 100644
@@ -9,6 +9,7 @@
  * for more details.
  */
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
@@ -676,6 +677,10 @@ static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	unsigned long size;
 	int err;
 
+	err = aperture_remove_conflicting_pci_devices(pdev, "kyrofb");
+	if (err)
+		return err;
+
 	if ((err = pci_enable_device(pdev))) {
 		printk(KERN_WARNING "kyrofb: Can't enable pdev: %d\n", err);
 		return err;
drivers/video/fbdev/matrox/matroxfb_base.c +5 -0
index 236521b19daf..3e26346c05a2 100644
@@ -100,6 +100,7 @@
  *
  */
 
+#include <linux/aperture.h>
 #include <linux/version.h>
 
 #include "matroxfb_base.h"
@@ -2044,6 +2045,10 @@ static int matroxfb_probe(struct pci_dev* pdev, const struct pci_device_id* dumm
 	u_int32_t cmd;
 	DBG(__func__)
 
+	err = aperture_remove_conflicting_pci_devices(pdev, "matroxfb");
+	if (err)
+		return err;
+
 	svid = pdev->subsystem_vendor;
 	sid = pdev->subsystem_device;
 	for (b = dev_list; b->vendor; b++) {
drivers/video/fbdev/mb862xx/mb862xxfbdrv.c +5 -0
index a7508f5be343..96800c9c9cd9 100644
@@ -10,6 +10,7 @@
 
 #undef DEBUG
 
+#include <linux/aperture.h>
 #include <linux/fb.h>
 #include <linux/delay.h>
 #include <linux/uaccess.h>
@@ -999,6 +1000,10 @@ static int mb862xx_pci_probe(struct pci_dev *pdev,
 	struct device *dev = &pdev->dev;
 	int ret;
 
+	ret = aperture_remove_conflicting_pci_devices(pdev, "mb862xxfb");
+	if (ret)
+		return ret;
+
 	ret = pci_enable_device(pdev);
 	if (ret < 0) {
 		dev_err(dev, "Cannot enable PCI device\n");
drivers/video/fbdev/neofb.c +5 -0
index 8ad2a79623af..93a2d2d1abe8 100644
@@ -54,6 +54,7 @@
  *
  */
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -2029,6 +2030,10 @@ static int neofb_probe(struct pci_dev *dev, const struct pci_device_id *id)
 
 	DBG("neofb_probe");
 
+	err = aperture_remove_conflicting_pci_devices(dev, "neofb");
+	if (err)
+		return err;
+
 	err = pci_enable_device(dev);
 	if (err)
 		return err;
drivers/video/fbdev/nvidia/nvidia.c +6 -1
index a372a183c1f0..329e2e8133c6 100644
@@ -9,6 +9,7 @@
  *
  */
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -1276,11 +1277,15 @@ static int nvidiafb_probe(struct pci_dev *pd, const struct pci_device_id *ent)
 	struct nvidia_par *par;
 	struct fb_info *info;
 	unsigned short cmd;
-
+	int ret;
 
 	NVTRACE_ENTER();
 	assert(pd != NULL);
 
+	ret = aperture_remove_conflicting_pci_devices(pd, "nvidiafb");
+	if (ret)
+		return ret;
+
 	info = framebuffer_alloc(sizeof(struct nvidia_par), &pd->dev);
 
 	if (!info)
drivers/video/fbdev/pm2fb.c +5 -0
index d3be2c64f1c0..bc80d8498aeb 100644
@@ -27,6 +27,7 @@
  *
  */
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/kernel.h>
@@ -1516,6 +1517,10 @@ static int pm2fb_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	int err;
 	int retval = -ENXIO;
 
+	err = aperture_remove_conflicting_pci_devices(pdev, "pm2fb");
+	if (err)
+		return err;
+
 	err = pci_enable_device(pdev);
 	if (err) {
 		printk(KERN_WARNING "pm2fb: Can't enable pdev: %d\n", err);
drivers/video/fbdev/pm3fb.c +5 -0
index a8faf46adeb1..ba69846d444f 100644
@@ -22,6 +22,7 @@
  *
  */
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -1315,6 +1316,10 @@ static int pm3fb_probe(struct pci_dev *dev, const struct pci_device_id *ent)
 	int err;
 	int retval = -ENXIO;
 
+	err = aperture_remove_conflicting_pci_devices(dev, "pm3fb");
+	if (err)
+		return err;
+
 	err = pci_enable_device(dev);
 	if (err) {
 		printk(KERN_WARNING "pm3fb: Can't enable PCI dev: %d\n", err);
drivers/video/fbdev/pvr2fb.c +5 -0
index f4add36cb5f4..b73ad14efa20 100644
@@ -45,6 +45,7 @@
 
 #undef DEBUG
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -942,6 +943,10 @@ static int pvr2fb_pci_probe(struct pci_dev *pdev,
 {
 	int ret;
 
+	ret = aperture_remove_conflicting_pci_devices(pdev, "pvrfb");
+	if (ret)
+		return ret;
+
 	ret = pci_enable_device(pdev);
 	if (ret) {
 		printk(KERN_ERR "pvr2fb: PCI enable failed\n");
drivers/video/fbdev/riva/fbdev.c +5 -0
index 5bafc44c591b..0ea74e28f915 100644
@@ -29,6 +29,7 @@
  *	doublescan modes are broken
  */
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -1898,6 +1899,10 @@ static int rivafb_probe(struct pci_dev *pd, const struct pci_device_id *ent)
 	NVTRACE_ENTER();
 	assert(pd != NULL);
 
+	ret = aperture_remove_conflicting_pci_devices(pd, "rivafb");
+	if (ret)
+		return ret;
+
 	info = framebuffer_alloc(sizeof(struct riva_par), &pd->dev);
 	if (!info) {
 		ret = -ENOMEM;
drivers/video/fbdev/s3fb.c +5 -0
index b93c8eb02336..f66c4de0e188 100644
@@ -11,6 +11,7 @@
  * which is based on the code of neofb.
  */
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -1129,6 +1130,10 @@ static int s3_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 		return -ENODEV;
 	}
 
+	rc = aperture_remove_conflicting_pci_devices(dev, "s3fb");
+	if (rc)
+		return rc;
+
 	/* Allocate and fill driver data structure */
 	info = framebuffer_alloc(sizeof(struct s3fb_info), &(dev->dev));
 	if (!info)
drivers/video/fbdev/savage/savagefb_driver.c +5 -0
index 8114c921ceb8..b7818b652698 100644
@@ -41,6 +41,7 @@
  *
  */
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -2176,6 +2177,10 @@ static int savagefb_probe(struct pci_dev *dev, const struct pci_device_id *id)
 
 	DBG("savagefb_probe");
 
+	err = aperture_remove_conflicting_pci_devices(dev, "savagefb");
+	if (err)
+		return err;
+
 	info = framebuffer_alloc(sizeof(struct savagefb_par), &dev->dev);
 	if (!info)
 		return -ENOMEM;
drivers/video/fbdev/sis/sis_main.c +5 -0
index f28fd69d5eb7..7114c5c17c91 100644
@@ -19,6 +19,7 @@
  * which is (c) 1998 Gerd Knorr <[email protected]>
  */
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/kernel.h>
@@ -5849,6 +5850,10 @@ static int sisfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if(sisfb_off)
 		return -ENXIO;
 
+	ret = aperture_remove_conflicting_pci_devices(pdev, "sisfb");
+	if (ret)
+		return ret;
+
 	sis_fb_info = framebuffer_alloc(sizeof(*ivideo), &pdev->dev);
 	if(!sis_fb_info)
 		return -ENOMEM;
drivers/video/fbdev/skeletonfb.c +8 -0
index 304320ce6c6f..125df366e23a 100644
@@ -42,6 +42,7 @@
  *  more details.
  */
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -668,6 +669,13 @@ static int xxxfb_probe(struct pci_dev *dev, const struct pci_device_id *ent)
     struct device *device = &dev->dev; /* or &pdev->dev */
     int cmap_len, retval;
 
+    /*
+     * Remove firmware-based drivers that create resource conflicts.
+     */
+    retval = aperture_remove_conflicting_pci_devices(pdev, "xxxfb");
+    if (retval)
+	    return retval;
+
     /*
      * Dynamically allocate info and par
      */
drivers/video/fbdev/sm712fb.c +5 -0
index 092a1caa1208..3baf33635e65 100644
@@ -18,6 +18,7 @@
  * Framebuffer driver for Silicon Motion SM710, SM712, SM721 and SM722 chips
  */
 
+#include <linux/aperture.h>
 #include <linux/io.h>
 #include <linux/fb.h>
 #include <linux/pci.h>
@@ -1502,6 +1503,10 @@ static int smtcfb_pci_probe(struct pci_dev *pdev,
 
 	dev_info(&pdev->dev, "Silicon Motion display driver.\n");
 
+	err = aperture_remove_conflicting_pci_devices(pdev, "smtcfb");
+	if (err)
+		return err;
+
 	err = pci_enable_device(pdev);	/* enable SMTC chip */
 	if (err)
 		return err;
drivers/video/fbdev/sstfb.c +5 -0
index 535ef4693cd4..73ca2782ebfc 100644
@@ -80,6 +80,7 @@
  * Includes
  */
 
+#include <linux/aperture.h>
 #include <linux/string.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -1326,6 +1327,10 @@ static int sstfb_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	struct sst_spec *spec;
 	int err;
 
+	err = aperture_remove_conflicting_pci_devices(pdev, "sstfb");
+	if (err)
+		return err;
+
 	/* Enable device in PCI config. */
 	if ((err=pci_enable_device(pdev))) {
 		printk(KERN_ERR "cannot enable device\n");
drivers/video/fbdev/sunxvr2500.c +5 -0
index 1d3bacd9d5ac..81d59613ea1f 100644
@@ -5,6 +5,7 @@
  * Copyright (C) 2007 David S. Miller ([email protected])
  */
 
+#include <linux/aperture.h>
 #include <linux/kernel.h>
 #include <linux/fb.h>
 #include <linux/pci.h>
@@ -123,6 +124,10 @@ static int s3d_pci_register(struct pci_dev *pdev,
 	struct s3d_info *sp;
 	int err;
 
+	err = aperture_remove_conflicting_pci_devices(pdev, "s3dfb");
+	if (err)
+		return err;
+
 	err = pci_enable_device(pdev);
 	if (err < 0) {
 		printk(KERN_ERR "s3d: Cannot enable PCI device %s\n",
drivers/video/fbdev/sunxvr500.c +5 -0
index 9daf17b11106..3a51b2a1480c 100644
@@ -5,6 +5,7 @@
  * Copyright (C) 2007 David S. Miller ([email protected])
  */
 
+#include <linux/aperture.h>
 #include <linux/kernel.h>
 #include <linux/fb.h>
 #include <linux/pci.h>
@@ -249,6 +250,10 @@ static int e3d_pci_register(struct pci_dev *pdev,
 	unsigned int line_length;
 	int err;
 
+	err = aperture_remove_conflicting_pci_devices(pdev, "e3dfb");
+	if (err)
+		return err;
+
 	of_node = pci_device_to_OF_node(pdev);
 	if (!of_node) {
 		printk(KERN_ERR "e3d: Cannot find OF node of %s\n",
drivers/video/fbdev/tdfxfb.c +5 -0
index 67e37a62b07c..059e0174e139 100644
@@ -64,6 +64,7 @@
  *
  */
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -1376,6 +1377,10 @@ static int tdfxfb_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	struct fb_monspecs *specs;
 	bool found;
 
+	err = aperture_remove_conflicting_pci_devices(pdev, "tdfxfb");
+	if (err)
+		return err;
+
 	err = pci_enable_device(pdev);
 	if (err) {
 		printk(KERN_ERR "tdfxfb: Can't enable pdev: %d\n", err);
drivers/video/fbdev/tgafb.c +7 -0
index 9266c76783cc..4600138e3bef 100644
@@ -12,6 +12,7 @@
  *  more details.
  */
 
+#include <linux/aperture.h>
 #include <linux/bitrev.h>
 #include <linux/compiler.h>
 #include <linux/delay.h>
@@ -106,6 +107,12 @@ static struct pci_driver tgafb_pci_driver = {
 static int tgafb_pci_register(struct pci_dev *pdev,
 			      const struct pci_device_id *ent)
 {
+	int ret;
+
+	ret = aperture_remove_conflicting_pci_devices(pdev, "tgafb");
+	if (ret)
+		return ret;
+
 	return tgafb_register(&pdev->dev);
 }
 
drivers/video/fbdev/tridentfb.c +5 -0
index 319131bd72cf..6813df793c49 100644
@@ -16,6 +16,7 @@
  *	timing value tweaking so it looks good on every monitor in every mode
  */
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/fb.h>
 #include <linux/init.h>
@@ -1470,6 +1471,10 @@ static int trident_pci_probe(struct pci_dev *dev,
 	int chip_id;
 	bool found = false;
 
+	err = aperture_remove_conflicting_pci_devices(dev, "tridentfb");
+	if (err)
+		return err;
+
 	err = pci_enable_device(dev);
 	if (err)
 		return err;
drivers/video/fbdev/vermilion/vermilion.c +6 -1
index ff61605b8764..82b36dbb5b1a 100644
@@ -14,6 +14,7 @@
  *   Alan Hourihane <alanh-at-tungstengraphics-dot-com>
  */
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -442,7 +443,11 @@ static int vml_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 	struct vml_info *vinfo;
 	struct fb_info *info;
 	struct vml_par *par;
-	int err = 0;
+	int err;
+
+	err = aperture_remove_conflicting_pci_devices(dev, "vmlfb");
+	if (err)
+		return err;
 
 	par = kzalloc(sizeof(*par), GFP_KERNEL);
 	if (par == NULL)
drivers/video/fbdev/via/via-core.c +5 -0
index 89d75079b730..2ee8fcae08df 100644
@@ -8,6 +8,7 @@
 /*
  * Core code for the Via multifunction framebuffer device.
  */
+#include <linux/aperture.h>
 #include <linux/via-core.h>
 #include <linux/via_i2c.h>
 #include <linux/via-gpio.h>
@@ -617,6 +618,10 @@ static int via_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
 	int ret;
 
+	ret = aperture_remove_conflicting_pci_devices(pdev, "viafb");
+	if (ret)
+		return ret;
+
 	ret = pci_enable_device(pdev);
 	if (ret)
 		return ret;
drivers/video/fbdev/vt8623fb.c +5 -0
index a92a8c670cf0..62318cef5f8c 100644
@@ -12,6 +12,7 @@
  * (http://davesdomain.org.uk/viafb/)
  */
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -670,6 +671,10 @@ static int vt8623_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 		return -ENODEV;
 	}
 
+	rc = aperture_remove_conflicting_pci_devices(dev, "vt8623fb");
+	if (rc)
+		return rc;
+
 	/* Allocate and fill driver data structure */
 	info = framebuffer_alloc(sizeof(struct vt8623fb_info), &(dev->dev));
 	if (!info)
Signature · 1 line
2.36.1
author maintainer
#24 lore raw

PATCH 8/11 video: Provide constants for VGA I/O range

In reply to Thomas Zimmermann

Provide VGA_FB_ constants for the VGA framebuffer I/O range and convert fbdev code.

---
 drivers/video/fbdev/core/fbmem.c |  4 ++--
 drivers/video/fbdev/vga16fb.c    | 15 ++++++---------
 include/video/vga.h              |  2 ++
 3 files changed, 10 insertions(+), 11 deletions(-)
drivers/video/fbdev/core/fbmem.c +2 -2
index 3ee3ea018245..2237049327db 100644
@@ -39,6 +39,7 @@
 
 #include <asm/fb.h>
 
+#include <video/vga.h>
 
     /*
      *  Frame buffer device initialization and setup routines
@@ -1549,7 +1550,6 @@ static bool fb_do_apertures_overlap(struct apertures_struct *gena,
 
 static void do_unregister_framebuffer(struct fb_info *fb_info);
 
-#define VGA_FB_PHYS 0xA0000
 static void do_remove_conflicting_framebuffers(struct apertures_struct *a,
 					       const char *name, bool primary)
 {
@@ -1568,7 +1568,7 @@ static void do_remove_conflicting_framebuffers(struct apertures_struct *a,
 		device = registered_fb[i]->device;
 		if (fb_do_apertures_overlap(gen_aper, a) ||
 			(primary && gen_aper && gen_aper->count &&
-			 gen_aper->ranges[0].base == VGA_FB_PHYS)) {
+			 gen_aper->ranges[0].base == VGA_FB_PHYS_BASE)) {
 
 			printk(KERN_INFO "fb%d: switching to %s from %s\n",
 			       i, name, registered_fb[i]->fix.id);
drivers/video/fbdev/vga16fb.c +6 -9
index e7767ed50c5b..595a69634082 100644
@@ -25,9 +25,6 @@
 #include <asm/io.h>
 #include <video/vga.h>
 
-#define VGA_FB_PHYS 0xA0000
-#define VGA_FB_PHYS_LEN 65536
-
 #define MODE_SKIP4	1
 #define MODE_8BPP	2
 #define MODE_CFB	4
@@ -87,8 +84,8 @@ static struct fb_var_screeninfo vga16fb_defined = {
 /* name should not depend on EGA/VGA */
 static const struct fb_fix_screeninfo vga16fb_fix = {
 	.id		= "VGA16 VGA",
-	.smem_start	= VGA_FB_PHYS,
-	.smem_len	= VGA_FB_PHYS_LEN,
+	.smem_start	= VGA_FB_PHYS_BASE,
+	.smem_len	= VGA_FB_PHYS_SIZE,
 	.type		= FB_TYPE_VGA_PLANES,
 	.type_aux	= FB_AUX_VGA_PLANES_VGA4,
 	.visual		= FB_VISUAL_PSEUDOCOLOR,
@@ -1357,8 +1354,8 @@ static int vga16fb_probe(struct platform_device *dev)
 		goto err_ioremap;
 	}
 
-	/* XXX share VGA_FB_PHYS and I/O region with vgacon and others */
-	info->screen_base = (void __iomem *)VGA_MAP_MEM(VGA_FB_PHYS, 0);
+	/* XXX share VGA_FB_PHYS_BASE and I/O region with vgacon and others */
+	info->screen_base = (void __iomem *)VGA_MAP_MEM(VGA_FB_PHYS_BASE, 0);
 
 	if (!info->screen_base) {
 		printk(KERN_ERR "vga16fb: unable to map device\n");
@@ -1409,8 +1406,8 @@ static int vga16fb_probe(struct platform_device *dev)
 
 	vga16fb_update_fix(info);
 
-	info->apertures->ranges[0].base = VGA_FB_PHYS;
-	info->apertures->ranges[0].size = VGA_FB_PHYS_LEN;
+	info->apertures->ranges[0].base = VGA_FB_PHYS_BASE;
+	info->apertures->ranges[0].size = VGA_FB_PHYS_SIZE;
 
 	if (register_framebuffer(info) < 0) {
 		printk(KERN_ERR "vga16fb: unable to register framebuffer\n");
include/video/vga.h +2 -0
index ef8e9fa9b9bd..947c0abd04ef 100644
@@ -22,6 +22,8 @@
 #include <asm/vga.h>
 #include <asm/byteorder.h>
 
+#define VGA_FB_PHYS_BASE	0xA0000 /* VGA framebuffer I/O base */
+#define VGA_FB_PHYS_SIZE	65536	/* VGA framebuffer I/O size */
 
 /* Some of the code below is taken from SVGAlib.  The original,
    unmodified copyright notice for that code is below. */
Signature · 1 line
2.36.1
author maintainer
#26 lore raw

PATCH 9/11 video/aperture: Remove conflicting VGA devices, if any

In reply to Thomas Zimmermann

On the primary graphics adapter, a driver might conflict with a VGA driver that controls the VGA framebuffer I/O range. Remove the VGA driver from the aperture helpers. Until now, this case has been hendled by fbdev, but it should work even with fbdev disabled.

---
 drivers/video/aperture.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/video/aperture.c +12 -2
index 101e13c2cf41..abc691284a77 100644
@@ -12,6 +12,8 @@
 #include <linux/types.h>
 #include <linux/vgaarb.h>
 
+#include <video/vga.h>
+
 /**
  * DOC: overview
  *
@@ -300,6 +302,16 @@ int aperture_remove_conflicting_devices(resource_size_t base, resource_size_t si
 	 */
 	sysfb_disable();
 
+	aperture_detach_devices(base, size);
+
+	/*
+	 * If this is the primary adapter, there could be a VGA device
+	 * that consumes the VGA framebuffer I/O range. Remove this device
+	 * as well.
+	 */
+	if (primary)
+		aperture_detach_devices(VGA_FB_PHYS_BASE, VGA_FB_PHYS_SIZE);
+
 #if IS_REACHABLE(CONFIG_FB)
 	a = alloc_apertures(1);
 	if (!a)
@@ -315,8 +327,6 @@ int aperture_remove_conflicting_devices(resource_size_t base, resource_size_t si
 		return ret;
 #endif
 
-	aperture_detach_devices(base, size);
-
 	return 0;
 }
 EXPORT_SYMBOL(aperture_remove_conflicting_devices);
Signature · 1 line
2.36.1
author maintainer
#28 lore raw

PATCH 10/11 fbdev: Acquire framebuffer apertures for firmware devices

In reply to Thomas Zimmermann

When registering a generic framebuffer, automatically acquire ownership of the framebuffer's I/O range. The device will now be handled by the aperture helpers. Fbdev-based conflict handling is no longer required.

---
 drivers/video/fbdev/core/fbmem.c | 33 ++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
drivers/video/fbdev/core/fbmem.c +33 -0
index 2237049327db..e556ad69f48f 100644
@@ -13,6 +13,7 @@
 
 #include <linux/module.h>
 
+#include <linux/aperture.h>
 #include <linux/compat.h>
 #include <linux/types.h>
 #include <linux/errno.h>
@@ -1739,6 +1740,32 @@ static void do_unregister_framebuffer(struct fb_info *fb_info)
 	put_fb_info(fb_info);
 }
 
+static int fbm_aperture_acquire_for_platform_device(struct fb_info *fb_info)
+{
+	struct apertures_struct *ap = fb_info->apertures;
+	struct device *dev = fb_info->device;
+	struct platform_device *pdev;
+	unsigned int i;
+	int ret;
+
+	if (!ap)
+		return 0;
+
+	if (!dev_is_platform(dev))
+		return 0;
+
+	pdev = to_platform_device(dev);
+
+	for (ret = 0, i = 0; i < ap->count; ++i) {
+		ret = devm_aperture_acquire_for_platform_device(pdev, ap->ranges[i].base,
+								ap->ranges[i].size);
+		if (ret)
+			break;
+	}
+
+	return ret;
+}
+
 /**
  * remove_conflicting_framebuffers - remove firmware-configured framebuffers
  * @a: memory range, users of which are to be removed
@@ -1789,6 +1816,12 @@ register_framebuffer(struct fb_info *fb_info)
 {
 	int ret;
 
+	if (fb_info->flags & FBINFO_MISC_FIRMWARE) {
+		ret = fbm_aperture_acquire_for_platform_device(fb_info);
+		if (ret)
+			return ret;
+	}
+
 	mutex_lock(&registration_lock);
 	ret = do_register_framebuffer(fb_info);
 	mutex_unlock(&registration_lock);
Signature · 1 line
2.36.1
author maintainer
#1 lore raw

PATCH 1/11 fbdev: Remove trailing whitespaces

In reply to Thomas Zimmermann

Fix coding style. No functional changes.

---
 drivers/video/fbdev/aty/aty128fb.c    |  52 ++---
 drivers/video/fbdev/aty/radeon_base.c |  66 +++---
 drivers/video/fbdev/chipsfb.c         |   6 +-
 drivers/video/fbdev/i810/i810_main.c  | 310 +++++++++++++-------------
 drivers/video/fbdev/imsttfb.c         |  28 +--
 drivers/video/fbdev/neofb.c           |  36 +--
 drivers/video/fbdev/riva/fbdev.c      |  62 +++---
 drivers/video/fbdev/skeletonfb.c      | 202 ++++++++---------
 drivers/video/fbdev/sstfb.c           |  38 ++--
 drivers/video/fbdev/tgafb.c           |  10 +-
 drivers/video/fbdev/vga16fb.c         |  86 +++----
 include/video/vga.h                   |  18 +-
 12 files changed, 457 insertions(+), 457 deletions(-)
drivers/video/fbdev/aty/aty128fb.c +26 -26
index b26c81233b6b..5cdbbba2a013 100644
@@ -23,7 +23,7 @@
  *			- Convert to new framebuffer API,
  *			  fix colormap setting at 16 bits/pixel (565)
  *
- *		  Paul Mundt 
+ *		  Paul Mundt
  *		  	- PCI hotplug
  *
  *		  Jon Smirl <[email protected]>
@@ -520,13 +520,13 @@ static const struct fb_ops aty128fb_ops = {
      *	- endian conversions may possibly be avoided by
      *    using the other register aperture. TODO.
      */
-static inline u32 _aty_ld_le32(volatile unsigned int regindex, 
+static inline u32 _aty_ld_le32(volatile unsigned int regindex,
 			       const struct aty128fb_par *par)
 {
 	return readl (par->regbase + regindex);
 }
 
-static inline void _aty_st_le32(volatile unsigned int regindex, u32 val, 
+static inline void _aty_st_le32(volatile unsigned int regindex, u32 val,
 				const struct aty128fb_par *par)
 {
 	writel (val, par->regbase + regindex);
@@ -559,12 +559,12 @@ static inline void _aty_st_8(unsigned int regindex, u8 val,
 
 static u32 _aty_ld_pll(unsigned int pll_index,
 		       const struct aty128fb_par *par)
-{       
+{
 	aty_st_8(CLOCK_CNTL_INDEX, pll_index & 0x3F);
 	return aty_ld_le32(CLOCK_CNTL_DATA);
 }
 
-    
+
 static void _aty_st_pll(unsigned int pll_index, u32 val,
 			const struct aty128fb_par *par)
 {
@@ -619,7 +619,7 @@ static int register_test(const struct aty128fb_par *par)
 		aty_st_le32(BIOS_0_SCRATCH, 0xAAAAAAAA);
 
 		if (aty_ld_le32(BIOS_0_SCRATCH) == 0xAAAAAAAA)
-			flag = 1; 
+			flag = 1;
 	}
 
 	aty_st_le32(BIOS_0_SCRATCH, val);	// restore value
@@ -901,7 +901,7 @@ static void aty128_get_pllinfo(struct aty128fb_par *par,
 
 	bios_hdr = BIOS_IN16(0x48);
 	bios_pll = BIOS_IN16(bios_hdr + 0x30);
-	
+
 	par->constants.ppll_max = BIOS_IN32(bios_pll + 0x16);
 	par->constants.ppll_min = BIOS_IN32(bios_pll + 0x12);
 	par->constants.xclk = BIOS_IN16(bios_pll + 0x08);
@@ -913,7 +913,7 @@ static void aty128_get_pllinfo(struct aty128fb_par *par,
 			par->constants.xclk, par->constants.ref_divider,
 			par->constants.ref_clk);
 
-}           
+}
 
 #ifdef CONFIG_X86
 static void __iomem *aty128_find_mem_vbios(struct aty128fb_par *par)
@@ -925,7 +925,7 @@ static void __iomem *aty128_find_mem_vbios(struct aty128fb_par *par)
 	 */
         u32  segstart;
         unsigned char __iomem *rom_base = NULL;
-                                                
+
         for (segstart=0x000c0000; segstart<0x000f0000; segstart+=0x00001000) {
                 rom_base = ioremap(segstart, 0x10000);
 		if (rom_base == NULL)
@@ -1118,12 +1118,12 @@ static int aty128_var_to_crtc(const struct fb_var_screeninfo *var,
 		v_sync_wid = 1;
 	else if (v_sync_wid > 0x1f)        /* 0x1f = max vwidth */
 		v_sync_wid = 0x1f;
-    
+
 	v_sync_strt = v_disp + lower;
 
 	h_sync_pol = sync & FB_SYNC_HOR_HIGH_ACT ? 0 : 1;
 	v_sync_pol = sync & FB_SYNC_VERT_HIGH_ACT ? 0 : 1;
-    
+
 	c_sync = sync & FB_SYNC_COMP_HIGH_ACT ? (1 << 4) : 0;
 
 	crtc->gen_cntl = 0x3000000L | c_sync | (dst << 8);
@@ -1301,11 +1301,11 @@ static void aty128_set_lcd_enable(struct aty128fb_par *par, int on)
 		aty_st_le32(LVDS_GEN_CNTL, reg);
 #ifdef CONFIG_FB_ATY128_BACKLIGHT
 		aty128_bl_set_power(info, FB_BLANK_UNBLANK);
-#endif	
+#endif
 	} else {
 #ifdef CONFIG_FB_ATY128_BACKLIGHT
 		aty128_bl_set_power(info, FB_BLANK_POWERDOWN);
-#endif	
+#endif
 		reg = aty_ld_le32(LVDS_GEN_CNTL);
 		reg |= LVDS_DISPLAY_DIS;
 		aty_st_le32(LVDS_GEN_CNTL, reg);
@@ -1481,7 +1481,7 @@ static int aty128_ddafifo(struct aty128_ddafifo *dsp,
  * This actually sets the video mode.
  */
 static int aty128fb_set_par(struct fb_info *info)
-{ 
+{
 	struct aty128fb_par *par = info->par;
 	u32 config;
 	int err;
@@ -1595,7 +1595,7 @@ static int aty128_encode_var(struct fb_var_screeninfo *var,
 	var->accel_flags = par->accel_flags;
 
 	return 0;
-}           
+}
 
 
 static int aty128fb_check_var(struct fb_var_screeninfo *var,
@@ -1979,12 +1979,12 @@ static int aty128_init(struct pci_dev *pdev, const struct pci_device_id *ent)
 			/* PowerBook Titanium */
 			if (of_machine_is_compatible("PowerBook3,2"))
 				default_vmode = VMODE_1152_768_60;
-	
-			if (default_cmode > 16) 
+
+			if (default_cmode > 16)
 				default_cmode = CMODE_32;
-			else if (default_cmode > 8) 
+			else if (default_cmode > 8)
 				default_cmode = CMODE_16;
-			else 
+			else
 				default_cmode = CMODE_8;
 
 			if (mac_vmode_to_var(default_vmode, default_cmode, &var))
@@ -1994,7 +1994,7 @@ static int aty128_init(struct pci_dev *pdev, const struct pci_device_id *ent)
 #endif /* CONFIG_PPC_PMAC */
 	{
 		if (mode_option)
-			if (fb_find_mode(&var, info, mode_option, NULL, 
+			if (fb_find_mode(&var, info, mode_option, NULL,
 					 0, &defaultmode, 8) == 0)
 				var = default_var;
 	}
@@ -2301,7 +2301,7 @@ static int aty128fb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
 	struct aty128fb_par *par = info->par;
 	u32 value;
 	int rc;
-    
+
 	switch (cmd) {
 	case FBIO_ATY128_SET_MIRROR:
 		if (par->chip_gen != rage_M3)
@@ -2313,8 +2313,8 @@ static int aty128fb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
 		par->crt_on = (value & 0x02) != 0;
 		if (!par->crt_on && !par->lcd_on)
 			par->lcd_on = 1;
-		aty128_set_crt_enable(par, par->crt_on);	
-		aty128_set_lcd_enable(par, par->lcd_on);	
+		aty128_set_crt_enable(par, par->crt_on);
+		aty128_set_lcd_enable(par, par->lcd_on);
 		return 0;
 	case FBIO_ATY128_GET_MIRROR:
 		if (par->chip_gen != rage_M3)
@@ -2331,7 +2331,7 @@ static void aty128_set_suspend(struct aty128fb_par *par, int suspend)
 
 	if (!par->pdev->pm_cap)
 		return;
-		
+
 	/* Set the chip into the appropriate suspend mode (we use D2,
 	 * D3 would require a complete re-initialisation of the chip,
 	 * including PCI config registers, clocks, AGP configuration, ...)
@@ -2376,12 +2376,12 @@ static int aty128_pci_suspend_late(struct device *dev, pm_message_t state)
 	 */
 	return 0;
 #endif /* CONFIG_PPC_PMAC */
-	 
+
 	if (state.event == pdev->dev.power.power_state.event)
 		return 0;
 
 	printk(KERN_DEBUG "aty128fb: suspending...\n");
-	
+
 	console_lock();
 
 	fb_set_suspend(info, 1);
drivers/video/fbdev/aty/radeon_base.c +33 -33

247 lines not on this page · raw message

drivers/video/fbdev/chipsfb.c +3 -3
index 393894af26f8..618fb6dbbedb 100644
@@ -122,7 +122,7 @@ static int chipsfb_set_par(struct fb_info *info)
 		info->var.blue.offset = 0;
 		info->var.red.length = info->var.green.length =
 			info->var.blue.length = 5;
-		
+
 	} else {
 		/* p->var.bits_per_pixel == 8 */
 		write_cr(0x13, 100);		// Set line length (doublewords)
@@ -131,13 +131,13 @@ static int chipsfb_set_par(struct fb_info *info)
 		write_xr(0x20, 0x00);		// 8 bit blitter mode
 
 		info->fix.line_length = 800;
-		info->fix.visual = FB_VISUAL_PSEUDOCOLOR;		
+		info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
 
  		info->var.red.offset = info->var.green.offset =
 			info->var.blue.offset = 0;
 		info->var.red.length = info->var.green.length =
 			info->var.blue.length = 8;
-		
+
 	}
 	return 0;
 }
drivers/video/fbdev/i810/i810_main.c +155 -155

947 lines not on this page · raw message

drivers/video/fbdev/imsttfb.c +14 -14
index 16f272a50811..f489386855c0 100644
@@ -86,7 +86,7 @@ enum {
 	SSTATUS	= 36, /* 0x90 */
 	PRC	= 37, /* 0x94 */
 
-#if 0	
+#if 0
 	/* PCI Registers */
 	DVID	= 0x00000000L,
 	SC	= 0x00000004L,
@@ -103,8 +103,8 @@ enum {
 	PDATA	= 0x04,
 	PPMASK	= 0x08,
 	PADDRR	= 0x0c,
-	PIDXLO	= 0x10,	
-	PIDXHI	= 0x14,	
+	PIDXLO	= 0x10,
+	PIDXHI	= 0x14,
 	PIDXDATA= 0x18,
 	PIDXCTL	= 0x1c
 };
@@ -131,7 +131,7 @@ enum {
 	SYSCLKC		= 0x18,	/* () System Clock C */
 	/*
 	 * Dot clock rate is 20MHz * (m + 1) / ((n + 1) * (p ? 2 * p : 1)
-	 * c is charge pump bias which depends on the VCO frequency  
+	 * c is charge pump bias which depends on the VCO frequency
 	 */
 	PIXM0		= 0x20,	/* () Pixel M 0 */
 	PIXN0		= 0x21,	/* () Pixel N 0 */
@@ -320,7 +320,7 @@ struct imstt_par {
 	__u32 ramdac;
 	__u32 palette[16];
 };
- 
+
 enum {
 	IBM = 0,
 	TVP = 1
@@ -373,7 +373,7 @@ static struct imstt_regvals tvp_reg_init_17 = {
 
 static struct imstt_regvals tvp_reg_init_18 = {
 	1152,
-  	0x0009, 0x0011, 0x059, 0x5b, 0x0003, 0x0031, 0x0397, 0x039a, 0x0000, 
+  	0x0009, 0x0011, 0x059, 0x5b, 0x0003, 0x0031, 0x0397, 0x039a, 0x0000,
 	0xfd, 0x3a, 0xf1,
 	{ 0x39, 0x38, 0x38 }, { 0xf3, 0xf3, 0xf2 }
 };
@@ -856,10 +856,10 @@ imsttfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
 }
 
 static int
-imsttfb_set_par(struct fb_info *info) 
+imsttfb_set_par(struct fb_info *info)
 {
 	struct imstt_par *par = info->par;
-		
+
 	if (!compute_imstt_regvals(par, info->var.xres, info->var.yres))
 		return -EINVAL;
 
@@ -930,7 +930,7 @@ imsttfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
 	return 0;
 }
 
-static int 
+static int
 imsttfb_blank(int blank, struct fb_info *info)
 {
 	struct imstt_par *par = info->par;
@@ -986,7 +986,7 @@ imsttfb_blank(int blank, struct fb_info *info)
 
 static void
 imsttfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
-{ 
+{
 	struct imstt_par *par = info->par;
 	__u32 Bpp, line_pitch, bgc, dx, dy, width, height;
 
@@ -1192,7 +1192,7 @@ imstt_set_cursor(struct imstt_par *par, struct fb_image *d, int on)
 	}
 }
 
-static int 
+static int
 imsttfb_cursor(struct fb_info *info, struct fb_cursor *cursor)
 {
 	struct imstt_par *par = info->par;
@@ -1200,7 +1200,7 @@ imsttfb_cursor(struct fb_info *info, struct fb_cursor *cursor)
 
 	if (cursor->dest == NULL && cursor->rop == ROP_XOR)
 		return 1;
-	
+
 	imstt_set_cursor(info, cursor, 0);
 
 	if (flags & FB_CUR_SETPOS) {
@@ -1470,7 +1470,7 @@ static int imsttfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	struct fb_info *info;
 	struct device_node *dp;
 	int ret = -ENOMEM;
-	
+
 	dp = pci_device_to_OF_node(pdev);
 	if(dp)
 		printk(KERN_INFO "%s: OF name %pOFn\n",__func__, dp);
@@ -1619,7 +1619,7 @@ static int __init imsttfb_init(void)
 #endif
 	return pci_register_driver(&imsttfb_pci_driver);
 }
- 
+
 static void __exit imsttfb_exit(void)
 {
 	pci_unregister_driver(&imsttfb_pci_driver);
drivers/video/fbdev/neofb.c +18 -18
index 28d32cbf496b..8ad2a79623af 100644
@@ -23,9 +23,9 @@
  *
  * 0.3.3
  *  - Porting over to new fbdev api. (jsimmons)
- *  
+ *
  * 0.3.2
- *  - got rid of all floating point (dok) 
+ *  - got rid of all floating point (dok)
  *
  * 0.3.1
  *  - added module license (dok)
@@ -1154,14 +1154,14 @@ static int neofb_set_par(struct fb_info *info)
 
 	switch (info->fix.accel) {
 		case FB_ACCEL_NEOMAGIC_NM2200:
-		case FB_ACCEL_NEOMAGIC_NM2230: 
-		case FB_ACCEL_NEOMAGIC_NM2360: 
-		case FB_ACCEL_NEOMAGIC_NM2380: 
+		case FB_ACCEL_NEOMAGIC_NM2230:
+		case FB_ACCEL_NEOMAGIC_NM2360:
+		case FB_ACCEL_NEOMAGIC_NM2380:
 			neo2200_accel_init(info, &info->var);
 			break;
 		default:
 			break;
-	}	
+	}
 	return 0;
 }
 
@@ -1493,15 +1493,15 @@ neofb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
 {
 	switch (info->fix.accel) {
 		case FB_ACCEL_NEOMAGIC_NM2200:
-		case FB_ACCEL_NEOMAGIC_NM2230: 
-		case FB_ACCEL_NEOMAGIC_NM2360: 
+		case FB_ACCEL_NEOMAGIC_NM2230:
+		case FB_ACCEL_NEOMAGIC_NM2360:
 		case FB_ACCEL_NEOMAGIC_NM2380:
 			neo2200_fillrect(info, rect);
 			break;
 		default:
 			cfb_fillrect(info, rect);
 			break;
-	}	
+	}
 }
 
 static void
@@ -1509,15 +1509,15 @@ neofb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
 {
 	switch (info->fix.accel) {
 		case FB_ACCEL_NEOMAGIC_NM2200:
-		case FB_ACCEL_NEOMAGIC_NM2230: 
-		case FB_ACCEL_NEOMAGIC_NM2360: 
-		case FB_ACCEL_NEOMAGIC_NM2380: 
+		case FB_ACCEL_NEOMAGIC_NM2230:
+		case FB_ACCEL_NEOMAGIC_NM2360:
+		case FB_ACCEL_NEOMAGIC_NM2380:
 			neo2200_copyarea(info, area);
 			break;
 		default:
 			cfb_copyarea(info, area);
 			break;
-	}	
+	}
 }
 
 static void
@@ -1536,20 +1536,20 @@ neofb_imageblit(struct fb_info *info, const struct fb_image *image)
 	}
 }
 
-static int 
+static int
 neofb_sync(struct fb_info *info)
 {
 	switch (info->fix.accel) {
 		case FB_ACCEL_NEOMAGIC_NM2200:
-		case FB_ACCEL_NEOMAGIC_NM2230: 
-		case FB_ACCEL_NEOMAGIC_NM2360: 
-		case FB_ACCEL_NEOMAGIC_NM2380: 
+		case FB_ACCEL_NEOMAGIC_NM2230:
+		case FB_ACCEL_NEOMAGIC_NM2360:
+		case FB_ACCEL_NEOMAGIC_NM2380:
 			neo2200_sync(info);
 			break;
 		default:
 			break;
 	}
-	return 0;		
+	return 0;
 }
 
 /*
drivers/video/fbdev/riva/fbdev.c +31 -31

237 lines not on this page · raw message

drivers/video/fbdev/skeletonfb.c +101 -101

431 lines not on this page · raw message

drivers/video/fbdev/sstfb.c +19 -19
index 27d4b0ace2d6..535ef4693cd4 100644
@@ -364,7 +364,7 @@ static int sstfb_check_var(struct fb_var_screeninfo *var,
 		return -EINVAL;
 	}
 	var->pixclock = KHZ2PICOS(freq);
-	
+
 	if (var->vmode & FB_VMODE_INTERLACED)
 		vBackPorch += (vBackPorch % 2);
 	if (var->vmode & FB_VMODE_DOUBLE) {
@@ -382,7 +382,7 @@ static int sstfb_check_var(struct fb_var_screeninfo *var,
 		printk(KERN_ERR "sstfb: Unsupported bpp %d\n", var->bits_per_pixel);
 		return -EINVAL;
 	}
-	
+
 	/* validity tests */
 	if (var->xres <= 1 || yDim <= 0 || var->hsync_len <= 1  ||
 	    hSyncOff <= 1  || var->left_margin <= 2  || vSyncOn <= 0 ||
@@ -392,7 +392,7 @@ static int sstfb_check_var(struct fb_var_screeninfo *var,
 
 	if (IS_VOODOO2(par)) {
 		/* Voodoo 2 limits */
-		tiles_in_X = (var->xres + 63 ) / 64 * 2;		
+		tiles_in_X = (var->xres + 63 ) / 64 * 2;
 
 		if (var->xres  > POW2(11) || yDim >= POW2(11)) {
 			printk(KERN_ERR "sstfb: Unsupported resolution %dx%d\n",
@@ -631,7 +631,7 @@ static int sstfb_set_par(struct fb_info *info)
 	lfbmode |= ( LFB_WORD_SWIZZLE_WR | LFB_BYTE_SWIZZLE_WR |
 		     LFB_WORD_SWIZZLE_RD | LFB_BYTE_SWIZZLE_RD );
 #endif
-	
+
 	if (clipping) {
 		sst_write(LFBMODE, lfbmode | EN_PXL_PIPELINE);
 	/*
@@ -684,7 +684,7 @@ static int sstfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
 	    | (green << info->var.green.offset)
 	    | (blue  << info->var.blue.offset)
 	    | (transp << info->var.transp.offset);
-	
+
 	par->palette[regno] = col;
 
 	return 0;
@@ -773,7 +773,7 @@ static void sstfb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
 {
 	struct sstfb_par *par = info->par;
 	u32 stride = info->fix.line_length;
-   
+
 	if (!IS_VOODOO2(par))
 		return;
 
@@ -795,17 +795,17 @@ static void sstfb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
  * FillRect 2D command (solidfill or invert (via ROP_XOR)) - Voodoo2 only
  */
 #if 0
-static void sstfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect) 
+static void sstfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
 {
 	struct sstfb_par *par = info->par;
 	u32 stride = info->fix.line_length;
 
 	if (!IS_VOODOO2(par))
 		return;
-   	
+
 	sst_write(BLTCLIPX, info->var.xres);
 	sst_write(BLTCLIPY, info->var.yres);
-	
+
 	sst_write(BLTDSTBASEADDR, 0);
 	sst_write(BLTCOLOR, rect->color);
 	sst_write(BLTROP, rect->rop == ROP_COPY ? BLTROP_COPY : BLTROP_XOR);
@@ -820,8 +820,8 @@ static void sstfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
 
 
 
-/* 
- * get lfb size 
+/*
+ * get lfb size
  */
 static int sst_get_memsize(struct fb_info *info, __u32 *memsize)
 {
@@ -859,8 +859,8 @@ static int sst_get_memsize(struct fb_info *info, __u32 *memsize)
 }
 
 
-/* 
- * DAC detection routines 
+/*
+ * DAC detection routines
  */
 
 /* fbi should be idle, and fifo emty and mem disabled */
@@ -963,7 +963,7 @@ static int sst_detect_ics(struct fb_info *info)
  * see detect_dac
  */
 
-static int sst_set_pll_att_ti(struct fb_info *info, 
+static int sst_set_pll_att_ti(struct fb_info *info,
 		const struct pll_timing *t, const int clock)
 {
 	struct sstfb_par *par = info->par;
@@ -1338,10 +1338,10 @@ static int sstfb_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		return -ENOMEM;
 
 	pci_set_drvdata(pdev, info);
-	
+
 	par  = info->par;
 	fix  = &info->fix;
-	
+
 	par->type = id->driver_data;
 	spec = &voodoo_spec[par->type];
 	f_ddprintk("found device : %s\n", spec->name);
@@ -1407,7 +1407,7 @@ static int sstfb_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	 * fact dithered to 16bit).
 	 */
 	fix->line_length = 2048; /* default value, for 24 or 32bit: 4096 */
-	
+
 	fb_find_mode(&info->var, info, mode_option, NULL, 0, NULL, 16);
 
 	if (sstfb_check_var(&info->var, info)) {
@@ -1419,7 +1419,7 @@ static int sstfb_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		printk(KERN_ERR "sstfb: can't set default video mode.\n");
 		goto fail;
 	}
-	
+
 	if (fb_alloc_cmap(&info->cmap, 256, 0)) {
 		printk(KERN_ERR "sstfb: can't alloc cmap memory.\n");
 		goto fail;
@@ -1465,7 +1465,7 @@ static void sstfb_remove(struct pci_dev *pdev)
 
 	info = pci_get_drvdata(pdev);
 	par = info->par;
-	
+
 	device_remove_file(info->dev, &device_attrs[0]);
 	sst_shutdown(info);
 	iounmap(info->screen_base);
drivers/video/fbdev/tgafb.c +5 -5
index ae0cf5540636..9266c76783cc 100644
@@ -729,7 +729,7 @@ tgafb_mono_imageblit(struct fb_info *info, const struct fb_image *image)
 
 		/* Handle another common case in which accel_putcs
 		   generates a large bitmap, which happens to be aligned.
-		   Allow the tail to be misaligned.  This case is 
+		   Allow the tail to be misaligned.  This case is
 		   interesting because we've not got to hold partial
 		   bytes across the words being written.  */
 
@@ -908,9 +908,9 @@ tgafb_imageblit(struct fb_info *info, const struct fb_image *image)
 }
 
 /**
- *      tgafb_fillrect - REQUIRED function. Can use generic routines if 
+ *      tgafb_fillrect - REQUIRED function. Can use generic routines if
  *                       non acclerated hardware and packed pixel based.
- *                       Draws a rectangle on the screen.               
+ *                       Draws a rectangle on the screen.
  *
  *      @info: frame buffer structure that represents a single frame buffer
  *      @rect: structure defining the rectagle and operation.
@@ -1044,7 +1044,7 @@ tgafb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
 
 /* Handle the special case of copying entire lines, e.g. during scrolling.
    We can avoid a lot of needless computation in this case.  In the 8bpp
-   case we need to use the COPY64 registers instead of mask writes into 
+   case we need to use the COPY64 registers instead of mask writes into
    the frame buffer to achieve maximum performance.  */
 
 static inline void
@@ -1251,7 +1251,7 @@ copyarea_8bpp(struct fb_info *info, u32 dx, u32 dy, u32 sx, u32 sy,
 }
 
 static void
-tgafb_copyarea(struct fb_info *info, const struct fb_copyarea *area) 
+tgafb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
 {
 	unsigned long dx, dy, width, height, sx, sy, vxres, vyres;
 	unsigned long line_length, bpp;
drivers/video/fbdev/vga16fb.c +43 -43

301 lines not on this page · raw message

include/video/vga.h +9 -9
index d334e64c1c19..ef8e9fa9b9bd 100644
@@ -2,15 +2,15 @@
  * linux/include/video/vga.h -- standard VGA chipset interaction
  *
  * Copyright 1999 Jeff Garzik <[email protected]>
- * 
+ *
  * Copyright history from vga16fb.c:
  *	Copyright 1999 Ben Pfaff and Petr Vandrovec
- *	Based on VGA info at http://www.osdever.net/FreeVGA/home.htm 
+ *	Based on VGA info at http://www.osdever.net/FreeVGA/home.htm
  *	Based on VESA framebuffer (c) 1998 Gerd Knorr
  *
  * This file is subject to the terms and conditions of the GNU General
  * Public License.  See the file COPYING in the main directory of this
- * archive for more details.  
+ * archive for more details.
  *
  */
 
@@ -190,7 +190,7 @@ struct vgastate {
 	__u32 num_gfx;		/* number of gfx registers, 0 for default  */
 	__u32 num_seq;		/* number of seq registers, 0 for default  */
 	void *vidstate;
-};	
+};
 
 extern int save_vga(struct vgastate *state);
 extern int restore_vga(struct vgastate *state);
@@ -198,7 +198,7 @@ extern int restore_vga(struct vgastate *state);
 /*
  * generic VGA port read/write
  */
- 
+
 static inline unsigned char vga_io_r (unsigned short port)
 {
 	return inb_p(port);
@@ -261,7 +261,7 @@ static inline void vga_w_fast (void __iomem *regbase, unsigned short port,
 /*
  * VGA CRTC register read/write
  */
- 
+
 static inline unsigned char vga_rcrt (void __iomem *regbase, unsigned char reg)
 {
         vga_w (regbase, VGA_CRT_IC, reg);
@@ -314,7 +314,7 @@ static inline void vga_mm_wcrt (void __iomem *regbase, unsigned char reg, unsign
 /*
  * VGA sequencer register read/write
  */
- 
+
 static inline unsigned char vga_rseq (void __iomem *regbase, unsigned char reg)
 {
         vga_w (regbase, VGA_SEQ_I, reg);
@@ -366,7 +366,7 @@ static inline void vga_mm_wseq (void __iomem *regbase, unsigned char reg, unsign
 /*
  * VGA graphics controller register read/write
  */
- 
+
 static inline unsigned char vga_rgfx (void __iomem *regbase, unsigned char reg)
 {
         vga_w (regbase, VGA_GFX_I, reg);
@@ -419,7 +419,7 @@ static inline void vga_mm_wgfx (void __iomem *regbase, unsigned char reg, unsign
 /*
  * VGA attribute controller register read/write
  */
- 
+
 static inline unsigned char vga_rattr (void __iomem *regbase, unsigned char reg)
 {
         vga_w (regbase, VGA_ATT_IW, reg);
Signature · 1 line
2.36.1
author maintainer
#31 lore raw

PATCH 11/11 fbdev: Remove conflict-handling code

In reply to Thomas Zimmermann

Remove the call to do_remove_conflicting_framebuffers() from the framebuffer registration. Aperture helpers take care of removing conflicting devices. With all ownership information stored in the aperture datastrcutures, remove remove_conflicting_framebuffers() entirely.

This change also rectifies DRM generic-framebuffer registration, which tried to unregister conflicting framebuffers, even though it's entirely build on top of DRM.

---
 drivers/video/aperture.c         | 21 -------
 drivers/video/fbdev/core/fbmem.c | 99 --------------------------------
 include/linux/fb.h               |  2 -
 3 files changed, 122 deletions(-)
drivers/video/aperture.c +0 -21
index abc691284a77..9e6bcc03a1a4 100644
@@ -2,7 +2,6 @@
 
 #include <linux/aperture.h>
 #include <linux/device.h>
-#include <linux/fb.h> /* for old fbdev helpers */
 #include <linux/list.h>
 #include <linux/mutex.h>
 #include <linux/pci.h>
@@ -286,11 +285,6 @@ static void aperture_detach_devices(resource_size_t base, resource_size_t size)
 int aperture_remove_conflicting_devices(resource_size_t base, resource_size_t size,
 					bool primary, const char *name)
 {
-#if IS_REACHABLE(CONFIG_FB)
-	struct apertures_struct *a;
-	int ret;
-#endif
-
 	/*
 	 * If a driver asked to unregister a platform device registered by
 	 * sysfb, then can be assumed that this is a driver for a display
@@ -312,21 +306,6 @@ int aperture_remove_conflicting_devices(resource_size_t base, resource_size_t si
 	if (primary)
 		aperture_detach_devices(VGA_FB_PHYS_BASE, VGA_FB_PHYS_SIZE);
 
-#if IS_REACHABLE(CONFIG_FB)
-	a = alloc_apertures(1);
-	if (!a)
-		return -ENOMEM;
-
-	a->ranges[0].base = base;
-	a->ranges[0].size = size;
-
-	ret = remove_conflicting_framebuffers(a, name, primary);
-	kfree(a);
-
-	if (ret)
-		return ret;
-#endif
-
 	return 0;
 }
 EXPORT_SYMBOL(aperture_remove_conflicting_devices);
drivers/video/fbdev/core/fbmem.c +0 -99

117 lines not on this page · raw message

include/linux/fb.h +0 -2
index b91c77016560..453c3b2b6b8e 100644
@@ -615,8 +615,6 @@ extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
 /* drivers/video/fbmem.c */
 extern int register_framebuffer(struct fb_info *fb_info);
 extern void unregister_framebuffer(struct fb_info *fb_info);
-extern int remove_conflicting_framebuffers(struct apertures_struct *a,
-					   const char *name, bool primary);
 extern int fb_prepare_logo(struct fb_info *fb_info, int rotate);
 extern int fb_show_logo(struct fb_info *fb_info, int rotate);
 extern char* fb_get_buffer_offset(struct fb_info *info, struct fb_pixmap *buf, u32 size);
Signature · 1 line
2.36.1
#4 lore raw

Re: [PATCH 02/11] fbdev/vga16fb: Create EGA/VGA devices in sysfb code

In reply to Thomas Zimmermann

Hello Thomas,

Quoted 19 lines · Thomas Zimmermann

Move the device-creation from vga16fb to sysfb code. Move the few extra videomode checks into vga16fb's probe function.

The vga16fb driver requires a screen_info for type VIDEO_TYPE_VGAC or VIDEO_TYPE_EGAC. Such code is nowhere present in the kernel, except for some MIPS systems. It's not clear if the vga16fb driver actually works in practice.

---
 drivers/firmware/sysfb.c      |  4 +++
 drivers/video/fbdev/vga16fb.c | 59 +++++++++++++++++------------------
 2 files changed, 32 insertions(+), 31 deletions(-)
drivers/firmware/sysfb.c +0 -0
index 1f276f108cc9..3fd3563d962b 100644

drivers/firmware/sysfb.c static __init int sysfb_init(void) · line 100

Quoted 7 lines
drivers/firmware/sysfb.c +4 -0
@@ -94,6 +94,10 @@ static __init int sysfb_init(void)
 		name = "efi-framebuffer";
 	else if (si->orig_video_isVGA == VIDEO_TYPE_VLFB)
 		name = "vesa-framebuffer";
+	else if (si->orig_video_isVGA == VIDEO_TYPE_VGAC)
+		name = "vga-framebuffer";
+	else if (si->orig_video_isVGA == VIDEO_TYPE_EGAC)
+

I wonder if we really need to do this distinction or could just have a single platform device for both VIDEO_TYPE_VGAC and VIDEO_TYPE_EGAC. After all, the same fbdev driver is bound against both platform devices.

[...]

Quoted 6 lines
drivers/firmware/sysfb.c +1 -0
 static int vga16fb_probe(struct platform_device *dev)
 {
+	struct screen_info *si;
 	struct fb_info *info;
 	struct vga16fb_par *par;
 	int i;

drivers/firmware/sysfb.c static __init int sysfb_init(void)

Quoted 10 lines
drivers/firmware/sysfb.c +8 -0
 	int ret = 0;
 
+	si = dev_get_platdata(&dev->dev);
+	if (!si)
+		return -ENODEV;
+
+	ret = check_mode_supported(si);
+	if (ret)
+		return ret;
+

What do you see as the advantage of moving the check to the driver's probe?

Because after this change the platform driver will be registered but for no reason, since can't even probe if orig_video_isVGA is neither VGAC nor EGAC.

[...]

drivers/firmware/sysfb.c

Quoted 6 lines
drivers/firmware/sysfb.c +6 -0
+static const struct platform_device_id vga16fb_driver_id_table[] = {
+	{"ega-framebuffer", 0},
+	{"vga-framebuffer", 0},
+	{ }
+};
+

The fact that the two entries don't have a platform data is an indication for me that we could just consolidate in a single "vga16-framebuffer" or smt. I know that this won't be consistent with efi, vesa, etc but I don't think is that important and also quite likely we will get rid of this driver and the platform device registration soon. Since as you said, it's unclear that is even used.

drivers/firmware/sysfb.c

Quoted 7 lines

static struct platform_driver vga16fb_driver = {

drivers/firmware/sysfb.c +1 -1
 	.probe = vga16fb_probe,
 	.remove = vga16fb_remove,
 	.driver = {
-		.name = "vga16fb",
+		.name = "vga-framebuffer",
 	},

Maybe "vga16-framebuffer" instead? Since for example VESA is also VGA AFAIK.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat
maintainer Reviewed-by on v1 3/11
#10 lore raw

Re: [PATCH 03/11] fbdev/vga16fb: Auto-generate module init/exit code

In reply to Thomas Zimmermann
Quoted 4 lines · Thomas Zimmermann

Move vgag16fb's option parsing into the driver's probe function and generate the rest of the module's init/exit functions from macros. Keep the options code, although there are no options defined.

Ah, I see now why you wanted to move the check to the probe function. If is to allow this cleanup then discard that comment from previous patch and I'm OK with the move.

Maybe you could comment in patch 02/11 commit message that the check is moved to the probe handler to allow this cleanup as a follow-up patch ?

Quoted 18 lines
---
 drivers/video/fbdev/vga16fb.c | 35 ++++++++++-------------------------
 1 file changed, 10 insertions(+), 25 deletions(-)
drivers/video/fbdev/vga16fb.c +3 -0
index f7c1bb018843..e7767ed50c5b 100644
@@ -1321,12 +1321,21 @@ static int __init vga16fb_setup(char *options)
 
 static int vga16fb_probe(struct platform_device *dev)
 {
+#ifndef MODULE
+	char *option = NULL;
+#endif
 	struct screen_info *si;
 	struct fb_info *info;

drivers/video/fbdev/vga16fb.c static int __init vga16fb_setup(char *options) · line 1338

Quoted 10 lines
drivers/video/fbdev/vga16fb.c +6 -0
 	struct vga16fb_par *par;
 	int i;
 	int ret = 0;
 
+#ifndef MODULE
+	if (fb_get_options("vga16fb", &option))
+		return -ENODEV;
+	vga16fb_setup(option);
+#endif
+

I would just drop these ifdefery and have the option unconditionally. It seems that's what most fbdev drivers do AFAICT.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat
author maintainer
#5 lore raw

Re: [PATCH 02/11] fbdev/vga16fb: Create EGA/VGA devices in sysfb code

In reply to Javier Martinez Canillas

Hi Javier,

I'll try to give the motivation of this patch below. I known it's rather hypothetical as the VGA driver is probably not used much.

Am 08.07.22 um 15:09 schrieb Javier Martinez Canillas:

Quoted 17 lines

Hello Thomas,

Quoted 14 lines · Thomas Zimmermann

Move the device-creation from vga16fb to sysfb code. Move the few extra videomode checks into vga16fb's probe function.

The vga16fb driver requires a screen_info for type VIDEO_TYPE_VGAC or VIDEO_TYPE_EGAC. Such code is nowhere present in the kernel, except for some MIPS systems. It's not clear if the vga16fb driver actually works in practice.

---
  drivers/firmware/sysfb.c      |  4 +++
  drivers/video/fbdev/vga16fb.c | 59 +++++++++++++++++------------------
  2 files changed, 32 insertions(+), 31 deletions(-)
Quoted 16 lines

drivers/firmware/sysfb.c static __init int sysfb_init(void) · line 100

Quoted 12 lines
drivers/firmware/sysfb.c +4 -0
index 1f276f108cc9..3fd3563d962b 100644
@@ -94,6 +94,10 @@ static __init int sysfb_init(void)
  		name = "efi-framebuffer";
  	else if (si->orig_video_isVGA == VIDEO_TYPE_VLFB)
  		name = "vesa-framebuffer";
+	else if (si->orig_video_isVGA == VIDEO_TYPE_VGAC)
+		name = "vga-framebuffer";
+	else if (si->orig_video_isVGA == VIDEO_TYPE_EGAC)
+

I wonder if we really need to do this distinction or could just have a single platform device for both VIDEO_TYPE_VGAC and VIDEO_TYPE_EGAC. After all, the same fbdev driver is bound against both platform devices.

With the current driver, we don't strictly need to distinguish. But the sysfb code is the one we care about. So I wanted it to be clear and nicely looking. All the mode tests, etc depend on the driver (which no one cares about).

There's also a difference in hardware features between EGA and VGA. Most notably, VGA has much better color support.

Quoted 22 lines

[...]

Quoted 6 lines
  static int vga16fb_probe(struct platform_device *dev)
  {
drivers/firmware/sysfb.c +1 -0
+	struct screen_info *si;
  	struct fb_info *info;
  	struct vga16fb_par *par;
  	int i;

drivers/firmware/sysfb.c

Quoted 10 lines
drivers/firmware/sysfb.c +8 -0
  	int ret = 0;
 
+	si = dev_get_platdata(&dev->dev);
+	if (!si)
+		return -ENODEV;
+
+	ret = check_mode_supported(si);
+	if (ret)
+		return ret;
+

What do you see as the advantage of moving the check to the driver's probe?

Quoted 2 lines

Because after this change the platform driver will be registered but for no reason, since can't even probe if orig_video_isVGA is neither VGAC nor EGAC.

The driver only supports very specific modes, which may not be what screen_info detected. Note that VGAC/EGAC can also refer to text-mode buffers. The current vgacon could be turned into a platform driver that adopts such a text buffer and integrates it with aperture helpers.

Quoted 11 lines

[...]

drivers/firmware/sysfb.c

Quoted 6 lines
drivers/firmware/sysfb.c +6 -0
+static const struct platform_device_id vga16fb_driver_id_table[] = {
+	{"ega-framebuffer", 0},
+	{"vga-framebuffer", 0},
+	{ }
+};
+

The fact that the two entries don't have a platform data is an indication for

The name is the indication. I know that vga16 doesn't treat them differently.

Quoted 5 lines

me that we could just consolidate in a single "vga16-framebuffer" or smt. I know that this won't be consistent with efi, vesa, etc but I don't think is that important and also quite likely we will get rid of this driver and the platform device registration soon. Since as you said, it's unclear that is even used.

There's mips code in the arch/ directory that appears to setup screen_info in the correct way. I can't say whether that's still useful to anyone. On x86, I could set a VGA mode on the kernel command line, but screen_info's isVGA only contained '1'. It might be possible to fix this easily by setting the right values in vga_probe(). [1] I simply don't have the time to provide a patch and deal with the potential fallout of such a change.

Quoted 10 lines

drivers/firmware/sysfb.c

Quoted 8 lines
  static struct platform_driver vga16fb_driver = {
  	.probe = vga16fb_probe,
  	.remove = vga16fb_remove,
  	.driver = {
drivers/firmware/sysfb.c +1 -1
-		.name = "vga16fb",
+		.name = "vga-framebuffer",
  	},

Maybe "vga16-framebuffer" instead? Since for example VESA is also VGA AFAIK.

VESA is something else than VGA. Setting a VESA mode (done via INT 10h IIRC) and then fiddling with VGA state will likely produce broken output on the screen.

Best regards
Thomas

[1] https://elixir.bootlin.com/linux/v5.18.10/source/arch/x86/boot/video-vga.c#L231

Quoted 1 line
Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev
author maintainer
#11 lore raw

Re: [PATCH 03/11] fbdev/vga16fb: Auto-generate module init/exit code

In reply to Javier Martinez Canillas

Hi

Am 08.07.22 um 15:16 schrieb Javier Martinez Canillas:

Quoted 6 lines · Thomas Zimmermann
Quoted 4 lines

Move vgag16fb's option parsing into the driver's probe function and generate the rest of the module's init/exit functions from macros. Keep the options code, although there are no options defined.

Quoted 6 lines

Ah, I see now why you wanted to move the check to the probe function. If is to allow this cleanup then discard that comment from previous patch and I'm OK with the move.

Maybe you could comment in patch 02/11 commit message that the check is moved to the probe handler to allow this cleanup as a follow-up patch ?

Sure.

I mostly wanted to use module_platform_driver(). The options handling is in the way.

Quoted 23 lines
Quoted 23 lines
---
  drivers/video/fbdev/vga16fb.c | 35 ++++++++++-------------------------
  1 file changed, 10 insertions(+), 25 deletions(-)
drivers/video/fbdev/vga16fb.c +3 -0
index f7c1bb018843..e7767ed50c5b 100644
@@ -1321,12 +1321,21 @@ static int __init vga16fb_setup(char *options)
 
  static int vga16fb_probe(struct platform_device *dev)
  {
+#ifndef MODULE
+	char *option = NULL;
+#endif
  	struct screen_info *si;
  	struct fb_info *info;
  	struct vga16fb_par *par;
  	int i;
  	int ret = 0;
 
Quoted 9 lines

drivers/video/fbdev/vga16fb.c static int __init vga16fb_setup(char *options) · line 1338

Quoted 6 lines
drivers/video/fbdev/vga16fb.c +6 -0
+#ifndef MODULE
+	if (fb_get_options("vga16fb", &option))
+		return -ENODEV;
+	vga16fb_setup(option);
+#endif
+

I would just drop these ifdefery and have the option unconditionally. It seems that's what most fbdev drivers do AFAICT.

Or can we kill it entirely? There are no actual options.

Best regards
Thomas

Quoted 3 lines
Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev
#6 lore raw

Re: [PATCH 02/11] fbdev/vga16fb: Create EGA/VGA devices in sysfb code

In reply to Thomas Zimmermann

Hello Thomas,

Quoted 40 lines · Thomas Zimmermann

Hi Javier,

I'll try to give the motivation of this patch below. I known it's rather hypothetical as the VGA driver is probably not used much.

Am 08.07.22 um 15:09 schrieb Javier Martinez Canillas:

Quoted 17 lines

Hello Thomas,

Quoted 14 lines · Thomas Zimmermann

Move the device-creation from vga16fb to sysfb code. Move the few extra videomode checks into vga16fb's probe function.

The vga16fb driver requires a screen_info for type VIDEO_TYPE_VGAC or VIDEO_TYPE_EGAC. Such code is nowhere present in the kernel, except for some MIPS systems. It's not clear if the vga16fb driver actually works in practice.

---
  drivers/firmware/sysfb.c      |  4 +++
  drivers/video/fbdev/vga16fb.c | 59 +++++++++++++++++------------------
  2 files changed, 32 insertions(+), 31 deletions(-)
Quoted 16 lines

drivers/firmware/sysfb.c static __init int sysfb_init(void) · line 100

Quoted 12 lines
drivers/firmware/sysfb.c +4 -0
index 1f276f108cc9..3fd3563d962b 100644
@@ -94,6 +94,10 @@ static __init int sysfb_init(void)
  		name = "efi-framebuffer";
  	else if (si->orig_video_isVGA == VIDEO_TYPE_VLFB)
  		name = "vesa-framebuffer";
+	else if (si->orig_video_isVGA == VIDEO_TYPE_VGAC)
+		name = "vga-framebuffer";
+	else if (si->orig_video_isVGA == VIDEO_TYPE_EGAC)
+

I wonder if we really need to do this distinction or could just have a single platform device for both VIDEO_TYPE_VGAC and VIDEO_TYPE_EGAC. After all, the same fbdev driver is bound against both platform devices.

Quoted 5 lines

With the current driver, we don't strictly need to distinguish. But the sysfb code is the one we care about. So I wanted it to be clear and nicely looking. All the mode tests, etc depend on the driver (which no one cares about).

Right. That is a good point. We don't want to leak a driver implementation detail in the sysfb code. And in theory there could be for example a DRM driver for EGA and one for VGA.

Quoted 3 lines

There's also a difference in hardware features between EGA and VGA. Most notably, VGA has much better color support.

Yes, I know the differences. My point was that the orig_video_isVGA was used to make the distinction and that the same driver supported both, but as you said that may not be the case and separate drivers could be used.

Quoted 22 lines
Quoted 22 lines

[...]

Quoted 6 lines
  static int vga16fb_probe(struct platform_device *dev)
  {
drivers/firmware/sysfb.c +1 -0
+	struct screen_info *si;
  	struct fb_info *info;
  	struct vga16fb_par *par;
  	int i;

drivers/firmware/sysfb.c

Quoted 10 lines
drivers/firmware/sysfb.c +8 -0
  	int ret = 0;
 
+	si = dev_get_platdata(&dev->dev);
+	if (!si)
+		return -ENODEV;
+
+	ret = check_mode_supported(si);
+	if (ret)
+		return ret;
+

What do you see as the advantage of moving the check to the driver's probe?

Quoted 8 lines
Quoted 2 lines

Because after this change the platform driver will be registered but for no reason, since can't even probe if orig_video_isVGA is neither VGAC nor EGAC.

The driver only supports very specific modes, which may not be what screen_info detected. Note that VGAC/EGAC can also refer to text-mode buffers. The current vgacon could be turned into a platform driver that adopts such a text buffer and integrates it with aperture helpers.

Yes, and also there's also the monochrome variant of VGA and EGA (VGAM/EGAM).

Should we also make that distinction or for example "vga-framebuffer" should handle both color and monochrome variants if at some point vgacon is turned into a fbdev or DRM driver ?

Quoted 12 lines
Quoted 11 lines

[...]

drivers/firmware/sysfb.c

Quoted 6 lines
drivers/firmware/sysfb.c +6 -0
+static const struct platform_device_id vga16fb_driver_id_table[] = {
+	{"ega-framebuffer", 0},
+	{"vga-framebuffer", 0},
+	{ }
+};
+

The fact that the two entries don't have a platform data is an indication for

Quoted 3 lines

The name is the indication. I know that vga16 doesn't treat them differently.

Yes, my point was that the platform device name used to bind is an internal Linux interface that could be changed later if needed. But I understand your point and since the platform device names are exposed to user-space, makes more sense for them to reflect what devices are bound even when the existing driver doesn't treat them differently.

Quoted 6 lines
Quoted 5 lines

me that we could just consolidate in a single "vga16-framebuffer" or smt. I know that this won't be consistent with efi, vesa, etc but I don't think is that important and also quite likely we will get rid of this driver and the platform device registration soon. Since as you said, it's unclear that is even used.

Quoted 8 lines

There's mips code in the arch/ directory that appears to setup screen_info in the correct way. I can't say whether that's still useful to anyone. On x86, I could set a VGA mode on the kernel command line, but screen_info's isVGA only contained '1'. It might be possible to fix this easily by setting the right values in vga_probe(). [1] I simply don't have the time to provide a patch and deal with the potential fallout of such a change.

Indeed. This seems to be a remnant from the time when isVGA was just a bool and then at some point the field semantics was extended to denote the mode but the existing users weren't fixed (nor the field named to reflect this).

Probably should be cleaned up at some point but unsure if the churn would be worth it.

Quoted 11 lines
Quoted 10 lines

drivers/firmware/sysfb.c

Quoted 8 lines
  static struct platform_driver vga16fb_driver = {
  	.probe = vga16fb_probe,
  	.remove = vga16fb_remove,
  	.driver = {
drivers/firmware/sysfb.c +1 -1
-		.name = "vga16fb",
+		.name = "vga-framebuffer",
  	},

Maybe "vga16-framebuffer" instead? Since for example VESA is also VGA AFAIK.

Quoted 4 lines

VESA is something else than VGA. Setting a VESA mode (done via INT 10h IIRC) and then fiddling with VGA state will likely produce broken output on the screen.

Technically it is something else but Linux conflates them in many places. For example, as you mentioned one can change the VESA modes using the "vga" param (which confusingly leads to the use of vesafb+fbcon driver instead of vgacon).

That's why I think that "vga-framebuffer" as driver name would be misleading. Specially since it would also bind to the "ega-framebuffer" platform device.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat
#12 lore raw

Re: [PATCH 03/11] fbdev/vga16fb: Auto-generate module init/exit code

In reply to Thomas Zimmermann
Quoted 13 lines · Thomas Zimmermann

Hi

Am 08.07.22 um 15:16 schrieb Javier Martinez Canillas:

Quoted 10 lines · Thomas Zimmermann
Quoted 4 lines

Move vgag16fb's option parsing into the driver's probe function and generate the rest of the module's init/exit functions from macros. Keep the options code, although there are no options defined.

Ah, I see now why you wanted to move the check to the probe function. If is to allow this cleanup then discard that comment from previous patch and I'm OK with the move.

Quoted 8 lines
Quoted 2 lines

Maybe you could comment in patch 02/11 commit message that the check is moved to the probe handler to allow this cleanup as a follow-up patch ?

Sure.

I mostly wanted to use module_platform_driver(). The options handling is in the way.

Yes, I got it when looked at this patch.

Quoted 33 lines
Quoted 23 lines
Quoted 23 lines
---
  drivers/video/fbdev/vga16fb.c | 35 ++++++++++-------------------------
  1 file changed, 10 insertions(+), 25 deletions(-)
drivers/video/fbdev/vga16fb.c +3 -0
index f7c1bb018843..e7767ed50c5b 100644
@@ -1321,12 +1321,21 @@ static int __init vga16fb_setup(char *options)
 
  static int vga16fb_probe(struct platform_device *dev)
  {
+#ifndef MODULE
+	char *option = NULL;
+#endif
  	struct screen_info *si;
  	struct fb_info *info;
  	struct vga16fb_par *par;
  	int i;
  	int ret = 0;
 
Quoted 9 lines

drivers/video/fbdev/vga16fb.c static int __init vga16fb_setup(char *options) · line 1338

Quoted 6 lines
drivers/video/fbdev/vga16fb.c +6 -0
+#ifndef MODULE
+	if (fb_get_options("vga16fb", &option))
+		return -ENODEV;
+	vga16fb_setup(option);
+#endif
+

I would just drop these ifdefery and have the option unconditionally. It seems that's what most fbdev drivers do AFAICT.

Quoted 2 lines

Or can we kill it entirely? There are no actual options.

That sounds good to me as well.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat
author maintainer
#7 lore raw

Re: [PATCH 02/11] fbdev/vga16fb: Create EGA/VGA devices in sysfb code

In reply to Javier Martinez Canillas

Hi Javier

Am 11.07.22 um 11:54 schrieb Javier Martinez Canillas:

Quoted 158 lines

Hello Thomas,

Quoted 40 lines · Thomas Zimmermann

Hi Javier,

I'll try to give the motivation of this patch below. I known it's rather hypothetical as the VGA driver is probably not used much.

Am 08.07.22 um 15:09 schrieb Javier Martinez Canillas:

Quoted 17 lines

Hello Thomas,

Quoted 14 lines · Thomas Zimmermann

Move the device-creation from vga16fb to sysfb code. Move the few extra videomode checks into vga16fb's probe function.

The vga16fb driver requires a screen_info for type VIDEO_TYPE_VGAC or VIDEO_TYPE_EGAC. Such code is nowhere present in the kernel, except for some MIPS systems. It's not clear if the vga16fb driver actually works in practice.

---
   drivers/firmware/sysfb.c      |  4 +++
   drivers/video/fbdev/vga16fb.c | 59 +++++++++++++++++------------------
   2 files changed, 32 insertions(+), 31 deletions(-)
Quoted 16 lines

drivers/firmware/sysfb.c static __init int sysfb_init(void) · line 100

Quoted 12 lines
drivers/firmware/sysfb.c +4 -0
index 1f276f108cc9..3fd3563d962b 100644
@@ -94,6 +94,10 @@ static __init int sysfb_init(void)
   		name = "efi-framebuffer";
   	else if (si->orig_video_isVGA == VIDEO_TYPE_VLFB)
   		name = "vesa-framebuffer";
+	else if (si->orig_video_isVGA == VIDEO_TYPE_VGAC)
+		name = "vga-framebuffer";
+	else if (si->orig_video_isVGA == VIDEO_TYPE_EGAC)
+

I wonder if we really need to do this distinction or could just have a single platform device for both VIDEO_TYPE_VGAC and VIDEO_TYPE_EGAC. After all, the same fbdev driver is bound against both platform devices.

Quoted 5 lines

With the current driver, we don't strictly need to distinguish. But the sysfb code is the one we care about. So I wanted it to be clear and nicely looking. All the mode tests, etc depend on the driver (which no one cares about).

Right. That is a good point. We don't want to leak a driver implementation detail in the sysfb code. And in theory there could be for example a DRM driver for EGA and one for VGA.

Quoted 3 lines

There's also a difference in hardware features between EGA and VGA. Most notably, VGA has much better color support.

Yes, I know the differences. My point was that the orig_video_isVGA was used to make the distinction and that the same driver supported both, but as you said that may not be the case and separate drivers could be used.

Quoted 22 lines
Quoted 22 lines

[...]

Quoted 6 lines
   static int vga16fb_probe(struct platform_device *dev)
   {
drivers/firmware/sysfb.c +1 -0
+	struct screen_info *si;
   	struct fb_info *info;
   	struct vga16fb_par *par;
   	int i;

drivers/firmware/sysfb.c

Quoted 10 lines
drivers/firmware/sysfb.c +8 -0
   	int ret = 0;
 
+	si = dev_get_platdata(&dev->dev);
+	if (!si)
+		return -ENODEV;
+
+	ret = check_mode_supported(si);
+	if (ret)
+		return ret;
+

What do you see as the advantage of moving the check to the driver's probe?

Quoted 8 lines
Quoted 2 lines

Because after this change the platform driver will be registered but for no reason, since can't even probe if orig_video_isVGA is neither VGAC nor EGAC.

The driver only supports very specific modes, which may not be what screen_info detected. Note that VGAC/EGAC can also refer to text-mode buffers. The current vgacon could be turned into a platform driver that adopts such a text buffer and integrates it with aperture helpers.

Yes, and also there's also the monochrome variant of VGA and EGA (VGAM/EGAM).

Should we also make that distinction or for example "vga-framebuffer" should handle both color and monochrome variants if at some point vgacon is turned into a fbdev or DRM driver ?

Quoted 12 lines
Quoted 11 lines

[...]

drivers/firmware/sysfb.c

Quoted 6 lines
drivers/firmware/sysfb.c +6 -0
+static const struct platform_device_id vga16fb_driver_id_table[] = {
+	{"ega-framebuffer", 0},
+	{"vga-framebuffer", 0},
+	{ }
+};
+

The fact that the two entries don't have a platform data is an indication for

Quoted 3 lines

The name is the indication. I know that vga16 doesn't treat them differently.

Yes, my point was that the platform device name used to bind is an internal Linux interface that could be changed later if needed. But I understand your point and since the platform device names are exposed to user-space, makes more sense for them to reflect what devices are bound even when the existing driver doesn't treat them differently.

Quoted 6 lines
Quoted 5 lines

me that we could just consolidate in a single "vga16-framebuffer" or smt. I know that this won't be consistent with efi, vesa, etc but I don't think is that important and also quite likely we will get rid of this driver and the platform device registration soon. Since as you said, it's unclear that is even used.

Quoted 8 lines

There's mips code in the arch/ directory that appears to setup screen_info in the correct way. I can't say whether that's still useful to anyone. On x86, I could set a VGA mode on the kernel command line, but screen_info's isVGA only contained '1'. It might be possible to fix this easily by setting the right values in vga_probe(). [1] I simply don't have the time to provide a patch and deal with the potential fallout of such a change.

Indeed. This seems to be a remnant from the time when isVGA was just a bool and then at some point the field semantics was extended to denote the mode but the existing users weren't fixed (nor the field named to reflect this).

Probably should be cleaned up at some point but unsure if the churn would be worth it.

Quoted 11 lines
Quoted 10 lines

drivers/firmware/sysfb.c

Quoted 8 lines
   static struct platform_driver vga16fb_driver = {
   	.probe = vga16fb_probe,
   	.remove = vga16fb_remove,
   	.driver = {
drivers/firmware/sysfb.c +1 -1
-		.name = "vga16fb",
+		.name = "vga-framebuffer",
   	},

Maybe "vga16-framebuffer" instead? Since for example VESA is also VGA AFAIK.

Quoted 4 lines

VESA is something else than VGA. Setting a VESA mode (done via INT 10h IIRC) and then fiddling with VGA state will likely produce broken output on the screen.

Quoted 6 lines

Technically it is something else but Linux conflates them in many places. For example, as you mentioned one can change the VESA modes using the "vga" param (which confusingly leads to the use of vesafb+fbcon driver instead of vgacon).

That's why I think that "vga-framebuffer" as driver name would be misleading. Specially since it would also bind to the "ega-framebuffer" platform device.

I messed up device and driver name, such that misunderstood your remark.

As we use the id_table field for matching devices, the driver name doesn't matter. [1] So let's keep the driver name as vga16fb. The change above must have been left over from an earlier prototype patch, I guess.

Best regards
Thomas

[1] https://elixir.bootlin.com/linux/v5.18.10/source/drivers/base/platform.c#L1365

Quoted 1 line
Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev
#8 lore raw

Re: [PATCH 02/11] fbdev/vga16fb: Create EGA/VGA devices in sysfb code

Quoted 1 line · Thomas Zimmermann

Hi Javier

[...]

Quoted 9 lines
Quoted 2 lines

That's why I think that "vga-framebuffer" as driver name would be misleading. Specially since it would also bind to the "ega-framebuffer" platform device.

I messed up device and driver name, such that misunderstood your remark.

As we use the id_table field for matching devices, the driver name doesn't matter. [1] So let's keep the driver name as vga16fb. The change above must have been left over from an earlier prototype patch, I guess.

Agreed. The driver name is used as the last resort to match a device only if there isn't any device ID table (ACPI, OF, platform, etc) but that's discouraged. Specially when the same driver supports different devices as it's the case for this driver.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat
maintainer Reviewed-by on v1 4/11
#14 lore raw

Re: [PATCH 04/11] fbdev/core: Remove remove_conflicting_pci_framebuffers()

In reply to Thomas Zimmermann
Quoted 7 lines · Thomas Zimmermann

Remove remove_conflicting_pci_framebuffers() and implement similar functionality in aperture_remove_conflicting_pci_device(), which was the only caller. Removes an otherwise unused interface and streamlines the aperture helper. No functional changes.

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat
#16 lore raw

Re: [PATCH 05/11] fbdev: Convert drivers to aperture helpers

In reply to Thomas Zimmermann
Quoted 6 lines · Thomas Zimmermann

Convert fbdev drivers from fbdev's remove_conflicting_framebuffers() to the framework-independent aperture_remove_conflicting_devices(). Calling this function will also remove conflicting DRM drivers.

---

[...]

Quoted 12 lines

static int lynxfb_kick_out_firmware_fb(struct pci_dev *pdev) {

drivers/staging/sm750fb/sm750.c +2 -6
-	struct apertures_struct *ap;
+	resource_size_t base = pci_resource_start(pdev, 0);
+	resource_size_t size = pci_resource_len(pdev, 0);
 	bool primary = false;
 
-	ap = alloc_apertures(1);
-	if (!ap)
-		return -ENOMEM;
-
-	ap->ranges[0].base = pci_resource_start(pdev, 0);

drivers/staging/sm750fb/sm750.c static int sm750fb_framebuffer_alloc(struct sm750_dev *sm750_dev, int fbidx) · line 1000

Quoted 10 lines
drivers/staging/sm750fb/sm750.c +2 -4
-	ap->ranges[0].size = pci_resource_len(pdev, 0);
 #ifdef CONFIG_X86
 	primary = pdev->resource[PCI_ROM_RESOURCE].flags &
 					IORESOURCE_ROM_SHADOW;
 #endif
-	remove_conflicting_framebuffers(ap, "sm750_fb1", primary);
-	kfree(ap);
-	return 0;
+
+	return aperture_remove_conflicting_devices(base, size, primary, "sm750_fb1");

Do you know why this can't just use aperture_remove_conflicting_pci_devices() ?

It seems that the driver is open coding part of the logic already in that helper. For example, figuring out if is a primary by checking the IORESOURCE_ROM_SHADOW flag in the PCI_ROM_RESOURCE.

But also getting the base and size for PCI BAR 0, since the loop in that helper would already take care of that (it also starts at BAR 0).

Quoted 26 lines

}

static int lynxfb_pci_probe(struct pci_dev *pdev,

drivers/video/fbdev/aty/radeon_base.c +3 -4
index b311c07fe66d..e5e362b8c9da 100644
@@ -54,6 +54,7 @@
 
 #include "radeonfb.h"
 
+#include <linux/aperture.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/kernel.h>
@@ -2239,20 +2240,10 @@ static const struct bin_attribute edid2_attr = {
 
 static int radeon_kick_out_firmware_fb(struct pci_dev *pdev)
 {
-	struct apertures_struct *ap;
+	resource_size_t base = pci_resource_start(pdev, 0);
+	resource_size_t size = pci_resource_len(pdev, 0);
 
-	ap = alloc_apertures(1);
-	if (!ap)
-		return -ENOMEM;

drivers/video/fbdev/aty/radeon_base.c static const struct bin_attribute edid2_attr = { · line 2246

Quoted 10 lines
drivers/video/fbdev/aty/radeon_base.c +1 -9
-
-	ap->ranges[0].base = pci_resource_start(pdev, 0);
-	ap->ranges[0].size = pci_resource_len(pdev, 0);
-
-	remove_conflicting_framebuffers(ap, KBUILD_MODNAME, false);
-
-	kfree(ap);
-
-	return 0;
+	return aperture_remove_conflicting_devices(base, size, KBUILD_MODNAME, false);

Same for this.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat
maintainer Reviewed-by on v1 6/11
#20 lore raw

Re: [PATCH 06/11] fbdev: Remove conflicting devices on PCI bus

In reply to Thomas Zimmermann
Quoted 9 lines · Thomas Zimmermann

Remove firmware devices on the PCI bus, by calling aperture_remove_conflicting_pci_devices() in the probe function of each related fbdev driver. iSo far, most of these drivers did not remove conflicting VESA or EFI devices, or outride failed for resource conflicts (i.e., matroxfb.) This must have been broken for quite some time.

---

[...]

drivers/video/fbdev/arkfb.c static int ark_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) · line 956

Quoted 8 lines
drivers/video/fbdev/arkfb.c +4 -0
@@ -949,6 +950,10 @@ static int ark_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 	int rc;
 	u8 regval;
 
+	rc = aperture_remove_conflicting_pci_devices(dev, "arkfb");
+	if (rc < 0)
+		return rc;
+

I wonder if we could think of a trick to avoid open coding the same check in all drivers. Maybe a combination of using KBUILD_MODNAME for the name and a probe callback wrapper or something ?

But probably not worth to invest more in the fbdev drivers and could be done as a follow-up anyways if someone feels like it.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat
maintainer Reviewed-by on v1 7/11
#23 lore raw

Re: [PATCH 07/11] video/aperture: Disable and unregister sysfb devices via aperture helpers

In reply to Thomas Zimmermann
Quoted 18 lines · Thomas Zimmermann

Call sysfb_disable() before removing conflicting devices in aperture helpers. Fixes sysfb state if fbdev has been disabled.

Fixes fb84efa28a48 ("drm/aperture: Run fbdev removal before internal helpers")
Cc Zack Rusin <[email protected]>
Cc Thomas Zimmermann <[email protected]>
Cc Javier Martinez Canillas <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Sam Ravnborg <[email protected]>
Cc Helge Deller <[email protected]>
Cc Alex Deucher <[email protected]>
Cc Zhen Lei <[email protected]>
Cc Changcheng Deng <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Quoted 1 line

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat
maintainer Reviewed-by on v1 8/11
#25 lore raw

Re: [PATCH 08/11] video: Provide constants for VGA I/O range

In reply to Thomas Zimmermann
Quoted 3 lines · Thomas Zimmermann

Provide VGA_FB_ constants for the VGA framebuffer I/O range and convert fbdev code.

I would probably mention in the commit message to that you are renaming s/VGA_FB_PHYS/VGA_FB_PHYS_BASE and s/VGA_FB_PHYS_LEN/VGA_FB_PHYS_SIZE.

I do agree with the rename and think that makes it much more readable, but think that's worth to mention the rationale for that change too.

Quoted 2 lines

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat
maintainer Reviewed-by on v1 9/11
#27 lore raw

Re: [PATCH 09/11] video/aperture: Remove conflicting VGA devices, if any

In reply to Thomas Zimmermann
Quoted 7 lines · Thomas Zimmermann

On the primary graphics adapter, a driver might conflict with a VGA driver that controls the VGA framebuffer I/O range. Remove the VGA driver from the aperture helpers. Until now, this case has been hendled by fbdev, but it should work even with fbdev disabled.

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat
maintainer Reviewed-by on v1 10/11
#29 lore raw

Re: [PATCH 10/11] fbdev: Acquire framebuffer apertures for firmware devices

In reply to Thomas Zimmermann
Quoted 22 lines · Thomas Zimmermann

When registering a generic framebuffer, automatically acquire ownership of the framebuffer's I/O range. The device will now be handled by the aperture helpers. Fbdev-based conflict handling is no longer required.

---
 drivers/video/fbdev/core/fbmem.c | 33 ++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
drivers/video/fbdev/core/fbmem.c +1 -0
index 2237049327db..e556ad69f48f 100644
@@ -13,6 +13,7 @@
 
 #include <linux/module.h>
 
+#include <linux/aperture.h>
 #include <linux/compat.h>
 #include <linux/types.h>
 #include <linux/errno.h>

drivers/video/fbdev/core/fbmem.c static void do_unregister_framebuffer(struct fb_info *fb_info) · line 1744

Quoted 5 lines
drivers/video/fbdev/core/fbmem.c +2 -0
@@ -1739,6 +1740,32 @@ static void do_unregister_framebuffer(struct fb_info *fb_info)
 	put_fb_info(fb_info);
 }
 
+static int fbm_aperture_acquire_for_platform_device(struct fb_info *fb_info)
+{

What's the meaning of 'm' here ? Misc, memory ? I would just call it 'fb_'.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat
maintainer Reviewed-by on v1 11/11
#32 lore raw

Re: [PATCH 11/11] fbdev: Remove conflict-handling code

In reply to Thomas Zimmermann
Quoted 4 lines · Thomas Zimmermann

Remove the call to do_remove_conflicting_framebuffers() from the framebuffer registration. Aperture helpers take care of removing conflicting devices. With all ownership information stored in the aperture datastrcutures, remove remove_conflicting_framebuffers()

data structures.

Quoted 8 lines

entirely.

This change also rectifies DRM generic-framebuffer registration, which tried to unregister conflicting framebuffers, even though it's entirely build on top of DRM.

---

Amazing patch! The whole series really. Thanks a lot for working on this.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat
author maintainer
#17 lore raw

Re: [PATCH 05/11] fbdev: Convert drivers to aperture helpers

In reply to Javier Martinez Canillas

Hi

Am 11.07.22 um 13:01 schrieb Javier Martinez Canillas:

Quoted 26 lines · Thomas Zimmermann
Quoted 6 lines

Convert fbdev drivers from fbdev's remove_conflicting_framebuffers() to the framework-independent aperture_remove_conflicting_devices(). Calling this function will also remove conflicting DRM drivers.

---

[...]

Quoted 16 lines
  static int lynxfb_kick_out_firmware_fb(struct pci_dev *pdev)
  {
drivers/staging/sm750fb/sm750.c +2 -7
-	struct apertures_struct *ap;
+	resource_size_t base = pci_resource_start(pdev, 0);
+	resource_size_t size = pci_resource_len(pdev, 0);
  	bool primary = false;
 
-	ap = alloc_apertures(1);
-	if (!ap)
-		return -ENOMEM;
-
-	ap->ranges[0].base = pci_resource_start(pdev, 0);
-	ap->ranges[0].size = pci_resource_len(pdev, 0);
  #ifdef CONFIG_X86
  	primary = pdev->resource[PCI_ROM_RESOURCE].flags &
  					IORESOURCE_ROM_SHADOW;
Quoted 8 lines

drivers/staging/sm750fb/sm750.c static int sm750fb_framebuffer_alloc(struct sm750_dev *sm750_dev, int fbidx) · line 1000

Quoted 6 lines
  #endif
drivers/staging/sm750fb/sm750.c +2 -3
-	remove_conflicting_framebuffers(ap, "sm750_fb1", primary);
-	kfree(ap);
-	return 0;
+
+	return aperture_remove_conflicting_devices(base, size, primary, "sm750_fb1");

Do you know why this can't just use aperture_remove_conflicting_pci_devices() ?

I simply don't want change too much at once, because there was this problem with the PCI helper on ast.

At some point we can make a push to really fix this throughout the code base. And that would include an update to fb_is_primary_device(), [1] which doesn't fill well into the new interfaces.

Best regards
Thomas

[1] https://elixir.bootlin.com/linux/latest/source/arch/x86/video/fbdev.c#L14

Quoted 47 lines

It seems that the driver is open coding part of the logic already in that helper. For example, figuring out if is a primary by checking the IORESOURCE_ROM_SHADOW flag in the PCI_ROM_RESOURCE.

But also getting the base and size for PCI BAR 0, since the loop in that helper would already take care of that (it also starts at BAR 0).

Quoted 26 lines
  }

static int lynxfb_pci_probe(struct pci_dev *pdev,

drivers/video/fbdev/aty/radeon_base.c +3 -4
index b311c07fe66d..e5e362b8c9da 100644
@@ -54,6 +54,7 @@
 
  #include "radeonfb.h"
 
+#include <linux/aperture.h>
  #include <linux/module.h>
  #include <linux/moduleparam.h>
  #include <linux/kernel.h>
@@ -2239,20 +2240,10 @@ static const struct bin_attribute edid2_attr = {
 
  static int radeon_kick_out_firmware_fb(struct pci_dev *pdev)
  {
-	struct apertures_struct *ap;
+	resource_size_t base = pci_resource_start(pdev, 0);
+	resource_size_t size = pci_resource_len(pdev, 0);
 
-	ap = alloc_apertures(1);
-	if (!ap)
-		return -ENOMEM;

drivers/video/fbdev/aty/radeon_base.c static const struct bin_attribute edid2_attr = { · line 2246

Quoted 10 lines
drivers/video/fbdev/aty/radeon_base.c +1 -9
-
-	ap->ranges[0].base = pci_resource_start(pdev, 0);
-	ap->ranges[0].size = pci_resource_len(pdev, 0);
-
-	remove_conflicting_framebuffers(ap, KBUILD_MODNAME, false);
-
-	kfree(ap);
-
-	return 0;
+	return aperture_remove_conflicting_devices(base, size, KBUILD_MODNAME, false);

Same for this.

Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev
author maintainer
#21 lore raw

Re: [PATCH 06/11] fbdev: Remove conflicting devices on PCI bus

In reply to Javier Martinez Canillas

Hi

Am 11.07.22 um 13:13 schrieb Javier Martinez Canillas:

Quoted 17 lines · Thomas Zimmermann
Quoted 9 lines

Remove firmware devices on the PCI bus, by calling aperture_remove_conflicting_pci_devices() in the probe function of each related fbdev driver. iSo far, most of these drivers did not remove conflicting VESA or EFI devices, or outride failed for resource conflicts (i.e., matroxfb.) This must have been broken for quite some time.

---

[...]

Quoted 4 lines
drivers/video/fbdev/arkfb.c +0 -0
@@ -949,6 +950,10 @@ static int ark_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
  	int rc;
  	u8 regval;
 
Quoted 8 lines

drivers/video/fbdev/arkfb.c static int ark_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) · line 956

Quoted 4 lines
drivers/video/fbdev/arkfb.c +4 -0
+	rc = aperture_remove_conflicting_pci_devices(dev, "arkfb");
+	if (rc < 0)
+		return rc;
+

I wonder if we could think of a trick to avoid open coding the same check in all drivers. Maybe a combination of using KBUILD_MODNAME for the name and a probe callback wrapper or something ?

Originally, I tried to hack this into register_framebuffer(), where the removal was originally located. But that's too late as there is conflicting resource access in most driver's probe function. The top of the probe function is the only place where this call can realistically be located. It's the same rule as with DRM drivers: the firmware driver needs to be gone before the native driver touches hardware.

Best regards
Thomas

Quoted 6 lines

But probably not worth to invest more in the fbdev drivers and could be done as a follow-up anyways if someone feels like it.

Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev
maintainer Reviewed-by
#18 lore raw

Re: [PATCH 05/11] fbdev: Convert drivers to aperture helpers

In reply to Thomas Zimmermann

Hello Thomas,

On 7/15/22 13:48, Thomas Zimmermann wrote:

[...]

Quoted 8 lines
Quoted 4 lines

drivers/staging/sm750fb/sm750.c static int sm750fb_framebuffer_alloc(struct sm750_dev *sm750_dev, int fbidx) · line 1000

Quoted 2 lines
drivers/staging/sm750fb/sm750.c +2 -0
+
+	return aperture_remove_conflicting_devices(base, size, primary, "sm750_fb1");

Do you know why this can't just use aperture_remove_conflicting_pci_devices() ?

I simply don't want change too much at once, because there was this problem with the PCI helper on ast.

Makes sense. Feel free to add:

Quoted 4 lines

At some point we can make a push to really fix this throughout the code base. And that would include an update to fb_is_primary_device(), [1] which doesn't fill well into the new interfaces.

Agreed.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat
author maintainer
#30 lore raw

Re: [PATCH 10/11] fbdev: Acquire framebuffer apertures for firmware devices

In reply to Javier Martinez Canillas

Hi

Am 11.07.22 um 13:29 schrieb Javier Martinez Canillas:

Quoted 26 lines · Thomas Zimmermann
Quoted 25 lines

When registering a generic framebuffer, automatically acquire ownership of the framebuffer's I/O range. The device will now be handled by the aperture helpers. Fbdev-based conflict handling is no longer required.

---
  drivers/video/fbdev/core/fbmem.c | 33 ++++++++++++++++++++++++++++++++
  1 file changed, 33 insertions(+)
drivers/video/fbdev/core/fbmem.c +1 -0
index 2237049327db..e556ad69f48f 100644
@@ -13,6 +13,7 @@
 
  #include <linux/module.h>
 
+#include <linux/aperture.h>
  #include <linux/compat.h>
  #include <linux/types.h>
  #include <linux/errno.h>
@@ -1739,6 +1740,32 @@ static void do_unregister_framebuffer(struct fb_info *fb_info)
  	put_fb_info(fb_info);
  }
 
Quoted 4 lines

drivers/video/fbdev/core/fbmem.c static void do_unregister_framebuffer(struct fb_info *fb_info) · line 1744

Quoted 2 lines
drivers/video/fbdev/core/fbmem.c +2 -0
+static int fbm_aperture_acquire_for_platform_device(struct fb_info *fb_info)
+{

What's the meaning of 'm' here ? Misc, memory ? I would just call it 'fb_'.

'managed' as in drmm_ But using fb_ is also good. I actually wasn't sure about this naming.

Best regards
Thomas

Quoted 3 lines
Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev