Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6019414ybc; Wed, 27 Nov 2019 13:31:14 -0800 (PST) X-Google-Smtp-Source: APXvYqxI+pBZ43QUZzuiY6Tx6XYqjbcq4nj+zfqEml/f7XcE3wlKuxATvY/GoMpEzGFpXEqUIxvV X-Received: by 2002:aa7:d346:: with SMTP id m6mr34998695edr.234.1574890273979; Wed, 27 Nov 2019 13:31:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574890273; cv=none; d=google.com; s=arc-20160816; b=XvsOBAE3xXpY3kZOckVhKLpuEzasNp97x+biBZR9sHP3hci34kfEDWGTxBnBv+7M4M sFBftOb99PL4DKr96XPBiNK+Ioi8fVqG5mLRrI1fjfQpQUHckKkoxTE+b1jMMkeZU7OW O/0kw2afDG+PpeCMomgUE9wSVHhsHLCnxKx0Wz8DOY5XwpMpzyOEwWN+u38KtqHlyTV4 7mR4Cm2ZbS6gLMK//RG4peEjxExh/B1qOeUSHLTptwnXyG/pIfDLl1+xvKwU/CIU9k6h 10FwyFo6rnUImlAHXQM0H3nbA18svkM2qUro8OT8VYN9JtLMFnE8G8nl9QdCpV8AKiPR PbVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rgofReuTMJmLMNbS4Y8UWZeD4v5WQJea56Z/SoPUYC8=; b=VZU02TRSfazSHz8ahlINwSQMAfnH98Vh64JNDaZKgrdOb0L43Iflkq3k7Vi/8fR17f jN7jUukrlHEq30oOwtbp7UQra50msQSoC822KDX/RXU//uIi1cM0ARmyOTD1PrWjPjiS 3rIh0teBktDr/oIXahjSI/vw1QSbmNJGWED4AB+8QCla5LaPJaT7Mopa9BaJFEI6FsmU 2U0S5VAp4TDNUgicqFxRMYLuAnGh7zHLRu0MxYgI8MMIrxdfkrXe+nB4fhtZgxfIzQf3 huByyj40iLMyFxw2uYycf6VqhdYoibTXqUfU+qA4pyWQ4NJcIcOXzudStw9PxDarlXYm BpNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=y4UHGNKB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b96si11560367edf.450.2019.11.27.13.30.50; Wed, 27 Nov 2019 13:31:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=y4UHGNKB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731669AbfK0V0c (ORCPT + 99 others); Wed, 27 Nov 2019 16:26:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:52480 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731578AbfK0VAe (ORCPT ); Wed, 27 Nov 2019 16:00:34 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CE1952154A; Wed, 27 Nov 2019 21:00:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888433; bh=9bch6VTDVZgwC2rRZU7Zqnz8hEruZA8tajpvcVynNb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y4UHGNKBYN4QSNLXnAu+9ngxiJPHhJDwP9ZXxGQBJ0s02I9lQGUYQ5KAghiKDPLW9 M2ARi9PzKmYroTGfbsExF1FLbPwGnRE/dNDA3qYoGlILbL2iOn7GKtIWgenFxXkua8 3AoygjX2MktIE3RcrtITSa+orKl53JfjSfKVbWqY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masahisa Kojima , Yoshitoyo Osaki , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 131/306] net: socionext: Stop PHY before resetting netsec Date: Wed, 27 Nov 2019 21:29:41 +0100 Message-Id: <20191127203124.655538998@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masahisa Kojima [ Upstream commit 8e850f25b5812aefedec6732732eb10e7b47cb5c ] In ndo_stop, driver resets the netsec ethernet controller IP. When the netsec IP is reset, HW running mode turns to NRM mode and driver has to wait until this mode transition completes. But mode transition to NRM will not complete if the PHY is in normal operation state. Netsec IP requires PHY is in power down state when it is reset. This modification stops the PHY before resetting netsec. Together with this modification, phy_addr is stored in netsec_priv structure because ndev->phydev is not yet ready in ndo_init. Fixes: 533dd11a12f6 ("net: socionext: Add Synquacer NetSec driver") Signed-off-by: Masahisa Kojima Signed-off-by: Yoshitoyo Osaki Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/socionext/netsec.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c index d2caeb9edc044..28d582c18afb9 100644 --- a/drivers/net/ethernet/socionext/netsec.c +++ b/drivers/net/ethernet/socionext/netsec.c @@ -274,6 +274,7 @@ struct netsec_priv { struct clk *clk; u32 msg_enable; u32 freq; + u32 phy_addr; bool rx_cksum_offload_flag; }; @@ -1346,11 +1347,11 @@ static int netsec_netdev_stop(struct net_device *ndev) netsec_uninit_pkt_dring(priv, NETSEC_RING_TX); netsec_uninit_pkt_dring(priv, NETSEC_RING_RX); - ret = netsec_reset_hardware(priv, false); - phy_stop(ndev->phydev); phy_disconnect(ndev->phydev); + ret = netsec_reset_hardware(priv, false); + pm_runtime_put_sync(priv->dev); return ret; @@ -1360,6 +1361,7 @@ static int netsec_netdev_init(struct net_device *ndev) { struct netsec_priv *priv = netdev_priv(ndev); int ret; + u16 data; ret = netsec_alloc_dring(priv, NETSEC_RING_TX); if (ret) @@ -1369,6 +1371,11 @@ static int netsec_netdev_init(struct net_device *ndev) if (ret) goto err1; + /* set phy power down */ + data = netsec_phy_read(priv->mii_bus, priv->phy_addr, MII_BMCR) | + BMCR_PDOWN; + netsec_phy_write(priv->mii_bus, priv->phy_addr, MII_BMCR, data); + ret = netsec_reset_hardware(priv, true); if (ret) goto err2; @@ -1418,7 +1425,7 @@ static const struct net_device_ops netsec_netdev_ops = { }; static int netsec_of_probe(struct platform_device *pdev, - struct netsec_priv *priv) + struct netsec_priv *priv, u32 *phy_addr) { priv->phy_np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0); if (!priv->phy_np) { @@ -1426,6 +1433,8 @@ static int netsec_of_probe(struct platform_device *pdev, return -EINVAL; } + *phy_addr = of_mdio_parse_addr(&pdev->dev, priv->phy_np); + priv->clk = devm_clk_get(&pdev->dev, NULL); /* get by 'phy_ref_clk' */ if (IS_ERR(priv->clk)) { dev_err(&pdev->dev, "phy_ref_clk not found\n"); @@ -1626,12 +1635,14 @@ static int netsec_probe(struct platform_device *pdev) } if (dev_of_node(&pdev->dev)) - ret = netsec_of_probe(pdev, priv); + ret = netsec_of_probe(pdev, priv, &phy_addr); else ret = netsec_acpi_probe(pdev, priv, &phy_addr); if (ret) goto free_ndev; + priv->phy_addr = phy_addr; + if (!priv->freq) { dev_err(&pdev->dev, "missing PHY reference clock frequency\n"); ret = -ENODEV; -- 2.20.1