From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-eopbgr780072.outbound.protection.outlook.com [40.107.78.72]) by dpdk.org (Postfix) with ESMTP id 2B08C1B61F for ; Wed, 19 Dec 2018 01:43:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6wDS3gCFUHJHjmn7wRdtEPcrLtKlccFRTEMzXEUW+6w=; b=YYQIN+RRwCMnjLNEPXo+D49GJ/Hs+GXYrY9jYaxK3Ti7oFVsWEWpuJ1A6z9pxK6P5NPoQFFoJyzvmtb1WroJnJFHODc3m5kbD7Zx4/+2fE7Qv3ox3WaWw/D2YGQs0Oc4xmvzSvDVZNxCdmK3NLw01gaUl+/uNeJiCfNPx4h2QXg= Received: from BYAPR07MB5365.namprd07.prod.outlook.com (20.177.125.18) by BYAPR07MB4792.namprd07.prod.outlook.com (52.135.205.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1425.18; Wed, 19 Dec 2018 00:43:49 +0000 Received: from BYAPR07MB5365.namprd07.prod.outlook.com ([fe80::514:ce1d:4236:9b9]) by BYAPR07MB5365.namprd07.prod.outlook.com ([fe80::514:ce1d:4236:9b9%3]) with mapi id 15.20.1425.021; Wed, 19 Dec 2018 00:43:48 +0000 From: "Mody, Rasesh" To: "stable@dpdk.org" CC: "Mody, Rasesh" , "yskoh@mellanox.com" , Dept-Eng DPDK Dev Thread-Topic: [PATCH 17.11 2/3] net/bnx2x: fix to add PHY lock Thread-Index: AQHUlzPn2l6L0JhClk+KTNua3+z2ug== Date: Wed, 19 Dec 2018 00:43:48 +0000 Message-ID: <1545180208-3622-2-git-send-email-rasesh.mody@cavium.com> References: <1545180208-3622-1-git-send-email-rasesh.mody@cavium.com> In-Reply-To: <1545180208-3622-1-git-send-email-rasesh.mody@cavium.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR01CA0017.prod.exchangelabs.com (2603:10b6:a02:80::30) To BYAPR07MB5365.namprd07.prod.outlook.com (2603:10b6:a03:64::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Rasesh.Mody@cavium.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [198.186.1.5] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BYAPR07MB4792; 6:hPKlnQa3XhsD4KDOP4JOgCyoThR+/i8ZjuHYgpvoMAYv8mKRNKQOLvUHHhSYI/BeXX06vlwd8Bty6OoGFW17hOCD4SIkALp8xgPBlkI1SpszsdtaBN0Vi99/+9kcxDfGeS8EPVwGvQeYcDuUcgEfVpqFOl/7NtauvpYyGgZqsorf8gIkztiEN8zG02b+O4ge44HS3iYNmVv9INXw/auvnlGT6ce0zo/K02adKC1mhZ0kZfPUrYNeWFcyNeqgcLlh6shapc7QTHwYXiGLHeLgk6hHdwV07XCuRW3gY5R6IRDa/IQN1NL9ta3pbTsPPTkooteDmz5vrsxDgfFY3HeIfR4cZymWkl64eo8ukz++NrqpzHf83pjkHZxVkqZ9Y3AbMlof4fdmsTW8JHMgabb3Rk9Q3R1YyKHa4S9akkU8DXJjLFHbHBCpCHM5Yypy1XLmzKzgu22KheeeRfibsQeIkw==; 5:zR8qHSE6x1o96tNEhNzAKAm5GzPCPYlZCAvcFOPE6x8yL6s7r035KBk9+3sAoQIstD1oiDxGnVGCsSe6npa9sgDXsbqXqbaaGtW+h1UEnDmGldzM5SBw37u6EFls87A63TmcBjmoxz8NPIdBAZUGagK46GNzGlchTiyvvbPyhBg=; 7:HjRs99TJp/pG7Kv3sBMyNd257hI/hzb1+Kn+yPJFD9lZQXoqY+L0odWaOl1v0y1j4fLl5eGCm+5wHyPf/8SU+wELgDSw1ujdD7ERwtpG/7oynzP9tZfUuS/THQqnzHKsQT6pXPl7Aqz5S4RkriyyGw== x-ms-office365-filtering-correlation-id: 99af1910-960e-42c3-2ae3-08d6654b0a03 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BYAPR07MB4792; x-ms-traffictypediagnostic: BYAPR07MB4792: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(6040522)(2401047)(8121501046)(5005006)(823302103)(93006095)(93001095)(3231475)(944501520)(52105112)(10201501046)(3002001)(148016)(149066)(150057)(6041310)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:BYAPR07MB4792; BCL:0; PCL:0; RULEID:; SRVR:BYAPR07MB4792; x-forefront-prvs: 0891BC3F3D x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(1496009)(396003)(366004)(346002)(376002)(39860400002)(136003)(199004)(189003)(99286004)(54906003)(72206003)(2616005)(81156014)(316002)(86362001)(386003)(2351001)(102836004)(76176011)(6116002)(6916009)(8936002)(6506007)(3846002)(305945005)(7736002)(2906002)(81166006)(1730700003)(8676002)(26005)(52116002)(105586002)(106356001)(71190400001)(186003)(71200400001)(486006)(11346002)(446003)(6486002)(6512007)(6436002)(14444005)(5660300001)(53936002)(256004)(4326008)(68736007)(66066001)(107886003)(5640700003)(2501003)(36756003)(478600001)(25786009)(476003)(14454004)(97736004); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR07MB4792; H:BYAPR07MB5365.namprd07.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: nOIAFdX+5bKoNEDIraS/Eg3HBlgx3Jn7jjgbSohAQde6yIPXDGTTa7ByRp6PEoVgqp4SJYdCcpGsc5Gk/AhRF73mfUKdphaxWkmo0lNkxIsS2Ni8Yvu8lxGXkK37GavNN4R1E3KAQ2D06DVN6VsyOWqzmfq5axydp1ENRAvkVcZhDStEw0VLkdAmhu9OZaxixCO5olMUPQ9gXbNQVp+b0Zk/+JxY0aEa81qpXhRyDtnJTcJQNFIv6C5Y1hAnQE2lzcmtSr+j9qh5Am5TRdPcKTvejS2snqgGSmPgVcOC0eERBhJufO3cibAQ299161EG spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-Network-Message-Id: 99af1910-960e-42c3-2ae3-08d6654b0a03 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2018 00:43:48.8342 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR07MB4792 Subject: [dpdk-stable] [PATCH 17.11 2/3] net/bnx2x: fix to add PHY lock X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Dec 2018 00:43:50 -0000 [ 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 --- 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 48ccd31..fb748a1 100644 --- a/drivers/net/bnx2x/bnx2x.c +++ b/drivers/net/bnx2x/bnx2x.c @@ -116,6 +116,7 @@ static uint8_t bnx2x_chk_parity_attn(struct bnx2x_softc= *sc, uint8_t * global, 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); @@ -202,7 +203,8 @@ static int bnx2x_acquire_hw_lock(struct bnx2x_softc *sc= , uint32_t resource) uint32_t hw_lock_control_reg; int cnt; =20 - PMD_INIT_FUNC_TRACE(sc); + if (resource) + PMD_INIT_FUNC_TRACE(sc); =20 /* validate the resource is within range */ if (resource > HW_LOCK_MAX_RESOURCE_VALUE) { @@ -238,7 +240,8 @@ static int bnx2x_acquire_hw_lock(struct bnx2x_softc *sc= , uint32_t resource) DELAY(5000); } =20 - 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; } =20 @@ -249,13 +252,14 @@ static int bnx2x_release_hw_lock(struct bnx2x_softc *= sc, uint32_t resource) int func =3D SC_FUNC(sc); uint32_t hw_lock_control_reg; =20 - PMD_INIT_FUNC_TRACE(sc); + if (resource) + PMD_INIT_FUNC_TRACE(sc); =20 /* 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; } =20 @@ -279,6 +283,18 @@ static int bnx2x_release_hw_lock(struct bnx2x_softc *s= c, uint32_t resource) return 0; } =20 +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, in= t idx) { @@ -2909,7 +2925,7 @@ static void bnx2x_link_attn(struct bnx2x_softc *sc) } } =20 - bnx2x_link_report(sc); + bnx2x_link_report_locked(sc); =20 if (IS_MF(sc)) { bnx2x_link_sync_notify(sc); @@ -2948,6 +2964,7 @@ static void bnx2x_attn_int_asserted(struct bnx2x_soft= c *sc, uint32_t asserted) if (asserted & ATTN_HARD_WIRED_MASK) { if (asserted & ATTN_NIG_FOR_FUNC) { =20 + bnx2x_acquire_phy_lock(sc); /* save nig interrupt mask */ nig_mask =3D REG_RD(sc, nig_int_mask_addr); =20 @@ -3045,6 +3062,7 @@ static void bnx2x_attn_int_asserted(struct bnx2x_soft= c *sc, uint32_t asserted) =20 REG_WR(sc, nig_int_mask_addr, nig_mask); =20 + bnx2x_release_phy_lock(sc); } } =20 @@ -3844,8 +3862,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 &=3D ~ELINK_PERIODIC_FLAGS_LINK_EVENT; + bnx2x_release_phy_lock(sc); if (IS_MF(sc)) { bnx2x_link_sync_notify(sc); } @@ -4035,7 +4055,9 @@ static void bnx2x_attn_int_deasserted0(struct bnx2x_s= oftc *sc, uint32_t attn) } =20 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); } =20 if (attn & HW_INTERRUT_ASSERT_SET_0) { @@ -6873,7 +6895,7 @@ static uint16_t bnx2x_get_mf_speed(struct bnx2x_softc= *sc) } =20 /* 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; =20 @@ -6894,8 +6916,13 @@ static void bnx2x_link_report(struct bnx2x_softc *sc= ) return; } =20 + PMD_DRV_LOG(INFO, sc, "Change in link status : cur_data =3D %lx, last_rep= orted_link =3D %lx\n", + cur_data.link_report_flags, + sc->last_reported_link.link_report_flags); + sc->link_cnt++; =20 + PMD_DRV_LOG(INFO, sc, "link status change count =3D %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)); =20 @@ -6947,6 +6974,14 @@ static void bnx2x_link_report(struct bnx2x_softc *sc= ) } } =20 +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 !=3D BNX2X_STATE_OPEN) { @@ -7025,6 +7060,8 @@ static int bnx2x_initial_phy_init(struct bnx2x_softc = *sc, int load_mode) =20 bnx2x_set_requested_fc(sc); =20 + bnx2x_acquire_phy_lock(sc); + if (load_mode =3D=3D LOAD_DIAG) { lp->loopback_mode =3D ELINK_LOOPBACK_XGXS; /* Prefer doing PHY loopback at 10G speed, if possible */ @@ -7044,6 +7081,8 @@ static int bnx2x_initial_phy_init(struct bnx2x_softc = *sc, int load_mode) =20 rc =3D elink_phy_init(&sc->link_params, &sc->link_vars); =20 + bnx2x_release_phy_lock(sc); + bnx2x_calc_fc_adv(sc); =20 if (sc->link_vars.link_up) { @@ -7094,7 +7133,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 @@ -9848,8 +9889,10 @@ static void bnx2x_common_init_phy(struct bnx2x_softc= *sc) shmem2_base[1] =3D SHMEM2_RD(sc, other_shmem2_base_addr); } =20 + bnx2x_acquire_phy_lock(sc); elink_common_init_phy(sc, shmem_base, shmem2_base, sc->devinfo.chip_id, 0); + bnx2x_release_phy_lock(sc); } =20 static void bnx2x_pf_disable(struct bnx2x_softc *sc) @@ -11328,7 +11371,9 @@ static int bnx2x_init_hw_func(struct bnx2x_softc *s= c) 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 33d75a5..2843702 100644 --- a/drivers/net/bnx2x/bnx2x.h +++ b/drivers/net/bnx2x/bnx2x.h @@ -727,6 +727,13 @@ struct bnx2x_port { =20 uint32_t phy_addr; =20 + /* 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 d8203b4..33cea4e 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 --=20 1.7.10.3