From patchwork Thu Aug 24 15:03:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 13364327 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id B74CAC6FA8F for ; Thu, 24 Aug 2023 15:03:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9CA7B10E57B; Thu, 24 Aug 2023 15:03:45 +0000 (UTC) Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by gabe.freedesktop.org (Postfix) with ESMTP id 2751210E57B for ; Thu, 24 Aug 2023 15:03:39 +0000 (UTC) Received: from loongson.cn (unknown [10.20.42.43]) by gateway (Coremail) with SMTP id _____8DxPOtGcedkm5AbAA--.51093S3; Thu, 24 Aug 2023 23:03:34 +0800 (CST) Received: from openarena.loongson.cn (unknown [10.20.42.43]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Cx_c5EcedkEYBiAA--.42989S4; Thu, 24 Aug 2023 23:03:33 +0800 (CST) From: Sui Jingfeng To: Bjorn Helgaas Subject: [PATCH v5 2/2] PCI/VGA: Remove vga_is_firmware_default() function Date: Thu, 24 Aug 2023 23:03:32 +0800 Message-Id: <20230824150332.6434-3-suijingfeng@loongson.cn> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230824150332.6434-1-suijingfeng@loongson.cn> References: <20230824150332.6434-1-suijingfeng@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8Cx_c5EcedkEYBiAA--.42989S4 X-CM-SenderInfo: xvxlyxpqjiv03j6o00pqjv00gofq/ X-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xhVjvjDU0xZFpf9x07Ul4E_UUUUU= 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: loongson-kernel@lists.loongnix.cn, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The new implemented pci_boot_vga_capturer() function is also effective on X86 and IA64, it can determine the default boot VGA device before VRAM BAR relocations done by the PCI core. Since the fixup handler has already identified the firmware framebuffer, there no need to look again later. So, switch to using the pci_boot_vga_capturer() on X86 and IA64 also, remove vga_is_firmware_default() and its relevant codes. Signed-off-by: Sui Jingfeng --- drivers/pci/vgaarb.c | 46 +++----------------------------------------- 1 file changed, 3 insertions(+), 43 deletions(-) diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c index bc5fcc855513..1dff74f778cd 100644 --- a/drivers/pci/vgaarb.c +++ b/drivers/pci/vgaarb.c @@ -51,7 +51,6 @@ struct vga_device { unsigned int io_norm_cnt; /* normal IO count */ unsigned int mem_norm_cnt; /* normal MEM count */ bool bridge_has_one_vga; - bool is_firmware_default; /* device selected by firmware */ unsigned int (*set_decode)(struct pci_dev *pdev, bool decode); }; @@ -544,41 +543,6 @@ void vga_put(struct pci_dev *pdev, unsigned int rsrc) } EXPORT_SYMBOL(vga_put); -static bool vga_is_firmware_default(struct pci_dev *pdev) -{ -#if defined(CONFIG_X86) || defined(CONFIG_IA64) - u64 base = screen_info.lfb_base; - u64 size = screen_info.lfb_size; - struct resource *r; - u64 limit; - - /* Select the device owning the boot framebuffer if there is one */ - - if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE) - base |= (u64)screen_info.ext_lfb_base << 32; - - limit = base + size; - - /* Does firmware framebuffer belong to us? */ - pci_dev_for_each_resource(pdev, r) { - if (resource_type(r) != IORESOURCE_MEM) - continue; - - if (!r->start || !r->end) - continue; - - if (base < r->start || limit >= r->end) - continue; - - return true; - } -#else - if (pdev_boot_vga && pdev_boot_vga == pdev) - return true; -#endif - return false; -} - static bool vga_arb_integrated_gpu(struct device *dev) { #if defined(CONFIG_ACPI) @@ -610,14 +574,10 @@ static bool vga_is_boot_device(struct vga_device *vgadev) */ /* - * We always prefer a firmware default device, so if we've already - * found one, there's no need to consider vgadev. + * We always prefer a firmware default device. */ - if (boot_vga && boot_vga->is_firmware_default) - return false; - - if (vga_is_firmware_default(pdev)) { - vgadev->is_firmware_default = true; + if (pdev == pdev_boot_vga) { + vgaarb_dbg(&pdev->dev, "Boot VGA selected by firmware\n"); return true; }