Re: [PATCH v2] rpmsg: virtio: add endianness conversions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jul 06, 2020 at 02:47:16PM +0200, Guennadi Liakhovetski wrote:
> On Wed, Jul 01, 2020 at 06:00:30AM -0400, Michael S. Tsirkin wrote:
> > On Tue, Jun 30, 2020 at 11:50:57AM -0600, Mathieu Poirier wrote:
> > > On Tue, Jun 16, 2020 at 09:30:11AM +0200, Guennadi Liakhovetski wrote:
> > > > According to the VirtIO 1.0 spec data, sent over virtual queues must
> > > > be in little-endian format. Update the RPMsg VirtIO implementation
> > > > to enforce that but let legacy configurations continue use native
> > > > endianness.
> > > > 
> > > > Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@xxxxxxxxxxxxxxx>
> > > > ---
> > > > 
> > > > v2: Following suggestions from Michael and Mathieu switch to using virtio16/32 
> > > > types and conversion functions.
> > > > 
> > > >  drivers/rpmsg/virtio_rpmsg_bus.c | 63 ++++++++++++++++++++++------------------
> > > >  1 file changed, 35 insertions(+), 28 deletions(-)
> > > > 
> > > > diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c
> > > > index 07d4f33..41025df 100644
> > > > --- a/drivers/rpmsg/virtio_rpmsg_bus.c
> > > > +++ b/drivers/rpmsg/virtio_rpmsg_bus.c

[snip]

> > > > @@ -846,15 +853,15 @@ static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len,
> > > >  	/* don't trust the remote processor for null terminating the name */
> > > >  	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->name, msg->addr);
> > > > -
> > > >  	strncpy(chinfo.name, msg->name, sizeof(chinfo.name));
> > > >  	chinfo.src = RPMSG_ADDR_ANY;
> > > > -	chinfo.dst = msg->addr;
> > > > +	chinfo.dst = virtio32_to_cpu(vrp->vdev, msg->addr);
> > > > +
> > > > +	dev_info(dev, "%sing channel %s addr 0x%x\n",
> > 
> > 
> > Let's not try tricks. Just %s and destroying/creating below.
> > Wastes 3 bytes of kernel space but is clearer.
> 
> Those aren't my tricks - they're already there, but sure, I can replace that while at it.

On a second thought, that would be an unrelated change, so, I should probably keep it 
as is.

Thanks
Guennadi

> > > > +		 virtio32_to_cpu(vrp->vdev, msg->flags) & RPMSG_NS_DESTROY ?
> > > > +		 "destroy" : "creat", msg->name, chinfo.dst);
> > > >  
> > > > -	if (msg->flags & RPMSG_NS_DESTROY) {
> > > > +	if (virtio32_to_cpu(vrp->vdev, 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);
> > > > -- 
> > > > 1.9.3



[Index of Archives]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux