[dpdk-stable] patch 'net/bnx2x: fix to add PHY lock' has been queued to LTS release 16.11.9

Luca Boccassi bluca at debian.org
Mon Oct 15 13:51:33 CEST 2018


Hi,

FYI, your patch has been queued to LTS release 16.11.9

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 10/17/18. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the patch applied
to the branch. If the code is different (ie: not only metadata diffs), due for example to
a change in context or macro names, please double check it.

Thanks.

Luca Boccassi

---
>From f82658ea867b14c69abdfb7c72a380352f8633cd Mon Sep 17 00:00:00 2001
From: Rasesh Mody <rasesh.mody at cavium.com>
Date: Sat, 29 Sep 2018 05:42:41 +0000
Subject: [PATCH] net/bnx2x: fix to add PHY lock

[ upstream commit a9b58b15ed5186fae34fe20faf74be339632bebc ]

This patch adds phy_lock, acquire/release the lock when performing
PHY transactions. Without this fix driver can run into synchronization
issues with management FW when modifying PHY settings.

Fixes: 540a211084a7 ("bnx2x: driver core")

Signed-off-by: Rasesh Mody <rasesh.mody at cavium.com>
---
 drivers/net/bnx2x/bnx2x.c     | 59 ++++++++++++++++++++++++++++++-----
 drivers/net/bnx2x/bnx2x.h     |  7 +++++
 drivers/net/bnx2x/ecore_reg.h |  1 +
 3 files changed, 60 insertions(+), 7 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x.c b/drivers/net/bnx2x/bnx2x.c
index 167b046ea9..92abdbbd49 100644
--- a/drivers/net/bnx2x/bnx2x.c
+++ b/drivers/net/bnx2x/bnx2x.c
@@ -114,6 +114,7 @@ static void bnx2x_pf_disable(struct bnx2x_softc *sc);
 static void bnx2x_update_rx_prod(struct bnx2x_softc *sc,
 				 struct bnx2x_fastpath *fp,
 				 uint16_t rx_bd_prod, uint16_t rx_cq_prod);
+static void bnx2x_link_report_locked(struct bnx2x_softc *sc);
 static void bnx2x_link_report(struct bnx2x_softc *sc);
 void bnx2x_link_status_update(struct bnx2x_softc *sc);
 static int bnx2x_alloc_mem(struct bnx2x_softc *sc);
@@ -201,7 +202,8 @@ static int bnx2x_acquire_hw_lock(struct bnx2x_softc *sc, uint32_t resource)
 	uint32_t hw_lock_control_reg;
 	int cnt;
 
-	PMD_INIT_FUNC_TRACE(sc);
+	if (resource)
+		PMD_INIT_FUNC_TRACE(sc);
 
 	/* validate the resource is within range */
 	if (resource > HW_LOCK_MAX_RESOURCE_VALUE) {
@@ -237,7 +239,8 @@ static int bnx2x_acquire_hw_lock(struct bnx2x_softc *sc, uint32_t resource)
 		DELAY(5000);
 	}
 
-	PMD_DRV_LOG(NOTICE, sc, "Resource lock timeout!");
+	PMD_DRV_LOG(NOTICE, sc, "Resource 0x%x resource_bit 0x%x lock timeout!",
+		    resource, resource_bit);
 	return -1;
 }
 
@@ -248,13 +251,14 @@ static int bnx2x_release_hw_lock(struct bnx2x_softc *sc, uint32_t resource)
 	int func = SC_FUNC(sc);
 	uint32_t hw_lock_control_reg;
 
-	PMD_INIT_FUNC_TRACE(sc);
+	if (resource)
+		PMD_INIT_FUNC_TRACE(sc);
 
 	/* validate the resource is within range */
 	if (resource > HW_LOCK_MAX_RESOURCE_VALUE) {
 		PMD_DRV_LOG(NOTICE, sc,
-			    "resource 0x%x > HW_LOCK_MAX_RESOURCE_VALUE",
-			    resource);
+			    "(resource 0x%x > HW_LOCK_MAX_RESOURCE_VALUE)"
+			    " resource_bit 0x%x", resource, resource_bit);
 		return -1;
 	}
 
