Skip to contentSkip to conversation

i40e: Fix kernel oops when i40e driver removes VF's

PATCH In review Eryk Rybak 3 participants 3 messages Feb 18, 2021 – Mar 18, 2021

Subsystems (2)
lore
Share & tools
lore

Eryk Rybak

author
#0 lore raw

PATCH 1/1 i40e: Fix kernel oops when i40e driver removes VF's

Fix the reason of kernel oops when i40e driver removed VFs. Added new __I40E_VFS_RELEASING state to signalize releasing process by PF, that it makes possible to exit of reset VF procedure. Without this patch, it is possible to suspend the VFs reset by releasing VFs resources procedure. Retrying the reset after the timeout works on the freed VF memory causing a kernel oops.

Fixes d43d60e5eb95("i40e: ensure reset occurs when disabling VF")
---
 drivers/net/ethernet/intel/i40e/i40e.h             | 1 +
 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 9 +++++++++
 2 files changed, 10 insertions(+)
drivers/net/ethernet/intel/i40e/i40e.h +1 -0
index 118473d..fe12587 100644
@@ -142,6 +142,7 @@ enum i40e_state_t {
 	__I40E_VIRTCHNL_OP_PENDING,
 	__I40E_RECOVERY_MODE,
 	__I40E_VF_RESETS_DISABLED,	/* disable resets during i40e_remove */
+	__I40E_VFS_RELEASING,
 	/* This must be last as it determines the size of the BITMAP */
 	__I40E_STATE_SIZE__,
 };
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +9 -0
index 1b6ec9b..0c6cbe9 100644
@@ -137,6 +137,7 @@ void i40e_vc_notify_vf_reset(struct i40e_vf *vf)
  **/
 static inline void i40e_vc_disable_vf(struct i40e_vf *vf)
 {
+	struct i40e_pf *pf = vf->pf;
 	int i;
 
 	i40e_vc_notify_vf_reset(vf);
@@ -147,6 +148,11 @@ static inline void i40e_vc_disable_vf(struct i40e_vf *vf)
 	 * ensure a reset.
 	 */
 	for (i = 0; i < 20; i++) {
+		/* If pf is in vfs releasing state reset vf is impossible,
+		 * so leave it.
+		 */
+		if (test_bit(__I40E_VFS_RELEASING, pf->state))
+			return;
 		if (i40e_reset_vf(vf, false))
 			return;
 		usleep_range(10000, 20000);
@@ -1574,6 +1580,8 @@ void i40e_free_vfs(struct i40e_pf *pf)
 
 	if (!pf->vf)
 		return;
+
+	set_bit(__I40E_VFS_RELEASING, pf->state);
 	while (test_and_set_bit(__I40E_VF_DISABLE, pf->state))
 		usleep_range(1000, 2000);
 
@@ -1631,6 +1639,7 @@ void i40e_free_vfs(struct i40e_pf *pf)
 		}
 	}
 	clear_bit(__I40E_VF_DISABLE, pf->state);
+	clear_bit(__I40E_VFS_RELEASING, pf->state);
 }
 
 #ifdef CONFIG_PCI_IOV

base-commit: e4b62cf7559f2ef9a022de235e5a09a8d7ded520

Signature · 1 line
2.20.1
#1 lore raw

[Intel-wired-lan] Incorrect Date: fields with Intel patch submissions (was: [PATCH net] i40e: Fix kernel oops when i40e driver removes VF's)

Dear Eryk, dear Intel folks,

It?s now the happened again, that Intel patches have timestamps from the future, messing up the ordering for people sorting their inbox according to the date.

I mentioned it several times, but it keeps happening. Could you please get to the bottom of that problem in your infrastructure and fix it?

Kind regards,

Paul

#2 lore raw

PATCH 1/1 i40e: Fix kernel oops when i40e driver removes VF's

In reply to Eryk Rybak
Quoted 78 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Eryk Rybak
Sent: czwartek, 18 lutego 2021 12:15
To: intel-wired-lan at lists.osuosl.org
Cc: Rybak, Eryk Roch <[email protected]>; Loktionov, Aleksandr <[email protected]>
Subject: [Intel-wired-lan] [PATCH net] i40e: Fix kernel oops when i40e driver removes VF's

Fix the reason of kernel oops when i40e driver removed VFs. Added new __I40E_VFS_RELEASING state to signalize releasing process by PF, that it makes possible to exit of reset VF procedure. Without this patch, it is possible to suspend the VFs reset by releasing VFs resources procedure. Retrying the reset after the timeout works on the freed VF memory causing a kernel oops.

Fixes d43d60e5eb95("i40e: ensure reset occurs when disabling VF")
---
 drivers/net/ethernet/intel/i40e/i40e.h             | 1 +
 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 9 +++++++++
 2 files changed, 10 insertions(+)
drivers/net/ethernet/intel/i40e/i40e.h +1 -0
index 118473d..fe12587 100644
@@ -142,6 +142,7 @@ enum i40e_state_t {
 	__I40E_VIRTCHNL_OP_PENDING,
 	__I40E_RECOVERY_MODE,
 	__I40E_VF_RESETS_DISABLED,	/* disable resets during i40e_remove
 */
+	__I40E_VFS_RELEASING,
 	/* This must be last as it determines the size of the BITMAP */
 	__I40E_STATE_SIZE__,

};

drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +6 -0
index 1b6ec9b..0c6cbe9 100644
@@ -137,6 +137,7 @@ void i40e_vc_notify_vf_reset(struct i40e_vf *vf)
  **/
 static inline void i40e_vc_disable_vf(struct i40e_vf *vf)  {
+	struct i40e_pf *pf = vf->pf;
 	int i;
 
 	i40e_vc_notify_vf_reset(vf);
@@ -147,6 +148,11 @@ static inline void i40e_vc_disable_vf(struct i40e_vf
 *vf)
 	 * ensure a reset.
 	 */
 	for (i = 0; i < 20; i++) {
+		/* If pf is in vfs releasing state reset vf is impossible,
+		 * so leave it.
+		 */
+		if (test_bit(__I40E_VFS_RELEASING, pf->state))
+			return;
 		if (i40e_reset_vf(vf, false))
 			return;
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +2 -0
 		usleep_range(10000, 20000);
@@ -1574,6 +1580,8 @@ void i40e_free_vfs(struct i40e_pf *pf)
 
 	if (!pf->vf)
 		return;
+
+	set_bit(__I40E_VFS_RELEASING, pf->state);
 	while (test_and_set_bit(__I40E_VF_DISABLE, pf->state))
 		usleep_range(1000, 2000);
 

drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c void i40e_free_vfs(struct i40e_pf *pf) · line 1645

Quoted 7 lines
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +1 -0
@@ -1631,6 +1639,7 @@ void i40e_free_vfs(struct i40e_pf *pf)
 		}
 	}
 	clear_bit(__I40E_VF_DISABLE, pf->state);
+	clear_bit(__I40E_VFS_RELEASING, pf->state);
 }
 
 #ifdef CONFIG_PCI_IOV