From e93d56b1edd217cf1e02472484ca906fe2d47b34 Mon Sep 17 00:00:00 2001 From: "tone.zhang" Date: Sat, 29 Sep 2018 09:25:16 +0800 Subject: [PATCH] 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 Reviewed-on: https://review.gerrithub.io/427297 Reviewed-by: Darek Stojaczyk Reviewed-by: Jim Harris Reviewed-by: Ben Walker Tested-by: SPDK CI Jenkins --- scripts/setup.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/scripts/setup.sh b/scripts/setup.sh index 22e726de5..4b46b3611 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -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