patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Kevin Traynor <ktraynor@redhat.com>
To: Rasesh Mody <rasesh.mody@cavium.com>
Cc: dpdk stable <stable@dpdk.org>
Subject: [dpdk-stable] patch 'net/bnx2x: fix to add PHY lock' has been queued to stable release 18.08.1
Date: Wed, 21 Nov 2018 16:47:45 +0000	[thread overview]
Message-ID: <20181121164828.32249-31-ktraynor@redhat.com> (raw)
In-Reply-To: <20181121164828.32249-1-ktraynor@redhat.com>

Hi,

FYI, your patch has been queued to stable release 18.08.1

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 11/27/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.

Kevin Traynor

---
>From 0844b13ca42515d9c03ac665b9d4463329255872 Mon Sep 17 00:00:00 2001
From: Rasesh Mody <rasesh.mody@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@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 0225bea9a..279759366 100644
--- a/drivers/net/bnx2x/bnx2x.c
+++ b/drivers/net/bnx2x/bnx2x.c
@@ -113,4 +113,5 @@ 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);
@@ -199,5 +200,6 @@ static int bnx2x_acquire_hw_lock(struct bnx2x_softc *sc, uint32_t resource)
 	int cnt;
 
-	PMD_INIT_FUNC_TRACE(sc);
+	if (resource)
+		PMD_INIT_FUNC_TRACE(sc);
 
 	/* validate the resource is within range */
@@ -235,5 +237,6 @@ static int bnx2x_acquire_hw_lock(struct bnx2x_softc *sc, uint32_t resource)
 	}
 
-	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;
 }
@@ -246,11 +249,12 @@ static int bnx2x_release_hw_lock(struct bnx2x_softc *sc, uint32_t resource)
 	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;
 	}
@@ -276,4 +280,16 @@ static int bnx2x_release_hw_lock(struct bnx2x_softc *sc, uint32_t resource)
 }
 
+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)
@@ -2904,5 +2920,5 @@ static void bnx2x_link_attn(struct bnx2x_softc *sc)
 	}
 
-	bnx2x_link_report(sc);
+	bnx2x_link_report_locked(sc);
 
 	if (IS_MF(sc)) {
@@ -2943,4 +2959,5 @@ static void bnx2x_attn_int_asserted(struct bnx2x_softc *sc, uint32_t asserted)
 		if (asserted & ATTN_NIG_FOR_FUNC) {
 
+			bnx2x_acquire_phy_lock(sc);
 			/* save nig interrupt mask */
 			nig_mask = REG_RD(sc, nig_int_mask_addr);
@@ -3040,4 +3057,5 @@ 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);
 	}
 }
@@ -3839,6 +3857,8 @@ static void bnx2x_attn_int_deasserted3(struct bnx2x_softc *sc, uint32_t attn)
 			    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);
@@ -4030,5 +4050,7 @@ 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);
 	}
 
@@ -6868,5 +6890,5 @@ 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;
@@ -6889,6 +6911,11 @@ static void bnx2x_link_report(struct bnx2x_softc *sc)
 	}
 
+	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 */
 	rte_memcpy(&sc->last_reported_link, &cur_data, sizeof(cur_data));
@@ -6942,4 +6969,12 @@ 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)
 {
@@ -7020,4 +7055,6 @@ 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;
@@ -7039,4 +7076,6 @@ 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);
 
@@ -7089,5 +7128,7 @@ 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);
 		}
 	}
@@ -9841,6 +9882,8 @@ static void bnx2x_common_init_phy(struct bnx2x_softc *sc)
 	}
 
+	bnx2x_acquire_phy_lock(sc);
 	elink_common_init_phy(sc, shmem_base, shmem2_base,
 			      sc->devinfo.chip_id, 0);
+	bnx2x_release_phy_lock(sc);
 }
 