@@ -278,6 +282,18 @@ static int bnx2x_release_hw_lock(struct bnx2x_softc *sc, uint32_t resource)
 	return 0;
 }
 
+static void bnx2x_acquire_phy_lock(struct bnx2x_softc *sc)
+{
+	BNX2X_PHY_LOCK(sc);
+	bnx2x_acquire_hw_lock(sc, HW_LOCK_RESOURCE_MDIO);
+}
+
+static void bnx2x_release_phy_lock(struct bnx2x_softc *sc)
+{
+	bnx2x_release_hw_lock(sc, HW_LOCK_RESOURCE_MDIO);
+	BNX2X_PHY_UNLOCK(sc);
+}
+
 /* copy command into DMAE command memory and set DMAE command Go */
 void bnx2x_post_dmae(struct bnx2x_softc *sc, struct dmae_command *dmae, int idx)
 {
@@ -2911,7 +2927,7 @@ static void bnx2x_link_attn(struct bnx2x_softc *sc)
 		}
 	}
 
-	bnx2x_link_report(sc);
+	bnx2x_link_report_locked(sc);
 
 	if (IS_MF(sc)) {
 		bnx2x_link_sync_notify(sc);
@@ -2950,6 +2966,7 @@ static void bnx2x_attn_int_asserted(struct bnx2x_softc *sc, uint32_t asserted)
 	if (asserted & ATTN_HARD_WIRED_MASK) {
 		if (asserted & ATTN_NIG_FOR_FUNC) {
 
+			bnx2x_acquire_phy_lock(sc);
 			/* save nig interrupt mask */
 			nig_mask = REG_RD(sc, nig_int_mask_addr);
 
@@ -3047,6 +3064,7 @@ static void bnx2x_attn_int_asserted(struct bnx2x_softc *sc, uint32_t asserted)
 
 		REG_WR(sc, nig_int_mask_addr, nig_mask);
 
+		bnx2x_release_phy_lock(sc);
 	}
 }
 
@@ -3846,8 +3864,10 @@ static void bnx2x_attn_int_deasserted3(struct bnx2x_softc *sc, uint32_t attn)
 			if (sc->link_vars.periodic_flags &
 			    ELINK_PERIODIC_FLAGS_LINK_EVENT) {
 				/* sync with link */
+				bnx2x_acquire_phy_lock(sc);
 				sc->link_vars.periodic_flags &=
 				    ~ELINK_PERIODIC_FLAGS_LINK_EVENT;
+				bnx2x_release_phy_lock(sc);
 				if (IS_MF(sc)) {
 					bnx2x_link_sync_notify(sc);
 				}
@@ -4037,7 +4057,9 @@ static void bnx2x_attn_int_deasserted0(struct bnx2x_softc *sc, uint32_t attn)
 	}
 
 	if ((attn & sc->link_vars.aeu_int_mask) && sc->port.pmf) {
+		bnx2x_acquire_phy_lock(sc);
 		elink_handle_module_detect_int(&sc->link_params);
+		bnx2x_release_phy_lock(sc);
 	}
 
 	if (attn & HW_INTERRUT_ASSERT_SET_0) {
@@ -6875,7 +6897,7 @@ bnx2x_fill_report_data(struct bnx2x_softc *sc, struct bnx2x_link_report_data *da
 }
 
 /* report link status to OS, should be called under phy_lock */
-static void bnx2x_link_report(struct bnx2x_softc *sc)
+static void bnx2x_link_report_locked(struct bnx2x_softc *sc)
 {
 	struct bnx2x_link_report_data cur_data;
 
@@ -6896,8 +6918,13 @@ static void bnx2x_link_report(struct bnx2x_softc *sc)
 		return;
 	}
 
+	PMD_DRV_LOG(INFO, sc, "Change in link status : cur_data = %lx, last_reported_link = %lx\n",
+		    cur_data.link_report_flags,
+		    sc->last_reported_link.link_report_flags);
+
 	sc->link_cnt++;
 
+	PMD_DRV_LOG(INFO, sc, "link status change count = %x\n", sc->link_cnt);
 	/* report new link params and remember the state for the next time */
 	(void)rte_memcpy(&sc->last_reported_link, &cur_data, sizeof(cur_data));
 
@@ -6949,6 +6976,14 @@ static void bnx2x_link_report(struct bnx2x_softc *sc)
 	}
 }
 
