Skip to contentSkip to conversation

Clarification regarding VFIO driver bind in the setup.sh

SPDK chandanga at google.com 1 participant 2 messages Aug 16, 2021 – Aug 18, 2021

lore
Share & tools
lore

chandanga at google.com

#0 lore raw

I needed a clarification regarding the VFIO setup script for SPDK (https://github.com/spdk/spdk/blob/master/scripts/setup.sh).
In the linux_bind_driver() method, we have the following lines:

	echo "$ven_dev_id" > "/sys/bus/pci/drivers/$driver_name/new_id" 2> /dev/null || true
	echo "$bdf" > "/sys/bus/pci/drivers/$driver_name/bind" 2> /dev/null || true

I'm wondering if both steps are necessary? It looks like if we set the vendor_id, device_id into "/sys/bus/pci/drivers/vfio-pci/new_id", this will automatically assign all the VFs (which are not assigned to the NVMe driver) to the VFIO driver. Hence, the second line (echoing the $bdf to the bind file) becomes redundant. Is this correct? Any reason why both of these steps are required? Thanks.

#1 lore raw

Hi,

For binding to vfio-pci (or uio_pci_generic), the first line is sufficient.

This same function is also used though for setup.sh reset to bind the devices back to their respective kernel mode drivers. For that case, the bind is required (but not the new_id).

So both steps are there since the linux_bind_driver() function is used for both cases. It could probably be optimized to check the $driver_name and only do the necessary sysfs writes.

Are these extra writes to /bind a problem in your use case, or was your question more out of curiosity?

Regards,

Jim

On 8/16/21, 3:36 PM, "chandanga(a)google.com" <chandanga(a)google.com> wrote:

I needed a clarification regarding the VFIO setup script for SPDK (https://github.com/spdk/spdk/blob/master/scripts/setup.sh).
In the linux_bind_driver() method, we have the following lines:
echo "$ven_dev_id" > "/sys/bus/pci/drivers/$driver_name/new_id" 2> /dev/null || true
echo "$bdf" > "/sys/bus/pci/drivers/$driver_name/bind" 2> /dev/null || true

I'm wondering if both steps are necessary? It looks like if we set the vendor_id, device_id into "/sys/bus/pci/drivers/vfio-pci/new_id", this will automatically assign all the VFs (which are not assigned to the NVMe driver) to the VFIO driver. Hence, the second line (echoing the $bdf to the bind file) becomes redundant. Is this correct? Any reason why both of these steps are required? Thanks.
_______________________________________________
SPDK mailing list -- spdk(a)lists.01.org
To unsubscribe send an email to spdk-leave(a)lists.01.org