| From 0e77783658066c02903cc6693460f3bb577e3030 Mon Sep 17 00:00:00 2001 |
| From: Jiuzhu Dong <dongjiuzhu1@xiaomi.com> |
| Date: Mon, 11 Apr 2022 13:31:35 +0800 |
| Subject: [PATCH 07/10] openamp: avoid double calling ns_bound when each other |
| calls create_ept |
| |
| VELAPLATFO-1522 |
| |
| Change-Id: I78c027e3fcaf54126b75358b91b557e477955964 |
| Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com> |
| --- |
| lib/rpmsg/rpmsg_virtio.c | 17 +++++++++++------ |
| 1 file changed, 11 insertions(+), 6 deletions(-) |
| |
| diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c |
| index efbcd68d..49817799 100644 |
| --- a/lib/rpmsg/rpmsg_virtio.c |
| +++ open-amp/lib/rpmsg/rpmsg_virtio.c |
| @@ -652,7 +652,7 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data, |
| metal_mutex_release(&rdev->lock); |
| if (rdev->ns_bind_cb) |
| rdev->ns_bind_cb(rdev, name, dest); |
| - } else { |
| + } else if (_ept->dest_addr == RPMSG_ADDR_ANY) { |
| _ept->dest_addr = dest; |
| metal_mutex_release(&rdev->lock); |
| if (_ept->name[0] && rdev->support_ack) |
| @@ -662,14 +662,19 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data, |
| if (_ept->ns_bound_cb) |
| _ept->ns_bound_cb(_ept); |
| } |
| + else |
| + metal_mutex_release(&rdev->lock); |
| } else { /* RPMSG_NS_CREATE_ACK */ |
| /* save the received destination address */ |
| - if (_ept) |
| + if (_ept && _ept->dest_addr == RPMSG_ADDR_ANY) { |
| _ept->dest_addr = dest; |
| - metal_mutex_release(&rdev->lock); |
| - /* notify application that the endpoint has been bound */ |
| - if (_ept && _ept->ns_bound_cb) |
| - _ept->ns_bound_cb(_ept); |
| + metal_mutex_release(&rdev->lock); |
| + /* notify application that the endpoint has been bound */ |
| + if (_ept->ns_bound_cb) |
| + _ept->ns_bound_cb(_ept); |
| + } |
| + else |
| + metal_mutex_release(&rdev->lock); |
| } |
| |
| return RPMSG_SUCCESS; |
| -- |
| 2.25.1 |
| |