openamp: decouple rpmsg virtio and remoteproc#549
Conversation
lib/include/openamp/rpmsg.h
Outdated
| typedef void (*rpmsg_ns_unbind_cb)(struct rpmsg_endpoint *ept); | ||
| typedef void (*rpmsg_ns_bind_cb)(struct rpmsg_device *rdev, | ||
| const char *name, uint32_t dest); | ||
| typedef int (*rpmsg_notify_wait_cb)(struct rpmsg_device *rdev, uint32_t id); |
There was a problem hiding this comment.
This is not related to the rpmsg but to the transport layer, I would expect that this is part of the rpmsg_virtio.
There was a problem hiding this comment.
but rpmsg could support other transport(e.g. uart/spi), this patch try to avoid couple the notify wait callback with the virtio transport.
There was a problem hiding this comment.
My point here is that "id" is related to the vring so the transport layer. the Id will probably be use then to identify the associated mailbox.
There was a problem hiding this comment.
@xiaoxiang781216 @arnopo So how about change the uint32_t id to void *arg to be compatible with all rpmsg transports ?
There was a problem hiding this comment.
This does not solve the issue for me as we would still need to interpret the args as a reference known by the transport layer.
The rpmsg_device struct should contain only fields related to the RPMsg service.
We can also assume that the notion of "notify" is linked to Virtio. For instance, for a UART transport, we will probably speak about an end-of-transfer callback.
Another question we have to answer is whether this callback is related to RPMsg Virtio or to Virtio. I wonder if this callback should not be in the Virtio layer to be able to reuse it for other Virtio services.
There was a problem hiding this comment.
@arnopo OK, move this callback to
struct rpmsg_virtio_deviceis acceptable to me. About the second question, I think let virtio services handle the buffer question is better just like rpmsg virtio device does.
Ok let keep it here for the moment, if needed for some other virtio service, we will implement it at virtio level and make this one deprecated
There was a problem hiding this comment.
@arnopo So you mean keep PR #518 and add new
notify_wait()callback instruct rpmsg_virtio_deviceto support two ways to handle the get tx buffer failed problem, but default to use thenotify_wait()callback instruct rpmsg_virtio_deviceway?
No, you can revert #518. My point here is that it is acceptable to implement this in rpmsg_virtio for the time being.
However, in the future, if this callback is also required for some other virtio services, we will have to rework it to implement something common in the virtio layer.
There was a problem hiding this comment.
to sum -up the remaining work here is
- move this callback to struct rpmsg_virtio_device
- management of the cb in rpmsg_virtio ( remove code in rpmsg.c)
…uffer get" This reverts commit 95802c1. Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
0b5c3bd to
f4ddcf5
Compare
5d13981 to
7fc6e43
Compare
6ec1958 to
613fb79
Compare
lib/rpmsg/rpmsg_virtio.c
Outdated
| if (rvdev->notify_wait_cb) | ||
| return rvdev->notify_wait_cb(&rvdev->rdev, vring_info->notifyid); | ||
|
|
||
| return RPMSG_ERR_NXIO; |
lib/include/openamp/rpmsg.h
Outdated
| #define RPMSG_ERR_ADDR (RPMSG_ERROR_BASE - 7) | ||
| #define RPMSG_ERR_PERM (RPMSG_ERROR_BASE - 8) | ||
| #define RPMSG_EOPNOTSUPP (RPMSG_ERROR_BASE - 9) | ||
| #define RPMSG_EOPNOTSUPP (RPMSG_ERROR_BASE - 9) |
lib/rpmsg/rpmsg_virtio.c
Outdated
| } | ||
|
|
||
| static int rpmsg_virtio_notify_wait(struct rpmsg_virtio_device *rvdev, | ||
| struct virtqueue *vq) |
There was a problem hiding this comment.
squash declaration on 1 line (up to 100 char is OK)
lib/rpmsg/rpmsg_virtio.c
Outdated
| * use metal_sleep_usec() method by default. | ||
| */ | ||
| status = rpmsg_virtio_notify_wait(rvdev, rvdev->rvq); | ||
| if (status != RPMSG_SUCCESS) { |
There was a problem hiding this comment.
if status is different from RPMSG_EOPNOTSUPP we should leave the loop
if (status == RPMSG_EOPNOTSUPP) {
metal_sleep_usec(RPMSG_TICKS_PER_INTERVAL);
tick_count--;
} else if (status == RPMSG_SUCCESS) {
break;
}
lib/rpmsg/rpmsg_internal.h
Outdated
| return rpmsg_get_endpoint(rdev, NULL, addr, RPMSG_ADDR_ANY); | ||
| } | ||
|
|
||
| int rpmsg_notify_wait(struct rpmsg_device *rdev, uint32_t id); |
|
@edmooring @tnmysh |
Give users a chance to handle the no tx buffer situation when get tx buffer, with this patch, user can set the notify_wait_cb in driver and this callback function will be called to handle the wait when no tx buffer in tx virtqueue. Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
openamp: move notify_wait() in rpmsg virtio to rpmsg, this ops can do in rpmsg without coupling to virtio.