Commit e1817b60 authored by Stephen Bates's avatar Stephen Bates Committed by Jim Harris
Browse files

setup.sh: Add support for built-in modules



setup.sh uses lsmod to detect if a module is present but this does
not work when modules are built-in. We add a second check (on
/sys/module/<module>) and place the check in a function.

We also change the sense of driver_loaded so it is more sane and also
allows us to return different positive values depending on if the
driver is a module or built-in.

Change-Id: Iccc4dca212a6f04fb2ac9bd4768935f8b2bb240a
Signed-off-by: default avatarStephen Bates <sbates@raithlin.com>
Reviewed-on: https://review.gerrithub.io/402178


Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent c1174e68
Loading
Loading
Loading
Loading
+21 −4
Original line number Diff line number Diff line
@@ -49,6 +49,23 @@ function usage()
	exit 0
}

# In monolithic kernels the lsmod won't work. So
# back that with a /sys/modules check. Return a different code for
# built-in vs module just in case we want that down the road.
function check_for_driver {
	$(lsmod | grep $1 > /dev/null)
	if [ $? -eq 0 ]; then
		return 1
	else
		if [[ -d /sys/module/$1 ]]; then
			return 2
		else
			return 0
		fi
	fi
	return 0
}

function pci_can_bind() {
	if [[ ${#PCI_WHITELIST[@]} == 0 ]]; then
		#no whitelist specified, bind all devices
@@ -275,7 +292,7 @@ function configure_linux {
function reset_linux_pci {
	# NVMe
	set +e
	lsmod | grep nvme > /dev/null
	check_for_driver nvme
	driver_loaded=$?
	set -e
	for bdf in $(iter_pci_class_code 01 08 02); do
@@ -283,7 +300,7 @@ function reset_linux_pci {
			echo "Skipping un-whitelisted NVMe controller $blkname ($bdf)"
			continue
		fi
		if [ $driver_loaded -eq 0 ]; then
		if [ $driver_loaded -ne 0 ]; then
			linux_bind_driver "$bdf" nvme
		else
			linux_unbind_driver "$bdf"
@@ -297,7 +314,7 @@ function reset_linux_pci {
	| awk -F"x" '{print $2}' > $TMP

	set +e
	lsmod | grep ioatdma > /dev/null
	check_for_driver ioatdma
	driver_loaded=$?
	set -e
	for dev_id in `cat $TMP`; do
@@ -306,7 +323,7 @@ function reset_linux_pci {
				echo "Skipping un-whitelisted I/OAT device at $bdf"
				continue
			fi
			if [ $driver_loaded -eq 0 ]; then
			if [ $driver_loaded -ne 0 ]; then
				linux_bind_driver "$bdf" ioatdma
			else
				linux_unbind_driver "$bdf"