From nobody Sun Apr 19 10:43:39 2026 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 D3EC9CCA473 for ; Sun, 3 Jul 2022 04:35:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231693AbiGCEfY (ORCPT ); Sun, 3 Jul 2022 00:35:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229994AbiGCEfV (ORCPT ); Sun, 3 Jul 2022 00:35:21 -0400 X-Greylist: delayed 767 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sat, 02 Jul 2022 21:35:20 PDT Received: from mx2.absolutedigital.net (mx2.absolutedigital.net [50.242.207.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A83D265F2 for ; Sat, 2 Jul 2022 21:35:20 -0700 (PDT) Received: from lancer.cnet.absolutedigital.net (lancer.cnet.absolutedigital.net [10.7.5.10]) by luxor.inet.absolutedigital.net (8.14.4/8.14.4) with ESMTP id 2634MI5g014737 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Sun, 3 Jul 2022 00:22:19 -0400 Received: from localhost (localhost [127.0.0.1]) by lancer.cnet.absolutedigital.net (8.17.1/8.17.1) with ESMTPS id 2634MIq1005330 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sun, 3 Jul 2022 00:22:18 -0400 Date: Sun, 3 Jul 2022 00:22:18 -0400 (EDT) From: Cal Peake To: Kernel Mailing List cc: Bjorn Helgaas , Huacai Chen Subject: [RFC] vgaarb: Add a module parm to use the first VGA device for boot Message-ID: <5e3f182f-7b6e-5c7f-d9a9-7cd1417cc38d@absolutedigital.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Hi, I have a dual GPU system with the GPU in the first CPU PCIe slot for the=20 host and the GPU in the second CPU PCIe slot being passed through to a=20 virtual machine. Currently, the VGA arbiter enumerates through all VGA devices in the order=20 that they appear in on the bus with the last one ultimately getting the=20 assignment for boot device. This is a problem because once the VFIO PCI driver claims the second GPU,=20 all display output is lost -- just empty black screens on both cards. Setting VGA_ARB_MAX_GPUS to 1 helps a little: the X server will initialize=20 on the first GPU like it should, but there's no VTs to be found (i.e.=20 Alt-F1/F2/etc), just more black screens. Below is an attempt at a fix by creating a kernel param to have the VGA=20 arbiter use the first VGA device it finds for the boot device and then=20 subsequently ignore the rest for this task. --=20 Cal Peake --- ./drivers/pci/vgaarb.c 2022-07-02 10:44:56.000000000 -0400 +++ ./drivers/pci/vgaarb.c 2022-07-02 22:55:24.291822548 -0400 @@ -35,6 +35,10 @@ =20 #include =20 +static bool use_first; +module_param(use_first, bool, 0); +MODULE_PARM_DESC(force, "Set to one to use the first VGA device for boot"); + static void vga_arbiter_notify_clients(void); /* * We keep a list of all vga devices in the system to speed @@ -815,7 +819,8 @@ static bool vga_arbiter_add_pci_device(s bus =3D bus->parent; } =20 - if (vga_is_boot_device(vgadev)) { + if (vga_is_boot_device(vgadev) && + (!use_first || (use_first && !vga_default_device()))) { vgaarb_info(&pdev->dev, "setting as boot VGA device%s\n", vga_default_device() ? " (overriding previous)" : "");