From patchwork Thu Jan 12 17:45:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 9513709 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 EF47360762 for ; Thu, 12 Jan 2017 17:45:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E210E286FB for ; Thu, 12 Jan 2017 17:45:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D6FA1286F3; Thu, 12 Jan 2017 17:45:50 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable 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 39061286F3 for ; Thu, 12 Jan 2017 17:45:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750946AbdALRp0 (ORCPT ); Thu, 12 Jan 2017 12:45:26 -0500 Received: from muru.com ([72.249.23.125]:56632 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750834AbdALRpV (ORCPT ); Thu, 12 Jan 2017 12:45:21 -0500 Received: from atomide.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTPS id 38EEB827F; Thu, 12 Jan 2017 17:46:02 +0000 (UTC) Date: Thu, 12 Jan 2017 09:45:16 -0800 From: Tony Lindgren To: Grygorii Strashko Cc: Alexandre Bailon , vinod.koul@intel.com, dmaengine@vger.kernel.org, linux-usb@vger.kernel.org, nsekhar@ti.com, khilman@baylibre.com, ptitiano@baylibre.com, linux-omap@vger.kernel.org, andy.shevchenko@gmail.com Subject: Re: [PATCH v2 1/2] dmaengine: cppi41: Fix list not empty warning on runtime suspend Message-ID: <20170112174515.GH2630@atomide.com> References: <20170109170337.6957-1-abailon@baylibre.com> <20170109170337.6957-2-abailon@baylibre.com> <20170109183416.GJ2630@atomide.com> <20170112170900.GG2630@atomide.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.2 (2016-11-26) Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP * Grygorii Strashko [170112 09:24]: > On 01/12/2017 11:09 AM, Tony Lindgren wrote: > > Below is what seems to fix issues for me, not seeing any more warnings > > either. > > > > Care to give it a try with your USB headset? > > This looks more close to what is provided in Documentation\power\runtime_pm.txt > (example at the end of the file), > but as per this document custom locking is required to access .active var. OK so sounds like we're on the right track then :) Here's a version using atomic.h. Regards, Tony 8< ------------------- --- To unsubscribe from this list: send the line "unsubscribe dmaengine" 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 --- a/drivers/dma/cppi41.c +++ b/drivers/dma/cppi41.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -153,6 +154,8 @@ struct cppi41_dd { /* context for suspend/resume */ unsigned int dma_tdfdq; + + atomic_t active; }; #define FIST_COMPLETION_QUEUE 93 @@ -320,7 +323,8 @@ static irqreturn_t cppi41_irq(int irq, void *data) int error; error = pm_runtime_get(cdd->ddev.dev); - if (error < 0) + if (((error != -EINPROGRESS) && error < 0) || + !atomic_read(&cdd->active)) dev_err(cdd->ddev.dev, "%s pm runtime get: %i\n", __func__, error); @@ -482,7 +486,7 @@ static void cppi41_dma_issue_pending(struct dma_chan *chan) return; } - if (likely(pm_runtime_active(cdd->ddev.dev))) + if (likely(atomic_read(&cdd->active))) push_desc_queue(c); else pending_desc(c); @@ -1003,6 +1007,7 @@ static int cppi41_dma_probe(struct platform_device *pdev) cdd->ddev.dst_addr_widths = CPPI41_DMA_BUSWIDTHS; cdd->ddev.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST; cdd->ddev.dev = dev; + atomic_set(&cdd->active, 0); INIT_LIST_HEAD(&cdd->ddev.channels); cpp41_dma_info.dma_cap = cdd->ddev.cap_mask; @@ -1151,6 +1156,7 @@ static int __maybe_unused cppi41_runtime_suspend(struct device *dev) { struct cppi41_dd *cdd = dev_get_drvdata(dev); + atomic_set(&cdd->active, 0); WARN_ON(!list_empty(&cdd->pending)); return 0; @@ -1159,13 +1165,20 @@ static int __maybe_unused cppi41_runtime_suspend(struct device *dev) static int __maybe_unused cppi41_runtime_resume(struct device *dev) { struct cppi41_dd *cdd = dev_get_drvdata(dev); - struct cppi41_channel *c, *_c; + struct cppi41_channel *c; unsigned long flags; + atomic_set(&cdd->active, 1); + spin_lock_irqsave(&cdd->lock, flags); - list_for_each_entry_safe(c, _c, &cdd->pending, node) { - push_desc_queue(c); + while (!list_empty(&cdd->pending)) { + c = list_first_entry(&cdd->pending, + struct cppi41_channel, + node); list_del(&c->node); + spin_unlock_irqrestore(&cdd->lock, flags); + push_desc_queue(c); + spin_lock_irqsave(&cdd->lock, flags); } spin_unlock_irqrestore(&cdd->lock, flags);