From: Bjorn Helgaas <bhelgaas@google.com>
To: Daniel Vetter <daniel.vetter@intel.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
Gabriele Paoloni <gabriele.paoloni@huawei.com>,
Ard Biesheuvel <ard.biesheuvel@linaro.org>,
linux-pci@vger.kernel.org,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will.deacon@arm.com>,
dri-devel@lists.freedesktop.org,
Xinliang Liu <z.liuxinliang@hisilicon.com>,
Alex Williamson <alex.williamson@redhat.com>,
Lukas Wunner <lukas@wunner.de>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Rongrong Zou <zourongrong@gmail.com>,
Dave Airlie <airlied@redhat.com>,
linuxppc-dev@lists.ozlabs.org,
linux-arm-kernel@lists.infradead.org,
Daniel Axtens <dja@axtens.net>
Subject: [PATCH v2 2/2] vgaarb: Factor out EFI and fallback default device selection
Date: Thu, 12 Oct 2017 22:47:29 -0500 [thread overview]
Message-ID: <20171013034729.14630.30419.stgit@bhelgaas-glaptop.roam.corp.google.com> (raw)
In-Reply-To: <20171013034338.14630.4766.stgit@bhelgaas-glaptop.roam.corp.google.com>
The default VGA device is normally set in vga_arbiter_add_pci_device() when
we call it for the first enabled device that can be accessed with the
legacy VGA resources ([mem 0xa0000-0xbffff], etc.)
That default device can be overridden by an EFI device that owns the boot
framebuffer. As a fallback, we can also select a VGA device that can't be
accessed via legacy VGA resources, or a VGA device that isn't even enabled.
Factor out this EFI and fallback selection from vga_arb_device_init() into
a separate vga_arb_select_default_device() function. This doesn't change
any behavior, but it untangles the "bridge control possible" checking and
messages from the default device selection.
Tested-by: Zhou Wang <wangzhou1@hisilicon.com> # D05 Hisi Hip07, Hip08
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
drivers/gpu/vga/vgaarb.c | 57 ++++++++++++++++++++++++++++------------------
1 file changed, 35 insertions(+), 22 deletions(-)
diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c
index 8035e38d5110..d35d6d271f3f 100644
--- a/drivers/gpu/vga/vgaarb.c
+++ b/drivers/gpu/vga/vgaarb.c
@@ -1402,29 +1402,14 @@ static struct miscdevice vga_arb_device = {
MISC_DYNAMIC_MINOR, "vga_arbiter", &vga_arb_device_fops
};
-static int __init vga_arb_device_init(void)
+static void __init vga_arb_select_default_device(void)
{
- int rc;
struct pci_dev *pdev;
struct vga_device *vgadev;
- rc = misc_register(&vga_arb_device);
- if (rc < 0)
- pr_err("error %d registering device\n", rc);
-
- bus_register_notifier(&pci_bus_type, &pci_notifier);
-
- /* We add all pci devices satisfying vga class in the arbiter by
- * default */
- pdev = NULL;
- while ((pdev =
- pci_get_subsys(PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
- PCI_ANY_ID, pdev)) != NULL)
- vga_arbiter_add_pci_device(pdev);
-
+#if defined(CONFIG_X86) || defined(CONFIG_IA64)
list_for_each_entry(vgadev, &vga_list, list) {
struct device *dev = &vgadev->pdev->dev;
-#if defined(CONFIG_X86) || defined(CONFIG_IA64)
/*
* Override vga_arbiter_add_pci_device()'s I/O based detection
* as it may take the wrong device (e.g. on Apple system under
@@ -1461,12 +1446,8 @@ static int __init vga_arb_device_init(void)
vgaarb_info(dev, "overriding boot device\n");
vga_set_default_device(vgadev->pdev);
}
-#endif
- if (vgadev->bridge_has_one_vga)
- vgaarb_info(dev, "bridge control possible\n");
- else
- vgaarb_info(dev, "no bridge control possible\n");
}
+#endif
if (!vga_default_device()) {
list_for_each_entry(vgadev, &vga_list, list) {
@@ -1492,6 +1473,38 @@ static int __init vga_arb_device_init(void)
vga_set_default_device(vgadev->pdev);
}
}
+}
+
+static int __init vga_arb_device_init(void)
+{
+ int rc;
+ struct pci_dev *pdev;
+ struct vga_device *vgadev;
+
+ rc = misc_register(&vga_arb_device);
+ if (rc < 0)
+ pr_err("error %d registering device\n", rc);
+
+ bus_register_notifier(&pci_bus_type, &pci_notifier);
+
+ /* We add all PCI devices satisfying VGA class in the arbiter by
+ * default */
+ pdev = NULL;
+ while ((pdev =
+ pci_get_subsys(PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
+ PCI_ANY_ID, pdev)) != NULL)
+ vga_arbiter_add_pci_device(pdev);
+
+ list_for_each_entry(vgadev, &vga_list, list) {
+ struct device *dev = &vgadev->pdev->dev;
+
+ if (vgadev->bridge_has_one_vga)
+ vgaarb_info(dev, "bridge control possible\n");
+ else
+ vgaarb_info(dev, "no bridge control possible\n");
+ }
+
+ vga_arb_select_default_device();
pr_info("loaded\n");
return rc;
next prev parent reply other threads:[~2017-10-13 3:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-13 3:47 [PATCH v2 0/2] vgaarb: Select fallback default VGA device Bjorn Helgaas
2017-10-13 3:47 ` [PATCH v2 1/2] vgaarb: Select a default VGA device even if there's no legacy VGA Bjorn Helgaas
2017-10-13 3:47 ` Bjorn Helgaas [this message]
2017-10-17 2:03 ` [PATCH v2 2/2] vgaarb: Factor out EFI and fallback default device selection Daniel Axtens
2017-10-17 12:05 ` Daniel Vetter
2017-10-17 12:21 ` Ard Biesheuvel
2017-10-18 0:24 ` Daniel Axtens
2017-10-18 8:18 ` Daniel Vetter
2017-10-18 11:05 ` Daniel Axtens
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=20171013034729.14630.30419.stgit@bhelgaas-glaptop.roam.corp.google.com \
--to=bhelgaas@google.com \
--cc=airlied@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=ard.biesheuvel@linaro.org \
--cc=benh@kernel.crashing.org \
--cc=catalin.marinas@arm.com \
--cc=daniel.vetter@intel.com \
--cc=dja@axtens.net \
--cc=dri-devel@lists.freedesktop.org \
--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=lorenzo.pieralisi@arm.com \
--cc=lukas@wunner.de \
--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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).