Commit 9c44fad7 authored by Dariusz Stojaczyk's avatar Dariusz Stojaczyk Committed by Daniel Verkamp
Browse files

setup.sh: don't bind controllers with only *some* devices mounted



This makes us iterate through all devices
on a controller and check if any of those
is mounted. Previously we only checked the
very first device, which is obviously
insufficient.

Change-Id: I776846b931480d1e0a059137950c21f057ecb710
Signed-off-by: default avatarDariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/393749


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent d57306d8
Loading
Loading
Loading
Loading
+16 −10
Original line number Diff line number Diff line
@@ -71,16 +71,19 @@ function get_nvme_name_from_bdf {
	done
}

function get_virtio_name_from_bdf {
function get_virtio_names_from_bdf {
	set +e
	virtio_ctrlrs=`lsblk --nodeps --output "NAME,SUBSYSTEMS" | grep virtio | awk '{print $1}'`
	set -e
	virtio_names=''

	for ctrlr in $virtio_ctrlrs; do
		if readlink "/sys/block/$ctrlr" | grep -q "$1"; then
			eval "$2=$ctrlr"
			return
			virtio_names="$virtio_names $ctrlr"
		fi
	done

	eval "$2='$virtio_names'"
}

function configure_linux_pci {
@@ -128,14 +131,17 @@ function configure_linux_pci {

	for dev_id in `cat $TMP`; do
		for bdf in $(iter_pci_dev_id 1af4 $dev_id); do
			blkname=''
			get_virtio_name_from_bdf "$bdf" blkname
			blknames=''
			get_virtio_names_from_bdf "$bdf" blknames
			for blkname in $blknames; do
				if mount | grep -q "/dev/$blkname"; then
					echo Active mountpoints on /dev/$blkname, so not binding PCI dev $bdf
			else
				linux_bind_driver "$bdf" "$driver_name"
					continue 2
				fi
			done

			linux_bind_driver "$bdf" "$driver_name"
		done
	done
	rm $TMP