Stefano Garzarella
2022-May-26 09:07 UTC
[PATCH v3 2/4] vhost-vdpa: introduce STOP backend feature bit
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 <gautam.dawar at amd.com> wrote: >> >> [AMD Official Use Only - General] >> >> -----Original Message----- >> From: Eugenio P?rez <eperezma at redhat.com> >> Sent: Wednesday, May 25, 2022 4:29 PM >> To: Michael S. Tsirkin <mst at redhat.com>; netdev at vger.kernel.org; linux-kernel at vger.kernel.org; kvm at vger.kernel.org; virtualization at lists.linux-foundation.org; Jason Wang <jasowang at redhat.com> >> Cc: Zhu Lingshan <lingshan.zhu at intel.com>; martinh at xilinx.com; Stefano Garzarella <sgarzare at redhat.com>; ecree.xilinx at gmail.com; Eli Cohen <elic at nvidia.com>; Dan Carpenter <dan.carpenter at oracle.com>; Parav Pandit <parav at nvidia.com>; Wu Zongyong <wuzongyong at linux.alibaba.com>; dinang at xilinx.com; Christophe JAILLET <christophe.jaillet at wanadoo.fr>; Xie Yongji <xieyongji at bytedance.com>; Dawar, Gautam <gautam.dawar at amd.com>; lulu at redhat.com; martinpo at xilinx.com; pabloc at xilinx.com; Longpeng <longpeng2 at huawei.com>; Piotr.Uminski at intel.com; Kamde, Tanuj <tanuj.kamde at amd.com>; Si-Wei Liu <si-wei.liu at oracle.com>; habetsm.xilinx at gmail.com; lvivier at redhat.com; Zhang Min <zhang.min9 at zte.com.cn>; hanand at 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() operation callback, and try to set it if the backend does not offer that callback is an error. >> >> Signed-off-by: Eugenio P?rez <eperezma at redhat.com> >> --- >> 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 1f1d1c425573..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 = v->vdpa; >> + const struct vdpa_config_ops *ops = 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.IIUC `ops->stop` is a function pointer, so what about return ops->stop != NULL; Thanks, Stefano