From patchwork Sun Jul 2 18:27:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 115121 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp90462vqx; Sun, 2 Jul 2023 11:29:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlETncF7DLdhTW9cI6c50a0hU1DczOxCI4N3J+6WdktgIoJbx6/H1uCJTumIE1Weprwj4xw/ X-Received: by 2002:a05:6a00:1f90:b0:675:8627:a291 with SMTP id bg16-20020a056a001f9000b006758627a291mr9642006pfb.3.1688322594324; Sun, 02 Jul 2023 11:29:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688322594; cv=none; d=google.com; s=arc-20160816; b=wigrxpYR5DBhyfI5QsOg4h+WkdL3sQJvXV6MTq+fTY2ayBqq4fnNealpbNwozmZ9oM 30I5RVPkS/ceGkjNVS+yQTKjVXJaGW6erlOG4Oi+HNb/D9MDaUiSMN6ye5aQYJ3AyykG N+jRXFJ/geLoMD2CEovD4gzvVLDIu+LPSGvbk9KkDi5Zx4HFHZnXUZhopSXuFe57NveR wlLEuqEhBRgSwUIUdtDaEnYnH8GBX2VpvXQ1fUGocLhKt1OLeqdUjoxQsv6mgAvYvzwG PhFTz7iUkse6ggqARllioVaiYEBMT2OXk/p83ZJ6ZZBoHEPgF/BNXFZqv2X/MVIr2uFZ Z1/A== 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 :dkim-signature; bh=btfhp53flz2znRJhVRVROxzr2+xJwf5jWKVzzdMQNCg=; fh=/dfiS5Lv3LlSQnY2o8NeqgR+mY3XBGJcD1eRnt20iig=; b=ethrEq89O9+d7U9fOsbYpEFIHsTIfV07x0lEWcaQe4szThxKpkQiyXxioIWh8YRgc9 lemmE8Tf70ugHOwpJ5j+6ejkjmcwZi7UYb+z3oOCR7KNy/4qc8uUioDlu42r2UVNqE5Y qaUMeo3NLK/s+4+2VJhSamuyO4Q0pMruhHD6Hve/9U+JqmIEaI1E3pl4h105jPAnGQfT U/ye6FqX92EFUJN8LFHbste1dWi57kVZfY4skogpVjkUpewtA+JvR/cKw91pbE6ph9Qm MiCi6YJOp7XNrGKYIbApjX1G/ytl0zBK+Th83KHl/XcMAYD8Z0qfpv3SH/1J9o5/CyRh mQqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=oQKi6ID1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cl11-20020a056a0032cb00b0067f4fd59b00si9748215pfb.260.2023.07.02.11.29.39; Sun, 02 Jul 2023 11:29:54 -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; dkim=pass header.i=@linux.dev header.s=key1 header.b=oQKi6ID1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229764AbjGBS2l (ORCPT + 99 others); Sun, 2 Jul 2023 14:28:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230010AbjGBS2h (ORCPT ); Sun, 2 Jul 2023 14:28:37 -0400 Received: from out-61.mta0.migadu.com (out-61.mta0.migadu.com [IPv6:2001:41d0:1004:224b::3d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF80D1B6 for ; Sun, 2 Jul 2023 11:28:29 -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=1688322507; 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=oQKi6ID1afguP4x/ojsnsDHQmXUzv98pprbJoD3+O0SU3KQeHD02lyeKnjI1XcQu3Pa5Yo KBMOMm5Ccwy6HtziwaVhZWyGV851AaNElUo1AcDBeEGL5hD9ef1eODvu1u4mvhKyY0fEBW O5N2ZIaf//ItxdDMSQ/3hAiJPgHsTbs= 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 Subject: [PATCH v2 4/6] drm/radeon: Implement the is_boot_device callback function Date: Mon, 3 Jul 2023 02:27:42 +0800 Message-Id: <20230702182744.755467-5-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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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?1770334553172137972?= X-GMAIL-MSGID: =?utf-8?q?1770334553172137972?= 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;