Skip to content

Commit 0c0644b

Browse files
Nicolas Pitrekartben
authored andcommitted
kernel/pipe: disable direct-to-readers copy with CONFIG_KERNEL_COHERENCE
Systems that enabled this option don't have their stacks in coherent memory. Given our pipe_buf_spec is stored on the stack, and readers may also have their destination buffer on their stack too, it is not worth going to the trouble of supporting direct-to-readers copy with them. Signed-off-by: Nicolas Pitre <[email protected]>
1 parent 3da90f9 commit 0c0644b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

kernel/pipe.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,18 @@ int z_impl_k_pipe_write(struct k_pipe *pipe, const uint8_t *data, size_t len, k_
162162
}
163163

164164
if (pipe_empty(pipe)) {
165-
if (pipe->waiting != 0) {
165+
if (IS_ENABLED(CONFIG_KERNEL_COHERENCE)) {
166+
/*
167+
* Systems that enabled this option don't have
168+
* their stacks in coherent memory. Given our
169+
* pipe_buf_spec is stored on the stack, and
170+
* readers may also have their destination
171+
* buffer on their stack too, it is not worth
172+
* supporting direct-to-readers copy with them.
173+
* Simply wake up all pending readers instead.
174+
*/
175+
need_resched = z_sched_wake_all(&pipe->data, 0, NULL);
176+
} else if (pipe->waiting != 0) {
166177
written += copy_to_pending_readers(pipe, &need_resched,
167178
&data[written],
168179
len - written);

0 commit comments

Comments
 (0)