scripts/common: Cache pci modalias
Additionally, include the first resolved alias of the module. Signed-off-by: Michal Berger <michalx.berger@intel.com> Change-Id: I71c7c15398ea36f3dea3340f5c98568ff6b6a68a Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7848 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
parent
5f61a0c919
commit
9b3773db68
@ -28,11 +28,23 @@ function pci_can_use() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resolve_mod() {
|
||||||
|
local mod=$1 aliases=()
|
||||||
|
|
||||||
|
if aliases=($(modprobe -R "$mod")); then
|
||||||
|
echo "${aliases[0]}"
|
||||||
|
else
|
||||||
|
echo "unknown"
|
||||||
|
fi 2> /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
cache_pci_init() {
|
cache_pci_init() {
|
||||||
local -gA pci_bus_cache
|
local -gA pci_bus_cache
|
||||||
local -gA pci_ids_vendor
|
local -gA pci_ids_vendor
|
||||||
local -gA pci_ids_device
|
local -gA pci_ids_device
|
||||||
local -gA pci_bus_driver
|
local -gA pci_bus_driver
|
||||||
|
local -gA pci_mod_driver
|
||||||
|
local -gA pci_mod_resolved
|
||||||
|
|
||||||
[[ -z ${pci_bus_cache[*]} || $CMD == reset ]] || return 1
|
[[ -z ${pci_bus_cache[*]} || $CMD == reset ]] || return 1
|
||||||
|
|
||||||
@ -40,10 +52,12 @@ cache_pci_init() {
|
|||||||
pci_bus_ids_vendor=()
|
pci_bus_ids_vendor=()
|
||||||
pci_bus_ids_device=()
|
pci_bus_ids_device=()
|
||||||
pci_bus_driver=()
|
pci_bus_driver=()
|
||||||
|
pci_mod_driver=()
|
||||||
|
pci_mod_resolved=()
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_pci() {
|
cache_pci() {
|
||||||
local pci=$1 class=$2 vendor=$3 device=$4 driver=$5
|
local pci=$1 class=$2 vendor=$3 device=$4 driver=$5 mod=$6
|
||||||
|
|
||||||
if [[ -n $class ]]; then
|
if [[ -n $class ]]; then
|
||||||
class=0x${class/0x/}
|
class=0x${class/0x/}
|
||||||
@ -59,6 +73,10 @@ cache_pci() {
|
|||||||
if [[ -n $driver ]]; then
|
if [[ -n $driver ]]; then
|
||||||
pci_bus_driver["$pci"]=$driver
|
pci_bus_driver["$pci"]=$driver
|
||||||
fi
|
fi
|
||||||
|
if [[ -n $mod ]]; then
|
||||||
|
pci_mod_driver["$pci"]=$mod
|
||||||
|
pci_mod_resolved["$pci"]=$(resolve_mod "$mod")
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_pci_bus_sysfs() {
|
cache_pci_bus_sysfs() {
|
||||||
@ -67,17 +85,20 @@ cache_pci_bus_sysfs() {
|
|||||||
cache_pci_init || return 0
|
cache_pci_init || return 0
|
||||||
|
|
||||||
local pci
|
local pci
|
||||||
local class vendor device driver
|
local class vendor device driver mod
|
||||||
|
|
||||||
for pci in /sys/bus/pci/devices/*; do
|
for pci in /sys/bus/pci/devices/*; do
|
||||||
class=$(< "$pci/class") vendor=$(< "$pci/vendor") device=$(< "$pci/device") driver=""
|
class=$(< "$pci/class") vendor=$(< "$pci/vendor") device=$(< "$pci/device") driver="" mod=""
|
||||||
if [[ -e $pci/driver ]]; then
|
if [[ -e $pci/driver ]]; then
|
||||||
driver=$(readlink -f "$pci/driver")
|
driver=$(readlink -f "$pci/driver")
|
||||||
driver=${driver##*/}
|
driver=${driver##*/}
|
||||||
else
|
else
|
||||||
driver=unbound
|
driver=unbound
|
||||||
fi
|
fi
|
||||||
cache_pci "${pci##*/}" "$class" "$vendor" "$device" "$driver"
|
if [[ -e $pci/modalias ]]; then
|
||||||
|
mod=$(< "$pci/modalias")
|
||||||
|
fi
|
||||||
|
cache_pci "${pci##*/}" "$class" "$vendor" "$device" "$driver" "$mod"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user