[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d9403e25-41a2-cfbe-efa9-8952b8e1b881@redhat.com>
Date: Mon, 7 Dec 2020 13:30:59 +0800
From: Jason Wang <jasowang@...hat.com>
To: Stefano Garzarella <sgarzare@...hat.com>,
virtualization@...ts.linux-foundation.org
Cc: Stefan Hajnoczi <stefanha@...hat.com>,
"Michael S. Tsirkin" <mst@...hat.com>, Oren Duer <oren@...dia.com>,
Laurent Vivier <lvivier@...hat.com>,
linux-kernel@...r.kernel.org, Max Gurtovoy <mgurtovoy@...dia.com>,
Shahaf Shuler <shahafs@...dia.com>, Eli Cohen <elic@...dia.com>
Subject: Re: [PATCH v3 15/19] vdpa_sim: set vringh notify callback
On 2020/12/4 上午1:05, Stefano Garzarella wrote:
> Instead of calling the vq callback directly, we can leverage the
> vringh_notify() function, adding vdpasim_vq_notify() and setting it
> in the vringh notify callback.
>
> Suggested-by: Jason Wang <jasowang@...hat.com>
> Signed-off-by: Stefano Garzarella <sgarzare@...hat.com>
Acked-by: Jason Wang <jasowang@...hat.com>
> ---
> v3:
> - cleared notify during reset [Jason]
> ---
> drivers/vdpa/vdpa_sim/vdpa_sim.c | 23 +++++++++++++++++++----
> 1 file changed, 19 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c
> index 03a8717f80ea..1243b02488f7 100644
> --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
> +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
> @@ -123,6 +123,17 @@ static struct vdpasim *dev_to_sim(struct device *dev)
> return vdpa_to_sim(vdpa);
> }
>
> +static void vdpasim_vq_notify(struct vringh *vring)
> +{
> + struct vdpasim_virtqueue *vq =
> + container_of(vring, struct vdpasim_virtqueue, vring);
> +
> + if (!vq->cb)
> + return;
> +
> + vq->cb(vq->private);
> +}
> +
> static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx)
> {
> struct vdpasim_virtqueue *vq = &vdpasim->vqs[idx];
> @@ -134,6 +145,8 @@ static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx)
> (uintptr_t)vq->driver_addr,
> (struct vring_used *)
> (uintptr_t)vq->device_addr);
> +
> + vq->vring.notify = vdpasim_vq_notify;
> }
>
> static void vdpasim_vq_reset(struct vdpasim *vdpasim,
> @@ -147,6 +160,8 @@ static void vdpasim_vq_reset(struct vdpasim *vdpasim,
> vq->private = NULL;
> vringh_init_iotlb(&vq->vring, vdpasim->dev_attr.supported_features,
> VDPASIM_QUEUE_MAX, false, NULL, NULL, NULL);
> +
> + vq->vring.notify = NULL;
> }
>
> static void vdpasim_reset(struct vdpasim *vdpasim)
> @@ -223,10 +238,10 @@ static void vdpasim_net_work(struct work_struct *work)
> smp_wmb();
>
> local_bh_disable();
> - if (txq->cb)
> - txq->cb(txq->private);
> - if (rxq->cb)
> - rxq->cb(rxq->private);
> + if (vringh_need_notify_iotlb(&txq->vring) > 0)
> + vringh_notify(&txq->vring);
> + if (vringh_need_notify_iotlb(&rxq->vring) > 0)
> + vringh_notify(&rxq->vring);
> local_bh_enable();
>
> if (++pkts > 4) {
Powered by blists - more mailing lists