Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp772555ybc; Sat, 16 Nov 2019 08:25:29 -0800 (PST) X-Google-Smtp-Source: APXvYqyvp8LLzMYgBQxmIPgSwzqEOXsjrsM9voZ2/lY1sqMECGo7/6arR6XB1HWaJJ78UP00eXcM X-Received: by 2002:a17:906:fad1:: with SMTP id lu17mr11010335ejb.24.1573921529627; Sat, 16 Nov 2019 08:25:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573921529; cv=none; d=google.com; s=arc-20160816; b=iv/Id4leJt7ooFXXXSDp0KSe7dFL6h74+Un2UOCclchllFUlklblKwtWOVUkju8SzU 1xNhPiwhNF9SHfkpKZjx8RDJuf5DeFqguHs2oXnTwfFjO6oUhqTy1wTPSAI+1RJ7Aey9 w1w8Rdaze7Imsa1FE5kHQ/k9XTsMH2m+xb0nAkd+3puMfN75pugrlBQ3Ay4Q+avHl9pG eKEeMhgsOIELGH3cNBM4YPhprCe9Ov2q5hM5PdqsoCk8WbvkUOZ5ijg4u4i6h/1fzFzA yQEl5BCXm5HQ3ZVsEJDc9y6QP7GWyD+XNh5O+Pzs1eRK0u/foOOSOCRFSjjEGjjHYpHM 3ACQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rgofReuTMJmLMNbS4Y8UWZeD4v5WQJea56Z/SoPUYC8=; b=sKuWCGZZJJw+3ClZ6RXbV0dJFNGjaMYsE485RSGxv/UT3Ou51r0JWD2oqBH1J+ejk9 8aV4tY9ZCQHVHA74DnMoNg54HYr961AKkgxbIFk5MDyQyHjFtahm4ZvAhsrPH0KVDaiT /Utv2PxCjAHyhxN24LCWc37UE/wMpjIHWqG6GRWvIZQeZ7ZgHy7lw3s/JZ8ovhmIN+Pa YvfDvLgTQV0q3Ll9QcCg7hpwM1XG7FUGaw6HdgKMFTmVD55U8A35AGc9uiQpaQ7IF3+Z Z4LVr3TWe5yz7uAE7X7gx+MtoWTMBsc+Rr2Ba2cXlDVUuILZZMjb631/ZSJ486kFGXyr CLGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lugkCPPQ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b7si9345008ede.12.2019.11.16.08.25.05; Sat, 16 Nov 2019 08:25:29 -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=lugkCPPQ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729047AbfKPQVk (ORCPT + 99 others); Sat, 16 Nov 2019 11:21:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:47500 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728750AbfKPPna (ORCPT ); Sat, 16 Nov 2019 10:43:30 -0500 Received: from sasha-vm.mshome.net (unknown [50.234.116.4]) (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 977D32072D; Sat, 16 Nov 2019 15:43:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573919009; bh=9bch6VTDVZgwC2rRZU7Zqnz8hEruZA8tajpvcVynNb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lugkCPPQuZi/h79ebvk+Iy2gYUhyR17jZqbOHyu0ooEC748c7E45A0uNUN6fRxCCr K6cxl5L6a0rl2or2sOzak87uE98iO5LXyx0AG7awloFID0KjmHo0Qenxe1WzVA4E+i q2CPHA5ww2I2XvKVMeKuoTV1Axl8rhSF6oABYkv8= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Masahisa Kojima , Yoshitoyo Osaki , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 113/237] net: socionext: Stop PHY before resetting netsec Date: Sat, 16 Nov 2019 10:39:08 -0500 Message-Id: <20191116154113.7417-113-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116154113.7417-1-sashal@kernel.org> References: <20191116154113.7417-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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