From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08893C43461 for ; Mon, 12 Apr 2021 16:25:52 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9AB4A6135C for ; Mon, 12 Apr 2021 16:25:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9AB4A6135C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=4faf5OOFaZYmD80bekRtqTTjmVHAapmsHHmyn499vUA=; b=a3xfVzhyYE5Wm53Rt0HX2UnJ6 8w6qcFGHVXZlvCd8Tg+e4Meis8VksMMKZc6e6QQWHM9mVHLYqW9zfozLghWW4ZieCNpQhzRJV06qd HyJb5PPfScVTulPU9qjmqBo+ysMI6dlXp9hjct8W4Z/FLmBXRYr56ymq6ENzrZ3fJEv76UQqR7QBC +Baou/5Dow666ZxjzlF7/G2VZyXynjh5mswBiEfVyYmawAZVvtGY+sEBEGQYjFsv+xUNW8CSgz/hc HePACQZjBmdVIRRc5kMqsQeN/Bl+Lmhc19xNJkD0hhfA5p7UJlISnZoSu3yppRaVyKBjv+jH8AT6K SXwBFjlMQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lVzLN-007EdT-Q8; Mon, 12 Apr 2021 16:23:22 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lVzLK-007EdB-Jr for linux-arm-kernel@desiato.infradead.org; Mon, 12 Apr 2021 16:23:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=Oc05rOdPgcwaHT3EtEhtlN7FbJbcdybIXrNbgUol1DU=; b=0MvA5JeIN1+6Ibz0paaDLWTWUe nHqOHYhTAjsgEZu5UvzhkdJRQidCbZqyHGQV6+u88uCPXDpNcf2jKaieheGvS+NVQdWhMBwHLyIuB SEalhCJL5/ScCj2ZT50D08Gk6n5OOPNl+a8ro5Zj/yE4OKwcR8hReMWcAOp2h/RDomKRbIDtrWiwU A4LJMRkFJlpjB50Ms0aHRyEtJhVN6MvunX58UZAlyjwO6Pe6A8FKNo4En8bmFBT3dS7ZNWTftnHvu JldyO2lHn333ebKcj17Tr/OaA2avk8/B+urF4a75qRDwVBELRYOkSEq4YEBzdp0FZt01ASNday+hj WOyiSoEA==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lVzLI-006NzH-3U for linux-arm-kernel@lists.infradead.org; Mon, 12 Apr 2021 16:23:17 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id DE7A861369; Mon, 12 Apr 2021 16:23:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618244595; bh=jEukYEUhaFyVfZevnjU1DgH7B2qU4S3Hom0+Adu5m4w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F75bdx7vTn030UDtk28IeI213k0Wi1VUfrVMBtOcvBvDEco4ZMlO4dlUqIMBrrgfC plHSjkTPK2kJa7PClNxjsLCeB7TmCHQ/AlpN0PjjCLHjv2d/xUGbMQtWBV8Ic55MWK i2aXyiq6s0IG8jM3xCiv8VTDg8s166cfZHgWh6z1RuD/d1eGY9YvSzZhlWcMhp4D4o x3lfZfdIBNpZoEi/S17sLoAejDcyjRY+ejNsrX5AuJ8KpMm6oAJYHNiEUj2ImXX3OB OfR8bW/rEBZRgFqkwMUnmkbWu/Yn0mRirdDtMGvcPUZtqKy8siTVlCuB0pgMCfG+aT SO9bJ7gFUnpiQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Daniel Mack , Radhey Shyam Pandey , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.11 15/51] net: axienet: allow setups without MDIO Date: Mon, 12 Apr 2021 12:22:20 -0400 Message-Id: <20210412162256.313524-15-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210412162256.313524-1-sashal@kernel.org> References: <20210412162256.313524-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210412_092316_208568_FBB73CAC X-CRM114-Status: GOOD ( 12.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Daniel Mack [ Upstream commit de9c7854e6e1589f639c6352112956d08243b659 ] In setups with fixed-link settings there is no mdio node in DTS. axienet_probe() already handles that gracefully but lp->mii_bus is then NULL. Fix code that tries to blindly grab the MDIO lock by introducing two helper functions that make the locking conditional. Signed-off-by: Daniel Mack Reviewed-by: Radhey Shyam Pandey Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/xilinx/xilinx_axienet.h | 12 ++++++++++++ drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 12 ++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet.h b/drivers/net/ethernet/xilinx/xilinx_axienet.h index a03c3ca1b28d..9e2cddba3b5b 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet.h +++ b/drivers/net/ethernet/xilinx/xilinx_axienet.h @@ -497,6 +497,18 @@ static inline u32 axinet_ior_read_mcr(struct axienet_local *lp) return axienet_ior(lp, XAE_MDIO_MCR_OFFSET); } +static inline void axienet_lock_mii(struct axienet_local *lp) +{ + if (lp->mii_bus) + mutex_lock(&lp->mii_bus->mdio_lock); +} + +static inline void axienet_unlock_mii(struct axienet_local *lp) +{ + if (lp->mii_bus) + mutex_unlock(&lp->mii_bus->mdio_lock); +} + /** * axienet_iow - Memory mapped Axi Ethernet register write * @lp: Pointer to axienet local structure diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index 4cd701a9277d..82176dd2cdf3 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -1053,9 +1053,9 @@ static int axienet_open(struct net_device *ndev) * including the MDIO. MDIO must be disabled before resetting. * Hold MDIO bus lock to avoid MDIO accesses during the reset. */ - mutex_lock(&lp->mii_bus->mdio_lock); + axienet_lock_mii(lp); ret = axienet_device_reset(ndev); - mutex_unlock(&lp->mii_bus->mdio_lock); + axienet_unlock_mii(lp); ret = phylink_of_phy_connect(lp->phylink, lp->dev->of_node, 0); if (ret) { @@ -1148,9 +1148,9 @@ static int axienet_stop(struct net_device *ndev) } /* Do a reset to ensure DMA is really stopped */ - mutex_lock(&lp->mii_bus->mdio_lock); + axienet_lock_mii(lp); __axienet_device_reset(lp); - mutex_unlock(&lp->mii_bus->mdio_lock); + axienet_unlock_mii(lp); cancel_work_sync(&lp->dma_err_task); @@ -1664,9 +1664,9 @@ static void axienet_dma_err_handler(struct work_struct *work) * including the MDIO. MDIO must be disabled before resetting. * Hold MDIO bus lock to avoid MDIO accesses during the reset. */ - mutex_lock(&lp->mii_bus->mdio_lock); + axienet_lock_mii(lp); __axienet_device_reset(lp); - mutex_unlock(&lp->mii_bus->mdio_lock); + axienet_unlock_mii(lp); for (i = 0; i < lp->tx_bd_num; i++) { cur_p = &lp->tx_bd_v[i]; -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EF79C43461 for ; Mon, 12 Apr 2021 16:24:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EDA3761288 for ; Mon, 12 Apr 2021 16:24:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243699AbhDLQYM (ORCPT ); Mon, 12 Apr 2021 12:24:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:54936 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243381AbhDLQXd (ORCPT ); Mon, 12 Apr 2021 12:23:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DE7A861369; Mon, 12 Apr 2021 16:23:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618244595; bh=jEukYEUhaFyVfZevnjU1DgH7B2qU4S3Hom0+Adu5m4w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F75bdx7vTn030UDtk28IeI213k0Wi1VUfrVMBtOcvBvDEco4ZMlO4dlUqIMBrrgfC plHSjkTPK2kJa7PClNxjsLCeB7TmCHQ/AlpN0PjjCLHjv2d/xUGbMQtWBV8Ic55MWK i2aXyiq6s0IG8jM3xCiv8VTDg8s166cfZHgWh6z1RuD/d1eGY9YvSzZhlWcMhp4D4o x3lfZfdIBNpZoEi/S17sLoAejDcyjRY+ejNsrX5AuJ8KpMm6oAJYHNiEUj2ImXX3OB OfR8bW/rEBZRgFqkwMUnmkbWu/Yn0mRirdDtMGvcPUZtqKy8siTVlCuB0pgMCfG+aT SO9bJ7gFUnpiQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Daniel Mack , Radhey Shyam Pandey , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.11 15/51] net: axienet: allow setups without MDIO Date: Mon, 12 Apr 2021 12:22:20 -0400 Message-Id: <20210412162256.313524-15-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210412162256.313524-1-sashal@kernel.org> References: <20210412162256.313524-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Daniel Mack [ Upstream commit de9c7854e6e1589f639c6352112956d08243b659 ] In setups with fixed-link settings there is no mdio node in DTS. axienet_probe() already handles that gracefully but lp->mii_bus is then NULL. Fix code that tries to blindly grab the MDIO lock by introducing two helper functions that make the locking conditional. Signed-off-by: Daniel Mack Reviewed-by: Radhey Shyam Pandey Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/xilinx/xilinx_axienet.h | 12 ++++++++++++ drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 12 ++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet.h b/drivers/net/ethernet/xilinx/xilinx_axienet.h index a03c3ca1b28d..9e2cddba3b5b 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet.h +++ b/drivers/net/ethernet/xilinx/xilinx_axienet.h @@ -497,6 +497,18 @@ static inline u32 axinet_ior_read_mcr(struct axienet_local *lp) return axienet_ior(lp, XAE_MDIO_MCR_OFFSET); } +static inline void axienet_lock_mii(struct axienet_local *lp) +{ + if (lp->mii_bus) + mutex_lock(&lp->mii_bus->mdio_lock); +} + +static inline void axienet_unlock_mii(struct axienet_local *lp) +{ + if (lp->mii_bus) + mutex_unlock(&lp->mii_bus->mdio_lock); +} + /** * axienet_iow - Memory mapped Axi Ethernet register write * @lp: Pointer to axienet local structure diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index 4cd701a9277d..82176dd2cdf3 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -1053,9 +1053,9 @@ static int axienet_open(struct net_device *ndev) * including the MDIO. MDIO must be disabled before resetting. * Hold MDIO bus lock to avoid MDIO accesses during the reset. */ - mutex_lock(&lp->mii_bus->mdio_lock); + axienet_lock_mii(lp); ret = axienet_device_reset(ndev); - mutex_unlock(&lp->mii_bus->mdio_lock); + axienet_unlock_mii(lp); ret = phylink_of_phy_connect(lp->phylink, lp->dev->of_node, 0); if (ret) { @@ -1148,9 +1148,9 @@ static int axienet_stop(struct net_device *ndev) } /* Do a reset to ensure DMA is really stopped */ - mutex_lock(&lp->mii_bus->mdio_lock); + axienet_lock_mii(lp); __axienet_device_reset(lp); - mutex_unlock(&lp->mii_bus->mdio_lock); + axienet_unlock_mii(lp); cancel_work_sync(&lp->dma_err_task); @@ -1664,9 +1664,9 @@ static void axienet_dma_err_handler(struct work_struct *work) * including the MDIO. MDIO must be disabled before resetting. * Hold MDIO bus lock to avoid MDIO accesses during the reset. */ - mutex_lock(&lp->mii_bus->mdio_lock); + axienet_lock_mii(lp); __axienet_device_reset(lp); - mutex_unlock(&lp->mii_bus->mdio_lock); + axienet_unlock_mii(lp); for (i = 0; i < lp->tx_bd_num; i++) { cur_p = &lp->tx_bd_v[i]; -- 2.30.2