Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp387473imw; Fri, 8 Jul 2022 04:58:27 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vfYpCBmTi1RexeVLyUfJTaCC0dkfIhNxjMfnHaHlHvbaZaCnLo2XmoPTcja1uRjx/nmjXw X-Received: by 2002:a17:906:7a56:b0:722:df69:3bd5 with SMTP id i22-20020a1709067a5600b00722df693bd5mr3096320ejo.581.1657281506804; Fri, 08 Jul 2022 04:58:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657281506; cv=none; d=google.com; s=arc-20160816; b=reSVRSV5cUgZTKGVkELdvbJO6BPNGA+zjpE17ecaELABi+Yyges6wIDNoeTDRfeHzl +lmvNNwLD/m776fs86tOdxiHsBWu8Ya4f+J5zfjaQ32dWe3LfY3wRQPYxCA8LhhG0YJ7 zAT3RiEQRK9uU/5Iu8YuLTWrCyqqoafpghS9NJ9F6PkL/cKKYh6NtFoM9jkgCUfHHQpe vpRy5NvETCzMOiAfqcYVLlaj4NQoydoK8zr5jDis7DcRCCVSL91HuhKbwFtM3Mf0hwuG EILqBEbqgxuOPB6V/utPkOlCewy34diaARBQ9/LbzatNWxdDl+2EgL4m0aRluAcDSz0t 89zw== 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=yNVgEcpzM+/vCThcvSnZLW7eVIEstg9RdMdX8L07Sh8=; b=N0DOJ10x82BPDh2rTxcPx9XSxSO6tuZAv7jIINc/kAMsEQM/5jp0yWj03CsHZXcGtb dRnkNmlfokHb23Hf6j0cOY/AwnyP0GrVXnXWqGfFz0sGxSQlOgFUXNYEOgYEAftib7s/ gjrKjLfKhS0q91AdUHiNrNeVKYE1OLbgbIa9MK+iCguZ1wSxPcveNwbydv6b+W7aCZp6 imVc0i9NZ1WBG3CX5iucUI5TPVSLZVHzg3/KLNvGzQjHdtsXHmESj9VNLwLdrHgk0M46 niDdsAfhHwXl4w1Ll+ils7O4S8WOq3MKP/FG2hrDWYz6DA8DLmve+KSjzWCM+F371uXG e9ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LIxn50q3; 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 sa13-20020a1709076d0d00b0072a84586c63si7202081ejc.564.2022.07.08.04.58.01; Fri, 08 Jul 2022 04:58:26 -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=LIxn50q3; 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 S237680AbiGHLjc (ORCPT + 99 others); Fri, 8 Jul 2022 07:39:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237499AbiGHLjb (ORCPT ); Fri, 8 Jul 2022 07:39:31 -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 576661D338 for ; Fri, 8 Jul 2022 04:39:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657280369; 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=yNVgEcpzM+/vCThcvSnZLW7eVIEstg9RdMdX8L07Sh8=; b=LIxn50q35A3XwPeeLmx7Er1tARueeQ2fK0eTcDpeWCkaecdnF3mAJ9oUIvH2YX6QFwso8O Dv6JiY2rV6SOm/yXgdQNX93RqrmqoosDBx2V4uSsIlANElCs3t/j0LUSfTccvq9rDOWnbi u+ttleVw9PlvIT0PdIV1xPuG5fZ5Cf8= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-486-zcGw7ikFMG-ULBAb5zKYVA-1; Fri, 08 Jul 2022 07:39:22 -0400 X-MC-Unique: zcGw7ikFMG-ULBAb5zKYVA-1 Received: by mail-qk1-f198.google.com with SMTP id bl27-20020a05620a1a9b00b0069994eeb30cso20599563qkb.11 for ; Fri, 08 Jul 2022 04:39:22 -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=yNVgEcpzM+/vCThcvSnZLW7eVIEstg9RdMdX8L07Sh8=; b=WSbMY4RZKwKBTszczEFqvBq/+W0y75kADwBVCeBLdZffJafLMl4vMMyuJRyv3yHBcm diP/qZVdo/5wWbBIJf5/wYd+8L0imNLqHADLxWqCoYpsYHaWVJkyD/qRdpVXkTXyIGS0 ZvTXOr8SiY2I78A8Sm1GjQoj8KXklRkrsl50ic9JqBiVHlqn78SqKGx00ScPfupsrTxU 46Uiv8UpIaZ3q5Y1Y0axPaFi6BkC7rySt6ttSK7PcyYG1t2ES4li6pYlaTdX1kgTAyZZ mbjBbVryTCqYxwI9jstXPBPTkJ/8Qxn9aQ3755XeBK2yE1SIAKopxRbTe8IxC4DeVWam A+eg== X-Gm-Message-State: AJIora9KM5rOosra7okwPQvm6D9ourJ0H28fgvAi6Popou+GZ8qwwzPO 5/+Vh+riqEPbHlxelrbkEtTD982CcedpLD6maep5v8wnMy1z1YxWoyP58/qeq4sn+NdRNaWBB+j dyImqUK4FGC2O0Ccy0qtMR3nLmXQRNb0m2kOnbi1+ X-Received: by 2002:ac8:5b51:0:b0:317:3513:cf60 with SMTP id n17-20020ac85b51000000b003173513cf60mr2417299qtw.495.1657280362052; Fri, 08 Jul 2022 04:39:22 -0700 (PDT) X-Received: by 2002:ac8:5b51:0:b0:317:3513:cf60 with SMTP id n17-20020ac85b51000000b003173513cf60mr2417280qtw.495.1657280361792; Fri, 08 Jul 2022 04:39:21 -0700 (PDT) MIME-Version: 1.0 References: <20220623160738.632852-1-eperezma@redhat.com> <20220623160738.632852-3-eperezma@redhat.com> <20220628134340.5fla7surd34bwnq3@sgarzare-redhat> In-Reply-To: <20220628134340.5fla7surd34bwnq3@sgarzare-redhat> From: Eugenio Perez Martin Date: Fri, 8 Jul 2022 13:38:45 +0200 Message-ID: Subject: Re: [PATCH v6 2/4] vhost-vdpa: introduce SUSPEND backend feature bit To: Stefano Garzarella Cc: netdev , Jason Wang , linux-kernel , virtualization , kvm list , "Michael S. Tsirkin" , Parav Pandit , Christophe JAILLET , Cindy Lu , "Kamde, Tanuj" , Si-Wei Liu , "Uminski, Piotr" , habetsm.xilinx@gmail.com, "Dawar, Gautam" , Pablo Cascon Katchadourian , Zhu Lingshan , Laurent Vivier , Longpeng , Dinan Gunawardena , Martin Petrus Hubertus Habets , Martin Porter , Eli Cohen , ecree.xilinx@gmail.com, Wu Zongyong , Dan Carpenter , Harpreet Singh Anand , Xie Yongji , Zhang Min Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.8 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 Tue, Jun 28, 2022 at 3:43 PM Stefano Garzarella wr= ote: > > On Thu, Jun 23, 2022 at 06:07:36PM +0200, Eugenio P=C3=A9rez wrote: > >Userland knows if it can suspend the device or not by checking this feat= ure > >bit. > > > >It's only offered if the vdpa driver backend implements the suspend() > >operation callback, and to offer it or userland to ack it if the backend > >does not offer that callback is an error. > > Should we document in the previous patch that the callback must be > implemented only if the drive/device support it? > It's marked as optional in the doc, following other optional callbacks like set_group_asid for example. But I'm ok with documenting this behavior further. > The rest LGTM although I have a doubt whether it is better to move this > patch after patch 3, or merge it with patch 3, for bisectability since > we enable the feature here but if the userspace calls ioctl() with > VHOST_VDPA_SUSPEND we reply back that it is not supported. > I'm fine with moving it, but we will have that behavior with all the devices anyway. Regarding userspace, we just replace ENOIOCTL with EOPNOTSUPP. Or I'm missing something? Thanks! > Thanks, > Stefano > > > > >Signed-off-by: Eugenio P=C3=A9rez > >--- > > drivers/vhost/vdpa.c | 16 +++++++++++++++- > > include/uapi/linux/vhost_types.h | 2 ++ > > 2 files changed, 17 insertions(+), 1 deletion(-) > > > >diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c > >index 23dcbfdfa13b..3d636e192061 100644 > >--- a/drivers/vhost/vdpa.c > >+++ b/drivers/vhost/vdpa.c > >@@ -347,6 +347,14 @@ static long vhost_vdpa_set_config(struct vhost_vdpa= *v, > > return 0; > > } > > > >+static bool vhost_vdpa_can_suspend(const struct vhost_vdpa *v) > >+{ > >+ struct vdpa_device *vdpa =3D v->vdpa; > >+ const struct vdpa_config_ops *ops =3D vdpa->config; > >+ > >+ return ops->suspend; > >+} > >+ > > static long vhost_vdpa_get_features(struct vhost_vdpa *v, u64 __user *f= eaturep) > > { > > struct vdpa_device *vdpa =3D v->vdpa; > >@@ -577,7 +585,11 @@ static long vhost_vdpa_unlocked_ioctl(struct file *= filep, > > if (cmd =3D=3D VHOST_SET_BACKEND_FEATURES) { > > if (copy_from_user(&features, featurep, sizeof(features))= ) > > return -EFAULT; > >- if (features & ~VHOST_VDPA_BACKEND_FEATURES) > >+ if (features & ~(VHOST_VDPA_BACKEND_FEATURES | > >+ BIT_ULL(VHOST_BACKEND_F_SUSPEND))) > >+ return -EOPNOTSUPP; > >+ if ((features & BIT_ULL(VHOST_BACKEND_F_SUSPEND)) && > >+ !vhost_vdpa_can_suspend(v)) > > return -EOPNOTSUPP; > > vhost_set_backend_features(&v->vdev, features); > > return 0; > >@@ -628,6 +640,8 @@ static long vhost_vdpa_unlocked_ioctl(struct file *f= ilep, > > break; > > case VHOST_GET_BACKEND_FEATURES: > > features =3D VHOST_VDPA_BACKEND_FEATURES; > >+ if (vhost_vdpa_can_suspend(v)) > >+ features |=3D BIT_ULL(VHOST_BACKEND_F_SUSPEND); > > if (copy_to_user(featurep, &features, sizeof(features))) > > r =3D -EFAULT; > > break; > >diff --git a/include/uapi/linux/vhost_types.h b/include/uapi/linux/vhost= _types.h > >index 634cee485abb..1bdd6e363f4c 100644 > >--- a/include/uapi/linux/vhost_types.h > >+++ b/include/uapi/linux/vhost_types.h > >@@ -161,5 +161,7 @@ struct vhost_vdpa_iova_range { > > * message > > */ > > #define VHOST_BACKEND_F_IOTLB_ASID 0x3 > >+/* Device can be suspended */ > >+#define VHOST_BACKEND_F_SUSPEND 0x4 > > > > #endif > >-- > >2.31.1 > > >