test/cuse: wait for device after reset

This patch adds waitforblk() after rebinding the driver.
If timing was unfortunate, it was possible to issue
id-ctrlr command to a device that was not yet ready.
Meaning the support for fw command was not read properly.

No error was reported due to "set +e", so this patch moves
it till after id-ctrlr.

Example of the error:
# get_nvme_ctrlr_from_bdf 0000:82:00.0
# readlink -f /sys/class/nvme/nvme9
# grep 0000:82:00.0/nvme/nvme
# bdf_sysfs_path=/sys/devices/pci0000:80/0000:80:03.0/0000:82:00.0/nvme/nvme9
# [[ -z /sys/devices/pci0000:80/0000:80:03.0/0000:82:00.0/nvme/nvme9 ]]
# basename /sys/devices/pci0000:80/0000:80:03.0/0000:82:00.0/nvme/nvme9
# printf '%s\n' nvme9
# nvme_name=nvme9
# [[ -z nvme9 ]]
# set +e
# ctrlr=/dev/nvme9
# ns=/dev/nvme9n1
# /usr/local/src/nvme-cli/nvme id-ctrl /dev/nvme9
# grep oacs
# cut -d: -f2
/dev/nvme9: Resource temporarily unavailable

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I5728a5062cd553eb39d18d9869fdf56319a27777
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2950
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
This commit is contained in:
Tomasz Zawadzki 2020-06-18 07:20:13 -04:00
parent 8c883b977f
commit 14ce25ab00

View File

@ -24,14 +24,16 @@ if [[ -z "$nvme_name" ]]; then
return 1
fi
set +e
ctrlr="/dev/${nvme_name}"
ns="/dev/${nvme_name}n1"
waitforblk "${nvme_name}n1"
oacs=$(${NVME_CMD} id-ctrl $ctrlr | grep oacs | cut -d: -f2)
oacs_firmware=$((oacs & 0x4))
set +e
${NVME_CMD} get-ns-id $ns > ${KERNEL_OUT}.1
${NVME_CMD} id-ns $ns > ${KERNEL_OUT}.2
${NVME_CMD} list-ns $ns > ${KERNEL_OUT}.3