Skip to content

Commit

Permalink
check VIRTIO_RPMSG_F_NS before send the namespace message
Browse files Browse the repository at this point in the history
Signed-off-by: Xiang Xiao <[email protected]>
  • Loading branch information
xiaoxiang781216 authored and Wendy Liang committed Mar 3, 2019
1 parent dd17c5a commit 66cf86d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/include/openamp/rpmsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ struct rpmsg_device_ops {
* @ns_bind_cb: callback handler for name service announcement without local
* endpoints waiting to bind.
* @ops: RPMsg device operations
* @support_ns: create/destroy namespace message
*/
struct rpmsg_device {
struct metal_list endpoints;
Expand All @@ -105,6 +106,7 @@ struct rpmsg_device {
metal_mutex_t lock;
rpmsg_ns_bind_cb ns_bind_cb;
struct rpmsg_device_ops ops;
bool support_ns;
};

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/rpmsg/rpmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ int rpmsg_create_ept(struct rpmsg_endpoint *ept, struct rpmsg_device *rdev,
rpmsg_init_ept(ept, name, addr, dest, cb, unbind_cb);
rpmsg_register_endpoint(rdev, ept);

if (ept->dest_addr == RPMSG_ADDR_ANY) {
if (rdev->support_ns && ept->dest_addr == RPMSG_ADDR_ANY) {
/* Send NS announcement to remote processor */
metal_mutex_release(&rdev->lock);
status = rpmsg_send_ns_message(ept, RPMSG_NS_CREATE);
Expand Down Expand Up @@ -257,7 +257,7 @@ void rpmsg_destroy_ept(struct rpmsg_endpoint *ept)
return;

rdev = ept->rdev;
if (ept->addr != RPMSG_NS_EPT_ADDR)
if (rdev->support_ns && ept->addr != RPMSG_NS_EPT_ADDR)
(void)rpmsg_send_ns_message(ept, RPMSG_NS_DESTROY);
metal_mutex_acquire(&rdev->lock);
rpmsg_unregister_endpoint(ept);
Expand Down
3 changes: 2 additions & 1 deletion lib/rpmsg/rpmsg_virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
}
#endif /*!VIRTIO_MASTER_ONLY*/
vdev->features = rpmsg_virtio_get_features(rvdev);
rdev->support_ns = !!(vdev->features & (1 << VIRTIO_RPMSG_F_NS));

#ifndef VIRTIO_SLAVE_ONLY
if (role == RPMSG_MASTER) {
Expand Down Expand Up @@ -633,7 +634,7 @@ int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev,
* Create name service announcement endpoint if device supports name
* service announcement feature.
*/
if (vdev->features & (1 << VIRTIO_RPMSG_F_NS)) {
if (rdev->support_ns) {
rpmsg_init_ept(&rdev->ns_ept, "NS",
RPMSG_NS_EPT_ADDR, RPMSG_NS_EPT_ADDR,
rpmsg_virtio_ns_callback, NULL);
Expand Down

0 comments on commit 66cf86d

Please sign in to comment.