From patchwork Tue Jul 11 16:43:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 118662 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp627860vqm; Tue, 11 Jul 2023 10:07:26 -0700 (PDT) X-Google-Smtp-Source: APBJJlFczFWFKdkvEVcNvZmYCB7TfiT13rBOp+dnhrfVWGwIxmEB79moA4ULIbbw+ICo7SVkb5oI X-Received: by 2002:a17:902:c212:b0:1b8:5bb4:8230 with SMTP id 18-20020a170902c21200b001b85bb48230mr12253972pll.50.1689095245695; Tue, 11 Jul 2023 10:07:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689095245; cv=none; d=google.com; s=arc-20160816; b=yWw7YlAJ+cbldEx0LswYRXe+obSXDf6Dy9ZQmiwVjnbnhKgRn55cNsttDAEdZnqxoy 2P9eeKhFsBRIGWnigQC7cArUOBVsT0O7hdA4kkO4g5fawrAD02acds0lJKmFJuBPptBV yFzUQztCqCZgdtVEgS5iBrAI/wbd4t4te1ZXoBY2XvPmyToTQJMjd8MjQ/4h1RYd3i5z BPQWTcTPMBdQa4GzD98empxh13WUwycQiv75n4YQoJtwWyc3j/YSmJRezfQgaSZCGMEJ itykVYB6U5uUTlU+rwvPGV4qAfvvmmlgDVJafRPDZ06LHPnLkMbK64+5auBwXK9XIbx8 CTjA== 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 :dkim-signature; bh=qerYEjJsYQa89wBNUybGoMjyzLMs27H7zUPn+Dcw/G0=; fh=ygkTXrv1QW2aJHL5AkX1nEAGd3njUqmECwhnenyY9Ag=; b=dBkgS8GAViilUnLc4UUYaCDQyY+TpLaeWu4f3GWY3ffhVNa18/HosiK5ZqACbWmQj+ I/6lKLpHBilhYdYA90ZPFD/yCEKd/WzS4wicxZNb+KF3OYqsEeRO40+BpqBiePvED0FI KfoVj24TQlIiLRoZFVluzpWS1DAOaQHoDxuTaNqT1wjGANn19vlhi4LKJ7MDKwtWZbQA /oqVwRVb/l6qEEo/3Nw29z4gLGDOJ9iozXkBY4jCvowfIBemKPMyaqy6pBD2tPnzpYnV 1aKOB82hIrdrGkT2Rcn5Ib1xTQ8xp3NaeQ7WDkdKIIrZoeE/cqjXrrlKZ9kDzpyOaS+N 80Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=cLX+YcBR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p1-20020a170902c70100b001b89bfd0c34si1778731plp.18.2023.07.11.10.07.10; Tue, 11 Jul 2023 10:07:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=cLX+YcBR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233025AbjGKQnv (ORCPT + 99 others); Tue, 11 Jul 2023 12:43:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233074AbjGKQnl (ORCPT ); Tue, 11 Jul 2023 12:43:41 -0400 Received: from out-41.mta1.migadu.com (out-41.mta1.migadu.com [IPv6:2001:41d0:203:375::29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B90510D5 for ; Tue, 11 Jul 2023 09:43:35 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1689093812; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qerYEjJsYQa89wBNUybGoMjyzLMs27H7zUPn+Dcw/G0=; b=cLX+YcBRiHpKikMeKMwG3mmNyBOCt0RfzhMRCQMFVMsE5PUvN0MMXatH5virGuBPf1bPzP TlrzyZr2xWSz6KpDcpt68BaSDQcRrPHi91BQyPlN45VH8b+lOC+BzDNGujXDPizGjou5oq GspWd6OWyS+7lx+YxAilLOZFQYnLH5E= From: Sui Jingfeng To: David Airlie Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, kvm@vger.kernel.org, linux-fbdev@vger.kernel.org, Sui Jingfeng Subject: [PATCH v3 3/9] PCI/VGA: Switch to aperture_contain_firmware_fb_nonreloc() Date: Wed, 12 Jul 2023 00:43:04 +0800 Message-Id: <20230711164310.791756-4-sui.jingfeng@linux.dev> In-Reply-To: <20230711164310.791756-1-sui.jingfeng@linux.dev> References: <20230711164310.791756-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771144736121779250 X-GMAIL-MSGID: 1771144736121779250 From: Sui Jingfeng The observation behind this is that we should avoid accessing the global screen_info directly. Call the aperture_contain_firmware_fb_nonreloc() function to implement the detection of whether an aperture contains the firmware FB. This patch helps to decouple the determination from the implementation. Or, in other words, we intend to make the determination opaque to the caller. The determination may choose to be arch-dependent or arch-independent. But vgaarb, as a consumer of the determination, shouldn't care how the does determination is implemented. Signed-off-by: Sui Jingfeng --- drivers/pci/vgaarb.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c index bf96e085751d..953daf731b2c 100644 --- a/drivers/pci/vgaarb.c +++ b/drivers/pci/vgaarb.c @@ -14,6 +14,7 @@ #define vgaarb_info(dev, fmt, arg...) dev_info(dev, "vgaarb: " fmt, ##arg) #define vgaarb_err(dev, fmt, arg...) dev_err(dev, "vgaarb: " fmt, ##arg) +#include #include #include #include @@ -26,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -558,20 +558,11 @@ void vga_put(struct pci_dev *pdev, unsigned int rsrc) } EXPORT_SYMBOL(vga_put); +/* Select the device owning the boot framebuffer if there is one */ 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) { @@ -581,10 +572,8 @@ static bool vga_is_firmware_default(struct pci_dev *pdev) if (!r->start || !r->end) continue; - if (base < r->start || limit >= r->end) - continue; - - return true; + if (aperture_contain_firmware_fb_nonreloc(r->start, r->end)) + return true; } #endif return false;