blob: 4ef1a59e0702593953d89b30f78439c769c2df30 [file] [log] [blame]
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +03001#!/bin/sh -e
2
3removed=
4
5# Unbind user-mode PCI drivers
6pci_dirs=`find /sys/bus/pci/drivers -type d -name igb_uio -o -name uio_pci_generic -o -name vfio-pci`
7for d in $pci_dirs; do
8 for f in ${d}/*; do
9 [ -e "${f}/config" ] || continue
Radu Nicolau02767e92017-02-23 14:28:49 +000010 echo ${f##*/} > ${d}/unbind
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +030011 basename `dirname ${f}` | xargs echo -n "Removing driver"; echo " for PCI ID" `basename ${f}`
12 removed=y
13 done
14done
15if [ -n "${removed}" ]; then
Paul Vinciguerra3ca4b142020-12-30 00:41:15 +000016 echo "There are changes in PCI drivers, rescanning"
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +030017 echo 1 > /sys/bus/pci/rescan
18else
Paul Vinciguerra3ca4b142020-12-30 00:41:15 +000019 echo "There weren't PCI devices bound"
Peter Ginchevdfa9c5b2016-10-11 15:34:24 +030020fi
21