Skip to contentSkip to conversation

iavf: use internal state to free traffic IRQs

PATCH Superseded Ahmed Zaki 2 participants 2 messages May 17, 2023 – May 19, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Ahmed Zaki

author
#0 lore raw

PATCH 1/1 iavf: use internal state to free traffic IRQs

If the system tries to close the netdev while iavf_reset_task() is running, __LINK_STATE_START will be cleared and netif_running() will return false in iavf_reinit_interrupt_scheme(). This will result in iavf_free_traffic_irqs() not being called and a leak as follows:

    [7632.489326] remove_proc_entry: removing non-empty directory 'irq/999', leaking at least 'iavf-enp24s0f0v0-TxRx-0'
    [7632.490214] WARNING: CPU: 0 PID: 10 at fs/proc/generic.c:718 remove_proc_entry+0x19b/0x1b0

is shown when pci_disable_msix() is later called. Fix by using the internal adapter state. The traffic IRQs will always exist if state == __IAVF_RUNNING.

Fixes 5b36e8d04b44 ("i40evf: Enable VF to request an alternate queue allocation")
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +3 -3
index e18d7cacf99c..bf522002dc42 100644
@@ -1943,12 +1943,12 @@ static void iavf_free_rss(struct iavf_adapter *adapter)
  *
  * Returns 0 on success, negative on failure
  **/
-static int iavf_reinit_interrupt_scheme(struct iavf_adapter *adapter)
+static int iavf_reinit_interrupt_scheme(struct iavf_adapter *adapter, bool running)
 {
 	struct net_device *netdev = adapter->netdev;
 	int err;
 
-	if (netif_running(netdev))
+	if (running)
 		iavf_free_traffic_irqs(adapter);
 	iavf_free_misc_irq(adapter);
 	iavf_reset_interrupt_capability(adapter);
@@ -3064,7 +3064,7 @@ static void iavf_reset_task(struct work_struct *work)
 
 	if ((adapter->flags & IAVF_FLAG_REINIT_MSIX_NEEDED) ||
 	    (adapter->flags & IAVF_FLAG_REINIT_ITR_NEEDED)) {
-		err = iavf_reinit_interrupt_scheme(adapter);
+		err = iavf_reinit_interrupt_scheme(adapter, running);
 		if (err)
 			goto reset_err;
 	}
Signature · 6 lines
2.34.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
maintainer
#1 lore raw
Quoted 23 lines · Ahmed Zaki

If the system tries to close the netdev while iavf_reset_task() is running, __LINK_STATE_START will be cleared and netif_running() will return false in iavf_reinit_interrupt_scheme(). This will result in iavf_free_traffic_irqs() not being called and a leak as follows:

     [7632.489326] remove_proc_entry: removing non-empty directory 'irq/999', leaking at least 'iavf-enp24s0f0v0-TxRx-0'
     [7632.490214] WARNING: CPU: 0 PID: 10 at fs/proc/generic.c:718 remove_proc_entry+0x19b/0x1b0

is shown when pci_disable_msix() is later called. Fix by using the internal adapter state. The traffic IRQs will always exist if state == __IAVF_RUNNING.

Fixes 5b36e8d04b44 ("i40evf: Enable VF to request an alternate queue allocation")
---
  drivers/net/ethernet/intel/iavf/iavf_main.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +0 -0
index e18d7cacf99c..bf522002dc42 100644

drivers/net/ethernet/intel/iavf/iavf_main.c static void iavf_free_rss(struct iavf_adapter *adapter) · line 1946

Quoted 5 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +1 -1
@@ -1943,12 +1943,12 @@ static void iavf_free_rss(struct iavf_adapter *adapter)
   *
   * Returns 0 on success, negative on failure
   **/
-static int iavf_reinit_interrupt_scheme(struct iavf_adapter *adapter)
+static int iavf_reinit_interrupt_scheme(struct iavf_adapter *adapter, bool running)

kdoc needs to be updated.

Quoted 10 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +1 -1
  {
  	struct net_device *netdev = adapter->netdev;
  	int err;
 
-	if (netif_running(netdev))
+	if (running)
  		iavf_free_traffic_irqs(adapter);
  	iavf_free_misc_irq(adapter);
  	iavf_reset_interrupt_capability(adapter);

drivers/net/ethernet/intel/iavf/iavf_main.c static void iavf_reset_task(struct work_struct *work) · line 3070

Quoted 8 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +1 -1
@@ -3064,7 +3064,7 @@ static void iavf_reset_task(struct work_struct *work)
 
  	if ((adapter->flags & IAVF_FLAG_REINIT_MSIX_NEEDED) ||
  	    (adapter->flags & IAVF_FLAG_REINIT_ITR_NEEDED)) {
-		err = iavf_reinit_interrupt_scheme(adapter);
+		err = iavf_reinit_interrupt_scheme(adapter, running);
  		if (err)
  			goto reset_err;
  	}

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan