Skip to contentSkip to conversation

Introduce a vringh accessor for IO memory

PATCH In review Shunsuke Mie 4 participants 10 messages Jun 2, 2023 – Jun 5, 2023

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v4 cover Introduce a vringh accessor for IO memory

Vringh is a host-side implementation of virtio rings, and supports the vring located on three kinds of memories, userspace, kernel space and a space translated iotlb.

This patch introduces a new accessor for the vring on IO memory regions. The accessor is used by the proposed PCIe endpoint virtio-{net[1], console[2]} function drivers, which emulate a virtio device and access the virtio ring on PCIe host memory mapped to the local IO memory region.

- [1] PCIe endpoint virtio-net function driver

- [2] PCIe endpoint virtio-console function driver

Changes from:

v3: https://lore.kernel.org/virtualization/[email protected]/
- Remove a kconfig option that is for this support
- Add comments to exported functions
- Remove duplicated newlines

rfc v2: https://lore.kernel.org/virtualization/[email protected]/
- Focus on a adding io memory APIs
- Rebase on next-20230414

rfc v1: https://lore.kernel.org/virtualization/[email protected]/
- Initial patchset

Shunsuke Mie (1):
vringh: IOMEM support

 drivers/vhost/vringh.c | 201 +++++++++++++++++++++++++++++++++++++++++
 include/linux/vringh.h |  32 +++++++
 2 files changed, 233 insertions(+)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v4 1/1 vringh: IOMEM support

Introduce a new memory accessor for vringh. It is able to use vringh to virtio rings located on io-memory region.

---
 drivers/vhost/vringh.c | 201 +++++++++++++++++++++++++++++++++++++++++
 include/linux/vringh.h |  32 +++++++
 2 files changed, 233 insertions(+)
drivers/vhost/vringh.c +201 -0
index 955d938eb663..6e89dcd871b4 100644
@@ -1604,4 +1604,205 @@ EXPORT_SYMBOL(vringh_need_notify_iotlb);
 
 #endif
 
+static inline int getu16_iomem(const struct vringh *vrh, u16 *val,
+			       const __virtio16 *p)
+{
+	*val = vringh16_to_cpu(vrh, ioread16(p));
+	return 0;
+}
+
+static inline int putu16_iomem(const struct vringh *vrh, __virtio16 *p, u16 val)
+{
+	iowrite16(cpu_to_vringh16(vrh, val), p);
+	return 0;
+}
+
+static inline int copydesc_iomem(const struct vringh *vrh, void *dst,
+				 const void *src, size_t len)
+{
+	memcpy_fromio(dst, src, len);
+	return 0;
+}
+
+static int putused_iomem(const struct vringh *vrh, struct vring_used_elem *dst,
+			 const struct vring_used_elem *src, unsigned int num)
+{
+	memcpy_toio(dst, src, num * sizeof(*dst));
+	return 0;
+}
+
+static inline int xfer_from_iomem(const struct vringh *vrh, void *src,
+				  void *dst, size_t len)
+{
+	memcpy_fromio(dst, src, len);
+	return 0;
+}
+
+static inline int xfer_to_iomem(const struct vringh *vrh, void *dst, void *src,
+				size_t len)
+{
+	memcpy_toio(dst, src, len);
+	return 0;
+}
+
+/**
+ * vringh_init_iomem - initialize a vringh for a vring on io-memory.
+ * @vrh: the vringh to initialize.
+ * @features: the feature bits for this ring.
+ * @num: the number of elements.
+ * @weak_barriers: true if we only need memory barriers, not I/O.
+ * @desc: the userspace descriptor pointer.
+ * @avail: the userspace avail pointer.
+ * @used: the userspace used pointer.
+ *
+ * Returns an error if num is invalid: you should check pointers
+ * yourself!
+ */
+int vringh_init_iomem(struct vringh *vrh, u64 features, unsigned int num,
+		      bool weak_barriers, struct vring_desc *desc,
+		      struct vring_avail *avail, struct vring_used *used)
+{
+	return vringh_init_kern(vrh, features, num, weak_barriers, desc, avail,
+				used);
+}
+EXPORT_SYMBOL(vringh_init_iomem);
+
+/**
+ * vringh_getdesc_iomem - get next available descriptor from vring on io-memory.
+ * @vrh: the vring on io-memory.
+ * @riov: where to put the readable descriptors (or NULL)
+ * @wiov: where to put the writable descriptors (or NULL)
+ * @head: head index we received, for passing to vringh_complete_iomem().
+ * @gfp: flags for allocating larger riov/wiov.
+ *
+ * Returns 0 if there was no descriptor, 1 if there was, or -errno.
+ *
+ * There some notes, and those are same with vringh_getdesc_kern(). Please see
+ * it.
+ */
+int vringh_getdesc_iomem(struct vringh *vrh, struct vringh_kiov *riov,
+			 struct vringh_kiov *wiov, u16 *head, gfp_t gfp)
+{
+	int err;
+
+	err = __vringh_get_head(vrh, getu16_iomem, &vrh->last_avail_idx);
+	if (err < 0)
+		return err;
+
+	/* Empty... */
+	if (err == vrh->vring.num)
+		return 0;
+
+	*head = err;
+	err = __vringh_iov(vrh, *head, riov, wiov, no_range_check, NULL, gfp,
+			   copydesc_iomem);
+	if (err)
+		return err;
+
+	return 1;
+}
+EXPORT_SYMBOL(vringh_getdesc_iomem);
+
+/**
+ * vringh_iov_pull_iomem - copy bytes from vring_iov.
+ * @riov: the riov as passed to vringh_getdesc_iomem() (updated as we consume)
+ * @dst: the place to copy.
+ * @len: the maximum length to copy.
+ *
+ * Returns the bytes copied <= len or a negative errno.
+ */
+ssize_t vringh_iov_pull_iomem(struct vringh *vrh, struct vringh_kiov *riov,
+			      void *dst, size_t len)
+{
+	return vringh_iov_xfer(vrh, riov, dst, len, xfer_from_iomem);
+}
+EXPORT_SYMBOL(vringh_iov_pull_iomem);
+
+/**
+ * vringh_iov_push_iomem - copy bytes into vring_iov.
+ * @wiov: the wiov as passed to vringh_getdesc_iomem() (updated as we consume)
+ * @src: the place to copy from.
+ * @len: the maximum length to copy.
+ *
+ * Returns the bytes copied <= len or a negative errno.
+ */
+ssize_t vringh_iov_push_iomem(struct vringh *vrh, struct vringh_kiov *wiov,
+			      const void *src, size_t len)
+{
+	return vringh_iov_xfer(vrh, wiov, (void *)src, len, xfer_to_iomem);
+}
+EXPORT_SYMBOL(vringh_iov_push_iomem);
+
+/**
+ * vringh_abandon_iomem - we've decided not to handle the descriptor(s).
+ * @vrh: the vring.
+ * @num: the number of descriptors to put back (ie. num
+ *	 vringh_getdesc_iomem() to undo).
+ *
+ * The next vringh_get_kern() will return the old descriptor(s) again.
+ */
+void vringh_abandon_iomem(struct vringh *vrh, unsigned int num)
+{
+	vringh_abandon_kern(vrh, num);
+}
+EXPORT_SYMBOL(vringh_abandon_iomem);
+
+/**
+ * vringh_complete_iomem - we've finished with descriptor, publish it.
+ * @vrh: the vring.
+ * @head: the head as filled in by vringh_getdesc_iomem().
+ * @len: the length of data we have written.
+ *
+ * You should check vringh_need_notify_iomem() after one or more calls
+ * to this function.
+ */
+int vringh_complete_iomem(struct vringh *vrh, u16 head, u32 len)
+{
+	struct vring_used_elem used;
+
+	used.id = cpu_to_vringh32(vrh, head);
+	used.len = cpu_to_vringh32(vrh, len);
+
+	return __vringh_complete(vrh, &used, 1, putu16_iomem, putused_iomem);
+}
+EXPORT_SYMBOL(vringh_complete_iomem);
+
+/**
+ * vringh_notify_enable_iomem - we want to know if something changes.
+ * @vrh: the vring.
+ *
+ * This always enables notifications, but returns false if there are
+ * now more buffers available in the vring.
+ */
+bool vringh_notify_enable_iomem(struct vringh *vrh)
+{
+	return __vringh_notify_enable(vrh, getu16_iomem, putu16_iomem);
+}
+EXPORT_SYMBOL(vringh_notify_enable_iomem);
+
+/**
+ * vringh_notify_disable_iomem - don't tell us if something changes.
+ * @vrh: the vring.
+ *
+ * This is our normal running state: we disable and then only enable when
+ * we're going to sleep.
+ */
+void vringh_notify_disable_iomem(struct vringh *vrh)
+{
+	__vringh_notify_disable(vrh, putu16_iomem);
+}
+EXPORT_SYMBOL(vringh_notify_disable_iomem);
+
+/**
+ * vringh_need_notify_iomem - must we tell the other side about used buffers?
+ * @vrh: the vring we've called vringh_complete_iomem() on.
+ *
+ * Returns -errno or 0 if we don't need to tell the other side, 1 if we do.
+ */
+int vringh_need_notify_iomem(struct vringh *vrh)
+{
+	return __vringh_need_notify(vrh, getu16_iomem);
+}
+EXPORT_SYMBOL(vringh_need_notify_iomem);
+
 MODULE_LICENSE("GPL");
