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: 74454 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1701510qga; Mon, 22 Aug 2016 11:19:02 -0700 (PDT) X-Received: by 10.98.204.74 with SMTP id a71mr45482788pfg.149.1471889942320; Mon, 22 Aug 2016 11:19:02 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l5si26963440pax.160.2016.08.22.11.19.02; Mon, 22 Aug 2016 11:19:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754318AbcHVSSm (ORCPT + 4 others); Mon, 22 Aug 2016 14:18:42 -0400 Received: from mail-lf0-f43.google.com ([209.85.215.43]:32866 "EHLO mail-lf0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754126AbcHVSSj (ORCPT ); Mon, 22 Aug 2016 14:18:39 -0400 Received: by mail-lf0-f43.google.com with SMTP id b199so84151571lfe.0 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=S84NMJ0u0Oxt7nyZ2HtmK0A3R58v604M6hCkXitsPrw3EA+1vCNVSeAYWICMwQt0NS JIeQZGgf+XGBVhGSY4cj+2/s4i5AQhSyhdlknBkqzZ2HGwEDyIqcAAojQsWzMDGtmZ+X mNHlYDaEVkYDFY6EzBZ+MSfRWrXs/JRpXmk5fGLaNgdSyOBvBxnMDRzP7FRvpjy+/lHp lAp7mR+jiiXq0OOSmZi2f+jSXM6YEx7n0dkjM+3HpoTKnytU5xKPlaLPsg2JiTaOD9nw aVwydsNCCMBoqoDy3DVmVyCTII8nnMHgzKWhpe0QSG70vqMi1LReWmQ2Q3GuvnQEQGZw nNWQ== X-Gm-Message-State: AEkoouveHbd66bqqeVODmy5J00qFsHXWRqne18IPZycnpOvJzXoUwAne1Ax+BpXrecc4IDAA 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: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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(+) -- 1.9.1 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);