From patchwork Tue Jul 11 16:43:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 701689 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 32587C00528 for ; Tue, 11 Jul 2023 16:53:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233009AbjGKQxk (ORCPT ); Tue, 11 Jul 2023 12:53:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232869AbjGKQxf (ORCPT ); Tue, 11 Jul 2023 12:53:35 -0400 Received: from out-51.mta1.migadu.com (out-51.mta1.migadu.com [IPv6:2001:41d0:203:375::33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 486C910F2 for ; Tue, 11 Jul 2023 09:53:32 -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=1689093824; 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=NIlpd2OuXAqZBmAKqEiHOVF8G3KI4fwGrKLh4KCVTtk=; b=ecINMnuvOGXb9BbruD5LvN4Yp3H0QtakNbtBqZGtbF+uuD1Ia0wIToBo3dNnNdqp2wca3L /dYsRshA52X9SZ13jGxCqAkY/HzcvDJ4zQmkUC31Et0p3dmpUkcI+j+ErMq5ZjHq/6QDJz 5m4MiOwv+urTFm8EUQit+44ndOvrrvU= From: Sui Jingfeng To: David Airlie Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, kvm@vger.kernel.org, linux-fbdev@vger.kernel.org, Sui Jingfeng , Alex Deucher , Christian Konig , Mario Limonciello Subject: [PATCH v3 5/9] drm/amdgpu: Implement the is_primary_gpu callback of vga_client_register() Date: Wed, 12 Jul 2023 00:43:06 +0800 Message-Id: <20230711164310.791756-6-sui.jingfeng@linux.dev> In-Reply-To: <20230711164310.791756-1-sui.jingfeng@linux.dev> References: <20230711164310.791756-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: Mario Limonciello 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);