[Bug,1169,vhost] VDPA example is aborting when VM starts

Message ID bug-1169-3@http.bugs.dpdk.org/ (mailing list archive)
State Not Applicable, archived
Delegated to: Maxime Coquelin
Headers
Series [Bug,1169,vhost] VDPA example is aborting when VM starts |

Checks

Context Check Description
ci/Intel-compilation warning apply issues

Commit Message

bugzilla@dpdk.org Feb. 28, 2023, 1:26 p.m. UTC
  https://bugs.dpdk.org/show_bug.cgi?id=1169

            Bug ID: 1169
           Summary: [vhost]VDPA example is aborting when VM starts
           Product: DPDK
           Version: 23.03
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: Normal
         Component: vhost/virtio
          Assignee: dev@dpdk.org
          Reporter: ssimma@nvidia.com
  Target Milestone: ---

We believe that issue was caused by the following change:
4b02c2673757 ("vhost: annotate async accesses") 

        return RTE_VHOST_MSG_RESULT_OK;
}
  

Patch

diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
index 70d221b9f6..8c1d60b76b 100644
--- a/lib/vhost/vhost_user.c
+++ b/lib/vhost/vhost_user.c
@@ -2168,6 +2168,7 @@  vhost_user_set_vring_enable(struct virtio_net **pdev,
                        int main_fd __rte_unused)
{
        struct virtio_net *dev = *pdev;
+       struct vhost_virtqueue *vq;
        bool enable = !!ctx->msg.payload.state.num;
        int index = (int)ctx->msg.payload.state.index;

@@ -2175,15 +2176,18 @@  vhost_user_set_vring_enable(struct virtio_net **pdev,
                "set queue enable: %d to qp idx: %d\n",
                enable, index);

-       if (enable && dev->virtqueue[index]->async) {
-               if (dev->virtqueue[index]->async->pkts_inflight_n) {
+       vq = dev->virtqueue[index];
+       /* vhost_user_lock_all_queue_pairs locked all qps */
+       vq_assert_lock(dev, vq);                                       # this
assert fired
+       if (enable && vq->async) {
+               if (vq->async->pkts_inflight_n) {
                        VHOST_LOG_CONFIG(dev->ifname, ERR,
                                "failed to enable vring. Inflight packets must
be completed first\n");
                        return RTE_VHOST_MSG_RESULT_ERR;
                }
        }

-       dev->virtqueue[index]->enabled = enable;
+       vq->enabled = enable;