rpmsg: virtio_rpmsg_bus: acknowledge the received creation message
PATCH 1/1 rpmsg: virtio_rpmsg_bus: acknowledge the received creation message
From: QianWenfa <[email protected]>
the two phase handsake make the client could initiate the transfer immediately without the server side send any dummy message first.
--- drivers/rpmsg/virtio_rpmsg_bus.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)
drivers/rpmsg/virtio_rpmsg_bus.c +20 -5
@@ -71,6 +71,7 @@ struct virtproc_info {/* The feature bitmap for virtio rpmsg */ #define VIRTIO_RPMSG_F_NS 0/* RP supports name service notifications */ +#define VIRTIO_RPMSG_F_ACK 1/* RP supports name service acknowledge */ /** * struct rpmsg_hdr - common header for all rpmsg messages
@@ -115,10 +116,12 @@ struct rpmsg_ns_msg {* * @RPMSG_NS_CREATE: a new remote service was just created * @RPMSG_NS_DESTROY: a known remote service was just destroyed +* @RPMSG_NS_ACK: acknowledge the previous creation message */ enum rpmsg_ns_flags {RPMSG_NS_CREATE =0 ,RPMSG_NS_DESTROY =1 , +RPMSG_NS_ACK =2 , };/**
@@ -330,13 +333,14 @@ static int virtio_rpmsg_announce_create(struct rpmsg_device *rpdev)int err =0 ;/* need to tell remote processor's name service about this channel ? */ -if (rpdev->announce && rpdev->ept && +if (rpdev->ept && (rpdev->announce || +virtio_has_feature (vrp->vdev,VIRTIO_RPMSG_F_ACK )) &&virtio_has_feature (vrp->vdev,VIRTIO_RPMSG_F_NS )) {struct rpmsg_ns_msg nsm;strncpy (nsm.name, rpdev->id.name,RPMSG_NAME_SIZE ); nsm.addr = rpdev->ept->addr; - nsm.flags =RPMSG_NS_CREATE ; + nsm.flags = rpdev->announce ?RPMSG_NS_CREATE :RPMSG_NS_ACK ; err =rpmsg_sendto (rpdev->ept, &nsm,sizeof (nsm),RPMSG_NS_ADDR );if (err)
@@ -820,6 +824,7 @@ static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len,struct rpmsg_channel_info chinfo;struct virtproc_info *vrp = priv;struct device *dev = &vrp->vdev->dev; +struct device *tmp;int ret;#if defined(CONFIG_DYNAMIC_DEBUG )
@@ -847,21 +852,30 @@ static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len, msg->name[RPMSG_NAME_SIZE -1 ] ='\0' ;dev_info (dev,"%sing channel %s addr 0x%x\n" , - msg->flags &RPMSG_NS_DESTROY ?"destroy" :"creat" , + msg->flags ==RPMSG_NS_ACK ?"ack" : + msg->flags ==RPMSG_NS_DESTROY ?"destroy" :"creat" , msg->name, msg->addr);strncpy (chinfo.name, msg->name,sizeof (chinfo.name)); chinfo.src =RPMSG_ADDR_ANY ; chinfo.dst = msg->addr; -if (msg->flags &RPMSG_NS_DESTROY ) { +if (msg->flags ==RPMSG_NS_DESTROY ) { ret =rpmsg_unregister_device (&vrp->vdev->dev, &chinfo);if (ret)dev_err (dev,"rpmsg_destroy_channel failed: %d\n" , ret); - }else { + }else if (msg->flags ==RPMSG_NS_CREATE ) { newch =rpmsg_create_channel (vrp, &chinfo);if (!newch)dev_err (dev,"rpmsg_create_channel failed\n" ); + }else if (msg->flags ==RPMSG_NS_ACK ) { + chinfo.dst =RPMSG_ADDR_ANY ; + tmp =rpmsg_find_device (&vrp->vdev->dev, &chinfo); +if (tmp) { + newch =to_rpmsg_device (tmp); + newch->dst = msg->addr; + }else +dev_err (dev,"rpmsg_find_device failed\n" ); }return 0 ;
@@ -1028,6 +1042,7 @@ static struct virtio_device_id id_table[] = {static unsigned int features[] = {VIRTIO_RPMSG_F_NS , +VIRTIO_RPMSG_F_ACK , };static struct virtio_driver virtio_ipc_driver = {
Signature · 1 line
2.7.4
Hello Xiang,
Quoted 4 lines · Xiang Xiao
From: QianWenfa <[email protected]>
the two phase handsake make the client could initiate the transfer immediately without the server side send any dummy message first.
As discussed on OpenAMP mailing list, the first point (from my pov) is to figure out if this should be part of the rpmsg protocol or service dependent (so managed by the rpmsg client itself)...
Quoted 33 lines
Signed-off-by Wenfa Qian <[email protected]>Signed-off-by Xiang Xiao <[email protected]>--- drivers/rpmsg/virtio_rpmsg_bus.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)drivers/rpmsg/virtio_rpmsg_bus.c +3
-0@@ -71,6 +71,7 @@ struct virtproc_info {/* The feature bitmap for virtio rpmsg */ #define VIRTIO_RPMSG_F_NS 0/* RP supports name service notifications */ +#define VIRTIO_RPMSG_F_ACK 1/* RP supports name service acknowledge */ /** * struct rpmsg_hdr - common header for all rpmsg messages @@ -115,10 +116,12 @@ struct rpmsg_ns_msg {* * @RPMSG_NS_CREATE: a new remote service was just created * @RPMSG_NS_DESTROY: a known remote service was just destroyed +* @RPMSG_NS_ACK: acknowledge the previous creation message */ enum rpmsg_ns_flags {RPMSG_NS_CREATE =0 ,RPMSG_NS_DESTROY =1 , +RPMSG_NS_ACK =2 , };/**
drivers/rpmsg/virtio_rpmsg_bus.c static int virtio_rpmsg_announce_create(struct rpmsg_device *rpdev) · line 338
Quoted 7 lines
drivers/rpmsg/virtio_rpmsg_bus.c +2
-1@@ -330,13 +333,14 @@ static int virtio_rpmsg_announce_create(struct rpmsg_device *rpdev)int err =0 ;/* need to tell remote processor's name service about this channel ? */ -if (rpdev->announce && rpdev->ept && +if (rpdev->ept && (rpdev->announce || +virtio_has_feature (vrp->vdev,VIRTIO_RPMSG_F_ACK )) && virtio_has_feature(vrp->vdev, VIRTIO_RPMSG_F_NS)) {Regarding this condition i have a concern. If rpdev->announce is false
but VIRTIO_RPMSG_F_ACK feature is set, this should generate an ack message. Seems that this condition can occurs depending on the rpmsg_device struct provided on registration, when rpmsg_dev_probe is called.
Quoted 33 lines
drivers/rpmsg/virtio_rpmsg_bus.c +5
-3struct rpmsg_ns_msg nsm;strncpy (nsm.name, rpdev->id.name,RPMSG_NAME_SIZE ); nsm.addr = rpdev->ept->addr; - nsm.flags =RPMSG_NS_CREATE ; + nsm.flags = rpdev->announce ?RPMSG_NS_CREATE :RPMSG_NS_ACK ; err =rpmsg_sendto (rpdev->ept, &nsm,sizeof (nsm),RPMSG_NS_ADDR );if (err)@@ -820,6 +824,7 @@ static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len,struct rpmsg_channel_info chinfo;struct virtproc_info *vrp = priv;struct device *dev = &vrp->vdev->dev; +struct device *tmp;int ret;#if defined(CONFIG_DYNAMIC_DEBUG )@@ -847,21 +852,30 @@ static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len, msg->name[RPMSG_NAME_SIZE -1 ] ='\0' ;dev_info (dev,"%sing channel %s addr 0x%x\n" , - msg->flags &RPMSG_NS_DESTROY ?"destroy" :"creat" , + msg->flags ==RPMSG_NS_ACK ?"ack" : + msg->flags ==RPMSG_NS_DESTROY ?"destroy" :"creat" , msg->name, msg->addr);strncpy (chinfo.name, msg->name,sizeof (chinfo.name)); chinfo.src =RPMSG_ADDR_ANY ; chinfo.dst = msg->addr; -if (msg->flags &RPMSG_NS_DESTROY ) { +if (msg->flags ==RPMSG_NS_DESTROY ) { ret =rpmsg_unregister_device (&vrp->vdev->dev, &chinfo);
drivers/rpmsg/virtio_rpmsg_bus.c static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len, · line 873
Quoted 10 lines
drivers/rpmsg/virtio_rpmsg_bus.c +4
-1if (ret)dev_err (dev,"rpmsg_destroy_channel failed: %d\n" , ret); - }else { + }else if (msg->flags ==RPMSG_NS_CREATE ) { newch =rpmsg_create_channel (vrp, &chinfo);if (!newch)dev_err (dev,"rpmsg_create_channel failed\n" ); + }else if (msg->flags ==RPMSG_NS_ACK ) { + chinfo.dst =RPMSG_ADDR_ANY ; + tmp =rpmsg_find_device (&vrp->vdev->dev, &chinfo);
nit-picking... replace &vrp->vdev->dev by dev and change tmp by a more explicit name.
drivers/rpmsg/virtio_rpmsg_bus.c static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len, · line 877
Quoted 4 lines
drivers/rpmsg/virtio_rpmsg_bus.c +4
-0+if (tmp) { + newch =to_rpmsg_device (tmp); + newch->dst = msg->addr; + }else
typo: braces
Regards,
Arnaud
Quoted 13 lines
drivers/rpmsg/virtio_rpmsg_bus.c +2
-0+dev_err (dev,"rpmsg_find_device failed\n" ); }return 0 ;@@ -1028,6 +1042,7 @@ static struct virtio_device_id id_table[] = {static unsigned int features[] = {VIRTIO_RPMSG_F_NS , +VIRTIO_RPMSG_F_ACK , };static struct virtio_driver virtio_ipc_driver = {
Thanks for review.
Quoted 5 lines · Arnaud Pouliquen
Hello Xiang,
Quoted 9 lines
Quoted 4 lines · Xiang Xiao
From: QianWenfa <[email protected]>
the two phase handsake make the client could initiate the transfer immediately without the server side send any dummy message first.
As discussed on OpenAMP mailing list, the first point (from my pov) is to figure out if this should be part of the rpmsg protocol or service dependent (so managed by the rpmsg client itself)...
Here is my thought:
1.The ack message don't have any side effect except kernel send back the local address through NS channel directly.
2.But without this message, remote side can't send the message first due to the lack of kernel address information.
The second limitation is very strange for all developer I think.
Quoted 36 lines
Quoted 36 lines
Signed-off-by Wenfa Qian <[email protected]>Signed-off-by Xiang Xiao <[email protected]>--- drivers/rpmsg/virtio_rpmsg_bus.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)drivers/rpmsg/virtio_rpmsg_bus.c +3
-0@@ -71,6 +71,7 @@ struct virtproc_info {/* The feature bitmap for virtio rpmsg */ #define VIRTIO_RPMSG_F_NS 0/* RP supports name service notifications */ +#define VIRTIO_RPMSG_F_ACK 1/* RP supports name service acknowledge */ /** * struct rpmsg_hdr - common header for all rpmsg messages @@ -115,10 +116,12 @@ struct rpmsg_ns_msg {* * @RPMSG_NS_CREATE: a new remote service was just created * @RPMSG_NS_DESTROY: a known remote service was just destroyed +* @RPMSG_NS_ACK: acknowledge the previous creation message */ enum rpmsg_ns_flags {RPMSG_NS_CREATE =0 ,RPMSG_NS_DESTROY =1 , +RPMSG_NS_ACK =2 , };/** @@ -330,13 +333,14 @@ static int virtio_rpmsg_announce_create(struct rpmsg_device *rpdev)int err =0 ;
Quoted 8 lines
drivers/rpmsg/virtio_rpmsg_bus.c static int virtio_rpmsg_announce_create(struct rpmsg_device *rpdev)
Quoted 5 lines
drivers/rpmsg/virtio_rpmsg_bus.c +2
-1/* need to tell remote processor's name service about this channel ? */ -if (rpdev->announce && rpdev->ept && +if (rpdev->ept && (rpdev->announce || +virtio_has_feature (vrp->vdev,VIRTIO_RPMSG_F_ACK )) && virtio_has_feature(vrp->vdev, VIRTIO_RPMSG_F_NS)) {Regarding this condition i have a concern. If rpdev->announce is falsebut
VIRTIO_RPMSG_F_ACKfeature is set, this should generate an ack message. Seems that this condition can occurs depending on therpmsg_devicestruct provided on registration, whenrpmsg_dev_probeis called.
The ack message can't be sent before device probe success, otherwise the early ack make the remote side consider kernel driver is ready and send the message immediately, but nobody can receive the message actually.
Quoted 31 lines
Quoted 31 lines
drivers/rpmsg/virtio_rpmsg_bus.c +4
-2struct rpmsg_ns_msg nsm;strncpy (nsm.name, rpdev->id.name,RPMSG_NAME_SIZE ); nsm.addr = rpdev->ept->addr; - nsm.flags =RPMSG_NS_CREATE ; + nsm.flags = rpdev->announce ?RPMSG_NS_CREATE :RPMSG_NS_ACK ; err =rpmsg_sendto (rpdev->ept, &nsm,sizeof (nsm),RPMSG_NS_ADDR );if (err)@@ -820,6 +824,7 @@ static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len,struct rpmsg_channel_info chinfo;struct virtproc_info *vrp = priv;struct device *dev = &vrp->vdev->dev; +struct device *tmp;int ret;#if defined(CONFIG_DYNAMIC_DEBUG )@@ -847,21 +852,30 @@ static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len, msg->name[RPMSG_NAME_SIZE -1 ] ='\0' ;dev_info (dev,"%sing channel %s addr 0x%x\n" , - msg->flags &RPMSG_NS_DESTROY ?"destroy" :"creat" , + msg->flags ==RPMSG_NS_ACK ?"ack" : + msg->flags ==RPMSG_NS_DESTROY ?"destroy" :"creat" , msg->name, msg->addr);strncpy (chinfo.name, msg->name,sizeof (chinfo.name)); chinfo.src =RPMSG_ADDR_ANY ; chinfo.dst = msg->addr;
Quoted 15 lines
drivers/rpmsg/virtio_rpmsg_bus.c static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len, · line 873
Quoted 13 lines
drivers/rpmsg/virtio_rpmsg_bus.c +5
-2-if (msg->flags &RPMSG_NS_DESTROY ) { +if (msg->flags ==RPMSG_NS_DESTROY ) { ret =rpmsg_unregister_device (&vrp->vdev->dev, &chinfo);if (ret)dev_err (dev,"rpmsg_destroy_channel failed: %d\n" , ret); - }else { + }else if (msg->flags ==RPMSG_NS_CREATE ) { newch =rpmsg_create_channel (vrp, &chinfo);if (!newch)dev_err (dev,"rpmsg_create_channel failed\n" ); + }else if (msg->flags ==RPMSG_NS_ACK ) { + chinfo.dst =RPMSG_ADDR_ANY ; + tmp =rpmsg_find_device (&vrp->vdev->dev, &chinfo);nit-picking... replace
&vrp->vdev->devby dev and change tmp by a more explicit name.
Ok.
Quoted 6 lines
drivers/rpmsg/virtio_rpmsg_bus.c static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len, · line 877
Quoted 4 lines
drivers/rpmsg/virtio_rpmsg_bus.c +4
-0+if (tmp) { + newch =to_rpmsg_device (tmp); + newch->dst = msg->addr; + }else typo: braces
Ok.
Quoted 15 lines
Regards,
ArnaudQuoted 13 lines
drivers/rpmsg/virtio_rpmsg_bus.c +2
-0+dev_err (dev,"rpmsg_find_device failed\n" ); }return 0 ;@@ -1028,6 +1042,7 @@ static struct virtio_device_id id_table[] = {static unsigned int features[] = {VIRTIO_RPMSG_F_NS , +VIRTIO_RPMSG_F_ACK , };static struct virtio_driver virtio_ipc_driver = {