[PATCH -next] vdpasim: remove unused variable 'ret'

2020-04-10 Thread YueHaibing
drivers/vdpa/vdpa_sim/vdpa_sim.c:92:6: warning:
 variable ‘ret’ set but not used [-Wunused-but-set-variable]

Signed-off-by: YueHaibing 
---
 drivers/vdpa/vdpa_sim/vdpa_sim.c | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c
index 7957d2d41fc4..01c456f7c1f7 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
@@ -89,15 +89,14 @@ static struct vdpasim *dev_to_sim(struct device *dev)
 static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx)
 {
struct vdpasim_virtqueue *vq = >vqs[idx];
-   int ret;
 
-   ret = vringh_init_iotlb(>vring, vdpasim_features,
-   VDPASIM_QUEUE_MAX, false,
-   (struct vring_desc *)(uintptr_t)vq->desc_addr,
-   (struct vring_avail *)
-   (uintptr_t)vq->driver_addr,
-   (struct vring_used *)
-   (uintptr_t)vq->device_addr);
+   vringh_init_iotlb(>vring, vdpasim_features,
+ VDPASIM_QUEUE_MAX, false,
+ (struct vring_desc *)(uintptr_t)vq->desc_addr,
+ (struct vring_avail *)
+ (uintptr_t)vq->driver_addr,
+ (struct vring_used *)
+ (uintptr_t)vq->device_addr);
 }
 
 static void vdpasim_vq_reset(struct vdpasim_virtqueue *vq)
-- 
2.17.1


___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Re: [PATCH] vdpa-sim: depend on HAS_DMA

2020-04-10 Thread Geert Uytterhoeven
Hi Michael,

On Sun, Apr 5, 2020 at 10:17 AM Michael S. Tsirkin  wrote:
>
> set_dma_ops isn't available on all architectures:
>
> make ARCH=um
> ...
>
>drivers/vdpa/vdpa_sim/vdpa_sim.c: In function 'vdpasim_create':
> >> drivers/vdpa/vdpa_sim/vdpa_sim.c:324:2: error: implicit declaration of 
> >> function 'set_dma_ops'; did you mean 'set_groups'?
> +[-Werror=implicit-function-declaration]
>  set_dma_ops(dev, _dma_ops);
>  ^~~
>  set_groups
>
> Signed-off-by: Michael S. Tsirkin 

As this fixes the Sun-3 all{mod,yes}-config build, which has NO_DMA=y:
Acked-by: Geert Uytterhoeven 

However, you may want to follow Christoph's suggestion instead.

> --- a/drivers/vdpa/Kconfig
> +++ b/drivers/vdpa/Kconfig
> @@ -14,7 +14,7 @@ if VDPA_MENU
>
>  config VDPA_SIM
> tristate "vDPA device simulator"
> -   depends on RUNTIME_TESTING_MENU
> +   depends on RUNTIME_TESTING_MENU && HAS_DMA
> select VDPA
> select VHOST_RING
> select VHOST_IOTLB

Gr{oetje,eeting}s,

Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: vhost: refine vhost and vringh kconfig

2020-04-10 Thread Geert Uytterhoeven
Hi Jason,

