From patchwork Tue Mar 4 14:07:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Riesch X-Patchwork-Id: 3762531 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6E05B9F1EE for ; Tue, 4 Mar 2014 14:09:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 58C1020225 for ; Tue, 4 Mar 2014 14:09:00 +0000 (UTC) Received: from comal.ext.ti.com (comal.ext.ti.com [198.47.26.152]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2132420221 for ; Tue, 4 Mar 2014 14:08:59 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id s24E8wjV010966 for ; Tue, 4 Mar 2014 08:08:58 -0600 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s24E8w4o027440 for ; Tue, 4 Mar 2014 08:08:58 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.174.1; Tue, 4 Mar 2014 08:08:57 -0600 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s24E8wSI014255 for ; Tue, 4 Mar 2014 08:08:58 -0600 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id E32F080626 for ; Tue, 4 Mar 2014 08:08:57 -0600 (CST) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflxv17.itg.ti.com (dflxv17.itg.ti.com [128.247.5.93]) by linux.omap.com (Postfix) with ESMTP id B09EC80626 for ; Tue, 4 Mar 2014 08:08:05 -0600 (CST) Received: from medina.ext.ti.com (medina.ext.ti.com [192.91.81.31]) by dflxv17.itg.ti.com (8.14.3/8.13.8) with ESMTP id s24E85Ze018838 for ; Tue, 4 Mar 2014 08:08:05 -0600 Received: from mail6.bemta7.messagelabs.com (mail6.bemta7.messagelabs.com [216.82.255.55]) by medina.ext.ti.com (8.13.7/8.13.7) with ESMTP id s24E85KC018436 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 4 Mar 2014 08:08:05 -0600 Received: from [216.82.253.67:45348] by server-5.bemta-7.messagelabs.com id C4/DE-22835-54ED5135; Tue, 04 Mar 2014 14:08:05 +0000 X-Env-Sender: christian.riesch@omicron.at X-Msg-Ref: server-5.tower-158.messagelabs.com!1393942081!3885956!1 X-Originating-IP: [212.183.10.25] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.9.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 25009 invoked from network); 4 Mar 2014 14:08:03 -0000 Received: from ns.omicron.at (HELO ns.omicron.at) (212.183.10.25) by server-5.tower-158.messagelabs.com with DHE-RSA-AES256-SHA encrypted SMTP; 4 Mar 2014 14:08:03 -0000 Received: from counter.omicron.at ([212.183.10.29]) by ns.omicron.at (8.13.1/8.13.1) with ESMTP id s24E7pDf012179; Tue, 4 Mar 2014 15:07:56 +0100 Received: from mary.at.omicron.at (mary.at.omicron.at [172.22.100.48]) by counter.omicron.at (8.14.4/8.14.4) with ESMTP id s24E7pgL027830; Tue, 4 Mar 2014 15:07:51 +0100 Received: from ChrRie22.omicron.at (172.22.3.154) by mary-special.at.omicron.at (172.22.100.48) with Microsoft SMTP Server id 8.3.327.1; Tue, 4 Mar 2014 15:07:47 +0100 From: Christian Riesch To: Subject: [PATCH] net: davinci_emac: Move call of devm_request_irq to emac_dev_open Date: Tue, 4 Mar 2014 15:07:41 +0100 X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Message-ID: <5dd177ee-f4e8-47b0-aeb8-d2fa64d3725b@mary.at.omicron.at> CC: , , Jon Ringle X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: Errors-To: davinci-linux-open-source-bounces+patchwork-davinci=patchwork.kernel.org@linux.davincidsp.com X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In commit 6892b41d9701283085b655c6086fb57a5d63fa47 Author: Lad, Prabhakar Date: Tue Jun 25 21:24:51 2013 +0530 net: davinci: emac: Convert to devm_* api the call of request_irq is replaced by devm_request_irq and the call of free_irq is removed. But since interrupts are requested in emac_dev_open, doing ifconfig up/down on the board requests the interrupts again each time, causing devm_request_irq to fail. This patch moves the interrupt requests to emac_dev_open and thus fixes this regression. Reported-by: Jon Ringle Signed-off-by: Christian Riesch Cc: Lad, Prabhakar Cc: --- Hi, This is an attempt to fix the bug discussed in https://lkml.org/lkml/2014/3/4/218 Since I am not really familiar with interrupts I am not sure if this is the right way to do it. I am looking forward to your comments. Christian drivers/net/ethernet/ti/davinci_emac.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c index cd9b164..97c6036 100644 --- a/drivers/net/ethernet/ti/davinci_emac.c +++ b/drivers/net/ethernet/ti/davinci_emac.c @@ -1531,10 +1531,8 @@ static int emac_dev_open(struct net_device *ndev) { struct device *emac_dev = &ndev->dev; u32 cnt; - struct resource *res; int ret; int i = 0; - int k = 0; struct emac_priv *priv = netdev_priv(ndev); pm_runtime_get(&priv->pdev->dev); @@ -1563,16 +1561,6 @@ static int emac_dev_open(struct net_device *ndev) break; } - /* Request IRQ */ - - while ((res = platform_get_resource(priv->pdev, IORESOURCE_IRQ, k))) { - for (i = res->start; i <= res->end; i++) { - if (devm_request_irq(&priv->pdev->dev, i, emac_irq, - 0, ndev->name, ndev)) - goto rollback; - } - k++; - } /* Start/Enable EMAC hardware */ emac_hw_enable(priv); @@ -1639,10 +1627,6 @@ static int emac_dev_open(struct net_device *ndev) return 0; -rollback: - - dev_err(emac_dev, "DaVinci EMAC: devm_request_irq() failed"); - ret = -EBUSY; err: pm_runtime_put(&priv->pdev->dev); return ret; @@ -1839,6 +1823,8 @@ static int davinci_emac_probe(struct platform_device *pdev) struct clk *emac_clk; unsigned long emac_bus_frequency; + int k = 0; + int i = 0; /* obtain emac clock from kernel */ emac_clk = devm_clk_get(&pdev->dev, NULL); @@ -1968,11 +1954,25 @@ static int davinci_emac_probe(struct platform_device *pdev) (void *)priv->emac_base_phys, ndev->irq); } + /* Request IRQ */ + while ((res = platform_get_resource(priv->pdev, IORESOURCE_IRQ, k))) { + for (i = res->start; i <= res->end; i++) { + if (devm_request_irq(&priv->pdev->dev, i, emac_irq, + 0, ndev->name, ndev)) + goto no_irq; + } + k++; + } + pm_runtime_enable(&pdev->dev); pm_runtime_resume(&pdev->dev); return 0; +no_irq: + dev_err(emac_dev, "DaVinci EMAC: devm_request_irq() failed"); + rc = -EBUSY; + no_cpdma_chan: if (priv->txchan) cpdma_chan_destroy(priv->txchan);