linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sui Jingfeng <sui.jingfeng@linux.dev>
To: Bjorn Helgaas <bhelgaas@google.com>
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,
	Sui Jingfeng <suijingfeng@loongson.cn>
Subject: [RFC,drm-misc-next v4 2/9] drm/nouveau: Implement .be_primary() callback
Date: Tue,  5 Sep 2023 03:57:17 +0800	[thread overview]
Message-ID: <20230904195724.633404-3-sui.jingfeng@linux.dev> (raw)
In-Reply-To: <20230904195724.633404-1-sui.jingfeng@linux.dev>

From: Sui Jingfeng <suijingfeng@loongson.cn>

On a machine with multiple GPUs, a Linux user has no control over which one
is primary at boot time. This patch tries to solve the mentioned problem by
implementing the .be_primary() callback. VGAARB will call back to Nouveau
when the drm/nouveau gets loaded successfully.

Pass nouveau.modeset=10 on the kernel cmd line if you really want the
device bound by Nouveau to be the primary video adapter. This overrides
whatever boot device selected by VGAARB.

Signed-off-by: Sui Jingfeng <suijingfeng@loongson.cn>
---
 drivers/gpu/drm/nouveau/nouveau_vga.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
index 162b4f4676c7..4242188667e2 100644
--- a/drivers/gpu/drm/nouveau/nouveau_vga.c
+++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
@@ -80,6 +80,15 @@ nouveau_switcheroo_ops = {
 	.can_switch = nouveau_switcheroo_can_switch,
 };
 
+static bool
+nouveau_want_to_be_primary(struct pci_dev *pdev)
+{
+	if (nouveau_modeset == 10)
+		return true;
+
+	return false;
+}
+
 void
 nouveau_vga_init(struct nouveau_drm *drm)
 {
@@ -92,7 +101,7 @@ nouveau_vga_init(struct nouveau_drm *drm)
 		return;
 	pdev = to_pci_dev(dev->dev);
 
-	vga_client_register(pdev, nouveau_vga_set_decode, NULL);
+	vga_client_register(pdev, nouveau_vga_set_decode, nouveau_want_to_be_primary);
 
 	/* don't register Thunderbolt eGPU with vga_switcheroo */
 	if (pci_is_thunderbolt_attached(pdev))
-- 
2.34.1


  parent reply	other threads:[~2023-09-04 19:57 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-04 19:57 [RFC,drm-misc-next v4 0/9] PCI/VGA: Allowing the user to select the primary video adapter at boot time Sui Jingfeng
2023-09-04 19:57 ` [RFC,drm-misc-next v4 1/9] " Sui Jingfeng
2023-09-04 19:57 ` Sui Jingfeng [this message]
2023-09-04 19:57 ` [RFC,drm-misc-next v4 3/9] drm/radeon: Implement .be_primary() callback Sui Jingfeng
2023-09-05  5:50   ` Christian König
2023-09-05 17:24     ` suijingfeng
2023-09-06 16:00       ` Alex Deucher
2023-09-07  1:40         ` Sui Jingfeng
2023-09-04 19:57 ` [RFC,drm-misc-next v4 4/9] drm/amdgpu: " Sui Jingfeng
2023-09-04 19:57 ` [RFC,drm-misc-next v4 5/9] drm/i915: " Sui Jingfeng
2023-09-04 19:57 ` [RFC,drm-misc-next v4 6/9] drm/loongson: " Sui Jingfeng
2023-09-04 19:57 ` [RFC,drm-misc-next v4 7/9] drm/ast: Register as a VGA client by calling vga_client_register() Sui Jingfeng
2023-09-04 19:57 ` [RFC,drm-misc-next v4 8/9] drm/hibmc: " Sui Jingfeng
2023-09-04 19:57 ` [RFC,drm-misc-next v4 9/9] drm/gma500: " Sui Jingfeng
2023-09-05 10:38 ` [RFC, drm-misc-next v4 0/9] PCI/VGA: Allowing the user to select the primary video adapter at boot time Jani Nikula
2023-09-05 13:28   ` Christian König
2023-09-05 14:28     ` Sui Jingfeng
2023-09-06  6:47       ` Christian König
2023-09-05 10:45 ` [Nouveau] " Thomas Zimmermann
2023-09-05 13:30   ` suijingfeng
2023-09-05 15:05     ` Thomas Zimmermann
2023-09-06  2:14       ` suijingfeng
2023-09-06  7:00         ` Thomas Zimmermann
2023-09-06  2:34       ` suijingfeng
2023-09-06  7:18         ` Thomas Zimmermann
2023-09-06  3:08       ` suijingfeng
2023-09-06  7:46         ` Thomas Zimmermann
2023-09-06  4:14       ` Sui Jingfeng
2023-09-06  6:45     ` Christian König
2023-09-06  9:08       ` suijingfeng
2023-09-06  9:40         ` Christian König
2023-09-07  2:30           ` Sui Jingfeng
2023-09-07  9:08             ` Christian König
2023-09-07 12:32               ` suijingfeng
2023-09-07 12:43                 ` Christian König
2023-09-07 15:26                   ` suijingfeng
2023-09-07 15:32                     ` Christian König
2023-09-07 16:33               ` suijingfeng
2023-09-08  6:59                 ` Christian König
2023-09-06 10:31       ` Sui Jingfeng
2023-09-06 10:50         ` Christian König
2023-09-05 10:49 ` Thomas Zimmermann
2023-09-05 15:59   ` suijingfeng
2023-09-06  8:05     ` Thomas Zimmermann
2023-09-06  9:48       ` suijingfeng
2023-09-06 11:06         ` Thomas Zimmermann
2023-09-07  9:43         ` Jani Nikula
2023-09-05 14:52 ` Alex Williamson
2023-09-05 16:21   ` suijingfeng
2023-09-05 16:39     ` Alex Williamson
2023-09-06  3:51   ` Sui Jingfeng
2023-09-06 19:29     ` Alex Williamson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230904195724.633404-3-sui.jingfeng@linux.dev \
    --to=sui.jingfeng@linux.dev \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=bhelgaas@google.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=nouveau@lists.freedesktop.org \
    --cc=suijingfeng@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).