Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/include/openamp/rpmsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,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 @@ -106,6 +107,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 Expand Up @@ -286,7 +288,7 @@ static inline void rpmsg_init_ept(struct rpmsg_endpoint *ept,
rpmsg_ept_cb cb,
rpmsg_ns_unbind_cb ns_unbind_cb)
{
strncpy(ept->name, name, sizeof(ept->name));
strncpy(ept->name, name ? name : "", sizeof(ept->name));
ept->addr = src;
ept->dest_addr = dest;
ept->cb = cb;
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 (ept->name[0] && rdev->support_ns && ept->addr != RPMSG_NS_EPT_ADDR)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same comment as before.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check is required since the nameless endpoint have the valid local address but RPMSG_NS_DESTROY shouldn't send out.

(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 @@ -541,6 +541,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 @@ -636,7 +637,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