From 7e3fc593567614dd0c70781f7bec4e5e2cdbecbd Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Wed, 3 Apr 2024 14:43:58 -0500 Subject: [PATCH] case-lib: is_ipc4: use new debugfs file instead of kernel parameter First step to remove use of kernel parameters Link: https://github.com/thesofproject/linux/pull/4902 Link: https://github.com/thesofproject/sof-test/issues/1166 Signed-off-by: Pierre-Louis Bossart --- case-lib/lib.sh | 51 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/case-lib/lib.sh b/case-lib/lib.sh index 32009bf2..1c7d0756 100644 --- a/case-lib/lib.sh +++ b/case-lib/lib.sh @@ -813,22 +813,47 @@ is_firmware_file_zephyr() is_ipc4() { local ipc_type - ipc_file=/sys/module/snd_sof_pci/parameters/ipc_type - # If /sys/module/snd_sof_pci/parameters/ipc_type does not exist - # the DUT is running IPC3 mode - ipc_type=$(cat $ipc_file) || { - return 1 - } + if ipc_type=$(cat /sys/kernel/debug/sof/ipc_type); then + # "cat" was successful + case $ipc_type in + 0) + return 1 + ;; + 1) + return 0 # in shell, success = error code 0 = "true" + ;; + *) + die "invalid ipc_type in /sys/kernel/debug/sof/ipc_type=$ipc_type" + ;; + esac + fi - # If /sys/module/snd_sof_pci/parameters/ipc_type exists - # If the value of file ipc_type is: - # -1: DUT runs IPC3 mode, is_ipc4 return 1(false) - # 1: DUT runs IPC4 mode, is_ipc4 return 0(true) - if [ "$ipc_type" -eq 1 ]; then - return 0 + # "cat" failed, backwards-compatible fallback with ipc_type kernel parameter + if ipc_type=$(cat /sys/module/snd_sof_pci/parameters/ipc_type); then + # "cat" was successful + case $ipc_type in + -1) + # the parameter is not set, assume IPC3 was used. + return 1 + ;; + 0) + # the parameter is set, IPC3 was used. + return 1 + ;; + 1) + # the parameter is set, IPC4 was used. + return 0 # in shell, success = error code 0 = "true" + ;; + *) + die "invalid ipc_type in /sys/module/snd_sof_pci/parameters/ipc_type=$ipc_type" + ;; + esac fi - return 1 + + # If /sys/module/snd_sof_pci/parameters/ipc_type does not exist + # assume IPC3 was used. + return 1 } logger_disabled()