On Fri, Apr 10, 2020 at 10:33 AM Jason Wang  wrote:
> On 2020/4/10 下午3:53, Geert Uytterhoeven wrote:
> > On Thu, Apr 9, 2020 at 6:04 AM Linux Kernel Mailing List
> >  wrote:
> >> Commit: 20c384f1ea1a0bc7320bc445c72dd02d2970d594
> >> Parent: 5a6b4cc5b7a1892a8d7f63d6cbac6e0ae2a9d031
> >> Refname:refs/heads/master
> >> Web:
> >> https://git.kernel.org/torvalds/c/20c384f1ea1a0bc7320bc445c72dd02d2970d594
> >> Author: Jason Wang 
> >> AuthorDate: Thu Mar 26 22:01:17 2020 +0800
> >> Committer:  Michael S. Tsirkin 
> >> CommitDate: Wed Apr 1 12:06:26 2020 -0400
> >>
> >>  vhost: refine vhost and vringh kconfig
> >>
> >>  Currently, CONFIG_VHOST depends on CONFIG_VIRTUALIZATION. But vhost is
> >>  not necessarily for VM since it's a generic userspace and kernel
> >>  communication protocol. Such dependency may prevent archs without
> >>  virtualization support from using vhost.
> >>
> >>  To solve this, a dedicated vhost menu is created under drivers so
> >>  CONIFG_VHOST can be decoupled out of CONFIG_VIRTUALIZATION.
> >>
> >>  While at it, also squash Kconfig.vringh into vhost Kconfig file. This
> >>  avoids the trick of conditional inclusion from VOP or CAIF. Then it
> >>  will be easier to introduce new vringh users and common dependency for
> >>  both vringh and vhost.
> >>
> >>  Signed-off-by: Jason Wang 
> >>  Link: 
> >> https://lore.kernel.org/r/20200326140125.19794-2-jasow...@redhat.com
> >>  Signed-off-by: Michael S. Tsirkin 
> >> ---
> >>   arch/arm/kvm/Kconfig |  2 --
> >>   arch/arm64/kvm/Kconfig   |  2 --
> >>   arch/mips/kvm/Kconfig|  2 --
> >>   arch/powerpc/kvm/Kconfig |  2 --
> >>   arch/s390/kvm/Kconfig|  4 
> >>   arch/x86/kvm/Kconfig |  4 
> >>   drivers/Kconfig  |  2 ++
> >>   drivers/misc/mic/Kconfig |  4 
> >>   drivers/net/caif/Kconfig |  4 
> >>   drivers/vhost/Kconfig| 28 +---
> >>   drivers/vhost/Kconfig.vringh |  6 --
> >>   11 files changed, 23 insertions(+), 37 deletions(-)
> >> --- a/drivers/vhost/Kconfig
> >> +++ b/drivers/vhost/Kconfig
> >> @@ -1,4 +1,23 @@
> >>   # SPDX-License-Identifier: GPL-2.0-only
> >> +config VHOST_RING
> >> +   tristate
> >> +   help
> >> + This option is selected by any driver which needs to access
> >> + the host side of a virtio ring.
> >> +
> >> +config VHOST
> >> +   tristate
> >> +   select VHOST_IOTLB
> >> +   help
> >> + This option is selected by any driver which needs to access
> >> + the core of vhost.
> >> +
> >> +menuconfig VHOST_MENU
> >> +   bool "VHOST drivers"
> >> +   default y
> > Please do not use default y. Your subsystem is not special.
>
>
> This is because before this patch VHOST depends on VIRTUALIZATION. So
> the archs whose defconfig that has VIRTUALIZATION can just enable e.g
> VHOST_NET without caring about VHOST_MENU.
>
> If this is not preferable, we can:
>
> 1) modify the defconfig and enable VHOST_MENU there
> 2) switch to use default y if $(all_archs_that_has_VIRTUALIZATION)

I think updating the few (1) defconfigs is preferable.
Else you put the burden on the maintainers of all the other (+400)
defconfigs, which will have to add "CONFIG_VHOST_MENU is not set".

> > I think this deserves a help text, so users know if they want to enable this
> > option or not.
>
> Will add one.

Thanks!

Gr{oetje,eeting}s,

Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Re: vhost: refine vhost and vringh kconfig

2020-04-10 Thread Jason Wang


On 2020/4/10 下午3:53, Geert Uytterhoeven wrote:

Hi Jason,

On Thu, Apr 9, 2020 at 6:04 AM Linux Kernel Mailing List
 wrote:

Commit: 20c384f1ea1a0bc7320bc445c72dd02d2970d594
Parent: 5a6b4cc5b7a1892a8d7f63d6cbac6e0ae2a9d031
Refname:refs/heads/master
Web:
https://git.kernel.org/torvalds/c/20c384f1ea1a0bc7320bc445c72dd02d2970d594
Author: Jason Wang 
AuthorDate: Thu Mar 26 22:01:17 2020 +0800
Committer:  Michael S. Tsirkin 
CommitDate: Wed Apr 1 12:06:26 2020 -0400

 vhost: refine vhost and vringh kconfig

 Currently, CONFIG_VHOST depends on CONFIG_VIRTUALIZATION. But vhost is
 not necessarily for VM since it's a generic userspace and kernel
 communication protocol. Such dependency may prevent archs without
 virtualization support from using vhost.

 To solve this, a dedicated vhost menu is created under drivers so
 CONIFG_VHOST can be decoupled out of CONFIG_VIRTUALIZATION.

 While at it, also squash Kconfig.vringh into vhost Kconfig file. This
 avoids the trick of conditional inclusion from VOP or CAIF. Then it
 will be easier to introduce new vringh users and common dependency for
 both vringh and vhost.

 Signed-off-by: Jason Wang 
 Link: https://lore.kernel.org/r/20200326140125.19794-2-jasow...@redhat.com
 Signed-off-by: Michael S. Tsirkin 
