From patchwork Fri Jun 30 11:02:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 13303711 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 E358FEB64D9 for ; Thu, 6 Jul 2023 13:18:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E02C710E42D; Thu, 6 Jul 2023 13:18:55 +0000 (UTC) X-Greylist: delayed 346 seconds by postgrey-1.36 at gabe; Fri, 30 Jun 2023 11:08:38 UTC Received: from out-57.mta0.migadu.com (out-57.mta0.migadu.com [91.218.175.57]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9BD3E10E44E for ; Fri, 30 Jun 2023 11:08:38 +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=1688122990; 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=btfhp53flz2znRJhVRVROxzr2+xJwf5jWKVzzdMQNCg=; b=T73HFHyypfPukJHUCivjqAqiND6lcrXP+g0ZSla4MUTvXmqJbQrwuT16aoxpOada4b8PuN Zb0G/hybooeV4zLJKuZI6dmV348rzV47I3c7QaAf/CWaoV1LLUZGqtqBRZZ0N54w/EswIc 92ry4Yxu6TJa1mUgnhkXb/bif7YjLxY= From: Sui Jingfeng To: Alex Deucher , David Airlie , Daniel Vetter , Thomas Zimmermann , Maxime Ripard , Jani Nikula Date: Fri, 30 Jun 2023 19:02:43 +0800 Message-Id: <20230630110243.141671-5-sui.jingfeng@linux.dev> In-Reply-To: <20230630110243.141671-1-sui.jingfeng@linux.dev> References: <20230630110243.141671-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Mailman-Approved-At: Thu, 06 Jul 2023 13:18:28 +0000 Subject: [Intel-gfx] [PATCH v1 4/4] drm/radeon: Implement the is_boot_device callback function X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, Sui Jingfeng , kvm@vger.kernel.org, nouveau@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Pan Xinhui , linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-pci@vger.kernel.org, Christian Konig Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Sui Jingfeng [why] The vga_is_firmware_default() defined in drivers/pci/vgaarb.c is arch-dependent, it's a dummy on non-x86 architectures currently. This made VGAARB lost an important condition for the arbitration. It could still be wrong even if we remove the #ifdef and #endif guards. because the PCI bar will move (resource re-allocation). [how] The device that owns the firmware framebuffer should be the default boot device. This patch adds an arch-independent function to enforce this rule. The vgaarb subsystem will call back to radeon_is_boot_device() function when drm/radeon is successfully bound to a radeon GPU device. 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..afb49000830c 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_is_boot_device(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_is_boot_device); if (rdev->flags & RADEON_IS_PX) runtime = true;