From patchwork Tue Jul 11 16:43:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 118657 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp616982vqm; Tue, 11 Jul 2023 09:51:22 -0700 (PDT) X-Google-Smtp-Source: APBJJlFb/ITx8JRkbgXpFlS9l3IBabms2TGgAdvDtha4kgcE9Pr3k78tXgTQd604DiV7AjJ4bjnl X-Received: by 2002:a17:906:d54b:b0:98e:48cc:4cbf with SMTP id cr11-20020a170906d54b00b0098e48cc4cbfmr24573840ejc.26.1689094282347; Tue, 11 Jul 2023 09:51:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689094282; cv=none; d=google.com; s=arc-20160816; b=AvsZQGu2n2aXBSIkd7fr8RO+E4ilGDkvg3Uopt2t34SsN8bFO70VlLpea4Gf7Ga7zv 4+93YhSemfM1oHlV+EhE/yAiWKiiyMjbi2SNXkYgxeK8OyrgF1xY53L4dqtkP6PZ9Mq7 +evEs12dsVc43V5lgky1wk6IUgp78+V7T14sywrt/4GrfcHk0lwj+9rwxnX4cZw2F4kX otakv3Ft514TK9T2ZFol+XxRB0OrewCgJKCVt2hIwue6fLv+PrzeL54rO1D77aEBJi0G 4vxfCCgZ0Ga4CwRtnLDk3H1vi2hHzXm+2RQwR4Yx7ymAn6iGqGu+XvB4CMxjNDVBlER4 d8Sw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kt22-20020a170906aad600b0098d85fee2e2si2351839ejb.608.2023.07.11.09.50.58; Tue, 11 Jul 2023 09:51:22 -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 S233007AbjGKQnn (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 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: 1771143726503022498 X-GMAIL-MSGID: 1771143726503022498 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 /**