Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp8775088rwp; Wed, 19 Jul 2023 15:24:13 -0700 (PDT) X-Google-Smtp-Source: APBJJlEsqkwYkiIACiAFzhjFBm7NcqunFGcgHr5k0EK8MRaH4KeanZo86Q0Vif8UBJao40s9Fu8k X-Received: by 2002:a17:903:32c4:b0:1b5:5162:53bd with SMTP id i4-20020a17090332c400b001b5516253bdmr4584839plr.33.1689805453272; Wed, 19 Jul 2023 15:24:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689805453; cv=none; d=google.com; s=arc-20160816; b=E9uvwt4Y0NKpqqTWTUmj6E3hYBY/sGCTq+FGWN2b/10vvOdgkBFiywUZpU8xB3C9jV cY0YzBOATm4StoZsF1XzjPiU3Y+GR2BawPGnumDfaj7xgNLYZBucPxfLTgF6f9NG41lk LOHfHvxOtLlKXAJ8PC4YJaMsUNSVn13PkD14t2sfgR32ebkMbVW7YuDIOrtxytr226J/ ztiSdCpu+vjB8MM3HXm5FEq5Eb8lCcTjKXqcpP5UjBgUI1QaW+WQ+A7dAH9Y9SbBm66K I6iP2b7QTX1kcwtOA51f+qubLJB16UPQ5S1LRgNpI5/zP1vtEzy/6QjsEimnV9ewuLnE ZInA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=QYEs6ciTKwT8St/nqPxnJxUcJvIPyGtDOfPaW75gg9w=; fh=iKkUIGTq/6K26WudWIhddz4MlAq7wy5BwjIvP84KqHI=; b=YaKDWS/y/l/JrY/1GcyhcMSNwXp57hD02gvamPLu6DpmE09lBY7xXiUhV6Xf56jZz+ cLF3Den4AETF2SOi6FOyOX6nsx0Kb4lbje8SJhGms6c8j4UkSj6EGydKszDc7UUeIAcO 0EjCxaqe92j7h8ptRCiTeQ0Ptd9yn/gZvJrgvZjPAlAVsorUrdtBtydsviBuxGNi+KuL Sv2ZM+S6Xp6H/jgRvA5gKi8ZSJ+pWEAy8+LKSIhjV2QbRLwd/l0y8z2qJOWUlDof/opy 0AxMAjxfUW35j6vK4FCl8PqwsqO7GOsNKhZp7mGEeGefWeJXVLAxCG/ar5eLGdAdVE6I Y4Fw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x15-20020a170902ec8f00b001bb3406a5f7si4577933plg.11.2023.07.19.15.24.01; Wed, 19 Jul 2023 15:24:13 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230218AbjGSWEf (ORCPT + 99 others); Wed, 19 Jul 2023 18:04:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230177AbjGSWEb (ORCPT ); Wed, 19 Jul 2023 18:04:31 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 804561FE8; Wed, 19 Jul 2023 15:04:23 -0700 (PDT) Received: from loongson.cn (unknown [10.20.42.43]) by gateway (Coremail) with SMTP id _____8Cxc_DmXbhkBHMHAA--.18957S3; Thu, 20 Jul 2023 06:04:22 +0800 (CST) Received: from [10.20.42.43] (unknown [10.20.42.43]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Cx7yPlXbhkPxo1AA--.40661S3; Thu, 20 Jul 2023 06:04:22 +0800 (CST) Message-ID: Date: Thu, 20 Jul 2023 06:04:21 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [Intel-gfx] [PATCH v3 3/9] PCI/VGA: Switch to aperture_contain_firmware_fb_nonreloc() Content-Language: en-US To: Bjorn Helgaas , Sui Jingfeng Cc: David Airlie , linux-fbdev@vger.kernel.org, kvm@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-pci@vger.kernel.org References: <20230719204314.GA512532@bhelgaas> From: suijingfeng In-Reply-To: <20230719204314.GA512532@bhelgaas> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CM-TRANSID: AQAAf8Cx7yPlXbhkPxo1AA--.40661S3 X-CM-SenderInfo: xvxlyxpqjiv03j6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBj93XoWxAr47uw17Jryxtw1rAr1xtFc_yoWrZw4xpa n5AFZ3Aa1DGr4rG3W2v3W2vF1Fvws7GFyUKF98Zw1ru3sIkwn7Kr18ArZ0v3s7ArZ7Ja1S vF43tw15uan8ZFXCm3ZEXasCq-sJn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUvIb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r106r15M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Jr0_Gr1l84ACjcxK6I8E87Iv67AKxVWxJVW8Jr1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6r4j6r4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI0UMc 02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUGVWUXwAv7VC2z280aVAF wI0_Cr0_Gr1UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvEwIxGrwCYjI0SjxkI62AI1c AE67vIY487MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8C rVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8Zw CIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x02 67AKxVWUJVW8JwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Cr 0_Gr1UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07UA Ma8UUUUU= X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Hi, On 2023/7/20 04:43, Bjorn Helgaas wrote: > [+cc linux-pci; I don't apply or ack PCI patches unless they appear there] > > On Wed, Jul 12, 2023 at 12:43:04AM +0800, Sui Jingfeng wrote: >> 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. > Because it's better to access the global screen_info from > aperture_contain_firmware_fb_nonreloc()? The reasoning here is not > super clear to me. Yes, honestly the benefits of this patch is not obvious. But I do have some (may not practical) ideas in my mind when I create this patch. See my explanation at the end. >> 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. > "how the determination ..." (drop the "does") Ok, will be fixed at the next version. > > Are you saying that aperture_contain_firmware_fb_nonreloc() might be > arch-dependent? Are there multiple callers? Or does this just move > code from one place to a more appropriate place? 1) To form a unify approach, and drop the screen_info.h header. There are similar cleanup patch at patchwork. screen_info.h is definitely arch-dependent, while vgaarb is just device-dependent. I think, they do have subtle difference. 2) Convert the *device driven* to the "driver driven". Move it from vgaarb.c to video/apperture allow code sharing. While this function are not going to be shared in vgaarb. Previous it is the device make the decision, after applied this patch it allow driver make the decision. They do have subtle difference. Emm, I will try to give some examples at the next version. 3) I was imagine to drag platform display controllers in (get platform devices involved in the arbitration). As Alex seem hint to implement something platform-independent. The aperture_contain_firmware_fb_nonreloc() actually is possible be shared. The aperture of platform device will be not moved. So it seems that platform device driver could call this function to do something else. >> 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 >>