[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACycT3sjeWhUmHSAeniSnMO6Jus_d1p3eO--y0qc9FYP_cDMzQ@mail.gmail.com>
Date: Mon, 23 Aug 2021 15:44:59 +0800
From: Yongji Xie <xieyongji@...edance.com>
To: Jason Wang <jasowang@...hat.com>
Cc: "Michael S. Tsirkin" <mst@...hat.com>,
Stefan Hajnoczi <stefanha@...hat.com>,
Stefano Garzarella <sgarzare@...hat.com>,
Parav Pandit <parav@...dia.com>,
Christoph Hellwig <hch@...radead.org>,
Christian Brauner <christian.brauner@...onical.com>,
Randy Dunlap <rdunlap@...radead.org>,
Matthew Wilcox <willy@...radead.org>,
Al Viro <viro@...iv.linux.org.uk>,
Jens Axboe <axboe@...nel.dk>, bcrl@...ck.org,
Jonathan Corbet <corbet@....net>,
Mika Penttilä <mika.penttila@...tfour.com>,
Dan Carpenter <dan.carpenter@...cle.com>, joro@...tes.org,
Greg KH <gregkh@...uxfoundation.org>,
He Zhe <zhe.he@...driver.com>,
Liu Xiaodong <xiaodong.liu@...el.com>,
Joe Perches <joe@...ches.com>,
Robin Murphy <robin.murphy@....com>, songmuchun@...edance.com,
virtualization <virtualization@...ts.linux-foundation.org>,
netdev@...r.kernel.org, kvm <kvm@...r.kernel.org>,
linux-fsdevel@...r.kernel.org, iommu@...ts.linux-foundation.org,
linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v11 04/12] vdpa: Add reset callback in vdpa_config_ops
On Mon, Aug 23, 2021 at 2:31 PM Jason Wang <jasowang@...hat.com> wrote:
>
>
> 在 2021/8/18 下午8:06, Xie Yongji 写道:
> > This adds a new callback to support device specific reset
> > behavior. The vdpa bus driver will call the reset function
> > instead of setting status to zero during resetting if device
> > driver supports the new callback.
> >
> > Signed-off-by: Xie Yongji <xieyongji@...edance.com>
> > ---
> > drivers/vhost/vdpa.c | 9 +++++++--
> > include/linux/vdpa.h | 11 ++++++++++-
> > 2 files changed, 17 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> > index b07aa161f7ad..b1c91b4db0ba 100644
> > --- a/drivers/vhost/vdpa.c
> > +++ b/drivers/vhost/vdpa.c
> > @@ -157,7 +157,7 @@ static long vhost_vdpa_set_status(struct vhost_vdpa *v, u8 __user *statusp)
> > struct vdpa_device *vdpa = v->vdpa;
> > const struct vdpa_config_ops *ops = vdpa->config;
> > u8 status, status_old;
> > - int nvqs = v->nvqs;
> > + int ret, nvqs = v->nvqs;
> > u16 i;
> >
> > if (copy_from_user(&status, statusp, sizeof(status)))
> > @@ -172,7 +172,12 @@ static long vhost_vdpa_set_status(struct vhost_vdpa *v, u8 __user *statusp)
> > if (status != 0 && (ops->get_status(vdpa) & ~status) != 0)
> > return -EINVAL;
> >
> > - ops->set_status(vdpa, status);
> > + if (status == 0 && ops->reset) {
> > + ret = ops->reset(vdpa);
> > + if (ret)
> > + return ret;
> > + } else
> > + ops->set_status(vdpa, status);
> >
> > if ((status & VIRTIO_CONFIG_S_DRIVER_OK) && !(status_old & VIRTIO_CONFIG_S_DRIVER_OK))
> > for (i = 0; i < nvqs; i++)
> > diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h
> > index 8a645f8f4476..af7ea5ad795f 100644
> > --- a/include/linux/vdpa.h
> > +++ b/include/linux/vdpa.h
> > @@ -196,6 +196,9 @@ struct vdpa_iova_range {
> > * @vdev: vdpa device
> > * Returns the iova range supported by
> > * the device.
> > + * @reset: Reset device (optional)
> > + * @vdev: vdpa device
> > + * Returns integer: success (0) or error (< 0)
>
>
> It looks to me we'd better make this mandatory. This help to reduce the
> confusion for the parent driver.
>
OK, will do it in next version.
Thanks,
Yongji
Powered by blists - more mailing lists