From patchwork Mon Oct 2 12:05:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 147261 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1386359vqb; Mon, 2 Oct 2023 05:22:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFSYVhXb07CllGk3l9be2e3lyKoLpP28Oh6kgLKbkiH0j69MKN2kt1FaFqwY5CNW0ut09MO X-Received: by 2002:a05:6a20:5511:b0:162:650c:76b8 with SMTP id ko17-20020a056a20551100b00162650c76b8mr2519194pzb.45.1696249320821; Mon, 02 Oct 2023 05:22:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696249320; cv=none; d=google.com; s=arc-20160816; b=XSrL2vXxcNNM+NKOYswBNLrJiOMYeqZnDF2SMCIdQER0pezr/5gsrFbB5NyhO33pY9 ZTarMUGb75BMdi5p55PcAx4pC6HqgMpkfJjaPLW5xkPyYwV5casPgAOLUD1oRxX54pJs 6oVUX8nv7wgsC5qze6x/DpxGs2XDmYYvLErGGt8TPWVThpo1w5YGwvg1RC6+u+yx5k8R LOaJzTnaFZprfnnx0dAsd+w9fGYHmIF0CITfXUOFtc+k2NUWloI2khDWjTpoPsGYu91m txhajc2nyDNN23TYyT2VTFQxLciDNjoH7U3NN4t0AqzqvLARnimUVhEtoaN8VNBT2csn tuXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=vQL1lx1pa85Kipxo/za/8EpefkZkfevfa21Egvbd9w8=; fh=0qCxjCvixYFjgYFDzgmT1u2HwZtsHsuy4jQzZ1FeYPg=; b=hnxcEovBuy+ZhcjWLZXeDjBxf2Z/HW/nVggc/0LxzNb0S2OBivMLV17uhN6JtjH2wd 8Lb87JRlOq+H4fORpP/4PW42yqyrrmugcJwg0NnibDXT0MKapvfd38h8nN2TDFnTOato TbUeIoZiAGYi0c9rV23E703w7QKRCPsFhuQabVIgj33lBcy3YXlyPPHM27ieO6PIFp4i ZZY/tijhkJETmhEhlR3WS+Bb3fWd0KEfyiHTD4Xe21yQJ4hCaPPCAgU+V9ak7IbdV5DO Y8qNV0OwYTf9MKc44+PEBuRnjdQKt/3LMPM0RAJzc0xmYfVH+cEa5czA0vS53AWWCnuW nXCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id bt25-20020a056a00439900b006901504b6a3si27314590pfb.153.2023.10.02.05.22.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 05:22:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 72CE7808986E; Mon, 2 Oct 2023 05:05:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236881AbjJBMFU (ORCPT + 18 others); Mon, 2 Oct 2023 08:05:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236710AbjJBMFT (ORCPT ); Mon, 2 Oct 2023 08:05:19 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 51C9EDA; Mon, 2 Oct 2023 05:05:13 -0700 (PDT) Received: from loongson.cn (unknown [10.20.42.43]) by gateway (Coremail) with SMTP id _____8DxFej4sRplzpMuAA--.30323S3; Mon, 02 Oct 2023 20:05:12 +0800 (CST) Received: from openarena.loongson.cn (unknown [10.20.42.43]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxK9z3sRplVSEXAA--.47905S4; Mon, 02 Oct 2023 20:05:12 +0800 (CST) From: Sui Jingfeng To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH pci-next v6 2/2] PCI/VGA: Remove vga_is_firmware_default() function Date: Mon, 2 Oct 2023 20:05:11 +0800 Message-Id: <20231002120511.594737-3-suijingfeng@loongson.cn> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231002120511.594737-1-suijingfeng@loongson.cn> References: <20231002120511.594737-1-suijingfeng@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8BxK9z3sRplVSEXAA--.47905S4 X-CM-SenderInfo: xvxlyxpqjiv03j6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBj93XoWxWr1UKry5tw43Cry3KryxtFc_yoW5GFW8pr 4ftFWxJrW8Wr45G34jyF48ZF15ZwnY9ayxKFWq93s3Ga45Arn7XrWxCrZYyryxJrZ2q3W3 ZF13Jr10qFyDJagCm3ZEXasCq-sJn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUkYb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVWxJVW8Jr1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6r4j6r4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI0UMc 02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAF wI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7V AKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCj r7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUXVWUAwCIc40Y0x0EwIxGrwCI42IY6x IIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAI w20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x 0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7IU8vApUUUUUU== X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 02 Oct 2023 05:05:42 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778646327880276289 X-GMAIL-MSGID: 1778646327880276289 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 02821c0f4cd0..a3f53982b131 100644 --- a/drivers/pci/vgaarb.c +++ b/drivers/pci/vgaarb.c @@ -50,7 +50,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); }; @@ -557,41 +556,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) @@ -623,14 +587,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; }