From patchwork Mon Aug 22 18:18:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 9294063 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 0A40A607F0 for ; Mon, 22 Aug 2016 18:19:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F3C762882E for ; Mon, 22 Aug 2016 18:19:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E7FB3288A0; Mon, 22 Aug 2016 18:19:07 +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 D47662882E for ; Mon, 22 Aug 2016 18:19:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754302AbcHVSSm (ORCPT ); Mon, 22 Aug 2016 14:18:42 -0400 Received: from mail-lf0-f53.google.com ([209.85.215.53]:33819 "EHLO mail-lf0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754130AbcHVSSj (ORCPT ); Mon, 22 Aug 2016 14:18:39 -0400 Received: by mail-lf0-f53.google.com with SMTP id l89so84046043lfi.1 for ; Mon, 22 Aug 2016 11:18:38 -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=ZL49HTM+ds/97v1SZvLF9YeedLWxfxA56GdEIEPRX34=; b=NiAZILLx98dBw2bApKCDlGPsAgMMbtDC8nMzQX5XmDufwnvAOumU5ELcGJ+m4warhL wCpHC63wZva1wvy1iMhyrSY6l17hX1QBvhMFI2wKUfRq4yOAq49kzdzCf5btTIYGCuCO SlpIogFzKXAAuabv+AWQyhZqI32CzzvtDykBQ= 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=ZL49HTM+ds/97v1SZvLF9YeedLWxfxA56GdEIEPRX34=; b=iTKlahqXh9fIQ2zmYZyP8SqgbfnvYwIXor1SCD2tN9gm04/Uc7R9Sh83FnOwAocPXr qu4ahkR0L9wmO2j3HsUhaxC5bcW7yUWncM84GZbiEvyox6yGPTMRfF/RC2PBMlwaE+Tb wFUZvZ76fIUSgNVQJfm7FGU50o/rpMnkpb2Mro14POjNeTVjPbEbW6PV5ksAPpArJFt7 6OfkESt8R85LBNxyCO8l+70+NA+4JrPWdqy+9076po/UnHz+j85OPoJ+iSBwJeSSwLjL Umekp1/5Xvg6fESQy3H4sumOejl9O4dGhbtynnAAz14/6ghNuEwoYY4HmeHZM2fvNy7D CLkA== X-Gm-Message-State: AEkoouvLoHNZ3jUSzzfqCRgGeTBzcqSupURiWzhj4ilGh0o0MzCnXrHsTcrRygW96rxyC43c X-Received: by 10.25.91.149 with SMTP id p143mr4853308lfb.39.1471889917053; Mon, 22 Aug 2016 11:18:37 -0700 (PDT) Received: from localhost.localdomain ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id 206sm3969101ljj.4.2016.08.22.11.18.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Aug 2016 11:18:36 -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, dlide@ti.com, Ivan Khoronzhuk Subject: [PATCH v4 2/5] net: ethernet: ti: davinci_cpdma: fix locking while ctrl_stop Date: Mon, 22 Aug 2016 21:18:25 +0300 Message-Id: <1471889908-29983-3-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1471889908-29983-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1471889908-29983-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(), it can cause WARN_ONCE when ctrl is stopping while not all packets were handled with NAPIs: 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. Reviewed-by: Mugunthan V N Signed-off-by: Ivan Khoronzhuk --- 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);