Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2536442pxb; Mon, 19 Apr 2021 07:59:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxx+VpQ7FjWXIeF8bIK1Q/3rXt/xaGWvK2YQzVEvrf+4rD7zbAHW8V2xAP3PyEmNRv8FNGG X-Received: by 2002:a17:90a:2e85:: with SMTP id r5mr25650319pjd.190.1618844370608; Mon, 19 Apr 2021 07:59:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618844370; cv=none; d=google.com; s=arc-20160816; b=neJishI4j+HXBhM4JUcQTjmOCf3leTYR3dtJBOvARJn+ev8ef6n+tcKWw9opa3KVig avIzP8gseUVLT8tRSo+iZr2pZQYCK+U3IKISOvhC7mOvqZuEKkxgBawmVsOYOoMpJNTs i0ohFbJWJywEDIvjw9FIkLXiIHzohNc1VRuIuwfGEpWYBxklu2m7niSEhTWWkIV5QNuJ vOxqlW8dLN9fvLbqCoI3N5OKEcl+Xo7pUho8A9h95MBBuWxPftRIb97VmSExPyX7dt/D pzeawt7r0RAWA3si4v2+17HRZTWuerfb26gVu/LkslXM+6/zLaVVFnfq4aj7GoyxGywK +CkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Oc05rOdPgcwaHT3EtEhtlN7FbJbcdybIXrNbgUol1DU=; b=VkG4AMSAHMbZ/Q87/JNj8++JMHs85+Lamqnp7/HMPf2zpCjEETBFdNG9tQtqkng1sP aj7Q10wa1yW9QGqKVq0tcM8L1bsAsrho5gXewyKfHgVccj2Rh8mdK1IpKxh4K/e6Zmam pXiNFX2+2BMeq8aTW7xR5x0hwJ/neDtH+tR8o9RdI9p6eR8i7OUKA9MTDpQ89/dLXD4R qY5N+KfMlR3qAECVNuu1NM4wVZpVfhvQkGtnte8a8i3wRxpp7zSdsskQNTHO/Abr+7+X T7yJEawPUj/UaGDeNhaKGvLa5CxdJ7xm0huoiMFNuvqZa2n2kbfh6SRfCr8/036dkNGZ vfuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KM143fiQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e8si691363plj.133.2021.04.19.07.59.18; Mon, 19 Apr 2021 07:59:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KM143fiQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239675AbhDSNKe (ORCPT + 99 others); Mon, 19 Apr 2021 09:10:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:44618 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239698AbhDSNJr (ORCPT ); Mon, 19 Apr 2021 09:09:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6666961245; Mon, 19 Apr 2021 13:09:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618837757; bh=jEukYEUhaFyVfZevnjU1DgH7B2qU4S3Hom0+Adu5m4w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KM143fiQsf02Svz69i9XoXbTnOlDbITdd85F/871+C8UiASJripp5GQzBhjNrn6H7 cLAiWkscOOjOBdDpnsEn7SYO5BWV+DsnaJr0JyoE3QAoU4ccdhZ8kAhG/U2QBR5W0m g8Y32pq9I3nxf56OA8xim6IxPXsqhy/n/ouffsfc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Mack , Radhey Shyam Pandey , "David S. Miller" , Sasha Levin Subject: [PATCH 5.11 026/122] net: axienet: allow setups without MDIO Date: Mon, 19 Apr 2021 15:05:06 +0200 Message-Id: <20210419130531.056140591@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210419130530.166331793@linuxfoundation.org> References: <20210419130530.166331793@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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