Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp25172982rwd; Sun, 2 Jul 2023 11:49:34 -0700 (PDT) X-Google-Smtp-Source: APBJJlHBiD3RFO4fnyWszVlDVhr5i0BaWBxVn/55HT7D26Fi9JjRKEsK4jIx1mAfnLj/oh4aSZ9n X-Received: by 2002:a17:902:d2cd:b0:1b6:ba60:77f0 with SMTP id n13-20020a170902d2cd00b001b6ba6077f0mr7630549plc.10.1688323774090; Sun, 02 Jul 2023 11:49:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688323774; cv=none; d=google.com; s=arc-20160816; b=Hr/SIc8tBVd3BA4KYTuox0vQKkIXBAr6Amuq+RBibzadTKhfyhrffz7+4DHtBomya2 16/wNxXUQR3qOuSzX6JzMr6w0J3SWLueACZXGcNB8Q5SLApSZAkbkfRYegI3fzQp4Yji VXxaNaABRxl6tpK8Nv2jURa+rq6RsfgGr/GhXYZn95ZZZ1+pyxuIACIKlZDsMarLFqOG RWV9pha7tyxptZsstruAUE/j2zRTFposfnKbQIyzBe4ZHKBVSLnMUGtP0BZnrh7f4k25 EssGtBVE8ChTEVOscMWIM8piMBslxbuBvRUOtTBfr6OEK2PIGP2Rxw6SAr6XtlcCPWGz cKxg== 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:dkim-signature; bh=c8oIOXLUyu6Hy3euIb+35kAKURoMMfCL4+zt+LpgQrI=; fh=PxEJJhr1DmYuTdFw5uPSXAFp4NvuaowGYw0ZCGBAMO8=; b=JsqmaQhTaTdKERlRSTGTOHP/CrrUETWJyIvy8pTWT20EksKJZ0EGmwWO7TEwU2iQhR va/chfFmqVj4cGWHWd43n2rWb9ZOVFdpMKNVp2iiDsKmyF3QjgVAELf/GCVB1+dSF1F2 iP772uLpndSl2xJUWRCMhdROaqnWXZzAhk0KGrgdpOk0rcTxiCWwy1XOc65ZbfRt3w6n iyL0RXjNR+HVy5ryXWIaoyI588d34rvwxo7Vz+fckPP/Ns9v5OYyinosMTrIcB5QpMLN RThn40o+XBGpRX6d0s5bIkvXgHK21a9GO9LO7LWeng0jY3CUJmTMTS+itWnlhOGqkSLK mmdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=cj5i7X8N; 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 t16-20020a17090aba9000b0025bd4dde456si19690855pjr.88.2023.07.02.11.49.21; Sun, 02 Jul 2023 11:49:34 -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=cj5i7X8N; 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 S229837AbjGBS2L (ORCPT + 99 others); Sun, 2 Jul 2023 14:28:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229817AbjGBS2J (ORCPT ); Sun, 2 Jul 2023 14:28:09 -0400 Received: from out-56.mta0.migadu.com (out-56.mta0.migadu.com [91.218.175.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0682B0 for ; Sun, 2 Jul 2023 11:28:07 -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=1688322485; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=c8oIOXLUyu6Hy3euIb+35kAKURoMMfCL4+zt+LpgQrI=; b=cj5i7X8NIGfrWOZux8pWRT6wSPgfMb6og8nVfn9C+hC3/QDZo2zIbH5h7ncrhXIklQCVrX 6sITBq6QW4gJjbqqGZFN3lcWgbJ1Qxrx8UY03BDxOWGGVbOpuqz6kYpL8d6nWQmT14fnfl 1JU2TEA88cvmiWUcyHCZqsveRzQOEyg= From: Sui Jingfeng To: Alex Deucher , David Airlie , Daniel Vetter , Thomas Zimmermann , Maxime Ripard , Jani Nikula , Lyude Paul , Bjorn Helgaas , Mario Limonciello Cc: dri-devel@lists.freedesktop.org, amd-gfx@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 Subject: [PATCH v2 0/6] PCI/VGA: Improve the default VGA device selection Date: Mon, 3 Jul 2023 02:27:38 +0800 Message-Id: <20230702182744.755467-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Currently, the default VGA device selection is not perfect. Potential problems are: 1) This function is a no-op on non-x86 architectures. 2) It does not take the PCI Bar may get relocated into consideration. 3) It is not effective for the PCI device without a dedicated VRAM Bar. 4) It is device-agnostic, thus it has to waste the effort to iterate all of the PCI Bar to find the VRAM aperture. 5) It has invented lots of methods to determine which one is the default boot device on a multiple video card coexistence system. But this is still a policy because it doesn't give the user a choice to override. With the observation that device drivers or video aperture helpers may have better knowledge about which PCI bar contains the firmware FB, This patch tries to solve the above problems by introducing a function callback to the vga_client_register() function interface. DRM device drivers for the PCI device need to register the is_boot_device() function callback during the driver loading time. Once the driver binds the device successfully, VRAARB will call back to the driver. This gives the device drivers a chance to provide accurate boot device identification. Which in turn unlock the abitration service to non-x86 architectures. A device driver can also pass a NULL pointer to keep the original behavior. This series is applied on the drm-tip branch (with a cleanup patch set[1] applied beforehand) [1] https://patchwork.freedesktop.org/series/120053/ v2: * Add a simple implemment for drm/i915 and drm/ast * Pick up all tags (Mario) Sui Jingfeng (6): video/aperture: Add a helper to detect if an aperture contains firmware FB PCI/VGA: Improve the default VGA device selection drm/amdgpu: Implement the is_boot_device callback function drm/radeon: Implement the is_boot_device callback function drm/i915: Implement the is_boot_device callback function drm/ast: Register as a vga client to vgaarb by calling vga_client_register() drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 +++++++- drivers/gpu/drm/ast/ast_drv.c | 29 ++++++++++++++++++++ drivers/gpu/drm/drm_aperture.c | 16 +++++++++++ drivers/gpu/drm/i915/display/intel_vga.c | 32 ++++++++++++++++++++-- drivers/gpu/drm/nouveau/nouveau_vga.c | 2 +- drivers/gpu/drm/radeon/radeon_device.c | 12 +++++++- drivers/pci/vgaarb.c | 21 +++++++++++++- 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 | 8 ++++-- 12 files changed, 162 insertions(+), 10 deletions(-) -- 2.25.1