mirror of
https://github.com/ebrandi/FDD-book.git
synced 2026-12-06 08:33:30 +00:00
Organize companion code and materials by book part: part-01/ Foundations part-02/ Kernel & driver fundamentals part-03/ Character & block devices part-04/ Networking & storage part-05/ Buses & advanced topics part-06/ Debugging & performance part-07/ Real-world drivers appendices/ Supplementary material README.md Overview and build instructions
53 lines
1.3 KiB
Bash
Executable file
53 lines
1.3 KiB
Bash
Executable file
#!/bin/sh
|
|
# ch22-transfer-across-cycle.sh - suspend in the middle of a transfer.
|
|
#
|
|
# Starts a DMA transfer, immediately calls devctl suspend, and verifies
|
|
# that the quiesce path aborted the transfer cleanly. Then resumes and
|
|
# verifies that a post-resume transfer succeeds.
|
|
|
|
set -e
|
|
|
|
DEV="dev.myfirst.0"
|
|
DEVNAME="myfirst0"
|
|
|
|
if ! sysctl -a | grep -q "^${DEV}"; then
|
|
echo "FAIL: ${DEV} not present."
|
|
exit 1
|
|
fi
|
|
|
|
# Start a transfer in the background.
|
|
(sysctl -n ${DEV}.dma_test_read=1 > /dev/null 2>&1 || true) &
|
|
BG=$!
|
|
|
|
# Give it a moment to enter the engine.
|
|
sleep 0.001 2>/dev/null || :
|
|
|
|
# Suspend immediately.
|
|
devctl suspend ${DEVNAME}
|
|
|
|
# Wait for the background to finish (aborted, possibly).
|
|
wait ${BG} 2>/dev/null || :
|
|
|
|
# Check the state.
|
|
state=$(sysctl -n ${DEV}.suspended)
|
|
if [ "${state}" != "1" ]; then
|
|
echo "FAIL: device not marked suspended (got '${state}')"
|
|
exit 1
|
|
fi
|
|
|
|
in_flight=$(sysctl -n ${DEV}.dma_in_flight)
|
|
if [ "${in_flight}" != "0" ]; then
|
|
echo "FAIL: dma_in_flight still 1 after suspend"
|
|
exit 1
|
|
fi
|
|
|
|
# Resume.
|
|
devctl resume ${DEVNAME}
|
|
|
|
# A post-resume transfer should succeed.
|
|
if ! sysctl -n ${DEV}.dma_test_read=1 > /dev/null 2>&1; then
|
|
echo "FAIL: post-resume dma_test_read failed"
|
|
exit 1
|
|
fi
|
|
|
|
echo "PASS: transfer-across-cycle completed"
|