From patchwork Tue Jul 11 16:43:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 13309128 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 66C15C0015E for ; Tue, 11 Jul 2023 16:53:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F0A9A10E408; Tue, 11 Jul 2023 16:53:44 +0000 (UTC) Received: from out-41.mta1.migadu.com (out-41.mta1.migadu.com [IPv6:2001:41d0:203:375::29]) by gabe.freedesktop.org (Postfix) with ESMTPS id E144A10E402 for ; Tue, 11 Jul 2023 16:53:32 +0000 (UTC) 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=1689093827; 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=phlB5jeyUkvMxIpxSGgMhgloOsV1JgjnEjP6Y7xHuM8=; b=tpCdteZ5Ib+wxbxFaAWwfiWUSKgfPXeqdoI+n2yWg+cepHeniy4juvONgWOcLejop+jeC0 PkigMOBJnABT1FN7Nc1r4q7XtVhHB/bxalYDRi/gFikN7sxsMDRAOv8gq9d4pRUrTFeRwf v6ZBO4PyK6QCCUJsme2hCie3x604P88= From: Sui Jingfeng To: David Airlie Subject: [PATCH v3 6/9] drm/radeon: Add an implement for the is_primary_gpu function callback Date: Wed, 12 Jul 2023 00:43:07 +0800 Message-Id: <20230711164310.791756-7-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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, Sui Jingfeng , kvm@vger.kernel.org, intel-gfx@lists.freedesktop.org, Pan Xinhui , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, Alex Deucher , Christian Konig Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Sui Jingfeng [why] The vga_is_firmware_default() function defined in drivers/pci/vgaarb.c is arch-dependent, it's no-op on non-x86 architectures. The arbitration is not usabe on non-x86 platform. [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 will call back to radeon_is_primary_gpu() when drm/radeon is bound to a ATI gpu device successfully. Cc: Alex Deucher Cc: Christian Konig Cc: Pan Xinhui Cc: David Airlie Cc: Daniel Vetter Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/radeon/radeon_device.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c index 71f2ff39d6a1..7db8dc5f79a9 100644 --- a/drivers/gpu/drm/radeon/radeon_device.c +++ b/drivers/gpu/drm/radeon/radeon_device.c @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -1263,6 +1264,15 @@ static const struct vga_switcheroo_client_ops radeon_switcheroo_ops = { .can_switch = radeon_switcheroo_can_switch, }; +static bool radeon_vga_is_primary_gpu(struct pci_dev *pdev) +{ + struct drm_device *dev = pci_get_drvdata(pdev); + struct radeon_device *rdev = dev->dev_private; + struct radeon_mc *gmc = &rdev->mc; + + return drm_aperture_contain_firmware_fb(gmc->aper_base, gmc->aper_size); +} + /** * radeon_device_init - initialize the driver * @@ -1425,7 +1435,7 @@ int radeon_device_init(struct radeon_device *rdev, /* if we have > 1 VGA cards, then disable the radeon VGA resources */ /* this will fail for cards that aren't VGA class devices, just * ignore it */ - vga_client_register(rdev->pdev, radeon_vga_set_decode, NULL); + vga_client_register(rdev->pdev, radeon_vga_set_decode, radeon_vga_is_primary_gpu); if (rdev->flags & RADEON_IS_PX) runtime = true;