Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp37133873rwd; Tue, 11 Jul 2023 09:52:01 -0700 (PDT) X-Google-Smtp-Source: APBJJlGeQIayB08Ru7v8PC/SaISU4MUowfbe6RuHHJIE0VTsgpiwizHq33XPgoKe4O61BNyk3fHK X-Received: by 2002:a05:6358:918e:b0:134:5667:a16c with SMTP id j14-20020a056358918e00b001345667a16cmr15440344rwa.32.1689094321256; Tue, 11 Jul 2023 09:52:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689094321; cv=none; d=google.com; s=arc-20160816; b=hkkxrukIcSnj2eO/R8kdRUT5U6qh0GlK6o6qQkuFQS/xVM3QBgng+GuD8g2qb3vL6t MXG+GXL/VTVIIpr6zEwTgJNcYlFm3P+xogX92s/HqiIxGzaj++lKx9p9Frb6lMDLDvf3 lSysb/cmy5qVeMywobhpmPajGRWWd0toOjaNTMY3QcBen0qRGfyNsMdkh7ucI/7bn1lN tr1ko42bolTnNsLMDXdv4kfwrtyy60hVIYbV2z2BY8Wx7mGNZy3v50CT1wl2X76sM/wI LMALzJyg8e+wm8lcAo/AdhWWzEXQr6JAweNKPzLNME5XIHU/NiLmPyxQnnFn+T79SUN/ mjJw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 24-20020a631258000000b005579a12f405si1639370pgs.200.2023.07.11.09.51.40; Tue, 11 Jul 2023 09:52:01 -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 S233265AbjGKQnv (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 Content-Transfer-Encoding: 8bit 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 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; -- 2.25.1