include/linux/vringh.h +32 -0
index c3a8117dabe8..4130e5302ee6 100644
@@ -330,4 +330,36 @@ int vringh_need_notify_iotlb(struct vringh *vrh);
 
 #endif /* CONFIG_VHOST_IOTLB */
 
+#if IS_REACHABLE(CONFIG_VHOST_RING_IOMEM)
+
+int vringh_init_iomem(struct vringh *vrh, u64 features,
+		      unsigned int num, bool weak_barriers,
+		      struct vring_desc *desc,
+		      struct vring_avail *avail,
+		      struct vring_used *used);
+
+int vringh_getdesc_iomem(struct vringh *vrh,
+			 struct vringh_kiov *riov,
+			 struct vringh_kiov *wiov,
+			 u16 *head,
+			 gfp_t gfp);
+
+ssize_t vringh_iov_pull_iomem(struct vringh *vrh,
+			      struct vringh_kiov *riov,
+			      void *dst, size_t len);
+ssize_t vringh_iov_push_iomem(struct vringh *vrh,
+			      struct vringh_kiov *wiov,
+			      const void *src, size_t len);
+
+void vringh_abandon_iomem(struct vringh *vrh, unsigned int num);
+
+int vringh_complete_iomem(struct vringh *vrh, u16 head, u32 len);
+
+bool vringh_notify_enable_iomem(struct vringh *vrh);
+void vringh_notify_disable_iomem(struct vringh *vrh);
+
+int vringh_need_notify_iomem(struct vringh *vrh);
+
+#endif /* CONFIG_VHOST_RING_IOMEM */
+
 #endif /* _LINUX_VRINGH_H */
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH v4 1/1] vringh: IOMEM support

kernel test robot noticed the following build warnings:

Hi Shunsuke,

kernel test robot noticed the following build warnings:

[auto build test WARNING on mst-vhost/linux-next]
[also build test WARNING on linus/master horms-ipvs/master v6.4-rc4 next-20230602] [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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Shunsuke-Mie/vringh-IOMEM-support/20230602-135351
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git linux-next
patch link:    https://lore.kernel.org/r/20230602055211.309960-2-mie%40igel.co.jp
patch subject: [PATCH v4 1/1] vringh: IOMEM support
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20230602/[email protected]/config)
compiler: alpha-linux-gcc (GCC) 12.3.0