+static void
+bnx2x_link_report(struct bnx2x_softc *sc)
+{
+	bnx2x_acquire_phy_lock(sc);
+	bnx2x_link_report_locked(sc);
+	bnx2x_release_phy_lock(sc);
+}
+
 void bnx2x_link_status_update(struct bnx2x_softc *sc)
 {
 	if (sc->state != BNX2X_STATE_OPEN) {
@@ -7037,6 +7072,8 @@ static int bnx2x_initial_phy_init(struct bnx2x_softc *sc, int load_mode)
 
 	bnx2x_set_requested_fc(sc);
 
+	bnx2x_acquire_phy_lock(sc);
+
 	if (load_mode == LOAD_DIAG) {
 		lp->loopback_mode = ELINK_LOOPBACK_XGXS;
 /* Prefer doing PHY loopback at 10G speed, if possible */
@@ -7056,6 +7093,8 @@ static int bnx2x_initial_phy_init(struct bnx2x_softc *sc, int load_mode)
 
 	rc = elink_phy_init(&sc->link_params, &sc->link_vars);
 
+	bnx2x_release_phy_lock(sc);
+
 	bnx2x_calc_fc_adv(sc);
 
 	if (sc->link_vars.link_up) {
@@ -7110,7 +7149,9 @@ void bnx2x_periodic_callout(struct bnx2x_softc *sc)
  */
 		mb();
 		if (sc->port.pmf) {
+			bnx2x_acquire_phy_lock(sc);
 			elink_period_func(&sc->link_params, &sc->link_vars);
+			bnx2x_release_phy_lock(sc);
 		}
 	}
 #ifdef BNX2X_PULSE
@@ -9864,8 +9905,10 @@ static void bnx2x_common_init_phy(struct bnx2x_softc *sc)
 		shmem2_base[1] = SHMEM2_RD(sc, other_shmem2_base_addr);
 	}
 
+	bnx2x_acquire_phy_lock(sc);
 	elink_common_init_phy(sc, shmem_base, shmem2_base,
 			      sc->devinfo.chip_id, 0);
+	bnx2x_release_phy_lock(sc);
 }
 
 static void bnx2x_pf_disable(struct bnx2x_softc *sc)
@@ -11344,7 +11387,9 @@ static int bnx2x_init_hw_func(struct bnx2x_softc *sc)
 static void bnx2x_link_reset(struct bnx2x_softc *sc)
 {
 	if (!BNX2X_NOMCP(sc)) {
+		bnx2x_acquire_phy_lock(sc);
 		elink_lfa_reset(&sc->link_params, &sc->link_vars);
+		bnx2x_release_phy_lock(sc);
 	} else {
 		if (!CHIP_REV_IS_SLOW(sc)) {
 			PMD_DRV_LOG(WARNING, sc,
diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h
index ca7d1920b3..5dfd2f8e47 100644
--- a/drivers/net/bnx2x/bnx2x.h
+++ b/drivers/net/bnx2x/bnx2x.h
@@ -725,6 +725,13 @@ struct bnx2x_port {
 
     uint32_t    phy_addr;
 
+	/* Used to synchronize phy accesses. */
+	rte_spinlock_t	phy_mtx;
+	char		phy_mtx_name[32];
+
+#define BNX2X_PHY_LOCK(sc)          rte_spinlock_lock(&sc->port.phy_mtx)
+#define BNX2X_PHY_UNLOCK(sc)        rte_spinlock_unlock(&sc->port.phy_mtx)
+
     /*
      * MCP scratchpad address for port specific statistics.
      * The device is responsible for writing statistcss
diff --git a/drivers/net/bnx2x/ecore_reg.h b/drivers/net/bnx2x/ecore_reg.h
index d8203b453d..33cea4eb9a 100644
--- a/drivers/net/bnx2x/ecore_reg.h
+++ b/drivers/net/bnx2x/ecore_reg.h
@@ -1969,6 +1969,7 @@
 #define HW_LOCK_MAX_RESOURCE_VALUE		 31
 #define HW_LOCK_RESOURCE_DRV_FLAGS		 10
 #define HW_LOCK_RESOURCE_GPIO			 1
+#define HW_LOCK_RESOURCE_MDIO			 0
 #define HW_LOCK_RESOURCE_NVRAM			 12
 #define HW_LOCK_RESOURCE_PORT0_ATT_MASK		 3
 #define HW_LOCK_RESOURCE_RECOVERY_LEADER_0	 8
-- 
2.19.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2018-10-15 12:48:34.949727686 +0100
+++ 0013-net-bnx2x-fix-to-add-PHY-lock.patch	2018-10-15 12:48:34.573096016 +0100
@@ -1,14 +1,15 @@
-From a9b58b15ed5186fae34fe20faf74be339632bebc Mon Sep 17 00:00:00 2001
+From f82658ea867b14c69abdfb7c72a380352f8633cd Mon Sep 17 00:00:00 2001
 From: Rasesh Mody <rasesh.mody at cavium.com>
 Date: Sat, 29 Sep 2018 05:42:41 +0000
 Subject: [PATCH] net/bnx2x: fix to add PHY lock
 
+[ upstream commit a9b58b15ed5186fae34fe20faf74be339632bebc ]
+
 This patch adds phy_lock, acquire/release the lock when performing
 PHY transactions. Without this fix driver can run into synchronization
 issues with management FW when modifying PHY settings.
 
 Fixes: 540a211084a7 ("bnx2x: driver core")
-Cc: stable at dpdk.org
 
 Signed-off-by: Rasesh Mody <rasesh.mody at cavium.com>
 ---
@@ -18,10 +19,10 @@
  3 files changed, 60 insertions(+), 7 deletions(-)
 
 diff --git a/drivers/net/bnx2x/bnx2x.c b/drivers/net/bnx2x/bnx2x.c
-index 0225bea9ae..279759366a 100644
+index 167b046ea9..92abdbbd49 100644
 --- a/drivers/net/bnx2x/bnx2x.c
 +++ b/drivers/net/bnx2x/bnx2x.c
-@@ -112,6 +112,7 @@ static void bnx2x_pf_disable(struct bnx2x_softc *sc);
+@@ -114,6 +114,7 @@ static void bnx2x_pf_disable(struct bnx2x_softc *sc);
  static void bnx2x_update_rx_prod(struct bnx2x_softc *sc,
  				 struct bnx2x_fastpath *fp,
  				 uint16_t rx_bd_prod, uint16_t rx_cq_prod);
@@ -29,7 +30,7 @@
  static void bnx2x_link_report(struct bnx2x_softc *sc);
  void bnx2x_link_status_update(struct bnx2x_softc *sc);
  static int bnx2x_alloc_mem(struct bnx2x_softc *sc);
-@@ -198,7 +199,8 @@ static int bnx2x_acquire_hw_lock(struct bnx2x_softc *sc, uint32_t resource)
+@@ -201,7 +202,8 @@ static int bnx2x_acquire_hw_lock(struct bnx2x_softc *sc, uint32_t resource)
  	uint32_t hw_lock_control_reg;
  	int cnt;
  
@@ -39,7 +40,7 @@
  
  	/* validate the resource is within range */
  	if (resource > HW_LOCK_MAX_RESOURCE_VALUE) {
-@@ -234,7 +236,8 @@ static int bnx2x_acquire_hw_lock(struct bnx2x_softc *sc, uint32_t resource)
+@@ -237,7 +239,8 @@ static int bnx2x_acquire_hw_lock(struct bnx2x_softc *sc, uint32_t resource)
  		DELAY(5000);
  	}
  
@@ -49,7 +50,7 @@
  	return -1;
  }
  
-@@ -245,13 +248,14 @@ static int bnx2x_release_hw_lock(struct bnx2x_softc *sc, uint32_t resource)
+@@ -248,13 +251,14 @@ static int bnx2x_release_hw_lock(struct bnx2x_softc *sc, uint32_t resource)
  	int func = SC_FUNC(sc);
  	uint32_t hw_lock_control_reg;
  
@@ -67,7 +68,7 @@
  		return -1;
  	}
  
-@@ -275,6 +279,18 @@ static int bnx2x_release_hw_lock(struct bnx2x_softc *sc, uint32_t resource)
+@@ -278,6 +282,18 @@ static int bnx2x_release_hw_lock(struct bnx2x_softc *sc, uint32_t resource)
  	return 0;
  }
  
@@ -86,7 +87,7 @@
  /* copy command into DMAE command memory and set DMAE command Go */
  void bnx2x_post_dmae(struct bnx2x_softc *sc, struct dmae_command *dmae, int idx)
  {
-@@ -2903,7 +2919,7 @@ static void bnx2x_link_attn(struct bnx2x_softc *sc)
+@@ -2911,7 +2927,7 @@ static void bnx2x_link_attn(struct bnx2x_softc *sc)
  		}
  	}
  
@@ -95,7 +96,7 @@
  
  	if (IS_MF(sc)) {
  		bnx2x_link_sync_notify(sc);
-@@ -2942,6 +2958,7 @@ static void bnx2x_attn_int_asserted(struct bnx2x_softc *sc, uint32_t asserted)
+@@ -2950,6 +2966,7 @@ static void bnx2x_attn_int_asserted(struct bnx2x_softc *sc, uint32_t asserted)
  	if (asserted & ATTN_HARD_WIRED_MASK) {
  		if (asserted & ATTN_NIG_FOR_FUNC) {
  
@@ -103,7 +104,7 @@
  			/* save nig interrupt mask */
  			nig_mask = REG_RD(sc, nig_int_mask_addr);
  
-@@ -3039,6 +3056,7 @@ static void bnx2x_attn_int_asserted(struct bnx2x_softc *sc, uint32_t asserted)
+@@ -3047,6 +3064,7 @@ static void bnx2x_attn_int_asserted(struct bnx2x_softc *sc, uint32_t asserted)
  
  		REG_WR(sc, nig_int_mask_addr, nig_mask);
  
@@ -111,7 +112,7 @@
  	}
  }
  
-@@ -3838,8 +3856,10 @@ static void bnx2x_attn_int_deasserted3(struct bnx2x_softc *sc, uint32_t attn)
+@@ -3846,8 +3864,10 @@ static void bnx2x_attn_int_deasserted3(struct bnx2x_softc *sc, uint32_t attn)
  			if (sc->link_vars.periodic_flags &
  			    ELINK_PERIODIC_FLAGS_LINK_EVENT) {
  				/* sync with link */
@@ -122,7 +123,7 @@
  				if (IS_MF(sc)) {
  					bnx2x_link_sync_notify(sc);
  				}
-@@ -4029,7 +4049,9 @@ static void bnx2x_attn_int_deasserted0(struct bnx2x_softc *sc, uint32_t attn)
+@@ -4037,7 +4057,9 @@ static void bnx2x_attn_int_deasserted0(struct bnx2x_softc *sc, uint32_t attn)
  	}
  
  	if ((attn & sc->link_vars.aeu_int_mask) && sc->port.pmf) {
@@ -132,7 +133,7 @@
  	}
  
  	if (attn & HW_INTERRUT_ASSERT_SET_0) {
-@@ -6867,7 +6889,7 @@ bnx2x_fill_report_data(struct bnx2x_softc *sc, struct bnx2x_link_report_data *da
+@@ -6875,7 +6897,7 @@ bnx2x_fill_report_data(struct bnx2x_softc *sc, struct bnx2x_link_report_data *da
  }
  
  /* report link status to OS, should be called under phy_lock */
@@ -141,7 +142,7 @@
  {
  	struct bnx2x_link_report_data cur_data;
  
-@@ -6888,8 +6910,13 @@ static void bnx2x_link_report(struct bnx2x_softc *sc)
+@@ -6896,8 +6918,13 @@ static void bnx2x_link_report(struct bnx2x_softc *sc)
  		return;
  	}
  
@@ -153,9 +154,9 @@
  
 +	PMD_DRV_LOG(INFO, sc, "link status change count = %x\n", sc->link_cnt);
  	/* report new link params and remember the state for the next time */
- 	rte_memcpy(&sc->last_reported_link, &cur_data, sizeof(cur_data));
+ 	(void)rte_memcpy(&sc->last_reported_link, &cur_data, sizeof(cur_data));
  
-@@ -6941,6 +6968,14 @@ static void bnx2x_link_report(struct bnx2x_softc *sc)
+@@ -6949,6 +6976,14 @@ static void bnx2x_link_report(struct bnx2x_softc *sc)
  	}
  }
  
@@ -170,7 +171,7 @@
  void bnx2x_link_status_update(struct bnx2x_softc *sc)
  {
  	if (sc->state != BNX2X_STATE_OPEN) {
-@@ -7019,6 +7054,8 @@ static int bnx2x_initial_phy_init(struct bnx2x_softc *sc, int load_mode)
+@@ -7037,6 +7072,8 @@ static int bnx2x_initial_phy_init(struct bnx2x_softc *sc, int load_mode)
  
  	bnx2x_set_requested_fc(sc);
  
@@ -179,7 +180,7 @@
  	if (load_mode == LOAD_DIAG) {
  		lp->loopback_mode = ELINK_LOOPBACK_XGXS;
  /* Prefer doing PHY loopback at 10G speed, if possible */
-@@ -7038,6 +7075,8 @@ static int bnx2x_initial_phy_init(struct bnx2x_softc *sc, int load_mode)
+@@ -7056,6 +7093,8 @@ static int bnx2x_initial_phy_init(struct bnx2x_softc *sc, int load_mode)
  
  	rc = elink_phy_init(&sc->link_params, &sc->link_vars);
  
@@ -188,7 +189,7 @@
  	bnx2x_calc_fc_adv(sc);
  
  	if (sc->link_vars.link_up) {
-@@ -7088,7 +7127,9 @@ void bnx2x_periodic_callout(struct bnx2x_softc *sc)
+@@ -7110,7 +7149,9 @@ void bnx2x_periodic_callout(struct bnx2x_softc *sc)
   */
  		mb();
  		if (sc->port.pmf) {
@@ -198,7 +199,7 @@
  		}
  	}
  #ifdef BNX2X_PULSE
-@@ -9840,8 +9881,10 @@ static void bnx2x_common_init_phy(struct bnx2x_softc *sc)
+@@ -9864,8 +9905,10 @@ static void bnx2x_common_init_phy(struct bnx2x_softc *sc)
  		shmem2_base[1] = SHMEM2_RD(sc, other_shmem2_base_addr);
  	}
  
@@ -209,7 +210,7 @@
  }
  
  static void bnx2x_pf_disable(struct bnx2x_softc *sc)
-@@ -11320,7 +11363,9 @@ static int bnx2x_init_hw_func(struct bnx2x_softc *sc)
+@@ -11344,7 +11387,9 @@ static int bnx2x_init_hw_func(struct bnx2x_softc *sc)
  static void bnx2x_link_reset(struct bnx2x_softc *sc)
  {
  	if (!BNX2X_NOMCP(sc)) {
@@ -220,7 +221,7 @@
  		if (!CHIP_REV_IS_SLOW(sc)) {
  			PMD_DRV_LOG(WARNING, sc,
 diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h
-index 1cc5a6b42c..74780725b9 100644
+index ca7d1920b3..5dfd2f8e47 100644
 --- a/drivers/net/bnx2x/bnx2x.h
 +++ b/drivers/net/bnx2x/bnx2x.h
 @@ -725,6 +725,13 @@ struct bnx2x_port {
@@ -238,10 +239,10 @@
       * MCP scratchpad address for port specific statistics.
       * The device is responsible for writing statistcss
 diff --git a/drivers/net/bnx2x/ecore_reg.h b/drivers/net/bnx2x/ecore_reg.h
-index ae8a93bb49..d69e857bf7 100644
+index d8203b453d..33cea4eb9a 100644
 --- a/drivers/net/bnx2x/ecore_reg.h
 +++ b/drivers/net/bnx2x/ecore_reg.h
-@@ -1967,6 +1967,7 @@
+@@ -1969,6 +1969,7 @@
  #define HW_LOCK_MAX_RESOURCE_VALUE		 31
  #define HW_LOCK_RESOURCE_DRV_FLAGS		 10
  #define HW_LOCK_RESOURCE_GPIO			 1


More information about the stable mailing list