From patchwork Mon Nov 25 19:54:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Bruno_Pr=C3=A9mont?= X-Patchwork-Id: 3234241 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 167DAC045B for ; Mon, 25 Nov 2013 20:05:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DAEAF202EA for ; Mon, 25 Nov 2013 20:05:37 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 654D520304 for ; Mon, 25 Nov 2013 20:05:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C1E8DFB22D; Mon, 25 Nov 2013 12:05:33 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 644 seconds by postgrey-1.32 at gabe; Mon, 25 Nov 2013 12:05:31 PST Received: from hygieia.santi-shop.eu (hygieia.santi-shop.eu [78.46.175.2]) by gabe.freedesktop.org (Postfix) with ESMTP id 5F3FDFB22D for ; Mon, 25 Nov 2013 12:05:31 -0800 (PST) Received: from neptune.home (unknown [IPv6:2001:960:7ab:0:2c0:9fff:fe2d:39d]) by hygieia.santi-shop.eu (Postfix) with ESMTPSA id 055FD40C12E1; Mon, 25 Nov 2013 20:54:42 +0100 (CET) Date: Mon, 25 Nov 2013 20:54:41 +0100 From: Bruno =?UTF-8?B?UHLDqW1vbnQ=?= To: Dave Airlie , Bjorn Helgaas , Peter Jones Subject: [RFC patch] PCI: Extend boot_vga sysfs attribute lookup to fix X on MBA+EFI Message-ID: <20131125205441.5046e0cb@neptune.home> X-Mailer: Claws Mail 3.9.0 (GTK+ 2.24.17; i686-pc-linux-gnu) Mime-Version: 1.0 Cc: Linux PCI , DRI mailing list X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 #include #include +#include #include #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));