Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp37125315rwd; Tue, 11 Jul 2023 09:44:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlFVZbm2o5O9KUW33emoCjcxcMIWhBrNTYvGY4XSo58U0z9+WrDByZUx/J5ZmDXNAnFn/NjA X-Received: by 2002:a05:6a20:258a:b0:12d:9f20:fcaa with SMTP id k10-20020a056a20258a00b0012d9f20fcaamr15710695pzd.57.1689093884287; Tue, 11 Jul 2023 09:44:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689093884; cv=none; d=google.com; s=arc-20160816; b=l9YF2TOW1CBQsrpav+6DieonM7f1OEZzyc8kw5GABSuwHajFvIPbveYAo6faER4eN6 dW7STA6VyoeVrGFXCiHsC9oGWgTTxLHmMCZPHtlPYHrKCqcPqCaHWWJFjij3FeAV1eaV PVa22sWlmULbaZShbGdmE/sYMUVIuapHj/97co7N9ftDtds+7hiNl6buWQJnVOhLeIk7 rtchAN3YrqP01SVSoIW8ECNmGyl32R9ejHJV7ylpoavI7yY0eg3Ms+huPxlKgPDwvAz+ vsLdht4ewtdGkLelnwhVRaOw9uv04x3CxzCHa26mQfoUEZ/KiV2kh9OhZ3g66LXk/OS9 H5Iw== 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=GBy5pJ1hlnJ55l3+0FoW8CoU4fx5kPQd0O17NeAPNiY=; fh=XlWA3Y+MFaMsv8l7a0bPbKiHO/DSgPSssRLTDW9iA0I=; b=Tp6oOw0XJB7mQswRQgi7Ql5en31wF0fG2KMf6uy10niozVd/bZGTnNdKxApjcIXKWi PoDRBfly3hB9pQvDDC5UltjhKgU/KYI6ZfEyW3YoQ2/QNgSEAtaHmVww7s1MhiXs4Klw mdDW6EHLERe0BrJzxzbhHLwFka/KGSUWC+gh4Z8U8hcWi8yvWL7ACXio2o9CRvUFOuSd 2WJ4Tz/0avBtESGNjCRjqPy0IKIpbpa1dYlwfbrFeif4M/8smpvwBmBaCG8fs++Vol71 tbzQq6V2A9gbKh6qTNrzQehLaoPBdwGgZK8H7Y1Dfq67oOWz4Qy1SyiPOln9cQXbFZsv Ty9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=KYZlRghv; 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 ct8-20020a056a000f8800b00682399fa4f9si1747262pfb.300.2023.07.11.09.44.31; Tue, 11 Jul 2023 09:44:44 -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=KYZlRghv; 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 S232486AbjGKQch (ORCPT + 99 others); Tue, 11 Jul 2023 12:32:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232311AbjGKQca (ORCPT ); Tue, 11 Jul 2023 12:32:30 -0400 Received: from out-41.mta0.migadu.com (out-41.mta0.migadu.com [91.218.175.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65B161728 for ; Tue, 11 Jul 2023 09:32:25 -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=1689093143; 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=GBy5pJ1hlnJ55l3+0FoW8CoU4fx5kPQd0O17NeAPNiY=; b=KYZlRghveBlPMMdTqgJuH2AOo5abl3+OkOVDjyy45nGSjfPLiaDVmnhOlljKyx8oMCa60y d7BFmREY8tPS1z9BIqw+xfPILjT53tOeW9fmTmFDOC4vkTkMTAw4mABB/S2iui/+v/n05V 4vY56OUQGLAxs6SUJ/Lz8uxkPskosok= From: Sui Jingfeng To: Alex Deucher , Christian Koenig , David Airlie , Daniel Vetter , Dave Airlie , Thomas Zimmermann , Jocelyn Falempe , Javier Martinez Canillas , Maxime Ripard , Jani Nikula , Joonas Lahtinen , Ben Skeggs , Lyude Paul , Bjorn Helgaas , Helge Deller , Mario Limonciello Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-pci@vger.kernel.org, kvm@vger.kernel.org, linux-fbdev@vger.kernel.org, Sui Jingfeng Subject: [PATCH v3 2/9] video/aperture: Add a helper for determining if an unmoved aperture contain FB Date: Wed, 12 Jul 2023 00:31:48 +0800 Message-Id: <20230711163155.791522-3-sui.jingfeng@linux.dev> In-Reply-To: <20230711163155.791522-1-sui.jingfeng@linux.dev> References: <20230711163155.791522-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 This patch is intended to form a uniform approach to determining if an unmoved aperture contains the firmware FB. I believe that the global screen_info is more about video-specific things. Putting it in video/aperture.c helps form a uniform approach. Cc: Thomas Zimmermann Cc: Javier Martinez Canillas Cc: Helge Deller Signed-off-by: Sui Jingfeng --- drivers/video/aperture.c | 36 ++++++++++++++++++++++++++++++++++++ include/linux/aperture.h | 7 +++++++ 2 files changed, 43 insertions(+) diff --git a/drivers/video/aperture.c b/drivers/video/aperture.c index 34eb962cfae8..f03dfcabc303 100644 --- a/drivers/video/aperture.c +++ b/drivers/video/aperture.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -406,3 +407,38 @@ bool aperture_contain_firmware_fb(resource_size_t ap_start, resource_size_t ap_e return false; } EXPORT_SYMBOL(aperture_contain_firmware_fb); + +/** + * aperture_contain_firmware_fb_nonreloc - Detect if the firmware framebuffer + * belong to a non-relocatable aperture, such as the aperture of platform + * device. Note that this function relay on the global screen info. + * @ap_start: the aperture's start address in physical memory + * @ap_end: the aperture's end address in physical memory + * + * Returns: + * true if there is a firmware framebuffer belong to the aperture passed in, + * or false otherwise. + */ +bool aperture_contain_firmware_fb_nonreloc(resource_size_t ap_start, resource_size_t ap_end) +{ + u64 fb_start; + u64 fb_end; + + if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE) { + fb_start = (u64)screen_info.ext_lfb_base << 32 | screen_info.lfb_base; + fb_end = fb_start + screen_info.lfb_size; + } else { + fb_start = screen_info.lfb_base; + fb_end = fb_start + screen_info.lfb_size; + } + + /* No firmware framebuffer support */ + if (!fb_start || !fb_end) + return false; + + if (fb_start >= ap_start && fb_end <= ap_end) + return true; + + return false; +} +EXPORT_SYMBOL(aperture_contain_firmware_fb_nonreloc); diff --git a/include/linux/aperture.h b/include/linux/aperture.h index d4dc5917c49b..906d23532b56 100644 --- a/include/linux/aperture.h +++ b/include/linux/aperture.h @@ -21,6 +21,8 @@ int __aperture_remove_legacy_vga_devices(struct pci_dev *pdev); int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const char *name); bool aperture_contain_firmware_fb(resource_size_t ap_start, resource_size_t ap_end); + +bool aperture_contain_firmware_fb_nonreloc(resource_size_t ap_start, resource_size_t ap_end); #else static inline int devm_aperture_acquire_for_platform_device(struct platform_device *pdev, resource_size_t base, @@ -49,6 +51,11 @@ static inline bool aperture_contain_firmware_fb(resource_size_t ap_start, resour { return false; } + +static bool aperture_contain_firmware_fb_nonreloc(resource_size_t ap_start, resource_size_t ap_end) +{ + return false; +} #endif /** -- 2.25.1