vdpa/sfc: fix sync between QEMU and vhost-user
authorAbhimanyu Saini <absaini@amd.com>
Tue, 28 Jun 2022 05:29:26 +0000 (10:59 +0530)
committerMaxime Coquelin <maxime.coquelin@redhat.com>
Fri, 1 Jul 2022 13:49:49 +0000 (15:49 +0200)
When DPDK app is running in the VF, it sometimes rings the doorbell
before dev_config has had a chance to complete and hence it misses
the event. As workaround, ring the doorbell when vDPA reports the
notify_area to QEMU.

Fixes: 630be406dcbf ("vdpa/sfc: get queue notify area info")
Cc: stable@dpdk.org
Signed-off-by: Vijay Kumar Srivastava <vsrivast@xilinx.com>
Signed-off-by: Abhimanyu Saini <absaini@amd.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
drivers/vdpa/sfc/sfc_vdpa_ops.c

index b3d9b6c..63aa52d 100644 (file)
@@ -794,6 +794,8 @@ sfc_vdpa_get_notify_area(int vid, int qid, uint64_t *offset, uint64_t *size)
        int vfio_dev_fd;
        efx_rc_t rc;
        unsigned int bar_offset;
+       volatile void *doorbell;
+       struct rte_pci_device *pci_dev;
        struct rte_vdpa_device *vdpa_dev;
        struct sfc_vdpa_ops_data *ops_data;
        struct vfio_region_info reg = { .argsz = sizeof(reg) };
@@ -856,6 +858,18 @@ sfc_vdpa_get_notify_area(int vid, int qid, uint64_t *offset, uint64_t *size)
        sfc_vdpa_info(dev, "vDPA ops get_notify_area :: offset : 0x%" PRIx64,
                      *offset);
 
+       pci_dev = sfc_vdpa_adapter_by_dev_handle(dev)->pdev;
+       doorbell = (uint8_t *)pci_dev->mem_resource[reg.index].addr + *offset;
+
+       /*
+        * virtio-net driver in VM sends queue notifications before
+        * vDPA has a chance to setup the queues and notification area,
+        * and hence the HW misses these doorbell notifications.
+        * Since, it is safe to send duplicate doorbell, send another
+        * doorbell from vDPA driver as workaround for this timing issue.
+        */
+       rte_write16(qid, doorbell);
+
        return 0;
 }