From patchwork Sat Aug 16 17:30:39 2014 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: 4729951 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8CDD89FADA for ; Sat, 16 Aug 2014 17:32:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 987C3201F4 for ; Sat, 16 Aug 2014 17:32:06 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7AFAD201BC for ; Sat, 16 Aug 2014 17:32:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 978A36E27A; Sat, 16 Aug 2014 10:32:03 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from hygieia.santi-shop.eu (hygieia.santi-shop.eu [78.46.175.2]) by gabe.freedesktop.org (Postfix) with ESMTP id 559C4891CD for ; Sat, 16 Aug 2014 10:31:58 -0700 (PDT) Received: from neptune.home (unknown [IPv6:2001:960:7ab:0:2c0:9fff:fe2d:39d]) by smtp.sysophe.eu (Postfix) with ESMTPSA id EC10B46315B1; Sat, 16 Aug 2014 19:31:55 +0200 (CEST) Date: Sat, 16 Aug 2014 19:30:39 +0200 From: Bruno =?UTF-8?B?UHLDqW1vbnQ=?= To: Andreas Noever Subject: [PATCH 2/2] x86, ia64: Don't default to first video device Message-ID: <20140816193039.76304abb@neptune.home> In-Reply-To: <20140816192135.34260115@neptune.home> References: <20140514224339.7f8be3a9@neptune.home> <20140527234255.GJ11907@google.com> <20140602201650.35f0e936@neptune.home> <20140602201926.4d476818@neptune.home> <20140625005501.7ff7e982@neptune.home> <20140705171503.GC6247@google.com> <20140810112654.1bf684d6@neptune.home> <20140810183411.19370721@neptune.home> <20140816192135.34260115@neptune.home> X-Mailer: Claws Mail 3.9.0 (GTK+ 2.24.24; i686-pc-linux-gnu) Mime-Version: 1.0 Cc: Matthew Garrett , Linux PCI , DRI mailing list , Greg Kroah-Hartman , Bjorn Helgaas X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.9 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 With commit 20cde694027e boot video device detection was moved from efifb to x86 and ia64 pci/fixup.c. For dual-GPU Apple computers above above change represents a regression as code in efifb did forcefully override vga_default_device while the merge did not (changed ordering of actions). This stops setting default_vga_device when applying IORESOURCE_ROM_SHADOW (only doing so for the detected boot GPU) and updates logging of boot video device selection, in vgaarb which covers VGA text-mode booting and first half of pci_fixup_video which covers framebuffer mode (EFI, VESA). By setting IORESOURCE_ROM_SHADOW only on effective boot GPU we also corrects a longstanding complaint from intel driver as reported by Andreas: > Does setting the ROM_SHADOW flag on (possibly) the wrong device > have any effect? Yes it does. Removing the line changes a long standing i915 0000:00:02.0: Invalid ROM contents into a i915 0000:00:02.0: BAR 6: can't assign [??? 0x00000000 flags 0x20000000] (bogus alignment). The first is logged at KERN_ERR while the second is at KERN_INFO. Reported-By: Andreas Noever Signed-off-by: Bruno Prémont CC: Matthew Garrett CC: stable@vger.kernel.org # v3.5+ --- Must be applied to stable when upstream commit 20cde694027e7477cc532833e38ab9fcaa83fb64, which is marked for stable, gets applied. Can be applied without patch 1/2 from this series though dropped #ifndefs will cause this patch not to apply cleanly. arch/ia64/pci/fixup.c | 9 +++++---- arch/x86/pci/fixup.c | 9 +++++---- drivers/gpu/vga/vgaarb.c | 4 +++- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/arch/ia64/pci/fixup.c b/arch/ia64/pci/fixup.c index ec73b2c..05198f8 100644 --- a/arch/ia64/pci/fixup.c +++ b/arch/ia64/pci/fixup.c @@ -54,8 +54,10 @@ static void pci_fixup_video(struct pci_dev *pdev) continue; if (screen_info.lfb_base >= start && - (screen_info.lfb_base + screen_info.lfb_size) < end) + (screen_info.lfb_base + screen_info.lfb_size) < end) { + dev_printk(KERN_DEBUG, &pdev->dev, "Boot video device\n"); vga_set_default_device(pdev); + } } } @@ -79,12 +81,11 @@ static void pci_fixup_video(struct pci_dev *pdev) } bus = bus->parent; } - if (!vga_default_device() || pdev == vga_default_device()) { + if (pdev == vga_default_device()) { pci_read_config_word(pdev, PCI_COMMAND, &config); if (config & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) { pdev->resource[PCI_ROM_RESOURCE].flags |= IORESOURCE_ROM_SHADOW; - dev_printk(KERN_DEBUG, &pdev->dev, "Boot video device\n"); - vga_set_default_device(pdev); + dev_printk(KERN_DEBUG, &pdev->dev, "Video device with shadowed ROM\n"); } } } diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c index c61ea57..5b392d2 100644 --- a/arch/x86/pci/fixup.c +++ b/arch/x86/pci/fixup.c @@ -342,8 +342,10 @@ static void pci_fixup_video(struct pci_dev *pdev) continue; if (screen_info.lfb_base >= start && - (screen_info.lfb_base + screen_info.lfb_size) < end) + (screen_info.lfb_base + screen_info.lfb_size) < end) { + dev_printk(KERN_DEBUG, &pdev->dev, "Boot video device\n"); vga_set_default_device(pdev); + } } } @@ -367,12 +369,11 @@ static void pci_fixup_video(struct pci_dev *pdev) } bus = bus->parent; } - if (!vga_default_device() || pdev == vga_default_device()) { + if (pdev == vga_default_device()) { pci_read_config_word(pdev, PCI_COMMAND, &config); if (config & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) { pdev->resource[PCI_ROM_RESOURCE].flags |= IORESOURCE_ROM_SHADOW; - dev_printk(KERN_DEBUG, &pdev->dev, "Boot video device\n"); - vga_set_default_device(pdev); + dev_printk(KERN_DEBUG, &pdev->dev, "Video device with shadowed ROM\n"); } } } diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c index 257674d..c6eeed5 100644 --- a/drivers/gpu/vga/vgaarb.c +++ b/drivers/gpu/vga/vgaarb.c @@ -580,8 +580,10 @@ static bool vga_arbiter_add_pci_device(struct pci_dev *pdev) * by default if arch doesn't have it's own hook */ if (vga_default == NULL && - ((vgadev->owns & VGA_RSRC_LEGACY_MASK) == VGA_RSRC_LEGACY_MASK)) + ((vgadev->owns & VGA_RSRC_LEGACY_MASK) == VGA_RSRC_LEGACY_MASK)) { + pr_info("vgaarb: Boot video device: PCI:%s\n", pci_name(pdev)); vga_set_default_device(pdev); + } vga_arbiter_check_bridge_sharing(vgadev);