-
Notifications
You must be signed in to change notification settings - Fork 294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
openamp: change rx buffer hold flag to count #524
Conversation
d345547
to
e98367f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange to me that you hold the buffer to release it in same function. I would say hold it at the end of the ept->cb if needed...
That say I think it is interesting to use a counter instead of a flag, as we could have several consumers.
What I'm expecting here is that we have same hold mechanism for the RX and the TX buffers. So please update also the TX part
@arnopo Hi, I'm a little confused about the update also the TX part, do you mean add |
075dc53
to
f7db776
Compare
My request was not cristal clear. |
c87de36
to
7e2bf84
Compare
@arnopo Got, and I has deleted the user interface. Could you take a look again. |
lib/rpmsg/rpmsg_virtio.c
Outdated
|
||
rvdev = metal_container_of(rdev, struct rpmsg_virtio_device, rdev); | ||
|
||
metal_mutex_acquire(&rdev->lock); | ||
|
||
r_desc->idx = idx; | ||
/* Check the hold status first */ | ||
if (RPMSG_BUF_HELD_STATUS(rp_hdr) <= 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be less than 0 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Release one buffer twice? Actually, I want to add a RPMSG_ASSERT
here to check the incorrect usage of buffer hold/release API. Do you have some suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose thta the issue is that user call twice time rpmsg_virtio_buf_held_dec_test, right?
so a test could be added in rpmsg_virtio_buf_held_dec_test with a log error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
7e2bf84
to
7f670be
Compare
7f670be
to
e42e1df
Compare
@arnopo do you have more suggestion? |
ac266f6
to
b7bd536
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM adressing @xiaoxiang781216 comment
b7bd536
to
30ff35f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor typos to fix before I merge it.
you can also remove "This commit fix one issue, " in the commit message
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>
30ff35f
to
7e09f36
Compare
@arnopo Thanks, all the comments have been addressed. |
This commit fix one issue, before this commit, if
rpmsg_hold_rx_buffer()
is called in the endpoint callback to hold current received buffer and callrpmsg_release_rx_buffer()
to release this buffer immediately.This buffer will be returned to the virtqueue in
rpmsg_virtio_release_rx_buffer()
and returned to virtqueue again inrpmsg_virtio_return_buffer()
after theept->cb()
.So same buffer returned to the virtqueue twice, error happened.
Follow shows this process:
The root cause of this issue is that the RPMSG_BUF_HELD has been cleared in
rpmsg_release_rx_buffer()
sorpmsg_virtio_rx_callback()
will treat this buffer is not HELD and callrpmsg_virtio_return_buffer()
to return this buffer again.This commit change the HELD flag in rp_hdr to count to fix this issue and also support hold/release rx buffer recursively.