From patchwork Tue Oct 23 11:24:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 149438 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp568331ljp; Tue, 23 Oct 2018 04:26:25 -0700 (PDT) X-Google-Smtp-Source: ACcGV61VZGNHQjJca047oWDcEeMJliXhi3g+pYsDy6dGbCgWTSh8lfxeZNQfur49rwZcsf6Apvr+ X-Received: by 2002:a62:2fc1:: with SMTP id v184-v6mr49414829pfv.115.1540293984885; Tue, 23 Oct 2018 04:26:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540293984; cv=none; d=google.com; s=arc-20160816; b=SjiedkXUvfR998UaOB2jG6zzzuwOvUAxpwFmEPSN4R1TWdjspbat5f7KgWO4plGoqK zvyVAcZsiUelSnLIbi0DHj57nt05lmcRUArLklYUBtasXN21gXoZpw28gfnCUkY8rmpP WvEljgaojYlA6pU/E26jME3SVkANZ9QIlIHqtUJLNHZCDgudcfHn/8Tj9LXXJiR0oWSY fGYkPSOf8T1JvWj1UHqtGdYIOJ7VZuHDzOVQRaHepjV5kV4avx/FAjt3Nj+zAijeW9ur 4jHhtUZ8UexvXcUFB8FbWgB0CEt8l2wgcaxFrIe0zypEgFtynn7hPknYzTLtsD/KztmS SpcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=VTrcox16L0L1sYuYwrRItVZKI8otDkkL7OPztax/Ops=; b=HJgLtgW+0Qtk9WxWygUqRcN80GpSb+PRkEDw8o2O/VKAeOgMWnmv/tf0KhEWvIo/mm x5lUV8l0bGLXrmBblKp6HfLfsNNFN3DQbFN4+y3kvG138XxpwAZfMSkxjnKt7TIurYBt eyTMkHYZtqhWILAINkpoSoYqtYlhslEwLPFf6MTotPmkgPAT8dw9eifDimWvr6xDCVZO SQcxmAC2xJG7dZ+FvkAm2nLrtos4HeWUlGfq+U5h14BV9e0gRIEPv6AmGeh17A4MsXxo s++IK2VmtD14LFyZdjpQMa6vdaYErOSwov+FHUVcNzVQCG/fLbgBrxouZsdr1beTFzHP ILhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WXKXuoUD; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j20-v6si1056098pgl.279.2018.10.23.04.26.24; Tue, 23 Oct 2018 04:26:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-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=@linaro.org header.s=google header.b=WXKXuoUD; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728077AbeJWTt0 (ORCPT + 10 others); Tue, 23 Oct 2018 15:49:26 -0400 Received: from mail-yw1-f68.google.com ([209.85.161.68]:34230 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727873AbeJWTt0 (ORCPT ); Tue, 23 Oct 2018 15:49:26 -0400 Received: by mail-yw1-f68.google.com with SMTP id v199-v6so379954ywg.1 for ; Tue, 23 Oct 2018 04:26:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VTrcox16L0L1sYuYwrRItVZKI8otDkkL7OPztax/Ops=; b=WXKXuoUDARaWg254hZi4AQR6NP0eKUZe0A2+gAboo6P5NIU/C6YH8oY3doQ64JZmNY 7D9KsSUAaJEKwq3Y9yUNhWzrAxl0arjtNaXQjYST5fL1gsKmd6sPLP13cOGqHvgWPhsv S8pUg1HZeZvcNQbPMuyIo89athATpEyz6wzf4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VTrcox16L0L1sYuYwrRItVZKI8otDkkL7OPztax/Ops=; b=G7kfT7RMHIkmKx0DYJqS7/DOLijqBlxjYTm7QRRYaWWe0VCaUvitQoVLFQCkPlxbse 1JaMYC8teQqEwgEHBJ7+RlW/oY3AUG2D09VHdywbH9YZZMFzibv53ryBfkIiW3293YFR r4Wo3b/BT6Yfcd60yXUXi2tfhWucq1XdMYUIEPKdIAd4UISagmNRNGqv62xCvi2IcQJy wd17k6711JtNavtCugXEeqib906l9u7ilBvDClkw+zmm7eMqUhMoJrKoK5dEYzTDlJcJ +K3S+Bc+SnJ76ipEqp1ipOQphFZel47wqbDoGZhypBn/zhRgVwo/A2Wu3jN40666Jt0G ezXA== X-Gm-Message-State: ABuFfohS7lxaFkpJO+AY07SGXQZfK4UzIriJq10FMPF+eEY7xerAAZ+n w6+KcOdDz86NiDrWZ5Ul9LSqffLwT7k= X-Received: by 2002:a81:5989:: with SMTP id n131-v6mr10396311ywb.54.1540293982192; Tue, 23 Oct 2018 04:26:22 -0700 (PDT) Received: from localhost ([121.95.100.191]) by smtp.gmail.com with ESMTPSA id j76-v6sm294066ywj.5.2018.10.23.04.26.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Oct 2018 04:26:21 -0700 (PDT) From: masahisa.kojima@linaro.org To: netdev@vger.kernel.org Cc: ilias.apalodimas@linaro.org, jaswinder.singh@linaro.org, ard.biesheuvel@linaro.org, osaki.yoshitoyo@socionext.com, Masahisa Kojima Subject: [PATCH net v2 1/3] net: socionext: Stop PHY before resetting netsec Date: Tue, 23 Oct 2018 20:24:26 +0900 Message-Id: <20181023112428.6785-2-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20181023112428.6785-1-masahisa.kojima@linaro.org> References: <20181023112428.6785-1-masahisa.kojima@linaro.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Masahisa Kojima 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 --- changes in v2: - change the place to perform the PHY power down - use the MACROs defiend in include/uapi/linux/mii.h drivers/net/ethernet/socionext/netsec.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) -- 2.14.2 diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c index 7aa5ebb6766c..829ed2718b22 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; }; @@ -1340,11 +1341,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; @@ -1354,6 +1355,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) @@ -1363,6 +1365,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; @@ -1412,7 +1419,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) { @@ -1420,6 +1427,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"); @@ -1620,12 +1629,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;