Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp37154687rwd; Tue, 11 Jul 2023 10:06:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlGIpVEL/ibveNsM9tBcEGyFbMXkjZmRJ+cF4kMWIQiyWP6kJ3oOkWRQZFj5dixCQpQ7mMIV X-Received: by 2002:a17:90a:d710:b0:263:484c:f173 with SMTP id y16-20020a17090ad71000b00263484cf173mr15693767pju.2.1689095211268; Tue, 11 Jul 2023 10:06:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689095211; cv=none; d=google.com; s=arc-20160816; b=LSpRVYfSoyFBCzImV01gnsbLouQtIkqbWFRLj1OOqvC+76QWqcmfyRj8EyEpIyp4re zKuUSkVqatA7/NOjo07JnzMgwO+vM2nXBaETzrtjfcvjwpEDJ2Pa6HK+5rQXD5ygCUIi W4HtbaD5TaVeAuY1dZ4gj6ZKqUxiOEm7B1pIiEHsUzVgG3sJy2axn3kKg/8DFYw0/APD Jxy4m+XQPoIRFsy5wLdY3jpLs71P8AjVOg/tKYItoPzNOeqPMkEXjGJb53Tcz6Ow8GOs tZSk4HiV8xFOg9GE+pbDe/+8MyU1E3JyIh3V/H1Q4dX5DTfSVzcfzZ2YD/+E7LNlTvwh KZ3Q== 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=HnuphIZXHV8C9F464kONhrfIxcFiaW93tVPsllXFGzc=; b=vvpfLOA3wF7cgKzEtBiCLAFek9Mpppvujf+L9QuJIfZ7ehDFuPy1XgF5tF0+sR/HD0 HaylPsJqD4N82uQVavqaqGdHmcCtfypsMCta5RSfu0hGs2FZntELSE82h37fzp3fRGSr wX/CtQAFDKRO67EkFnUzSl+qEvK+5hdd+GQrgrAfg8+V+x4uqQul4c44T5DrXIfOHzbL EvN75eThtJ1FsA+wEb1ocIg34iZlp0G6Zhl5a/r6cZy59GoplEDZKLZ/h6ndrQsBk3wC sxFDjkfEzTsTSpVKbVAepWVAAzyjsCcHrHz8oq9SYuwPP+4IsbP8qDReLcoyMxT9TfwK KLrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=VLnHpbhm; 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 z12-20020a17090a7b8c00b00262f798b614si1843783pjc.51.2023.07.11.10.06.38; Tue, 11 Jul 2023 10:06:51 -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=VLnHpbhm; 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 S233014AbjGKQnn (ORCPT + 99 others); Tue, 11 Jul 2023 12:43:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232949AbjGKQne (ORCPT ); Tue, 11 Jul 2023 12:43:34 -0400 Received: from out-53.mta1.migadu.com (out-53.mta1.migadu.com [IPv6:2001:41d0:203:375::35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F577E69 for ; Tue, 11 Jul 2023 09:43:33 -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=1689093809; 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=VLnHpbhmCbj+VytfP2De0A90dTbIOm7DbFncSWPFk5st0NBQu1Rgdl8iXr4M//w7gMNkg6 k82DFVKmL0UkqsJrG275lNVeqSYnUy+KXU/qz2KFRRtukDcsipHPOqzM3498Fm16a4DX4L 10mrRoZDA7Sbop614INjogTPQZG6Ouw= 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 , Thomas Zimmermann , Javier Martinez Canillas , Helge Deller Subject: [PATCH v3 2/9] video/aperture: Add a helper for determining if an unmoved aperture contain FB Date: Wed, 12 Jul 2023 00:43:03 +0800 Message-Id: <20230711164310.791756-3-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 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