@@ -11321,5 +11364,7 @@ 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)) {
diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h
index 2d545f514..a51fd79d4 100644
--- a/drivers/net/bnx2x/bnx2x.h
+++ b/drivers/net/bnx2x/bnx2x.h
@@ -726,4 +726,11 @@ 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.
diff --git a/drivers/net/bnx2x/ecore_reg.h b/drivers/net/bnx2x/ecore_reg.h
index ae8a93bb4..d69e857bf 100644
--- a/drivers/net/bnx2x/ecore_reg.h
+++ b/drivers/net/bnx2x/ecore_reg.h
@@ -1968,4 +1968,5 @@
 #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
-- 
2.19.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2018-11-21 16:44:31.799930978 +0000
+++ 0031-net-bnx2x-fix-to-add-PHY-lock.patch	2018-11-21 16:44:30.000000000 +0000
@@ -1,14 +1,15 @@
-From a9b58b15ed5186fae34fe20faf74be339632bebc Mon Sep 17 00:00:00 2001
+From 0844b13ca42515d9c03ac665b9d4463329255872 Mon Sep 17 00:00:00 2001
 From: Rasesh Mody <rasesh.mody@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@dpdk.org
 
 Signed-off-by: Rasesh Mody <rasesh.mody@cavium.com>
 ---
@@ -184,7 +185,7 @@
  	} else {
  		if (!CHIP_REV_IS_SLOW(sc)) {
 diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h
-index 1cc5a6b42..74780725b 100644
+index 2d545f514..a51fd79d4 100644
 --- a/drivers/net/bnx2x/bnx2x.h
 +++ b/drivers/net/bnx2x/bnx2x.h
 @@ -726,4 +726,11 @@ struct bnx2x_port {

  parent reply	other threads:[~2018-11-21 16:50 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-21 16:47 [dpdk-stable] patch 'doc: fix eventdev shared library version' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'event/dpaa2: fix mbuf assignment in atomic processing' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'eventdev: fix eth Rx adapter hotplug incompatibility' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'test/event: remove eth Rx adapter vdev workaround' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'event/sw: fix cq index check for unlink usecases' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'test/event: check burst mode capability' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'test/event: fix build for timer adapter' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'test/event: fix RSS config for eth Rx " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'app/eventdev: fix minor typos' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'test/event: fix eth Rx adapter test for skeleton PMD' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'test/event: fix Rx adapter intr " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'mem: fix undefined behavior in NUMA-aware mapping' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'mem: fix --huge-unlink option' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'igb_uio: fix refcount if open returns error' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'net/i40e: fix send admin queue command before init' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'net/i40e/base: fix partition id calculation for X722' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'net/i40e/base: improve the polling mechanism' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'net/i40e/base: read LLDP config area with correct endianness' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'net/i40e/base: properly clean resources' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'net/i40e/base: gracefully clean the " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'net/i40e/base: correct global reset timeout calculation' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'net/ixgbe: wait longer for link after fiber MAC setup' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'net/enic: do not use non-standard integer types' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'net/enic: set Rx VLAN offload flag for non-stripped packets' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'net/enic: explicitly disable overlay offload' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'net/failsafe: report actual device capabilities' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'net/nfp: fix RSS' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'net/bnx2x: fix logging to include device name' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'net/bnx2x: fix to disable further interrupts' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'net/bnx2x: fix call to link handling periodic function' " Kevin Traynor
2018-11-21 16:47 ` Kevin Traynor [this message]
2018-11-21 16:47 ` [dpdk-stable] patch 'net/enic: fix flow API memory leak' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'net/bnxt: get rid of ff pools and use VNIC info array' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'net/bnxt: fix uninitialized pointer access in Tx' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'net/bnxt: fix MTU setting' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'net/bnxt: fix registration of VF async event completion ring' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'net/bnxt: set MAC filtering as outer for non tunnel frames' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'net/bnxt: set a VNIC as default only once' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'net/bnxt: set VLAN strip mode before default VNIC cfg' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'net/bnxt: remove excess log messages' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'net/bnxt: reduce polling interval for valid bit' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'app/testpmd: check Rx VLAN offload flag to print VLAN TCI' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'app/testpmd: fix csum parse-tunnel command invocation' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'doc: fix typos in the flow API guide' " Kevin Traynor
2018-11-21 16:47 ` [dpdk-stable] patch 'net/sfc: receive prepared packets even in Rx exception case' " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'mbuf: fix Tx offload mask' " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'net/mlx5: fix representor port link status' " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'net/mlx5: fix representor port xstats' " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'net/mlx4: support externally allocated static memory' " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'net/mlx5: " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'app/testpmd: fix displaying RSS hash functions' " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'doc: clarify L3 Tx checksum prerequisite' " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'doc: clarify L4 " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'net/failsafe: use prefix for function' " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'net/mlx5: fix errno values for flow engine' " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'doc: add VFIO in ENA guide' " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'drivers/net: fix log type string' " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'app/testpmd: fix printf format in event callback' " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'app/testpmd: fix duplicate exit' " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'net/mlx5: support missing counter in extended statistics' " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'net/mlx5: add representor specific " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'net/mlx5: always use representor ifindex for ioctl' " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'net/e1000: do not error out if Rx drop enable is set' " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'net/ifc: fix address translation function name' " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'net/sfc: do not skip RSS configuration step on reconfigure' " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'net/sfc: allow to query RSS key and HF in isolated mode' " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'net/sfc: allow to query RSS key and HF when RSS is disabled' " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'eal: use correct data type for bitmap slab operations' " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'app/testpmd: fix metering and policing commands' " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'examples/ip_pipeline: fix IPv6 endianness' " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'net/softnic: " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'bus/fslmc: fix physical addressing check' " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'net/dpaa2: fix IOVA conversion for congestion memory' " Kevin Traynor
2018-11-21 16:48 ` [dpdk-stable] patch 'net/dpaa2: fix VLAN filter enablement' " Kevin Traynor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181121164828.32249-31-ktraynor@redhat.com \
    --to=ktraynor@redhat.com \
    --cc=rasesh.mody@cavium.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).