From patchwork Fri Oct 19 01:08:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 986413 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="V+V6Z1hD"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42bnsQ5RZjz9s8F for ; Fri, 19 Oct 2018 12:10:34 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726566AbeJSJOP (ORCPT ); Fri, 19 Oct 2018 05:14:15 -0400 Received: from mail-yb1-f195.google.com ([209.85.219.195]:36247 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726245AbeJSJOP (ORCPT ); Fri, 19 Oct 2018 05:14:15 -0400 Received: by mail-yb1-f195.google.com with SMTP id 5-v6so12645671ybf.3 for ; Thu, 18 Oct 2018 18:10:32 -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=zup1u/FBvCTqA8w/OBz9sjLyaTKGoKh65IYPknttpgs=; b=V+V6Z1hDFT8ARhOl0L+rYMJoEQs7Q7L6hYR99OUysDd6HShy5W/+IjX74jtbWRDfSS J9IDOZXfnNoaiaWXnyozUcbD3Sr/EHfS7ch0zDNXRGas0+8piHYCVy9vHKzVqd1QrIZp +ZVto3gKWxxJ0nnz6ApOdKf77dl0tryt61vCk= 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=zup1u/FBvCTqA8w/OBz9sjLyaTKGoKh65IYPknttpgs=; b=okKlzcJkvFu1JdtnOyfpwALOfLue5t0H9JxOaF+LqZ97CgCS/4Ovm9NoGO7ETiaa9O hYFFZhxBcAzEOApcI+YAoni1dwDB9mWwRKqpRgIYroJVdpuqqtrNzedSN0cLJ+OOIiPe ZQ/iMKkVmw9EM0B9On8K0OA62HOgDPfqpDRhifUUEHRiwK/zp3ElcJwNvm8JAEOczbKF 7Jb89GpnniP5dXwH6VCSP12h5DNoughPcFPNwNAsf2V6zQcpE+/jPj/+ae3J9A1lzyh3 2A+xMXe2oqvvm9e2ELPrXulYg7njKR4nNEcLhmkYaE84g1tMjKFnqGjO3VcB4i+GHMKz od+A== X-Gm-Message-State: ABuFfohlF0Y7nRY9KFyEGf35eEnD12QQUxgg06Ur0qlOfLTLBpEh+URu xMYC/aqZE2mtHkI/jMejsxGP1AcyfUk= X-Google-Smtp-Source: ACcGV61w04szsORy1WgNn0Zq3RB+KCsiqfbTdTjULzUdaif7Dv1i/AD0EIBDj93WUxH9M40keKoarQ== X-Received: by 2002:a25:b88d:: with SMTP id w13-v6mr21581335ybj.213.1539911432088; Thu, 18 Oct 2018 18:10:32 -0700 (PDT) Received: from localhost ([121.95.100.191]) by smtp.gmail.com with ESMTPSA id n186-v6sm7608373ywn.16.2018.10.18.18.10.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 18:10:31 -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 1/3] net: socionext: Stop PHY before resetting netsec Date: Fri, 19 Oct 2018 10:08:41 +0900 Message-Id: <20181019010843.3605-2-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20181019010843.3605-1-masahisa.kojima@linaro.org> References: <20181019010843.3605-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 After resetting netsec IP, driver have to wait until netsec mode turns to NRM mode. But sometimes mode transition to NRM will not complete if the PHY is in normal operation state. To avoid this situation, stop PHY before resetting netsec. Signed-off-by: Masahisa Kojima Signed-off-by: Yoshitoyo Osaki --- drivers/net/ethernet/socionext/netsec.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c index 4289ccb26e4e..273cc5fc07e0 100644 --- a/drivers/net/ethernet/socionext/netsec.c +++ b/drivers/net/ethernet/socionext/netsec.c @@ -1343,11 +1343,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; @@ -1415,7 +1415,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) { @@ -1423,6 +1423,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"); @@ -1473,6 +1475,7 @@ static int netsec_register_mdio(struct netsec_priv *priv, u32 phy_addr) { struct mii_bus *bus; int ret; + u16 data; bus = devm_mdiobus_alloc(priv->dev); if (!bus) @@ -1486,6 +1489,10 @@ static int netsec_register_mdio(struct netsec_priv *priv, u32 phy_addr) bus->parent = priv->dev; priv->mii_bus = bus; + /* set phy power down */ + data = netsec_phy_read(bus, phy_addr, 0) | 0x800; + netsec_phy_write(bus, phy_addr, 0, data); + if (dev_of_node(priv->dev)) { struct device_node *mdio_node, *parent = dev_of_node(priv->dev); @@ -1623,7 +1630,7 @@ 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) From patchwork Fri Oct 19 01:08:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 986414 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="b9p42Az8"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42bnsy2wbPz9sC2 for ; Fri, 19 Oct 2018 12:11:02 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726634AbeJSJOn (ORCPT ); Fri, 19 Oct 2018 05:14:43 -0400 Received: from mail-yw1-f68.google.com ([209.85.161.68]:41902 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726245AbeJSJOn (ORCPT ); Fri, 19 Oct 2018 05:14:43 -0400 Received: by mail-yw1-f68.google.com with SMTP id 135-v6so12574902ywo.8 for ; Thu, 18 Oct 2018 18:10:59 -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=vERzpTd8PFyshf2pm/39BUZZNvqkHOHkVNwWtxqM1k4=; b=b9p42Az8SLZnMrei5M0Z/irgkHo4HigCpgizRZffM97//DBy0PmLb1b85anZfafMca ecxM74uheGMCpJkRHt7L8eK6m0XgogAVzABbRprH4LZgiyCstDQbsuwZ4MlD/yYsmToi Upbf4wXhqoYt5PxHoCQSDGQcIzwPsgvZL3g+w= 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=vERzpTd8PFyshf2pm/39BUZZNvqkHOHkVNwWtxqM1k4=; b=Jl6TYF70OwSg5ATzwrTYuyOMq4IBiUoYnuLzxXes7QumcewYDiw+kSLEzrwbd6KHYR BtTzhP3I3NLv+rtadzbLfn+ulPaIpF4h1IF6nopcliNa1/ShxrmQxYdkdtjLAJwJF9F5 v6d0AqYHZoGiR9Zknoq9mP5KZWUG/M2GWlR0Mo9GG0r1g+dN9174+2zKZ8qlt0N1/wFC hat4HhssBTFoxood+AIoBCOtcfp1c+bgmVaQW3IerLhGSQufyeGDPs5kK84jkUmZRbtE DdLzXTr2K7BKIeXsQlXfWa38APIyXzNvo89pp2z9B4mt8k3I12aOPeAZzWlS6msbdFvI QsIw== X-Gm-Message-State: ABuFfoiRaoquI+3BVQBQZtITc11C3g81BSRIf6rXVcWh2OErn5GStOF5 jNXKZ/Irbpc2AWxS5Gw99FwM9JpomoE= X-Google-Smtp-Source: ACcGV63ubVxpbPFiR5yZ9jySLXkRGQOpBZLxQpWHcpEjvOphP2OnU2jFzmpDZs3Bid62eDj1zTUXHg== X-Received: by 2002:a81:4a55:: with SMTP id x82-v6mr21252592ywa.3.1539911459131; Thu, 18 Oct 2018 18:10:59 -0700 (PDT) Received: from localhost ([121.95.100.191]) by smtp.gmail.com with ESMTPSA id n7-v6sm5481622ywb.8.2018.10.18.18.10.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 18:10:58 -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 2/3] net: socionext: Add dummy PHY register read in phy_write() Date: Fri, 19 Oct 2018 10:08:42 +0900 Message-Id: <20181019010843.3605-3-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20181019010843.3605-1-masahisa.kojima@linaro.org> References: <20181019010843.3605-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 There is a compatibility issue between RTL8211E implemented in Developerbox and netsec network controller IP(F_GMAC4). RTL8211E expects MDC clock must be kept toggling for several clock cycle with MDIO high before entering the IDLE state. To meet this requirement, netsec driver needs to issue dummy read(e.g. read PHYID1(offset 0x2) register) right after write. Signed-off-by: Masahisa Kojima Signed-off-by: Yoshitoyo Osaki --- drivers/net/ethernet/socionext/netsec.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c index 273cc5fc07e0..e7faaf8be99e 100644 --- a/drivers/net/ethernet/socionext/netsec.c +++ b/drivers/net/ethernet/socionext/netsec.c @@ -431,9 +431,12 @@ static int netsec_mac_update_to_phy_state(struct netsec_priv *priv) return 0; } +static int netsec_phy_read(struct mii_bus *bus, int phy_addr, int reg_addr); + static int netsec_phy_write(struct mii_bus *bus, int phy_addr, int reg, u16 val) { + int status; struct netsec_priv *priv = bus->priv; if (netsec_mac_write(priv, GMAC_REG_GDR, val)) @@ -446,8 +449,19 @@ static int netsec_phy_write(struct mii_bus *bus, GMAC_REG_SHIFT_CR_GAR))) return -ETIMEDOUT; - return netsec_mac_wait_while_busy(priv, GMAC_REG_GAR, - NETSEC_GMAC_GAR_REG_GB); + status = netsec_mac_wait_while_busy(priv, GMAC_REG_GAR, + NETSEC_GMAC_GAR_REG_GB); + + /* Developerbox implements RTL8211E PHY and there is + * a compatibility problem with F_GMAC4. + * RTL8211E expects MDC clock must be kept toggling for several + * clock cycle with MDIO high before entering the IDLE state. + * To meet this requirement, netsec driver needs to issue dummy + * read(e.g. read PHYID1(offset 0x2) register) right after write. + */ + netsec_phy_read(bus, phy_addr, 2); + + return status; } static int netsec_phy_read(struct mii_bus *bus, int phy_addr, int reg_addr) From patchwork Fri Oct 19 01:08:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 986415 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="iUfIg/9o"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42bntN3YTSz9sC2 for ; Fri, 19 Oct 2018 12:11:24 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726647AbeJSJPF (ORCPT ); Fri, 19 Oct 2018 05:15:05 -0400 Received: from mail-yw1-f68.google.com ([209.85.161.68]:40587 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726245AbeJSJPF (ORCPT ); Fri, 19 Oct 2018 05:15:05 -0400 Received: by mail-yw1-f68.google.com with SMTP id l79-v6so12581212ywc.7 for ; Thu, 18 Oct 2018 18:11: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=mvsMdqlrZflUMcGarFKUW1cQ+K9e6pvoW52898rH0kU=; b=iUfIg/9oAbi1aeXeSLTrR8n40Yflsjc1TkE1aFsY64WZz+Krw7ALnb4bIzWwOpFdz3 S6PpwvjwjOsOJzfMFB5yf97P15hCuj4QrbBdwgHt9UyluDO66qwpZM2Gl92sGMlOLXtj I9s3BHuV8FLWijHCNuSLTGpOVtOv+EKU7J9dU= 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=mvsMdqlrZflUMcGarFKUW1cQ+K9e6pvoW52898rH0kU=; b=PSQDSPwsiGNTADZ5z7gL7ZAsTet9OGhwuu/vq2pPblnQnSxyXBCNrjme8QwjfpcIHL lrmUSpJZOhpp1PCwSGWW1kUz5evyysFILL9mRCikRko0P44mRhrlaUTpskheVAH9Hctc lVyrUQh6x5l58HHAGfSnJgUEX7wb9kBXEOHakoVFkwkOWpVrwZ+fTJsecSodw+d4HTSJ 3++FbEDXHLLWmRdAm1lx+4Z3lcqkLEwo0iHmTvr01Uacz+lIQUjMT04uFRf4VGmTMf9S dE0pLhpJowKcSIVN7N1K+aH18aeGdgAGhlekSAI72Xt2V03xs+hCyU7NnbkeiUTdYOcr PvKA== X-Gm-Message-State: ABuFfogvhohW6A+kU1tljUiLo8xbLXcbWgGt5DeLB2bW39M3tJvpknQ7 nXzQ/RXvDhTrl9VgMLfadHV8BFI92lk= X-Google-Smtp-Source: ACcGV61pSs7GiUQ3w0BzWGArU9x82VvdTYyr7xhKGvyUGtEdeGWSqQ/1QuKGlUnJRgqI5ZlLQjJd6Q== X-Received: by 2002:a81:7cd:: with SMTP id 196-v6mr19929645ywh.434.1539911482018; Thu, 18 Oct 2018 18:11:22 -0700 (PDT) Received: from localhost ([121.95.100.191]) by smtp.gmail.com with ESMTPSA id n7-v6sm5481918ywb.8.2018.10.18.18.11.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 18:11: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 3/3] net: socionext: Reset tx queue in ndo_stop Date: Fri, 19 Oct 2018 10:08:43 +0900 Message-Id: <20181019010843.3605-4-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20181019010843.3605-1-masahisa.kojima@linaro.org> References: <20181019010843.3605-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 Without resetting tx queue in ndo_stop, packets and bytes count are not reset when the interface is down. Eventually, tx queue is exhausted and packets will not be sent out. Signed-off-by: Masahisa Kojima Signed-off-by: Yoshitoyo Osaki --- drivers/net/ethernet/socionext/netsec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c index e7faaf8be99e..4b32da76d577 100644 --- a/drivers/net/ethernet/socionext/netsec.c +++ b/drivers/net/ethernet/socionext/netsec.c @@ -954,6 +954,9 @@ static void netsec_uninit_pkt_dring(struct netsec_priv *priv, int id) dring->head = 0; dring->tail = 0; dring->pkt_cnt = 0; + + if (id == NETSEC_RING_TX) + netdev_reset_queue(priv->ndev); } static void netsec_free_dring(struct netsec_priv *priv, int id)