From patchwork Thu Jul 25 13:27:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 261694 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id E81652C00BA for ; Thu, 25 Jul 2013 23:28:30 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756079Ab3GYN2S (ORCPT ); Thu, 25 Jul 2013 09:28:18 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:46656 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755609Ab3GYN2P (ORCPT ); Thu, 25 Jul 2013 09:28:15 -0400 Received: from dude.hi.pengutronix.de ([2001:6f8:1178:2:21e:67ff:fe11:9c5c]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1V2LaU-0007uz-51; Thu, 25 Jul 2013 15:28:10 +0200 Received: from ukl by dude.hi.pengutronix.de with local (Exim 4.80) (envelope-from ) id 1V2LaQ-0002Hc-Ms; Thu, 25 Jul 2013 15:28:06 +0200 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= To: netdev@vger.kernel.org Cc: "David S. Miller" , Fabio Estevam , Frank Li , Shawn Guo , kernel@pengutronix.de, Hector Palacios , Tim Sander , Steven Rostedt , Thomas Gleixner Subject: [PATCH] net/fec: call netif_carrier_off when not having link Date: Thu, 25 Jul 2013 15:27:55 +0200 Message-Id: <1374758875-7926-1-git-send-email-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 1.8.3.2 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:6f8:1178:2:21e:67ff:fe11:9c5c X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Without this patch I see a machine running an -rt patched Linux being stuck in sch_direct_xmit when it looses link while there is still a packet to be send. In this case the fec_enet_start_xmit routine returns NETDEV_TX_BUSY which makes the network stack reschedule the packet and so sch_direct_xmit calls fec_enet_start_xmit again. The right fix is to tell the network stack that the link was lost (using netif_carrier_off) so that it doesn't even try to get rid of the pending packets. Signed-off-by: Uwe Kleine-König --- Hello, this resembles a problem described on the linux-rt mailing list some time ago: http://thread.gmane.org/gmane.linux.rt.user/7815 So I Cc:d the people that participated in that thread. IMHO this is 3.11 material (assuming I did it right) and is even worth backporting as I think the problem exists in mainline, too, just harder to trigger. Best regards Uwe drivers/net/ethernet/freescale/fec_main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 0642006..631bd5a 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -280,11 +280,6 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *ndev) unsigned short status; unsigned int index; - if (!fep->link) { - /* Link is down or auto-negotiation is in progress. */ - return NETDEV_TX_BUSY; - } - /* Fill in a Tx ring entry */ bdp = fep->cur_tx; @@ -459,6 +454,11 @@ fec_restart(struct net_device *ndev, int duplex) netif_tx_lock_bh(ndev); } + if (!fep->link) + netif_carrier_off(ndev); + else + netif_carrier_on(ndev); + /* Whack a reset. We should wait for this. */ writel(1, fep->hwp + FEC_ECNTRL); udelay(10);