reproduce (this is a W=1 build):
mkdir -p ~/bin
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/de2a1f5220c32e953400f225aba6bd294a8d41b8
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Shunsuke-Mie/vringh-IOMEM-support/20230602-135351
git checkout de2a1f5220c32e953400f225aba6bd294a8d41b8
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir ARCH=alpha olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir ARCH=alpha SHELL=/bin/bash drivers/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/vhost/vringh.c:1661:5: warning: no previous prototype for 'vringh_init_iomem' [-Wmissing-prototypes]
    1661 | int vringh_init_iomem(struct vringh *vrh, u64 features, unsigned int num,
         |     ^~~~~~~~~~~~~~~~~
>> drivers/vhost/vringh.c:1683:5: warning: no previous prototype for 'vringh_getdesc_iomem' [-Wmissing-prototypes]
    1683 | int vringh_getdesc_iomem(struct vringh *vrh, struct vringh_kiov *riov,
         |     ^~~~~~~~~~~~~~~~~~~~
>> drivers/vhost/vringh.c:1714:9: warning: no previous prototype for 'vringh_iov_pull_iomem' [-Wmissing-prototypes]
    1714 | ssize_t vringh_iov_pull_iomem(struct vringh *vrh, struct vringh_kiov *riov,
         |         ^~~~~~~~~~~~~~~~~~~~~
>> drivers/vhost/vringh.c:1729:9: warning: no previous prototype for 'vringh_iov_push_iomem' [-Wmissing-prototypes]
    1729 | ssize_t vringh_iov_push_iomem(struct vringh *vrh, struct vringh_kiov *wiov,
         |         ^~~~~~~~~~~~~~~~~~~~~
>> drivers/vhost/vringh.c:1744:6: warning: no previous prototype for 'vringh_abandon_iomem' [-Wmissing-prototypes]
    1744 | void vringh_abandon_iomem(struct vringh *vrh, unsigned int num)
         |      ^~~~~~~~~~~~~~~~~~~~
>> drivers/vhost/vringh.c:1759:5: warning: no previous prototype for 'vringh_complete_iomem' [-Wmissing-prototypes]
    1759 | int vringh_complete_iomem(struct vringh *vrh, u16 head, u32 len)
         |     ^~~~~~~~~~~~~~~~~~~~~
>> drivers/vhost/vringh.c:1777:6: warning: no previous prototype for 'vringh_notify_enable_iomem' [-Wmissing-prototypes]
    1777 | bool vringh_notify_enable_iomem(struct vringh *vrh)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/vhost/vringh.c:1790:6: warning: no previous prototype for 'vringh_notify_disable_iomem' [-Wmissing-prototypes]
    1790 | void vringh_notify_disable_iomem(struct vringh *vrh)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/vhost/vringh.c:1802:5: warning: no previous prototype for 'vringh_need_notify_iomem' [-Wmissing-prototypes]

1802 | int vringh_need_notify_iomem(struct vringh *vrh)
| ^~~~~~~~~~~~~~~~~~~~~~~~

vim +/vringh_init_iomem +1661 drivers/vhost/vringh.c

1647
1648 /**
1649 * vringh_init_iomem - initialize a vringh for a vring on io-memory.
1650 * @vrh: the vringh to initialize.
1651 * @features: the feature bits for this ring.
1652 * @num: the number of elements.
1653 * @weak_barriers: true if we only need memory barriers, not I/O.
1654 * @desc: the userspace descriptor pointer.
1655 * @avail: the userspace avail pointer.
1656 * @used: the userspace used pointer.
1657 *
1658 * Returns an error if num is invalid: you should check pointers
1659 * yourself!
1660 */

> 1661	int vringh_init_iomem(struct vringh *vrh, u64 features, unsigned int num,
  1662			      bool weak_barriers, struct vring_desc *desc,
  1663			      struct vring_avail *avail, struct vring_used *used)
  1664	{
  1665		return vringh_init_kern(vrh, features, num, weak_barriers, desc, avail,
  1666					used);
  1667	}
  1668	EXPORT_SYMBOL(vringh_init_iomem);
  1669	
  1670	/**
  1671	 * vringh_getdesc_iomem - get next available descriptor from vring on io-memory.
  1672	 * @vrh: the vring on io-memory.
  1673	 * @riov: where to put the readable descriptors (or NULL)
  1674	 * @wiov: where to put the writable descriptors (or NULL)
  1675	 * @head: head index we received, for passing to vringh_complete_iomem().
  1676	 * @gfp: flags for allocating larger riov/wiov.
  1677	 *
  1678	 * Returns 0 if there was no descriptor, 1 if there was, or -errno.
  1679	 *
  1680	 * There some notes, and those are same with vringh_getdesc_kern(). Please see
  1681	 * it.
  1682	 */
> 1683	int vringh_getdesc_iomem(struct vringh *vrh, struct vringh_kiov *riov,
  1684				 struct vringh_kiov *wiov, u16 *head, gfp_t gfp)
  1685	{
  1686		int err;
  1687	
  1688		err = __vringh_get_head(vrh, getu16_iomem, &vrh->last_avail_idx);
  1689		if (err < 0)
  1690			return err;
  1691	
  1692		/* Empty... */
  1693		if (err == vrh->vring.num)
  1694			return 0;
  1695	
  1696		*head = err;
  1697		err = __vringh_iov(vrh, *head, riov, wiov, no_range_check, NULL, gfp,
  1698				   copydesc_iomem);
  1699		if (err)
  1700			return err;
  1701	
  1702		return 1;
  1703	}
  1704	EXPORT_SYMBOL(vringh_getdesc_iomem);
  1705	
  1706	/**
  1707	 * vringh_iov_pull_iomem - copy bytes from vring_iov.
  1708	 * @riov: the riov as passed to vringh_getdesc_iomem() (updated as we consume)
  1709	 * @dst: the place to copy.
  1710	 * @len: the maximum length to copy.
  1711	 *
  1712	 * Returns the bytes copied <= len or a negative errno.
  1713	 */
> 1714	ssize_t vringh_iov_pull_iomem(struct vringh *vrh, struct vringh_kiov *riov,
  1715				      void *dst, size_t len)
  1716	{
  1717		return vringh_iov_xfer(vrh, riov, dst, len, xfer_from_iomem);
  1718	}
  1719	EXPORT_SYMBOL(vringh_iov_pull_iomem);
  1720	
  1721	/**
  1722	 * vringh_iov_push_iomem - copy bytes into vring_iov.
  1723	 * @wiov: the wiov as passed to vringh_getdesc_iomem() (updated as we consume)
  1724	 * @src: the place to copy from.
  1725	 * @len: the maximum length to copy.
  1726	 *
  1727	 * Returns the bytes copied <= len or a negative errno.
  1728	 */
> 1729	ssize_t vringh_iov_push_iomem(struct vringh *vrh, struct vringh_kiov *wiov,
  1730				      const void *src, size_t len)
  1731	{
  1732		return vringh_iov_xfer(vrh, wiov, (void *)src, len, xfer_to_iomem);
  1733	}
  1734	EXPORT_SYMBOL(vringh_iov_push_iomem);
  1735	
  1736	/**
  1737	 * vringh_abandon_iomem - we've decided not to handle the descriptor(s).
  1738	 * @vrh: the vring.
  1739	 * @num: the number of descriptors to put back (ie. num
  1740	 *	 vringh_getdesc_iomem() to undo).
  1741	 *
  1742	 * The next vringh_get_kern() will return the old descriptor(s) again.
  1743	 */
> 1744	void vringh_abandon_iomem(struct vringh *vrh, unsigned int num)
  1745	{
  1746		vringh_abandon_kern(vrh, num);
  1747	}
  1748	EXPORT_SYMBOL(vringh_abandon_iomem);
  1749	
  1750	/**
  1751	 * vringh_complete_iomem - we've finished with descriptor, publish it.
  1752	 * @vrh: the vring.
  1753	 * @head: the head as filled in by vringh_getdesc_iomem().
  1754	 * @len: the length of data we have written.
  1755	 *
  1756	 * You should check vringh_need_notify_iomem() after one or more calls
  1757	 * to this function.
  1758	 */
> 1759	int vringh_complete_iomem(struct vringh *vrh, u16 head, u32 len)
  1760	{
  1761		struct vring_used_elem used;
  1762	
  1763		used.id = cpu_to_vringh32(vrh, head);
  1764		used.len = cpu_to_vringh32(vrh, len);
  1765	
  1766		return __vringh_complete(vrh, &used, 1, putu16_iomem, putused_iomem);
  1767	}
  1768	EXPORT_SYMBOL(vringh_complete_iomem);
  1769	
  1770	/**
  1771	 * vringh_notify_enable_iomem - we want to know if something changes.
  1772	 * @vrh: the vring.
  1773	 *
  1774	 * This always enables notifications, but returns false if there are
  1775	 * now more buffers available in the vring.
  1776	 */
> 1777	bool vringh_notify_enable_iomem(struct vringh *vrh)
  1778	{
  1779		return __vringh_notify_enable(vrh, getu16_iomem, putu16_iomem);
  1780	}
  1781	EXPORT_SYMBOL(vringh_notify_enable_iomem);
  1782	
  1783	/**
  1784	 * vringh_notify_disable_iomem - don't tell us if something changes.
  1785	 * @vrh: the vring.
  1786	 *
  1787	 * This is our normal running state: we disable and then only enable when
  1788	 * we're going to sleep.
  1789	 */
> 1790	void vringh_notify_disable_iomem(struct vringh *vrh)
  1791	{
  1792		__vringh_notify_disable(vrh, putu16_iomem);
  1793	}
  1794	EXPORT_SYMBOL(vringh_notify_disable_iomem);
  1795	
  1796	/**
  1797	 * vringh_need_notify_iomem - must we tell the other side about used buffers?
  1798	 * @vrh: the vring we've called vringh_complete_iomem() on.
  1799	 *
  1800	 * Returns -errno or 0 if we don't need to tell the other side, 1 if we do.
  1801	 */
> 1802	int vringh_need_notify_iomem(struct vringh *vrh)

1803 {
1804 return __vringh_need_notify(vrh, getu16_iomem);
1805 }
1806 EXPORT_SYMBOL(vringh_need_notify_iomem);
1807

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#3 lore raw

Re: [PATCH v4 1/1] vringh: IOMEM support

Quoted 57 lines · kernel test robot

Hi Shunsuke,

kernel test robot noticed the following build warnings:

[auto build test WARNING on mst-vhost/linux-next]
[also build test WARNING on linus/master horms-ipvs/master v6.4-rc4 next-20230602] [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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Shunsuke-Mie/vringh-IOMEM-support/20230602-135351
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git linux-next
patch link:    https://lore.kernel.org/r/20230602055211.309960-2-mie%40igel.co.jp
patch subject: [PATCH v4 1/1] vringh: IOMEM support
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20230602/[email protected]/config)
compiler: alpha-linux-gcc (GCC) 12.3.0

reproduce (this is a W=1 build):
mkdir -p ~/bin
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/de2a1f5220c32e953400f225aba6bd294a8d41b8
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Shunsuke-Mie/vringh-IOMEM-support/20230602-135351
git checkout de2a1f5220c32e953400f225aba6bd294a8d41b8
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir ARCH=alpha olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir ARCH=alpha SHELL=/bin/bash drivers/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

drivers/vhost/vringh.c:1661:5: warning: no previous prototype for 'vringh_init_iomem' [-Wmissing-prototypes]

1661 | int vringh_init_iomem(struct vringh *vrh, u64 features, unsigned int num,
| ^~~~~~~~~~~~~~~~~

Quoted 1 line
Quoted 1 line

drivers/vhost/vringh.c:1683:5: warning: no previous prototype for 'vringh_getdesc_iomem' [-Wmissing-prototypes]

1683 | int vringh_getdesc_iomem(struct vringh *vrh, struct vringh_kiov *riov,
| ^~~~~~~~~~~~~~~~~~~~

Quoted 1 line
Quoted 1 line

drivers/vhost/vringh.c:1714:9: warning: no previous prototype for 'vringh_iov_pull_iomem' [-Wmissing-prototypes]

1714 | ssize_t vringh_iov_pull_iomem(struct vringh *vrh, struct vringh_kiov *riov,
| ^~~~~~~~~~~~~~~~~~~~~

Quoted 1 line
Quoted 1 line

drivers/vhost/vringh.c:1729:9: warning: no previous prototype for 'vringh_iov_push_iomem' [-Wmissing-prototypes]

1729 | ssize_t vringh_iov_push_iomem(struct vringh *vrh, struct vringh_kiov *wiov,
| ^~~~~~~~~~~~~~~~~~~~~

Quoted 1 line
Quoted 1 line

drivers/vhost/vringh.c:1744:6: warning: no previous prototype for 'vringh_abandon_iomem' [-Wmissing-prototypes]

1744 | void vringh_abandon_iomem(struct vringh *vrh, unsigned int num)
| ^~~~~~~~~~~~~~~~~~~~

Quoted 1 line
Quoted 1 line

drivers/vhost/vringh.c:1759:5: warning: no previous prototype for 'vringh_complete_iomem' [-Wmissing-prototypes]

1759 | int vringh_complete_iomem(struct vringh *vrh, u16 head, u32 len)
| ^~~~~~~~~~~~~~~~~~~~~

Quoted 1 line
Quoted 1 line

drivers/vhost/vringh.c:1777:6: warning: no previous prototype for 'vringh_notify_enable_iomem' [-Wmissing-prototypes]

1777 | bool vringh_notify_enable_iomem(struct vringh *vrh)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~

Quoted 1 line
Quoted 1 line

drivers/vhost/vringh.c:1790:6: warning: no previous prototype for 'vringh_notify_disable_iomem' [-Wmissing-prototypes]

Quoted 8 lines

1790 | void vringh_notify_disable_iomem(struct vringh *vrh)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~

Quoted 1 line
Quoted 1 line

drivers/vhost/vringh.c:1802:5: warning: no previous prototype for 'vringh_need_notify_iomem' [-Wmissing-prototypes]

1802 | int vringh_need_notify_iomem(struct vringh *vrh)
| ^~~~~~~~~~~~~~~~~~~~~~~~

vim +/vringh_init_iomem +1661 drivers/vhost/vringh.c

You probably should put the relevant code within ifdef.

Quoted 165 lines

1647
1648 /**
1649 * vringh_init_iomem - initialize a vringh for a vring on io-memory.
1650 * @vrh: the vringh to initialize.
1651 * @features: the feature bits for this ring.
1652 * @num: the number of elements.
1653 * @weak_barriers: true if we only need memory barriers, not I/O.
1654 * @desc: the userspace descriptor pointer.
1655 * @avail: the userspace avail pointer.
1656 * @used: the userspace used pointer.
1657 *
1658 * Returns an error if num is invalid: you should check pointers
1659 * yourself!
1660 */

Quoted 1 line

1661 int vringh_init_iomem(struct vringh *vrh, u64 features, unsigned int num,

1662 bool weak_barriers, struct vring_desc *desc,
1663 struct vring_avail *avail, struct vring_used *used)
1664 {
1665 return vringh_init_kern(vrh, features, num, weak_barriers, desc, avail,
1666 used);
1667 }
1668 EXPORT_SYMBOL(vringh_init_iomem);
1669
1670 /**
1671 * vringh_getdesc_iomem - get next available descriptor from vring on io-memory.
1672 * @vrh: the vring on io-memory.
1673 * @riov: where to put the readable descriptors (or NULL)
1674 * @wiov: where to put the writable descriptors (or NULL)
1675 * @head: head index we received, for passing to vringh_complete_iomem().
1676 * @gfp: flags for allocating larger riov/wiov.
1677 *
1678 * Returns 0 if there was no descriptor, 1 if there was, or -errno.
1679 *
1680 * There some notes, and those are same with vringh_getdesc_kern(). Please see
1681 * it.
1682 */

Quoted 1 line

1683 int vringh_getdesc_iomem(struct vringh *vrh, struct vringh_kiov *riov,

1684 struct vringh_kiov *wiov, u16 *head, gfp_t gfp)
1685 {
1686 int err;
1687
1688 err = __vringh_get_head(vrh, getu16_iomem, &vrh->last_avail_idx);
1689 if (err < 0)
1690 return err;
1691
1692 /* Empty... */
1693 if (err == vrh->vring.num)
1694 return 0;
1695
1696 *head = err;
1697 err = __vringh_iov(vrh, *head, riov, wiov, no_range_check, NULL, gfp,
1698 copydesc_iomem);
1699 if (err)
1700 return err;
1701
1702 return 1;
1703 }
1704 EXPORT_SYMBOL(vringh_getdesc_iomem);
1705
1706 /**
1707 * vringh_iov_pull_iomem - copy bytes from vring_iov.
1708 * @riov: the riov as passed to vringh_getdesc_iomem() (updated as we consume)
1709 * @dst: the place to copy.
1710 * @len: the maximum length to copy.
1711 *
1712 * Returns the bytes copied <= len or a negative errno.
1713 */

Quoted 1 line

1714 ssize_t vringh_iov_pull_iomem(struct vringh *vrh, struct vringh_kiov *riov,

1715 void *dst, size_t len)
1716 {
1717 return vringh_iov_xfer(vrh, riov, dst, len, xfer_from_iomem);
1718 }
1719 EXPORT_SYMBOL(vringh_iov_pull_iomem);
1720
1721 /**
1722 * vringh_iov_push_iomem - copy bytes into vring_iov.
1723 * @wiov: the wiov as passed to vringh_getdesc_iomem() (updated as we consume)
1724 * @src: the place to copy from.
1725 * @len: the maximum length to copy.
1726 *
1727 * Returns the bytes copied <= len or a negative errno.
1728 */

Quoted 1 line

1729 ssize_t vringh_iov_push_iomem(struct vringh *vrh, struct vringh_kiov *wiov,

1730 const void *src, size_t len)
1731 {
1732 return vringh_iov_xfer(vrh, wiov, (void *)src, len, xfer_to_iomem);
1733 }
1734 EXPORT_SYMBOL(vringh_iov_push_iomem);
1735
1736 /**
1737 * vringh_abandon_iomem - we've decided not to handle the descriptor(s).
1738 * @vrh: the vring.
1739 * @num: the number of descriptors to put back (ie. num
1740 * vringh_getdesc_iomem() to undo).
1741 *
1742 * The next vringh_get_kern() will return the old descriptor(s) again.
1743 */

Quoted 1 line

1744 void vringh_abandon_iomem(struct vringh *vrh, unsigned int num)

1745 {
1746 vringh_abandon_kern(vrh, num);
1747 }
1748 EXPORT_SYMBOL(vringh_abandon_iomem);
1749
1750 /**
1751 * vringh_complete_iomem - we've finished with descriptor, publish it.
1752 * @vrh: the vring.
1753 * @head: the head as filled in by vringh_getdesc_iomem().
1754 * @len: the length of data we have written.
1755 *
1756 * You should check vringh_need_notify_iomem() after one or more calls
1757 * to this function.
1758 */

Quoted 1 line

1759 int vringh_complete_iomem(struct vringh *vrh, u16 head, u32 len)

1760 {
1761 struct vring_used_elem used;
1762
1763 used.id = cpu_to_vringh32(vrh, head);
1764 used.len = cpu_to_vringh32(vrh, len);
1765
1766 return __vringh_complete(vrh, &used, 1, putu16_iomem, putused_iomem);
1767 }
1768 EXPORT_SYMBOL(vringh_complete_iomem);
1769
1770 /**
1771 * vringh_notify_enable_iomem - we want to know if something changes.
1772 * @vrh: the vring.
1773 *
1774 * This always enables notifications, but returns false if there are
1775 * now more buffers available in the vring.
1776 */

Quoted 1 line

1777 bool vringh_notify_enable_iomem(struct vringh *vrh)

1778 {
1779 return __vringh_notify_enable(vrh, getu16_iomem, putu16_iomem);
1780 }
1781 EXPORT_SYMBOL(vringh_notify_enable_iomem);
1782
1783 /**
1784 * vringh_notify_disable_iomem - don't tell us if something changes.
1785 * @vrh: the vring.
1786 *
1787 * This is our normal running state: we disable and then only enable when
1788 * we're going to sleep.
1789 */

Quoted 1 line

1790 void vringh_notify_disable_iomem(struct vringh *vrh)

1791 {
1792 __vringh_notify_disable(vrh, putu16_iomem);
1793 }
1794 EXPORT_SYMBOL(vringh_notify_disable_iomem);
1795
1796 /**
1797 * vringh_need_notify_iomem - must we tell the other side about used buffers?
1798 * @vrh: the vring we've called vringh_complete_iomem() on.
1799 *
1800 * Returns -errno or 0 if we don't need to tell the other side, 1 if we do.
1801 */

Quoted 1 line

1802 int vringh_need_notify_iomem(struct vringh *vrh)

1803 {
1804 return __vringh_need_notify(vrh, getu16_iomem);
1805 }
1806 EXPORT_SYMBOL(vringh_need_notify_iomem);
1807

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#4 lore raw

Re: [PATCH v4 1/1] vringh: IOMEM support

Quoted 60 lines · Michael S. Tsirkin
Quoted 59 lines · kernel test robot

Hi Shunsuke,

kernel test robot noticed the following build warnings:

[auto build test WARNING on mst-vhost/linux-next]
[also build test WARNING on linus/master horms-ipvs/master v6.4-rc4 next-20230602] [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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Shunsuke-Mie/vringh-IOMEM-support/20230602-135351
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git linux-next
patch link:    https://lore.kernel.org/r/20230602055211.309960-2-mie%40igel.co.jp
patch subject: [PATCH v4 1/1] vringh: IOMEM support
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20230602/[email protected]/config)
compiler: alpha-linux-gcc (GCC) 12.3.0

reproduce (this is a W=1 build):
mkdir -p ~/bin
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/de2a1f5220c32e953400f225aba6bd294a8d41b8
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Shunsuke-Mie/vringh-IOMEM-support/20230602-135351
git checkout de2a1f5220c32e953400f225aba6bd294a8d41b8
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir ARCH=alpha olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir ARCH=alpha SHELL=/bin/bash drivers/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

drivers/vhost/vringh.c:1661:5: warning: no previous prototype for 'vringh_init_iomem' [-Wmissing-prototypes]

1661 | int vringh_init_iomem(struct vringh *vrh, u64 features, unsigned int num,
| ^~~~~~~~~~~~~~~~~

Quoted 1 line
Quoted 1 line

drivers/vhost/vringh.c:1683:5: warning: no previous prototype for 'vringh_getdesc_iomem' [-Wmissing-prototypes]

1683 | int vringh_getdesc_iomem(struct vringh *vrh, struct vringh_kiov *riov,
| ^~~~~~~~~~~~~~~~~~~~

Quoted 1 line
Quoted 1 line

drivers/vhost/vringh.c:1714:9: warning: no previous prototype for 'vringh_iov_pull_iomem' [-Wmissing-prototypes]

1714 | ssize_t vringh_iov_pull_iomem(struct vringh *vrh, struct vringh_kiov *riov,
| ^~~~~~~~~~~~~~~~~~~~~

Quoted 1 line
Quoted 1 line

drivers/vhost/vringh.c:1729:9: warning: no previous prototype for 'vringh_iov_push_iomem' [-Wmissing-prototypes]

1729 | ssize_t vringh_iov_push_iomem(struct vringh *vrh, struct vringh_kiov *wiov,
| ^~~~~~~~~~~~~~~~~~~~~

Quoted 1 line
Quoted 1 line

drivers/vhost/vringh.c:1744:6: warning: no previous prototype for 'vringh_abandon_iomem' [-Wmissing-prototypes]

1744 | void vringh_abandon_iomem(struct vringh *vrh, unsigned int num)
| ^~~~~~~~~~~~~~~~~~~~

Quoted 1 line
Quoted 1 line

drivers/vhost/vringh.c:1759:5: warning: no previous prototype for 'vringh_complete_iomem' [-Wmissing-prototypes]

1759 | int vringh_complete_iomem(struct vringh *vrh, u16 head, u32 len)
| ^~~~~~~~~~~~~~~~~~~~~

Quoted 1 line
Quoted 1 line

drivers/vhost/vringh.c:1777:6: warning: no previous prototype for 'vringh_notify_enable_iomem' [-Wmissing-prototypes]

1777 | bool vringh_notify_enable_iomem(struct vringh *vrh)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~

Quoted 1 line
Quoted 1 line

drivers/vhost/vringh.c:1790:6: warning: no previous prototype for 'vringh_notify_disable_iomem' [-Wmissing-prototypes]

1790 | void vringh_notify_disable_iomem(struct vringh *vrh)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~

Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line

drivers/vhost/vringh.c:1802:5: warning: no previous prototype for 'vringh_need_notify_iomem' [-Wmissing-prototypes]

1802 | int vringh_need_notify_iomem(struct vringh *vrh)
| ^~~~~~~~~~~~~~~~~~~~~~~~

vim +/vringh_init_iomem +1661 drivers/vhost/vringh.c

You probably should put the relevant code within ifdef.

I should'v removed a ifdef/endif from a header file, vringh.h. I'll fix it.

Quoted 163 lines
Quoted 163 lines

1647
1648 /**
1649 * vringh_init_iomem - initialize a vringh for a vring on io-memory.
1650 * @vrh: the vringh to initialize.
1651 * @features: the feature bits for this ring.
1652 * @num: the number of elements.
1653 * @weak_barriers: true if we only need memory barriers, not I/O.
1654 * @desc: the userspace descriptor pointer.
1655 * @avail: the userspace avail pointer.
1656 * @used: the userspace used pointer.
1657 *
1658 * Returns an error if num is invalid: you should check pointers
1659 * yourself!
1660 */

Quoted 1 line

1661 int vringh_init_iomem(struct vringh *vrh, u64 features, unsigned int num,

1662 bool weak_barriers, struct vring_desc *desc,
1663 struct vring_avail *avail, struct vring_used *used)

   1664	{
   1665		return vringh_init_kern(vrh, features, num, weak_barriers, desc, avail,
   1666					used);
   1667	}
   1668	EXPORT_SYMBOL(vringh_init_iomem);
   1669	
   1670	/**
   1671	 * vringh_getdesc_iomem - get next available descriptor from vring on io-memory.
   1672	 * @vrh: the vring on io-memory.
   1673	 * @riov: where to put the readable descriptors (or NULL)
   1674	 * @wiov: where to put the writable descriptors (or NULL)
   1675	 * @head: head index we received, for passing to vringh_complete_iomem().
   1676	 * @gfp: flags for allocating larger riov/wiov.
   1677	 *
   1678	 * Returns 0 if there was no descriptor, 1 if there was, or -errno.
   1679	 *
   1680	 * There some notes, and those are same with vringh_getdesc_kern(). Please see
   1681	 * it.
   1682	 */
Quoted 1 line

1683 int vringh_getdesc_iomem(struct vringh *vrh, struct vringh_kiov *riov,

1684 struct vringh_kiov *wiov, u16 *head, gfp_t gfp)

   1685	{
   1686		int err;
   1687	
   1688		err = __vringh_get_head(vrh, getu16_iomem, &vrh->last_avail_idx);
   1689		if (err < 0)
   1690			return err;
   1691	
   1692		/* Empty... */
   1693		if (err == vrh->vring.num)
   1694			return 0;
   1695	
   1696		*head = err;
   1697		err = __vringh_iov(vrh, *head, riov, wiov, no_range_check, NULL, gfp,
   1698				   copydesc_iomem);
   1699		if (err)
   1700			return err;
   1701	
   1702		return 1;
   1703	}
   1704	EXPORT_SYMBOL(vringh_getdesc_iomem);
   1705	
   1706	/**
   1707	 * vringh_iov_pull_iomem - copy bytes from vring_iov.
   1708	 * @riov: the riov as passed to vringh_getdesc_iomem() (updated as we consume)
   1709	 * @dst: the place to copy.
   1710	 * @len: the maximum length to copy.
   1711	 *
   1712	 * Returns the bytes copied <= len or a negative errno.
   1713	 */
Quoted 1 line

1714 ssize_t vringh_iov_pull_iomem(struct vringh *vrh, struct vringh_kiov *riov,

1715 void *dst, size_t len)

   1716	{
   1717		return vringh_iov_xfer(vrh, riov, dst, len, xfer_from_iomem);
   1718	}
   1719	EXPORT_SYMBOL(vringh_iov_pull_iomem);
   1720	
   1721	/**
   1722	 * vringh_iov_push_iomem - copy bytes into vring_iov.
   1723	 * @wiov: the wiov as passed to vringh_getdesc_iomem() (updated as we consume)
   1724	 * @src: the place to copy from.
   1725	 * @len: the maximum length to copy.
   1726	 *
   1727	 * Returns the bytes copied <= len or a negative errno.
   1728	 */
Quoted 1 line

1729 ssize_t vringh_iov_push_iomem(struct vringh *vrh, struct vringh_kiov *wiov,

1730 const void *src, size_t len)

   1731	{
   1732		return vringh_iov_xfer(vrh, wiov, (void *)src, len, xfer_to_iomem);
   1733	}
   1734	EXPORT_SYMBOL(vringh_iov_push_iomem);
   1735	
   1736	/**
   1737	 * vringh_abandon_iomem - we've decided not to handle the descriptor(s).
   1738	 * @vrh: the vring.
   1739	 * @num: the number of descriptors to put back (ie. num
   1740	 *	 vringh_getdesc_iomem() to undo).
   1741	 *
   1742	 * The next vringh_get_kern() will return the old descriptor(s) again.
   1743	 */
Quoted 1 line

1744 void vringh_abandon_iomem(struct vringh *vrh, unsigned int num)

   1745	{
   1746		vringh_abandon_kern(vrh, num);
   1747	}
   1748	EXPORT_SYMBOL(vringh_abandon_iomem);
   1749	
   1750	/**
   1751	 * vringh_complete_iomem - we've finished with descriptor, publish it.
   1752	 * @vrh: the vring.
   1753	 * @head: the head as filled in by vringh_getdesc_iomem().
   1754	 * @len: the length of data we have written.
   1755	 *
   1756	 * You should check vringh_need_notify_iomem() after one or more calls
   1757	 * to this function.
   1758	 */
Quoted 1 line

1759 int vringh_complete_iomem(struct vringh *vrh, u16 head, u32 len)

   1760	{
   1761		struct vring_used_elem used;
   1762	
   1763		used.id = cpu_to_vringh32(vrh, head);
   1764		used.len = cpu_to_vringh32(vrh, len);
   1765	
   1766		return __vringh_complete(vrh, &used, 1, putu16_iomem, putused_iomem);
   1767	}
   1768	EXPORT_SYMBOL(vringh_complete_iomem);
   1769	
   1770	/**
   1771	 * vringh_notify_enable_iomem - we want to know if something changes.
   1772	 * @vrh: the vring.
   1773	 *
   1774	 * This always enables notifications, but returns false if there are
   1775	 * now more buffers available in the vring.
   1776	 */
Quoted 1 line

1777 bool vringh_notify_enable_iomem(struct vringh *vrh)

   1778	{
   1779		return __vringh_notify_enable(vrh, getu16_iomem, putu16_iomem);
   1780	}
   1781	EXPORT_SYMBOL(vringh_notify_enable_iomem);
   1782	
   1783	/**
   1784	 * vringh_notify_disable_iomem - don't tell us if something changes.
   1785	 * @vrh: the vring.
   1786	 *
   1787	 * This is our normal running state: we disable and then only enable when
   1788	 * we're going to sleep.
   1789	 */
Quoted 1 line

1790 void vringh_notify_disable_iomem(struct vringh *vrh)

   1791	{
   1792		__vringh_notify_disable(vrh, putu16_iomem);
   1793	}
   1794	EXPORT_SYMBOL(vringh_notify_disable_iomem);
   1795	
   1796	/**
   1797	 * vringh_need_notify_iomem - must we tell the other side about used buffers?
   1798	 * @vrh: the vring we've called vringh_complete_iomem() on.
   1799	 *
   1800	 * Returns -errno or 0 if we don't need to tell the other side, 1 if we do.
   1801	 */
Quoted 1 line

1802 int vringh_need_notify_iomem(struct vringh *vrh)

   1803	{
   1804		return __vringh_need_notify(vrh, getu16_iomem);
   1805	}
   1806	EXPORT_SYMBOL(vringh_need_notify_iomem);
   1807	
Quoted 3 lines
Quoted 3 lines
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

Best regards,

Shunsuke

#5 lore raw

Re: [PATCH v4 1/1] vringh: IOMEM support

In reply to Shunsuke Mie
kernel test robot noticed the following build warnings:

Hi Shunsuke,

kernel test robot noticed the following build warnings:

[auto build test WARNING on mst-vhost/linux-next]
[also build test WARNING on linus/master horms-ipvs/master v6.4-rc4 next-20230602] [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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Shunsuke-Mie/vringh-IOMEM-support/20230602-135351
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git linux-next
patch link:    https://lore.kernel.org/r/20230602055211.309960-2-mie%40igel.co.jp
patch subject: [PATCH v4 1/1] vringh: IOMEM support
config: hexagon-randconfig-r034-20230531 (https://download.01.org/0day-ci/archive/20230603/[email protected]/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project 4faf3aaf28226a4e950c103a14f6fc1d1fdabb1b)

reproduce (this is a W=1 build):
mkdir -p ~/bin
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/de2a1f5220c32e953400f225aba6bd294a8d41b8
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Shunsuke-Mie/vringh-IOMEM-support/20230602-135351
git checkout de2a1f5220c32e953400f225aba6bd294a8d41b8
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=hexagon olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/vhost/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

In file included from drivers/vhost/vringh.c:17:
In file included from include/linux/bvec.h:10:
In file included from include/linux/highmem.h:12:
In file included from include/linux/hardirq.h:11:
In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/hexagon/include/asm/io.h:334:
include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]

           val = __raw_readb(PCI_IOBASE + addr);
                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
   #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
                                                     ^
   In file included from drivers/vhost/vringh.c:17:
   In file included from include/linux/bvec.h:10:
   In file included from include/linux/highmem.h:12:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:334:
   include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
                                                     ^
   In file included from drivers/vhost/vringh.c:17:
   In file included from include/linux/bvec.h:10:
   In file included from include/linux/highmem.h:12:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:334:
   include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writeb(value, PCI_IOBASE + addr);
                               ~~~~~~~~~~ ^
   include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
>> drivers/vhost/vringh.c:1661:5: warning: no previous prototype for function 'vringh_init_iomem' [-Wmissing-prototypes]
   int vringh_init_iomem(struct vringh *vrh, u64 features, unsigned int num,
       ^
   drivers/vhost/vringh.c:1661:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int vringh_init_iomem(struct vringh *vrh, u64 features, unsigned int num,
   ^
   static 
>> drivers/vhost/vringh.c:1683:5: warning: no previous prototype for function 'vringh_getdesc_iomem' [-Wmissing-prototypes]
   int vringh_getdesc_iomem(struct vringh *vrh, struct vringh_kiov *riov,
       ^
   drivers/vhost/vringh.c:1683:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int vringh_getdesc_iomem(struct vringh *vrh, struct vringh_kiov *riov,
   ^
   static 
>> drivers/vhost/vringh.c:1714:9: warning: no previous prototype for function 'vringh_iov_pull_iomem' [-Wmissing-prototypes]
   ssize_t vringh_iov_pull_iomem(struct vringh *vrh, struct vringh_kiov *riov,
           ^
   drivers/vhost/vringh.c:1714:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   ssize_t vringh_iov_pull_iomem(struct vringh *vrh, struct vringh_kiov *riov,
   ^
   static 
>> drivers/vhost/vringh.c:1729:9: warning: no previous prototype for function 'vringh_iov_push_iomem' [-Wmissing-prototypes]
   ssize_t vringh_iov_push_iomem(struct vringh *vrh, struct vringh_kiov *wiov,
           ^
   drivers/vhost/vringh.c:1729:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   ssize_t vringh_iov_push_iomem(struct vringh *vrh, struct vringh_kiov *wiov,
   ^
   static 
>> drivers/vhost/vringh.c:1744:6: warning: no previous prototype for function 'vringh_abandon_iomem' [-Wmissing-prototypes]
   void vringh_abandon_iomem(struct vringh *vrh, unsigned int num)
        ^
   drivers/vhost/vringh.c:1744:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void vringh_abandon_iomem(struct vringh *vrh, unsigned int num)
   ^
   static 
>> drivers/vhost/vringh.c:1759:5: warning: no previous prototype for function 'vringh_complete_iomem' [-Wmissing-prototypes]
   int vringh_complete_iomem(struct vringh *vrh, u16 head, u32 len)
       ^
   drivers/vhost/vringh.c:1759:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int vringh_complete_iomem(struct vringh *vrh, u16 head, u32 len)
   ^
   static 
>> drivers/vhost/vringh.c:1777:6: warning: no previous prototype for function 'vringh_notify_enable_iomem' [-Wmissing-prototypes]
   bool vringh_notify_enable_iomem(struct vringh *vrh)
        ^
   drivers/vhost/vringh.c:1777:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   bool vringh_notify_enable_iomem(struct vringh *vrh)
   ^
   static 
>> drivers/vhost/vringh.c:1790:6: warning: no previous prototype for function 'vringh_notify_disable_iomem' [-Wmissing-prototypes]
   void vringh_notify_disable_iomem(struct vringh *vrh)
        ^
   drivers/vhost/vringh.c:1790:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void vringh_notify_disable_iomem(struct vringh *vrh)
   ^
   static 
>> drivers/vhost/vringh.c:1802:5: warning: no previous prototype for function 'vringh_need_notify_iomem' [-Wmissing-prototypes]
   int vringh_need_notify_iomem(struct vringh *vrh)
       ^

drivers/vhost/vringh.c:1802:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int vringh_need_notify_iomem(struct vringh *vrh)
^
static
15 warnings generated.

vim +/vringh_init_iomem +1661 drivers/vhost/vringh.c

1647
1648 /**
1649 * vringh_init_iomem - initialize a vringh for a vring on io-memory.
1650 * @vrh: the vringh to initialize.
1651 * @features: the feature bits for this ring.
1652 * @num: the number of elements.
1653 * @weak_barriers: true if we only need memory barriers, not I/O.
1654 * @desc: the userspace descriptor pointer.
1655 * @avail: the userspace avail pointer.
1656 * @used: the userspace used pointer.
1657 *
1658 * Returns an error if num is invalid: you should check pointers
1659 * yourself!
1660 */

> 1661	int vringh_init_iomem(struct vringh *vrh, u64 features, unsigned int num,
  1662			      bool weak_barriers, struct vring_desc *desc,
  1663			      struct vring_avail *avail, struct vring_used *used)
  1664	{
  1665		return vringh_init_kern(vrh, features, num, weak_barriers, desc, avail,
  1666					used);
  1667	}
  1668	EXPORT_SYMBOL(vringh_init_iomem);
  1669	
  1670	/**
  1671	 * vringh_getdesc_iomem - get next available descriptor from vring on io-memory.
  1672	 * @vrh: the vring on io-memory.
  1673	 * @riov: where to put the readable descriptors (or NULL)
  1674	 * @wiov: where to put the writable descriptors (or NULL)
  1675	 * @head: head index we received, for passing to vringh_complete_iomem().
  1676	 * @gfp: flags for allocating larger riov/wiov.
  1677	 *
  1678	 * Returns 0 if there was no descriptor, 1 if there was, or -errno.
  1679	 *
  1680	 * There some notes, and those are same with vringh_getdesc_kern(). Please see
  1681	 * it.
  1682	 */
> 1683	int vringh_getdesc_iomem(struct vringh *vrh, struct vringh_kiov *riov,
  1684				 struct vringh_kiov *wiov, u16 *head, gfp_t gfp)
  1685	{
  1686		int err;
  1687	
  1688		err = __vringh_get_head(vrh, getu16_iomem, &vrh->last_avail_idx);
  1689		if (err < 0)
  1690			return err;
  1691	
  1692		/* Empty... */
  1693		if (err == vrh->vring.num)
  1694			return 0;
  1695	
  1696		*head = err;
  1697		err = __vringh_iov(vrh, *head, riov, wiov, no_range_check, NULL, gfp,
  1698				   copydesc_iomem);
  1699		if (err)
  1700			return err;
  1701	
  1702		return 1;
  1703	}
  1704	EXPORT_SYMBOL(vringh_getdesc_iomem);
  1705	
  1706	/**
  1707	 * vringh_iov_pull_iomem - copy bytes from vring_iov.
  1708	 * @riov: the riov as passed to vringh_getdesc_iomem() (updated as we consume)
  1709	 * @dst: the place to copy.
  1710	 * @len: the maximum length to copy.
  1711	 *
  1712	 * Returns the bytes copied <= len or a negative errno.
  1713	 */
> 1714	ssize_t vringh_iov_pull_iomem(struct vringh *vrh, struct vringh_kiov *riov,
  1715				      void *dst, size_t len)
  1716	{
  1717		return vringh_iov_xfer(vrh, riov, dst, len, xfer_from_iomem);
  1718	}
  1719	EXPORT_SYMBOL(vringh_iov_pull_iomem);
  1720	
  1721	/**
  1722	 * vringh_iov_push_iomem - copy bytes into vring_iov.
  1723	 * @wiov: the wiov as passed to vringh_getdesc_iomem() (updated as we consume)
  1724	 * @src: the place to copy from.
  1725	 * @len: the maximum length to copy.
  1726	 *
  1727	 * Returns the bytes copied <= len or a negative errno.
  1728	 */
> 1729	ssize_t vringh_iov_push_iomem(struct vringh *vrh, struct vringh_kiov *wiov,
  1730				      const void *src, size_t len)
  1731	{
  1732		return vringh_iov_xfer(vrh, wiov, (void *)src, len, xfer_to_iomem);
  1733	}
  1734	EXPORT_SYMBOL(vringh_iov_push_iomem);
  1735	
  1736	/**
  1737	 * vringh_abandon_iomem - we've decided not to handle the descriptor(s).
  1738	 * @vrh: the vring.
  1739	 * @num: the number of descriptors to put back (ie. num
  1740	 *	 vringh_getdesc_iomem() to undo).
  1741	 *
  1742	 * The next vringh_get_kern() will return the old descriptor(s) again.
  1743	 */
> 1744	void vringh_abandon_iomem(struct vringh *vrh, unsigned int num)
  1745	{
  1746		vringh_abandon_kern(vrh, num);
  1747	}
  1748	EXPORT_SYMBOL(vringh_abandon_iomem);
  1749	
  1750	/**
  1751	 * vringh_complete_iomem - we've finished with descriptor, publish it.
  1752	 * @vrh: the vring.
  1753	 * @head: the head as filled in by vringh_getdesc_iomem().
  1754	 * @len: the length of data we have written.
  1755	 *
  1756	 * You should check vringh_need_notify_iomem() after one or more calls
  1757	 * to this function.
  1758	 */
> 1759	int vringh_complete_iomem(struct vringh *vrh, u16 head, u32 len)
  1760	{
  1761		struct vring_used_elem used;
  1762	
  1763		used.id = cpu_to_vringh32(vrh, head);
  1764		used.len = cpu_to_vringh32(vrh, len);
  1765	
  1766		return __vringh_complete(vrh, &used, 1, putu16_iomem, putused_iomem);
  1767	}
  1768	EXPORT_SYMBOL(vringh_complete_iomem);
  1769	
  1770	/**
  1771	 * vringh_notify_enable_iomem - we want to know if something changes.
  1772	 * @vrh: the vring.
  1773	 *
  1774	 * This always enables notifications, but returns false if there are
  1775	 * now more buffers available in the vring.
  1776	 */
> 1777	bool vringh_notify_enable_iomem(struct vringh *vrh)
  1778	{
  1779		return __vringh_notify_enable(vrh, getu16_iomem, putu16_iomem);
  1780	}
  1781	EXPORT_SYMBOL(vringh_notify_enable_iomem);
  1782	
  1783	/**
  1784	 * vringh_notify_disable_iomem - don't tell us if something changes.
  1785	 * @vrh: the vring.
  1786	 *
  1787	 * This is our normal running state: we disable and then only enable when
  1788	 * we're going to sleep.
  1789	 */
> 1790	void vringh_notify_disable_iomem(struct vringh *vrh)
  1791	{
  1792		__vringh_notify_disable(vrh, putu16_iomem);
  1793	}
  1794	EXPORT_SYMBOL(vringh_notify_disable_iomem);
  1795	
  1796	/**
  1797	 * vringh_need_notify_iomem - must we tell the other side about used buffers?
  1798	 * @vrh: the vring we've called vringh_complete_iomem() on.
  1799	 *
  1800	 * Returns -errno or 0 if we don't need to tell the other side, 1 if we do.
  1801	 */
> 1802	int vringh_need_notify_iomem(struct vringh *vrh)

1803 {
1804 return __vringh_need_notify(vrh, getu16_iomem);
1805 }
1806 EXPORT_SYMBOL(vringh_need_notify_iomem);
1807

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#6 lore raw

Re: [PATCH v4 1/1] vringh: IOMEM support

In reply to Shunsuke Mie
kernel test robot noticed the following build errors:

Hi Shunsuke,

kernel test robot noticed the following build errors:

[auto build test ERROR on mst-vhost/linux-next]
[also build test ERROR on linus/master horms-ipvs/master v6.4-rc4 next-20230602] [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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Shunsuke-Mie/vringh-IOMEM-support/20230602-135351
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git linux-next
patch link:    https://lore.kernel.org/r/20230602055211.309960-2-mie%40igel.co.jp
patch subject: [PATCH v4 1/1] vringh: IOMEM support
config: i386-randconfig-i003-20230531 (https://download.01.org/0day-ci/archive/20230603/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0

reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/de2a1f5220c32e953400f225aba6bd294a8d41b8
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Shunsuke-Mie/vringh-IOMEM-support/20230602-135351 git checkout de2a1f5220c32e953400f225aba6bd294a8d41b8
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=i386 olddefconfig
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/vhost/vringh.c: In function 'getu16_iomem':

>> drivers/vhost/vringh.c:1610:37: error: implicit declaration of function 'ioread16' [-Werror=implicit-function-declaration]
    1610 |         *val = vringh16_to_cpu(vrh, ioread16(p));
         |                                     ^~~~~~~~
   drivers/vhost/vringh.c: In function 'putu16_iomem':
>> drivers/vhost/vringh.c:1616:9: error: implicit declaration of function 'iowrite16' [-Werror=implicit-function-declaration]
    1616 |         iowrite16(cpu_to_vringh16(vrh, val), p);
         |         ^~~~~~~~~
   drivers/vhost/vringh.c: In function 'copydesc_iomem':
>> drivers/vhost/vringh.c:1623:9: error: implicit declaration of function 'memcpy_fromio'; did you mean 'memcpy_from_bvec'? [-Werror=implicit-function-declaration]
    1623 |         memcpy_fromio(dst, src, len);
         |         ^~~~~~~~~~~~~
         |         memcpy_from_bvec
   drivers/vhost/vringh.c: In function 'putused_iomem':
>> drivers/vhost/vringh.c:1630:9: error: implicit declaration of function 'memcpy_toio' [-Werror=implicit-function-declaration]
    1630 |         memcpy_toio(dst, src, num * sizeof(*dst));
         |         ^~~~~~~~~~~

drivers/vhost/vringh.c: At top level:
drivers/vhost/vringh.c:1661:5: warning: no previous prototype for 'vringh_init_iomem' [-Wmissing-prototypes]
1661 | int vringh_init_iomem(struct vringh *vrh, u64 features, unsigned int num,
| ^~~~~~~~~~~~~~~~~
drivers/vhost/vringh.c:1683:5: warning: no previous prototype for 'vringh_getdesc_iomem' [-Wmissing-prototypes]
1683 | int vringh_getdesc_iomem(struct vringh *vrh, struct vringh_kiov *riov,
| ^~~~~~~~~~~~~~~~~~~~
drivers/vhost/vringh.c:1714:9: warning: no previous prototype for 'vringh_iov_pull_iomem' [-Wmissing-prototypes]
1714 | ssize_t vringh_iov_pull_iomem(struct vringh *vrh, struct vringh_kiov *riov,
| ^~~~~~~~~~~~~~~~~~~~~
drivers/vhost/vringh.c:1729:9: warning: no previous prototype for 'vringh_iov_push_iomem' [-Wmissing-prototypes]
1729 | ssize_t vringh_iov_push_iomem(struct vringh *vrh, struct vringh_kiov *wiov,
| ^~~~~~~~~~~~~~~~~~~~~
drivers/vhost/vringh.c:1744:6: warning: no previous prototype for 'vringh_abandon_iomem' [-Wmissing-prototypes]
1744 | void vringh_abandon_iomem(struct vringh *vrh, unsigned int num)
| ^~~~~~~~~~~~~~~~~~~~
drivers/vhost/vringh.c:1759:5: warning: no previous prototype for 'vringh_complete_iomem' [-Wmissing-prototypes]
1759 | int vringh_complete_iomem(struct vringh *vrh, u16 head, u32 len)
| ^~~~~~~~~~~~~~~~~~~~~
drivers/vhost/vringh.c:1777:6: warning: no previous prototype for 'vringh_notify_enable_iomem' [-Wmissing-prototypes]
1777 | bool vringh_notify_enable_iomem(struct vringh *vrh)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/vhost/vringh.c:1790:6: warning: no previous prototype for 'vringh_notify_disable_iomem' [-Wmissing-prototypes]
1790 | void vringh_notify_disable_iomem(struct vringh *vrh)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/vhost/vringh.c:1802:5: warning: no previous prototype for 'vringh_need_notify_iomem' [-Wmissing-prototypes]
1802 | int vringh_need_notify_iomem(struct vringh *vrh)
| ^~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors

vim +/ioread16 +1610 drivers/vhost/vringh.c

1606
1607 static inline int getu16_iomem(const struct vringh *vrh, u16 *val,
1608 const __virtio16 *p)
1609 {

> 1610		*val = vringh16_to_cpu(vrh, ioread16(p));
  1611		return 0;
  1612	}
  1613	
  1614	static inline int putu16_iomem(const struct vringh *vrh, __virtio16 *p, u16 val)
  1615	{
> 1616		iowrite16(cpu_to_vringh16(vrh, val), p);
  1617		return 0;
  1618	}
  1619	
  1620	static inline int copydesc_iomem(const struct vringh *vrh, void *dst,
  1621					 const void *src, size_t len)
  1622	{
> 1623		memcpy_fromio(dst, src, len);
  1624		return 0;
  1625	}
  1626	
  1627	static int putused_iomem(const struct vringh *vrh, struct vring_used_elem *dst,
  1628				 const struct vring_used_elem *src, unsigned int num)
  1629	{
> 1630		memcpy_toio(dst, src, num * sizeof(*dst));

1631 return 0;
1632 }
1633

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#7 lore raw

Re: [PATCH v4 1/1] vringh: IOMEM support

In reply to Shunsuke Mie
kernel test robot noticed the following build warnings:

Hi Shunsuke,

kernel test robot noticed the following build warnings:

[auto build test WARNING on mst-vhost/linux-next]
[also build test WARNING on linus/master horms-ipvs/master v6.4-rc4 next-20230602] [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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Shunsuke-Mie/vringh-IOMEM-support/20230602-135351
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git linux-next
patch link:    https://lore.kernel.org/r/20230602055211.309960-2-mie%40igel.co.jp
patch subject: [PATCH v4 1/1] vringh: IOMEM support
config: nios2-randconfig-s053-20230531 (https://download.01.org/0day-ci/archive/20230603/[email protected]/config)
compiler: nios2-linux-gcc (GCC) 12.3.0

reproduce:
mkdir -p ~/bin
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.4-39-gce1a6720-dirty
# https://github.com/intel-lab-lkp/linux/commit/de2a1f5220c32e953400f225aba6bd294a8d41b8
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Shunsuke-Mie/vringh-IOMEM-support/20230602-135351
git checkout de2a1f5220c32e953400f225aba6bd294a8d41b8
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=nios2 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=nios2 SHELL=/bin/bash drivers/vhost/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

sparse warnings: (new ones prefixed by >>)

>> drivers/vhost/vringh.c:1630:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void volatile [noderef] __iomem *addr @@     got struct vring_used_elem *dst @@
   drivers/vhost/vringh.c:1630:21: sparse:     expected void volatile [noderef] __iomem *addr
   drivers/vhost/vringh.c:1630:21: sparse:     got struct vring_used_elem *dst
   drivers/vhost/vringh.c:592:18: sparse: sparse: restricted __virtio16 degrades to integer
   drivers/vhost/vringh.c:592:18: sparse: sparse: restricted __virtio16 degrades to integer
   drivers/vhost/vringh.c:592:18: sparse: sparse: cast to restricted __virtio16
   drivers/vhost/vringh.c:1280:23: sparse: sparse: restricted __virtio16 degrades to integer
   drivers/vhost/vringh.c:1280:23: sparse: sparse: restricted __virtio16 degrades to integer
   drivers/vhost/vringh.c:1280:23: sparse: sparse: cast to restricted __virtio16
>> drivers/vhost/vringh.c:1610:46: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile [noderef] __iomem *addr @@     got restricted __virtio16 const [usertype] *p @@
   drivers/vhost/vringh.c:1610:46: sparse:     expected void const volatile [noderef] __iomem *addr
   drivers/vhost/vringh.c:1610:46: sparse:     got restricted __virtio16 const [usertype] *p
>> drivers/vhost/vringh.c:1610:45: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected restricted __virtio16 [usertype] val @@     got unsigned short @@
   drivers/vhost/vringh.c:1610:45: sparse:     expected restricted __virtio16 [usertype] val
   drivers/vhost/vringh.c:1610:45: sparse:     got unsigned short
>> drivers/vhost/vringh.c:1623:28: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected void const volatile [noderef] __iomem *addr @@     got void const *src @@
   drivers/vhost/vringh.c:1623:28: sparse:     expected void const volatile [noderef] __iomem *addr
   drivers/vhost/vringh.c:1623:28: sparse:     got void const *src
>> drivers/vhost/vringh.c:1637:28: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected void const volatile [noderef] __iomem *addr @@     got void *src @@
   drivers/vhost/vringh.c:1637:28: sparse:     expected void const volatile [noderef] __iomem *addr
   drivers/vhost/vringh.c:1637:28: sparse:     got void *src
>> drivers/vhost/vringh.c:1644:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void volatile [noderef] __iomem *addr @@     got void *dst @@
   drivers/vhost/vringh.c:1644:21: sparse:     expected void volatile [noderef] __iomem *addr
   drivers/vhost/vringh.c:1644:21: sparse:     got void *dst
>> drivers/vhost/vringh.c:1616:34: sparse: sparse: incorrect type in argument 1 (different base types) @@     expected unsigned short [usertype] value @@     got restricted __virtio16 @@
   drivers/vhost/vringh.c:1616:34: sparse:     expected unsigned short [usertype] value
   drivers/vhost/vringh.c:1616:34: sparse:     got restricted __virtio16
>> drivers/vhost/vringh.c:1616:46: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected void volatile [noderef] __iomem *addr @@     got restricted __virtio16 [usertype] *p @@

drivers/vhost/vringh.c:1616:46: sparse: expected void volatile [noderef] __iomem *addr
drivers/vhost/vringh.c:1616:46: sparse: got restricted __virtio16 [usertype] *p
drivers/vhost/vringh.c: note: in included file (through include/uapi/linux/swab.h, include/linux/swab.h, include/uapi/linux/byteorder/little_endian.h, ...):
arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:25:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:25:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:25:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:25:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:25:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:31:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:25:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:25:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:25:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:25:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:25:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:25:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:25:24: sparse: sparse: too many arguments for function __builtin_custom_ini arch/nios2/include/uapi/asm/swab.h:25:24: sparse: sparse: too many arguments for function __builtin_custom_ini

vim +1630 drivers/vhost/vringh.c

1606
1607 static inline int getu16_iomem(const struct vringh *vrh, u16 *val,
1608 const __virtio16 *p)
1609 {

> 1610		*val = vringh16_to_cpu(vrh, ioread16(p));
  1611		return 0;
  1612	}
  1613	
  1614	static inline int putu16_iomem(const struct vringh *vrh, __virtio16 *p, u16 val)
  1615	{
> 1616		iowrite16(cpu_to_vringh16(vrh, val), p);
  1617		return 0;
  1618	}
  1619	
  1620	static inline int copydesc_iomem(const struct vringh *vrh, void *dst,
  1621					 const void *src, size_t len)
  1622	{
> 1623		memcpy_fromio(dst, src, len);
  1624		return 0;
  1625	}
  1626	
  1627	static int putused_iomem(const struct vringh *vrh, struct vring_used_elem *dst,
  1628				 const struct vring_used_elem *src, unsigned int num)
  1629	{
> 1630		memcpy_toio(dst, src, num * sizeof(*dst));
  1631		return 0;
  1632	}
  1633	
  1634	static inline int xfer_from_iomem(const struct vringh *vrh, void *src,
  1635					  void *dst, size_t len)
  1636	{
> 1637		memcpy_fromio(dst, src, len);
  1638		return 0;
  1639	}
  1640	
  1641	static inline int xfer_to_iomem(const struct vringh *vrh, void *dst, void *src,
  1642					size_t len)
  1643	{
> 1644		memcpy_toio(dst, src, len);

1645 return 0;
1646 }
1647

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#8 lore raw

Re: [PATCH v4 1/1] vringh: IOMEM support

In reply to Shunsuke Mie
Quoted 4 lines · Shunsuke Mie

Introduce a new memory accessor for vringh. It is able to use vringh to virtio rings located on io-memory region.

...

Quoted 2 lines

+/**
+ * vringh_iov_pull_iomem - copy bytes from vring_iov.

Hi Mie-san,

as it looks like there will be a v2,
please consider documenting the vrh parameter here.

Quoted 6 lines

+ * @riov: the riov as passed to vringh_getdesc_iomem() (updated as we consume)
+ * @dst: the place to copy.
+ * @len: the maximum length to copy.
+ *
+ * Returns the bytes copied <= len or a negative errno.
+ */

drivers/vhost/vringh.c EXPORT_SYMBOL(vringh_need_notify_iotlb); · line 1722

Quoted 9 lines
drivers/vhost/vringh.c +9 -0
+ssize_t vringh_iov_pull_iomem(struct vringh *vrh, struct vringh_kiov *riov,
+			      void *dst, size_t len)
+{
+	return vringh_iov_xfer(vrh, riov, dst, len, xfer_from_iomem);
+}
+EXPORT_SYMBOL(vringh_iov_pull_iomem);
+
+/**
+ * vringh_iov_push_iomem - copy bytes into vring_iov.

And here.

Quoted 12 lines

+ * @wiov: the wiov as passed to vringh_getdesc_iomem() (updated as we consume)
+ * @src: the place to copy from.
+ * @len: the maximum length to copy.
+ *
+ * Returns the bytes copied <= len or a negative errno.
+ */

drivers/vhost/vringh.c +6 -0
+ssize_t vringh_iov_push_iomem(struct vringh *vrh, struct vringh_kiov *wiov,
+			      const void *src, size_t len)
+{
+	return vringh_iov_xfer(vrh, wiov, (void *)src, len, xfer_to_iomem);
+}
+EXPORT_SYMBOL(vringh_iov_push_iomem);

...

#9 lore raw

Re: [PATCH v4 1/1] vringh: IOMEM support

Hi Simon-san,

Quoted 5 lines · Simon Horman
Quoted 4 lines · Shunsuke Mie

Introduce a new memory accessor for vringh. It is able to use vringh to virtio rings located on io-memory region.

Quoted 8 lines

...

Quoted 2 lines

+/**
+ * vringh_iov_pull_iomem - copy bytes from vring_iov.

Hi Mie-san,

as it looks like there will be a v2,
please consider documenting the vrh parameter here.

It was missing an explanation. I will address that and review this patch. Thank you.

Quoted 17 lines
Quoted 7 lines

+ * @riov: the riov as passed to vringh_getdesc_iomem() (updated as we consume)
+ * @dst: the place to copy.
+ * @len: the maximum length to copy.
+ *
+ * Returns the bytes copied <= len or a negative errno.
+ */

drivers/vhost/vringh.c EXPORT_SYMBOL(vringh_need_notify_iotlb); · line 1722

Quoted 9 lines
drivers/vhost/vringh.c +9 -0
+ssize_t vringh_iov_pull_iomem(struct vringh *vrh, struct vringh_kiov *riov,
+			      void *dst, size_t len)
+{
+	return vringh_iov_xfer(vrh, riov, dst, len, xfer_from_iomem);
+}
+EXPORT_SYMBOL(vringh_iov_pull_iomem);
+
+/**
+ * vringh_iov_push_iomem - copy bytes into vring_iov.

And here.

I do the same.

Quoted 5 lines
Quoted 5 lines

+ * @wiov: the wiov as passed to vringh_getdesc_iomem() (updated as we consume)
+ * @src: the place to copy from.
+ * @len: the maximum length to copy.
+ *
+ * Returns the bytes copied <= len or a negative errno.

Quoted 8 lines
Quoted 7 lines

+ */

drivers/vhost/vringh.c +6 -0
+ssize_t vringh_iov_push_iomem(struct vringh *vrh, struct vringh_kiov *wiov,
+			      const void *src, size_t len)
+{
+	return vringh_iov_xfer(vrh, wiov, (void *)src, len, xfer_to_iomem);
+}
+EXPORT_SYMBOL(vringh_iov_push_iomem);

...

Best regards,

Shunsuke