video/aperture: Ignore firmware framebuffers with non-primary devices
Subsystems (26)
Thomas Zimmermann
maintainerv5 cover video/aperture: Ignore firmware framebuffers with non-primary devices
Only remove sysfb and VGA devices for primary graphics devices. The PCI helper for aperture ownership now detects primary devices. Resolves bug reports about lost framebuffer consoles on systems with multiple graphics cards.
The series picks up Daniel's patchset at v3 from [1] and cleans up a few minor things. There's another patch on top that clarifys gma500's special case.
v5:
* fix gma500 comment
* add S-o-b tag with Daniel's Intel address
v4:
* add gma500 patch on top of v3
* fix Daniel's S-o-b address
* fix various typos in the commit messages
Daniel Vetter (8):
drm/gma500: Use drm_aperture_remove_conflicting_pci_framebuffers video/aperture: use generic code to figure out the vga default device drm/aperture: Remove primary argument
video/aperture: Only kick vgacon when the pdev is decoding vga video/aperture: Move vga handling to pci function video/aperture: Drop primary argument
video/aperture: Only remove sysfb on the default vga pci device
fbdev: Simplify fb_is_primary_device for x86
Thomas Zimmermann (1):
video/aperture: Provide a VGA helper for gma500 and internal use
arch/x86/video/fbdev.c | 13 +--- drivers/gpu/drm/arm/hdlcd_drv.c | 2 +- drivers/gpu/drm/armada/armada_drv.c | 2 +- drivers/gpu/drm/drm_aperture.c | 11 +--- drivers/gpu/drm/gma500/psb_drv.c | 43 ++++++++++--- drivers/gpu/drm/hyperv/hyperv_drm_drv.c | 1 - drivers/gpu/drm/meson/meson_drv.c | 2 +- drivers/gpu/drm/msm/msm_fbdev.c | 2 +- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 2 +- drivers/gpu/drm/stm/drv.c | 2 +- drivers/gpu/drm/sun4i/sun4i_drv.c | 2 +- drivers/gpu/drm/tegra/drm.c | 2 +- drivers/gpu/drm/vc4/vc4_drv.c | 2 +- drivers/video/aperture.c | 70 ++++++++++++++------- drivers/video/fbdev/hyperv_fb.c | 2 +- include/drm/drm_aperture.h | 7 +-- include/linux/aperture.h | 16 +++-- 17 files changed, 108 insertions(+), 73 deletions(-)
Signature · 1 line
2.40.0
Thomas Zimmermann
maintainerPATCH v5 1/9 drm/gma500: Use drm_aperture_remove_conflicting_pci_framebuffers
From: Daniel Vetter <[email protected]>
This one nukes all framebuffers, which is a bit much. In reality gma500 is igpu and never shipped with anything discrete, so there should not be any difference.
v2: Unfortunately the framebuffer sits outside of the pci bars for gma500, and so only using the pci helpers won't be enough. Otoh if we only use non-pci helper, then we don't get the vga handling, and subsequent refactoring to untangle these special cases won't work.
It's not pretty, but the simplest fix (since gma500 really is the only quirky pci driver like this we have) is to just have both calls.
v4:
- fix Daniel's S-o-b address
v5:
- add back an S-o-b tag with Daniel's Intel address
--- drivers/gpu/drm/gma500/psb_drv.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/gma500/psb_drv.c +7 -2
@@ -422,12 +422,17 @@ static int psb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)/* * We cannot yet easily find the framebuffer's location in memory. So -* remove all framebuffers here. +* remove all framebuffers here. Note that we still want the pci special +* handling to kick out vgacon. * * TODO: Refactor psb_driver_load() to map vdc_reg earlier. Then we * might be able to read the framebuffer range from the device. */ - ret =drm_aperture_remove_framebuffers (true, &driver); + ret =drm_aperture_remove_framebuffers (false, &driver); +if (ret) +return ret; + + ret =drm_aperture_remove_conflicting_pci_framebuffers (pdev, &driver);if (ret)return ret;
Signature · 1 line
2.40.0
Re: [PATCH v5 1/9] drm/gma500: Use drm_aperture_remove_conflicting_pci_framebuffers
Quoted 20 lines · Thomas Zimmermann
From: Daniel Vetter <[email protected]>
This one nukes all framebuffers, which is a bit much. In reality gma500 is igpu and never shipped with anything discrete, so there should not be any difference.
v2: Unfortunately the framebuffer sits outside of the pci bars for gma500, and so only using the pci helpers won't be enough. Otoh if we only use non-pci helper, then we don't get the vga handling, and subsequent refactoring to untangle these special cases won't work.
It's not pretty, but the simplest fix (since gma500 really is the only quirky pci driver like this we have) is to just have both calls.
v4:
- fix Daniel's S-o-b addressv5:
- add back an S-o-b tag with Daniel's Intel address
Quoted 6 lines
Signed-off-by Daniel Vetter <[email protected]>Signed-off-by Daniel Vetter <[email protected]>Cc Patrik Jakobsson <[email protected]>Cc Thomas Zimmermann <[email protected]>Cc Javier Martinez Canillas <[email protected]>---
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Thomas Zimmermann
maintainerPATCH v5 2/9 video/aperture: use generic code to figure out the vga default device
In reply to Thomas ZimmermannFrom: Daniel Vetter <[email protected]>
Since vgaarb has been promoted to be a core piece of the pci subsystem we don't have to open code random guesses anymore, we actually know this in a platform agnostic way, and there's no need for an x86 specific hack. See also commit 1d38fe6ee6a8 ("PCI/VGA: Move vgaarb to drivers/pci")
This should not result in any functional change, and the non-x86 multi-gpu pci systems are probably rare enough to not matter (I don't know of any tbh). But it's a nice cleanup, so let's do it.
There's been a few questions on previous iterations on dri-devel and irc:
- fb_is_primary_device() seems to be yet another implementation of this theme, and at least on x86 it checks for both vga_default_device OR rom shadowing. There shouldn't ever be a case where rom shadowing gives any additional hints about the boot vga device, but if there is then the default vga selection in vgaarb should probably be fixed. And not special-case checks replicated all over.
- Thomas also brought up that on most !x86 systems fb_is_primary_device() returns 0, except on sparc/parisc. But these 2 special cases are about platform specific devices and not pci, so shouldn't have any interactions.
- Furthermore fb_is_primary_device() is a bit a red herring since it's only used to select the right fbdev driver for fbcon, and not for the fw handover dance which the aperture helpers handle. At least for x86 we might want to look into unifying them, but that's a separate thing.
v2: Extend commit message trying to summarize various discussions.
v4:
- make the test for the primary device easier to read (Javier)
- fix commit message style (i.e., commit 1234 ("..."))
- fix Daniel's S-o-b address
v5:
- add back an S-o-b tag with Daniel's Intel address
--- drivers/video/aperture.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/video/aperture.c +2 -3
@@ -328,9 +328,8 @@ int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const char *naresource_size_t base, size;int bar, ret; -#ifdef CONFIG_X86 - primary = pdev->resource[PCI_ROM_RESOURCE ].flags &IORESOURCE_ROM_SHADOW ; -#endif +if (pdev ==vga_default_device ()) + primary = true;for (bar =0 ; bar <PCI_STD_NUM_BARS ; ++bar) {if (!(pci_resource_flags (pdev, bar) &IORESOURCE_MEM ))
Signature · 1 line
2.40.0
Helge Deller
maintainerRe: [PATCH v5 2/9] video/aperture: use generic code to figure out the vga default device
Quoted 23 lines · Thomas Zimmermann
From: Daniel Vetter <[email protected]>
Since vgaarb has been promoted to be a core piece of the pci subsystem we don't have to open code random guesses anymore, we actually know this in a platform agnostic way, and there's no need for an x86 specific hack. See also commit
1d38fe6ee6a8("PCI/VGA: Move vgaarb todrivers/pci")This should not result in any functional change, and the non-x86 multi-gpu pci systems are probably rare enough to not matter (I don't know of any tbh). But it's a nice cleanup, so let's do it.
There's been a few questions on previous iterations on dri-devel and irc:
-
fb_is_primary_device()seems to be yet another implementation of this theme, and at least on x86 it checks for bothvga_default_deviceOR rom shadowing. There shouldn't ever be a case where rom shadowing gives any additional hints about the boot vga device, but if there is then the default vga selection in vgaarb should probably be fixed. And not special-case checks replicated all over.
Quoted 4 lines
- Thomas also brought up that on most !x86 systems
fb_is_primary_device()returns 0, except on sparc/parisc. But these 2 special cases are about platform specific devices and not pci, so shouldn't have any interactions.
Nearly all graphics cards on parisc machines are actually PCI cards, but the way we handle the handover to graphics mode with STIcore doesn't conflicts with your planned aperture changes.
So no problem as far as I can see for parisc...
Helge
Re: [PATCH v5 2/9] video/aperture: use generic code to figure out the vga default device
Quoted 29 lines · Helge Deller
Quoted 23 lines · Thomas Zimmermann
From: Daniel Vetter <[email protected]>
Since vgaarb has been promoted to be a core piece of the pci subsystem we don't have to open code random guesses anymore, we actually know this in a platform agnostic way, and there's no need for an x86 specific hack. See also commit
1d38fe6ee6a8("PCI/VGA: Move vgaarb todrivers/pci")This should not result in any functional change, and the non-x86 multi-gpu pci systems are probably rare enough to not matter (I don't know of any tbh). But it's a nice cleanup, so let's do it.
There's been a few questions on previous iterations on dri-devel and irc:
-
fb_is_primary_device()seems to be yet another implementation of this theme, and at least on x86 it checks for bothvga_default_deviceOR rom shadowing. There shouldn't ever be a case where rom shadowing gives any additional hints about the boot vga device, but if there is then the default vga selection in vgaarb should probably be fixed. And not special-case checks replicated all over.Quoted 4 lines
- Thomas also brought up that on most !x86 systems
fb_is_primary_device()returns 0, except on sparc/parisc. But these 2 special cases are about platform specific devices and not pci, so shouldn't have any interactions.
Quoted 4 lines
Nearly all graphics cards on parisc machines are actually PCI cards, but the way we handle the handover to graphics mode with STIcore doesn't conflicts with your planned aperture changes.
So no problem as far as I can see for parisc...
Ah I thought sticore was some very special bus, if those can be pci cards underneath then I guess some cleanup eventually might be a good idea? For anything with a pci bus it's rather strange when vgaarb and fb_is_primary_device() aren't a match ...
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Helge Deller
maintainerRe: [PATCH v5 2/9] video/aperture: use generic code to figure out the vga default device
Quoted 30 lines · Daniel Vetter
Quoted 29 lines · Helge Deller
Quoted 27 lines · Thomas Zimmermann
From: Daniel Vetter <[email protected]>
Since vgaarb has been promoted to be a core piece of the pci subsystem we don't have to open code random guesses anymore, we actually know this in a platform agnostic way, and there's no need for an x86 specific hack. See also commit
1d38fe6ee6a8("PCI/VGA: Move vgaarb todrivers/pci")This should not result in any functional change, and the non-x86 multi-gpu pci systems are probably rare enough to not matter (I don't know of any tbh). But it's a nice cleanup, so let's do it.
There's been a few questions on previous iterations on dri-devel and irc:
-
fb_is_primary_device()seems to be yet another implementation of this theme, and at least on x86 it checks for bothvga_default_deviceOR rom shadowing. There shouldn't ever be a case where rom shadowing gives any additional hints about the boot vga device, but if there is then the default vga selection in vgaarb should probably be fixed. And not special-case checks replicated all over.- Thomas also brought up that on most !x86 systems
fb_is_primary_device()returns 0, except on sparc/parisc. But these 2 special cases are about platform specific devices and not pci, so shouldn't have any interactions.
Quoted 6 lines
Quoted 4 lines
Nearly all graphics cards on parisc machines are actually PCI cards, but the way we handle the handover to graphics mode with STIcore doesn't conflicts with your planned aperture changes.
So no problem as far as I can see for parisc...Ah I thought sticore was some very special bus, if those can be pci cards
STI stands for "Standard Text Interface" [1], which is a API of ROM functions to output text chars on a console. It's comparable to the text output functions in a PC-BIOS on x86 and dependend on the ROM it drives any supported card which has a parisc ROM. So, STI supports cards on PCI & AGP busses, as well on older GSC busses.
[1] https://parisc.wiki.kernel.org/images-parisc/e/e3/Sti.pdf
Quoted 3 lines
underneath then I guess some cleanup eventually might be a good idea? For anything with a pci bus it's rather strange when vgaarb and
fb_is_primary_device()aren't a match ...
There is no VGA on parisc, so there is no conflict. Cards come either with a parisc STI ROM to support text mode, or they will only be used as secondary cards only. The graphics mode is only done in userspace by specific drivers, e.g. by the X11 server in HP-UX.
Even on x86 the BIOS will only show text output if the graphics card comes with a VGA-compatible BIOS.
Helge
Re: [PATCH v5 2/9] video/aperture: use generic code to figure out the vga default device
Quoted 48 lines · Helge Deller
Quoted 30 lines · Daniel Vetter
Quoted 29 lines · Helge Deller
Quoted 27 lines · Thomas Zimmermann
From: Daniel Vetter <[email protected]>
Since vgaarb has been promoted to be a core piece of the pci subsystem we don't have to open code random guesses anymore, we actually know this in a platform agnostic way, and there's no need for an x86 specific hack. See also commit
1d38fe6ee6a8("PCI/VGA: Move vgaarb todrivers/pci")This should not result in any functional change, and the non-x86 multi-gpu pci systems are probably rare enough to not matter (I don't know of any tbh). But it's a nice cleanup, so let's do it.
There's been a few questions on previous iterations on dri-devel and irc:
-
fb_is_primary_device()seems to be yet another implementation of this theme, and at least on x86 it checks for bothvga_default_deviceOR rom shadowing. There shouldn't ever be a case where rom shadowing gives any additional hints about the boot vga device, but if there is then the default vga selection in vgaarb should probably be fixed. And not special-case checks replicated all over.- Thomas also brought up that on most !x86 systems
fb_is_primary_device()returns 0, except on sparc/parisc. But these 2 special cases are about platform specific devices and not pci, so shouldn't have any interactions.Quoted 6 lines
Quoted 4 lines
Nearly all graphics cards on parisc machines are actually PCI cards, but the way we handle the handover to graphics mode with STIcore doesn't conflicts with your planned aperture changes.
So no problem as far as I can see for parisc...Ah I thought sticore was some very special bus, if those can be pci cards
STI stands for "Standard Text Interface" [1], which is a API of ROM functions to output text chars on a console. It's comparable to the text output functions in a PC-BIOS on x86 and dependend on the ROM it drives any supported card which has a parisc ROM. So, STI supports cards on PCI & AGP busses, as well on older GSC busses.
[1] https://parisc.wiki.kernel.org/images-parisc/e/e3/Sti.pdfQuoted 3 lines
underneath then I guess some cleanup eventually might be a good idea? For anything with a pci bus it's rather strange when vgaarb and
fb_is_primary_device()aren't a match ...
Quoted 6 lines
There is no VGA on parisc, so there is no conflict. Cards come either with a parisc STI ROM to support text mode, or they will only be used as secondary cards only. The graphics mode is only done in userspace by specific drivers, e.g. by the X11 server in HP-UX.
Even on x86 the BIOS will only show text output if the graphics card comes with a VGA-compatible BIOS.
tbf after reading vt.c and fbcon.c some more I'm pretty sure my patch is nonsense. As sure as you can be with vt/fbcon :-/
Since it sounds like it's a driver bug, maybe a patch to do a pr_warn in register_framebuffer if there's no mode? I read a pile of code around modedb.c right now, and there's a lot of things that silently assume that you always have a mode. So would be good thing to check. -Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Thomas Zimmermann
maintainerPATCH v5 3/9 drm/aperture: Remove primary argument
In reply to Thomas ZimmermannFrom: Daniel Vetter <[email protected]>
Only really pci devices have a business setting this - it's for figuring out whether the legacy vga stuff should be nuked too. And with the preceding two patches those are all using the pci version of this.
Which means for all other callers primary == false and we can remove it now.
v2:
- Reorder to avoid compile fail (Thomas)
- Include gma500, which retained it's called to the non-pci version.
v4:
- fix Daniel's S-o-b address
v5:
- add back an S-o-b tag with Daniel's Intel address
--- drivers/gpu/drm/arm/hdlcd_drv.c | 2 +- drivers/gpu/drm/armada/armada_drv.c | 2 +- drivers/gpu/drm/drm_aperture.c | 11 +++-------- drivers/gpu/drm/gma500/psb_drv.c | 2 +- drivers/gpu/drm/hyperv/hyperv_drm_drv.c | 1 - drivers/gpu/drm/meson/meson_drv.c | 2 +- drivers/gpu/drm/msm/msm_fbdev.c | 2 +- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 2 +- drivers/gpu/drm/stm/drv.c | 2 +- drivers/gpu/drm/sun4i/sun4i_drv.c | 2 +- drivers/gpu/drm/tegra/drm.c | 2 +- drivers/gpu/drm/vc4/vc4_drv.c | 2 +- include/drm/drm_aperture.h | 7 +++---- 13 files changed, 16 insertions(+), 23 deletions(-)
drivers/gpu/drm/arm/hdlcd_drv.c +1 -1
@@ -285,7 +285,7 @@ static int hdlcd_drm_bind(struct device *dev)*/ if (hdlcd_read (hdlcd,HDLCD_REG_COMMAND )) {hdlcd_write (hdlcd,HDLCD_REG_COMMAND ,0 ); -drm_aperture_remove_framebuffers (false, &hdlcd_driver); +drm_aperture_remove_framebuffers (&hdlcd_driver); }drm_mode_config_reset (drm);
drivers/gpu/drm/armada/armada_drv.c +1 -1
@@ -95,7 +95,7 @@ static int armada_drm_bind(struct device *dev) }/* Remove early framebuffers */ - ret =drm_aperture_remove_framebuffers (false, &armada_drm_driver); + ret =drm_aperture_remove_framebuffers (&armada_drm_driver);if (ret) {dev_err (dev,"[" DRM_NAME ":%s] can't kick out simple-fb: %d\n" , __func__, ret);
drivers/gpu/drm/drm_aperture.c +3 -8
@@ -32,17 +32,13 @@* * static int remove_conflicting_framebuffers(struct pci_dev *pdev) * { -* bool primary = false; * resource_size_t base, size; * int ret; * * base = pci_resource_start(pdev, 0); * size = pci_resource_len(pdev, 0); -* #ifdef CONFIG_X86 -* primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; -* #endif * -* return drm_aperture_remove_conflicting_framebuffers(base, size, primary, +* return drm_aperture_remove_conflicting_framebuffers(base, size, * &example_driver); * } *
@@ -161,7 +157,6 @@ EXPORT_SYMBOL(devm_aperture_acquire_from_firmware);* drm_aperture_remove_conflicting_framebuffers - remove existing framebuffers in the given range * @base: the aperture's base address in physical memory * @size: aperture size in bytes -* @primary: also kick vga16fb if present * @req_driver: requesting DRM driver * * This function removes graphics device drivers which use the memory range described by
@@ -171,9 +166,9 @@ EXPORT_SYMBOL(devm_aperture_acquire_from_firmware);* 0 on success, or a negative errno code otherwise */ int drm_aperture_remove_conflicting_framebuffers (resource_size_t base,resource_size_t size, -bool primary,const struct drm_driver *req_driver) +const struct drm_driver *req_driver) { -return aperture_remove_conflicting_devices (base, size, primary, req_driver->name); +return aperture_remove_conflicting_devices (base, size, false, req_driver->name); }EXPORT_SYMBOL (drm_aperture_remove_conflicting_framebuffers);
drivers/gpu/drm/gma500/psb_drv.c +1 -1
@@ -428,7 +428,7 @@ static int psb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)* TODO: Refactor psb_driver_load() to map vdc_reg earlier. Then we * might be able to read the framebuffer range from the device. */ - ret =drm_aperture_remove_framebuffers (false, &driver); + ret =drm_aperture_remove_framebuffers (&driver);if (ret)return ret;
drivers/gpu/drm/hyperv/hyperv_drm_drv.c +0 -1
@@ -74,7 +74,6 @@ static int hyperv_setup_vram(struct hyperv_drm_device *hv,drm_aperture_remove_conflicting_framebuffers (screen_info.lfb_base, screen_info.lfb_size, - false, &hyperv_driver); hv->fb_size = (unsigned long )hv->mmio_megabytes *1024 *1024 ;
drivers/gpu/drm/meson/meson_drv.c +1 -1
@@ -285,7 +285,7 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)* Remove early framebuffers (ie. simplefb). The framebuffer can be * located anywhere in RAM */ - ret =drm_aperture_remove_framebuffers (false, &meson_driver); + ret =drm_aperture_remove_framebuffers (&meson_driver);if (ret) goto free_drm;
drivers/gpu/drm/msm/msm_fbdev.c +1 -1
@@ -155,7 +155,7 @@ struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev) }/* the fw fb could be anywhere in memory */ - ret =drm_aperture_remove_framebuffers (false, dev->driver); + ret =drm_aperture_remove_framebuffers (dev->driver);if (ret) goto fini;
drivers/gpu/drm/rockchip/rockchip_drm_drv.c +1 -1
@@ -140,7 +140,7 @@ static int rockchip_drm_bind(struct device *dev)int ret;/* Remove existing drivers that may own the framebuffer memory. */ - ret =drm_aperture_remove_framebuffers (false, &rockchip_drm_driver); + ret =drm_aperture_remove_framebuffers (&rockchip_drm_driver);if (ret) { DRM_DEV_ERROR(dev, "Failed to remove existing framebuffers - %d.\n",
drivers/gpu/drm/stm/drv.c +1 -1
@@ -185,7 +185,7 @@ static int stm_drm_platform_probe(struct platform_device *pdev)DRM_DEBUG ("%s\n" , __func__); - ret =drm_aperture_remove_framebuffers (false, &drv_driver); + ret =drm_aperture_remove_framebuffers (&drv_driver);if (ret)return ret;
drivers/gpu/drm/sun4i/sun4i_drv.c +1 -1
@@ -98,7 +98,7 @@ static int sun4i_drv_bind(struct device *dev) goto unbind_all;/* Remove early framebuffers (ie. simplefb) */ - ret =drm_aperture_remove_framebuffers (false, &sun4i_drv_driver); + ret =drm_aperture_remove_framebuffers (&sun4i_drv_driver);if (ret) goto unbind_all;
drivers/gpu/drm/tegra/drm.c +1 -1
@@ -1252,7 +1252,7 @@ static int host1x_drm_probe(struct host1x_device *dev)drm_mode_config_reset (drm); - err =drm_aperture_remove_framebuffers (false, &tegra_drm_driver); + err =drm_aperture_remove_framebuffers (&tegra_drm_driver);if (err <0 ) goto hub;
drivers/gpu/drm/vc4/vc4_drv.c +1 -1
@@ -350,7 +350,7 @@ static int vc4_drm_bind(struct device *dev)return -EPROBE_DEFER ; } - ret =drm_aperture_remove_framebuffers (false, driver); + ret =drm_aperture_remove_framebuffers (driver);if (ret)return ret;
include/drm/drm_aperture.h +3 -4
@@ -13,14 +13,13 @@ int devm_aperture_acquire_from_firmware(struct drm_device *dev, resource_size_t resource_size_t size);int drm_aperture_remove_conflicting_framebuffers (resource_size_t base,resource_size_t size, -bool primary,const struct drm_driver *req_driver); +const struct drm_driver *req_driver);int drm_aperture_remove_conflicting_pci_framebuffers (struct pci_dev *pdev,const struct drm_driver *req_driver);/** * drm_aperture_remove_framebuffers - remove all existing framebuffers -* @primary: also kick vga16fb if present * @req_driver: requesting DRM driver * * This function removes all graphics device drivers. Use this function on systems
@@ -30,9 +29,9 @@ int drm_aperture_remove_conflicting_pci_framebuffers(struct pci_dev *pdev,* 0 on success, or a negative errno code otherwise */ static inline int -drm_aperture_remove_framebuffers (bool primary,const struct drm_driver *req_driver) +drm_aperture_remove_framebuffers (const struct drm_driver *req_driver) { -return drm_aperture_remove_conflicting_framebuffers (0 , (resource_size_t)-1 , primary, +return drm_aperture_remove_conflicting_framebuffers (0 , (resource_size_t)-1 , req_driver); }
Signature · 1 line
2.40.0
Thomas Zimmermann
maintainerPATCH v5 4/9 video/aperture: Only kick vgacon when the pdev is decoding vga
In reply to Thomas ZimmermannFrom: Daniel Vetter <[email protected]>
Otherwise it's a bit silly, and we might throw out the driver for the screen the user is actually looking at. I haven't found a bug report for this case yet, but we did get bug reports for the analog case where we're throwing out the efifb driver.
v2: Flip the check around to make it clear it's a special case for kicking out the vgacon driver only (Thomas)
v4:
- fixes to commit message
- fix Daniel's S-o-b address
v5:
- add back an S-o-b tag with Daniel's Intel address
--- drivers/video/aperture.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/video/aperture.c +9 -7
@@ -342,13 +342,15 @@ int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const char *nareturn 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; +if (primary) { +/* +* 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 ;
Signature · 1 line
2.40.0
Thomas Zimmermann
maintainerPATCH v5 5/9 video/aperture: Move vga handling to pci function
In reply to Thomas ZimmermannFrom: Daniel Vetter <[email protected]>
A few reasons for this:
- It's really the only one where this matters. I tried looking around, and I didn't find any non-pci vga-compatible controllers for x86 (since that's the only platform where we had this until a few patches ago), where a driver participating in the aperture claim dance would interfere.
- I also don't expect that any future bus anytime soon will not just look like pci towards the OS, that's been the case for like 25+ years by now for practically everything (even non non-x86).
- Also it's a bit funny if we have one part of the vga removal in the pci function, and the other in the generic one.
v2: Rebase.
v4:
- fix Daniel's S-o-b address
v5:
- add back an S-o-b tag with Daniel's Intel address
--- drivers/video/aperture.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/video/aperture.c +7 -8
@@ -298,14 +298,6 @@ int aperture_remove_conflicting_devices(resource_size_t base, resource_size_t siaperture_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 ); -return 0 ; }EXPORT_SYMBOL (aperture_remove_conflicting_devices);
@@ -343,6 +335,13 @@ int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const char *na }if (primary) { +/* +* 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. +*/ +aperture_detach_devices (VGA_FB_PHYS_BASE ,VGA_FB_PHYS_SIZE ); +/* * WARNING: Apparently we must kick fbdev drivers before vgacon, * otherwise the vga fbdev driver falls over.
Signature · 1 line
2.40.0
Thomas Zimmermann
maintainerPATCH v5 6/9 video/aperture: Drop primary argument
In reply to Thomas ZimmermannFrom: Daniel Vetter <[email protected]>
With the preceding patches it's become defunct. Also I'm about to add a different boolean argument, so it's better to keep the confusion down to the absolute minimum.
v2: Since the hypervfb patch got droppped (it's only a pci device for gen1 vm, not for gen2) there is one leftover user in an actual driver left to touch.
v4:
- fixes to commit message
- fix Daniel's S-o-b address
v5:
- add back an S-o-b tag with Daniel's Intel address
--- drivers/gpu/drm/drm_aperture.c | 2 +- drivers/video/aperture.c | 7 +++---- drivers/video/fbdev/hyperv_fb.c | 2 +- include/linux/aperture.h | 9 ++++----- 4 files changed, 9 insertions(+), 11 deletions(-)
drivers/gpu/drm/drm_aperture.c +1 -1
@@ -168,7 +168,7 @@ EXPORT_SYMBOL(devm_aperture_acquire_from_firmware);int drm_aperture_remove_conflicting_framebuffers (resource_size_t base,resource_size_t size,const struct drm_driver *req_driver) { -return aperture_remove_conflicting_devices (base, size, false, req_driver->name); +return aperture_remove_conflicting_devices (base, size, req_driver->name); }EXPORT_SYMBOL (drm_aperture_remove_conflicting_framebuffers);
drivers/video/aperture.c +3 -4
@@ -43,7 +43,7 @@* base = mem->start; * size = resource_size(mem); * -* ret = aperture_remove_conflicting_devices(base, size, false, "example"); +* ret = aperture_remove_conflicting_devices(base, size, "example"); * if (ret) * return ret; *
@@ -274,7 +274,6 @@ static void aperture_detach_devices(resource_size_t base, resource_size_t size)* aperture_remove_conflicting_devices - remove devices in the given range * @base: the aperture's base address in physical memory * @size: aperture size in bytes -* @primary: also kick vga16fb if present; only relevant for VGA devices * @name: a descriptive name of the requesting driver * * This function removes devices that own apertures within @base and @size.
@@ -283,7 +282,7 @@ static void aperture_detach_devices(resource_size_t base, resource_size_t size)* 0 on success, or a negative errno code otherwise */ int aperture_remove_conflicting_devices (resource_size_t base,resource_size_t size, -bool primary,const char *name) +const char *name) {/* * If a driver asked to unregister a platform device registered by
@@ -329,7 +328,7 @@ int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const char *na base =pci_resource_start (pdev, bar); size =pci_resource_len (pdev, bar); - ret =aperture_remove_conflicting_devices (base, size, primary, name); + ret =aperture_remove_conflicting_devices (base, size, name);if (ret)return ret; }
drivers/video/fbdev/hyperv_fb.c +1 -1
@@ -1073,7 +1073,7 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info) info->screen_size = dio_fb_size; getmem_done: -aperture_remove_conflicting_devices (base, size, false,KBUILD_MODNAME ); +aperture_remove_conflicting_devices (base, size,KBUILD_MODNAME );if (gen2vm) {/* framebuffer is reallocated, clear screen_info to avoid misuse from kexec */
include/linux/aperture.h +4 -5
@@ -14,7 +14,7 @@ int devm_aperture_acquire_for_platform_device(struct platform_device *pdev, resource_size_t size);int aperture_remove_conflicting_devices (resource_size_t base,resource_size_t size, -bool primary,const char *name); +const char *name);int aperture_remove_conflicting_pci_devices (struct pci_dev *pdev,const char *name);#else
@@ -26,7 +26,7 @@ static inline int devm_aperture_acquire_for_platform_device(struct platform_devi }static inline int aperture_remove_conflicting_devices (resource_size_t base,resource_size_t size, -bool primary,const char *name) +const char *name) {return 0 ; }
@@ -39,7 +39,6 @@ static inline int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev,/** * aperture_remove_all_conflicting_devices - remove all existing framebuffers -* @primary: also kick vga16fb if present; only relevant for VGA devices * @name: a descriptive name of the requesting driver * * This function removes all graphics device drivers. Use this function on systems
@@ -48,9 +47,9 @@ static inline int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev,* Returns: * 0 on success, or a negative errno code otherwise */ -static inline int aperture_remove_all_conflicting_devices (bool primary,const char *name) +static inline int aperture_remove_all_conflicting_devices (const char *name) { -return aperture_remove_conflicting_devices (0 , (resource_size_t)-1 , primary, name); +return aperture_remove_conflicting_devices (0 , (resource_size_t)-1 , name); }#endif
Signature · 1 line
2.40.0
Thomas Zimmermann
maintainerPATCH v5 7/9 video/aperture: Only remove sysfb on the default vga pci device
In reply to Thomas ZimmermannFrom: Daniel Vetter <[email protected]>
Instead of calling aperture_remove_conflicting_devices() to remove the conflicting devices, just call to aperture_detach_devices() to detach the device that matches the same PCI BAR / aperture range. Since the former is just a wrapper of the latter plus a sysfb_disable() call, and now that's done in this function but only for the primary devices.
This fixes a regression introduced by commit ee7a69aa38d8 ("fbdev:
Disable sysfb device registration when removing conflicting FBs"), where we remove the sysfb when loading a driver for an unrelated pci device, resulting in the user losing their efifb console or similar.
Note that in practice this only is a problem with the nvidia blob, because that's the only gpu driver people might install which does not come with an fbdev driver of it's own. For everyone else the real gpu driver will restore a working console.
Also note that in the referenced bug there's confusion that this same bug also happens on amdgpu. But that was just another amdgpu specific regression, which just happened to happen at roughly the same time and with the same user-observable symptoms. That bug is fixed now, see
https://bugzilla.kernel.org/show_bug.cgi?id=216331#c15
Note that we should not have any such issues on non-pci multi-gpu issues, because I could only find two such cases:
- SoC with some external panel over spi or similar. These panel drivers do not use drm_aperture_remove_conflicting_framebuffers(), so no problem.
- vga+mga, which is a direct console driver and entirely bypasses all this.
For the above reasons the cc: stable is just notionally, this patch will need a backport and that's up to nvidia if they care enough.
v2:
- Explain a bit better why other multi-gpu that aren't pci shouldn't have any issues with making all this fully pci specific.
v3
- polish commit message (Javier)
v4:
- Fix commit message style (i.e., commit 1234 ("..."))
- fix Daniel's S-o-b address
v5:
- add back an S-o-b tag with Daniel's Intel address
--- drivers/video/aperture.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/video/aperture.c +4 -3
@@ -322,15 +322,16 @@ int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const char *naif (pdev ==vga_default_device ()) primary = true; +if (primary) +sysfb_disable (); +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); - ret =aperture_remove_conflicting_devices (base, size, name); -if (ret) -return ret; +aperture_detach_devices (base, size); }if (primary) {
Signature · 1 line
2.40.0
Thomas Zimmermann
maintainerPATCH v5 8/9 fbdev: Simplify fb_is_primary_device for x86
In reply to Thomas ZimmermannFrom: Daniel Vetter <[email protected]>
vga_default_device really is supposed to cover all corners, at least for x86. Additionally checking for rom shadowing should be redundant, because the bios/fw only does that for the boot vga device.
If this turns out to be wrong, then most likely that's a special case which should be added to the vgaarb code, not replicated all over.
Patch motived by changes to the aperture helpers, which also have this open code in a bunch of places, and which are all removed in a clean-up series. This function here is just for selecting the default fbdev device for fbcon, but I figured for consistency it might be good to throw this patch in on top.
Note that the shadow rom check predates vgaarb, which was only wired up in commit 88674088d10c ("x86: Use vga_default_device() when determining whether an fb is primary"). That patch doesn't explain why we still fall back to the shadow rom check.
v4:
- fix commit message style (i.e., commit 1234 ("..."))
- fix Daniel's S-o-b address
v5:
- add back an S-o-b tag with Daniel's Intel address
--- arch/x86/video/fbdev.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
arch/x86/video/fbdev.c +1 -12
@@ -14,26 +14,15 @@int fb_is_primary_device (struct fb_info *info) {struct device *device = info->device; -struct pci_dev *default_device =vga_default_device ();struct pci_dev *pci_dev; -struct resource *res;if (!device || !dev_is_pci (device))return 0 ; pci_dev =to_pci_dev (device); -if (default_device) { -if (pci_dev == default_device) -return 1 ; -return 0 ; - } - - res = pci_dev->resource +PCI_ROM_RESOURCE ; - -if (res->flags &IORESOURCE_ROM_SHADOW ) +if (pci_dev ==vga_default_device ())return 1 ; -return 0 ; }EXPORT_SYMBOL (fb_is_primary_device);
Signature · 1 line
2.40.0
Thomas Zimmermann
maintainerPATCH v5 9/9 video/aperture: Provide a VGA helper for gma500 and internal use
In reply to Thomas ZimmermannThe hardware for gma500 is different from the rest, as it uses stolen framebuffer memory that is not available via PCI BAR. The regular PCI removal helper cannot detect the framebuffer, while the non-PCI helper misses possible conflicting VGA devices (i.e., a framebuffer or text console).
Gma500 therefore calls both helpers to catch all cases. It's confusing as it implies that there's something about the PCI device that requires ownership management. The relationship between the PCI device and the VGA devices is non-obvious. At worst, readers might assume that calling two functions for clearing aperture ownership is a bug in the driver.
Hence, move the PCI removal helper's code for VGA functionality into a separate function and call this function from gma500. Documents the purpose of each call to aperture helpers. The change contains comments and example code form the discussion at [1].
v5:
* fix grammar in gma500 comment (Javier)
--- drivers/gpu/drm/gma500/psb_drv.c | 48 ++++++++++++++++++-------- drivers/video/aperture.c | 58 ++++++++++++++++++++++---------- include/linux/aperture.h | 7 ++++ 3 files changed, 81 insertions(+), 32 deletions(-)
drivers/gpu/drm/gma500/psb_drv.c +34 -14
@@ -7,6 +7,7 @@* **************************************************************************/ +#include <linux/aperture.h> #include <linux/cpu.h> #include <linux/module.h> #include <linux/notifier.h>
@@ -19,7 +20,6 @@#include <acpi/video.h> #include <drm/drm.h> -#include <drm/drm_aperture.h> #include <drm/drm_drv.h> #include <drm/drm_file.h> #include <drm/drm_ioctl.h>
@@ -414,25 +414,45 @@ static int psb_driver_load(struct drm_device *dev, unsigned long flags)return ret; } -static int psb_pci_probe (struct pci_dev *pdev,const struct pci_device_id *ent) +/* +* Hardware for gma500 is a hybrid device, which both acts as a PCI +* device (for legacy vga functionality) but also more like an +* integrated display on a SoC where the framebuffer simply +* resides in main memory and not in a special PCI bar (that +* internally redirects to a stolen range of main memory) like all +* other integrated PCI display devices implement it. +* +* To catch all cases we need to remove conflicting firmware devices +* for the stolen system memory and for the VGA functionality. As we +* currently cannot easily find the framebuffer's location in stolen +* memory, we remove all framebuffers here. +* +* TODO: Refactor psb_driver_load() to map vdc_reg earlier. Then +* we might be able to read the framebuffer range from the +* device. +*/ +static int gma_remove_conflicting_framebuffers (struct pci_dev *pdev, +const struct drm_driver *req_driver) { -struct drm_psb_private *dev_priv; -struct drm_device *dev; +resource_size_t base =0 ; +resource_size_t size =U32_MAX ;/* 4 GiB HW limit */ +const char *name = req_driver->name;int ret; -/* -* We cannot yet easily find the framebuffer's location in memory. So -* remove all framebuffers here. Note that we still want the pci special -* handling to kick out vgacon. -* -* TODO: Refactor psb_driver_load() to map vdc_reg earlier. Then we -* might be able to read the framebuffer range from the device. -*/ - ret =drm_aperture_remove_framebuffers (&driver); + ret =aperture_remove_conflicting_devices (base, size, name);if (ret)return ret; - ret =drm_aperture_remove_conflicting_pci_framebuffers (pdev, &driver); +return __aperture_remove_legacy_vga_devices (pdev); +} + +static int psb_pci_probe (struct pci_dev *pdev,const struct pci_device_id *ent) +{ +struct drm_psb_private *dev_priv; +struct drm_device *dev; +int ret; + + ret =gma_remove_conflicting_framebuffers (pdev, &driver);if (ret)return ret;
drivers/video/aperture.c +40 -18
77 lines not on this page · raw message
include/linux/aperture.h +7 -0
@@ -16,6 +16,8 @@ int devm_aperture_acquire_for_platform_device(struct platform_device *pdev,int aperture_remove_conflicting_devices (resource_size_t base,resource_size_t size,const char *name); +int __aperture_remove_legacy_vga_devices (struct pci_dev *pdev); +int aperture_remove_conflicting_pci_devices (struct pci_dev *pdev,const char *name);#else static inline int devm_aperture_acquire_for_platform_device(struct platform_device *pdev,
@@ -31,6 +33,11 @@ static inline int aperture_remove_conflicting_devices(resource_size_t base, resoreturn 0 ; } +static inline int __aperture_remove_legacy_vga_devices (struct pci_dev *pdev) +{ +return 0 ; +} +static inline int aperture_remove_conflicting_pci_devices (struct pci_dev *pdev,const char *name) {return 0 ;
Signature · 1 line
2.40.0