Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1145798imw; Tue, 5 Jul 2022 04:41:44 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sHnjFf2ShrXFFzkMPSB48/tCOuyd4qilzMUORwwtvlVjNwh/zp+HgbuXPFYZizRCUtO5u1 X-Received: by 2002:a17:90b:1206:b0:1ef:7bcd:e8d1 with SMTP id gl6-20020a17090b120600b001ef7bcde8d1mr18754050pjb.156.1657021304731; Tue, 05 Jul 2022 04:41:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657021304; cv=none; d=google.com; s=arc-20160816; b=V1J8Sye+AfKHyh00TpFbluG8l/mySNN9zubm6kA2eOmJT0F1jVq2D0tweHB6I7hi7a rqybi5a49EJ5uGfDhUFyIs6fScKlsqmZhRZHNv3a4grAQ4dhG2zac2Wj3KgBlEK6I2iq QPvinKzU9LvlP5ioCDJwSBXdemJsZWtw0HXuC34d2D73A+G/KTSc2o4WW1rALXDmUlzG a41RcfOGegXubGUkzo14kawEkLN1j8ptb0EjKdyxOCHmEnsnU9Eo9OxbLOjKDZZ2ExQK +fPbEjcAiuaeqYV6yQMx/UGEVzdkwZW05E1lec5m6VKyksEGmBRlV/jCAkLhHNfgYdAe lQQw== 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 :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=8pvPoWqIvsWl8w+U7M/aIkzJ6IsvvChEXLW+2arMSpA=; b=DLnS1fY9lGOU9HqqyHdd8ira8wNhSbzuVnZ6UQsyYURh7x4pgzbxPLFt/537AFHmgx JiE82AYc16G4nXQ2ydRIlt8+oVdHREj7Ko2Njditkj5Md6s7TMq1rGuzyRaHVefkPGRO cwBOi10kjD2GxRaqSncp7/eygvAbUyq+G1vDUHbpOcYVhSqVWgfkLk+/n2j/TvU+gxw5 PkecGN/gaz8lya9B0kQLqFYiBs1dpj3kH1TRC8h/Di5ofUyqNmEzjdETAyCGVmkWFxTy 5NDp4tAarL+D5lotGCxqmS5EYfPu6TLnNAsgryZjNr5AsAxSIdOc/O/BnhR9Us4bFolC hefQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=POHx8hwJ; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c12-20020a655a8c000000b0040cf77ea09esi15240954pgt.555.2022.07.05.04.41.31; Tue, 05 Jul 2022 04:41:44 -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=@redhat.com header.s=mimecast20190719 header.b=POHx8hwJ; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230360AbiGELjj (ORCPT + 99 others); Tue, 5 Jul 2022 07:39:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229575AbiGELjg (ORCPT ); Tue, 5 Jul 2022 07:39:36 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 895DE13FA3 for ; Tue, 5 Jul 2022 04:39:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657021174; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8pvPoWqIvsWl8w+U7M/aIkzJ6IsvvChEXLW+2arMSpA=; b=POHx8hwJKryFHEE3EkiGctr28M/hwyoUEgmUmSXQRDETq2i+8dRYgEfBwHqjXk/pJNbeBV E3SagL5r2xetGA8kfUtM31lcTDjZY3YetmQYKQD53yIqnp0etRKtnOg6/76wV/P341LUhV WzKoDQfxhEv9U615G0m8uUyt1nrFaLk= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-82-3mnC9-PaOHKV0kigRXdAEg-1; Tue, 05 Jul 2022 07:39:33 -0400 X-MC-Unique: 3mnC9-PaOHKV0kigRXdAEg-1 Received: by mail-wm1-f70.google.com with SMTP id h125-20020a1c2183000000b003a0374f1eb8so8728407wmh.8 for ; Tue, 05 Jul 2022 04:39:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=8pvPoWqIvsWl8w+U7M/aIkzJ6IsvvChEXLW+2arMSpA=; b=PoedQBPxdoILnlKiTdzoNYYiPNM33j0+IoEybRk1GOhOEOSFs7bJFuuw68k/tPx6hE +a972QNj2FhM0mo6jxTHss/+3CYKcqjr4Sk5uDlfGCz3n5WwM4m5IfLawH36ZcBeRBn4 1UBxtvrNpBro1xJqJaMONyIyei7arBToVwoZ6T+PanQjoBS4QTE2L8QpPPs9m9oh9CJh AnDr+oaUSrZnyhF59BLqeI5rqrAVzKl4Pk7Qwl12c3bIoTarXg6sYRjFtW2Nh+xs/iRX kiYf2R8GF97ZYIEn6EpvypncHxCVohmhA3mCLg93HBqM042Br+yTxeoBK0B5PqobRsC2 I3yQ== X-Gm-Message-State: AJIora/hlmRzWJI/xEmx2PWZLfFKdhamqVQ2YbgJlumPFMPX8YPhDd4a o5klra0NURyPQ2Ay7BDQdcBpjT1D6NrMRWj6VzSzgKGToh2PPXziT8fniTyCsBQtPFr1plF690O CISYYVRnLduFXLzOhU7Ka24n7 X-Received: by 2002:a05:6000:2c6:b0:21b:ad25:9c1b with SMTP id o6-20020a05600002c600b0021bad259c1bmr32896926wry.391.1657021172233; Tue, 05 Jul 2022 04:39:32 -0700 (PDT) X-Received: by 2002:a05:6000:2c6:b0:21b:ad25:9c1b with SMTP id o6-20020a05600002c600b0021bad259c1bmr32896901wry.391.1657021172014; Tue, 05 Jul 2022 04:39:32 -0700 (PDT) Received: from [10.35.4.238] (bzq-82-81-161-50.red.bezeqint.net. [82.81.161.50]) by smtp.gmail.com with ESMTPSA id l3-20020a1c7903000000b003a04962ad3esm19548302wme.31.2022.07.05.04.39.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jul 2022 04:39:31 -0700 (PDT) Message-ID: <86df559c732a796b2e3da0136a643a212826229f.camel@redhat.com> Subject: Re: [PATCHv2] vgaarb: Add module param to allow for choosing the boot VGA device From: Maxim Levitsky To: Cal Peake , Bjorn Helgaas Cc: Randy Dunlap , Kernel Mailing List , Bjorn Helgaas , Huacai Chen , linux-pci@vger.kernel.org, Alex Williamson , Cornelia Huck , kvm@vger.kernel.org Date: Tue, 05 Jul 2022 14:39:29 +0300 In-Reply-To: <17b4da8c-8847-857e-21ca-b8a53446c362@absolutedigital.net> References: <20220704213829.GA16883@bhelgaas> <17b4da8c-8847-857e-21ca-b8a53446c362@absolutedigital.net> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.40.4 (3.40.4-5.fc34) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,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 Mon, 2022-07-04 at 19:07 -0400, Cal Peake wrote: > On Mon, 4 Jul 2022, Bjorn Helgaas wrote: > > > I cc'd KVM folks in case they have anything to add here because I'm > > not a VFIO passthrough expert. > > > > It sounds like the problem occurs when the VFIO driver claims the GPU. > > I assume that happens after boot, when setting up for the virtual > > machine? > > No, this is during boot, long before a VM is launched. As you can kinda > see from these lines from early on in the boot process: > > [   22.066610] amdgpu 0000:0e:00.0: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=none:owns=none > [   25.726469] vfio-pci 0000:0f:00.0: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=io+mem:owns=none > > The vfio-pci driver claims the device like it was a typical GPU driver, > but since it isn't, the display output functionality of the card stops > because part of the vfio-pci driver's job is to make sure the card is in > an unused, preferably pristine-as-possible state for when the VM takes > control of it. > > If we go back earlier in the boot process, you'll see that second line again: > > [    9.226635] vfio-pci 0000:0f:00.0: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=io+mem:owns=none > [    9.238385] vfio_pci: add [10de:1f06[ffffffff:ffffffff]] class 0x000000/00000000 > [    9.251529] vfio_pci: add [10de:10f9[ffffffff:ffffffff]] class 0x000000/00000000 > [    9.264328] vfio_pci: add [10de:1ada[ffffffff:ffffffff]] class 0x000000/00000000 > [    9.277162] vfio_pci: add [10de:1adb[ffffffff:ffffffff]] class 0x000000/00000000 > > If that device is the one selected by the arbiter as boot device, then > that is the point where display output stops and everything goes to black. > > >  If so, is there a way to avoid the problem at run-time so the admin > > doesn't have to decide at boot-time which GPU will be passed through to > > a VM? > > With the way that many people like me run this kind of setup, the > passthrough GPU gets reserved at boot-time anyway with the passing of a > line like: > > vfio_pci.ids=10de:1f06,10de:10f9,10de:1ada,10de:1adb > > on the kernel command-line from the bootloader. Doing a similar > reservation for the host GPU with something like 'vgaarb.bootdev=0e:00.0' > alongside it should be no big deal to anyone running a setup like this. > > You can bind/unbind devices to the vfio-pci driver at run-time using > sysfs[1], but as far as I can tell, there is no way to change the boot VGA > device at run-time. > > >  Is it possible or desirable to pass through GPU A to VM A, then after > > VM A exits, pass through GPU B to VM B? > > Yeah, there are many ways one can run this setup. Some run with a single > GPU that gets passed-through and the host is headless. There's probably > some with more than two GPUs with multiple VMs each getting their own. > > The setup I'm running is pretty common: dedicated GPU for the host > (doesn't need to be anything special, just needs to handle workstation > duties) and a dedicated GPU for a Windows VM for gaming (something quite > powerful for those high FPS :-) > > As you can see, statically assigning the devices ahead of time is okay. > The real problem (for me anyway) is there's no way in the UEFI/BIOS to > tell the firmware which device should be used for boot. Sometimes it picks > the first GPU, sometimes the second. If if picks wrong, I get an unusable > system because the VGA arbiter deems the GPU selected by the firmware to > be the best choice for boot VGA device. > My 0.2 semi unrelated cents: On my desktop system I have two GPUS (AMD workstation GPU and a NVIDIA's gpu),  I sometimes use each of them (or even both) with VFIO, But regardless of VFIO, I sometimes use one and sometimes another as my main GPU (I have all displays connected to each GPU, its quite complex setup with lot of cables and HDMI switches, but somehow it is actually quite robust) Choosing boot GPU would be nice to have. On my system I setup it in such way that AMD GPU gets to be the boot GPU (I don't remember if I blacklisted the nvidia driver or something for that), and I have a script to dynamicallly swith them prior to starting X if in a config file I created, I specified that I want the nvidia GPU to be the default. So this is a use case which doesn't involve VFIO. Best regards, Maxim Levitsky