Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1695631imw; Tue, 5 Jul 2022 13:56:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sNsdQuWy41dqywWH0LMzPTbX5aV7NPm4ovf+RY2EGCpnSV6jcqTdUVkUidsVzz3ugDQg1o X-Received: by 2002:a17:90a:ea88:b0:1ef:94f6:834 with SMTP id h8-20020a17090aea8800b001ef94f60834mr8227931pjz.236.1657054591475; Tue, 05 Jul 2022 13:56:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657054591; cv=none; d=google.com; s=arc-20160816; b=lMMRqkYTGLv4WD8Glp5nxNjOJyNCFbb5FhQU23sYgRjHJ4LJef3XH2C5EPzVODz5tb 7RdYSp3gg0zQC8o/x4dsEVDGrMzfAm0mLfAZegb+PjLzFdeVTaAFbGXuoKo6IcT+2grJ K72qX7RBEyq/Z1R4ZTmIJDLVkOYFqo7zfPqXfAVCvElURP3cNJ3ec7q1hFzjK3TKbaZ3 HcCMaIMQAG7oXgAZSNO/i9KHCYzGHWbBCFu4mZMKnn4KgXQ4JsXbu1t95Vxf0DE3fc+k ZdF4Tz7SaPPElyiXmrKDJYapRMqhEvCUEjhNgYH+ZoIfM21BbYFz7RhBCLydFCIYkuEO uD9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date; bh=LWZ9M+gTr3hbHt6+JPR3qvNJ+A+N3bNGjAabWGOkaW4=; b=yHYMO1DtbbAvTHRVdCL0vR9Ms6ICwc/2qx8+//wbpjo4XCLzYIjdNiB8f+zowGUEjJ OU4XOpRjW43tb+9smKAk15oypXCu0i+Cx4G60wvq7oJHI7Em2hSWbgUvCYnUQ41tkR93 Pm9UJrtycTEWtdRkqlrgZQ6E9bhGr6Szvh7jmbWXGPqczQ9xfo1qSzbomyri9F4iD0WE AUEYdWJnkYhP4voG3VNip3yJ0JcJrQGDKB8H861wlbzjwbH/odSHwLk0oopykxwxv819 IL8qVWM2CoB8egKzxXRRjz6z9EfmA/KgghOk3lihLvdt7IttVHqwHgSK4N68bonGutHs Jxww== 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 f125-20020a636a83000000b00411442a950fsi34590857pgc.726.2022.07.05.13.56.19; Tue, 05 Jul 2022 13:56:31 -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 S231382AbiGEUmh (ORCPT + 99 others); Tue, 5 Jul 2022 16:42:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229710AbiGEUmg (ORCPT ); Tue, 5 Jul 2022 16:42:36 -0400 Received: from mx2.absolutedigital.net (mx2.absolutedigital.net [50.242.207.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 219D2120AE; Tue, 5 Jul 2022 13:42:35 -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 265Kg5Z7028293 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Tue, 5 Jul 2022 16:42:05 -0400 Received: from localhost (localhost [127.0.0.1]) by lancer.cnet.absolutedigital.net (8.17.1/8.17.1) with ESMTPS id 265KgHAl008523 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 5 Jul 2022 16:42:18 -0400 Date: Tue, 5 Jul 2022 16:42:17 -0400 (EDT) From: Cal Peake To: Alex Williamson cc: Bjorn Helgaas , Randy Dunlap , Kernel Mailing List , Bjorn Helgaas , Huacai Chen , linux-pci@vger.kernel.org, Cornelia Huck , kvm@vger.kernel.org Subject: Re: [PATCHv2] vgaarb: Add module param to allow for choosing the boot VGA device In-Reply-To: <20220705101535.569f5cac.alex.williamson@redhat.com> Message-ID: <93acb310-ede4-cd9d-e470-2375971a451@absolutedigital.net> References: <8498ea9f-2ba9-b5da-7dc4-1588363f1b62@absolutedigital.net> <20220704213829.GA16883@bhelgaas> <20220705101535.569f5cac.alex.williamson@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, 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 On Tue, 5 Jul 2022, Alex Williamson wrote: > > > + ret = sscanf(input, "%x:%x.%x", &bus, &dev, &func); > > > + if (ret != 3) { > > > + pr_warn("Improperly formatted PCI ID: %s\n", input); > > > + return; > > > + } > > See pci_dev_str_match() Hi Alex, thanks for the feedback. I'll add this if we wind up going with some version of my patch. > > > + if (boot_vga && boot_vga->is_chosen_one) > > > + return false; > > > + > > > + if (bootdev_id == PCI_DEVID(pdev->bus->number, pdev->devfn)) { > > > + vgadev->is_chosen_one = true; > > > + return true; > > > + } > > This seems too simplistic, for example PCI code determines whether the > ROM is a shadow ROM at 0xc0000 based on whether it's the > vga_default_device() where that default device is set in > vga_arbiter_add_pci_device() based on the value returned by > this vga_is_boot_device() function. A user wishing to specify the boot > VGA device doesn't magically make that device's ROM shadowed into this > location. > I think I understand what you're saying. We're not telling the system what the boot device is, it's telling us? > I also don't see how this actually enables VGA routing to the user > selected device, where we generally expect the boot device already has > this enabled. > > Furthermore, what's the initialization state of the selected device, if > it has not had its option ROM executed, is it necessarily in a state to > accept VGA commands? If we're changing the default VGA device, are we > fully uncoupling from any firmware notions of the console device? > Thanks, Unfortunately, I'm not the best qualified to answer these questions. My understanding is mostly surface-level until I start digging into the code. I think the answer to most of them though might be that the UEFI firmware initializes both cards. During POST, I do get output on both GPUs. One gets the static BIOS text (Copyright AMI etc.) -- this is the one selected as boot device -- and the other gets the POST-code counting up. Once the firmware hands off to the bootloader, whichever GPU has the active display (both GPUs go to the same display, the input source gets switched depending on whether I'm using the host or the VM) is where the bootloader output is. When the bootloader hands off to the kernel, the boot device chosen by the firmware gets the kernel output. If that's the host GPU, then everything is fine. If that's the VM GPU, then it gets the kernel output until the vfio-pci driver loads and then all output stops. Back on the host GPU, the screen is black until the X server spawns[1] but I get no VTs. With my patch, telling the arbiter that the host GPU is always the boot device results in everything just working. With all that said, if you feel this isn't the right way to go, do you have any thoughts on what would be a better path to try? Thanks, -- Cal Peake [1] I said in a previous email that this only happened when I set VGA_ARB_MAX_GPUS=1, but after doing some more testing just now, it seems I was wrong and the X server was just taking longer than expected to load.