Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

vdpa_sim: set vringh notify callback

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@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Link: https://lore.kernel.org/r/20201215144256.155342-15-sgarzare@redhat.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

authored by

Stefano Garzarella and committed by
Michael S. Tsirkin
b240491b c124a95e

+19 -4
+19 -4
drivers/vdpa/vdpa_sim/vdpa_sim.c
··· 131 131 return vdpa_to_sim(vdpa); 132 132 } 133 133 134 + static void vdpasim_vq_notify(struct vringh *vring) 135 + { 136 + struct vdpasim_virtqueue *vq = 137 + container_of(vring, struct vdpasim_virtqueue, vring); 138 + 139 + if (!vq->cb) 140 + return; 141 + 142 + vq->cb(vq->private); 143 + } 144 + 134 145 static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx) 135 146 { 136 147 struct vdpasim_virtqueue *vq = &vdpasim->vqs[idx]; ··· 153 142 (uintptr_t)vq->driver_addr, 154 143 (struct vring_used *) 155 144 (uintptr_t)vq->device_addr); 145 + 146 + vq->vring.notify = vdpasim_vq_notify; 156 147 } 157 148 158 149 static void vdpasim_vq_reset(struct vdpasim *vdpasim, ··· 168 155 vq->private = NULL; 169 156 vringh_init_iotlb(&vq->vring, vdpasim->dev_attr.supported_features, 170 157 VDPASIM_QUEUE_MAX, false, NULL, NULL, NULL); 158 + 159 + vq->vring.notify = NULL; 171 160 } 172 161 173 162 static void vdpasim_reset(struct vdpasim *vdpasim) ··· 246 231 smp_wmb(); 247 232 248 233 local_bh_disable(); 249 - if (txq->cb) 250 - txq->cb(txq->private); 251 - if (rxq->cb) 252 - rxq->cb(rxq->private); 234 + if (vringh_need_notify_iotlb(&txq->vring) > 0) 235 + vringh_notify(&txq->vring); 236 + if (vringh_need_notify_iotlb(&rxq->vring) > 0) 237 + vringh_notify(&rxq->vring); 253 238 local_bh_enable(); 254 239 255 240 if (++pkts > 4) {