Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp625826rwd; Mon, 12 Jun 2023 20:14:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4kgZBPcmy4cnofThRYZFnwl3SJbI4Pqe4gH90wab/8Y7dbbx/md+Qu9l1Y9i20CS6g2nLH X-Received: by 2002:a17:907:168a:b0:982:3bae:afda with SMTP id hc10-20020a170907168a00b009823baeafdamr817384ejc.45.1686626073360; Mon, 12 Jun 2023 20:14:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686626073; cv=none; d=google.com; s=arc-20160816; b=tmhFpZ7ELTheBvaVhOb/ZTvk0vAhjwOCdjuiHahlMg8G82eCrtCHFqX0o5kb6qbFTd qGmPoHFGOoZM/YI2qoKJUp3Mkv4NnB3oGgakKBziWKaahq0ItP7Xd+5f1kc3guTJeICv Gz6r5UWqK0XGId/yp3OFHSVtD65HmzGA0dde/XQ7Tc3YySdfNwub8LF8PU7bVKZyNdtM pRAc1VKERx17Vqoh3fYTqvyRjRP46zuiDyPS+szloXlt8RdiZ/1ND+CZjjzLinTuc+9q VCQ5jG5PnDvh/Ho2NGlEIHNv6h+1sF5IMAC4hBN9NLzRWA9J2isKaCVtT5AsNNDIstAp ziRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :hmm_source_type:hmm_attache_num:hmm_source_ip; bh=SYRZ4uur9kNYX03HaBRnzbZnq/65B3fZg5U9oUL3L2U=; b=y2ykHW1TigzdxMhrqt3ohfKhnLsAY/LCjPisvJiIjCo0qUTJoYIjrr/IGEjs2PUwIC KI596l5QSgPosFcCfTzoCR5G/6FDpWStmnhHzsUDAd6dxTfThjGyUaHliLwPnAnE8v9n aHK8X0PkIrm+xXBSUeChHKjOBNc/+bW4pLkrKId1JIRTXIl14oeVXQUNpY98Xhgzhyhh SEZIagFKEkgvDLbMYxbAxF3h2bV04yOLz2SYP8PeLqj8o6f5bg+Yrvcnl3aLz8gqR3p6 8uD+RdmLS+wfbhft3mCuymVOEvckRGkfJPTs+D/aqUhQ2IEshr0uJazrv8Kd9OdxAySw BOYA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gz22-20020a170906f2d600b00973771bddcdsi6375346ejb.685.2023.06.12.20.14.08; Mon, 12 Jun 2023 20:14:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239676AbjFMDF0 (ORCPT + 99 others); Mon, 12 Jun 2023 23:05:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239404AbjFMDEM (ORCPT ); Mon, 12 Jun 2023 23:04:12 -0400 Received: from 189.cn (ptr.189.cn [183.61.185.102]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C46172108; Mon, 12 Jun 2023 20:03:07 -0700 (PDT) HMM_SOURCE_IP: 10.64.8.43:47948.1267835893 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP Received: from clientip-114.242.206.180 (unknown [10.64.8.43]) by 189.cn (HERMES) with SMTP id B628610033A; Tue, 13 Jun 2023 11:02:22 +0800 (CST) Received: from ([114.242.206.180]) by gateway-151646-dep-75648544bd-7vx9t with ESMTP id 2eb90189369545dd91f8f29cc5b53ba2 for bhelgaas@google.com; Tue, 13 Jun 2023 11:02:26 CST X-Transaction-ID: 2eb90189369545dd91f8f29cc5b53ba2 X-Real-From: 15330273260@189.cn X-Receive-IP: 114.242.206.180 X-MEDUSA-Status: 0 Sender: 15330273260@189.cn From: Sui Jingfeng <15330273260@189.cn> To: Bjorn Helgaas 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 , Alex Deucher , Christian Konig , Pan Xinhui , David Airlie , Daniel Vetter , Hawking Zhang , Mario Limonciello , Lijo Lazar , YiPeng Chai , Bokun Zhang , Likun Gao Subject: [PATCH v7 7/8] drm/amdgpu: Implement the is_boot_device callback function Date: Tue, 13 Jun 2023 11:01:50 +0800 Message-Id: <20230613030151.216625-8-15330273260@189.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230613030151.216625-1-15330273260@189.cn> References: <20230613030151.216625-1-15330273260@189.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,FROM_LOCAL_DIGITS, FROM_LOCAL_HEX,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 7a096f2d5c16..77624e8062d5 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -3560,6 +3560,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 * @@ -3960,7 +3969,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); -- 2.25.1