From patchwork Tue Jul 11 16:31:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 702070 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 177E8C001DD for ; Tue, 11 Jul 2023 16:33:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232554AbjGKQdJ (ORCPT ); Tue, 11 Jul 2023 12:33:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233297AbjGKQc7 (ORCPT ); Tue, 11 Jul 2023 12:32:59 -0400 Received: from out-37.mta0.migadu.com (out-37.mta0.migadu.com [91.218.175.37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECB4719BD for ; Tue, 11 Jul 2023 09:32:45 -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=1689093163; 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=QoMhwjFigAbTHq+HcB9GYpyFfpHDzGgLNmwruJkUmC8=; b=mjzopN32gkDIHH2DKeXPU4Uhh5gf5z6r2DVtvgerWF+e+HZlmhuYpklBE1idXQeZo+0qP6 kmmBiis6yM0xkO0eQgkG3GzLPBwQlnlpbqo8JYOMgGxYMoHSFvkTp+dFbaI/Dx0l2tA5er DVLQ6sEcNFPLD8VVKk9IBe1o8Q3fX7c= From: Sui Jingfeng To: Alex Deucher , Christian Koenig , David Airlie , Daniel Vetter , Dave Airlie , Thomas Zimmermann , Jocelyn Falempe , Javier Martinez Canillas , Maxime Ripard , Jani Nikula , Joonas Lahtinen , Ben Skeggs , Lyude Paul , Bjorn Helgaas , Helge Deller , Mario Limonciello 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 , Pan Xinhui , Hawking Zhang , Lijo Lazar , YiPeng Chai , Bokun Zhang , Likun Gao Subject: [PATCH v3 5/9] drm/amdgpu: Implement the is_primary_gpu callback of vga_client_register() Date: Wed, 12 Jul 2023 00:31:51 +0800 Message-Id: <20230711163155.791522-6-sui.jingfeng@linux.dev> In-Reply-To: <20230711163155.791522-1-sui.jingfeng@linux.dev> References: <20230711163155.791522-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org From: Sui Jingfeng [why] The vga_is_firmware_default() function defined in drivers/pci/vgaarb.c is arch-dependent, it's a dummy on non-x86 architectures. This made VGAARB lost an important condition for the arbitration on non-x86 platform. The rules about which GPU is (or should be) the primary display device get used by userspace are obscure on non-x86 platform, let's made the things clear. [how] The device that owns the firmware framebuffer should be the default boot device. This patch adds an arch-independent function to implement this rule. The vgaarb subsystem will call back to amdgpu_is_primary_gpu() when drm/amdgpu is bound to an AMDGPU device successfully. Cc: Alex Deucher Cc: Christian Konig Cc: Pan Xinhui Cc: David Airlie Cc: Daniel Vetter Cc: Hawking Zhang Cc: Mario Limonciello Cc: Lijo Lazar Cc: YiPeng Chai Cc: Bokun Zhang CC: Likun Gao Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index d98f0801ac77..b638eff58636 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -3690,6 +3690,15 @@ static void amdgpu_device_set_mcbp(struct amdgpu_device *adev) DRM_INFO("MCBP is enabled\n"); } +static bool amdgpu_is_primary_gpu(struct pci_dev *pdev) +{ + struct drm_device *dev = pci_get_drvdata(pdev); + struct amdgpu_device *adev = drm_to_adev(dev); + struct amdgpu_gmc *gmc = &adev->gmc; + + return drm_aperture_contain_firmware_fb(gmc->aper_base, gmc->aper_size); +} + /** * amdgpu_device_init - initialize the driver * @@ -4103,7 +4112,8 @@ int amdgpu_device_init(struct amdgpu_device *adev, /* this will fail for cards that aren't VGA class devices, just * ignore it */ if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA) - vga_client_register(adev->pdev, amdgpu_device_vga_set_decode, NULL); + vga_client_register(adev->pdev, amdgpu_device_vga_set_decode, + amdgpu_is_primary_gpu); px = amdgpu_device_supports_px(ddev);