Branch: refs/heads/main Home: https://github.com/OpenAMP/open-amp Commit: b32187e4fb890c5014b93dd734a0aab9eaebcfb7 https://github.com/OpenAMP/open-amp/commit/b32187e4fb890c5014b93dd734a0aab9e... Author: Guiding Li liguiding1@xiaomi.com Date: 2024-01-10 (Wed, 10 Jan 2024)
Changed paths: M lib/rpmsg/rpmsg_internal.h M lib/rpmsg/rpmsg_virtio.c
Log Message: ----------- openamp: change rx/tx buffer hold flag to count
Before this commit, if rpmsg_hold_rx_buffer() is called in the endpoint callback to hold current rx buffer and call rpmsg_release_rx_buffer() to release this buffer immediately, this rx buffer will be returned to the virtqueue twice: 1. the first time is in rpmsg_virtio_release_rx_buffer() 2. and the second time is in rpmsg_virtio_return_buffer() after ept->cb() Follow shows this process:
rpmsg_virtio_rx_callback() - get rp_hdr - ept->cb(data = RPMSG_LOCATE_DATA(rp_hdr)) - rpsmg_hold_rx_buffer(data) - rpmsg_release_rx_buffer(data) return buffer to virtqueue - rpmsg_virtio_return_buffer(data) return same buffer to virtqueue again
So this commit changes the HELD flag in rp_hdr to count to avoid this use case and also supports hold/release rx buffer recursively.
Signed-off-by: Guiding Li liguiding1@xiaomi.com Signed-off-by: Yin Tao yintao@xiaomi.com Signed-off-by: Bowen Wang wangbowen6@xiaomi.com