From: Daniel Axtens <dja@axtens.net> To: linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Cc: benh@kernel.crashing.org, z.liuxinliang@hisilicon.com, zourongrong@gmail.com, catalin.marinas@arm.com, will.deacon@arm.com, gabriele.paoloni@huawei.com, bhelgaas@google.com, airlied@linux.ie, daniel.vetter@intel.com, alex.williamson@redhat.com, Daniel Axtens <dja@axtens.net>, Brian King <brking@linux.vnet.ibm.com> Subject: [PATCH 1/3] powerpc: simplify and fix VGA default device behaviour Date: Fri, 4 Aug 2017 20:20:31 +1000 [thread overview] Message-ID: <20170804102033.27731-2-dja@axtens.net> (raw) In-Reply-To: <20170804102033.27731-1-dja@axtens.net> 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. Cc: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Daniel Axtens <dja@axtens.net> --- 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. Informal benh ack: https://patchwork.kernel.org/patch/9850235/ --- arch/powerpc/kernel/pci-common.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 341a7469cab8..c95fdda3a2dc 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -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); } -- 2.11.0
WARNING: multiple messages have this Message-ID (diff)
From: dja@axtens.net (Daniel Axtens) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/3] powerpc: simplify and fix VGA default device behaviour Date: Fri, 4 Aug 2017 20:20:31 +1000 [thread overview] Message-ID: <20170804102033.27731-2-dja@axtens.net> (raw) In-Reply-To: <20170804102033.27731-1-dja@axtens.net> 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. Cc: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Daniel Axtens <dja@axtens.net> --- 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. Informal benh ack: https://patchwork.kernel.org/patch/9850235/ --- arch/powerpc/kernel/pci-common.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 341a7469cab8..c95fdda3a2dc 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -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); } -- 2.11.0
next prev parent reply other threads:[~2017-08-04 10:21 UTC|newest] Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-08-04 10:20 [PATCH 0/3] Split VGA default selection from VGA arbiter Daniel Axtens 2017-08-04 10:20 ` Daniel Axtens 2017-08-04 10:20 ` Daniel Axtens 2017-08-04 10:20 ` Daniel Axtens [this message] 2017-08-04 10:20 ` [PATCH 1/3] powerpc: simplify and fix VGA default device behaviour Daniel Axtens 2017-08-11 21:44 ` Bjorn Helgaas 2017-08-11 21:44 ` Bjorn Helgaas 2017-08-11 21:44 ` Bjorn Helgaas 2017-08-13 22:34 ` Daniel Axtens 2017-08-13 22:34 ` Daniel Axtens 2017-08-04 10:20 ` [PATCH 2/3] Split VGA default device handler out of VGA arbiter Daniel Axtens 2017-08-04 10:20 ` Daniel Axtens 2017-08-04 10:20 ` Daniel Axtens 2017-08-05 6:57 ` Lukas Wunner 2017-08-05 6:57 ` Lukas Wunner 2017-08-06 23:49 ` Daniel Axtens 2017-08-06 23:49 ` Daniel Axtens 2017-08-06 23:49 ` Daniel Axtens 2017-08-04 10:20 ` [PATCH 3/3] powerpc: replace vga_fixup() with generic code Daniel Axtens 2017-08-04 10:20 ` Daniel Axtens 2017-08-07 7:18 ` Michael Ellerman 2017-08-07 7:18 ` Michael Ellerman 2017-08-07 7:18 ` Michael Ellerman 2017-08-07 23:01 ` Daniel Axtens 2017-08-07 23:01 ` Daniel Axtens 2017-08-07 23:01 ` Daniel Axtens 2017-08-08 10:12 ` Michael Ellerman 2017-08-08 10:12 ` Michael Ellerman 2017-08-08 10:12 ` Michael Ellerman
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20170804102033.27731-2-dja@axtens.net \ --to=dja@axtens.net \ --cc=airlied@linux.ie \ --cc=alex.williamson@redhat.com \ --cc=benh@kernel.crashing.org \ --cc=bhelgaas@google.com \ --cc=brking@linux.vnet.ibm.com \ --cc=catalin.marinas@arm.com \ --cc=daniel.vetter@intel.com \ --cc=gabriele.paoloni@huawei.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-pci@vger.kernel.org \ --cc=linuxppc-dev@lists.ozlabs.org \ --cc=will.deacon@arm.com \ --cc=z.liuxinliang@hisilicon.com \ --cc=zourongrong@gmail.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.