Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1260185ioo; Fri, 27 May 2022 05:12:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwL5S4ff9QLqItzzCYih6ZsCMVcAruxTvWCJhf3kQvj7ahLL5nYk9K96ZzPu5+p39kK2XoR X-Received: by 2002:a05:6402:440d:b0:412:9e8a:5e51 with SMTP id y13-20020a056402440d00b004129e8a5e51mr43778199eda.362.1653653527810; Fri, 27 May 2022 05:12:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653653527; cv=none; d=google.com; s=arc-20160816; b=XluSMxNcSm/0yvOar64X97YQ8kjoL14+hYiJLPpwVUB5m5QQoOlqTPpmFWpGbmWrUn FrYIt7GGwNb01+liDfmG3Xr+9sLbtvNWvyymrYkEC8565Nw3nELPEZms3X/Ob3Bw6XTe p/b4/p68Cw2JnX4u3SJveNbHZJa4+QpILyuF7T7VSZMgP+FHXCDofVPYpxuDfuJDWrDw iAQ7j2CVbbRyLLd1hzsD3r9VxtV8SRyg9W9OmCjNKbHgSQWGPRphktm1SgvJF4XzoZOx RHrQ3gv/1NgNhpiNAI8zClwnGwfDOmi7h5svsSIQ68sDpSswhtx+sJubSbuw28J55DFz /Ugg== 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=wZpmyj3OZQ3pBrXt/5TVuYqgh1eNpvGfVJnmbN2oiSY=; b=Sabvzx/Ixe27cTamyvAoM3bXs2nEJ2YV45DSigSeXdhClTeOwdx5VOEhfN4fPdmfUB 3bc4H7HZQ5i8DlHPRXCUjjIQWF23Xa8f9Bw5DA+I82pkrAcVvR9NrAwXruMr8lZKnxHn +dgHs5cbVfwotUOwWADYB6/3kgIR74DoueUxu2dAbTkkMK+r4Ao5p/pmdmbDaflgpymm dltBnT7zT+qLSIhr5kUldXdMMbR02WnFCATBYCa3axE6eI1/g2sislXMT9OB1cmU/hFH LCP1+IWBz8x0YMLQ+lgvuWQ2CL7ka5Njdr8WlRVoQY+0TPhN4SulGL32fnQ85Blh1Rmg RwMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dO5EkKVj; 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 f23-20020a170906c09700b006fef7a49ad1si59916ejz.84.2022.05.27.05.11.38; Fri, 27 May 2022 05:12:07 -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=dO5EkKVj; 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 S1345950AbiEZI5p (ORCPT + 99 others); Thu, 26 May 2022 04:57:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235533AbiEZI5n (ORCPT ); Thu, 26 May 2022 04:57:43 -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 9D369A8883 for ; Thu, 26 May 2022 01:57:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653555461; 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=wZpmyj3OZQ3pBrXt/5TVuYqgh1eNpvGfVJnmbN2oiSY=; b=dO5EkKVjhdhnkPqMNpleLatDOFu41WN94sXoC3WJAsKwL5N+vNbSYr0rrijIZIiDryOE7D FbSez67kgYwyjNbCXVB4ftmC/zR5fnI+RbrtjOP8XIkt1LiGG+2Y0fTM6glr78sQcgvAMH pEhGIwzqyzVCQC3PcRBX5wItuaZLkUM= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-554-qVEj97hjP42I0ZkOaNGiqQ-1; Thu, 26 May 2022 04:57:40 -0400 X-MC-Unique: qVEj97hjP42I0ZkOaNGiqQ-1 Received: by mail-qk1-f197.google.com with SMTP id c8-20020a05620a268800b0069c0f1b3206so853287qkp.18 for ; Thu, 26 May 2022 01:57:40 -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=wZpmyj3OZQ3pBrXt/5TVuYqgh1eNpvGfVJnmbN2oiSY=; b=T8PCABsEyrCM+ppHnchgFbYvL01/9t5pC1MueJipvDAZXYlVv3HDH4mMDArJsysiJ2 L9iq9HbXVvvGYhqFKM4d1KgEuPN1HZKRyrou0c9vLCs+rocRUJJ27zjzI1YKrCajCfC7 edy/QlWMh5Dd9LeQVZVxeHPtbJPvoQ5leGNqMhKCZJziDytMgFw/TFzZF00xN7Z2jJ/m 33aKu5c2lRjYRgnUWpf5CT2WSjuLYHQ0AJiZBpdRMmKXxa6N4cMUGTihFzJh8PaqKns/ Vuj9zuuHS6nCPzeg4WRPAxu0L2UBM5eO6ehFMm2R3+lpOuvVhMGbgWEaNrU6ysBd+nKe Sxpw== X-Gm-Message-State: AOAM5312hO98D9sBHm3XZ3pzuBo/9eq5gvi3Vx/qHm4DFycyCvkC7rWG nZIGF3c8OTtZsdJKhf01fswklswynyDrgw62U0IB/VBeZFUMSZ6TPcqVX88vqttrBnIkqshq2ik Z9lppqhvWol5yNB/ghbjrweK1BtNqvK76QF0V1PvV X-Received: by 2002:a05:622a:1899:b0:2f3:b09e:dbe9 with SMTP id v25-20020a05622a189900b002f3b09edbe9mr27814502qtc.199.1653555459670; Thu, 26 May 2022 01:57:39 -0700 (PDT) X-Received: by 2002:a05:622a:1899:b0:2f3:b09e:dbe9 with SMTP id v25-20020a05622a189900b002f3b09edbe9mr27814485qtc.199.1653555459453; Thu, 26 May 2022 01:57:39 -0700 (PDT) MIME-Version: 1.0 References: <20220525105922.2413991-1-eperezma@redhat.com> <20220525105922.2413991-3-eperezma@redhat.com> In-Reply-To: From: Eugenio Perez Martin Date: Thu, 26 May 2022 10:57:03 +0200 Message-ID: Subject: Re: [PATCH v3 2/4] vhost-vdpa: introduce STOP backend feature bit To: "Dawar, Gautam" Cc: "Michael S. Tsirkin" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" , "virtualization@lists.linux-foundation.org" , Jason Wang , Zhu Lingshan , "martinh@xilinx.com" , Stefano Garzarella , "ecree.xilinx@gmail.com" , Eli Cohen , Dan Carpenter , Parav Pandit , Wu Zongyong , "dinang@xilinx.com" , Christophe JAILLET , Xie Yongji , "lulu@redhat.com" , "martinpo@xilinx.com" , "pabloc@xilinx.com" , Longpeng , "Piotr.Uminski@intel.com" , "Kamde, Tanuj" , Si-Wei Liu , "habetsm.xilinx@gmail.com" , "lvivier@redhat.com" , Zhang Min , "hanand@xilinx.com" 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 Wed, May 25, 2022 at 1:23 PM Dawar, Gautam wrote: > > [AMD Official Use Only - General] > > -----Original Message----- > From: Eugenio P=C3=A9rez > Sent: Wednesday, May 25, 2022 4:29 PM > To: Michael S. Tsirkin ; netdev@vger.kernel.org; linux-ke= rnel@vger.kernel.org; kvm@vger.kernel.org; virtualization@lists.linux-found= ation.org; Jason Wang > Cc: Zhu Lingshan ; martinh@xilinx.com; Stefano Ga= rzarella ; ecree.xilinx@gmail.com; Eli Cohen ; Dan Carpenter ; Parav Pandit ; Wu Zongyong ; dinang@xilinx.com; Ch= ristophe JAILLET ; Xie Yongji ; Dawar, Gautam ; lulu@redhat.com; martinp= o@xilinx.com; pabloc@xilinx.com; Longpeng ; Piotr.Umi= nski@intel.com; Kamde, Tanuj ; Si-Wei Liu ; habetsm.xilinx@gmail.com; lvivier@redhat.com; Zhang Min ; hanand@xilinx.com > Subject: [PATCH v3 2/4] vhost-vdpa: introduce STOP backend feature bit > > [CAUTION: External Email] > > Userland knows if it can stop the device or not by checking this feature = bit. > > It's only offered if the vdpa driver backend implements the stop() operat= ion callback, and try to set it if the backend does not offer that callback= is an error. > > 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 1f1d1c4255= 73..32713db5831d 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_stop(const struct vhost_vdpa *v) { > + struct vdpa_device *vdpa =3D v->vdpa; > + const struct vdpa_config_ops *ops =3D vdpa->config; > + > + return ops->stop; > [GD>>] Would it be better to explicitly return a bool to match the return= type? I'm not sure about the kernel code style regarding that casting. Maybe it's better to return !!ops->stop here. The macros likely and unlikely do that. Thanks! > +} > + > static long vhost_vdpa_get_features(struct vhost_vdpa *v, u64 __user *fe= aturep) { > struct vdpa_device *vdpa =3D v->vdpa; @@ -575,7 +583,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_STOP))) > + return -EOPNOTSUPP; > + if ((features & BIT_ULL(VHOST_BACKEND_F_STOP)) && > + !vhost_vdpa_can_stop(v)) > return -EOPNOTSUPP; > vhost_set_backend_features(&v->vdev, features); > return 0; > @@ -624,6 +636,8 @@ static long vhost_vdpa_unlocked_ioctl(struct file *fi= lep, > break; > case VHOST_GET_BACKEND_FEATURES: > features =3D VHOST_VDPA_BACKEND_FEATURES; > + if (vhost_vdpa_can_stop(v)) > + features |=3D BIT_ULL(VHOST_BACKEND_F_STOP); > 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..2758e665791b 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 > +/* Stop device from processing virtqueue buffers */ #define > +VHOST_BACKEND_F_STOP 0x4 > > #endif > -- > 2.27.0 >