unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: "Nick Zalutskiy" <nick@const.fun>
To: 55907@debbugs.gnu.org
Subject: bug#55907: VFIO kernel module fails to capture PCI device
Date: Sat, 11 Jun 2022 09:40:18 -0400	[thread overview]
Message-ID: <ed5747f5-eaa6-4ae5-8434-d9db467079b5@www.fastmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2120 bytes --]

Hello all,

I am trying to capture my graphics card at initrd, using vfio, to later pass it through to a virtual machine. Judging by dmesg, the VFIO module does load early, however, the card is not captured at that point and the amdgpu driver is later loaded instead.

This is what I have in my `operating-system` config:

> (kernel-arguments '("iommu=pt" "vfio-pci.ids=1002:73bf"))
>   (initrd-modules (cons* "vfio_pci" "vfio" "vfio_iommu_type1" "vfio_virqfd" %base-initrd-modules))

There are two video cards in the system, both AMD, but different models. The video card of interest is in a separate IOMMU group and the <vendor id>:<device id> combination is correct for my machine.

Best I can tell, vfio-pci.ids argument is not propagated to the module by initramfs. See the following:

Searching online I came up against a GitHub issue for a different initramfs generator that exhibited the same symptoms: VFIO module was loaded, kernel arguments were correct, yet the card was not captured by the vfio driver. The maintainer there did a great job tracking down and fixing the issue and came up with this insight https://github.com/anatol/booster/issues/20#issuecomment-808956316

> After reading kmod code I found that kernel does not use cmdline params for loadable modules. It was surprising for me. Instead it is expected that userspace handles cmdline parsing and provides required module params explicitly.

Another way to attach the correct driver to the gpu is to run a script at initrd, which I don't know how to accomplish with Guix. This approach has the advantage of working with two identical video cards (or disks, etc) See https://wiki.archlinux.org/title/PCI_passthrough_via_OVMF#Using_identical_guest_and_host_GPUs

I tried following the kernel docs to rebind a different driver after boot, but I believe this doesn't work for video cards, and hasn't worked for me.

Any help is greatly appreciated!

Links:
Kernel docs for vfio
https://www.kernel.org/doc/html/latest/driver-api/vfio.html

Arch guide for GPU passthrough
https://wiki.archlinux.org/title/PCI_passthrough_via_OVMF

Thank you!

-Nick

[-- Attachment #2: Type: text/html, Size: 3207 bytes --]

             reply	other threads:[~2022-06-11 13:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-11 13:40 Nick Zalutskiy [this message]
2023-09-08  8:43 ` bug#55907: VFIO kernel module fails to capture PCI device Lars Rustand

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

  List information: https://guix.gnu.org/

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

  git send-email \
    --in-reply-to=ed5747f5-eaa6-4ae5-8434-d9db467079b5@www.fastmail.com \
    --to=nick@const.fun \
    --cc=55907@debbugs.gnu.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).