Re: [RFC PATCH v2 0/5] TUN/VirtioNet USO features support.
On Tue, May 24, 2022 at 7:07 PM Andrew Melnichenko wrote: > > Hi all, > > The issue is that host segments packets between guests on the same host. > Tests show that it happens because SKB_GSO_DODGY skb offload in > virtio_net_hdr_from_skb(). > To do segmentation you need to remove SKB_GSO_DODGY or add SKB_GSO_PARTIAL > The solution with DODGY/PARTIAL offload looks like a dirty hack, so > for now, I've lived it as it is for further investigation. Ok, I managed to find the previous discussion. It looks to me the reason is that __udp_gso_segment will segment dodgy packets unconditionally. I wonder if the attached patch works? (compile test only). Thanks > > > On Tue, May 17, 2022 at 9:32 AM Jason Wang wrote: > > > > On Thu, May 12, 2022 at 7:33 PM Andrew Melnychenko > > wrote: > > > > > > Added new offloads for TUN devices TUN_F_USO4 and TUN_F_USO6. > > > Technically they enable NETIF_F_GSO_UDP_L4 > > > (and only if USO4 & USO6 are set simultaneously). > > > It allows to transmission of large UDP packets. > > > > > > Different features USO4 and USO6 are required for qemu where Windows > > > guests can > > > enable disable USO receives for IPv4 and IPv6 separately. > > > On the other side, Linux can't really differentiate USO4 and USO6, for > > > now. > > > For now, to enable USO for TUN it requires enabling USO4 and USO6 > > > together. > > > In the future, there would be a mechanism to control UDP_L4 GSO > > > separately. > > > > > > Test it WIP Qemu https://github.com/daynix/qemu/tree/Dev_USOv2 > > > > > > New types for VirtioNet already on mailing: > > > https://lists.oasis-open.org/archives/virtio-comment/202110/msg00010.html > > > > > > Also, there is a known issue with transmitting packages between two > > > guests. > > > > Could you explain this more? It looks like a bug. (Or any pointer to > > the discussion) > > > > Thanks > > > > > Without hacks with skb's GSO - packages are still segmented on the host's > > > postrouting. > > > > > > Andrew (5): > > > uapi/linux/if_tun.h: Added new offload types for USO4/6. > > > driver/net/tun: Added features for USO. > > > uapi/linux/virtio_net.h: Added USO types. > > > linux/virtio_net.h: Support USO offload in vnet header. > > > drivers/net/virtio_net.c: Added USO support. > > > > > > drivers/net/tap.c | 10 -- > > > drivers/net/tun.c | 8 +++- > > > drivers/net/virtio_net.c| 19 +++ > > > include/linux/virtio_net.h | 9 + > > > include/uapi/linux/if_tun.h | 2 ++ > > > include/uapi/linux/virtio_net.h | 4 > > > 6 files changed, 45 insertions(+), 7 deletions(-) > > > > > > -- > > > 2.35.1 > > > > > > 0001-udp-allow-header-check-for-dodgy-GSO_UDP_L4-packets.patch Description: Binary data ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [linux-next:master] BUILD REGRESSION 8cb8311e95e3bb58bd84d6350365f14a718faa6d
On Wed, May 25, 2022 at 03:20:06PM -0700, Andrew Morton wrote: > On Wed, 25 May 2022 23:07:35 +0100 Jessica Clarke wrote: > > > This is i386, so an unsigned long is 32-bit, but i_blocks is a blkcnt_t > > i.e. a u64, which makes the shift without a cast of the LHS fishy. > > Ah, of course, thanks. I remember 32 bits ;) > > --- a/mm/shmem.c~mm-shmemc-suppress-shift-warning > +++ a/mm/shmem.c > @@ -1945,7 +1945,7 @@ alloc_nohuge: > > spin_lock_irq(&info->lock); > info->alloced += folio_nr_pages(folio); > - inode->i_blocks += BLOCKS_PER_PAGE << folio_order(folio); > + inode->i_blocks += (blkcnt_t)BLOCKS_PER_PAGE << folio_order(folio); Bizarre this started showing up now. The recent patch was: - info->alloced += compound_nr(page); - inode->i_blocks += BLOCKS_PER_PAGE << compound_order(page); + info->alloced += folio_nr_pages(folio); + inode->i_blocks += BLOCKS_PER_PAGE << folio_order(folio); so it could tell that compound_order() was small, but folio_order() might be large? Silencing the warning is a good thing, but folio_order() can (at the moment) be at most 9 on i386, so it isn't actually going to be larger than 4096. ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [linux-next:master] BUILD REGRESSION 8cb8311e95e3bb58bd84d6350365f14a718faa6d
On Wed, 25 May 2022 23:07:35 +0100 Jessica Clarke wrote: > This is i386, so an unsigned long is 32-bit, but i_blocks is a blkcnt_t > i.e. a u64, which makes the shift without a cast of the LHS fishy. Ah, of course, thanks. I remember 32 bits ;) --- a/mm/shmem.c~mm-shmemc-suppress-shift-warning +++ a/mm/shmem.c @@ -1945,7 +1945,7 @@ alloc_nohuge: spin_lock_irq(&info->lock); info->alloced += folio_nr_pages(folio); - inode->i_blocks += BLOCKS_PER_PAGE << folio_order(folio); + inode->i_blocks += (blkcnt_t)BLOCKS_PER_PAGE << folio_order(folio); shmem_recalc_inode(inode); spin_unlock_irq(&info->lock); alloced = true; _ ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [linux-next:master] BUILD REGRESSION 8cb8311e95e3bb58bd84d6350365f14a718faa6d
On Thu, 26 May 2022 05:35:20 +0800 kernel test robot wrote: > tree/branch: > https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master > branch HEAD: 8cb8311e95e3bb58bd84d6350365f14a718faa6d Add linux-next > specific files for 20220525 > > Error/Warning reports: > > ... > > Unverified Error/Warning (likely false positive, please contact us if > interested): Could be so. > mm/shmem.c:1948 shmem_getpage_gfp() warn: should '(((1) << 12) / 512) << > folio_order(folio)' be a 64 bit type? I've been seeing this one for a while. And from this report I can't figure out what tool emitted it. Clang? > > ... > > |-- i386-randconfig-m021 > | `-- > mm-shmem.c-shmem_getpage_gfp()-warn:should-((()-)-)-folio_order(folio)-be-a-bit-type If you're going to use randconfig then shouldn't you make the config available? Or maybe quote the KCONFIG_SEED - presumably there's a way for others to regenerate. Anyway, the warning seems wrong to me. #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) #define BLOCKS_PER_PAGE (PAGE_SIZE/512) inode->i_blocks += BLOCKS_PER_PAGE << folio_order(folio); so the RHS here should have unsigned long type. Being able to generate the cpp output would be helpful. That requires the .config. ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
[linux-next:master] BUILD REGRESSION 8cb8311e95e3bb58bd84d6350365f14a718faa6d
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master branch HEAD: 8cb8311e95e3bb58bd84d6350365f14a718faa6d Add linux-next specific files for 20220525 Error/Warning reports: https://lore.kernel.org/linux-mm/202204291924.vtgzmeri-...@intel.com https://lore.kernel.org/linux-mm/202205031017.4twman3l-...@intel.com https://lore.kernel.org/linux-mm/202205041248.wgcwpcev-...@intel.com https://lore.kernel.org/linux-mm/202205150051.3rzuooag-...@intel.com https://lore.kernel.org/linux-mm/202205150117.sd6hzbvm-...@intel.com https://lore.kernel.org/lkml/202205100617.5uum3uet-...@intel.com https://lore.kernel.org/llvm/202205251645.gusu3spl-...@intel.com Error/Warning: (recently discovered and may have been fixed) drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c:1364:5: warning: no previous prototype for 'amdgpu_discovery_get_mall_info' [-Wmissing-prototypes] drivers/gpu/drm/amd/amdgpu/soc21.c:171:6: warning: no previous prototype for 'soc21_grbm_select' [-Wmissing-prototypes] drivers/gpu/drm/solomon/ssd130x-spi.c:154:35: warning: 'ssd130x_spi_table' defined but not used [-Wunused-const-variable=] drivers/net/wireless/intel/iwlwifi/pcie/trans.c:1093:9: warning: 'CAUSE' macro redefined [-Wmacro-redefined] drivers/video/fbdev/omap/hwa742.c:492:5: warning: no previous prototype for 'hwa742_update_window_async' [-Wmissing-prototypes] fs/buffer.c:2254:5: warning: stack frame size (2144) exceeds limit (1024) in 'block_read_full_folio' [-Wframe-larger-than] fs/ntfs/aops.c:378:12: warning: stack frame size (2216) exceeds limit (1024) in 'ntfs_read_folio' [-Wframe-larger-than] Unverified Error/Warning (likely false positive, please contact us if interested): .__mulsi3.o.cmd: No such file or directory Makefile:686: arch/h8300/Makefile: No such file or directory Makefile:765: arch/h8300/Makefile: No such file or directory arch/Kconfig:10: can't open file "arch/h8300/Kconfig" arch/riscv/purgatory/kexec-purgatory.c:1860:9: sparse: sparse: trying to concatenate 29720-character string (8191 bytes max) drivers/gpu/drm/bridge/adv7511/adv7511.h:229:17: warning: 'ADV7511_REG_CEC_RX_FRAME_HDR' defined but not used [-Wunused-const-variable=] drivers/gpu/drm/bridge/adv7511/adv7511.h:235:17: warning: 'ADV7511_REG_CEC_RX_FRAME_LEN' defined but not used [-Wunused-const-variable=] drivers/infiniband/hw/hns/hns_roce_hw_v2.c:309:9: sparse: sparse: dubious: x & !y drivers/pinctrl/meson/pinctrl-meson8-pmx.c:60:25: warning: Value stored to 'func' during its initialization is never read [clang-analyzer-deadcode.DeadStores] drivers/staging/vt6655/card.c:758:16: sparse: sparse: cast to restricted __le64 drivers/vhost/vdpa.c:595 vhost_vdpa_unlocked_ioctl() warn: maybe return -EFAULT instead of the bytes remaining? kernel/bpf/helpers.c:1468:29: sparse: sparse: symbol 'bpf_dynptr_from_mem_proto' was not declared. Should it be static? kernel/bpf/helpers.c:1490:29: sparse: sparse: symbol 'bpf_dynptr_from_mem_proto' was not declared. Should it be static? kernel/bpf/helpers.c:1516:29: sparse: sparse: symbol 'bpf_dynptr_read_proto' was not declared. Should it be static? kernel/bpf/helpers.c:1542:29: sparse: sparse: symbol 'bpf_dynptr_write_proto' was not declared. Should it be static? kernel/bpf/helpers.c:1569:29: sparse: sparse: symbol 'bpf_dynptr_data_proto' was not declared. Should it be static? make[1]: *** No rule to make target 'arch/h8300/Makefile'. mm/shmem.c:1948 shmem_getpage_gfp() warn: should '(((1) << 12) / 512) << folio_order(folio)' be a 64 bit type? sound/soc/intel/avs/ipc.c:87:5-24: atomic_dec_and_test variation before object free at line 88. {standard input}:3488: Error: unknown pseudo-op: `.l28' Error/Warning ids grouped by kconfigs: gcc_recent_errors |-- alpha-allmodconfig | |-- drivers-gpu-drm-amd-amdgpu-amdgpu_discovery.c:warning:no-previous-prototype-for-amdgpu_discovery_get_mall_info | `-- drivers-gpu-drm-amd-amdgpu-soc21.c:warning:no-previous-prototype-for-soc21_grbm_select |-- alpha-allyesconfig | |-- drivers-gpu-drm-amd-amdgpu-amdgpu_discovery.c:warning:no-previous-prototype-for-amdgpu_discovery_get_mall_info | |-- drivers-gpu-drm-amd-amdgpu-soc21.c:warning:no-previous-prototype-for-soc21_grbm_select | |-- drivers-pci-pci.c:sparse:sparse:incorrect-type-in-assignment-(different-base-types)-expected-restricted-pci_power_t-assigned-usertype-state-got-int | `-- drivers-staging-vt6655-card.c:sparse:sparse:cast-to-restricted-__le64 |-- arc-allyesconfig | |-- drivers-gpu-drm-amd-amdgpu-amdgpu_discovery.c:warning:no-previous-prototype-for-amdgpu_discovery_get_mall_info | |-- drivers-gpu-drm-amd-amdgpu-soc21.c:warning:no-previous-prototype-for-soc21_grbm_select | |-- drivers-pci-pci.c:sparse:sparse:incorrect-type-in-assignment-(different-base-types)
Re: [PATCH v3 3/4] vhost-vdpa: uAPI to stop the device
Hi "Eugenio, Thank you for the patch! Yet something to improve: [auto build test ERROR on mst-vhost/linux-next] [also build test ERROR on next-20220525] [cannot apply to horms-ipvs/master linux/master linus/master v5.18] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/intel-lab-lkp/linux/commits/Eugenio-P-rez/Implement-vdpasim-stop-operation/20220525-190143 base: https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git linux-next config: x86_64-randconfig-a005 (https://download.01.org/0day-ci/archive/20220526/202205260121.6v500ttl-...@intel.com/config) compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project d52a6e75b0c402c7f3b42a2b1b2873f151220947) reproduce (this is a W=1 build): 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/515f6b6d2a0164df801ddbe61e1cb1ae4e763873 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Eugenio-P-rez/Implement-vdpasim-stop-operation/20220525-190143 git checkout 515f6b6d2a0164df801ddbe61e1cb1ae4e763873 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/vhost/ If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot All errors (new ones prefixed by >>): >> drivers/vhost/vdpa.c:668:7: error: use of undeclared identifier 'VHOST_STOP' case VHOST_STOP: ^ 1 error generated. vim +/VHOST_STOP +668 drivers/vhost/vdpa.c 587 588 static long vhost_vdpa_unlocked_ioctl(struct file *filep, 589unsigned int cmd, unsigned long arg) 590 { 591 struct vhost_vdpa *v = filep->private_data; 592 struct vhost_dev *d = &v->vdev; 593 void __user *argp = (void __user *)arg; 594 u64 __user *featurep = argp; 595 u64 features; 596 long r = 0; 597 598 if (cmd == VHOST_SET_BACKEND_FEATURES) { 599 if (copy_from_user(&features, featurep, sizeof(features))) 600 return -EFAULT; 601 if (features & ~(VHOST_VDPA_BACKEND_FEATURES | 602 BIT_ULL(VHOST_BACKEND_F_STOP))) 603 return -EOPNOTSUPP; 604 if ((features & BIT_ULL(VHOST_BACKEND_F_STOP)) && 605 !vhost_vdpa_can_stop(v)) 606 return -EOPNOTSUPP; 607 vhost_set_backend_features(&v->vdev, features); 608 return 0; 609 } 610 611 mutex_lock(&d->mutex); 612 613 switch (cmd) { 614 case VHOST_VDPA_GET_DEVICE_ID: 615 r = vhost_vdpa_get_device_id(v, argp); 616 break; 617 case VHOST_VDPA_GET_STATUS: 618 r = vhost_vdpa_get_status(v, argp); 619 break; 620 case VHOST_VDPA_SET_STATUS: 621 r = vhost_vdpa_set_status(v, argp); 622 break; 623 case VHOST_VDPA_GET_CONFIG: 624 r = vhost_vdpa_get_config(v, argp); 625 break; 626 case VHOST_VDPA_SET_CONFIG: 627 r = vhost_vdpa_set_config(v, argp); 628 break; 629 case VHOST_GET_FEATURES: 630 r = vhost_vdpa_get_features(v, argp); 631 break; 632 case VHOST_SET_FEATURES: 633 r = vhost_vdpa_set_features(v, argp); 634 break; 635 case VHOST_VDPA_GET_VRING_NUM: 636 r = vhost_vdpa_get_vring_num(v, argp); 637 break; 638 case VHOST_VDPA_GET_GROUP_NUM: 639 r = copy_to_user(argp, &v->vdpa->ngroups, 640 sizeof(v->vdpa->ngroups)); 641 break; 642 case VHOST_VDPA_GET_AS_NUM: 643 r = copy_to_user(argp, &v->vdpa->nas, sizeof(v->vdpa->nas)); 644 break; 645 case VHOST_SET_LOG_BASE: 646 case VHOST_SET_LOG_FD: 647 r = -ENOIOCTLCMD; 648 break; 649 case VHOST_VDPA_SET_CONFIG_CALL: 650 r = vhost_vdpa_set_config_call(v
Re: [PATCH v3 3/4] vhost-vdpa: uAPI to stop the device
Hi "Eugenio, Thank you for the patch! Yet something to improve: [auto build test ERROR on mst-vhost/linux-next] [also build test ERROR on next-20220525] [cannot apply to horms-ipvs/master linux/master linus/master v5.18] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/intel-lab-lkp/linux/commits/Eugenio-P-rez/Implement-vdpasim-stop-operation/20220525-190143 base: https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git linux-next config: x86_64-randconfig-a013 (https://download.01.org/0day-ci/archive/20220525/202205252236.4ysv1zwg-...@intel.com/config) compiler: gcc-11 (Debian 11.3.0-1) 11.3.0 reproduce (this is a W=1 build): # https://github.com/intel-lab-lkp/linux/commit/515f6b6d2a0164df801ddbe61e1cb1ae4e763873 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Eugenio-P-rez/Implement-vdpasim-stop-operation/20220525-190143 git checkout 515f6b6d2a0164df801ddbe61e1cb1ae4e763873 # save the config file mkdir build_dir && cp config build_dir/.config make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot All errors (new ones prefixed by >>): drivers/vhost/vdpa.c: In function 'vhost_vdpa_unlocked_ioctl': >> drivers/vhost/vdpa.c:668:14: error: 'VHOST_STOP' undeclared (first use in >> this function) 668 | case VHOST_STOP: | ^~ drivers/vhost/vdpa.c:668:14: note: each undeclared identifier is reported only once for each function it appears in vim +/VHOST_STOP +668 drivers/vhost/vdpa.c 587 588 static long vhost_vdpa_unlocked_ioctl(struct file *filep, 589unsigned int cmd, unsigned long arg) 590 { 591 struct vhost_vdpa *v = filep->private_data; 592 struct vhost_dev *d = &v->vdev; 593 void __user *argp = (void __user *)arg; 594 u64 __user *featurep = argp; 595 u64 features; 596 long r = 0; 597 598 if (cmd == VHOST_SET_BACKEND_FEATURES) { 599 if (copy_from_user(&features, featurep, sizeof(features))) 600 return -EFAULT; 601 if (features & ~(VHOST_VDPA_BACKEND_FEATURES | 602 BIT_ULL(VHOST_BACKEND_F_STOP))) 603 return -EOPNOTSUPP; 604 if ((features & BIT_ULL(VHOST_BACKEND_F_STOP)) && 605 !vhost_vdpa_can_stop(v)) 606 return -EOPNOTSUPP; 607 vhost_set_backend_features(&v->vdev, features); 608 return 0; 609 } 610 611 mutex_lock(&d->mutex); 612 613 switch (cmd) { 614 case VHOST_VDPA_GET_DEVICE_ID: 615 r = vhost_vdpa_get_device_id(v, argp); 616 break; 617 case VHOST_VDPA_GET_STATUS: 618 r = vhost_vdpa_get_status(v, argp); 619 break; 620 case VHOST_VDPA_SET_STATUS: 621 r = vhost_vdpa_set_status(v, argp); 622 break; 623 case VHOST_VDPA_GET_CONFIG: 624 r = vhost_vdpa_get_config(v, argp); 625 break; 626 case VHOST_VDPA_SET_CONFIG: 627 r = vhost_vdpa_set_config(v, argp); 628 break; 629 case VHOST_GET_FEATURES: 630 r = vhost_vdpa_get_features(v, argp); 631 break; 632 case VHOST_SET_FEATURES: 633 r = vhost_vdpa_set_features(v, argp); 634 break; 635 case VHOST_VDPA_GET_VRING_NUM: 636 r = vhost_vdpa_get_vring_num(v, argp); 637 break; 638 case VHOST_VDPA_GET_GROUP_NUM: 639 r = copy_to_user(argp, &v->vdpa->ngroups, 640 sizeof(v->vdpa->ngroups)); 641 break; 642 case VHOST_VDPA_GET_AS_NUM: 643 r = copy_to_user(argp, &v->vdpa->nas, sizeof(v->vdpa->nas)); 644 break; 645 case VHOST_SET_LOG_BASE: 646 case VHOST_SET_LOG_FD: 647 r = -ENOIOCTLCMD; 648 break; 649 case VHOST_VDPA_SET_CONFIG_CALL: 650 r = vhost_vdpa_set_config_call(v, argp); 651 break; 652 case VHOST_GET_BAC
Re: [PATCH v2 4/4] vdpa_sim: Implement stop vdpa op
On Tue, May 24, 2022 at 07:06:10PM +0200, Eugenio Pérez wrote: Implement stop operation for vdpa_sim devices, so vhost-vdpa will offer that backend feature and userspace can effectively stop the device. This is a must before get virtqueue indexes (base) for live migration, since the device could modify them after userland gets them. There are individual ways to perform that action for some devices (VHOST_NET_SET_BACKEND, VHOST_VSOCK_SET_RUNNING, ...) but there was no way to perform it for any vhost device (and, in particular, vhost-vdpa). After the return of ioctl with stop != 0, the device MUST finish any pending operations like in flight requests. It must also preserve all the necessary state (the virtqueue vring base plus the possible device specific states) that is required for restoring in the future. The device must not change its configuration after that point. After the return of ioctl with stop == 0, the device can continue processing buffers as long as typical conditions are met (vq is enabled, DRIVER_OK status bit is enabled, etc). In the future, we will provide features similar to VHOST_USER_GET_INFLIGHT_FD so the device can save pending operations. Signed-off-by: Eugenio Pérez --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 21 + drivers/vdpa/vdpa_sim/vdpa_sim.h | 1 + drivers/vdpa/vdpa_sim/vdpa_sim_blk.c | 3 +++ drivers/vdpa/vdpa_sim/vdpa_sim_net.c | 3 +++ 4 files changed, 28 insertions(+) diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c index 50d721072beb..0515cf314bed 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -107,6 +107,7 @@ static void vdpasim_do_reset(struct vdpasim *vdpasim) for (i = 0; i < vdpasim->dev_attr.nas; i++) vhost_iotlb_reset(&vdpasim->iommu[i]); + vdpasim->running = true; spin_unlock(&vdpasim->iommu_lock); vdpasim->features = 0; @@ -505,6 +506,24 @@ static int vdpasim_reset(struct vdpa_device *vdpa) return 0; } +static int vdpasim_stop(struct vdpa_device *vdpa, bool stop) +{ + struct vdpasim *vdpasim = vdpa_to_sim(vdpa); + int i; + + spin_lock(&vdpasim->lock); + vdpasim->running = !stop; + if (vdpasim->running) { + /* Check for missed buffers */ + for (i = 0; i < vdpasim->dev_attr.nvqs; ++i) + vdpasim_kick_vq(vdpa, i); + + } + spin_unlock(&vdpasim->lock); + + return 0; +} + static size_t vdpasim_get_config_size(struct vdpa_device *vdpa) { struct vdpasim *vdpasim = vdpa_to_sim(vdpa); @@ -694,6 +713,7 @@ static const struct vdpa_config_ops vdpasim_config_ops = { .get_status = vdpasim_get_status, .set_status = vdpasim_set_status, .reset = vdpasim_reset, + .stop = vdpasim_stop, .get_config_size= vdpasim_get_config_size, .get_config = vdpasim_get_config, .set_config = vdpasim_set_config, @@ -726,6 +746,7 @@ static const struct vdpa_config_ops vdpasim_batch_config_ops = { .get_status = vdpasim_get_status, .set_status = vdpasim_set_status, .reset = vdpasim_reset, + .stop = vdpasim_stop, .get_config_size= vdpasim_get_config_size, .get_config = vdpasim_get_config, .set_config = vdpasim_set_config, diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.h b/drivers/vdpa/vdpa_sim/vdpa_sim.h index 622782e92239..061986f30911 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.h +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.h @@ -66,6 +66,7 @@ struct vdpasim { u32 generation; u64 features; u32 groups; + bool running; /* spinlock to synchronize iommu table */ spinlock_t iommu_lock; }; diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c b/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c index 42d401d43911..bcdb1982c378 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c @@ -204,6 +204,9 @@ static void vdpasim_blk_work(struct work_struct *work) if (!(vdpasim->status & VIRTIO_CONFIG_S_DRIVER_OK)) goto out; + if (!vdpasim->running) + goto out; + Not related to this series, but I think in vdpa_sim_blk.c we should implement something similar to what we already do in vdpa_sim_net.c and re-schedule the work after X requests handled, otherwise we risk never stopping if there are always requests to handle. Also for supporting multiple queues, that could be a problem, but for now we only support one, so there should be no problem. I have other patches to send for vdpa_sim_blk.c, so if you want I can do that in my series. Thanks, Stefano for (i = 0; i < VDPASIM_BLK_VQ_NUM; i++) { struct vdpasim_virtqueue *vq = &vdpasim->vqs[i