[v4,28/31] net/ena: exhaust interrupt callbacks in device close
Checks
Commit Message
From: Shai Brandes <shaibran@amazon.com>
Change rte_intr_callback_unregister to its synchronous variant to
ensure all active interrupt callbacks are completed before proceeding
with the flow. Relocate the interrupt deregistration to precede the
release of stats memory, thereby preventing the interrupt handler
from accessing memory that has already been freed.
Signed-off-by: Shai Brandes <shaibran@amazon.com>
Reviewed-by: Amit Bernstein <amitbern@amazon.com>
---
drivers/net/ena/ena_ethdev.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
@@ -867,6 +867,7 @@ static int ena_close(struct rte_eth_dev *dev)
struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
struct ena_adapter *adapter = dev->data->dev_private;
int ret = 0;
+ int rc;
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return 0;
@@ -875,17 +876,17 @@ static int ena_close(struct rte_eth_dev *dev)
ret = ena_stop(dev);
adapter->state = ENA_ADAPTER_STATE_CLOSED;
+ rte_intr_disable(intr_handle);
+ rc = rte_intr_callback_unregister_sync(intr_handle, ena_interrupt_handler_rte, dev);
+ if (unlikely(rc != 0))
+ PMD_INIT_LOG(ERR, "Failed to unregister interrupt handler\n");
+
ena_rx_queue_release_all(dev);
ena_tx_queue_release_all(dev);
rte_free(adapter->drv_stats);
adapter->drv_stats = NULL;
- rte_intr_disable(intr_handle);
- rte_intr_callback_unregister(intr_handle,
- ena_interrupt_handler_rte,
- dev);
-
/*
* MAC is not allocated dynamically. Setting NULL should prevent from
* release of the resource in the rte_eth_dev_release_port().