Re: [PATCH V3 2/4] misc: vop: do not allocate and reassign the used ring

kernel test robot
2020-10-22T08:53:59Z

[-- Attachment #1: Type: text/plain, Size: 4976 bytes --]

Hi Sherry,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on char-misc/char-misc-testing]
[also build test WARNING on soc/for-next linus/master v5.9 next-20201022]
[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/Sherry-Sun/Change-vring-space-from-nomal-memory-to-dma-coherent-memory/20201022-131008
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git f3277cbfba763cd2826396521b9296de67cf1bbc
config: i386-randconfig-s002-20201022 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.3-dirty
# https://github.com/0day-ci/linux/commit/6ae9d6d36b63c7bb8170f4c0409470d8e7101880
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Sherry-Sun/Change-vring-space-from-nomal-memory-to-dma-coherent-memory/20201022-131008
git checkout 6ae9d6d36b63c7bb8170f4c0409470d8e7101880
# 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/misc/mic/vop/vop_main.c:339:14: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected void *used @@ got void [noderef] __iomem * @@
>> drivers/misc/mic/vop/vop_main.c:339:14: sparse: expected void *used
>> drivers/misc/mic/vop/vop_main.c:339:14: sparse: got void [noderef] __iomem *
>> drivers/misc/mic/vop/vop_main.c:357:35: sparse: sparse: restricted __le64 degrades to integer

vim +339 drivers/misc/mic/vop/vop_main.c

289
290 /*
291 * This routine will assign vring's allocated in host/io memory. Code in
292 * virtio_ring.c however continues to access this io memory as if it were local
293 * memory without io accessors.
294 */
295 static struct virtqueue *vop_find_vq(struct virtio_device *dev,
296 unsigned index,
297 void (*callback)(struct virtqueue *vq),
298 const char *name, bool ctx)
299 {
300 struct _vop_vdev *vdev = to_vopvdev(dev);
301 struct vop_device *vpdev = vdev->vpdev;
302 struct mic_vqconfig __iomem *vqconfig;
303 struct mic_vqconfig config;
304 struct virtqueue *vq;
305 void __iomem *va;
306 struct _mic_vring_info __iomem *info;
307 void *used;
308 int vr_size, _vr_size, err, magic;
309 u8 type = ioread8(&vdev->desc->type);
310
311 if (index >= ioread8(&vdev->desc->num_vq))
312 return ERR_PTR(-ENOENT);
313
314 if (!name)
315 return ERR_PTR(-ENOENT);
316
317 /* First assign the vring's allocated in host memory */
318 vqconfig = _vop_vq_config(vdev->desc) + index;
319 memcpy_fromio(&config, vqconfig, sizeof(config));
320 _vr_size = round_up(vring_size(le16_to_cpu(config.num), MIC_VIRTIO_RING_ALIGN), 4);
321 vr_size = PAGE_ALIGN(_vr_size + sizeof(struct _mic_vring_info));
322 va = vpdev->hw_ops->remap(vpdev, le64_to_cpu(config.address), vr_size);
323 if (!va)
324 return ERR_PTR(-ENOMEM);
325 vdev->vr[index] = va;
326 memset_io(va, 0x0, _vr_size);
327
328 info = va + _vr_size;
329 magic = ioread32(&info->magic);
330
331 if (WARN(magic != MIC_MAGIC + type + index, "magic mismatch")) {
332 err = -EIO;
333 goto unmap;
334 }
335
336 vdev->used_size[index] = PAGE_ALIGN(sizeof(__u16) * 3 +
337 sizeof(struct vring_used_elem) *
338 le16_to_cpu(config.num));
> 339 used = va + PAGE_ALIGN(sizeof(struct vring_desc) * le16_to_cpu(config.num) +
340 sizeof(__u16) * (3 + le16_to_cpu(config.num)));
341 vdev->used_virt[index] = used;
342 if (!used) {
343 err = -ENOMEM;
344 dev_err(_vop_dev(vdev), "%s %d err %d\n",
345 __func__, __LINE__, err);
346 goto unmap;
347 }
348
349 vq = vop_new_virtqueue(index, le16_to_cpu(config.num), dev, ctx,
350 (void __force *)va, vop_notify, callback,
351 name, used);
352 if (!vq) {
353 err = -ENOMEM;
354 goto unmap;
355 }
356
> 357 vdev->used[index] = config.address + PAGE_ALIGN(sizeof(struct vring_desc) * le16_to_cpu(config.num) +
358 sizeof(__u16) * (3 + le16_to_cpu(config.num)));
359 writeq(vdev->used[index], &vqconfig->used_address);
360
361 vq->priv = vdev;
362 return vq;
363 unmap:
364 vpdev->hw_ops->unmap(vpdev, vdev->vr[index]);
365 return ERR_PTR(err);
366 }
367

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

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 36245 bytes --]