---
  arch/arm/kvm/Kconfig |  2 --
  arch/arm64/kvm/Kconfig   |  2 --
  arch/mips/kvm/Kconfig|  2 --
  arch/powerpc/kvm/Kconfig |  2 --
  arch/s390/kvm/Kconfig|  4 
  arch/x86/kvm/Kconfig |  4 
  drivers/Kconfig  |  2 ++
  drivers/misc/mic/Kconfig |  4 
  drivers/net/caif/Kconfig |  4 
  drivers/vhost/Kconfig| 28 +---
  drivers/vhost/Kconfig.vringh |  6 --
  11 files changed, 23 insertions(+), 37 deletions(-)
--- a/drivers/vhost/Kconfig
+++ b/drivers/vhost/Kconfig
@@ -1,4 +1,23 @@
  # SPDX-License-Identifier: GPL-2.0-only
+config VHOST_RING
+   tristate
+   help
+ This option is selected by any driver which needs to access
+ the host side of a virtio ring.
+
+config VHOST
+   tristate
+   select VHOST_IOTLB
+   help
+ This option is selected by any driver which needs to access
+ the core of vhost.
+
+menuconfig VHOST_MENU
+   bool "VHOST drivers"
+   default y

Please do not use default y. Your subsystem is not special.



This is because before this patch VHOST depends on VIRTUALIZATION. So 
the archs whose defconfig that has VIRTUALIZATION can just enable e.g 
VHOST_NET without caring about VHOST_MENU.


If this is not preferable, we can:

1) modify the defconfig and enable VHOST_MENU there
2) switch to use default y if $(all_archs_that_has_VIRTUALIZATION)





+

I think this deserves a help text, so users know if they want to enable this
option or not.



Will add one.

Thanks




Thanks!


+if VHOST_MENU
+
  config VHOST_NET
 tristate "Host kernel accelerator for virtio net"
 depends on NET && EVENTFD && (TUN || !TUN) && (TAP || !TAP)

Gr{oetje,eeting}s,

 Geert


--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
 -- Linus Torvalds



___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Re: [PATCH V9 8/9] vdpasim: vDPA device simulator

2020-04-10 Thread Jason Wang


On 2020/4/10 下午3:45, Geert Uytterhoeven wrote:

Hi Jason,

On Thu, Mar 26, 2020 at 3:07 PM Jason Wang  wrote:

This patch implements a software vDPA networking device. The datapath
is implemented through vringh and workqueue. The device has an on-chip
IOMMU which translates IOVA to PA. For kernel virtio drivers, vDPA
simulator driver provides dma_ops. For vhost driers, set_map() methods
of vdpa_config_ops is implemented to accept mappings from vhost.

Currently, vDPA device simulator will loopback TX traffic to RX. So
the main use case for the device is vDPA feature testing, prototyping
and development.

Note, there's no management API implemented, a vDPA device will be
registered once the module is probed. We need to handle this in the
future development.

Signed-off-by: Jason Wang 

This is now commit 2c53d0f64c06f458 ("vdpasim: vDPA device simulator").


--- a/drivers/virtio/vdpa/Kconfig
+++ b/drivers/virtio/vdpa/Kconfig
@@ -5,3 +5,22 @@ config VDPA
   Enable this module to support vDPA device that uses a
   datapath which complies with virtio specifications with
   vendor specific control path.
+
+menuconfig VDPA_MENU
+   bool "VDPA drivers"
+   default n

 *
 * VDPA drivers
 *
 VDPA drivers (VDPA_MENU) [N/y/?] (NEW) ?

 There is no help available for this option.
 Symbol: VDPA_MENU [=n]
 Type  : bool
 Defined at drivers/vdpa/Kconfig:9
  Prompt: VDPA drivers
  Location:
-> Device Drivers

I think this deserves a help text, so users know if they want to enable this
option or not.



Will add a help text for this.




I had a quick look, but couldn't find the meaning of "vdpa" in the whole kernel
source tree.



The meaning was explained in the commit log of 
961e9c84077f6c8579d7a628cbe94a675cb67ae4 and help text for CONFIG_VDPA.


Thanks




Thanks!


