From patchwork Mon Sep 25 16:39:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 9971441 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3090760365 for ; Tue, 26 Sep 2017 08:11:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BE43287FE for ; Tue, 26 Sep 2017 08:11:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A39A28919; Tue, 26 Sep 2017 08:11:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7F3862882B for ; Tue, 26 Sep 2017 08:11:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BD4CC6E45B; Tue, 26 Sep 2017 08:10:28 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id 16F476E37A for ; Mon, 25 Sep 2017 16:39:50 +0000 (UTC) Received: from localhost (unknown [69.71.4.159]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5A84A2148C; Mon, 25 Sep 2017 16:39:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5A84A2148C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=helgaas@kernel.org Date: Mon, 25 Sep 2017 11:39:48 -0500 From: Bjorn Helgaas To: Daniel Axtens Subject: Re: [PATCH v3 0/3] Split default display handling out from VGA arbiter Message-ID: <20170925163948.GD15970@bhelgaas-glaptop.roam.corp.google.com> References: <20170901072744.2409-1-dja@axtens.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170901072744.2409-1-dja@axtens.net> User-Agent: Mutt/1.5.21 (2010-09-15) X-Mailman-Approved-At: Tue, 26 Sep 2017 08:10:09 +0000 Cc: lorenzo.pieralisi@arm.com, catalin.marinas@arm.com, gabriele.paoloni@huawei.com, ard.biesheuvel@linaro.org, linux-pci@vger.kernel.org, will.deacon@arm.com, dri-devel@lists.freedesktop.org, z.liuxinliang@hisilicon.com, alex.williamson@redhat.com, zourongrong@gmail.com, daniel.vetter@intel.com, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 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-Virus-Scanned: ClamAV using ClamSMTP On Fri, Sep 01, 2017 at 05:27:41PM +1000, Daniel Axtens wrote: > This patch set: > > - splits the default display handling out from VGA arbiter, into its > own file and behind its own Kconfig option (and gives the functions > better names). > > - adds extra detection of default devices. To be nominated, the vga > arbiter and platform hooks must not have nominated a default. A > card will then only be nominated if it has a driver attached and > has IO or memory decoding enabled. > > - adds relevant documentation. > > The practical impact of this is improved X autoconfiguration on some > arm64 systems. I think I gave you bad advice about trying to separate the "default device" idea from the VGA arbiter. It is true that the "VGA arbiter" per se is related to routing the legacy VGA resources, and the arbiter currently only selects a default device if it finds a device to which those resources are routed. We have some cases where we want to select a default device that may not support the legacy VGA resources, or where they might not be routed to the device: - systems where we match the EFI framebuffer address with a BAR, and select that device as default, - powerpc systems where there may be no host bridge window that maps to the legacy VGA resources, - your ARM64 systems where the default device may be behind a bridge that doesn't support legacy VGA routing (PCI_BRIDGE_CTL_VGA) But I think trying to split the "default device" part out from the VGA arbiter ends up being overkill and making things more complicated instead of simpler. Would something like the following work for you as well as the powerpc case? On powerpc, we already use vga_set_default_device() to select a device that doesn't use legacy VGA resources, so maybe we can just do the same on ARM64? I suppose there might be wrinkles in how the arbiter deals with multiple graphics devices on those systems, since I don't think it identifies these devices that don't use the legacy resources, but it seems like we live with whatever those on are powerpc and probably can on ARM64 as well. Tested-by: Daniel Axtens # arm64, ppc64-qemu-tcg diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 02831a396419..0ac7aa346c69 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -1740,15 +1740,3 @@ static void fixup_hide_host_resource_fsl(struct pci_dev *dev) } DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MOTOROLA, PCI_ANY_ID, fixup_hide_host_resource_fsl); DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_FREESCALE, PCI_ANY_ID, fixup_hide_host_resource_fsl); - -static void fixup_vga(struct pci_dev *pdev) -{ - u16 cmd; - - pci_read_config_word(pdev, PCI_COMMAND, &cmd); - if ((cmd & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) || !vga_default_device()) - vga_set_default_device(pdev); - -} -DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID, - PCI_CLASS_DISPLAY_VGA, 8, fixup_vga); diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c index 76875f6299b8..9df4802c5f04 100644 --- a/drivers/gpu/vga/vgaarb.c +++ b/drivers/gpu/vga/vgaarb.c @@ -1468,6 +1468,21 @@ static int __init vga_arb_device_init(void) vgaarb_info(dev, "no bridge control possible\n"); } + if (!vga_default_device()) { + list_for_each_entry(vgadev, &vga_list, list) { + struct device *dev = &vgadev->pdev->dev; + u16 cmd; + + pdev = vgadev->pdev; + pci_read_config_word(pdev, PCI_COMMAND, &cmd); + if (cmd & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) { + vgaarb_info(dev, "setting as boot device\n"); + vga_set_default_device(pdev); + break; + } + } + } + pr_info("loaded\n"); return rc; }