From patchwork Mon Apr 16 07:39:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jassi Brar X-Patchwork-Id: 133440 Delivered-To: patch@linaro.org Received: by 10.46.84.18 with SMTP id i18csp3278691ljb; Mon, 16 Apr 2018 00:40:17 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+cuSCztvO61OdITeXoty1y3TdvJcfNPUfAKAo0pHWeSSAVnglCDuKusO6RlefKSGqDj8jL X-Received: by 10.101.98.196 with SMTP id m4mr11963931pgv.329.1523864417746; Mon, 16 Apr 2018 00:40:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523864417; cv=none; d=google.com; s=arc-20160816; b=GsjGW9hHJGx+n5cf01QMhH6v3ZlDfTEvB561EfN/bNu5qhjPcA1IGRIkTzw3KcUr1f /bfp2E/tbmsP8E0i573uqHwn2pRj2AweImxDox9G0v4wh7twphWPrtBi2R9/nT3DTtQs yqmZAUcBHpwzOsAZMBGdYJSidNUU1JXFUQFQc3329lsvohwLdNA6cW/w7atYz7J1pHvO g7sV2T84a+VU3YpqvgyDgwItl02F+QbaJcm5EK6WMsXZF4/7ofNreq8xgM/RFmPytwQt ByNFmN2fFjt7kHSoFPhxzDrAivNjUbHsyA9r02MEsuNFYQMySz1jZHW3FlUHU/cfYW9R 4SiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=/WtKtgC612nWBOsPn60OX0zx8SNSHemUDmHPjLL9ZbA=; b=sZY7Yy2WkjRffIFCQHFqVV/EzotaNHydTTYQ1XRrsOJE6NJcAQmkj6OMYNljvw2gYm wCRu+ItIIrathDRvREHEus0tTb8cK++kNV8BqyRX+Z0WmoCjb2X8E9EkxauCreXRaqIi W5QEVDIGREAsjBN6Rzvc4stO189UQjyYsD+4i1/8sKSOd7JXdVxrY7wM8+9gTRCSdQk3 VH3kh+nK41uUZzUkpjhzHGoXwi5rhoQh8hHHeciEER9pfgt3EnikWoH5rGcndWO5JRcB dBj5smzVcdIuOzonF8QLQCOob/dPRbklQxDRE4+1jg4eVjGXLDcMDLRVHlAjXX6z9bha oz7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Y9INEsBz; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bf10-v6si11875019plb.417.2018.04.16.00.40.17; Mon, 16 Apr 2018 00:40:17 -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=@gmail.com header.s=20161025 header.b=Y9INEsBz; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752209AbeDPHkP (ORCPT + 9 others); Mon, 16 Apr 2018 03:40:15 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:45943 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751183AbeDPHkO (ORCPT ); Mon, 16 Apr 2018 03:40:14 -0400 Received: by mail-pl0-f66.google.com with SMTP id k9-v6so4771959pll.12 for ; Mon, 16 Apr 2018 00:40:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=/WtKtgC612nWBOsPn60OX0zx8SNSHemUDmHPjLL9ZbA=; b=Y9INEsBzgNrPA7Il+dQyomjgIL0aUIIYlaVeXMvV6mYDpVpQwZx0vnzujEzgERKsud u3FxU6KRYrrFf2weBP8a6ylQGe4IvgciKd2zT2j6iIvVeyzJ4LbkwjTmOuhUysRxmLcl e1SlylK+TDAqBQ4cU1juJO2T0WwZWG2LeDNq/Ya3QrEofzgElWJq0UgUO1uesewicn3S jRg66Lm/LxZHzqhhpuvXfGY74okDsBVZ5ih4xKc5T/1VuHwn91WoWhcjWTTrplKdmLCn vgR+iOsm2HYaBEeUI3oYl72kSnj43yi64lg4Tf8+QjDeG/wQ1gfk8cTfS3H3FYngekDJ lZzQ== 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; bh=/WtKtgC612nWBOsPn60OX0zx8SNSHemUDmHPjLL9ZbA=; b=j8qz8EG+3Cu2MlF9zxQXcFn2hL08Dvf8QrfTf31J97I7jtjCQw1n7Qa3UhuGeH7rBr q06JJtArwWVeRtwAzOttU8ySmSUtHmeoV+WhiLd7EOuapglUWO0jF9yufGRl0Dk3zxdV N/joxIQDUy+Wl7nB/RABuQgGraHB86CUKODHWaS0pxmroRkFBThqaR5y8dVgJiAfjUho /L45mnYNO0vOYfznVsePvLL2BduyMEw1VYreyF8gtmmWa0lbBDVVWavhIXfwPCSHUZak 5jffUk7WUL4rsbh8FATAS+C+45FuVZa8mXhRufjmsbnsxKSSdp2vxTrNiCaEAdUCUGjx TBNQ== X-Gm-Message-State: ALQs6tBe5p8/tSsoph/3YSipOHLgOxaXHqEPCBr0wOq2EHOUxxNGI9lk doSKSeVAoECpbyl/H2oaOoFYQqPF X-Received: by 2002:a17:902:3204:: with SMTP id y4-v6mr14227509plb.226.1523864413335; Mon, 16 Apr 2018 00:40:13 -0700 (PDT) Received: from localhost.localdomain ([117.224.27.197]) by smtp.gmail.com with ESMTPSA id z21sm20367607pge.42.2018.04.16.00.40.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Apr 2018 00:40:12 -0700 (PDT) From: jassisinghbrar@gmail.com To: netdev@vger.kernel.org Cc: davem@davemloft.net, masahisa.kojima@linaro.org, ard.biesheuvel@linaro.org, Jassi Brar Subject: [PATCH 2/2] net: socionext: reset hardware in ndo_stop Date: Mon, 16 Apr 2018 13:09:59 +0530 Message-Id: <1523864399-27296-1-git-send-email-jassisinghbrar@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Masahisa KOJIMA When the interface is down, head/tail of the descriptor ring address is set to 0 in netsec_netdev_stop(). But netsec hardware still keeps the previous descriptor ring address, so there is inconsistency between driver and hardware after interface is up at a later time. To address this inconsistency, add netsec_reset_hardware() when the interface is down. In addition, to minimize the reset process, add flag to decide whether driver loads the netsec microcode. Even if driver resets the netsec hardware, netsec microcode keeps resident on RAM, so it is ok we only load the microcode at initialization. This patch is critical for installation over network. Signed-off-by: Masahisa KOJIMA Fixes: 533dd11a12f6 ("net: socionext: Add Synquacer NetSec driver") Signed-off-by: Jassi Brar --- drivers/net/ethernet/socionext/netsec.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c index f6fe70e..aa50331 100644 --- a/drivers/net/ethernet/socionext/netsec.c +++ b/drivers/net/ethernet/socionext/netsec.c @@ -1057,7 +1057,8 @@ static int netsec_netdev_load_microcode(struct netsec_priv *priv) return 0; } -static int netsec_reset_hardware(struct netsec_priv *priv) +static int netsec_reset_hardware(struct netsec_priv *priv, + bool load_ucode) { u32 value; int err; @@ -1102,11 +1103,14 @@ static int netsec_reset_hardware(struct netsec_priv *priv) netsec_write(priv, NETSEC_REG_NRM_RX_CONFIG, 1 << NETSEC_REG_DESC_ENDIAN); - err = netsec_netdev_load_microcode(priv); - if (err) { - netif_err(priv, probe, priv->ndev, - "%s: failed to load microcode (%d)\n", __func__, err); - return err; + if (load_ucode) { + err = netsec_netdev_load_microcode(priv); + if (err) { + netif_err(priv, probe, priv->ndev, + "%s: failed to load microcode (%d)\n", + __func__, err); + return err; + } } /* start DMA engines */ @@ -1328,6 +1332,7 @@ static int netsec_netdev_open(struct net_device *ndev) static int netsec_netdev_stop(struct net_device *ndev) { + int ret; struct netsec_priv *priv = netdev_priv(ndev); netif_stop_queue(priv->ndev); @@ -1343,12 +1348,14 @@ 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); pm_runtime_put_sync(priv->dev); - return 0; + return ret; } static int netsec_netdev_init(struct net_device *ndev) @@ -1364,7 +1371,7 @@ static int netsec_netdev_init(struct net_device *ndev) if (ret) goto err1; - ret = netsec_reset_hardware(priv); + ret = netsec_reset_hardware(priv, true); if (ret) goto err2;