From patchwork Thu Jul 22 21:29:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 12394877 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23747C4320A for ; Thu, 22 Jul 2021 21:29:37 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C521660C41 for ; Thu, 22 Jul 2021 21:29:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C521660C41 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 370386EB7F; Thu, 22 Jul 2021 21:29:36 +0000 (UTC) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id 412A26E979 for ; Thu, 22 Jul 2021 21:29:32 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id C63A960C41; Thu, 22 Jul 2021 21:29:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626989372; bh=u/F5pMdUcli9ePovSRITwLtDnsHwqFH8b6TIeMrm+DY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=myRxgdTL7wZdEyMhn5h0fLlXngG8ZyzC8/AUy3jLdMj3rRI/ASDi0vWcXRybHwW98 mmJQ4oUM/IL8JVHrrLeF6sPmNnm+10YHZVVHwNUj+++nqgZurjjugwb/YyBdgHuw44 UD0DvgWKxyGQY384S3OoX8TPEK5j9/v7XjkenuzG9nGLajOyR5ehq3+WOBZfqMPCC3 fT4BVa8ln19+BwWMvu8VUvdO1TOD0K8TrkNJPp2Tp8xDegE4sdEf8s+0dsLGs3BcYV VUBvhS5g2MTsk0u8x+C61vHbZDRrdpwhI5oRuph8d3X6uTIFrQL+HFc69jvDoL5s9r W6i2YzvLpPUbg== From: Bjorn Helgaas To: Huacai Chen Subject: [PATCH v2 1/9] PCI/VGA: Move vgaarb to drivers/pci Date: Thu, 22 Jul 2021 16:29:12 -0500 Message-Id: <20210722212920.347118-2-helgaas@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210722212920.347118-1-helgaas@kernel.org> References: <20210722212920.347118-1-helgaas@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , dri-devel@lists.freedesktop.org, linux-pci@vger.kernel.org, Bjorn Helgaas , Xuefeng Li Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Bjorn Helgaas The VGA arbiter is really PCI-specific and doesn't depend on any GPU things. Move it to the PCI subsystem. Signed-off-by: Bjorn Helgaas --- drivers/gpu/vga/Kconfig | 19 ------------------- drivers/gpu/vga/Makefile | 1 - drivers/pci/Kconfig | 19 +++++++++++++++++++ drivers/pci/Makefile | 1 + drivers/{gpu/vga => pci}/vgaarb.c | 0 5 files changed, 20 insertions(+), 20 deletions(-) rename drivers/{gpu/vga => pci}/vgaarb.c (100%) diff --git a/drivers/gpu/vga/Kconfig b/drivers/gpu/vga/Kconfig index 1ad4c4ef0b5e..eb8b14ab22c3 100644 --- a/drivers/gpu/vga/Kconfig +++ b/drivers/gpu/vga/Kconfig @@ -1,23 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only -config VGA_ARB - bool "VGA Arbitration" if EXPERT - default y - depends on (PCI && !S390) - help - Some "legacy" VGA devices implemented on PCI typically have the same - hard-decoded addresses as they did on ISA. When multiple PCI devices - are accessed at same time they need some kind of coordination. Please - see Documentation/gpu/vgaarbiter.rst for more details. Select this to - enable VGA arbiter. - -config VGA_ARB_MAX_GPUS - int "Maximum number of GPUs" - default 16 - depends on VGA_ARB - help - Reserves space in the kernel to maintain resource locking for - multiple GPUS. The overhead for each GPU is very small. - config VGA_SWITCHEROO bool "Laptop Hybrid Graphics - GPU switching support" depends on X86 diff --git a/drivers/gpu/vga/Makefile b/drivers/gpu/vga/Makefile index e92064442d60..9800620deda3 100644 --- a/drivers/gpu/vga/Makefile +++ b/drivers/gpu/vga/Makefile @@ -1,3 +1,2 @@ # SPDX-License-Identifier: GPL-2.0-only -obj-$(CONFIG_VGA_ARB) += vgaarb.o obj-$(CONFIG_VGA_SWITCHEROO) += vga_switcheroo.o diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig index 0c473d75e625..7c9e56d7b857 100644 --- a/drivers/pci/Kconfig +++ b/drivers/pci/Kconfig @@ -252,6 +252,25 @@ config PCIE_BUS_PEER2PEER endchoice +config VGA_ARB + bool "VGA Arbitration" if EXPERT + default y + depends on (PCI && !S390) + help + Some "legacy" VGA devices implemented on PCI typically have the same + hard-decoded addresses as they did on ISA. When multiple PCI devices + are accessed at same time they need some kind of coordination. Please + see Documentation/gpu/vgaarbiter.rst for more details. Select this to + enable VGA arbiter. + +config VGA_ARB_MAX_GPUS + int "Maximum number of GPUs" + default 16 + depends on VGA_ARB + help + Reserves space in the kernel to maintain resource locking for + multiple GPUS. The overhead for each GPU is very small. + source "drivers/pci/hotplug/Kconfig" source "drivers/pci/controller/Kconfig" source "drivers/pci/endpoint/Kconfig" diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile index d62c4ac4ae1b..ebe720f69b15 100644 --- a/drivers/pci/Makefile +++ b/drivers/pci/Makefile @@ -29,6 +29,7 @@ obj-$(CONFIG_PCI_PF_STUB) += pci-pf-stub.o obj-$(CONFIG_PCI_ECAM) += ecam.o obj-$(CONFIG_PCI_P2PDMA) += p2pdma.o obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += xen-pcifront.o +obj-$(CONFIG_VGA_ARB) += vgaarb.o # Endpoint library must be initialized before its users obj-$(CONFIG_PCI_ENDPOINT) += endpoint/ diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/pci/vgaarb.c similarity index 100% rename from drivers/gpu/vga/vgaarb.c rename to drivers/pci/vgaarb.c From patchwork Thu Jul 22 21:29:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 12394879 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31BC3C432BE for ; Thu, 22 Jul 2021 21:29:39 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0109160EB6 for ; Thu, 22 Jul 2021 21:29:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0109160EB6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 289786E979; Thu, 22 Jul 2021 21:29:36 +0000 (UTC) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id E3FF56E979 for ; Thu, 22 Jul 2021 21:29:33 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 74D5460EB6; Thu, 22 Jul 2021 21:29:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626989373; bh=yT2wSQrJaNFX4K2jAtoq62rmvkHA7eOZeZyOwW2EwGs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GeFDo7pdnWk5KDQ1Bie7jWD+3Vf2FZb/YWDJQ7sP6z1gRDurYold0JVb2+/o5PCbE Ujc95zZ0pAivm/XIBKHPV+6Pj+ZOxE85IFMxIdT/LUja4ZP1Hp2Fs/Y4T7CrXm6E7n vOmYVDavw2t+U9R6Lq8TIsccPRSAohhVIwPOTuyNAZLInXwzVVZIewG55txL8Qj79L SApTDydyAzyZzyrAa7v70lMOzemeFkMiJ/rRwNLVl82sJVV53ffUU5UVXifgY82Lxi SCT076FgDixTzAA3ptZb4HdhgdxDrNl+UVpT3WLkjYPDB7k9dRVq308B1MVHubSuCm 6sZmEeW+CB2Cw== From: Bjorn Helgaas To: Huacai Chen Subject: [PATCH v2 2/9] PCI/VGA: Replace full MIT license text with SPDX identifier Date: Thu, 22 Jul 2021 16:29:13 -0500 Message-Id: <20210722212920.347118-3-helgaas@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210722212920.347118-1-helgaas@kernel.org> References: <20210722212920.347118-1-helgaas@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , dri-devel@lists.freedesktop.org, linux-pci@vger.kernel.org, Bjorn Helgaas , Xuefeng Li Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Bjorn Helgaas Per Documentation/process/license-rules.rst, the SPDX MIT identifier is equivalent to including the entire MIT license text from LICENSES/preferred/MIT. Replace the MIT license text with the equivalent SPDX identifier. Signed-off-by: Bjorn Helgaas --- drivers/pci/vgaarb.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c index 949fde433ea2..61b57abcb014 100644 --- a/drivers/pci/vgaarb.c +++ b/drivers/pci/vgaarb.c @@ -1,32 +1,11 @@ +// SPDX-License-Identifier: MIT /* * vgaarb.c: Implements the VGA arbitration. For details refer to * Documentation/gpu/vgaarbiter.rst * - * * (C) Copyright 2005 Benjamin Herrenschmidt * (C) Copyright 2007 Paulo R. Zanoni * (C) Copyright 2007, 2009 Tiago Vignatti - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS - * IN THE SOFTWARE. - * */ #define pr_fmt(fmt) "vgaarb: " fmt From patchwork Thu Jul 22 21:29:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 12394881 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 412F5C4320A for ; Thu, 22 Jul 2021 21:29:42 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 118D160EB5 for ; Thu, 22 Jul 2021 21:29:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 118D160EB5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 290356ECE5; Thu, 22 Jul 2021 21:29:41 +0000 (UTC) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id 80BFD6E979 for ; Thu, 22 Jul 2021 21:29:35 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 1343660EB4; Thu, 22 Jul 2021 21:29:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626989375; bh=+LKRbiNvmHkl8/IrviCxFfiMWC8MpEArh68DHC/vlAo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dtgsCzGCBCaLunfh+FGJr+czlx/ToitKRHx9PTOSEdRYNpY5kSIN+Mql3RM9noXbv aNLootyCBPaLGRBx8E2Riio9M3AmkzDRZdnb95Lj7dK+4a22DX01boSk4t5E+yozQN 0SG3mtsJOdx+/WTc4/fNyRc1sF5+JL3cBdOU3+my+o3jd0HlRHkiPdMlWiH6YFhn/L yzellZ1K+qtdc5sITJ4iRjFcPATcJdnA2Bg073VT4zdAaaMflqtAeYjaLMu0JDzIMM iCgF6X3hF9S8O9yIp363jrIZ+LfBddjyRj+/903bHe7pr6dSA5zZvciOjbz1FJ5Zn8 I/dFyF2DX96bQ== From: Bjorn Helgaas To: Huacai Chen Subject: [PATCH v2 3/9] PCI/VGA: Use unsigned format string to print lock counts Date: Thu, 22 Jul 2021 16:29:14 -0500 Message-Id: <20210722212920.347118-4-helgaas@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210722212920.347118-1-helgaas@kernel.org> References: <20210722212920.347118-1-helgaas@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , dri-devel@lists.freedesktop.org, linux-pci@vger.kernel.org, Bjorn Helgaas , Xuefeng Li Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Bjorn Helgaas In struct vga_device, io_lock_cnt and mem_lock_cnt are unsigned, but we previously printed them with "%d", the signed decimal format. Print them with the unsigned format "%u" instead. Signed-off-by: Bjorn Helgaas --- drivers/pci/vgaarb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c index 61b57abcb014..e4153ab70481 100644 --- a/drivers/pci/vgaarb.c +++ b/drivers/pci/vgaarb.c @@ -1022,7 +1022,7 @@ static ssize_t vga_arb_read(struct file *file, char __user *buf, /* Fill the buffer with infos */ len = snprintf(lbuf, 1024, - "count:%d,PCI:%s,decodes=%s,owns=%s,locks=%s(%d:%d)\n", + "count:%d,PCI:%s,decodes=%s,owns=%s,locks=%s(%u:%u)\n", vga_decode_count, pci_name(pdev), vga_iostate_to_str(vgadev->decodes), vga_iostate_to_str(vgadev->owns), From patchwork Thu Jul 22 21:29:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 12394885 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0FE42C4320A for ; Thu, 22 Jul 2021 21:29:48 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D175C60EB4 for ; Thu, 22 Jul 2021 21:29:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D175C60EB4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E77236F384; Thu, 22 Jul 2021 21:29:46 +0000 (UTC) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3231B6F384 for ; Thu, 22 Jul 2021 21:29:37 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id A9B2760E8F; Thu, 22 Jul 2021 21:29:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626989377; bh=4jqIwftB8QisJXWGSPJ0If22UZlDrJUNrwHxBUaRVCM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hC4lDdYw+PN5SpuNdN/en3tTRWApgc38vpxETRbo6AChyYrzBTRmJ7r4fxXh0pxnv qZHE32rQVt55ik/dHPyC6qInDKzH7Dk4Id2FP5gD4wEmdoI0vQO378VuNv3qxqGf8D lbuWqxjn87W++iiM+WoUxwhTAaVRUl08/4vOspisITLL96j9UvDJwWWZh0doTFsrfZ FICWoXI4M1HcP9iZC5OBWItLlJManEgZt8jAg0GdRNUHuaJx2Cj9qu2xosHCYrDtD3 QpyaSg4nV+5K3yFT7Zw7nepcW21cAuFhjiNOc82+Ek449iiVQyiF33Awx3tqzHx+ZF ytyRA1nndJ1tw== From: Bjorn Helgaas To: Huacai Chen Subject: [PATCH v2 4/9] PCI/VGA: Remove empty vga_arb_device_card_gone() Date: Thu, 22 Jul 2021 16:29:15 -0500 Message-Id: <20210722212920.347118-5-helgaas@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210722212920.347118-1-helgaas@kernel.org> References: <20210722212920.347118-1-helgaas@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , dri-devel@lists.freedesktop.org, linux-pci@vger.kernel.org, Bjorn Helgaas , Xuefeng Li Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Bjorn Helgaas vga_arb_device_card_gone() has always been empty. Remove it. Signed-off-by: Bjorn Helgaas --- drivers/pci/vgaarb.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c index e4153ab70481..c984c76b3fd7 100644 --- a/drivers/pci/vgaarb.c +++ b/drivers/pci/vgaarb.c @@ -104,8 +104,6 @@ static int vga_str_to_iostate(char *buf, int str_size, int *io_state) /* this is only used a cookie - it should not be dereferenced */ static struct pci_dev *vga_default; -static void vga_arb_device_card_gone(struct pci_dev *pdev); - /* Find somebody in our list */ static struct vga_device *vgadev_find(struct pci_dev *pdev) { @@ -741,10 +739,6 @@ static bool vga_arbiter_del_pci_device(struct pci_dev *pdev) /* Remove entry from list */ list_del(&vgadev->list); vga_count--; - /* Notify userland driver that the device is gone so it discards - * it's copies of the pci_dev pointer - */ - vga_arb_device_card_gone(pdev); /* Wake up all possible waiters */ wake_up_all(&vga_wait_queue); @@ -994,9 +988,7 @@ static ssize_t vga_arb_read(struct file *file, char __user *buf, if (lbuf == NULL) return -ENOMEM; - /* Shields against vga_arb_device_card_gone (pci_dev going - * away), and allows access to vga list - */ + /* Protects vga_list */ spin_lock_irqsave(&vga_lock, flags); /* If we are targeting the default, use it */ @@ -1013,8 +1005,6 @@ static ssize_t vga_arb_read(struct file *file, char __user *buf, /* Wow, it's not in the list, that shouldn't happen, * let's fix us up and return invalid card */ - if (pdev == priv->target) - vga_arb_device_card_gone(pdev); spin_unlock_irqrestore(&vga_lock, flags); len = sprintf(lbuf, "invalid"); goto done; @@ -1358,10 +1348,6 @@ static int vga_arb_release(struct inode *inode, struct file *file) return 0; } -static void vga_arb_device_card_gone(struct pci_dev *pdev) -{ -} - /* * callback any registered clients to let them know we have a * change in VGA cards From patchwork Thu Jul 22 21:29:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 12394883 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84C0DC432BE for ; Thu, 22 Jul 2021 21:29:43 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 56BE860E8F for ; Thu, 22 Jul 2021 21:29:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 56BE860E8F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6AA506EEAA; Thu, 22 Jul 2021 21:29:41 +0000 (UTC) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id D17206ECE5 for ; Thu, 22 Jul 2021 21:29:38 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 5F1B060C41; Thu, 22 Jul 2021 21:29:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626989378; bh=jzI4K0thGJA1hYgjMq9AeGLmE9HeNM6DZi9oIzIppys=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m/Cz/zr3klCDL8wPUjP5VrC4X/FslhOLTp7JbvxX+f0NBrSFiTiIEKOFbecMBGbtE ZOKxnjYy+XbsYdkEWspu64XXYlxq205X4H81mQnWKAl7CAjHeMeN85/4YMvJQOt4Hp +5Fb2gljR+gsviWyxROLE0evWIr0fnKBzp529KiypXrwW70THxu3BLfXQxNcPOMf9N i5mX7KWhsPIm7m0ABC1yiU+HFzgStMdWbueDYlPt/Ge0OSbn8C5a5azqQBCFAignl5 pUrPAavTxITT0v/jlSqxt5oowCIcGZ+KN2U51oWt02sft/dG3FNWUrPmgLJil3Krd6 +MfANMJEmrHhw== From: Bjorn Helgaas To: Huacai Chen Subject: [PATCH v2 5/9] PCI/VGA: Move vga_arb_integrated_gpu() earlier in file Date: Thu, 22 Jul 2021 16:29:16 -0500 Message-Id: <20210722212920.347118-6-helgaas@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210722212920.347118-1-helgaas@kernel.org> References: <20210722212920.347118-1-helgaas@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , dri-devel@lists.freedesktop.org, linux-pci@vger.kernel.org, Bjorn Helgaas , Xuefeng Li Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Huacai Chen Move vga_arb_integrated_gpu() earlier in file to prepare for future patch. No functional change intended. [bhelgaas: split to separate patch] Link: https://lore.kernel.org/r/20210705100503.1120643-1-chenhuacai@loongson.cn Signed-off-by: Huacai Chen Signed-off-by: Bjorn Helgaas --- drivers/pci/vgaarb.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c index c984c76b3fd7..1f8fb37be5fa 100644 --- a/drivers/pci/vgaarb.c +++ b/drivers/pci/vgaarb.c @@ -563,6 +563,20 @@ void vga_put(struct pci_dev *pdev, unsigned int rsrc) } EXPORT_SYMBOL(vga_put); +#if defined(CONFIG_ACPI) +static bool vga_arb_integrated_gpu(struct device *dev) +{ + struct acpi_device *adev = ACPI_COMPANION(dev); + + return adev && !strcmp(acpi_device_hid(adev), ACPI_VIDEO_HID); +} +#else +static bool vga_arb_integrated_gpu(struct device *dev) +{ + return false; +} +#endif + /* * Rules for using a bridge to control a VGA descendant decoding: if a bridge * has only one VGA descendant then it can be used to control the VGA routing @@ -1416,20 +1430,6 @@ static struct miscdevice vga_arb_device = { MISC_DYNAMIC_MINOR, "vga_arbiter", &vga_arb_device_fops }; -#if defined(CONFIG_ACPI) -static bool vga_arb_integrated_gpu(struct device *dev) -{ - struct acpi_device *adev = ACPI_COMPANION(dev); - - return adev && !strcmp(acpi_device_hid(adev), ACPI_VIDEO_HID); -} -#else -static bool vga_arb_integrated_gpu(struct device *dev) -{ - return false; -} -#endif - static void __init vga_arb_select_default_device(void) { struct pci_dev *pdev, *found = NULL; From patchwork Thu Jul 22 21:29:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 12394893 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F831C4338F for ; Thu, 22 Jul 2021 21:29:57 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 49BB760EB4 for ; Thu, 22 Jul 2021 21:29:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 49BB760EB4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B426E6F417; Thu, 22 Jul 2021 21:29:56 +0000 (UTC) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id E760D6ECE5 for ; Thu, 22 Jul 2021 21:29:40 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 1AD7E60E8F; Thu, 22 Jul 2021 21:29:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626989380; bh=Lz23JGy+v1mDBP4c8nviBW9vDZbHxkZ37b5vU6RZt3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gDmTIGte49hhlTJe+xP1rCOKEdVr8p17RCKsZEd79fevg3LUokOIas1nZFL+MUjT+ AcdZpMrvj50KLJ294lgztA7l2b5ifpOcVFZ6pzQiBorvYwrjTQvSFwJKmUnjNS9fQ1 vO6FwZB+w9a5hN5O8CdlddiwoDNadISf/LKtbQpJus4s4qgiKCKdUa4lXsAPtz46ha CI3VnKebZ69LcvjAhzlwfRfz7mqeLinWEqarqf1zF2A7V0wsVXkje1KYGsP85xYkHi cfxZOCPpYOZ7+ZeMZXE5kfSJ9OaREITYkXnoWo6IEg0nTe2UAwk45NMg4RWdtPcvQb MIgJP3eAL3kzQ== From: Bjorn Helgaas To: Huacai Chen Subject: [PATCH v2 6/9] PCI/VGA: Prefer vga_default_device() Date: Thu, 22 Jul 2021 16:29:17 -0500 Message-Id: <20210722212920.347118-7-helgaas@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210722212920.347118-1-helgaas@kernel.org> References: <20210722212920.347118-1-helgaas@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , dri-devel@lists.freedesktop.org, linux-pci@vger.kernel.org, Bjorn Helgaas , Xuefeng Li Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Huacai Chen Use the vga_default_device() interface consistently instead of directly testing vga_default. No functional change intended. [bhelgaas: split to separate patch and extended] Link: https://lore.kernel.org/r/20210705100503.1120643-1-chenhuacai@loongson.cn Signed-off-by: Huacai Chen Signed-off-by: Bjorn Helgaas --- drivers/pci/vgaarb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c index 1f8fb37be5fa..a6a5864ff538 100644 --- a/drivers/pci/vgaarb.c +++ b/drivers/pci/vgaarb.c @@ -173,7 +173,7 @@ int vga_remove_vgacon(struct pci_dev *pdev) { int ret = 0; - if (pdev != vga_default) + if (pdev != vga_default_device()) return 0; vgaarb_info(&pdev->dev, "deactivate vga console\n"); @@ -707,7 +707,7 @@ static bool vga_arbiter_add_pci_device(struct pci_dev *pdev) /* Deal with VGA default device. Use first enabled one * by default if arch doesn't have it's own hook */ - if (vga_default == NULL && + if (!vga_default_device() && ((vgadev->owns & VGA_RSRC_LEGACY_MASK) == VGA_RSRC_LEGACY_MASK)) { vgaarb_info(&pdev->dev, "setting as boot VGA device\n"); vga_set_default_device(pdev); @@ -744,7 +744,7 @@ static bool vga_arbiter_del_pci_device(struct pci_dev *pdev) goto bail; } - if (vga_default == pdev) + if (vga_default_device() == pdev) vga_set_default_device(NULL); if (vgadev->decodes & (VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM)) From patchwork Thu Jul 22 21:29:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 12394887 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B3C2C4338F for ; Thu, 22 Jul 2021 21:29:48 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4902E60EB4 for ; Thu, 22 Jul 2021 21:29:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4902E60EB4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3951D6F388; Thu, 22 Jul 2021 21:29:47 +0000 (UTC) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6D4A96F3DC for ; Thu, 22 Jul 2021 21:29:42 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id D76A360EC0; Thu, 22 Jul 2021 21:29:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626989382; bh=rDBL/DrcxrM8sheIRMWXyOuRj4OssHldiIThz+01+pY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DmfvhOpcAxbW/UiRPvCqM03W5cJOJiAlpzo22zaQ90A+ExUd0uxu1P0okeL5YpCAM Mi6WIFUINXsMzeNbvK5hTyz6eIKH6zjbeVNKQ1r9x07laE5Sqwq0L8fYtbvOap06+N Oq8TYHIAeZjNsRX0DrOaosP4RgDP/Hz+dQFaQ+zbInHUsLFxUhPISOIt9bImV+zqGH CUZD16SDwmnxVX2StqT9LrQBrMzUgUv2g8yvEeSce8hnm2Np6IC/+VMqkgvGmb1o/W LvnvdAc9Tv++phZtC1g9BSWYfeWWYJmGFG4XhGjGsAp4GJr4pC35cBKB5x9t/WtofI pa0Ji3q9VD6zQ== From: Bjorn Helgaas To: Huacai Chen Subject: [PATCH v2 7/9] PCI/VGA: Split out vga_arb_update_default_device() Date: Thu, 22 Jul 2021 16:29:18 -0500 Message-Id: <20210722212920.347118-8-helgaas@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210722212920.347118-1-helgaas@kernel.org> References: <20210722212920.347118-1-helgaas@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , dri-devel@lists.freedesktop.org, linux-pci@vger.kernel.org, Bjorn Helgaas , Xuefeng Li Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Huacai Chen If there's no default VGA device, and we find a VGA device that owns the legacy VGA resources, we make that device the default. Split this logic out from vga_arbiter_add_pci_device() into a new function, vga_arb_update_default_device(). [bhelgaas: split another piece to separate patch] Link: https://lore.kernel.org/r/20210705100503.1120643-1-chenhuacai@loongson.cn Signed-off-by: Huacai Chen Signed-off-by: Bjorn Helgaas --- drivers/pci/vgaarb.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c index a6a5864ff538..4cecb599f5ed 100644 --- a/drivers/pci/vgaarb.c +++ b/drivers/pci/vgaarb.c @@ -577,6 +577,21 @@ static bool vga_arb_integrated_gpu(struct device *dev) } #endif +static void vga_arb_update_default_device(struct vga_device *vgadev) +{ + struct pci_dev *pdev = vgadev->pdev; + + /* + * If we don't have a default VGA device yet, and this device owns + * the legacy VGA resources, make it the default. + */ + if (!vga_default_device() && + ((vgadev->owns & VGA_RSRC_LEGACY_MASK) == VGA_RSRC_LEGACY_MASK)) { + vgaarb_info(&pdev->dev, "setting as boot VGA device\n"); + vga_set_default_device(pdev); + } +} + /* * Rules for using a bridge to control a VGA descendant decoding: if a bridge * has only one VGA descendant then it can be used to control the VGA routing @@ -704,15 +719,7 @@ static bool vga_arbiter_add_pci_device(struct pci_dev *pdev) bus = bus->parent; } - /* Deal with VGA default device. Use first enabled one - * by default if arch doesn't have it's own hook - */ - if (!vga_default_device() && - ((vgadev->owns & VGA_RSRC_LEGACY_MASK) == VGA_RSRC_LEGACY_MASK)) { - vgaarb_info(&pdev->dev, "setting as boot VGA device\n"); - vga_set_default_device(pdev); - } - + vga_arb_update_default_device(vgadev); vga_arbiter_check_bridge_sharing(vgadev); /* Add to the list */ From patchwork Thu Jul 22 21:29:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 12394891 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CCC6C4338F for ; Thu, 22 Jul 2021 21:29:55 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D956360EB6 for ; Thu, 22 Jul 2021 21:29:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D956360EB6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 571E16F404; Thu, 22 Jul 2021 21:29:54 +0000 (UTC) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id 91B296F384 for ; Thu, 22 Jul 2021 21:29:44 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 2208F60EB4; Thu, 22 Jul 2021 21:29:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626989384; bh=rWA9U1DI5ZDX+nTcAKFLpU/M8BW7KefHvlzjEfOZ7/E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S1cg5xOweBpPMYAg1YSSjPtL04jR9dkL0cezMFBmBkIWHAo5EFQxpZwY8qDsz9cZG q92L71BIPsEIH+hcGFvoAd9BBxii1w3WHy4SdzCm6q4gG0Av/jaw/z3h0n+e2qF3Qw n9SpL7o6iz9pf5ch+ZEDcX4hd1o9Hct/DN2mbeCzhrjKkgpkrc70xX1a1y+6aenNjf tCxcZ5syzqnmOFR3btXb59G/GP1WiyIxlSBLF7aI8jRvcpNuqTq8vjsZ+eU5r5k9q7 gqVNe6ovdHyG6npARaW8lyrVsph3WWkGG6pjXA97qeVXCTDATy9j2A+Yj8zO+I1eKa FY/Ktn2tLiI8A== From: Bjorn Helgaas To: Huacai Chen Subject: [PATCH v2 8/9] PCI/VGA: Log bridge control messages when adding devices Date: Thu, 22 Jul 2021 16:29:19 -0500 Message-Id: <20210722212920.347118-9-helgaas@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210722212920.347118-1-helgaas@kernel.org> References: <20210722212920.347118-1-helgaas@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , dri-devel@lists.freedesktop.org, linux-pci@vger.kernel.org, Bjorn Helgaas , Xuefeng Li Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Huacai Chen Previously vga_arb_device_init() iterated through all VGA devices and indicated whether legacy VGA routing to each could be controlled by an upstream bridge. But we determine that information in vga_arbiter_add_pci_device(), which we call for every device, so we can log it there without iterating through the VGA devices again. Note that we call vga_arbiter_check_bridge_sharing() before adding the device to vga_list, so we have to handle the very first device separately. [bhelgaas: commit log, split another piece to separate patch, fix list_empty() issue] Link: https://lore.kernel.org/r/20210705100503.1120643-1-chenhuacai@loongson.cn Signed-off-by: Huacai Chen Signed-off-by: Bjorn Helgaas --- drivers/pci/vgaarb.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c index 4cecb599f5ed..dd07b1c3205f 100644 --- a/drivers/pci/vgaarb.c +++ b/drivers/pci/vgaarb.c @@ -609,8 +609,10 @@ static void vga_arbiter_check_bridge_sharing(struct vga_device *vgadev) vgadev->bridge_has_one_vga = true; - if (list_empty(&vga_list)) + if (list_empty(&vga_list)) { + vgaarb_info(&vgadev->pdev->dev, "bridge control possible\n"); return; + } /* okay iterate the new devices bridge hierarachy */ new_bus = vgadev->pdev->bus; @@ -649,6 +651,11 @@ static void vga_arbiter_check_bridge_sharing(struct vga_device *vgadev) } new_bus = new_bus->parent; } + + if (vgadev->bridge_has_one_vga) + vgaarb_info(&vgadev->pdev->dev, "bridge control possible\n"); + else + vgaarb_info(&vgadev->pdev->dev, "no bridge control possible\n"); } /* @@ -1527,7 +1534,6 @@ static int __init vga_arb_device_init(void) { int rc; struct pci_dev *pdev; - struct vga_device *vgadev; rc = misc_register(&vga_arb_device); if (rc < 0) @@ -1543,15 +1549,6 @@ static int __init vga_arb_device_init(void) PCI_ANY_ID, pdev)) != NULL) vga_arbiter_add_pci_device(pdev); - list_for_each_entry(vgadev, &vga_list, list) { - struct device *dev = &vgadev->pdev->dev; - - if (vgadev->bridge_has_one_vga) - vgaarb_info(dev, "bridge control possible\n"); - else - vgaarb_info(dev, "no bridge control possible\n"); - } - vga_arb_select_default_device(); pr_info("loaded\n"); From patchwork Thu Jul 22 21:29:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 12394889 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3150EC432BE for ; Thu, 22 Jul 2021 21:29:50 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0285760C41 for ; Thu, 22 Jul 2021 21:29:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0285760C41 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A4C296F3DC; Thu, 22 Jul 2021 21:29:47 +0000 (UTC) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id 455276F384 for ; Thu, 22 Jul 2021 21:29:46 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id CC55660E8F; Thu, 22 Jul 2021 21:29:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626989386; bh=DBFGdtf/Y0RQscrMiQqVmzQYk7VU6kgtFbhfE0dmbe0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oB5ivAIL6i7OG7Vjlo/Pwa/F7XRs3t4iKASXXzOoKETkvWhwRASCts65oNuUjVZYM ASMYjNqoWHHhwvxuDjyXGG/ST41bIYrYzU0FFq82CZ+Fsk7rtl41CB9sHqafZu6R1h 2hnVZP5S2DNvVpUL2OCHrrJvA0CcdNCVX1qD/WqtyWfNwv4Fz+q8BaK+lLxvIYCTgX UAjTPnwyl+QYBvvDs1QcXrAU5j9Xx0gGXskIqakQm+vLJidqzxIXXLEi22MqKZVwwn HC853tL71UxE3Yc20Gd5Me04yvTO90k2mbP8IgJELqxdtsFLGcrES3NeJvR8NABzUH aonnQ/Hccg/ZA== From: Bjorn Helgaas To: Huacai Chen Subject: [PATCH v2 9/9] PCI/VGA: Rework default VGA device selection Date: Thu, 22 Jul 2021 16:29:20 -0500 Message-Id: <20210722212920.347118-10-helgaas@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210722212920.347118-1-helgaas@kernel.org> References: <20210722212920.347118-1-helgaas@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , dri-devel@lists.freedesktop.org, linux-pci@vger.kernel.org, Xuefeng Li Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Huacai Chen Needs a better subject and a commit log. Link: https://lore.kernel.org/r/20210705100503.1120643-1-chenhuacai@loongson.cn --- drivers/pci/vgaarb.c | 158 ++++++++++++++++++------------------------- 1 file changed, 66 insertions(+), 92 deletions(-) diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c index dd07b1c3205f..0b059a2fc749 100644 --- a/drivers/pci/vgaarb.c +++ b/drivers/pci/vgaarb.c @@ -580,16 +580,79 @@ static bool vga_arb_integrated_gpu(struct device *dev) static void vga_arb_update_default_device(struct vga_device *vgadev) { struct pci_dev *pdev = vgadev->pdev; + struct device *dev = &pdev->dev; + struct vga_device *vgadev_default; +#if defined(CONFIG_X86) || defined(CONFIG_IA64) + int i; + unsigned long flags; + u64 base = screen_info.lfb_base; + u64 size = screen_info.lfb_size; + u64 limit; + resource_size_t start, end; +#endif /* * If we don't have a default VGA device yet, and this device owns * the legacy VGA resources, make it the default. */ - if (!vga_default_device() && - ((vgadev->owns & VGA_RSRC_LEGACY_MASK) == VGA_RSRC_LEGACY_MASK)) { - vgaarb_info(&pdev->dev, "setting as boot VGA device\n"); + if (!vga_default_device()) { + if ((vgadev->owns & VGA_RSRC_LEGACY_MASK) == VGA_RSRC_LEGACY_MASK) + vgaarb_info(dev, "setting as boot VGA device\n"); + else + vgaarb_info(dev, "setting as boot device (VGA legacy resources not available)\n"); vga_set_default_device(pdev); } + + vgadev_default = vgadev_find(vga_default); + + /* Overridden by a better device */ + if (vgadev_default && ((vgadev_default->owns & VGA_RSRC_LEGACY_MASK) == 0) + && ((vgadev->owns & VGA_RSRC_LEGACY_MASK) == VGA_RSRC_LEGACY_MASK)) { + vgaarb_info(dev, "overriding boot VGA device\n"); + vga_set_default_device(pdev); + } + + if (vga_arb_integrated_gpu(dev)) { + vgaarb_info(dev, "overriding boot VGA device\n"); + vga_set_default_device(pdev); + } + +#if defined(CONFIG_X86) || defined(CONFIG_IA64) + if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE) + base |= (u64)screen_info.ext_lfb_base << 32; + + limit = base + size; + + /* + * Override vga_arbiter_add_pci_device()'s I/O based detection + * as it may take the wrong device (e.g. on Apple system under + * EFI). + * + * Select the device owning the boot framebuffer if there is + * one. + */ + + /* Does firmware framebuffer belong to us? */ + for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { + flags = pci_resource_flags(vgadev->pdev, i); + + if ((flags & IORESOURCE_MEM) == 0) + continue; + + start = pci_resource_start(vgadev->pdev, i); + end = pci_resource_end(vgadev->pdev, i); + + if (!start || !end) + continue; + + if (base < start || limit >= end) + continue; + + if (vgadev->pdev != vga_default_device()) + vgaarb_info(dev, "overriding boot device\n"); + vga_set_default_device(vgadev->pdev); + } +#endif } /* @@ -1444,92 +1507,6 @@ static struct miscdevice vga_arb_device = { MISC_DYNAMIC_MINOR, "vga_arbiter", &vga_arb_device_fops }; -static void __init vga_arb_select_default_device(void) -{ - struct pci_dev *pdev, *found = NULL; - struct vga_device *vgadev; - -#if defined(CONFIG_X86) || defined(CONFIG_IA64) - u64 base = screen_info.lfb_base; - u64 size = screen_info.lfb_size; - u64 limit; - resource_size_t start, end; - unsigned long flags; - int i; - - if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE) - base |= (u64)screen_info.ext_lfb_base << 32; - - limit = base + size; - - list_for_each_entry(vgadev, &vga_list, list) { - struct device *dev = &vgadev->pdev->dev; - /* - * Override vga_arbiter_add_pci_device()'s I/O based detection - * as it may take the wrong device (e.g. on Apple system under - * EFI). - * - * Select the device owning the boot framebuffer if there is - * one. - */ - - /* Does firmware framebuffer belong to us? */ - for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { - flags = pci_resource_flags(vgadev->pdev, i); - - if ((flags & IORESOURCE_MEM) == 0) - continue; - - start = pci_resource_start(vgadev->pdev, i); - end = pci_resource_end(vgadev->pdev, i); - - if (!start || !end) - continue; - - if (base < start || limit >= end) - continue; - - if (!vga_default_device()) - vgaarb_info(dev, "setting as boot device\n"); - else if (vgadev->pdev != vga_default_device()) - vgaarb_info(dev, "overriding boot device\n"); - vga_set_default_device(vgadev->pdev); - } - } -#endif - - if (!vga_default_device()) { - list_for_each_entry_reverse(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)) { - found = pdev; - if (vga_arb_integrated_gpu(dev)) - break; - } - } - } - - if (found) { - vgaarb_info(&found->dev, "setting as boot device (VGA legacy resources not available)\n"); - vga_set_default_device(found); - return; - } - - if (!vga_default_device()) { - vgadev = list_first_entry_or_null(&vga_list, - struct vga_device, list); - if (vgadev) { - struct device *dev = &vgadev->pdev->dev; - vgaarb_info(dev, "setting as boot device (VGA legacy resources not available)\n"); - vga_set_default_device(vgadev->pdev); - } - } -} - static int __init vga_arb_device_init(void) { int rc; @@ -1549,9 +1526,6 @@ static int __init vga_arb_device_init(void) PCI_ANY_ID, pdev)) != NULL) vga_arbiter_add_pci_device(pdev); - vga_arb_select_default_device(); - - pr_info("loaded\n"); return rc; } subsys_initcall(vga_arb_device_init);