diff mbox series

[09/10] rpmsg: virtio: Make endianness conversion virtIO specific

Message ID 20200922001000.899956-10-mathieu.poirier@linaro.org
State Superseded
Headers show
Series rpmsg: Make RPMSG name service modular | expand

Commit Message

Mathieu Poirier Sept. 22, 2020, 12:09 a.m. UTC
Introduce rpmsg operations to make byte conversion specific to the
virtIO transport layer, therefore avoiding the protocol code from
being aware of the virtIO transport specification.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
 drivers/rpmsg/virtio_rpmsg_bus.c | 36 ++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

Comments

kernel test robot Sept. 23, 2020, 1:08 a.m. UTC | #1
Hi Mathieu,

I love your patch! Perhaps something to improve:

[auto build test WARNING on next-20200921]
[cannot apply to linux/master linus/master rpmsg/for-next v5.9-rc6 v5.9-rc5 v5.9-rc4 v5.9-rc6]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Mathieu-Poirier/rpmsg-Make-RPMSG-name-service-modular/20200922-081745
base:    b10b8ad862118bf42c28a98b0f067619aadcfb23
config: i386-randconfig-s001-20200921 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.2-201-g24bdaac6-dirty
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)

>> drivers/rpmsg/virtio_rpmsg_bus.c:165:43: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected restricted __virtio16 [usertype] val @@     got unsigned short [usertype] val @@
>> drivers/rpmsg/virtio_rpmsg_bus.c:165:43: sparse:     expected restricted __virtio16 [usertype] val
>> drivers/rpmsg/virtio_rpmsg_bus.c:165:43: sparse:     got unsigned short [usertype] val
>> drivers/rpmsg/virtio_rpmsg_bus.c:173:31: sparse: sparse: incorrect type in return expression (different base types) @@     expected unsigned short @@     got restricted __virtio16 @@
>> drivers/rpmsg/virtio_rpmsg_bus.c:173:31: sparse:     expected unsigned short
>> drivers/rpmsg/virtio_rpmsg_bus.c:173:31: sparse:     got restricted __virtio16
>> drivers/rpmsg/virtio_rpmsg_bus.c:181:43: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected restricted __virtio32 [usertype] val @@     got unsigned int [usertype] val @@
>> drivers/rpmsg/virtio_rpmsg_bus.c:181:43: sparse:     expected restricted __virtio32 [usertype] val
>> drivers/rpmsg/virtio_rpmsg_bus.c:181:43: sparse:     got unsigned int [usertype] val
>> drivers/rpmsg/virtio_rpmsg_bus.c:189:31: sparse: sparse: incorrect type in return expression (different base types) @@     expected unsigned int @@     got restricted __virtio32 @@
>> drivers/rpmsg/virtio_rpmsg_bus.c:189:31: sparse:     expected unsigned int
>> drivers/rpmsg/virtio_rpmsg_bus.c:189:31: sparse:     got restricted __virtio32

# https://github.com/0day-ci/linux/commit/dd032e0b67fcd6197fed6b6a35c14fa07934a9b4
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Mathieu-Poirier/rpmsg-Make-RPMSG-name-service-modular/20200922-081745
git checkout dd032e0b67fcd6197fed6b6a35c14fa07934a9b4
vim +165 drivers/rpmsg/virtio_rpmsg_bus.c

   159	
   160	static u16 virtio_rpmsg_transport16_to_cpu(struct rpmsg_device *rpdev, u16 val)
   161	{
   162		struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(rpdev);
   163		struct virtproc_info *vrp = vch->vrp;
   164	
 > 165		return virtio16_to_cpu(vrp->vdev, val);
   166	}
   167	
   168	static u16 virtio_rpmsg_cpu_to_transport16(struct rpmsg_device *rpdev, u16 val)
   169	{
   170		struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(rpdev);
   171		struct virtproc_info *vrp = vch->vrp;
   172	
 > 173		return cpu_to_virtio16(vrp->vdev, val);
   174	}
   175	
   176	static u32 virtio_rpmsg_transport32_to_cpu(struct rpmsg_device *rpdev, u32 val)
   177	{
   178		struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(rpdev);
   179		struct virtproc_info *vrp = vch->vrp;
   180	
 > 181		return virtio32_to_cpu(vrp->vdev, val);
   182	}
   183	
   184	static u32 virtio_rpmsg_cpu_to_transport32(struct rpmsg_device *rpdev, u32 val)
   185	{
   186		struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(rpdev);
   187		struct virtproc_info *vrp = vch->vrp;
   188	
 > 189		return cpu_to_virtio32(vrp->vdev, val);
   190	}
   191	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c
index 1c0be0ee790c..15cc383a85cc 100644
--- a/drivers/rpmsg/virtio_rpmsg_bus.c
+++ b/drivers/rpmsg/virtio_rpmsg_bus.c
@@ -157,6 +157,38 @@  static struct rpmsg_endpoint *__rpmsg_create_ept(struct virtproc_info *vrp,
 	return NULL;
 }
 
+static u16 virtio_rpmsg_transport16_to_cpu(struct rpmsg_device *rpdev, u16 val)
+{
+	struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(rpdev);
+	struct virtproc_info *vrp = vch->vrp;
+
+	return virtio16_to_cpu(vrp->vdev, val);
+}
+
+static u16 virtio_rpmsg_cpu_to_transport16(struct rpmsg_device *rpdev, u16 val)
+{
+	struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(rpdev);
+	struct virtproc_info *vrp = vch->vrp;
+
+	return cpu_to_virtio16(vrp->vdev, val);
+}
+
+static u32 virtio_rpmsg_transport32_to_cpu(struct rpmsg_device *rpdev, u32 val)
+{
+	struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(rpdev);
+	struct virtproc_info *vrp = vch->vrp;
+
+	return virtio32_to_cpu(vrp->vdev, val);
+}
+
+static u32 virtio_rpmsg_cpu_to_transport32(struct rpmsg_device *rpdev, u32 val)
+{
+	struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(rpdev);
+	struct virtproc_info *vrp = vch->vrp;
+
+	return cpu_to_virtio32(vrp->vdev, val);
+}
+
 static struct rpmsg_device *
 virtio_rpmsg_create_channel(struct rpmsg_device *rpdev,
 			    struct rpmsg_channel_info *chinfo)
@@ -268,6 +300,10 @@  static int virtio_rpmsg_announce_destroy(struct rpmsg_device *rpdev)
 }
 
 static const struct rpmsg_device_ops virtio_rpmsg_ops = {
+	.transport16_to_cpu = virtio_rpmsg_transport16_to_cpu,
+	.cpu_to_transport16 = virtio_rpmsg_cpu_to_transport16,
+	.transport32_to_cpu = virtio_rpmsg_transport32_to_cpu,
+	.cpu_to_transport32 = virtio_rpmsg_cpu_to_transport32,
 	.create_channel = virtio_rpmsg_create_channel,
 	.release_channel = virtio_rpmsg_release_channel,
 	.create_ept = virtio_rpmsg_create_ept,