test/nvme/cmb: Use get-pmr as fallback

Under latest kernels the cmb* attributes are not present under the
sysfs anymore. See:

https://bugzilla.kernel.org/show_bug.cgi?id=217037

this is a regression that was fixed in 6.2 kernel. Until we jump to
that release, we need to have a workaround in place.

Signed-off-by: Michal Berger <michal.berger@intel.com>
Change-Id: Ia659518224899cbb3e9cef19681a457c945a9c96
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16776
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:41:21 +01:00 committed by Tomasz Zawadzki
parent b0107e8cf6
commit 03e2374c93

View File

@ -79,13 +79,25 @@ xtrace_disable
# read 0 from the CMBSZ register (meaning CMB is either not supported
# or the CMBMSC.CRE bit was cleared).
# FIXME: This is akward but under latest kernels, >=6.1.9, the cmb* attrs
# are gone. Do a quick fallback check via get-pmr and skip registry dump.
mapfile -t get_pmr < <("$rootdir/scripts/get-pmr")
cmb_nvmes=()
for nvme in /sys/class/nvme/nvme+([0-9]); do
[[ -e $nvme/cmb ]] || continue
cmb_nvmes+=("$(< "$nvme/address")")
pci=$(< "$nvme/address")
if [[ ! -e $nvme/cmb ]]; then
if printf '%s\n' "${get_pmr[@]}" | grep -qE "$pci.+:cmb"; then
cmb_nvmes+=("$pci")
fi
# Skip the detailed printout as there's no relevant info to display
# in this case.
continue
fi
cmb_nvmes+=("$pci")
printf '* %s (%s:%s:%s:%s) CMB:\n' \
"${nvme##*/}" \
"$(< "$nvme/address")" \
"$pci" \
"$(< "$nvme/model")" \
"$(< "$nvme/serial")" \
"$(< "$nvme/transport")"