Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp373100rwb; Thu, 11 Aug 2022 03:10:42 -0700 (PDT) X-Google-Smtp-Source: AA6agR6URJLshBT0X840MYq5t2NuWZ/Q7sfQM+Kd5qQ8sbPFGAj4ZYWSNYKekgBvLfjgWVSageJs X-Received: by 2002:a17:907:6288:b0:72f:90ba:f0b2 with SMTP id nd8-20020a170907628800b0072f90baf0b2mr22255745ejc.696.1660212642446; Thu, 11 Aug 2022 03:10:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660212642; cv=none; d=google.com; s=arc-20160816; b=pIVLBid2UR8CuR/tPdAUljTt4JFRV6Nk9mBa/L0ACq+oj33XhJRzBcWBfB+oUKZ7aJ PuX+VgeeY+pUvoPKbGiTzyikaWAiZ4uiVMOemXHJNwVr0PwQHDFsmVzYgmHoRLIzsour ImSam7ByWSTPTJQvhMv5Qaj21dIQmdiJoZFe/WrOH/GLZzef2n78sio9fBlYWg8phTBI L6RiIbd30v74mXI7i5zyBny3mhtY3QulY/ZYoGx3C0+bcsx9jCWCiCTsH72s69AWrAvi T+eQugeZ1+1URFspOBDCHh683ZhfwmvIFvHaet9COg194VKwFxrApXKgLwFt0l/FLOQ6 xHJw== 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=/R7Dryv+d3GV8pIXJrc5C98POWrIYtqGZwBiNr+Dx9I=; b=sYWni455yz5ifGAh1+DSK/+JW8rnz9H+mzP889hC9tLeZ9zcqxBW9xce4d100UC+Ct 1FIrLWnyturuKwC2eAdOM2l7ZjrVKs5hFzKY6xfOi9f6UGsx/G7f7V2AngID8PeNrgQx zNGtQHD39vtMzg4eTjv+52qOp68/IlGtjiqLVvDU+5H9K2PhnT4/UDE8b6qjeMU1+u/M 1HF839JwX99voMeJtYFp5V3prjshlFs51BbZ9S8FBLxs7WJj8NugY56z0F58mxAjxEqO 3GdFhENY840yGXwgyIBMvk077EQL9tFiNXXmuVrJRpkCjf29ipHt24xn7oMmuv/2zDU+ gWFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="R/Nvp7V9"; 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 f11-20020a056402354b00b0043cfed4d661si14882501edd.358.2022.08.11.03.10.17; Thu, 11 Aug 2022 03:10:42 -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="R/Nvp7V9"; 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 S234550AbiHKJ7C (ORCPT + 99 others); Thu, 11 Aug 2022 05:59:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233931AbiHKJ67 (ORCPT ); Thu, 11 Aug 2022 05:58:59 -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 F040291091 for ; Thu, 11 Aug 2022 02:58:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660211937; 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=/R7Dryv+d3GV8pIXJrc5C98POWrIYtqGZwBiNr+Dx9I=; b=R/Nvp7V91kusqwT9k4PzuN7jZvNUv/gvSztRZ5DAlrxSTXYo926VipWA6/8rY6WmBxBO8/ HvWtdMkAmECg+ZL0dGU0uzjtXGhFpoSB9IJNNncESX/iFzoKxzZLtu0R3flqTpnBYucUim w7fICKaxUoIRf593/gMqYgKEADCWP/8= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-146-dfe_E6B_MEaU54HU7XwEnA-1; Thu, 11 Aug 2022 05:58:55 -0400 X-MC-Unique: dfe_E6B_MEaU54HU7XwEnA-1 Received: by mail-qk1-f200.google.com with SMTP id bk21-20020a05620a1a1500b006b5c24695a4so14505774qkb.15 for ; Thu, 11 Aug 2022 02:58:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc; bh=/R7Dryv+d3GV8pIXJrc5C98POWrIYtqGZwBiNr+Dx9I=; b=ImPp1VPS+tYer6ZNUJ5/39Cesl1JxpKZNAHCGz8xkVPt49qI9QWdYs+f9po5DSgzdW JDN1gmnZZoVFoon27U4KkIcxxj6PszyQzS1xigHto/ArmlIcWSMntSZkVHaxC8OX7HCX cIlEjFsEgIIVIN/aKtkUQMC6//LcNfxVOyZo2gGCS15YXDpATOAPfPBMz86OO2+pxAqM JOmxE8b2BAeyJjHoucM99gOxR5cpy0mssabZry4xmhr67nK0i7mavOSAixrXRMa9TLCB J9hwmxSHm+h1B6L32y3fF8HvmlSOZerCAiWRIXWXJ2djg1HQOjnQcgGgX+clsmP1z9aw ynKA== X-Gm-Message-State: ACgBeo0NYtlS2tD3vlpA6FuHzKvY2QOWFRahlA1xegGzjzU4+pDdpTX3 RDmyYacMwIzFUXBYbqpn/ZKinhd41akJUN6HoqnbPG2EjuKeH/kGwXVti+pFCdvuCVxRIrhZycg IMW+/JE964y/hNhXbn45wmH/rFsMSyJwKt/Wl2Wu/ X-Received: by 2002:a05:620a:f10:b0:6aa:318e:55a9 with SMTP id v16-20020a05620a0f1000b006aa318e55a9mr23448015qkl.559.1660211935150; Thu, 11 Aug 2022 02:58:55 -0700 (PDT) X-Received: by 2002:a05:620a:f10:b0:6aa:318e:55a9 with SMTP id v16-20020a05620a0f1000b006aa318e55a9mr23447989qkl.559.1660211934843; Thu, 11 Aug 2022 02:58:54 -0700 (PDT) MIME-Version: 1.0 References: <20220810171512.2343333-1-eperezma@redhat.com> <20220810171512.2343333-4-eperezma@redhat.com> <20220811042847-mutt-send-email-mst@kernel.org> In-Reply-To: <20220811042847-mutt-send-email-mst@kernel.org> From: Eugenio Perez Martin Date: Thu, 11 Aug 2022 11:58:18 +0200 Message-ID: Subject: Re: [PATCH v7 3/4] vhost-vdpa: uAPI to suspend the device To: "Michael S. Tsirkin" Cc: kvm list , linux-kernel , Jason Wang , virtualization , netdev , Dinan Gunawardena , Martin Porter , Wu Zongyong , "Uminski, Piotr" , "Dawar, Gautam" , ecree.xilinx@gmail.com, Martin Petrus Hubertus Habets , Stefano Garzarella , Pablo Cascon Katchadourian , habetsm.xilinx@gmail.com, Laurent Vivier , Zhu Lingshan , "Kamde, Tanuj" , Longpeng , Cindy Lu , Harpreet Singh Anand , Parav Pandit , Si-Wei Liu , Eli Cohen , Xie Yongji , Zhang Min , Dan Carpenter , Christophe JAILLET 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=ham 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 Thu, Aug 11, 2022 at 10:29 AM Michael S. Tsirkin wrote: > > On Wed, Aug 10, 2022 at 07:15:11PM +0200, Eugenio P=C3=A9rez wrote: > > The ioctl adds support for suspending the device from userspace. > > > > This is a must before getting virtqueue indexes (base) for live migrati= on, > > 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 a successful return of the ioctl call the device must not process > > more virtqueue descriptors. The device can answer to read or writes of > > config fields as if it were not suspended. In particular, writing to > > "queue_enable" with a value of 1 will not make the device start > > processing buffers of the virtqueue. > > > > Signed-off-by: Eugenio P=C3=A9rez > > Message-Id: <20220623160738.632852-4-eperezma@redhat.com> > > Signed-off-by: Michael S. Tsirkin > > You are not supposed to include upstream maintainer's signoff > like this. > I'm very sorry, I modified the commits in your vhost branch and I left the signoff (and message-id) lines by mistake. > > --- > > v7: Delete argument to ioctl, unused > > --- > > drivers/vhost/vdpa.c | 19 +++++++++++++++++++ > > include/uapi/linux/vhost.h | 9 +++++++++ > > 2 files changed, 28 insertions(+) > > > > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c > > index 3d636e192061..7fa671ac4bdf 100644 > > --- a/drivers/vhost/vdpa.c > > +++ b/drivers/vhost/vdpa.c > > @@ -478,6 +478,22 @@ static long vhost_vdpa_get_vqs_count(struct vhost_= vdpa *v, u32 __user *argp) > > return 0; > > } > > > > +/* After a successful return of ioctl the device must not process more > > + * virtqueue descriptors. The device can answer to read or writes of c= onfig > > + * fields as if it were not suspended. In particular, writing to "queu= e_enable" > > + * with a value of 1 will not make the device start processing buffers= . > > + */ > > +static long vhost_vdpa_suspend(struct vhost_vdpa *v) > > +{ > > + struct vdpa_device *vdpa =3D v->vdpa; > > + const struct vdpa_config_ops *ops =3D vdpa->config; > > + > > + if (!ops->suspend) > > + return -EOPNOTSUPP; > > + > > + return ops->suspend(vdpa); > > +} > > + > > static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int = cmd, > > void __user *argp) > > { > > @@ -654,6 +670,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_SUSPEND: > > + r =3D vhost_vdpa_suspend(v); > > + 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..f9f115a7c75b 100644 > > --- a/include/uapi/linux/vhost.h > > +++ b/include/uapi/linux/vhost.h > > @@ -171,4 +171,13 @@ > > #define VHOST_VDPA_SET_GROUP_ASID _IOW(VHOST_VIRTIO, 0x7C, \ > > struct vhost_vring_state) > > > > +/* Suspend a device so it does not process virtqueue requests anymore > > + * > > + * After the return of ioctl the device must preserve all the necessar= y state > > + * (the virtqueue vring base plus the possible device specific states)= that is > > + * required for restoring in the future. The device must not change it= s > > + * configuration after that point. > > + */ > > +#define VHOST_VDPA_SUSPEND _IO(VHOST_VIRTIO, 0x7D) > > + > > #endif > > -- > > 2.31.1 >