net/ixgbe: fix probability of obtaining mailbox lock failure

Message ID 20210831084051.6300-1-chenqiming_huawei@163.com (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers
Series net/ixgbe: fix probability of obtaining mailbox lock failure |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot: build success github build: passed
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/intel-Testing fail Testing issues
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing fail Testing issues

Commit Message

Qiming Chen Aug. 31, 2021, 8:40 a.m. UTC
  Ifconfig pf port up/down, after several times, the dpdk vf driver may fail
to obtain the mailbox lock, resulting in configuration failure and
functional failure. In order to increase the reliability of mailbox
communication, the patch uses a trial strategy.

Fixes: abf7275bbaa2 ("ixgbe: move to drivers/net/")
Cc: stable@dpdk.org

Signed-off-by: Qiming Chen <chenqiming_huawei@163.com>
---
 drivers/net/ixgbe/base/ixgbe_mbx.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
  

Comments

Wang, Haiyue Sept. 6, 2021, 1:48 a.m. UTC | #1
> -----Original Message-----
> From: Qiming Chen <chenqiming_huawei@163.com>
> Sent: Tuesday, August 31, 2021 16:41
> To: dev@dpdk.org
> Cc: Wang, Haiyue <haiyue.wang@intel.com>; Qiming Chen <chenqiming_huawei@163.com>; stable@dpdk.org
> Subject: [PATCH] net/ixgbe: fix probability of obtaining mailbox lock failure
> 
> Ifconfig pf port up/down, after several times, the dpdk vf driver may fail
> to obtain the mailbox lock, resulting in configuration failure and
> functional failure. In order to increase the reliability of mailbox
> communication, the patch uses a trial strategy.
> 
> Fixes: abf7275bbaa2 ("ixgbe: move to drivers/net/")

Should be
 Fixes: af75078fece3 ("first public release")

> Cc: stable@dpdk.org
> 
> Signed-off-by: Qiming Chen <chenqiming_huawei@163.com>
> ---
>  drivers/net/ixgbe/base/ixgbe_mbx.c | 18 +++++++++++++-----
>  1 file changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ixgbe/base/ixgbe_mbx.c b/drivers/net/ixgbe/base/ixgbe_mbx.c
> index 4dddff2c58..5a14fcc7b4 100644
> --- a/drivers/net/ixgbe/base/ixgbe_mbx.c
> +++ b/drivers/net/ixgbe/base/ixgbe_mbx.c
> @@ -370,15 +370,23 @@ STATIC s32 ixgbe_check_for_rst_vf(struct ixgbe_hw *hw, u16 mbx_id)
>  STATIC s32 ixgbe_obtain_mbx_lock_vf(struct ixgbe_hw *hw)
>  {
>  	s32 ret_val = IXGBE_ERR_MBX;
> +	s32 timeout = hw->mbx.timeout;
> +	s32 usec = hw->mbx.usec_delay;
> 
>  	DEBUGFUNC("ixgbe_obtain_mbx_lock_vf");
> 
> -	/* Take ownership of the buffer */
> -	IXGBE_WRITE_REG(hw, IXGBE_VFMAILBOX, IXGBE_VFMAILBOX_VFU);
> +	do {
> +		/* Take ownership of the buffer */
> +		IXGBE_WRITE_REG(hw, IXGBE_VFMAILBOX, IXGBE_VFMAILBOX_VFU);
> 
> -	/* reserve mailbox for vf use */
> -	if (ixgbe_read_v2p_mailbox(hw) & IXGBE_VFMAILBOX_VFU)
> -		ret_val = IXGBE_SUCCESS;
> +		/* reserve mailbox for vf use */
> +		if (ixgbe_read_v2p_mailbox(hw) & IXGBE_VFMAILBOX_VFU) {
> +			ret_val = IXGBE_SUCCESS;
> +			break;
> +		}
> +
> +		usec_delay(usec);
> +	} while (timeout--);
> 
>  	return ret_val;
>  }
> --
> 2.30.1.windows.1
  

Patch

diff --git a/drivers/net/ixgbe/base/ixgbe_mbx.c b/drivers/net/ixgbe/base/ixgbe_mbx.c
index 4dddff2c58..5a14fcc7b4 100644
--- a/drivers/net/ixgbe/base/ixgbe_mbx.c
+++ b/drivers/net/ixgbe/base/ixgbe_mbx.c
@@ -370,15 +370,23 @@  STATIC s32 ixgbe_check_for_rst_vf(struct ixgbe_hw *hw, u16 mbx_id)
 STATIC s32 ixgbe_obtain_mbx_lock_vf(struct ixgbe_hw *hw)
 {
 	s32 ret_val = IXGBE_ERR_MBX;
+	s32 timeout = hw->mbx.timeout;
+	s32 usec = hw->mbx.usec_delay;
 
 	DEBUGFUNC("ixgbe_obtain_mbx_lock_vf");
 
-	/* Take ownership of the buffer */
-	IXGBE_WRITE_REG(hw, IXGBE_VFMAILBOX, IXGBE_VFMAILBOX_VFU);
+	do {
+		/* Take ownership of the buffer */
+		IXGBE_WRITE_REG(hw, IXGBE_VFMAILBOX, IXGBE_VFMAILBOX_VFU);
 
-	/* reserve mailbox for vf use */
-	if (ixgbe_read_v2p_mailbox(hw) & IXGBE_VFMAILBOX_VFU)
-		ret_val = IXGBE_SUCCESS;
+		/* reserve mailbox for vf use */
+		if (ixgbe_read_v2p_mailbox(hw) & IXGBE_VFMAILBOX_VFU) {
+			ret_val = IXGBE_SUCCESS;
+			break;
+		}
+
+		usec_delay(usec);
+	} while (timeout--);
 
 	return ret_val;
 }