From patchwork Tue Jun 13 03:01:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng <15330273260@189.cn> X-Patchwork-Id: 107039 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp273339vqr; Mon, 12 Jun 2023 20:12:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6tMIfAMNTjEXqTT9P6YUCKe4EIQYM6dgzo3mmm6wPQrZ2MNp0XoQA4HXAR62qK+NdHgd19 X-Received: by 2002:a2e:87cd:0:b0:2ac:66c8:3c4b with SMTP id v13-20020a2e87cd000000b002ac66c83c4bmr3465725ljj.11.1686625961423; Mon, 12 Jun 2023 20:12:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686625961; cv=none; d=google.com; s=arc-20160816; b=j9u9aSZ3jkU09+6ALmwvnMy6wbhDP8OGDgwBPPawPWuc/p1FXoZuPCm57+bqnB1itO LOimHjxoyXOLfXXZnmoF4nT6xrMoXElQuixuE1c+kKdaWGFP6w4+LI0xfqnwVN4xEreG oMakP3O69QxwARu5YQIscAgr8fRySrPWcavxDiQ1M2Md7mRdnOXslLe67MBO1Uacg26V IoMIcMW2qcoPvUzidV1zEXCWBkgs3zTmsWeLxzkd5Ew/qkfk7bn3Si0/H50L6UzGmkFF t75o5qI0k+ytI8GkOhoGUpJLD9Y4cQotxXXdBT9wCeVGnUAi91IhxNrlejE2mSiNUSHd pxjA== 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=btfhp53flz2znRJhVRVROxzr2+xJwf5jWKVzzdMQNCg=; b=AZmPjcXDdbdj4NvW10bWwndRbt87OOaehnaYaGsjVa9flGaKLF+vKq5cHuj/ZibMxi kTBMVRfJ+btKSVSDO0G3r3EQK+qmJqJMac+ryfOvGuF9CIY21JwEr2Di0/68uPpKhMY8 uL1j6Np2PbGWfg1nHsETKyetLcyv8K+yYmd6xdQRbBP+xeOYsOqnVSBaFxPzoq0CGkvZ mhd+J2y/ZRF2pSNZL1CYonEaLixCqO0xZ5GmN09OFrrFPE60ycXIxPD5xnQfzeiy+8we 2RDNO0rFfXAdhJCI5aADMIH+jUmdYQ5e9BrGBvD+LPX2lz2q9qGBthUY0ybrp6JzCp4G dIyQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l12-20020aa7d94c000000b00515406c4e1csi2486628eds.439.2023.06.12.20.12.16; Mon, 12 Jun 2023 20:12:41 -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 S239671AbjFMDFU (ORCPT + 99 others); Mon, 12 Jun 2023 23:05:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239386AbjFMDEG (ORCPT ); Mon, 12 Jun 2023 23:04:06 -0400 Received: from 189.cn (ptr.189.cn [183.61.185.102]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C4AE8210A; 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 2B88B1002F4; Tue, 13 Jun 2023 11:02:26 +0800 (CST) Received: from ([114.242.206.180]) by gateway-151646-dep-75648544bd-7vx9t with ESMTP id 9b21112c8a744a598e4680c08d0d9487 for bhelgaas@google.com; Tue, 13 Jun 2023 11:02:30 CST X-Transaction-ID: 9b21112c8a744a598e4680c08d0d9487 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 Subject: [PATCH v7 8/8] drm/radeon: Implement the is_boot_device callback function Date: Tue, 13 Jun 2023 11:01:51 +0800 Message-Id: <20230613030151.216625-9-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768555503702675216?= X-GMAIL-MSGID: =?utf-8?q?1768555503702675216?= 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;