From patchwork Mon Aug 15 23:25:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 9282329 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 8AEDC60839 for ; Mon, 15 Aug 2016 23:27:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F3FD28EA4 for ; Mon, 15 Aug 2016 23:27:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7425128EA6; Mon, 15 Aug 2016 23:27:19 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28A8328EA4 for ; Mon, 15 Aug 2016 23:27:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932182AbcHOX0G (ORCPT ); Mon, 15 Aug 2016 19:26:06 -0400 Received: from mail-wm0-f48.google.com ([74.125.82.48]:35594 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752408AbcHOX0E (ORCPT ); Mon, 15 Aug 2016 19:26:04 -0400 Received: by mail-wm0-f48.google.com with SMTP id f65so113377767wmi.0 for ; Mon, 15 Aug 2016 16:26:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HKyEdX8rzQJn4aipcTydI63oKncB6HBOBCstBpGvMs8=; b=O9wQH4091rFMMBVKtNVBm67H1K3fXhko+GlnjYOMgO2Pf/Ijws0JWUy2A2OJdJaXbu 8u+lQ3zPsdh3VCltfUlFMHJ5T9IunOoa5Bp6PXDxpsw76U2NqjBUiOoJLQqmi6fJeq3h +WplrjNqxG4qrMIgmD2JuygCodsyxX0fmMWbg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HKyEdX8rzQJn4aipcTydI63oKncB6HBOBCstBpGvMs8=; b=AXDlAY5QaDp55VT8Ad3Upo7BW6Vr2DTUZUflWLOPzPpsMlPeBEjiQ4dsxibl9RfbhM Is2EfXFdA75vl317Ea20BCxHjJ+r7+xEmdmIR1M06cQLJtnamaU/TBP6hGs7EaumL30B bNSgEnurHTqwoB0ZRaJxvSXyfb7/d2sTsjGYEeqi+SV8+/C2FrVx4DCcDpLR6Zpk0nmk imkszuichOrAnDB2s5HvvhWiW+8Z1XgvGjUAaL0vL/DeP+0gRPZ3NPB38Ws6tplSnGt9 n6h2shIca7s5/XxpAubmRwi84Q2q3di51IQqW7bwX7/5Q27Db8WuxH/rZyHuVcZ8YcL3 3JhQ== X-Gm-Message-State: AEkoouuFsQ/d8+E0uDZYO/+a9/XgAiZRSDlHO1mhI/l65+U4czYkTqvPTWihp43rFA3GqxpJ X-Received: by 10.25.44.71 with SMTP id s68mr5965676lfs.197.1471303562712; Mon, 15 Aug 2016 16:26:02 -0700 (PDT) Received: from localhost.localdomain (20-202-94-178.pool.ukrtel.net. [178.94.202.20]) by smtp.gmail.com with ESMTPSA id i5sm3701035lfe.40.2016.08.15.16.26.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Aug 2016 16:26:02 -0700 (PDT) From: Ivan Khoronzhuk To: davem@davemloft.net, netdev@vger.kernel.org, mugunthanvnm@ti.com, grygorii.strashko@ti.com Cc: linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, nsekhar@ti.com, Ivan Khoronzhuk Subject: [PATCH v3 2/5] net: ethernet: ti: davinci_cpdma: fix locking while ctrl_stop Date: Tue, 16 Aug 2016 02:25:46 +0300 Message-Id: <1471303549-4134-3-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1471303549-4134-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1471303549-4134-1-git-send-email-ivan.khoronzhuk@linaro.org> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The interrupts shouldn't be disabled while receiving skb, but while ctrl_stop, the channels are stopped and all remaining packets are handled with netif_receive_skb(): lock_irq_save cpdma_ctlr_stop cpdma_chan_top __cpdma_chan_free cpsw_rx_handler netif_receive_skb So, split locking while ctrl stop thus interrupts are still enabled while skbs handling. It can cause WARN_ONCE in rare cases when ctrl is stopping while not all packets were handled with NAPIs. Signed-off-by: Ivan Khoronzhuk Reviewed-by: Mugunthan V N --- drivers/net/ethernet/ti/davinci_cpdma.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c index 167fd65..ffb32af 100644 --- a/drivers/net/ethernet/ti/davinci_cpdma.c +++ b/drivers/net/ethernet/ti/davinci_cpdma.c @@ -334,12 +334,14 @@ int cpdma_ctlr_stop(struct cpdma_ctlr *ctlr) } ctlr->state = CPDMA_STATE_TEARDOWN; + spin_unlock_irqrestore(&ctlr->lock, flags); for (i = 0; i < ARRAY_SIZE(ctlr->channels); i++) { if (ctlr->channels[i]) cpdma_chan_stop(ctlr->channels[i]); } + spin_lock_irqsave(&ctlr->lock, flags); dma_reg_write(ctlr, CPDMA_RXINTMASKCLEAR, 0xffffffff); dma_reg_write(ctlr, CPDMA_TXINTMASKCLEAR, 0xffffffff);