+
+if VDPA_MENU
+
+config VDPA_SIM
+   tristate "vDPA device simulator"
+   depends on RUNTIME_TESTING_MENU
+   select VDPA
+   select VHOST_RING
+   default n
+   help
+ vDPA networking device simulator which loop TX traffic back
+ to RX. This device is used for testing, prototyping and
+ development of vDPA.
+
+endif # VDPA_MENU

Gr{oetje,eeting}s,

 Geert



___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Re: vhost: refine vhost and vringh kconfig

2020-04-10 Thread Geert Uytterhoeven
Hi Jason,

On Thu, Apr 9, 2020 at 6:04 AM Linux Kernel Mailing List
 wrote:
> Commit: 20c384f1ea1a0bc7320bc445c72dd02d2970d594
> Parent: 5a6b4cc5b7a1892a8d7f63d6cbac6e0ae2a9d031
> Refname:refs/heads/master
> Web:
> https://git.kernel.org/torvalds/c/20c384f1ea1a0bc7320bc445c72dd02d2970d594
> Author: Jason Wang 
> AuthorDate: Thu Mar 26 22:01:17 2020 +0800
> Committer:  Michael S. Tsirkin 
> CommitDate: Wed Apr 1 12:06:26 2020 -0400
>
> vhost: refine vhost and vringh kconfig
>
> Currently, CONFIG_VHOST depends on CONFIG_VIRTUALIZATION. But vhost is
> not necessarily for VM since it's a generic userspace and kernel
> communication protocol. Such dependency may prevent archs without
> virtualization support from using vhost.
>
> To solve this, a dedicated vhost menu is created under drivers so
> CONIFG_VHOST can be decoupled out of CONFIG_VIRTUALIZATION.
>
> While at it, also squash Kconfig.vringh into vhost Kconfig file. This
> avoids the trick of conditional inclusion from VOP or CAIF. Then it
> will be easier to introduce new vringh users and common dependency for
> both vringh and vhost.
>
> Signed-off-by: Jason Wang 
> Link: https://lore.kernel.org/r/20200326140125.19794-2-jasow...@redhat.com
> Signed-off-by: Michael S. Tsirkin 
> ---
>  arch/arm/kvm/Kconfig |  2 --
>  arch/arm64/kvm/Kconfig   |  2 --
>  arch/mips/kvm/Kconfig|  2 --
>  arch/powerpc/kvm/Kconfig |  2 --
>  arch/s390/kvm/Kconfig|  4 
>  arch/x86/kvm/Kconfig |  4 
>  drivers/Kconfig  |  2 ++
>  drivers/misc/mic/Kconfig |  4 
>  drivers/net/caif/Kconfig |  4 
>  drivers/vhost/Kconfig| 28 +---
>  drivers/vhost/Kconfig.vringh |  6 --
>  11 files changed, 23 insertions(+), 37 deletions(-)

> --- a/drivers/vhost/Kconfig
> +++ b/drivers/vhost/Kconfig
> @@ -1,4 +1,23 @@
>  # SPDX-License-Identifier: GPL-2.0-only
> +config VHOST_RING
> +   tristate
> +   help
> + This option is selected by any driver which needs to access
> + the host side of a virtio ring.
> +
> +config VHOST
> +   tristate
> +   select VHOST_IOTLB
> +   help
> + This option is selected by any driver which needs to access
> + the core of vhost.
> +
> +menuconfig VHOST_MENU
> +   bool "VHOST drivers"
> +   default y

Please do not use default y. Your subsystem is not special.

> +

I think this deserves a help text, so users know if they want to enable this
option or not.

Thanks!

> +if VHOST_MENU
> +
>  config VHOST_NET
> tristate "Host kernel accelerator for virtio net"
> depends on NET && EVENTFD && (TUN || !TUN) && (TAP || !TAP)

Gr{oetje,eeting}s,

Geert


--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH V9 8/9] vdpasim: vDPA device simulator

2020-04-10 Thread Geert Uytterhoeven
Hi Jason,

On Thu, Mar 26, 2020 at 3:07 PM Jason Wang  wrote:
> This patch implements a software vDPA networking device. The datapath
> is implemented through vringh and workqueue. The device has an on-chip
> IOMMU which translates IOVA to PA. For kernel virtio drivers, vDPA
> simulator driver provides dma_ops. For vhost driers, set_map() methods
> of vdpa_config_ops is implemented to accept mappings from vhost.
>
> Currently, vDPA device simulator will loopback TX traffic to RX. So
> the main use case for the device is vDPA feature testing, prototyping
> and development.
>
> Note, there's no management API implemented, a vDPA device will be
> registered once the module is probed. We need to handle this in the
> future development.
>
> Signed-off-by: Jason Wang 

