Peter Ginchev | dfa9c5b | 2016-10-11 15:34:24 +0300 | [diff] [blame] | 1 | #!/bin/sh -e |
| 2 | |
| 3 | removed= |
| 4 | |
| 5 | # Unbind user-mode PCI drivers |
| 6 | pci_dirs=`find /sys/bus/pci/drivers -type d -name igb_uio -o -name uio_pci_generic -o -name vfio-pci` |
| 7 | for d in $pci_dirs; do |
| 8 | for f in ${d}/*; do |
| 9 | [ -e "${f}/config" ] || continue |
Radu Nicolau | 02767e9 | 2017-02-23 14:28:49 +0000 | [diff] [blame] | 10 | echo ${f##*/} > ${d}/unbind |
Peter Ginchev | dfa9c5b | 2016-10-11 15:34:24 +0300 | [diff] [blame] | 11 | basename `dirname ${f}` | xargs echo -n "Removing driver"; echo " for PCI ID" `basename ${f}` |
| 12 | removed=y |
| 13 | done |
| 14 | done |
| 15 | if [ -n "${removed}" ]; then |
Paul Vinciguerra | 3ca4b14 | 2020-12-30 00:41:15 +0000 | [diff] [blame] | 16 | echo "There are changes in PCI drivers, rescanning" |
Peter Ginchev | dfa9c5b | 2016-10-11 15:34:24 +0300 | [diff] [blame] | 17 | echo 1 > /sys/bus/pci/rescan |
| 18 | else |
Paul Vinciguerra | 3ca4b14 | 2020-12-30 00:41:15 +0000 | [diff] [blame] | 19 | echo "There weren't PCI devices bound" |
Peter Ginchev | dfa9c5b | 2016-10-11 15:34:24 +0300 | [diff] [blame] | 20 | fi |
| 21 | |