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: 659450 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 3sCs9B3Hkwz9t1Q for ; Tue, 16 Aug 2016 09:27:42 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b=O9wQH409; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753298AbcHOX11 (ORCPT ); Mon, 15 Aug 2016 19:27:27 -0400 Received: from mail-wm0-f42.google.com ([74.125.82.42]:33390 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753087AbcHOX0E (ORCPT ); Mon, 15 Aug 2016 19:26:04 -0400 Received: by mail-wm0-f42.google.com with SMTP id d196so24490921wmd.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=TfezFsy5j1kYOMKeATBjYsds51yRYFwrSbpALY9MPMq9ViIK4IWSR0Irgz/HNRNAq+ EM1qWr/I78ZWuEeyJ13MUE6pC3XdYAe+UGIV/723CxpuyOw/yo+acT3GXGsScZgT4XkK Q/i/ELqXv1ZZIz8TNlJp/a6IGHrOw1kHk0qvcsIVGUtY3eH4M5y7XyWROhfkRPN4aIzO aMFFP2zNt1h7J0LVHJfZrM+Z/LKviwFmeauv0c8EuPrhNqAF3lMFbs2oWLM2hjPyegXz JHvbvW+eCubxy9Bqn2IH5HNogTm5kybnuscpxzVGPi8aeNz5+RLUJVdm/Us5uIr1cPYP lJdQ== X-Gm-Message-State: AEkoouvGnf0HcybZJ/HxoRo/pIXpXIRcuzygSVDTdqm7EdBnYSGcxNiHPgHIBMi421/YXMyd 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: 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(): 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);