From patchwork Sun Jul 2 18:27:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 13299431 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 7F2A8EB64D9 for ; Sun, 2 Jul 2023 18:28:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229947AbjGBS2f (ORCPT ); Sun, 2 Jul 2023 14:28:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230020AbjGBS2b (ORCPT ); Sun, 2 Jul 2023 14:28:31 -0400 Received: from out-42.mta0.migadu.com (out-42.mta0.migadu.com [91.218.175.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC7BBDF for ; Sun, 2 Jul 2023 11:28:25 -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=1688322503; 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=9VT31crvj/hSyen+1yeJunQKIe6CJXCWJLM4jAJyVsI=; b=VWF57D2RseclrzcKi119DMJUFZtaHElS7q8jbbh1XWQr8bBCK8JJYFDv5kCFqfSUbl8Zxj OfeNWV8lWl7Z/3X4/oZsFJHS6v2PhXoEiYBdlpE02JaUy3Qqzzt1+3bGGp3Lm9+gp8wrVW 1d/YvTbmfmhNSt2c7WBL8ZsgF8ys6Yg= 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 , Christian Konig , Pan Xinhui , Hawking Zhang , Lijo Lazar , YiPeng Chai , Bokun Zhang , Likun Gao Subject: [PATCH v2 3/6] drm/amdgpu: Implement the is_boot_device callback function Date: Mon, 3 Jul 2023 02:27:41 +0800 Message-Id: <20230702182744.755467-4-sui.jingfeng@linux.dev> In-Reply-To: <20230702182744.755467-1-sui.jingfeng@linux.dev> References: <20230702182744.755467-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 amdgpu_is_boot_device() function when drm/amdgpu is successfully bound to an AMDGPU device. 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 c5bdf6eff29e..2f54250f9d58 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -3673,6 +3673,15 @@ static const struct attribute *amdgpu_dev_attributes[] = { NULL }; +static bool amdgpu_is_boot_device(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 * @@ -4082,7 +4091,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_boot_device); px = amdgpu_device_supports_px(ddev);