This is now commit 2c53d0f64c06f458 ("vdpasim: vDPA device simulator").

> --- a/drivers/virtio/vdpa/Kconfig
> +++ b/drivers/virtio/vdpa/Kconfig
> @@ -5,3 +5,22 @@ config VDPA
>   Enable this module to support vDPA device that uses a
>   datapath which complies with virtio specifications with
>   vendor specific control path.
> +
> +menuconfig VDPA_MENU
> +   bool "VDPA drivers"
> +   default n

*
* VDPA drivers
*
VDPA drivers (VDPA_MENU) [N/y/?] (NEW) ?

There is no help available for this option.
Symbol: VDPA_MENU [=n]
Type  : bool
Defined at drivers/vdpa/Kconfig:9
 Prompt: VDPA drivers
 Location:
   -> Device Drivers

I think this deserves a help text, so users know if they want to enable this
option or not.

I had a quick look, but couldn't find the meaning of "vdpa" in the whole kernel
source tree.

Thanks!

> +
> +if VDPA_MENU
> +
> +config VDPA_SIM
> +   tristate "vDPA device simulator"
> +   depends on RUNTIME_TESTING_MENU
> +   select VDPA
> +   select VHOST_RING
> +   default n
> +   help
> + vDPA networking device simulator which loop TX traffic back
> + to RX. This device is used for testing, prototyping and
> + development of vDPA.
> +
> +endif # VDPA_MENU

Gr{oetje,eeting}s,

Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH] vdpa: allow a 32 bit vq alignment

2020-04-10 Thread Jason Wang

Cc Ling Shan.

On 2020/4/10 上午4:28, Michael S. Tsirkin wrote:

get_vq_align returns u16 now, but that's not enough for
systems/devices with 64K pages. All callers assign it to
a u32 variable anyway, so let's just change the return
value type to u32.

Cc: "Zhu, Lingshan" 
Reported-by: Arnd Bergmann 
Signed-off-by: Michael S. Tsirkin 
---
  drivers/vdpa/ifcvf/ifcvf_main.c  | 2 +-
  drivers/vdpa/vdpa_sim/vdpa_sim.c | 2 +-
  include/linux/vdpa.h | 2 +-
  3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c b/drivers/vdpa/ifcvf/ifcvf_main.c
index 28d9e5de5675..abf6a061cab6 100644
--- a/drivers/vdpa/ifcvf/ifcvf_main.c
+++ b/drivers/vdpa/ifcvf/ifcvf_main.c
@@ -226,7 +226,7 @@ static u32 ifcvf_vdpa_get_vendor_id(struct vdpa_device 
*vdpa_dev)
return IFCVF_SUBSYS_VENDOR_ID;
  }
  
-static u16 ifcvf_vdpa_get_vq_align(struct vdpa_device *vdpa_dev)

+static u32 ifcvf_vdpa_get_vq_align(struct vdpa_device *vdpa_dev)
  {
return IFCVF_QUEUE_ALIGNMENT;
  }
diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c
index 72863d01a12a..7957d2d41fc4 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
@@ -435,7 +435,7 @@ static u64 vdpasim_get_vq_state(struct vdpa_device *vdpa, 
u16 idx)
return vrh->last_avail_idx;
  }
  
-static u16 vdpasim_get_vq_align(struct vdpa_device *vdpa)

+static u32 vdpasim_get_vq_align(struct vdpa_device *vdpa)
  {
return VDPASIM_QUEUE_ALIGN;
  }
diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h
index 733acfb7ef84..5453af87a33e 100644
--- a/include/linux/vdpa.h
+++ b/include/linux/vdpa.h
@@ -164,7 +164,7 @@ struct vdpa_config_ops {
u64 (*get_vq_state)(struct vdpa_device *vdev, u16 idx);
  
  	/* Device ops */

-   u16 (*get_vq_align)(struct vdpa_device *vdev);
+   u32 (*get_vq_align)(struct vdpa_device *vdev);
u64 (*get_features)(struct vdpa_device *vdev);
int (*set_features)(struct vdpa_device *vdev, u64 features);
void (*set_config_cb)(struct vdpa_device *vdev,


___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization