From patchwork Tue Jan 17 13:45:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 91652 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp498731qgi; Tue, 17 Jan 2017 05:53:02 -0800 (PST) X-Received: by 10.98.55.131 with SMTP id e125mr43704444pfa.58.1484661182869; Tue, 17 Jan 2017 05:53:02 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t6si25008640plm.337.2017.01.17.05.53.02; Tue, 17 Jan 2017 05:53:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751140AbdAQNxA (ORCPT + 4 others); Tue, 17 Jan 2017 08:53:00 -0500 Received: from mail-wm0-f53.google.com ([74.125.82.53]:38328 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751158AbdAQNwy (ORCPT ); Tue, 17 Jan 2017 08:52:54 -0500 Received: by mail-wm0-f53.google.com with SMTP id r144so223375769wme.1 for ; Tue, 17 Jan 2017 05:52:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7fpgNcJJF18Kt6HTI8Dobj2zVZWFCpKfcQZW2WXdZ28=; b=NW9R8tqoUZeE0s3BbO79EoPB8CAsjWykxvADOdnBXLaVxafl3Ht/wBmse+njGJLUse RDfW8Bi3HfaLVX9VxNBF3t3TyT6iCp2TANmSFzGoX5gJCTS1ZTZj5lD0dE24y76lMC/d hm81U7Gii0UBuauV020nMBUCGEiAhDPSWrp9jLzMioSR81yKTL13rb6ze+bgl5gTLnsk Crql9eDt57yLoPxYr+5+6hcbpRY3A+vXebVfJR1v+NZzveKJtCC6ZHl7/vsyEpKSauIu m+yqIXrQD7YzFwEKOqMelQVRqJMcffkQkzC2yVaxZJVTAQd2eMcGwxSrgWyzbahlftGm BfLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7fpgNcJJF18Kt6HTI8Dobj2zVZWFCpKfcQZW2WXdZ28=; b=hxfjljqJ+dO60ezdUv2KwNB49jM8oPWbpceBHLg9KEf47n/Fj4Ti1NDxeeuJnPbjEv qdhMKD5HJnBzUktuKAiAl9kZo0bVRlaBSzeQns+/Z2oAdhLWp+2vcw/8F0chYT8X1wRt UZ9Q3QqalgjXvuP5Oo+62BTDFr8heWFn6jT+30bJroFQx5eizJe5KyCyjq68HQVeg0z1 LV3sK8LqW1fY551OOWeeV1rM07K5i5sLzSZerJXFE17eEGGT2ErE/7ZYVjBJ6MGFuV9/ B8UVdMqf7D5KYTlua1L4avmiMz5DICadSGTqaQXSVtm+M5eFkqJkTtqPmLT2UrEPg3ct GWTA== X-Gm-Message-State: AIkVDXLyu71cW5a+2elcoJQAx++BUZ+VZdstrsRKikLQHRs/5gRPyJoGcmZV38RBU/ZwZ6I/ X-Received: by 10.28.203.75 with SMTP id b72mr18055115wmg.110.1484660757604; Tue, 17 Jan 2017 05:45:57 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id l187sm37064811wml.6.2017.01.17.05.45.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Jan 2017 05:45:57 -0800 (PST) From: Alexandre Bailon To: vinod.koul@intel.com, b-liu@ti.com, robh+dt@kernel.org Cc: dmaengine@vger.kernel.org, nsekhar@ti.com, khilman@baylibre.com, ptitiano@baylibre.com, tony@atomide.com, linux-omap@vger.kernel.org, sergei.shtylyov@cogentembedded.com, devicetree@vger.kernel.org, Alexandre Bailon Subject: [PATCH v2 7/7] dmaengine: cppi41: Fix a race between PM runtime and channel abort Date: Tue, 17 Jan 2017 14:45:40 +0100 Message-Id: <20170117134540.9988-8-abailon@baylibre.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170117134540.9988-1-abailon@baylibre.com> References: <20170117134540.9988-1-abailon@baylibre.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org cppi41_dma_issue_pending() may be called while the device is runtime suspended. In that case, the descriptor will be pushed to the pending list and then be queued to hardware queue. But if cppi41_stop_chan() is called before the device got time to resume, then the descriptor will remain in the pending list and be queued to hardware queue after the teardown. During the channel stop, check if there is a pending descriptor and if so, remove it. Signed-off-by: Alexandre Bailon --- drivers/dma/cppi41.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) -- 2.10.2 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c index 303ccee..0bc4f1a 100644 --- a/drivers/dma/cppi41.c +++ b/drivers/dma/cppi41.c @@ -687,10 +687,17 @@ static int cppi41_stop_chan(struct dma_chan *chan) { struct cppi41_channel *c = to_cpp41_chan(chan); struct cppi41_dd *cdd = c->cdd; + unsigned long flags; u32 desc_num; u32 desc_phys; int ret; + /* Remove pending descriptor that haven't been pushed to queue */ + spin_lock_irqsave(&cdd->lock, flags); + if (!list_empty(&c->node)) + list_del_init(&c->node); + spin_unlock_irqrestore(&cdd->lock, flags); + desc_phys = lower_32_bits(c->desc_phys); desc_num = (desc_phys - cdd->descs_phys) / sizeof(struct cppi41_desc); if (!cdd->chan_busy[desc_num]) @@ -748,6 +755,7 @@ static int cppi41_add_chans(struct device *dev, struct cppi41_dd *cdd) cchan->desc_phys = cdd->descs_phys; cchan->desc_phys += i * sizeof(struct cppi41_desc); cchan->chan.device = &cdd->ddev; + INIT_LIST_HEAD(&cchan->node); list_add_tail(&cchan->chan.device_node, &cdd->ddev.channels); } cdd->first_td_desc = n_chans; @@ -1163,7 +1171,7 @@ static int __maybe_unused cppi41_runtime_resume(struct device *dev) spin_lock_irqsave(&cdd->lock, flags); list_for_each_entry_safe(c, _c, &cdd->pending, node) { push_desc_queue(c); - list_del(&c->node); + list_del_init(&c->node); } spin_unlock_irqrestore(&cdd->lock, flags);