setup.sh: Enable users select kernel driver for identified PCI deivces

The PCI devices used for SPDK are bound with vfio-pci or
uio_pci_generic kernel drivers. In setup.sh, if the path /sys/kernel
/iommu_groups is not empty, vfio-pci kernel driver is the only choice;
otherwise uio_pci_generic is selected.

In system, IOMMU can be enabled but set to pass through. It means
IOMMU will not affect the DMA transmission although IOMMU groups has
been configured. In this case both two kernel drivers are workable. The
script cannot deal with the case now.

The new option DRIVER_OVERRIDE is introduced in the patch and allow
user selects the kernel driver for PCI devices. With the patch the above
case can be handled correctly.

Change-Id: I540d8750bf837ce67b8bc8b516a1a3acb72c502c
Signed-off-by: tone.zhang <tone.zhang@arm.com>
Reviewed-on: https://review.gerrithub.io/427297
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
tone.zhang 2018-09-29 09:25:16 +08:00 committed by Jim Harris
parent f4ba781552
commit e93d56b1ed

View File

@ -49,6 +49,9 @@ function usage()
echo " If empty or unset, all PCI devices will be bound."
echo "TARGET_USER User that will own hugepage mountpoint directory and vfio groups."
echo " By default the current user will be used."
echo "DRIVER_OVERRIDE Disable automatic vfio-pci/uio_pci_generic selection and forcefully"
echo " bind devices to the given driver."
echo " E.g. DRIVER_OVERRIDE=uio_pci_generic or DRIVER_OVERRIDE=vfio-pci"
exit 0
}
@ -164,14 +167,18 @@ function get_virtio_names_from_bdf {
}
function configure_linux_pci {
driver_name=vfio-pci
if [ -z "$(ls /sys/kernel/iommu_groups)" ]; then
# No IOMMU. Use uio.
driver_name=uio_pci_generic
if [ -z "${DRIVER_OVERRIDE}" ]; then
driver_name=vfio-pci
if [ -z "$(ls /sys/kernel/iommu_groups)" ]; then
# No IOMMU. Use uio.
driver_name=uio_pci_generic
fi
else
driver_name="${DRIVER_OVERRIDE}"
fi
# NVMe
modprobe $driver_name || true
modprobe $driver_name
for bdf in $(iter_pci_class_code 01 08 02); do
blkname=''
get_nvme_name_from_bdf "$bdf" blkname
@ -203,6 +210,7 @@ function configure_linux_pci {
echo "Skipping un-whitelisted I/OAT device at $bdf"
continue
fi
linux_bind_driver "$bdf" "$driver_name"
done
done