# bind kernel driver to only one of two identical pieces of HW

## Atom2

Hi guys,

Anybody knows how to restrict loading of a kernel device driver to only one of many (in my case two) identical pieces of PCIe cards installed in the system? To be more specific, I have two identical SAS controllers installed in my server. The first SAS controller is used to boot the system thus the driver for the card must be built into the kernel.

Now the built-in driver should however be restricted to only bind to the boot PCIe SAS device and not touch the second (identical) PCIe device. This second device will then be used to be passed through to a virtual machine once the system is up. Clearly the two devices can be distinguished by their unique <domain>:<bus>:<device>:<func> data displayed by lspci. I have however not found any way of providing this data to the in-kernel driver.

The kernel driver btw is the mpt3sas driver used for LSI cards.

Any insight into this would be appreciated.

Thanks Atom2

----------

## R0b0t1

https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF#Using_identical_guest_and_host_GPUs

You can pass a device through using bus address.

----------

## Atom2

 *R0b0t1 wrote:*   

> https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF#Using_identical_guest_and_host_GPUs
> 
> You can pass a device through using bus address.

 Thanks for the pointer, it was an interesting read, albeit mainly limited to GPUs for the relevant question. If I have correctly understood this, it would also require the driver to be available as a loadable kernel module and the BIOS of the card to support UEFI - both of which does not work/is not available with my SATA/SAS controller the system is booted from.

The passthrough as such is something I do know how to do (i.e. using the bus address as listed by lspci).

Thanls Atom2

----------

## R0b0t1

 *Atom2 wrote:*   

>  *R0b0t1 wrote:*   https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF#Using_identical_guest_and_host_GPUs
> 
> You can pass a device through using bus address. Thanks for the pointer, it was an interesting read, albeit mainly limited to GPUs for the relevant question. If I have correctly understood this, it would also require the driver to be available as a loadable kernel module and the BIOS of the card to support UEFI - both of which does not work/is not available with my SATA/SAS controller the system is booted from.
> 
> The passthrough as such is something I do know how to do (i.e. using the bus address as listed by lspci).
> ...

 

It is specific to GPUs but I was hoping the instructions would generalize well; you might refer to QEMU's documentation for PCIe passthrough. I suspect it shares some design with the USB interface which does allow the equivalent of what you want.

Is the main compatibility the use of UEFI? Per my experience doing that with graphics cards the only thing the OVMF firmware is needed for is to keep the passthrough from silently failing - if you are doing it with non VGA devices it should simply work. The other incompatibility, if the driver must be a module, may not be possible to work around. In that case you might need a ramdisk. You should link this thread in #gentoo on irc.freenode.net:6697 if you don't get more replies in a timely fashion.

----------

