[2/2] net/virtio: fix notification area initialization

Message ID 20240312104849.667036-3-maxime.coquelin@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers
Series net/virtio: vhost-vdpa fixes |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/iol-abi-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS

Commit Message

Maxime Coquelin March 12, 2024, 10:48 a.m. UTC
  Notification area is a Virtio feature that require 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")

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

Comments

David Marchand March 12, 2024, 2:12 p.m. UTC | #1
On Tue, Mar 12, 2024 at 11:48 AM Maxime Coquelin
<maxime.coquelin@redhat.com> wrote:
>
> Notification area is a Virtio feature that require to be

requires*

> 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")
>
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Reviewed-by: David Marchand <david.marchand@redhat.com>
  

Patch

diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 0b5db12886..b2e361ef3b 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -433,8 +433,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;