Skip to contentSkip to conversation

net/virtio: fix eventfd enable on device re-init

PATCH In review Ciara Loftus 2 participants 4 messages Nov 23 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/virtio: fix eventfd enable on device re-init

virtio_dev_configure() can call virtio_init_device() more than once with Rx interrupts enabled. Each call enables the eventfds again without releasing the previous ones. This used to leak the old eventfds, but EAL now rejects the repeated enable, causing dev_configure() to fail.

Fix this by disabling the eventfds before enabling them again, except for virtio-user which does not recreate them.

Fixes e7b9d1d2806c ("net/virtio: fix Rx interrupt setup")
---
 drivers/net/virtio/virtio_ethdev.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/virtio/virtio_ethdev.c +4 -0
index f2302089ee..18d258a519 100644
@@ -1455,6 +1455,10 @@ virtio_configure_intr(struct rte_eth_dev *dev)
 		return -ENOTSUP;
 	}
 
+	/* Release efds from a previous init. VDEV owns its own */
+	if (rte_intr_type_get(dev->intr_handle) != RTE_INTR_HANDLE_VDEV)
+		rte_intr_efd_disable(dev->intr_handle);
+
 	ret = rte_intr_efd_enable(dev->intr_handle, dev->data->nb_rx_queues);
 	if (ret < 0) {
 		PMD_INIT_LOG(ERR, "Fail to create eventfd");
Signature · 1 line
2.43.0
#1 lore raw

Hello Ciara,

Quoted 9 lines · Ciara Loftus

virtio_dev_configure() can call virtio_init_device() more than once with Rx interrupts enabled. Each call enables the eventfds again without releasing the previous ones. This used to leak the old eventfds, but EAL now rejects the repeated enable, causing dev_configure() to fail.

Fix this by disabling the eventfds before enabling them again, except for virtio-user which does not recreate them.

Quoted 8 lines
Fixes e7b9d1d2806c ("net/virtio: fix Rx interrupt setup")
---
 drivers/net/virtio/virtio_ethdev.c | 4 ++++
 1 file changed, 4 insertions(+)

David posted a patch to revert 3ba6b689893f, so in theory your patch should not be needed.

The revert is part of v26.11-rc4.
Can you confirm you do not reproduce this issue with -rc4?

Thanks,
Maxime

#2 lore raw
Quoted 18 lines

Subject: Re: [PATCH] net/virtio: fix eventfd enable on device re-init

Hello Ciara,

Quoted 12 lines · Ciara Loftus

virtio_dev_configure() can call virtio_init_device() more than once with Rx interrupts enabled. Each call enables the eventfds again without releasing the previous ones. This used to leak the old eventfds, but EAL now rejects the repeated enable, causing dev_configure() to fail.

Fix this by disabling the eventfds before enabling them again, except for virtio-user which does not recreate them.

Fixes e7b9d1d2806c ("net/virtio: fix Rx interrupt setup")
Quoted 8 lines
Quoted 5 lines
---
 drivers/net/virtio/virtio_ethdev.c | 4 ++++
 1 file changed, 4 insertions(+)

David posted a patch to revert 3ba6b689893f, so in theory your patch should not be needed.

Apologies, I missed that.

Quoted 3 lines

The revert is part of v26.11-rc4.
Can you confirm you do not reproduce this issue with -rc4?

Confirmed, I don't see the configure failure with rc4.

Quoted 3 lines

Thanks,
Maxime

#3 lore raw
Quoted 25 lines · Ciara
Quoted 25 lines

Subject: Re: [PATCH] net/virtio: fix eventfd enable on device re-init

Hello Ciara,

Quoted 17 lines · Ciara Loftus

virtio_dev_configure() can call virtio_init_device() more than once with Rx interrupts enabled. Each call enables the eventfds again without releasing the previous ones. This used to leak the old eventfds, but EAL now rejects the repeated enable, causing dev_configure() to fail.

Fix this by disabling the eventfds before enabling them again, except for virtio-user which does not recreate them.

Fixes e7b9d1d2806c ("net/virtio: fix Rx interrupt setup")
---
 drivers/net/virtio/virtio_ethdev.c | 4 ++++
 1 file changed, 4 insertions(+)
Quoted 4 lines
Quoted 2 lines

David posted a patch to revert 3ba6b689893f, so in theory your patch should not be needed.

Apologies, I missed that.

No apologies needed!

Quoted 5 lines
Quoted 3 lines

The revert is part of v26.11-rc4.
Can you confirm you do not reproduce this issue with -rc4?

Confirmed, I don't see the configure failure with rc4.

Thanks for confirming,
Maxime

Quoted 4 lines
Quoted 3 lines

Thanks,
Maxime