From patchwork Fri Jul 28 16:13:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Gonzalez X-Patchwork-Id: 9869101 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3EBF06035E for ; Fri, 28 Jul 2017 16:14:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32E6628885 for ; Fri, 28 Jul 2017 16:14:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2765228898; Fri, 28 Jul 2017 16:14:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 954A22888F for ; Fri, 28 Jul 2017 16:14:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Date:Message-ID:Subject: From:To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=QeefPJjj+ze34Mfwg5LDXNlTRBSZRlePjKmyWO7QbxA=; b=Yh1smfbdpucyGB U+3jpQ+pyyX886OUCXF2WfrfhFZ3K4RMXwWJPM7MO9mKQJ5cCRLd4nzHyvqFrDNm7A5mUSRWUjxcb PBQTl9kQ/I2Hq52kkR7ya9OONCuxP0aRSNMqmAPX+QsoErBGqNpnWrzNuX7eVz7ZxtZz2aIUyTTra gd0rWXLEpbFBHOZ4OgPZLMmhsd4JDoXUg8iQwJLhvW77vH5IlXT56bk8z1qQ9gxkO9AXWaDF8gVKC GY2W8E2yPW9+d3vNVJwQefj1hZZTyX+59uOo0CuW9do2H2w80rXEegJcx36cA4u5MixEeWuF9z/Ar PDdkYnDkdRfvTLfJKqbg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1db7ta-0003wJ-EV; Fri, 28 Jul 2017 16:13:46 +0000 Received: from us-smtp-delivery-107.mimecast.com ([63.128.21.107]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1db7tX-0003v9-8T for linux-arm-kernel@lists.infradead.org; Fri, 28 Jul 2017 16:13:45 +0000 Received: from CPH-EX1.SDESIGNS.COM (195-215-56-170-static.dk.customer.tdc.net [195.215.56.170]) (Using TLS) by us-smtp-1.mimecast.com with ESMTP id us-mta-164--lCCIyuBNTaFlmdmMZzYGg-1; Fri, 28 Jul 2017 12:13:18 -0400 Received: from [172.27.0.114] (172.27.0.114) by CPH-EX1.sdesigns.com (192.168.10.36) with Microsoft SMTP Server (TLS) id 14.3.294.0; Fri, 28 Jul 2017 18:13:15 +0200 To: Florian Fainelli , Mans Rullgard , "David S. Miller" From: Marc Gonzalez Subject: [RFC PATCH v1] net: ethernet: nb8800: Reset HW block in ndo_open Message-ID: <823b1540-b528-bbd7-7f99-5dc39a08868a@sigmadesigns.com> Date: Fri, 28 Jul 2017 18:13:15 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 SeaMonkey/2.49.1 MIME-Version: 1.0 X-Originating-IP: [172.27.0.114] X-MC-Unique: -lCCIyuBNTaFlmdmMZzYGg-1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170728_091343_488321_9F2A477D X-CRM114-Status: UNSURE ( 7.88 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev , Linux ARM , Mason Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP ndo_stop breaks RX in a way that ndo_open is unable to undo. Work around the issue by resetting the HW in ndo_open. This will provide the basis for suspend/resume support. Signed-off-by: Marc Gonzalez --- drivers/net/ethernet/aurora/nb8800.c | 40 +++++++++++++++++------------------- drivers/net/ethernet/aurora/nb8800.h | 1 + 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/aurora/nb8800.c b/drivers/net/ethernet/aurora/nb8800.c index e94159507847..954a28542c3b 100644 --- a/drivers/net/ethernet/aurora/nb8800.c +++ b/drivers/net/ethernet/aurora/nb8800.c @@ -39,6 +39,7 @@ #include "nb8800.h" +static void nb8800_init(struct net_device *dev); static void nb8800_tx_done(struct net_device *dev); static int nb8800_dma_stop(struct net_device *dev); @@ -957,6 +958,8 @@ static int nb8800_open(struct net_device *dev) struct phy_device *phydev; int err; + nb8800_init(dev); + /* clear any pending interrupts */ nb8800_writel(priv, NB8800_RXC_SR, 0xf); nb8800_writel(priv, NB8800_TXC_SR, 0xf); @@ -1350,6 +1353,20 @@ static const struct of_device_id nb8800_dt_ids[] = { }; MODULE_DEVICE_TABLE(of, nb8800_dt_ids); +static void nb8800_init(struct net_device *dev) +{ + struct nb8800_priv *priv = netdev_priv(dev); + const struct nb8800_ops *ops = priv->ops; + + if (ops && ops->reset) + ops->reset(dev); + nb8800_hw_init(dev); + if (ops && ops->init) + ops->init(dev); + nb8800_update_mac_addr(dev); + priv->speed = 0; +} + static int nb8800_probe(struct platform_device *pdev) { const struct of_device_id *match; @@ -1389,6 +1406,7 @@ static int nb8800_probe(struct platform_device *pdev) priv = netdev_priv(dev); priv->base = base; + priv->ops = ops; priv->phy_mode = of_get_phy_mode(pdev->dev.of_node); if (priv->phy_mode < 0) @@ -1407,12 +1425,6 @@ static int nb8800_probe(struct platform_device *pdev) spin_lock_init(&priv->tx_lock); - if (ops && ops->reset) { - ret = ops->reset(dev); - if (ret) - goto err_disable_clk; - } - bus = devm_mdiobus_alloc(&pdev->dev); if (!bus) { ret = -ENOMEM; @@ -1454,16 +1466,6 @@ static int nb8800_probe(struct platform_device *pdev) priv->mii_bus = bus; - ret = nb8800_hw_init(dev); - if (ret) - goto err_deregister_fixed_link; - - if (ops && ops->init) { - ret = ops->init(dev); - if (ret) - goto err_deregister_fixed_link; - } - dev->netdev_ops = &nb8800_netdev_ops; dev->ethtool_ops = &nb8800_ethtool_ops; dev->flags |= IFF_MULTICAST; @@ -1476,14 +1478,12 @@ static int nb8800_probe(struct platform_device *pdev) if (!is_valid_ether_addr(dev->dev_addr)) eth_hw_addr_random(dev); - nb8800_update_mac_addr(dev); - netif_carrier_off(dev); ret = register_netdev(dev); if (ret) { netdev_err(dev, "failed to register netdev\n"); - goto err_free_dma; + goto err_deregister_fixed_link; } netif_napi_add(dev, &priv->napi, nb8800_poll, NAPI_POLL_WEIGHT); @@ -1492,8 +1492,6 @@ static int nb8800_probe(struct platform_device *pdev) return 0; -err_free_dma: - nb8800_dma_free(dev); err_deregister_fixed_link: if (of_phy_is_fixed_link(pdev->dev.of_node)) of_phy_deregister_fixed_link(pdev->dev.of_node); diff --git a/drivers/net/ethernet/aurora/nb8800.h b/drivers/net/ethernet/aurora/nb8800.h index 6ec4a956e1e5..d5f4481a2c7b 100644 --- a/drivers/net/ethernet/aurora/nb8800.h +++ b/drivers/net/ethernet/aurora/nb8800.h @@ -305,6 +305,7 @@ struct nb8800_priv { dma_addr_t tx_desc_dma; struct clk *clk; + const struct nb8800_ops *ops; }; struct nb8800_ops {