From patchwork Mon Jun 12 19:25:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng <15330273260@189.cn> X-Patchwork-Id: 10657 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp87351vqr; Mon, 12 Jun 2023 12:29:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5wpmrtenwzdgRikMDqi/xxCZ6mtsKtwMz3/02Xi8JTPwkemWHFR/0HHJ60FxTjw2cJDokT X-Received: by 2002:aa7:d49a:0:b0:50b:fd52:2f4b with SMTP id b26-20020aa7d49a000000b0050bfd522f4bmr6712885edr.24.1686598148261; Mon, 12 Jun 2023 12:29:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686598148; cv=none; d=google.com; s=arc-20160816; b=CcRjC9fB770HbO2SpvYcqK8OyxQwEj7y1ZX5fxKkhjR+BJiwPPF9BxaIDDxiM8x3GQ P2m6KvvdQUCSWVAWXu0JiaygckFPdjk4daYjGiAt60XNcr3i8xL/U+q0CINZJNAwW9w5 SVdjfC0STCzYeE0pQuScRiC9kSeuW9XLkM8ISELmpprAmiLHPrRnu6yeGCfXRMm+CrNg Q/YMHJax2gdk7M20XtTDHd2NtttgIHK15Wncxln2I/UWPwS+92vs5U4fOVg1ahkVRt1u wzHU8m9VxeGwBKO3t8H+0hCpOdexa4ELFTxI7pgw+xpBaXS0v2HKm9DD3ad4huzXDiic R0mg== 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 :message-id:date:subject:cc:to:from:sender:hmm_source_type :hmm_attache_num:hmm_source_ip; bh=pxpXDSIVD+pG4q56yzx1JrJ6OddlUc0lQ/9SGG9gJnY=; b=CoWBdk7wBJnZauE8gPSPHz6KI6H2i5XWE1iJPII0z2Usuxheb4BwMlMrzZSJsW0eI/ o+z3eyJUfSUKozXMx7CoF5d91c+MvFLZwzonKX4d11t1i/4AKci/6mwWb3iiS9S+bGgP E2SlYTvfdunBn14T92HhOgAkzBZuTQZqO6qZg0HVfSNXMLWIeIG6xuzpcQQODShoWvI1 zBXRRfzqWy0xkSd+5Wheiz/D4KkH8NueWkabSisPduwNKF/XJY3nT2AV+qUsVGi08RDy tSanK9siX1Uy8QJVop0wlzAZ6R2NZTkQygo12vQF3e3rIkbLoTqFmZ8b8x1dvonDAiKT EsLA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r11-20020aa7cfcb000000b0051456f61f7dsi6208996edy.457.2023.06.12.12.28.44; Mon, 12 Jun 2023 12:29:08 -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 S236030AbjFLT0C (ORCPT + 99 others); Mon, 12 Jun 2023 15:26:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230466AbjFLT0A (ORCPT ); Mon, 12 Jun 2023 15:26:00 -0400 Received: from 189.cn (ptr.189.cn [183.61.185.102]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E86ADB1; Mon, 12 Jun 2023 12:25:57 -0700 (PDT) HMM_SOURCE_IP: 10.64.8.41:42778.1249123675 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP Received: from clientip-114.242.206.180 (unknown [10.64.8.41]) by 189.cn (HERMES) with SMTP id E55DE1001B5; Tue, 13 Jun 2023 03:25:52 +0800 (CST) Received: from ([114.242.206.180]) by gateway-151646-dep-75648544bd-xwndj with ESMTP id c3854781d6844409b550d5c2521a5b02 for alexander.deucher@amd.com; Tue, 13 Jun 2023 03:25:55 CST X-Transaction-ID: c3854781d6844409b550d5c2521a5b02 X-Real-From: 15330273260@189.cn X-Receive-IP: 114.242.206.180 X-MEDUSA-Status: 0 Sender: 15330273260@189.cn From: Sui Jingfeng <15330273260@189.cn> To: Alex Deucher , Christian Konig , Pan Xinhui , David Airlie , Daniel Vetter , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Ben Skeggs , Karol Herbst , Lyude Paul , Bjorn Helgaas , Alex Williamson , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Hawking Zhang , Mario Limonciello , Lijo Lazar , YiPeng Chai , Andrey Grodzovsky , Somalapuram Amaranath , Bokun Zhang , Ville Syrjala , Li Yi , Sui Jingfeng , Jason Gunthorpe , Kevin Tian , Cornelia Huck , Yishai Hadas , Abhishek Sahu , Yi Liu 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, loongson-kernel@lists.loongnix.cn Subject: [PATCH v6 0/8] PCI/VGA: introduce is_boot_device function callback to vga_client_register Date: Tue, 13 Jun 2023 03:25:42 +0800 Message-Id: <20230612192550.197053-1-15330273260@189.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,FROM_LOCAL_DIGITS, FROM_LOCAL_HEX,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768526340145110449?= X-GMAIL-MSGID: =?utf-8?q?1768526340145110449?= From: Sui Jingfeng 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(-) Reviewed-by: Lyude Paul