Notification area is a Virtio feature that requires to be
negotiated because not all devices support it. Currently,
it is tried to be initialized as soon as the backend
implements the callback, so it assumes all Vhost-vDPA
devices support it.

This patch skips calling the notification area map callback
if the device does not advertise its support.

Fixes: 0fd2782660c8 ("net/virtio-user: support notification area mapping")

Reviewed-by: David Marchand <david.march...@redhat.com>
Signed-off-by: Maxime Coquelin <maxime.coque...@redhat.com>
---
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c 
b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 54187fedf5..4fdfe70e7c 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -445,8 +445,9 @@ virtio_user_dev_init_notify(struct virtio_user_dev *dev)
                dev->kickfds[i] = kickfd;
        }
 
-       if (dev->ops->map_notification_area)
-               if (dev->ops->map_notification_area(dev))
+       if (dev->device_features & (1ULL << VIRTIO_F_NOTIFICATION_DATA))
+               if (dev->ops->map_notification_area &&
+                               dev->ops->map_notification_area(dev))
                        goto err;
 
        return 0;
-- 
2.44.0

Reply via email to