From patchwork Wed Jul 19 01:28:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Axtens X-Patchwork-Id: 9850239 X-Patchwork-Delegate: bhelgaas@google.com 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 CB0F9601C8 for ; Wed, 19 Jul 2017 01:29:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB194285BA for ; Wed, 19 Jul 2017 01:29:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B012F285CD; Wed, 19 Jul 2017 01:29:38 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 586A3285BA for ; Wed, 19 Jul 2017 01:29:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752115AbdGSB3h (ORCPT ); Tue, 18 Jul 2017 21:29:37 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:33683 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751906AbdGSB3h (ORCPT ); Tue, 18 Jul 2017 21:29:37 -0400 Received: by mail-pg0-f66.google.com with SMTP id z1so4871363pgs.0 for ; Tue, 18 Jul 2017 18:29:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=n8klp6m6vA4ehhOYV+x47M/uMd6ZUR16BjxpLcofWug=; b=SJpO4KOqahkqf9FRf9e8Hi1zhl+GP1PwviUHo0oYgxa3cUgy15vomXtT5PyBdMQbMA S0K2q+Hjs7m2ldCBVNgrkb3MJFjSfl/t++wXpy3wRK5FEKVtEUN1/5oApH9en6xxAhC6 Aec2vqAi2SY4U9hJ0iK7Ur5SVcMdiDc1nXElU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=n8klp6m6vA4ehhOYV+x47M/uMd6ZUR16BjxpLcofWug=; b=OYZw37XUINwSzPVyMRko1Z3tsoYy9hK+3m9N21x6b2brIuqBDN++YpMVjBAjUPboWC 6o9OxjC7l3Cy+L7aGu5Mt6zGKxJluz3Lx1wxnbAOD/V2FEGcad0W6HF1+f/wDOb4Wo9J HcPXL50dxQUcU2Yey/bYWMSk3DzuxAVckYplmoOqFVHL8tFIkasndj8xSCqGQwhOwUWS uHEYPViMjCuFN/qNN7mkguftGRY+pyDbncH2AAiHvS48TuK42pLVryOttsnKwkgZrKnz 7ynlJiz3XHcUnuG4qknwsmgjItRK0acaZzYqpqQQ1yf61ZJYHRSx8n9NqJW8wsjW2FSq GJ8g== X-Gm-Message-State: AIVw113lF8N6JVWKqgmTej5o5w4nPMjM4ajFpCnzst8s8XQITIqO/jSo FJmF/WfF+j5Ta99pVOdgJA== X-Received: by 10.84.140.235 with SMTP id 98mr525304plt.26.1500427776426; Tue, 18 Jul 2017 18:29:36 -0700 (PDT) Received: from localhost.localdomain (203-59-51-51.dyn.iinet.net.au. [203.59.51.51]) by smtp.gmail.com with ESMTPSA id n90sm7582401pfk.105.2017.07.18.18.29.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Jul 2017 18:29:35 -0700 (PDT) From: Daniel Axtens To: linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Cc: benh@kernel.crashing.org, z.liuxinliang@hisilicon.com, zourongrong@gmail.com, catalin.marinas@arm.com, will.deacon@arm.com, gabriele.paoloni@huawei.com, helgass@kernel.org, airlied@linux.ie, daniel.vetter@intel.com, alex.williamson@redhat.com, Daniel Axtens Subject: [PATCH 2/3] vgaarb rework Date: Wed, 19 Jul 2017 11:28:36 +1000 Message-Id: <20170719012839.20124-4-dja@axtens.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170719012839.20124-1-dja@axtens.net> References: <20170719012839.20124-1-dja@axtens.net> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Daniel Axtens --- arch/powerpc/Kconfig | 1 + arch/powerpc/kernel/pci-common.c | 2 ++ drivers/gpu/vga/Kconfig | 8 ++++++++ drivers/gpu/vga/vgaarb.c | 21 +++++++++++++++++++++ 4 files changed, 32 insertions(+) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 524f71104b75..f86e4c8a9cc6 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -83,6 +83,7 @@ config PPC select BUILDTIME_EXTABLE_SORT select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_MIGHT_HAVE_PC_SERIO + select ARCH_WANT_VGA_ARB_FALLBACK select BINFMT_ELF select ARCH_HAS_ELF_RANDOMIZE select OF diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 07f05a0f59a2..e0f29a594aa1 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -1740,6 +1740,7 @@ 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); +#if !defined(CONFIG_ARCH_WANT_VGA_ARB_FALLBACK) static void fixup_vga(struct pci_dev *pdev) { u16 cmd; @@ -1754,3 +1755,4 @@ static void fixup_vga(struct pci_dev *pdev) } DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA, 8, fixup_vga); +#endif diff --git a/drivers/gpu/vga/Kconfig b/drivers/gpu/vga/Kconfig index 29437eabe095..20f6c5a9a159 100644 --- a/drivers/gpu/vga/Kconfig +++ b/drivers/gpu/vga/Kconfig @@ -17,6 +17,14 @@ config VGA_ARB_MAX_GPUS Reserves space in the kernel to maintain resource locking for multiple GPUS. The overhead for each GPU is very small. +config ARCH_WANT_VGA_ARB_FALLBACK + bool + depends on !(X86 || IA64) + help + Some architectures don't have a concept of "legacy" PCI addresses + which the VGA arbiter relies on. Instead, they can fall back to + selecting the first device that decodes memory and I/O. + config VGA_SWITCHEROO bool "Laptop Hybrid Graphics - GPU switching support" depends on X86 diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c index 0f5b2dd24507..02424dc3a58d 100644 --- a/drivers/gpu/vga/vgaarb.c +++ b/drivers/gpu/vga/vgaarb.c @@ -1472,3 +1472,24 @@ static int __init vga_arb_device_init(void) return rc; } subsys_initcall(vga_arb_device_init); + +#if defined(CONFIG_ARCH_WANT_VGA_ARB_FALLBACK) +static void vga_arb_fallback_fixup(struct pci_dev *pdev) +{ + u16 cmd; + + if (vga_default_device()) + return; + + pci_read_config_word(pdev, PCI_COMMAND, &cmd); + if (cmd & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) { + vgaarb_info(&pdev->dev, "[fallback]" + " setting as default device\n"); + vga_set_default_device(pdev); + } + +} +DECLARE_PCI_FIXUP_CLASS_ENABLE(PCI_ANY_ID, PCI_ANY_ID, + PCI_CLASS_DISPLAY_VGA, 8, + vga_arb_fallback_fixup); +#endif