vdpa/sfc: resolve race between vhost lib and device conf
authorAbhimanyu Saini <absaini@amd.com>
Wed, 6 Jul 2022 09:24:01 +0000 (14:54 +0530)
committerMaxime Coquelin <maxime.coquelin@redhat.com>
Fri, 8 Jul 2022 10:38:36 +0000 (12:38 +0200)
commitd9a1ef20f0f1c6f4029f79d5eab5dc696d115c81
treea1f4f57dfbbcfde44bf1b36ebda71925a637e756
parent60600018d3c6ae9ab4c24f9acb5c213bf9a21aaf
vdpa/sfc: resolve race between vhost lib and device conf

libvhost calls dev_conf() before prosessing the
VHOST_USER_SET_VRING_CALL message for the last VQ. So
this message is processed after dev_conf() returns.

However, the dev_conf() function spawns a thread to set
rte_vhost_host_notifier_ctrl() before returning control to
libvhost. This parallel thread in turn invokes get_notify_area().
To get the notify_area, the vdpa driver needs to query the HW and
for this query it needs an enabled VQ.

But at the same time libvhost is processing the last
VHOST_USER_SET_VRING_CALL, and to do that it disables the last VQ.

Hence there is a race b/w the libvhost and the vdpa driver.

To resolve this race condition, query the HW and cache notify_area
inside dev_conf() instead of doing it the parallel thread.

Fixes: 630be406dcbf ("vdpa/sfc: get queue notify area info")
Cc: stable@dpdk.org
Signed-off-by: Abhimanyu Saini <absaini@amd.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
drivers/vdpa/sfc/sfc_vdpa_ops.c
drivers/vdpa/sfc/sfc_vdpa_ops.h