Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1036399ioo; Thu, 26 May 2022 23:13:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw74eYoDPDyoj9MxPMoeHOSRZQKZ4qV4YWVb0rgZd4TuUPh/wK4gCJaarXrLFqBd6jmnIEq X-Received: by 2002:a17:906:3087:b0:6f4:2901:608a with SMTP id 7-20020a170906308700b006f42901608amr37548404ejv.646.1653631984899; Thu, 26 May 2022 23:13:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653631984; cv=none; d=google.com; s=arc-20160816; b=Q6KTHrMPRAr7sIBThoJnBJNXb21fzPWP2IGizLZvLysN/MCYh6PriwL4sqDGCCk9A0 LOaqfzWurpVPTEpf+XKaT98wVSXw50EGO+5qpKFTaTglN8VBbR4Y1FbT0JueNrqVtxAt hqbkh65e0b8mf1nCpHWZrvmNtfXV7lnM4ECq6Jd281hm4WrdzMQk770+cKPlzPF7GXbV 6TTUGbrcvppvtd+Zf2Zg0SsPFUPUYpw2vD+/VNuJdV07wSQLLAn/iyaZiRi/BcxFxNtS e/IjSZNN2yvFu9FAGxfSlcJsc4DQwjx6aKR0MoouA7om+X4azd3O33R1Vnl+e8Nnp+uc 6nuw== 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=HHe1LaBtedJ5JV6CIRJWahlJ1EFaGN6YwiuH4nEgZ+o=; b=0zt8NvrvjyieumK5snIuAVpNBAgxW3FbZ78CMCwOk3kiK148JiNjFKJNGujWk/8a3B bj7BAcpQlK2XQuzcBSSQm3jaAf06zsg+Tq/pnWij+sPB3Ra9bUOPw04JJdAibboHB6t6 OWlfrTlPJJNzGpbG1RZPhvX8yAjIHD6aiVdvfBNym+XRlOsOewWsx5c5DxrakQugkSaT LYivlJ/kN633MPmp8CPtiD/KROd43ohzmhbo6W4EXC0U5srgWcri768d4pV0lLKEFe3n 73D3rdfQ7gUQRROotT7/5dWB3kHMnXPc/d85XZfu+qx85dBzB9vv47wg64HgqOh7NazR fVAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ciYRdY8W; 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 m15-20020a056402510f00b0042b710e9bbesi4014115edd.566.2022.05.26.23.12.39; Thu, 26 May 2022 23:13:04 -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=ciYRdY8W; 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 S1347392AbiEZMoy (ORCPT + 99 others); Thu, 26 May 2022 08:44:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347482AbiEZMon (ORCPT ); Thu, 26 May 2022 08:44:43 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 04BA8986DA for ; Thu, 26 May 2022 05:44:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653569080; 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=HHe1LaBtedJ5JV6CIRJWahlJ1EFaGN6YwiuH4nEgZ+o=; b=ciYRdY8WaY8hjk16N5ZWvG6uUSXazxyeuoXEzPlQVhBBr4W7pNzNguMnMod1f5vWjVMORY +lwANqaSk2NdUTw9cLg/uI+1tQsXv1+boIqjFlwdfQsrzBJIgqRV4A2Qt51V61Cmm1Z3J5 wWYmqZU1zmDixSpzTzDBFtdAzrZUvFU= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-631-nVtkJpS-PL2GBgRJXQT9Ag-1; Thu, 26 May 2022 08:44:39 -0400 X-MC-Unique: nVtkJpS-PL2GBgRJXQT9Ag-1 Received: by mail-qt1-f198.google.com with SMTP id a11-20020a05622a02cb00b002f3d23bdca2so1466777qtx.5 for ; Thu, 26 May 2022 05:44:39 -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=HHe1LaBtedJ5JV6CIRJWahlJ1EFaGN6YwiuH4nEgZ+o=; b=52TNdKe8uLnPzgMFPW1SB4KsXkdyQyFeBwqSfx4D0pKicrMLnQTSRgKQnyfD2ynHrQ VvFV6x6hNFbytHePU3nXwXJpoWBBuOt1Z/q8qKJFNTygVHlYFH5B03IIHAxeRNawZq+w mSX2eOB29gcL8Rp7Kpvh6XjJILfKpxiTaDvN/rLbyxhocvuqRB6Bqtk27I/5qcs2aWgi dCkEOTviegnnftWGXHJGpy3kojAH3Q47mmRIGu+ri4rgOpUgSvNYEC6DWqEYVoxru7tu jx9JUJrq2Rf2gkjCjUCFVRsl9GnLlbpf1192PGfRIGKeExNAfgGjpejLtu5fTeTaZAqY uHyg== X-Gm-Message-State: AOAM5322Z5FCh0aRb9BOyFKjqlg7bpQRKSaByPTNQNcRuz5TwHDmNVG+ IvqFeaybuCkETxCQwKHCmtiVKfKz10TYc0NYlX9pFffwlcVeTYpv+vnUcqOLrMfGQK+CzZqEEbM dUWIQCspj2iPkdIj3OjGSCOFacnhC3QUROtz1D5tV X-Received: by 2002:ad4:5b8e:0:b0:45e:727e:581 with SMTP id 14-20020ad45b8e000000b0045e727e0581mr30237118qvp.91.1653569078529; Thu, 26 May 2022 05:44:38 -0700 (PDT) X-Received: by 2002:ad4:5b8e:0:b0:45e:727e:581 with SMTP id 14-20020ad45b8e000000b0045e727e0581mr30237079qvp.91.1653569078322; Thu, 26 May 2022 05:44:38 -0700 (PDT) MIME-Version: 1.0 References: <20220525105922.2413991-1-eperezma@redhat.com> <20220525105922.2413991-3-eperezma@redhat.com> <20220526090706.maf645wayelb7mcp@sgarzare-redhat> In-Reply-To: <20220526090706.maf645wayelb7mcp@sgarzare-redhat> From: Eugenio Perez Martin Date: Thu, 26 May 2022 14:44:02 +0200 Message-ID: Subject: Re: [PATCH v3 2/4] vhost-vdpa: introduce STOP backend feature bit To: Stefano Garzarella Cc: "Dawar, Gautam" , "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" , "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=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, 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 Thu, May 26, 2022 at 11:07 AM Stefano Garzarella w= rote: > > On Thu, May 26, 2022 at 10:57:03AM +0200, Eugenio Perez Martin wrote: > >On Wed, May 25, 2022 at 1:23 PM Dawar, Gautam wro= te: > >> > >> [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= -kernel@vger.kernel.org; kvm@vger.kernel.org; virtualization@lists.linux-fo= undation.org; Jason Wang > >> Cc: 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 ; Dawar, Gautam ; lulu@redhat.com; mart= inpo@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 > >> 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 featu= re bit. > >> > >> It's only offered if the vdpa driver backend implements the stop() ope= ration callback, and try to set it if the backend does not offer that callb= ack 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 1f1d1c4= 25573..32713db5831d 100644 > >> --- a/drivers/vhost/vdpa.c > >> +++ b/drivers/vhost/vdpa.c > >> @@ -347,6 +347,14 @@ static long vhost_vdpa_set_config(struct vhost_vd= pa *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 ret= urn 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. > > IIUC `ops->stop` is a function pointer, so what about > > return ops->stop !=3D NULL; > I'm ok with any method proposed. Both three ways can be found in the kernel so I think they are all valid (although the double negation is from bool to integer in (0,1) set actually). Maybe Jason or Michael (as maintainers) can state the preferred method here= . Generally I prefer explicit conversions, both signed and from/to different types length. But I find conversion to bool to be simple enough to be an exception to the rule. Same with void *. Let's see! Sending v4 without this changed, waiting for answers. Thanks!