Allow non-legacy cards to be vgaarb default
Subsystems (5)
cover Allow non-legacy cards to be vgaarb default
Hi all,
Previously I posted a patch that provided a quirk for a hibmc card behind a particular Huawei bridge that allowed it to be marked as the default device in the VGA arbiter.[0] This lead to some discussion.[1] It was broadly suggested that a more generic solution would be better, something in the style of powerpc's fixup_vga() quirk.
Here is my suggested solution:
- Create a Kconfig option ARCH_WANT_VGA_ARB_FALLBACK
- if an arch selects that option, install PCI_FIXUP_CLASS_ENABLE hook. This hook fires when a card is enabled, which will require that a driver has been bound.
- if there is no default device when the hook fires, and the device can control memory and I/O, mark it as default.
The patches are as follows:
(1) powerpc: simplify and fix VGA default device behaviour
This cleans up some quirks in the powerpc implementation of the vga_fixup. It should make the behaviour match the original intention.
(2) vgaarb: allow non-legacy cards to be marked as default
Add the Kconfig option, and create the fixup in vgaarb.c gated behind the option. Nothing happens at this stage because no arch has selected the option yet.
(3) powerpc: replace vga_fixup() with generic code
Select the option on powerpc and remove the old code. The only change is that it moves from being a final fixup to an enable fixup.
(4) arm64: allow non-legacy VGA devices to be default
Select the option on arm64. This solves my problem with the D05, but may cause other cards to be marked as default on other boards. This shouldn't cause any real issues but is worth being aware of.
Regards,
Daniel
[0]: https://patchwork.ozlabs.org/patch/787003/
[1]: https://www.spinics.net/lists/arm-kernel/msg593656.html
Daniel Axtens (4):
powerpc: simplify and fix VGA default device behaviour
vgaarb: allow non-legacy cards to be marked as default
powerpc: replace vga_fixup() with generic code
arm64: allow non-legacy VGA devices to be default
arch/arm64/Kconfig | 1 + arch/powerpc/Kconfig | 1 + arch/powerpc/kernel/pci-common.c | 12 ------------ drivers/gpu/vga/Kconfig | 7 +++++++ drivers/gpu/vga/vgaarb.c | 21 +++++++++++++++++++++ 5 files changed, 30 insertions(+), 12 deletions(-)
Signature · 1 line
2.11.0
PATCH 1/4 powerpc: simplify and fix VGA default device behaviour
Some powerpc devices provide a PCI display that isn't picked up by the VGA arbiter, presumably because it doesn't support the PCI legacy VGA ranges.
Commit c2e1d84523ad ("powerpc: Set default VGA device") introduced an arch quirk to mark these devices as default to fix X autoconfig.
The commit message stated that the patch:
Ensures a default VGA is always set if a graphics adapter is present, even if firmware did not initialize it. If more than one graphics adapter is present, ensure the one initialized by firmware is set as the default VGA device.
The patch used the following test to decide whether or not to mark a device as default:
pci_read_config_word(pdev, PCI_COMMAND, &cmd);
if ((cmd & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) || !vga_default_device())
vga_set_default_device(pdev);This doesn't seem like it works quite as intended. Because of the logical OR, the default device will be set in 2 cases:
1) if there is no default device
OR
2) if this device has normal memory/IO decoding turned on
This will work as intended if there is only one device, but if there are multiple devices, we may override the device the VGA arbiter picked.
Instead, set a device as default if there is no default device AND this device decodes.
This will not change behaviour on single-headed systems.
---
Tested in TCG (the card provided by qemu doesn't automatically register with vgaarb, so the relevant code path has been tested) but I would appreciate any tests on real hardware.
--- arch/powerpc/kernel/pci-common.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/powerpc/kernel/pci-common.c +4 -1
@@ -1746,8 +1746,11 @@ static void fixup_vga(struct pci_dev *pdev) {u16 cmd; +if (vga_default_device ()) +return ; +pci_read_config_word (pdev,PCI_COMMAND , &cmd); -if ((cmd & (PCI_COMMAND_IO |PCI_COMMAND_MEMORY )) || !vga_default_device ()) +if (cmd & (PCI_COMMAND_IO |PCI_COMMAND_MEMORY ))vga_set_default_device (pdev); }
Signature · 1 line
2.11.0
PATCH 1/4 powerpc: simplify and fix VGA default device behaviour
Quoted 28 lines · Daniel Axtens
Some powerpc devices provide a PCI display that isn't picked up by the VGA arbiter, presumably because it doesn't support the PCI legacy VGA ranges.
Commit
c2e1d84523ad("powerpc: Set default VGA device") introduced an arch quirk to mark these devices as default to fix X autoconfig.The commit message stated that the patch:
Ensures a default VGA is always set if a graphics adapter is present, even if firmware did not initialize it. If more than one graphics adapter is present, ensure the one initialized by firmware is set as the default VGA device.
The patch used the following test to decide whether or not to mark a device as default:
pci_read_config_word(pdev, PCI_COMMAND, &cmd); if ((cmd & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) || !vga_default_device()) vga_set_default_device(pdev);This doesn't seem like it works quite as intended. Because of the logical OR, the default device will be set in 2 cases:
1) if there is no default device
OR
2) if this device has normal memory/IO decoding turned on
Quoted 8 lines
This will work as intended if there is only one device, but if there are multiple devices, we may override the device the VGA arbiter picked.
Instead, set a device as default if there is no default device AND this device decodes.
This will not change behaviour on single-headed systems.
Ack.
Quoted 29 lines
Cc Brian King <[email protected]>Signed-off-by Daniel Axtens <[email protected]>---
Tested in TCG (the card provided by qemu doesn't automatically register with vgaarb, so the relevant code path has been tested) but I would appreciate any tests on real hardware.
--- arch/powerpc/kernel/pci-common.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)arch/powerpc/kernel/pci-common.c +4
-1@@ -1746,8 +1746,11 @@ static void fixup_vga(struct pci_dev *pdev) {u16 cmd; +if (vga_default_device ()) +return ; +pci_read_config_word (pdev,PCI_COMMAND , &cmd); -if ((cmd & (PCI_COMMAND_IO |PCI_COMMAND_MEMORY )) || !vga_default_device ()) +if (cmd & (PCI_COMMAND_IO |PCI_COMMAND_MEMORY ))vga_set_default_device (pdev); }
PATCH 2/4 vgaarb: allow non-legacy cards to be marked as default
In reply to Daniel AxtensThe VGA arbiter currently only selects a card as default if it can decode legacy I/O and memory ranges.
However, on some architectures, legacy PCI resources are not used. This has lead to a powerpc quirk, and issues on arm64.
Allow architectures to select ARCH_WANT_VGA_ARB_FALLBACK. When that symbol is selected, add a PCI_FIXUP_CLASS_ENABLE hook, which will mark the first card that is enabled and that can control I/O and memory as the default card.
Behaviour is unchanged unless arches opt-in by selecting the Kconfig option.
--- drivers/gpu/vga/Kconfig | 7 +++++++ drivers/gpu/vga/vgaarb.c | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+)
drivers/gpu/vga/Kconfig +7 -0
@@ -17,6 +17,13 @@ config VGA_ARB_MAX_GPUS Reserves space in the kernel to maintain resource locking for multiple GPUS. The overhead for each GPU is very small. +config ARCH_WANT_VGA_ARB_FALLBACK + bool + help + Some architectures don't have a concept of "legacy" PCI addresses + which the VGA arbiter relies on. Instead, they can fall back to + selecting the first device that decodes memory and I/O. + config VGA_SWITCHEROO bool "Laptop Hybrid Graphics - GPU switching support" depends on X86
drivers/gpu/vga/vgaarb.c +21 -0
@@ -1472,3 +1472,24 @@ static int __init vga_arb_device_init(void)return rc; }subsys_initcall (vga_arb_device_init); + +#if defined(CONFIG_ARCH_WANT_VGA_ARB_FALLBACK ) +static void vga_arb_fallback_fixup (struct pci_dev *pdev) +{ +u16 cmd; + +if (vga_default_device ()) +return ; + +pci_read_config_word (pdev,PCI_COMMAND , &cmd); +if (cmd & (PCI_COMMAND_IO |PCI_COMMAND_MEMORY )) { +vgaarb_info (&pdev->dev,"[fallback]" +" setting as default device\n" ); +vga_set_default_device (pdev); + } + +} +DECLARE_PCI_FIXUP_CLASS_ENABLE (PCI_ANY_ID ,PCI_ANY_ID , +PCI_CLASS_DISPLAY_VGA ,8 , + vga_arb_fallback_fixup); +#endif
Signature · 1 line
2.11.0
PATCH 2/3 vgaarb rework
In reply to Daniel Axtens--- arch/powerpc/Kconfig | 1 + arch/powerpc/kernel/pci-common.c | 2 ++ drivers/gpu/vga/Kconfig | 8 ++++++++ drivers/gpu/vga/vgaarb.c | 21 +++++++++++++++++++++ 4 files changed, 32 insertions(+)
arch/powerpc/Kconfig +1 -0
@@ -83,6 +83,7 @@ config PPC select BUILDTIME_EXTABLE_SORT select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_MIGHT_HAVE_PC_SERIO + select ARCH_WANT_VGA_ARB_FALLBACK select BINFMT_ELF select ARCH_HAS_ELF_RANDOMIZE select OF
arch/powerpc/kernel/pci-common.c +2 -0
@@ -1740,6 +1740,7 @@ static void fixup_hide_host_resource_fsl(struct pci_dev *dev)DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_MOTOROLA ,PCI_ANY_ID , fixup_hide_host_resource_fsl);DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_FREESCALE ,PCI_ANY_ID , fixup_hide_host_resource_fsl); +#if !defined(CONFIG_ARCH_WANT_VGA_ARB_FALLBACK )static void fixup_vga (struct pci_dev *pdev) {u16 cmd;
@@ -1754,3 +1755,4 @@ static void fixup_vga(struct pci_dev *pdev) }DECLARE_PCI_FIXUP_CLASS_FINAL (PCI_ANY_ID ,PCI_ANY_ID ,PCI_CLASS_DISPLAY_VGA ,8 , fixup_vga); +#endif
drivers/gpu/vga/Kconfig +8 -0
@@ -17,6 +17,14 @@ config VGA_ARB_MAX_GPUS Reserves space in the kernel to maintain resource locking for multiple GPUS. The overhead for each GPU is very small. +config ARCH_WANT_VGA_ARB_FALLBACK + bool + depends on !(X86 || IA64) + help + Some architectures don't have a concept of "legacy" PCI addresses + which the VGA arbiter relies on. Instead, they can fall back to + selecting the first device that decodes memory and I/O. + config VGA_SWITCHEROO bool "Laptop Hybrid Graphics - GPU switching support" depends on X86
drivers/gpu/vga/vgaarb.c +21 -0
@@ -1472,3 +1472,24 @@ static int __init vga_arb_device_init(void)return rc; }subsys_initcall (vga_arb_device_init); + +#if defined(CONFIG_ARCH_WANT_VGA_ARB_FALLBACK ) +static void vga_arb_fallback_fixup (struct pci_dev *pdev) +{ +u16 cmd; + +if (vga_default_device ()) +return ; + +pci_read_config_word (pdev,PCI_COMMAND , &cmd); +if (cmd & (PCI_COMMAND_IO |PCI_COMMAND_MEMORY )) { +vgaarb_info (&pdev->dev,"[fallback]" +" setting as default device\n" ); +vga_set_default_device (pdev); + } + +} +DECLARE_PCI_FIXUP_CLASS_ENABLE (PCI_ANY_ID ,PCI_ANY_ID , +PCI_CLASS_DISPLAY_VGA ,8 , + vga_arb_fallback_fixup); +#endif
Signature · 1 line
2.11.0
PATCH 3/3 extend to arm
In reply to Daniel Axtens--- arch/arm64/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm64/Kconfig +1 -0
@@ -20,6 +20,7 @@ config ARM64 select ARCH_SUPPORTS_NUMA_BALANCING select ARCH_WANT_COMPAT_IPC_PARSE_VERSION select ARCH_WANT_FRAME_POINTERS + select ARCH_WANT_VGA_ARB_FALLBACK select ARCH_HAS_UBSAN_SANITIZE_ALL select ARM_AMBA select ARM_ARCH_TIMER
Signature · 1 line
2.11.0
PATCH 3/4 powerpc: replace vga_fixup() with generic code
In reply to Daniel AxtensCurrently, we do a PCI fixup to mark a default card so that Xorg autoconfiguration works.
There is a new generic method to do this sort of vga fixup.
Code-wise, it is identical, however instead of firing at the FIXUP_FINAL stage it fires at the FIXUP_ENABLE stage. This means a card will not be marked as default unless a driver enables it.
---
Tested with xeyes on qemu TCG, which does use this code path.
--- arch/powerpc/Kconfig | 1 + arch/powerpc/kernel/pci-common.c | 15 --------------- 2 files changed, 1 insertion(+), 15 deletions(-)
arch/powerpc/Kconfig +1 -0
@@ -140,6 +140,7 @@ config PPC select ARCH_USE_BUILTIN_BSWAP select ARCH_USE_CMPXCHG_LOCKREF if PPC64 select ARCH_WANT_IPC_PARSE_VERSION + select ARCH_WANT_VGA_ARB_FALLBACK select ARCH_WEAK_RELEASE_ACQUIRE select BINFMT_ELF select BUILDTIME_EXTABLE_SORT
arch/powerpc/kernel/pci-common.c +0 -15
@@ -1741,18 +1741,3 @@ static void fixup_hide_host_resource_fsl(struct pci_dev *dev) }DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_MOTOROLA ,PCI_ANY_ID , fixup_hide_host_resource_fsl);DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_FREESCALE ,PCI_ANY_ID , fixup_hide_host_resource_fsl); - -static void fixup_vga (struct pci_dev *pdev) -{ -u16 cmd; - -if (vga_default_device ()) -return ; - -pci_read_config_word (pdev,PCI_COMMAND , &cmd); -if (cmd & (PCI_COMMAND_IO |PCI_COMMAND_MEMORY )) -vga_set_default_device (pdev); - -} -DECLARE_PCI_FIXUP_CLASS_FINAL (PCI_ANY_ID ,PCI_ANY_ID , -PCI_CLASS_DISPLAY_VGA ,8 , fixup_vga);
Signature · 1 line
2.11.0
PATCH 4/4 arm64: allow non-legacy VGA devices to be default
In reply to Daniel AxtensThe VGA arbiter only marks a device as default if it can decode legacy I/O and memory ranges. This is often not the case on arm64, which doesn't use the legacy ranges.
Enable the VGA arbiter to mark the first enabled VGA card as default.
---
Tested on a D05 using the hibmc card.
--- arch/arm64/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm64/Kconfig +1 -0
@@ -28,6 +28,7 @@ config ARM64 select ARCH_SUPPORTS_NUMA_BALANCING select ARCH_WANT_COMPAT_IPC_PARSE_VERSION select ARCH_WANT_FRAME_POINTERS + select ARCH_WANT_VGA_ARB_FALLBACK select ARCH_HAS_UBSAN_SANITIZE_ALL select ARM_AMBA select ARM_ARCH_TIMER
Signature · 1 line
2.11.0
cover Allow non-legacy cards to be vgaarb default
In reply to Daniel AxtensApologies everyone - this got mixed in with another patch set. I'll do a v2 that isn't completely broken and confusing.
Again, my apologies for the noise.
Regards,
Daniel
Quoted 67 lines · Daniel Axtens
Hi all,
Previously I posted a patch that provided a quirk for a hibmc card behind a particular Huawei bridge that allowed it to be marked as the default device in the VGA arbiter.[0] This lead to some discussion.[1] It was broadly suggested that a more generic solution would be better, something in the style of powerpc's
fixup_vga()quirk.Here is my suggested solution:
- Create a
KconfigoptionARCH_WANT_VGA_ARB_FALLBACK- if an arch selects that option, install
PCI_FIXUP_CLASS_ENABLEhook. This hook fires when a card is enabled, which will require that a driver has been bound.- if there is no default device when the hook fires, and the device can control memory and I/O, mark it as default.
The patches are as follows:
(1) powerpc: simplify and fix VGA default device behaviour
This cleans up some quirks in the powerpc implementation of the
vga_fixup. It should make the behaviour match the original intention.(2) vgaarb: allow non-legacy cards to be marked as default
Add the
Kconfigoption, and create the fixup invgaarb.cgated behind the option. Nothing happens at this stage because no arch has selected the option yet.(3) powerpc: replace
vga_fixup()with generic codeSelect the option on powerpc and remove the old code. The only change is that it moves from being a final fixup to an enable fixup.
(4) arm64: allow non-legacy VGA devices to be default
Select the option on arm64. This solves my problem with the D05, but may cause other cards to be marked as default on other boards. This shouldn't cause any real issues but is worth being aware of.
Regards,
Daniel[0]: https://patchwork.ozlabs.org/patch/787003/
[1]: https://www.spinics.net/lists/arm-kernel/msg593656.htmlDaniel Axtens (4):
powerpc: simplify and fix VGA default device behaviour
vgaarb: allow non-legacy cards to be marked as default
powerpc: replacevga_fixup()with generic code
arm64: allow non-legacy VGA devices to be defaultarch/arm64/Kconfig | 1 + arch/powerpc/Kconfig | 1 + arch/powerpc/kernel/pci-common.c | 12 ------------ drivers/gpu/vga/Kconfig | 7 +++++++ drivers/gpu/vga/vgaarb.c | 21 +++++++++++++++++++++ 5 files changed, 30 insertions(+), 12 deletions(-)Signature · 1 line
2.11.0
cover Allow non-legacy cards to be vgaarb default
In reply to Daniel Axtens(+ Laszlo)
Quoted 39 lines · Daniel Axtens
Hi all,
Previously I posted a patch that provided a quirk for a hibmc card behind a particular Huawei bridge that allowed it to be marked as the default device in the VGA arbiter.[0] This lead to some discussion.[1] It was broadly suggested that a more generic solution would be better, something in the style of powerpc's
fixup_vga()quirk.Here is my suggested solution:
- Create a
KconfigoptionARCH_WANT_VGA_ARB_FALLBACK- if an arch selects that option, install
PCI_FIXUP_CLASS_ENABLEhook. This hook fires when a card is enabled, which will require that a driver has been bound.- if there is no default device when the hook fires, and the device can control memory and I/O, mark it as default.
The patches are as follows:
(1) powerpc: simplify and fix VGA default device behaviour
This cleans up some quirks in the powerpc implementation of the
vga_fixup. It should make the behaviour match the original intention.(2) vgaarb: allow non-legacy cards to be marked as default
Add the
Kconfigoption, and create the fixup invgaarb.cgated behind the option. Nothing happens at this stage because no arch has selected the option yet.(3) powerpc: replace
vga_fixup()with generic codeSelect the option on powerpc and remove the old code. The only change is that it moves from being a final fixup to an enable fixup.
Quoted 7 lines
(4) arm64: allow non-legacy VGA devices to be default
Select the option on arm64. This solves my problem with the D05, but may cause other cards to be marked as default on other boards. This shouldn't cause any real issues but is worth being aware of.
Hi Daniel,
Given that the whole point of the VGA arbiter is the ability to share the legacy mem+io ranges between different cards, why do we care about the VGA arbiter in the first place on arm64?
AFAIK, there have been some recent changes in Xorg to address the auto-detection problem. I don't remember the exact details, but I have added Laszlo, who was involved with this at the time.
Signature · 1 line
Ard.
cover Allow non-legacy cards to be vgaarb default
Hi Ard,
Quoted 52 lines
(+ Laszlo)
Quoted 39 lines · Daniel Axtens
Hi all,
Previously I posted a patch that provided a quirk for a hibmc card behind a particular Huawei bridge that allowed it to be marked as the default device in the VGA arbiter.[0] This lead to some discussion.[1] It was broadly suggested that a more generic solution would be better, something in the style of powerpc's
fixup_vga()quirk.Here is my suggested solution:
- Create a
KconfigoptionARCH_WANT_VGA_ARB_FALLBACK- if an arch selects that option, install
PCI_FIXUP_CLASS_ENABLEhook. This hook fires when a card is enabled, which will require that a driver has been bound.- if there is no default device when the hook fires, and the device can control memory and I/O, mark it as default.
The patches are as follows:
(1) powerpc: simplify and fix VGA default device behaviour
This cleans up some quirks in the powerpc implementation of the
vga_fixup. It should make the behaviour match the original intention.(2) vgaarb: allow non-legacy cards to be marked as default
Add the
Kconfigoption, and create the fixup invgaarb.cgated behind the option. Nothing happens at this stage because no arch has selected the option yet.(3) powerpc: replace
vga_fixup()with generic codeSelect the option on powerpc and remove the old code. The only change is that it moves from being a final fixup to an enable fixup.
Quoted 7 lines
(4) arm64: allow non-legacy VGA devices to be default
Select the option on arm64. This solves my problem with the D05, but may cause other cards to be marked as default on other boards. This shouldn't cause any real issues but is worth being aware of.
Hi Daniel,
Quoted 7 lines
Given that the whole point of the VGA arbiter is the ability to share the legacy mem+io ranges between different cards, why do we care about the VGA arbiter in the first place on arm64?
AFAIK, there have been some recent changes in Xorg to address the auto-detection problem. I don't remember the exact details, but I have added Laszlo, who was involved with this at the time.
I haven't been able to locate those changes - I remember that the call to pci_device_is_boot_vga() in xf86pciBus.c [0] was critical and that is still there in the latest git.
Indeed, the reason we care about the vga arbiter at all is because of that Xorg dependency on the boot VGA card. pci_device_is_boot_vga() reads a sysfs file, and that sysfs file is populated based on the vga_default_driver(), so it's very difficult to extricate ourselves from the vga arbiter and its concept of the default device.
We could make this method an 'either/or' rather than a fallback - so platforms who didn't care about legacy resources didn't bother with those tests, but I'm not sure what benefit that would give and I find it harder to be confident of an absence of unexpected consequences.
Regards,
Daniel
[0] https://cgit.freedesktop.org/xorg/xserver/tree/hw/xfree86/common/xf86pciBus.c#n113
Quoted 3 lines
Signature · 2 lines
-- Ard.
cover Allow non-legacy cards to be vgaarb default
(+ Hans)
Quoted 72 lines · Daniel Axtens
Hi Ard,
Quoted 52 lines
(+ Laszlo)
Quoted 39 lines · Daniel Axtens
Hi all,
Previously I posted a patch that provided a quirk for a hibmc card behind a particular Huawei bridge that allowed it to be marked as the default device in the VGA arbiter.[0] This lead to some discussion.[1] It was broadly suggested that a more generic solution would be better, something in the style of powerpc's
fixup_vga()quirk.Here is my suggested solution:
- Create a
KconfigoptionARCH_WANT_VGA_ARB_FALLBACK- if an arch selects that option, install
PCI_FIXUP_CLASS_ENABLEhook. This hook fires when a card is enabled, which will require that a driver has been bound.- if there is no default device when the hook fires, and the device can control memory and I/O, mark it as default.
The patches are as follows:
(1) powerpc: simplify and fix VGA default device behaviour
This cleans up some quirks in the powerpc implementation of the
vga_fixup. It should make the behaviour match the original intention.(2) vgaarb: allow non-legacy cards to be marked as default
Add the
Kconfigoption, and create the fixup invgaarb.cgated behind the option. Nothing happens at this stage because no arch has selected the option yet.(3) powerpc: replace
vga_fixup()with generic codeSelect the option on powerpc and remove the old code. The only change is that it moves from being a final fixup to an enable fixup.
Quoted 7 lines
(4) arm64: allow non-legacy VGA devices to be default
Select the option on arm64. This solves my problem with the D05, but may cause other cards to be marked as default on other boards. This shouldn't cause any real issues but is worth being aware of.
Hi Daniel,
Quoted 7 lines
Given that the whole point of the VGA arbiter is the ability to share the legacy mem+io ranges between different cards, why do we care about the VGA arbiter in the first place on arm64?
AFAIK, there have been some recent changes in Xorg to address the auto-detection problem. I don't remember the exact details, but I have added Laszlo, who was involved with this at the time.
I haven't been able to locate those changes - I remember that the call to
pci_device_is_boot_vga()inxf86pciBus.c[0] was critical and that is still there in the latest git.Indeed, the reason we care about the vga arbiter at all is because of that Xorg dependency on the boot VGA card.
pci_device_is_boot_vga()reads a sysfs file, and that sysfs file is populated based on thevga_default_driver(), so it's very difficult to extricate ourselves from the vga arbiter and its concept of the default device.
Quoted 5 lines
We could make this method an 'either/or' rather than a fallback - so platforms who didn't care about legacy resources didn't bother with those tests, but I'm not sure what benefit that would give and I find it harder to be confident of an absence of unexpected consequences.
I was referring to this commit
https://cgit.freedesktop.org/xorg/xserver/commit/?id=ca8d88e50310a0d440a127c22a0a383cc149f408
but reading the commit log, it may have less to do with this issue than I thought originally.
But the fact remains that we are going about this the wrong way. Whether a graphics card decodes legacy VGA ranges or not has *nothing* to do with whether or not it is in fact the primary device on a non-x86 system, and so I still think the VGA arbiter should be omitted entirely for such platforms, and Xorg should be fixed instead.
cover Allow non-legacy cards to be vgaarb default
Hi Ard,
Quoted 5 lines
But the fact remains that we are going about this the wrong way. Whether a graphics card decodes legacy VGA ranges or not has *nothing* to do with whether or not it is in fact the primary device on a non-x86 system, and so I still think the VGA arbiter should be omitted entirely for such platforms, and Xorg should be fixed instead.
OK, I see where you're coming from. I've been trying to keep my changes small as I don't want to end up on the hook for the almost limitless range of problems that changing this sort of code can have, but I do take your point that it's a bit of an ugly hack of a solution.
Say we were to change Xorg instead. What would correct Xorg behaviour look like? Xorg would need to honour the boot_vga file if it existed so as not to break x86, etc. So your proposed Xorg - if it couldn't find a default card that way, and if there was no helpful config file info, would arbitrarily pick a card that has an Xorg driver? In other words, much like the proposed kernel approach but at a different level of the stack?
Are there other graphical applications we care about (other than Xorg) that would need to be patched? I'm happy to do the Xorg patch, but I don't know if anything other than Xorg keys off the boot_vga file.
I'm not fundamentally opposed to this approach if the Xorg community is happy with it, the kernel community is happy with it, and no-one expects me to provide patches to any other user-space applications that depend on boot_vga.
Regards,
Daniel
cover Allow non-legacy cards to be vgaarb default
Quoted 21 lines · Daniel Axtens
Hi Ard,
Quoted 5 lines
But the fact remains that we are going about this the wrong way. Whether a graphics card decodes legacy VGA ranges or not has *nothing* to do with whether or not it is in fact the primary device on a non-x86 system, and so I still think the VGA arbiter should be omitted entirely for such platforms, and Xorg should be fixed instead.
OK, I see where you're coming from. I've been trying to keep my changes small as I don't want to end up on the hook for the almost limitless range of problems that changing this sort of code can have, but I do take your point that it's a bit of an ugly hack of a solution.
Say we were to change Xorg instead. What would correct Xorg behaviour look like? Xorg would need to honour the
boot_vgafile if it existed so as not to break x86, etc. So your proposed Xorg - if it couldn't find a default card that way, and if there was no helpful config file info, would arbitrarily pick a card that has an Xorg driver? In other words, much like the proposed kernel approach but at a different level of the stack?
Quoted 8 lines
Are there other graphical applications we care about (other than Xorg) that would need to be patched? I'm happy to do the Xorg patch, but I don't know if anything other than Xorg keys off the
boot_vgafile.I'm not fundamentally opposed to this approach if the Xorg community is happy with it, the kernel community is happy with it, and no-one expects me to provide patches to any other user-space applications that depend on
boot_vga.
Ard both identified the Xorg commit that I would have, and CC'd Hans which I would have recommended as well.
I assume the symptom is that now there's a class of platform GPU devices that is neither PCI nor legacy VGA, so neither the kernel's boot_vga logic matches it, nor Xorg's commit in question.
I agree that it should be possible to add more logic to Xorg to detect this kind device as primary. However, I share Daniel's worry that it wouldn't cover all user space apps -- I see "Wayland this, Wayland that" on reddit every week.
Having practically zero background in gfx development (either kernel or Xorg), I think the problem is that vga_default_device() / vga_set_default_device(), which -- apparently -- "boot_vga" is based upon, come from "drivers/gpu/vga/vgaarb.c". Namely, the concept of "primary / boot display device" is tied to the VGA arbiter, plus only a PCI device can currently be marked as primary/boot display device.
Can these concepts be split from each other? (I can fully imagine that this would result in a userspace visible interface change (or addition), so that e.g. "/sys/devices/**/boot_gpu" would have to be consulted by display servers.)
(Sorry if I'm totally wrong.)
... Hm, reading the thread starter at
<https://www.mail-archive.com/[email protected]/msg120851.html>,
and the references within... It looks like this work is motivated by hardware that is supposed to be PCI, but actually breaks the specs. Is that correct? If so, then I don't think I can suggest anything useful. Specs exist so that hardware vendors and software authors follow them. If hardware does not conform, then software should either refuse to work with it, or handle it with quirks, on a case-by-case basis. I guess this means that I don't agree with the
broad[] suggest[ion] that a more generic solution would be better
which seems to disqualify me from the discussion, as it must have been suggested by people with incomparably more experience than what I have :)
Thanks
Laszlo
cover Allow non-legacy cards to be vgaarb default
Hi Laszlo
[...]
Quoted 14 lines
Having practically zero background in gfx development (either kernel or Xorg), I think the problem is that
vga_default_device()/vga_set_default_device(), which -- apparently -- "boot_vga" is based upon, come from "drivers/gpu/vga/vgaarb.c". Namely, the concept of "primary / boot display device" is tied to the VGA arbiter, plus only a PCI device can currently be marked as primary/boot display device.Can these concepts be split from each other? (I can fully imagine that this would result in a userspace visible interface change (or addition),
so that e.g. "/sys/devices/**/boot_gpu" would have to be consulted by display servers.)
Quoted 8 lines
(Sorry if I'm totally wrong.)
... Hm, reading the thread starter at
<https://www.mail-archive.com/linuxppc-
dev at lists.ozlabs.org/msg120851.html>,
and the references within... It looks like this work is motivated by hardware that is supposed to be PCI, but actually breaks the specs. Is that correct? If so, then I don't think I can suggest anything useful.
My understanding is that the current PCIe HW is specs compliant but the vgaarb, in order to make a VGA device the default one, requires all the bridges on top of such device to have the "VGA Enable" bit set (optional bit in the PCI Express? to PCI/PCI-X Bridge Spec). I.e. all the bridges on top have to support legacy VGA devices; and this is not mandatory from the specs...right?
BTW my VGA experience is limited too...this is just my understanding...
Gab
Quoted 15 lines
Specs exist so that hardware vendors and software authors follow them. If hardware does not conform, then software should either refuse to work
with it, or handle it with quirks, on a case-by-case basis. I guess this
means that I don't agree with thebroad[] suggest[ion] that a more generic solution would be better
which seems to disqualify me from the discussion, as it must have been suggested by people with incomparably more experience than what I have :)
Thanks
Laszlo
cover Allow non-legacy cards to be vgaarb default
Quoted 27 lines · Gabriele Paoloni
Hi Laszlo
[...]
Quoted 14 lines
Having practically zero background in gfx development (either kernel or Xorg), I think the problem is that
vga_default_device()/vga_set_default_device(), which -- apparently -- "boot_vga" is based upon, come from "drivers/gpu/vga/vgaarb.c". Namely, the concept of "primary / boot display device" is tied to the VGA arbiter, plus only a PCI device can currently be marked as primary/boot display device.Can these concepts be split from each other? (I can fully imagine that this would result in a userspace visible interface change (or addition),
so that e.g. "/sys/devices/**/boot_gpu" would have to be consulted by display servers.)Quoted 8 lines
(Sorry if I'm totally wrong.)
... Hm, reading the thread starter at
<https://www.mail-archive.com/linuxppc-
dev at lists.ozlabs.org/msg120851.html>,
and the references within... It looks like this work is motivated by hardware that is supposed to be PCI, but actually breaks the specs. Is that correct? If so, then I don't think I can suggest anything useful.
Quoted 6 lines
My understanding is that the current PCIe HW is specs compliant but the vgaarb, in order to make a VGA device the default one, requires all the bridges on top of such device to have the "VGA Enable" bit set (optional bit in the PCI Express? to PCI/PCI-X Bridge Spec). I.e. all the bridges on top have to support legacy VGA devices; and this is not mandatory from the specs...right?
Sounds very plausible to me. And, I guess if the "boot GPU" concept were split from the VGA arbiter, then the VGA arbiter's above requirement
(a) would not have to be disturbed, and
(b) would no longer interfere with the kind of hardware that's being discussed.
Thanks
Laszlo
Quoted 19 lines
BTW my VGA experience is limited too...this is just my understanding...
Gab
Quoted 15 lines
Specs exist so that hardware vendors and software authors follow them. If hardware does not conform, then software should either refuse to work
with it, or handle it with quirks, on a case-by-case basis. I guess this
means that I don't agree with thebroad[] suggest[ion] that a more generic solution would be better
which seems to disqualify me from the discussion, as it must have been suggested by people with incomparably more experience than what I have :)
Thanks
Laszlo
cover Allow non-legacy cards to be vgaarb default
In reply to Gabriele PaoloniQuoted 22 lines · Gabriele Paoloni
Quoted 13 lines
Having practically zero background in gfx development (either kernel or Xorg), I think the problem is that
vga_default_device()/vga_set_default_device(), which -- apparently -- "boot_vga" is based upon, come from "drivers/gpu/vga/vgaarb.c". Namely, the concept of "primary / boot display device" is tied to the VGA arbiter, plus only a PCI device can currently be marked as primary/boot display device.Can these concepts be split from each other? (I can fully imagine that this would result in a userspace visible interface change (or addition),
so that e.g. "/sys/devices/**/boot_gpu" would have to be consulted by display servers.)Quoted 8 lines
(Sorry if I'm totally wrong.)
... Hm, reading the thread starter at
<https://www.mail-archive.com/linuxppc-
dev at lists.ozlabs.org/msg120851.html>,
and the references within... It looks like this work is motivated by hardware that is supposed to be PCI, but actually breaks the specs. Is that correct? If so, then I don't think I can suggest anything useful.
Quoted 6 lines
My understanding is that the current PCIe HW is specs compliant but the vgaarb, in order to make a VGA device the default one, requires all the bridges on top of such device to have the "VGA Enable" bit set (optional bit in the PCI Express? to PCI/PCI-X Bridge Spec). I.e. all the bridges on top have to support legacy VGA devices; and this is not mandatory from the specs...right?
Per the PCIe-to-PCI Bridge spec r1.0, sec 5.1.2.13, the VGA Enable bit is optional, as you say. The PCI-to-PCI Bridge spec r1.2, sec 3.2.5.18, doesn't say VGA Enable is optional, *but* sec 4.5 says bridges need not support VGA. I naively assume one would discover that by finding VGA Enable to be RO zero.
Of course, in any case, I also assume that (a) there exist VGA cards that require legacy VGA resources, e.g., memory 0xa0000-0xbffff, and
(b) such cards will not work behind bridges without VGA support.
I have no idea what if anything the VGA arbiter should do about bridges like this or VGA devices behind them, but it does sound like the arbiter might need to become smarter.
Bjorn
cover Allow non-legacy cards to be vgaarb default
In reply to Laszlo ErsekHi Laszlo,
Thanks for your input!
Quoted 21 lines
Quoted 8 lines
Are there other graphical applications we care about (other than Xorg) that would need to be patched? I'm happy to do the Xorg patch, but I don't know if anything other than Xorg keys off the
boot_vgafile.I'm not fundamentally opposed to this approach if the Xorg community is happy with it, the kernel community is happy with it, and no-one expects me to provide patches to any other user-space applications that depend on
boot_vga.Ard both identified the Xorg commit that I would have, and CC'd Hans which I would have recommended as well.
I assume the symptom is that now there's a class of platform GPU devices that is neither PCI nor legacy VGA, so neither the kernel's
boot_vgalogic matches it, nor Xorg's commit in question.I agree that it should be possible to add more logic to Xorg to detect this kind device as primary. However, I share Daniel's worry that it wouldn't cover all user space apps -- I see "Wayland this, Wayland that" on reddit every week.
Quoted 6 lines
Having practically zero background in gfx development (either kernel or Xorg), I think the problem is that
vga_default_device()/vga_set_default_device(), which -- apparently -- "boot_vga" is based upon, come from "drivers/gpu/vga/vgaarb.c". Namely, the concept of "primary / boot display device" is tied to the VGA arbiter, plus only a PCI device can currently be marked as primary/boot display device.
You're right, the issue is that the primary/boot device is tied to the VGA arbiter.
Quoted 5 lines
Can these concepts be split from each other? (I can fully imagine that this would result in a userspace visible interface change (or addition), so that e.g. "
/sys/devices/**/boot_gpu" would have to be consulted by display servers.)
Yes, they can be split or a way of marking the default vga device that doesn't depend on the arbiter can be added.
(But there is some question about what it actually means to be a boot vga card - it's better defined on an x86 system, but on a ppc or arm64 system we're reduced to guessing based on the first driver loaded.)
Quoted 12 lines
(Sorry if I'm totally wrong.)
... Hm, reading the thread starter at
<https://www.mail-archive.com/[email protected]/msg120851.html>,
and the references within... It looks like this work is motivated by hardware that is supposed to be PCI, but actually breaks the specs. Is that correct? If so, then I don't think I can suggest anything useful. Specs exist so that hardware vendors and software authors follow them. If hardware does not conform, then software should either refuse to work with it, or handle it with quirks, on a case-by-case basis. I guess this means that I don't agree with the
Quoted 4 lines
broad[] suggest[ion] that a more generic solution would be better
which seems to disqualify me from the discussion, as it must have been suggested by people with incomparably more experience than what I have :)
Originally this was brought to the fore through a PCI bridge that wasn't spec compliant, and originally I proposed a simple quirk: [0]. However, that highlighted the related issue that platforms that don't use legacy resources still go through the VGA arbiter process which is built around legacy resource arbitration. Changing that behaviour also fixes the issue with the non-spec-compliant bridge because the new model doesn't rely upon the particular part of the spec that the bridge violates.
I'm not fussy about how we solve this problem, so long as we solve this problem somehow.
Regards,
Daniel
[0]: https://patchwork.ozlabs.org/patch/787003/
Quoted 3 lines
Thanks
Laszlo