<div dir="ltr">Sorry about delay reply.<div><br></div><div>Same reason as Kyle. We have 2 NICs which had same VID:PID. And want to passthrough one of them into VM.</div><div>The script can use, but need to unbind device from NIC driver first as premise.</div><div><br></div><div><font face="monospace, monospace">echo $DEV > /sys/bus/pci/devices/$DEV/unbind</font></div><div><font face="monospace, monospace">echo $DEV > /sys/bus/pci/drivers/vfio-pci/new_id</font></div><div>(Can't remember the second command path.)<br></div><div><br></div><div><br></div><div>if using</div><div><br></div><div><font face="monospace, monospace">echo vfio-pci > /sys/bus/pci/devices/$DEV/driver_override </font></div><div><br></div><div>lspci -k will shows NIC driver still occupied this NIC.</div><div><br></div><div><br></div><div>I'ii try Kyle's method but need to think about how to transfer this method for Ubuntu (Debian)...</div></div><div class="gmail_extra"><br><div class="gmail_quote">2018-05-18 1:43 GMT+08:00 Alex Williamson <span dir="ltr"><<a href="mailto:alex.williamson@redhat.com" target="_blank">alex.williamson@redhat.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Thu, 17 May 2018 13:12:07 -0400<br>
Kyle Marek <<a href="mailto:psppsn96@gmail.com">psppsn96@gmail.com</a>> wrote:<br>
<br>
> On 05/17/2018 10:27 AM, Alex Williamson wrote:<br>
> > On Thu, 17 May 2018 12:56:49 +0800<br>
> > Eddie Yen <<a href="mailto:missile0407@gmail.com">missile0407@gmail.com</a>> wrote:<br>
> >  <br>
> >> Hi everyone,<br>
> >><br>
> >> IME, you can set VID:PID by adding "options vfio-pci" into conf file and<br>
> >> put at modprobe.d<br>
> >> So that VFIO can take over the device that had same VID:PID when boot.<br>
> >><br>
> >> But how can I set this option by using PCI Address without using override<br>
> >> script?  <br>
> > There's no such module option, what's wrong with a script?  Part of the<br>
> > reason we don't have such a module option is that PCI addresses are not<br>
> > persistent, they can change based on devices added or removed, or even<br>
> > motherboard BIOS updates.  Userspace has more flexibility for managing<br>
> > this and is fully able to do so via initrd scripts and modprobe.d.<br>
> > Thanks,<br>
> ><br>
> > Alex  <br>
> <br>
> That's a good point.<br>
> <br>
> However, I had an environment where I needed to pass through one of two<br>
> devices with the same PCI IDs. I accomplished it with an install command<br>
> in my modprobe config.<br>
> <br>
> I can probably make this look at other factors before overriding the<br>
> driver, but the following config might work well enough if the PCI IDs<br>
> don't change:<br>
> <br>
> # For each PCI device listed in the for-loop, override their assigned driver<br>
> # to vfio-pci, for usage with PCI-passthrough.<br>
> #<br>
> # Please make sure to include vfio-pci in the initrd, or some other modules<br>
> # will likely claim the devices first. This can be done on systems that use<br>
> # initramfs-tools by adding "vfio-pci" to /etc/initramfs-tools/modules<br>
> install vfio-pci for dev in 0000:03:00.0 0000:03:00.1; do echo vfio-pci > "/sys/bus/pci/devices/$dev/<wbr>driver_override"; done; /sbin/modprobe --ignore-install vfio-pci $CMDLINE_OPTS<br>
> <br>
> # Load vfio-pci before some other drivers so they don't claim devices first.<br>
> # The pre-drm line should handle all graphics drivers.<br>
> softdep snd_hda_intel pre: vfio-pci<br>
> softdep drm pre: vfio-pci<br>
> <br>
> <br>
> This worked well for me in dracut and initramfs-tools initrds with the<br>
> vfio-pci module included.<br>
<br>
</div></div>Yes, this is a good demonstration of how userspace can easily<br>
accomplish this through modprobe.d softdeps and custom install<br>
options.  A more persistence focused version of the above might do the<br>
same knowing that we're looking for all devices device downstream of<br>
the root port at 0000:00:01.0, and would look something like:<br>
<br>
install vfio-pci for dev in $(find /sys/devices/pci0000:00/0000:<wbr>00:01.0/<br>
-maxdepth 1 -mindepth 1 -type d -name "????:??:??.?"); do echo vfio-pci > $dev/driver_override; done; modprobe --ignore-install...<br>
<br>
or even<br>
<br>
for override in $(find /sys/devices/pci0000:00/0000:<wbr>00:01.0/ -mindepth<br>
2 -name driver_override); do echo vfio-pci > $override; done...<br>
<br>
There are countless ways to do this, including ways that take advantage<br>
of PCI slots information provided through ACPI if the system supports<br>
it.  Thanks,<br>
<br>
Alex<br>
</blockquote></div><br></div>