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 B1CF5C28CC5 for ; Sat, 8 Jun 2019 11:49:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7E2EF21537 for ; Sat, 8 Jun 2019 11:49:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559994551; bh=AD4GRc4EAoNu9rDsMfCIUcUdXChBE37MLd0TH5O79V4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=US6eu08wniCY2lVDDCvqe7yJXSyYxpqY2PkIfWrft2HCZ+Ix+SQUywkCRC2/3v3+q UYzmT2eZylncMGMsVDnxS3gHu3CnxoZ5aTaYOBlQycdoD1p+0lbWfgxme1h/+XVLBG bb7W1gUoYjpfw/8+nTI/Wwi3jm0QGJGq9bvZvhNA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730058AbfFHLtK (ORCPT ); Sat, 8 Jun 2019 07:49:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:37946 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730030AbfFHLtH (ORCPT ); Sat, 8 Jun 2019 07:49:07 -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 7B22A21726; Sat, 8 Jun 2019 11:49:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559994547; bh=AD4GRc4EAoNu9rDsMfCIUcUdXChBE37MLd0TH5O79V4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PQ+FofXCyX2mb3/iZcCySRKzmqP+qYoes9yz8tuZhqwzk4ajobG8k4b1em9RjN1qh KjXdHoV7O3XhObYhsOxZaTY8OH2jUrRKcJKh/L9Nnq3e5Gh9ALaXGI2XvBlKxYvXvV Dj6PlWblATcBhMtZmh79XvdfvYDRr2OVXf4pr7Vk= 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.4 11/13] net: sh_eth: fix mdio access in sh_eth_close() for R-Car Gen2 and RZ/A1 SoCs Date: Sat, 8 Jun 2019 07:48:43 -0400 Message-Id: <20190608114847.9973-11-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190608114847.9973-1-sashal@kernel.org> References: <20190608114847.9973-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 afaf79b8761f..2d9f4ed9a65e 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c @@ -1408,6 +1408,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