From dc43aae54d4b2d99c2eb585801e614fdb6a5e296 Mon Sep 17 00:00:00 2001 From: Krzysztof Karas Date: Fri, 22 Jul 2022 06:47:59 +0000 Subject: [PATCH] hw_hotplug: use all available GPIO lines Prepare Beetles to use all available GPIO lines to manage NVMe drives. The two reasons are: + we want to test multiple NVMes instead just one + setting all GPIO will make it easier to physically connect NVMe connectors to Beetles Change-Id: I0351dd2e7cfef0a75eff0692be3c746ad1b5664f Signed-off-by: Krzysztof Karas Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13748 Tested-by: SPDK CI Jenkins Reviewed-by: Tomasz Zawadzki Reviewed-by: Konrad Sztyber Reviewed-by: Karol Latecki --- test/nvme/hw_hotplug.sh | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/test/nvme/hw_hotplug.sh b/test/nvme/hw_hotplug.sh index 07bcc4bc2..657fe2f02 100755 --- a/test/nvme/hw_hotplug.sh +++ b/test/nvme/hw_hotplug.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +shopt -s nullglob testdir=$(readlink -f $(dirname $0)) rootdir=$(readlink -f $testdir/../..) @@ -15,22 +16,25 @@ function beetle_ssh() { } function insert_device() { - beetle_ssh 'Beetle --SetGpio "$gpio" HIGH' - waitforblk $name + beetle_ssh 'for gpio in {0..10}; do Beetle --SetGpio "$gpio" HIGH; done' + for name in "${names[@]}"; do + waitforblk $name + done DRIVER_OVERRIDE=$driver $rootdir/scripts/setup.sh } function remove_device() { - beetle_ssh 'Beetle --SetGpio "$gpio" LOW' + beetle_ssh 'for gpio in {0..10}; do Beetle --SetGpio "$gpio" LOW; done' } function restore_device() { - beetle_ssh 'Beetle --SetGpio "$gpio" HIGH' + beetle_ssh 'for gpio in {0..10}; do Beetle --SetGpio "$gpio" HIGH; done' + # Bind all devices to kernel + "$rootdir/scripts/setup.sh" reset } ip=$1 -gpio=$2 -driver=$3 +driver=$2 declare -i io_time=5 declare -i kernel_hotplug_time=7 @@ -38,18 +42,22 @@ declare -i kernel_hotplug_time=7 timing_enter hotplug_hw_cfg # Configure microcontroller -beetle_ssh 'Beetle --SetGpioDirection "$gpio" OUT' +beetle_ssh 'for gpio in {0..10}; do Beetle --SetGpioDirection "$gpio" OUT; done' -# Get blk dev name connected to interposer -beetle_ssh 'Beetle --SetGpio "$gpio" HIGH' +# Get blk dev names connected to interposer +restore_device sleep $kernel_hotplug_time -$rootdir/scripts/setup.sh reset blk_list1=$(lsblk -d --output NAME | grep "^nvme") remove_device sleep $kernel_hotplug_time blk_list2=$(lsblk -d --output NAME | grep "^nvme") || true -name=${blk_list1#"$blk_list2"} +names=(${blk_list1#"$blk_list2"}) + +nvme_count="${#names[@]}" +echo nvme_count + +# Move devices back to userspace insert_device timing_exit hotplug_hw_cfg @@ -64,7 +72,7 @@ fi exec {log}> >(tee -a "$testdir/log.txt") exec >&$log 2>&1 -$SPDK_EXAMPLE_DIR/hotplug -i 0 -t 100 -n 2 -r 2 $mode & +"$SPDK_EXAMPLE_DIR/hotplug" -i 0 -t 100 -n $((2 * nvme_count)) -r $((2 * nvme_count)) $mode & hotplug_pid=$! trap 'killprocess $hotplug_pid; restore_device; rm $testdir/log.txt; exit 1' SIGINT SIGTERM EXIT @@ -105,4 +113,6 @@ rm $testdir/log.txt trap - SIGINT SIGTERM EXIT +restore_device + timing_exit hotplug_hw_test