linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC patch] PCI: Extend boot_vga sysfs attribute lookup to fix X on MBA+EFI
@ 2013-11-25 19:54 Bruno Prémont
  2013-11-25 20:36 ` Bjorn Helgaas
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Bruno Prémont @ 2013-11-25 19:54 UTC (permalink / raw)
  To: Dave Airlie, Bjorn Helgaas, Peter Jones; +Cc: DRI mailing list, Linux PCI

On a MacBookAir2,1, booting to Linux with EFI though having
no efifb built-in Xorg refuses to start with "no devices detected"
because for the only VGA device available (NVidia Geforce 9400M)
the sysfs attribute boot_vga is zero (instead of expected 1).

When CONFIG_FB_EFI is selected, efifb does provide its own
vga_default_device() to report the PCI device matching global
screen_info as determined during efifb setup.

Otherwise there is just a dummy or VGA_ARB's vga_default_device()
that does not provide the right information.

On the other hand, boot_vga_show() falls back to poking PCI
resources to flag a PCI device as boot_vga if vga_default_device()
returned no PCI device (NULL).

To complement this PCI resource poking, this patch copies the
validation code used to determine which PCI device to report as
default VGA device by efifb into boot_vga_show().

Signed-off-by: Bruno Prémont <bonbons@linux-vserver.org>
---
Would it make sense to kill the corresponding code from efifb
as it covers only a single case?

The other EFI capable system I have (AMD Ilano based, Gigabyte
mainboard does report boot_vga=1, possibly through the resources
poking and there Xorg starts properly without efifb built in.

Selecting CONFIG_X86_SYSFB (combined with CONFIG_FB_SIMPLE) does
not help by itself, patching that one instead of PCI's boot_vga
attribute directly would still not cover the case when neither
of them is enabled.


 drivers/pci/pci-sysfs.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 7128cfd..91cac71 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -28,6 +28,7 @@
 #include <linux/pci-aspm.h>
 #include <linux/slab.h>
 #include <linux/vgaarb.h>
+#include <linux/screen_info.h>
 #include <linux/pm_runtime.h>
 #include "pci.h"
 
@@ -540,6 +541,26 @@ boot_vga_show(struct device *dev, struct device_attribute *attr, char *buf)
 	if (vga_dev)
 		return sprintf(buf, "%u\n", (pdev == vga_dev));
 
+	if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA) {
+		resource_size_t start, end;
+		int i;
+
+		for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
+			if (!(pci_resource_flags(pdev, i) & IORESOURCE_MEM))
+				continue;
+
+			start = pci_resource_start(pdev, i);
+			end  = pci_resource_end(pdev, i);
+
+			if (!start || !end)
+				continue;
+
+			if (screen_info.lfb_base >= start &&
+				(screen_info.lfb_base + screen_info.lfb_size) < end)
+				return sprintf(buf, "1\n");
+		}
+	}
+
 	return sprintf(buf, "%u\n",
 		!!(pdev->resource[PCI_ROM_RESOURCE].flags &
 		   IORESOURCE_ROM_SHADOW));

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-03-18 17:11 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-25 19:54 [RFC patch] PCI: Extend boot_vga sysfs attribute lookup to fix X on MBA+EFI Bruno Prémont
2013-11-25 20:36 ` Bjorn Helgaas
2013-11-25 21:04   ` Bruno Prémont
2013-11-27 20:40 ` David Herrmann
2013-11-28  7:22   ` Bruno Prémont
2013-11-30 13:52 ` [RFC patch v2] x86: Improve boot_vga/vga_default_device() for EFI Bruno Prémont
2013-12-09 21:35   ` Bjorn Helgaas
2013-12-18 15:38   ` David Herrmann
2013-12-18 15:43     ` David Herrmann
2013-12-18 18:46       ` Bruno Prémont
2014-03-18 17:05         ` [RFC patch v3] " Bruno Prémont

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).