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=-9.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,T_DKIMWL_WL_HIGH,URIBL_BLOCKED,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 6FB83C468BC for ; Sat, 8 Jun 2019 11:50:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3B82621537 for ; Sat, 8 Jun 2019 11:50:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559994618; bh=Pqmy6eY/Cs5qNb5DoLTJDOCL4cixWFnepxFhdTLRHhk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=cqiUISprSPT3XjqLhPmt9PPxTgTsd+9iujsnZNfujIMItDbAKhADgR0Kdo2///IRT NWfyFrsth73kspBI57jy+2nVUgSw6mEMu0oaS64s0CypWe8Z2qIfp3Ct3cmUlIb3c2 yYUiaPWa0D53xgMWgfM8strt5STDQr+rH0nfPB6w= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729760AbfFHLsl (ORCPT ); Sat, 8 Jun 2019 07:48:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:37402 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728745AbfFHLsi (ORCPT ); Sat, 8 Jun 2019 07:48:38 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C14872168B; Sat, 8 Jun 2019 11:48:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559994517; bh=Pqmy6eY/Cs5qNb5DoLTJDOCL4cixWFnepxFhdTLRHhk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=naQtO5IxF74oqWuD+Gcer24KmMPq0iEN7psGkUtETtDMuZlP2K5M/rPLap9KEYErX qmAgFMWgxJQ/0KyLTeFyCxkM1Dy3dPjGO6eg13mLF1k8DzjEf6LWnAxc9tZVdruXh8 KE4RqsZT86iqWNpExJYe4/X6pU1OJx0K+O2Jwti0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Yoshihiro Shimoda , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 16/20] net: sh_eth: fix mdio access in sh_eth_close() for R-Car Gen2 and RZ/A1 SoCs Date: Sat, 8 Jun 2019 07:47:52 -0400 Message-Id: <20190608114756.9742-16-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190608114756.9742-1-sashal@kernel.org> References: <20190608114756.9742-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Yoshihiro Shimoda [ Upstream commit 315ca92dd863fecbffc0bb52ae0ac11e0398726a ] The sh_eth_close() resets the MAC and then calls phy_stop() so that mdio read access result is incorrect without any error according to kernel trace like below: ifconfig-216 [003] .n.. 109.133124: mdio_access: ee700000.ethernet-ffffffff read phy:0x01 reg:0x00 val:0xffff According to the hardware manual, the RMII mode should be set to 1 before operation the Ethernet MAC. However, the previous code was not set to 1 after the driver issued the soft_reset in sh_eth_dev_exit() so that the mdio read access result seemed incorrect. To fix the issue, this patch adds a condition and set the RMII mode register in sh_eth_dev_exit() for R-Car Gen2 and RZ/A1 SoCs. Note that when I have tried to move the sh_eth_dev_exit() calling after phy_stop() on sh_eth_close(), but it gets worse (kernel panic happened and it seems that a register is accessed while the clock is off). Signed-off-by: Yoshihiro Shimoda Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/renesas/sh_eth.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index c59e8fe37069..49300194d3f9 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c @@ -1388,6 +1388,10 @@ static void sh_eth_dev_exit(struct net_device *ndev) sh_eth_get_stats(ndev); sh_eth_reset(ndev); + /* Set the RMII mode again if required */ + if (mdp->cd->rmiimode) + sh_eth_write(ndev, 0x1, RMIIMODE); + /* Set MAC address again */ update_mac_address(ndev); } -- 2.20.1