scripts/get-pmr: Adjust BAR2 lookup

Under latest QEMU, BAR2 is exclusively dedicated to CMB, so
reflect that.

Also, add paranoid check for the header type to make sure we
use proper offsets along the way.

Signed-off-by: Michal Berger <michal.berger@intel.com>
Change-Id: I75ecfa5bf03861aedfc7bd064cbad60522b8bf0e
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16774
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Michal Berger 2023-02-14 15:27:03 +01:00 committed by Tomasz Zawadzki
parent d254a3b924
commit 843606d7c6

View File

@ -12,7 +12,7 @@ shopt -s nullglob
[[ $(< /sys/class/dmi/id/chassis_vendor) == QEMU ]] || exit 0 [[ $(< /sys/class/dmi/id/chassis_vendor) == QEMU ]] || exit 0
get_bar() { get_bar() {
echo "0x$(setpci -s "$1" "$2.L")" echo "0x$(setpci -s "$1" "$2.${3:-L}")"
} }
get_size() { get_size() {
@ -34,12 +34,12 @@ info() {
local dev=$1 local dev=$1
local pref local pref
local head
local base_addr2 local base_addr2
local base_addr4 local base_addr4
local bar bar2 bar3 bar4 bar5 local bar2 bar3 bar4 bar5
local bar_type2
pref[0]=non-prefetchable pref[0]=non-prefetchable
pref[1]=prefetchable pref[1]=prefetchable
@ -56,11 +56,17 @@ info() {
"$bar_type" "$bar_type"
} }
head=$(get_bar "$dev" 0x0e B)
bar2=$(get_bar "$dev" 0x18) bar2=$(get_bar "$dev" 0x18)
bar3=$(get_bar "$dev" 0x1c) bar3=$(get_bar "$dev" 0x1c)
bar4=$(get_bar "$dev" 0x20) bar4=$(get_bar "$dev" 0x20)
bar5=$(get_bar "$dev" 0x24) bar5=$(get_bar "$dev" 0x24)
if ((head != 0)); then
echo "Wrong haeder type under $dev" >&2
return 1
fi
# QEMU uses 64-bit BARs. If there is no CMB or PMR present, report # QEMU uses 64-bit BARs. If there is no CMB or PMR present, report
# that to the user and signal failure. # that to the user and signal failure.
if ((!(bar2 & 1 << 2) && !(bar4 & 1 << 2))); then if ((!(bar2 & 1 << 2) && !(bar4 & 1 << 2))); then
@ -69,12 +75,8 @@ info() {
fi fi
if ((bar2 & 1 << 2)); then if ((bar2 & 1 << 2)); then
bar_type2=pmr
if [[ -e $nvme/cmb ]]; then
bar_type2=cmb
fi
base_addr2=$(((bar2 & ~0xf) + (bar3 << 32))) base_addr2=$(((bar2 & ~0xf) + (bar3 << 32)))
print_info "$bar2" "$base_addr2" "$bar_type2" print_info "$bar2" "$base_addr2" cmb
fi fi
if ((bar4 & 1 << 2)); then if ((bar4 & 1 << 2)); then