Skip to content

Commit fe32a27

Browse files
committed
ASoC: SOF: llext_load: fix single-shot write and add noop_llseek
The sof_llext_dfs_write handler requires the complete library binary delivered in a single write() syscall (it returns -EINVAL if *ppos != 0 on entry). The 'cat' command splits files larger than ~16 KB into BUFSIZ-sized chunks, so the first chunk triggered a truncated IPC4 LOAD_LIBRARY with only a partial payload, causing the DSP DMA to time out waiting for the remaining bytes. Two fixes: 1. Add .llseek = noop_llseek to sof_llext_load_fops so that tools like 'dd' that call lseek(SEEK_CUR) to determine the current position do not get ESPIPE and abort before writing anything. 2. Improve the -EINVAL error message when a non-zero *ppos write is rejected to tell the user to use 'dd bs=<size> count=1' instead of 'cat'. Users and scripts should write the module binary with: dd if=<module.ri> of=/sys/kernel/debug/sof/llext_load \ bs=$(stat -c%s <module.ri>) count=1 Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 37ccb6b commit fe32a27

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

sound/soc/sof/sof-client-llext-load.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,13 @@ static ssize_t sof_llext_dfs_write(struct file *file,
7777
u32 lib_id, state;
7878
int ret;
7979

80-
if (*ppos)
80+
if (*ppos) {
81+
dev_err_ratelimited(&cdev->auxdev.dev,
82+
"llext_load: partial write rejected (offset=%lld) — "
83+
"use 'dd if=<module.ri> of=/sys/kernel/debug/sof/llext_load bs=$(stat -c%%s <module.ri>) count=1'\n",
84+
*ppos);
8185
return -EINVAL; /* no seek; single-shot write only */
86+
}
8287

8388
if (!count || count > SOF_LLEXT_MAX_SIZE)
8489
return count ? -EFBIG : -EINVAL;
@@ -217,6 +222,7 @@ static const struct file_operations sof_llext_load_fops = {
217222
.open = sof_llext_dfs_open,
218223
.write = sof_llext_dfs_write,
219224
.release = sof_llext_dfs_release,
225+
.llseek = noop_llseek, /* allow lseek(0) from dd/tools; write must start at pos=0 */
220226
.owner = THIS_MODULE,
221227
};
222228

0 commit comments

Comments
 (0)