tree:
https://github.com/intel/linux-intel-lts.git 5.4/yocto
head: 87241c08286384feb3ddc57d4cb0daca4be1e384
commit: eb1a47484bcfad11d9299b9ae659bde9290e8649 [1516/9195] add support for virtio-i2c FE
driver
config: nios2-randconfig-s031-20200811 (attached as .config)
compiler: nios2-linux-gcc (GCC) 9.3.0
reproduce:
wget
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O
~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.2-168-g9554805c-dirty
git checkout eb1a47484bcfad11d9299b9ae659bde9290e8649
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1
CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=nios2
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
sparse warnings: (new ones prefixed by >>)
drivers/i2c/busses/i2c-virtio.c:75:24: sparse: sparse: incorrect type in assignment
(different base types) @@ expected restricted __virtio16 [usertype] addr @@ got
unsigned short [usertype] addr @@
drivers/i2c/busses/i2c-virtio.c:75:24: sparse: expected restricted __virtio16
[usertype] addr
drivers/i2c/busses/i2c-virtio.c:75:24: sparse: got unsigned short [usertype] addr
drivers/i2c/busses/i2c-virtio.c:76:25: sparse: sparse: incorrect type in assignment
(different base types) @@ expected restricted __virtio16 [usertype] flags @@ got
unsigned short [usertype] flags @@
drivers/i2c/busses/i2c-virtio.c:76:25: sparse: expected restricted __virtio16
[usertype] flags
drivers/i2c/busses/i2c-virtio.c:76:25: sparse: got unsigned short [usertype] flags
drivers/i2c/busses/i2c-virtio.c:77:23: sparse: sparse: incorrect type in assignment
(different base types) @@ expected restricted __virtio16 [usertype] len @@ got
unsigned short [usertype] len @@
drivers/i2c/busses/i2c-virtio.c:77:23: sparse: expected restricted __virtio16
[usertype] len
drivers/i2c/busses/i2c-virtio.c:77:23: sparse: got unsigned short [usertype] len
> drivers/i2c/busses/i2c-virtio.c:80:46: sparse: sparse: incorrect
type in argument 1 (different base types) @@ expected unsigned int [usertype] size @@
got restricted __virtio16 [usertype] len @@
> drivers/i2c/busses/i2c-virtio.c:80:46: sparse: expected unsigned int [usertype]
size
drivers/i2c/busses/i2c-virtio.c:80:46: sparse: got restricted __virtio16
[usertype] len
drivers/i2c/busses/i2c-virtio.c:85:30: sparse: sparse: restricted __virtio16 degrades
to integer
drivers/i2c/busses/i2c-virtio.c:167:40: sparse: sparse: restricted __virtio16 degrades
to integer
> drivers/i2c/busses/i2c-virtio.c:168:75: sparse: sparse: incorrect
type in argument 3 (different base types) @@ expected unsigned int [usertype] count @@
got restricted __virtio16 [usertype] len @@
> drivers/i2c/busses/i2c-virtio.c:168:75: sparse: expected unsigned int [usertype]
count
drivers/i2c/busses/i2c-virtio.c:168:75: sparse: got restricted
__virtio16 [usertype] len
vim +80 drivers/i2c/busses/i2c-virtio.c
67
68 static int virtio_queue_add_msg(struct virtqueue *vq,
69 struct virtio_i2c_msg *vmsg,
70 struct i2c_msg *msg)
71 {
72 struct scatterlist *sgs[3], hdr, bout, bin, status;
73 int outcnt = 0, incnt = 0;
74
75 vmsg->hdr.addr = msg->addr;
76 vmsg->hdr.flags = msg->flags;
77 vmsg->hdr.len = msg->len;
78
79 if (vmsg->hdr.len)
80 vmsg->buf = kzalloc(vmsg->hdr.len, GFP_KERNEL);
81
82 sg_init_one(&hdr, &vmsg->hdr, sizeof(struct virtio_i2c_hdr));
83 sgs[outcnt++] = &hdr;
84 if (vmsg->buf) {
85 if (vmsg->hdr.flags & I2C_M_RD) {
86 sg_init_one(&bin, vmsg->buf, msg->len);
87 sgs[outcnt + incnt++] = &bin;
88 } else {
89 memcpy(vmsg->buf, msg->buf, msg->len);
90 sg_init_one(&bout, vmsg->buf, msg->len);
91 sgs[outcnt++] = &bout;
92 }
93 }
94 sg_init_one(&status, &vmsg->status, 1);
95 sgs[outcnt + incnt++] = &status;
96
97 return virtqueue_add_sgs(vq, sgs, outcnt, incnt, vmsg, GFP_KERNEL);
98 }
99
100 static int virtio_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
101 {
102 struct virtio_i2c *virtio_i2c = i2c_get_adapdata(adap);
103 struct virtqueue *vq = virtio_i2c->msg_vq.vq;
104 struct virtio_i2c_msg *vmsg, *msg_r;
105 int len, i, ret;
106 unsigned long time_left;
107
108 ret = 0;
109 if (unlikely(!vq))
110 return ret;
111
112 vmsg = kzalloc(sizeof(*vmsg), GFP_KERNEL);
113 if (unlikely(!vmsg))
114 return ret;
115
116 mutex_lock(&virtio_i2c->i2c_lock);
117 vmsg->buf = NULL;
118 for (i = 0; i < num; i++) {
119 dev_dbg(&adap->dev,
120 "start to add msg[%d]: addr:0x%x \n",
121 i,
122 msgs[i].addr);
123
124 ret = virtio_queue_add_msg(vq, vmsg, &msgs[i]);
125 if (ret) {
126 dev_err(&adap->dev,
127 "failed to add msg[%d] to virtqueue\n",
128 i);
129 ret = 0;
130 goto err;
131 }
132
133 virtqueue_kick(vq);
134 dev_dbg(&adap->dev, "wait for complete...\n");
135 /*wait for complete*/
136 time_left = wait_for_completion_timeout(&virtio_i2c->completion,
137 adap->timeout);
138 if (!time_left) {
139 dev_err(&adap->dev,
140 "msg[%d]: addr=0x%x timeout\n",
141 i,
142 msgs[i].addr);
143 ret = i ? (i - 1) : 0;
144 goto err;
145 }
146 msg_r = (struct virtio_i2c_msg *)virtqueue_get_buf(vq, &len);
147 if (msg_r) {
148 /* msg_r should point to the same address with vmsg */
149 if (msg_r != vmsg) {
150 dev_err(&adap->dev,
151 "msg[%d]: addr=0x%x virtqueue error \n",
152 i,
153 msg_r->hdr.addr);
154 ret = i - 1;
155 goto err;
156 }
157
158 if (msg_r->status != VIRTIO_I2C_MSG_OK) {
159 dev_dbg(&adap->dev,
160 "msg[%d]: addr=0x%x error=%d \n",
161 i,
162 msg_r->hdr.addr,
163 msg_r->status);
164 ret = i - 1;
165 goto err;
166 }
167 if ((msg_r->hdr.flags & I2C_M_RD) && msg_r->hdr.len)
168 memcpy(msgs[i].buf, msg_r->buf, msg_r->hdr.len);
169 kfree(msg_r->buf);
170 msg_r->buf = NULL;
171 }
172 reinit_completion(&virtio_i2c->completion);
173 dev_dbg(&adap->dev, "msg[%d] ok \n", i);
174 }
175 if (i == num)
176 ret = num;
177
178 err:
179 mutex_unlock(&virtio_i2c->i2c_lock);
180 if (vmsg) {
181 kfree(vmsg->buf);
182 vmsg->buf = NULL;
183 kfree(vmsg);
184 }
185 return ret;
186 }
187
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org