From patchwork Wed Jul 4 09:14:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Ferre X-Patchwork-Id: 1155321 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id F1107DFF0F for ; Wed, 4 Jul 2012 09:20:55 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SmLgv-0000iQ-A1; Wed, 04 Jul 2012 09:16:09 +0000 Received: from eusmtp01.atmel.com ([212.144.249.242]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SmLfj-0000YA-Bq for linux-arm-kernel@lists.infradead.org; Wed, 04 Jul 2012 09:15:08 +0000 Received: from HNOCHT02.corp.atmel.com (10.161.30.162) by eusmtp01.atmel.com (10.161.101.30) with Microsoft SMTP Server (TLS) id 14.2.247.3; Wed, 4 Jul 2012 11:14:27 +0200 Received: from tenerife.rfo.atmel.com (10.159.245.203) by HNOCHT02.corp.atmel.com (10.161.30.160) with Microsoft SMTP Server (TLS) id 14.2.247.3; Wed, 4 Jul 2012 11:14:19 +0200 From: Nicolas Ferre To: , , Subject: [PATCH] net/macb: manage carrier state with call to netif_carrier_{on|off}() Date: Wed, 4 Jul 2012 11:14:13 +0200 Message-ID: <1341393253-6531-1-git-send-email-nicolas.ferre@atmel.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1341361835.2839.21.camel@bwh-desktop.uk.solarflarecom.com> References: <1341361835.2839.21.camel@bwh-desktop.uk.solarflarecom.com> MIME-Version: 1.0 X-Originating-IP: [10.159.245.203] X-Spam-Note: CRM114 invocation failed X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: kuznet@ms2.inr.ac.ru, shemminger@vyatta.com, Nicolas Ferre , davem@davemloft.net, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org OFF carrier state is setup in probe() open() and suspend() functions. The carrier ON state is managed in macb_handle_link_change(). Signed-off-by: Nicolas Ferre --- Hi, This patch follows the discussion about IPv6 and macb interface ("ADDRCONF(NETDEV_UP): eth0: link is not ready" with IPv6) It may not address all aspects of the discussion, so please do comments... I am still wondering if netif_carrier_off() is needed in macb_probe() *after* the call to register_netdev() in addition to its inclusion in the open() function. As I saw it in sevral drivers, I kept it. I have tested several suspend/resume loops, and I think that just calling netif_carrier_off() in suspend() function is sufficient: am I right? Thanks for your help, Best regards, drivers/net/ethernet/cadence/macb.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c index 1466bc4..033064b 100644 --- a/drivers/net/ethernet/cadence/macb.c +++ b/drivers/net/ethernet/cadence/macb.c @@ -179,13 +179,16 @@ static void macb_handle_link_change(struct net_device *dev) spin_unlock_irqrestore(&bp->lock, flags); if (status_change) { - if (phydev->link) + if (phydev->link) { + netif_carrier_on(dev); netdev_info(dev, "link up (%d/%s)\n", phydev->speed, phydev->duplex == DUPLEX_FULL ? "Full" : "Half"); - else + } else { + netif_carrier_off(dev); netdev_info(dev, "link down\n"); + } } } @@ -1033,6 +1036,9 @@ static int macb_open(struct net_device *dev) netdev_dbg(bp->dev, "open\n"); + /* carrier starts down */ + netif_carrier_off(dev); + /* if the phy is not yet register, retry later*/ if (!bp->phy_dev) return -EAGAIN; @@ -1406,6 +1412,8 @@ static int __init macb_probe(struct platform_device *pdev) platform_set_drvdata(pdev, dev); + netif_carrier_off(dev); + netdev_info(dev, "Cadence %s at 0x%08lx irq %d (%pM)\n", macb_is_gem(bp) ? "GEM" : "MACB", dev->base_addr, dev->irq, dev->dev_addr); @@ -1469,6 +1477,7 @@ static int macb_suspend(struct platform_device *pdev, pm_message_t state) struct net_device *netdev = platform_get_drvdata(pdev); struct macb *bp = netdev_priv(netdev); + netif_carrier_off(netdev); netif_device_detach(netdev); clk_disable(bp->hclk);