numam-spdk/scripts/cleanup.sh
Daniel Verkamp 3e5fe6f602 autobuild: unbind NVMe devices on FreeBSD
Change-Id: I5e6a6ca6751d77aed48bedc2e59f97139dd8ef00
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2015-10-09 10:03:25 -07:00

29 lines
558 B
Bash
Executable File

#!/usr/bin/env bash
set -e
function cleanup_linux() {
# detach pci devices from uio driver
grep -q "^uio_pci_generic" /proc/modules && rmmod uio_pci_generic
# bind NVMe devices to NVMe driver if no kernel device
if [ -d "/sys/bus/pci/drivers/nvme" ]; then
device=`find /sys/bus/pci/drivers/nvme -name "0000*" -print`
if [ -z "$device" ]; then
rmmod nvme
modprobe nvme
fi
fi
}
function cleanup_freebsd {
kldunload contigmem.ko || true
kldunload nic_uio.ko || true
}
if [ `uname` = Linux ]; then
cleanup_linux
else
cleanup_freebsd
fi