Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp7175668ioo; Fri, 3 Jun 2022 00:56:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyv5ZcZRuJctzOL4NkK23VpCp1NQknZClme9HSUdQ3i3CMjzCrAiFDml2oHHfxfR5S601d3 X-Received: by 2002:a17:906:1f09:b0:70d:b470:1aaa with SMTP id w9-20020a1709061f0900b0070db4701aaamr2436255ejj.758.1654242960479; Fri, 03 Jun 2022 00:56:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654242960; cv=none; d=google.com; s=arc-20160816; b=CUGrerxMrMlhCdOENksrSDSbbn0AxtIgkMuOt7qdUF8KgrZketARQJVpO/SFtC5Z9O 0OpCf3+Htshr/jcWPB4TEjy3+toUE17EPxZcHFoI5KdOnCZNPVpEZf0V8AFCpqqWeA0z nce6k9pmCA4377J4j7s0d5q2YLJ61o+lTzdFN8knDrwtGQH739zxYxVL2LPYPIIbwOWB Du3xo4zp0v8sD0GpYLo/B8C+MPMso079qqMalUtcD2eKnnpLG5t2L2FCX23TfhCXFQ+1 T09GzMiAyBXZ7sO6nzFt8zvwd0TEc4IQafvwVFj/daWsG2SKBrt/Mlm0uPcZ/hcIhV7e FC1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=dftoX5xxTZB/c8O5WA81vrlQezqU2CDPcAxmSZhNEc4=; b=uNhT+3LiaO5ILOl3abuzlXhCUtm45mkxIO+aBmypbNeYisfkOj6Y8FnAFF5iS/AOmd jk58ygcU1rPy3rOsnzRDP0IoyZ4eXh5yWpp4hAMs34WvZp22rM+YGVpgAKv2XrE6GFtw EqPaImO7iMFTdfN3tjHwzbGeR161EqfC3bTPXjjypE75o0ft42GznUJyc0fD8XkFZ9cS ncNmiZBe2pxQ4DVDMA/GCEJfRPrSjG/OcLsop6Ll4DUfns5nUTrwTU66XC+0fNG6+ENm I4LGY65ZqHIiUHCG/hUX164DrdsBi0fbUObdALYXAPx/P4nTHJkaS5TcjNDo5r15X7Oc P6rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Hxp3PweV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l16-20020a17090615d000b00705df47a7fdsi6331749ejd.3.2022.06.03.00.55.27; Fri, 03 Jun 2022 00:56:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Hxp3PweV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230454AbiFBGWo (ORCPT + 99 others); Thu, 2 Jun 2022 02:22:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230497AbiFBGWm (ORCPT ); Thu, 2 Jun 2022 02:22:42 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5DF7C33372 for ; Wed, 1 Jun 2022 23:22:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654150955; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dftoX5xxTZB/c8O5WA81vrlQezqU2CDPcAxmSZhNEc4=; b=Hxp3PweVceqPY9q0omzQ4eKyLu/maXeie1mURY0XlG/gN9FWUHFdPVV/A6q/lZNwDvzWhQ QpEGRV0FWauwoJCi/T0YG9VfQ/grfR0nwfZrN1yorRRFR3cAfRGW0FoAOThmhdIXVQXSMD Yut10gLONjr3+n/DQjmEQPYkhrxQPBQ= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-582-Ai9lckmTNpWkQVI2j6bT9g-1; Thu, 02 Jun 2022 02:22:32 -0400 X-MC-Unique: Ai9lckmTNpWkQVI2j6bT9g-1 Received: by mail-qv1-f69.google.com with SMTP id az18-20020ad45512000000b004645f3d2c36so2926060qvb.0 for ; Wed, 01 Jun 2022 23:22:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=dftoX5xxTZB/c8O5WA81vrlQezqU2CDPcAxmSZhNEc4=; b=S2/6SXSv0NQiNyZBy7/O51wiSv7T/09rC46nZjO+IYoedmhFKW22ilCHe1zC8kkHJB +vaEZsfSqy2vw+Ur0nK0FPowZ3CjGcFH+XLsovFvzP356voRkSRdJeD850dUdfLea9Nj UintCKf2z9//5E105fBz5y04o/kp85N1lUS1CKmwSepvboyjpeurd4vwjLTffCOsy6gl JjIkRANFOz9M3Yjtb1KwXIMFk09c0QsrcN3GTKro46DF6rkYocHaZAVpkZFpXGX+uQBd ZfEyFYRtFzDQzy71pw7sPuzgzPHXiequXCzq3rijK21T6BxluMTcD5142mjatqEOnYQg 7ahQ== X-Gm-Message-State: AOAM530zb3V5dL7JBcEi4K0K21DWrFoAkPFen7OLRDaB/hwXh+6+8Lcx 9899QmwEHTZ0f+dK0VrQlTTGLm7XcjGevkLV8AQ3zZ5Xh/MotuRG1U2qLSEwdmDwjU1xzl4Nsex zxmd1F7IbHaQ1Jzk3lKWEJWJhThfrPxEvS2KkJRrK X-Received: by 2002:a0c:e702:0:b0:467:538e:ebba with SMTP id d2-20020a0ce702000000b00467538eebbamr2217003qvn.2.1654150951932; Wed, 01 Jun 2022 23:22:31 -0700 (PDT) X-Received: by 2002:a0c:e702:0:b0:467:538e:ebba with SMTP id d2-20020a0ce702000000b00467538eebbamr2216984qvn.2.1654150951730; Wed, 01 Jun 2022 23:22:31 -0700 (PDT) MIME-Version: 1.0 References: <20220526124338.36247-1-eperezma@redhat.com> <20220526124338.36247-4-eperezma@redhat.com> <20220601070303-mutt-send-email-mst@kernel.org> In-Reply-To: From: Eugenio Perez Martin Date: Thu, 2 Jun 2022 08:21:55 +0200 Message-ID: Subject: Re: [PATCH v4 3/4] vhost-vdpa: uAPI to stop the device To: Parav Pandit Cc: "Michael S. Tsirkin" , kvm list , virtualization , linux-kernel , Jason Wang , netdev , Martin Petrus Hubertus Habets , Stefano Garzarella , Martin Porter , Laurent Vivier , Pablo Cascon Katchadourian , Eli Cohen , Dan Carpenter , Xie Yongji , Christophe JAILLET , Zhang Min , Wu Zongyong , Cindy Lu , Zhu Lingshan , "Uminski, Piotr" , Si-Wei Liu , "ecree.xilinx@gmail.com" , "Dawar, Gautam" , "habetsm.xilinx@gmail.com" , "Kamde, Tanuj" , Harpreet Singh Anand , Dinan Gunawardena , Longpeng Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 1, 2022 at 9:13 PM Parav Pandit wrote: > > > > > From: Eugenio Perez Martin > > Sent: Wednesday, June 1, 2022 7:15 AM > > > > On Wed, Jun 1, 2022 at 1:03 PM Michael S. Tsirkin wrot= e: > > > > > > On Thu, May 26, 2022 at 02:43:37PM +0200, Eugenio P=C3=A9rez wrote: > > > > The ioctl adds support for stop the device from userspace. > > > > > > > > Signed-off-by: Eugenio P=C3=A9rez > > > > --- > > > > drivers/vhost/vdpa.c | 18 ++++++++++++++++++ > > > > include/uapi/linux/vhost.h | 14 ++++++++++++++ > > > > 2 files changed, 32 insertions(+) > > > > > > > > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index > > > > 32713db5831d..d1d19555c4b7 100644 > > > > --- a/drivers/vhost/vdpa.c > > > > +++ b/drivers/vhost/vdpa.c > > > > @@ -478,6 +478,21 @@ static long vhost_vdpa_get_vqs_count(struct > > vhost_vdpa *v, u32 __user *argp) > > > > return 0; > > > > } > > > > > > > > +static long vhost_vdpa_stop(struct vhost_vdpa *v, u32 __user *argp= ) > > > > +{ > > > > + struct vdpa_device *vdpa =3D v->vdpa; > > > > + const struct vdpa_config_ops *ops =3D vdpa->config; > > > > + int stop; > > > > + > > > > + if (!ops->stop) > > > > + return -EOPNOTSUPP; > > > > + > > > > + if (copy_from_user(&stop, argp, sizeof(stop))) > > > > + return -EFAULT; > > > > + > > > > + return ops->stop(vdpa, stop); > > > > +} > > > > + > > > > static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned = int > > cmd, > > > > void __user *argp) { @@ -650,6 > > > > +665,9 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep, > > > > case VHOST_VDPA_GET_VQS_COUNT: > > > > r =3D vhost_vdpa_get_vqs_count(v, argp); > > > > break; > > > > + case VHOST_VDPA_STOP: > > > > + r =3D vhost_vdpa_stop(v, argp); > > > > + break; > > > > default: > > > > r =3D vhost_dev_ioctl(&v->vdev, cmd, argp); > > > > if (r =3D=3D -ENOIOCTLCMD) diff --git > > > > a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h index > > > > cab645d4a645..c7e47b29bf61 100644 > > > > --- a/include/uapi/linux/vhost.h > > > > +++ b/include/uapi/linux/vhost.h > > > > @@ -171,4 +171,18 @@ > > > > #define VHOST_VDPA_SET_GROUP_ASID _IOW(VHOST_VIRTIO, 0x7C, > > \ > > > > struct vhost_vring_state= ) > > > > > > > > +/* Stop or resume a device so it does not process virtqueue > > > > +requests anymore > > > > + * > > > > + * After the return of ioctl with stop !=3D 0, the device must fin= ish > > > > +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 =3D=3D 0, the device can > > > > +continue > > > > + * processing buffers as long as typical conditions are met (vq is > > > > +enabled, > > > > + * DRIVER_OK status bit is enabled, etc). > > > > + */ > > > > +#define VHOST_VDPA_STOP _IOW(VHOST_VIRTIO, 0x= 7D, int) > > > > + > A better name is VHOST_VDPA_SET_STATE > State =3D stop/suspend > State =3D start/resume > > Suspend/resume seems more logical, as opposed start/stop, because it more= clearly indicates that the resume (start) is from some programmed beginnin= g (and not first boot). > It's fine to move to that nomenclature in my opinion. > > > > #endif > > > > > > I wonder how does this interact with the admin vq idea. > > > I.e. if we stop all VQs then apparently admin vq can't work either ..= . > > > Thoughts? > > > > > > > Copying here the answer to Parav, feel free to answer to any thread or > > highlight if I missed something :). Using the admin vq proposal termino= logy of > > "device group". > > > > -- > > This would stop a device of a device > > group, but not the whole virtqueue group. If the admin VQ is offered by= the > > PF (since it's not exposed to the guest), it will continue accepting re= quests as > > normal. If it's exposed in the VF, I think the best bet is to shadow it= , since > > guest and host requests could conflict. > > > > vhost-vdpa device is exposed for a VF through vp-vdpa driver to user land= . > Now vp-vdpa driver will have to choose between using config register vs u= sing AQ to suspend/resume the device. > vp_vdpa cannot choose if the virtio device has an admin vq or any other feature, it just wraps the virtio device. If that virtio device does not expose AQ, vp_vdpa cannot expose it. > Why not always begin with more superior interface of AQ that address mult= iple of these needs for LM case? > Because it doesn't address valid use cases like vp_vdpa with no AQ, devices that are not VF, or nested virtualization. VHOST_VDPA_STOP / VHOST_VDPA_SET_STATE does not replace AQ commands: It's just the way vhost-vdpa exposes that capability to qemu. vdpa backend is free to choose whatever methods it finds better to implement it. > For LM case, more you explore, we realize that either VF relying on PF's = AQ for query/config/setup/restore makes more sense or have its own dedicate= d AQ. > This ioctl does not mandate that the device cannot implement it through AQ, or that the device has to be a VF. Thanks! > VM's suspend/resume operation can be handled through the shadow Q. > > > Since this is offered through vdpa, the device backend driver can route= it to > > whatever method works better for the hardware. For example, to send an > > admin vq command to the PF. That's why it's important to keep the featu= re > > as self-contained and orthogonal to others as possible. > > -- > > > > > > -- > > > > 2.31.1 > > > >