Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp320436rwb; Thu, 11 Aug 2022 02:02:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR6gULl8briHRYiD6hBORsynH31k0RYVoA9mQ+2n71x7vX+uTw+1p7AafcS287lNF/ICAXwF X-Received: by 2002:a17:907:7f9f:b0:733:76c:44c9 with SMTP id qk31-20020a1709077f9f00b00733076c44c9mr5344134ejc.642.1660208522506; Thu, 11 Aug 2022 02:02:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660208522; cv=none; d=google.com; s=arc-20160816; b=ujgKnBV2IX7W0EZ68OH7eLQHa9JNs3kERDVjjcYnHCuM/pN5dhh/NyAGWpv7JDnSgd V30Z9dTE1oYhNDDqHpHsN99Zs30CpG5IDFccgLpRl3ByoGPH5yxFbdbKNg9ORlKxvRIM 2bTPHgnQprP86NDVd7oAMKHvR2jmW63idsFfqcly/Ei56aA2fKtfpRQF/umYI45uRvMM e2FyQ2zN6KUPH/ZdPuU1faWRe2BJr1LSQL0ObWw5AEHSIWmCxo1zNYHNZbaTt14dZIZ5 XcK7ZwST+FQSLTpt9OBRSrCSLao/1ypbXVBvztCWOpiefRRvMTrSK106q1RUaeZOm4Ur No6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=FxVByzSzFDmsCiLB/TiRSXnYOQzfrWFzUNaldqvoDEA=; b=RyDDXDsquhpWvO0qkr0rHpjC7tG/FuySlxv9CEcJt+nEt1/ALD8itUL8pqNb6S0M1B QmureenXoeiNXSTpT3fUbePfzo7ovRloeOPQjRnhTfz5/9T9O5hw9ZG2OQtT2H49Lpmf KHu507vrIaEg2/3UUf09lJ4IHQ4lotAxhgIG7BKBhhkjQlOuEfAveE222Jk5wEdK8fPV 0oVoKFNv3XuH5EAHHc8qdf+h5M4+xhzBvED3HB6zTwhVvTY7aLnw+3yUoOuut4EIQ4Q0 URVOkkVeFwGiod8+SbP5Vmk/EWWk83dS2WR3im18EFpzMhqSiiqRXCSFSGYlG7an36PH NHAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FcuPBac9; 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 dd7-20020a1709069b8700b0073045237fd2si7163975ejc.751.2022.08.11.02.01.34; Thu, 11 Aug 2022 02:02:02 -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=FcuPBac9; 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 S234193AbiHKI3U (ORCPT + 99 others); Thu, 11 Aug 2022 04:29:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234481AbiHKI3T (ORCPT ); Thu, 11 Aug 2022 04:29:19 -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 130B990837 for ; Thu, 11 Aug 2022 01:29:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660206556; 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=FxVByzSzFDmsCiLB/TiRSXnYOQzfrWFzUNaldqvoDEA=; b=FcuPBac9nPT8MZMNA0pvH3pQdYJ6MuzVJkVA59rxA9BLjP33Jq9yD1AYRXF85QFAqFqeDU wvzOWtrUmztqKERLfFOw+8RLIzdktCFIbxb6wb+VtiL4J+zzUmAcD4ixs8CKMNziCy/ZqW XR+Ku1lQuZTmqEYWk13zAaSCwpQqors= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-126-Vze-934UN4m0CCeQx0n_Jg-1; Thu, 11 Aug 2022 04:29:14 -0400 X-MC-Unique: Vze-934UN4m0CCeQx0n_Jg-1 Received: by mail-wm1-f70.google.com with SMTP id q10-20020a1ce90a000000b003a4f6e08166so1416236wmc.5 for ; Thu, 11 Aug 2022 01:29:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc; bh=FxVByzSzFDmsCiLB/TiRSXnYOQzfrWFzUNaldqvoDEA=; b=u7lc0vJpP42FWcGXRMsjKFQmKZTfrPlyikyZxLdFUdMwZ1DRT4TzHoqXrcKXQigdz6 cyICnmjm08ngjAgLKdSUUI7zsvDwy/vvRa6TqCMP3p9R2eUpAF7LQoburSBP9xP6JfXA e6Dep/YP/0mI1lHQ8JWo3AAGBkcMiV9/XYYfOwkPEqw/30XoY0P8YUFO90XpTWSWG5CG QGW3+6KC2Gv0vbemahDPK9XBLf+DOhWTqItQR8rRg3LCScNsf92u2CYQFmVkEVK9y6IN cQx+uIGO0I9Wa06TBcJKQqyxzpgn+cYCooylwCz3gfBzfgyPtCzyGUWlSWMN6nN2V0S/ Wjgw== X-Gm-Message-State: ACgBeo3yu2Kz+G3LYR8gFOtLbLIorc6l3yhI7fScqGtTulU/f6IzATvw HBrmcd2ktOyoJ3Hd2OHk3CLkc1hh0lSlYatHmoFQJXjTosoGaLkweMU/cnzVFee2xXXkUh6kICL FlvaELgpYcjf0CZ4iBI0VVyQs X-Received: by 2002:a7b:cbd7:0:b0:3a5:500e:13bc with SMTP id n23-20020a7bcbd7000000b003a5500e13bcmr4872406wmi.83.1660206553689; Thu, 11 Aug 2022 01:29:13 -0700 (PDT) X-Received: by 2002:a7b:cbd7:0:b0:3a5:500e:13bc with SMTP id n23-20020a7bcbd7000000b003a5500e13bcmr4872374wmi.83.1660206553473; Thu, 11 Aug 2022 01:29:13 -0700 (PDT) Received: from redhat.com ([2.52.152.113]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c3b1500b003a317ee3036sm5522733wms.2.2022.08.11.01.29.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Aug 2022 01:29:12 -0700 (PDT) Date: Thu, 11 Aug 2022 04:29:06 -0400 From: "Michael S. Tsirkin" To: Eugenio =?iso-8859-1?Q?P=E9rez?= Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Jason Wang , virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, dinang@xilinx.com, martinpo@xilinx.com, Wu Zongyong , Piotr.Uminski@intel.com, gautam.dawar@amd.com, ecree.xilinx@gmail.com, martinh@xilinx.com, Stefano Garzarella , pabloc@xilinx.com, habetsm.xilinx@gmail.com, lvivier@redhat.com, Zhu Lingshan , tanuj.kamde@amd.com, Longpeng , lulu@redhat.com, hanand@xilinx.com, Parav Pandit , Si-Wei Liu , Eli Cohen , Xie Yongji , Zhang Min , Dan Carpenter , Christophe JAILLET Subject: Re: [PATCH v7 3/4] vhost-vdpa: uAPI to suspend the device Message-ID: <20220811042847-mutt-send-email-mst@kernel.org> References: <20220810171512.2343333-1-eperezma@redhat.com> <20220810171512.2343333-4-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220810171512.2343333-4-eperezma@redhat.com> 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, Aug 10, 2022 at 07:15:11PM +0200, Eugenio P?rez wrote: > The ioctl adds support for suspending the device from userspace. > > This is a must before getting 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 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?rez > 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. > --- > 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 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. > + */ > +static long vhost_vdpa_suspend(struct vhost_vdpa *v) > +{ > + struct vdpa_device *vdpa = v->vdpa; > + const struct vdpa_config_ops *ops = 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 = vhost_vdpa_get_vqs_count(v, argp); > break; > + case VHOST_VDPA_SUSPEND: > + r = vhost_vdpa_suspend(v); > + break; > default: > r = vhost_dev_ioctl(&v->vdev, cmd, argp); > if (r == -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 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. > + */ > +#define VHOST_VDPA_SUSPEND _IO(VHOST_VIRTIO, 0x7D) > + > #endif > -- > 2.31.1