From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A2F8C88CBB for ; Tue, 13 Jun 2023 03:00:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239106AbjFMDAt (ORCPT ); Mon, 12 Jun 2023 23:00:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238922AbjFMDAn (ORCPT ); Mon, 12 Jun 2023 23:00:43 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4E245172B; Mon, 12 Jun 2023 20:00:39 -0700 (PDT) Received: from loongson.cn (unknown [10.20.42.43]) by gateway (Coremail) with SMTP id _____8AxnOrV24dkQ2MEAA--.9295S3; Tue, 13 Jun 2023 11:00:37 +0800 (CST) Received: from openarena.loongson.cn (unknown [10.20.42.43]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxC8rV24dkOkAYAA--.60391S2; Tue, 13 Jun 2023 11:00:37 +0800 (CST) From: Sui Jingfeng To: Bjorn Helgaas 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 <15330273260@189.cn> Subject: [PATCH v7 0/8] PCI/VGA: Introduce is_boot_device function callback to vga_client_register Date: Tue, 13 Jun 2023 11:00:27 +0800 Message-Id: <20230613030035.216556-1-suijingfeng@loongson.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8b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AIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r 4j6F4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07jr eOLUUUUU= Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sui Jingfeng <15330273260@189.cn> The vga_is_firmware_default() function is arch-dependent, it's probably wrong if we simply remove the arch guard. As the VRAM BAR which contains firmware framebuffer may move, while the lfb_base and lfb_size members of the screen_info does not change accordingly. In short, it should take the re-allocation of the PCI BAR into consideration. With the observation that device drivers or video aperture helpers may have better knowledge about which PCI bar contains the firmware fb, which could avoid the need to iterate all of the PCI BARs. But as a PCI function at pci/vgaarb.c, vga_is_firmware_default() is not suitable to make such an optimization since it is loaded too early. There are PCI display controllers that don't have a dedicated VRAM bar, this function will lose its effectiveness in such a case. Luckily, the device driver can provide an accurate workaround. Therefore, this patch introduces a callback that allows the device driver to tell the VGAARB if the device is the default boot device. Also honor the comment: "Clients have two callback mechanisms they can use" Sui Jingfeng (8): PCI/VGA: Use unsigned type for the io_state variable PCI/VGA: Deal only with VGA class devices PCI/VGA: Tidy up the code and comment format PCI/VGA: Replace full MIT license text with SPDX identifier video/aperture: Add a helper to detect if an aperture contains firmware FB PCI/VGA: Introduce is_boot_device function callback to vga_client_register drm/amdgpu: Implement the is_boot_device callback function drm/radeon: Implement the is_boot_device callback function drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 +- drivers/gpu/drm/drm_aperture.c | 16 +++ drivers/gpu/drm/i915/display/intel_vga.c | 3 +- drivers/gpu/drm/nouveau/nouveau_vga.c | 2 +- drivers/gpu/drm/radeon/radeon_device.c | 12 +- drivers/pci/vgaarb.c | 153 +++++++++++++-------- drivers/vfio/pci/vfio_pci_core.c | 2 +- drivers/video/aperture.c | 29 ++++ include/drm/drm_aperture.h | 2 + include/linux/aperture.h | 7 + include/linux/vgaarb.h | 35 ++--- 11 files changed, 184 insertions(+), 89 deletions(-) -- 2.25.1