From patchwork Wed Jan 4 16:03:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 9497053 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 95BF2606B4 for ; Wed, 4 Jan 2017 16:12:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84FE52808C for ; Wed, 4 Jan 2017 16:12:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7568B2808F; Wed, 4 Jan 2017 16:12:34 +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 1464D2807E for ; Wed, 4 Jan 2017 16:12:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936541AbdADQMb (ORCPT ); Wed, 4 Jan 2017 11:12:31 -0500 Received: from mail-wm0-f52.google.com ([74.125.82.52]:38539 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934540AbdADQMa (ORCPT ); Wed, 4 Jan 2017 11:12:30 -0500 Received: by mail-wm0-f52.google.com with SMTP id k184so264955858wme.1 for ; Wed, 04 Jan 2017 08:12:29 -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=PMb5irDdDG6NB1BfV6rlr3Jh6udk93jtGCxMEtmSre8=; b=WaaqTyqvvrEJWObF3zha/fNNbqK3EQPrTjjEsdgpzqUm/bzo9krydvyPxi3T8V3m+L IELeyCNWAyKgoTAPfxVmUNbjNDmRR3IYYugeHkUk7HxVC3FUUWqtfV9e+pNSisw0d9CS Xez4SX+++FM064pCjGiWkHE+7juPwmUkCai6E50iif7tKbIFFhnFGL+RjQrvNV5Can6J WBSrSXhOG/INOcTfuipouUxbsdwbVIGAQz41j1qhVMqcdt7MmWnz5GVPaG4I8BwWNe9+ LM6ckcJSG5vRP3nnMG1EBMK1Rm5GJQlYbb75JFlGlrAr5Ho2DVwA/8H65a2C8XBfhMjf 9QLg== 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=PMb5irDdDG6NB1BfV6rlr3Jh6udk93jtGCxMEtmSre8=; b=Y8O8lbvAmM35/ssjJ0U+Cwylaeq6jAuGwUviZljVnc6IGt1cJpZBTjyRDdPPuKcZi+ G1uHZI1Mzde110764WhfqZ8R4t5r/gK09AKyWkoj8A/vpe6IAVnr5yec2vGCB+kMpnQa 8FeZ31USwislLqTcn/3fq9MC6//VAfiVZM4rpq6TuTArKD3IfszY+bqFb+Q/RItimDpM 25NHW+q+ZDYLP1Q395jkrrRgw9rxThWXuL0OVZiYP8Djve8TCkFKajwUJS+DUiMin70A DWbyI6Xx4ZvZL2ue2/hxvmRpXyfvPC8kCZSth4Pfjus0lpryo4YBeNe5aX3uE2dXIU3L rUvA== X-Gm-Message-State: AIkVDXJxz4lQQ/4J2XTXoNGPBEPuIpSDOdYRRWrTpX6+ruQRZypvfbBLMJFMLuimB5ATUJoO X-Received: by 10.28.47.15 with SMTP id v15mr59657769wmv.76.1483545787852; Wed, 04 Jan 2017 08:03:07 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id 14sm95826547wmk.1.2017.01.04.08.03.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 Jan 2017 08:03:07 -0800 (PST) From: Alexandre Bailon To: vinod.koul@intel.com Cc: dmaengine@vger.kernel.org, linux-usb@vger.kernel.org, nsekhar@ti.com, khilman@baylibre.com, ptitiano@baylibre.com, Alexandre Bailon Subject: [PATCH 1/2] dmaengine: cppi41: Fix list not empty warning on runtime suspend Date: Wed, 4 Jan 2017 17:03:00 +0100 Message-Id: <20170104160301.22406-2-abailon@baylibre.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170104160301.22406-1-abailon@baylibre.com> References: <20170104160301.22406-1-abailon@baylibre.com> Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Sometime, a transfer may not be queued due to a race between runtime pm and cppi41_dma_issue_pending(). Sometime, cppi41_runtime_resume() may be interrupted right before to update device PM state to RESUMED. When it happens, if a new dma transfer is issued, because the device is not in active state, the descriptor will be added to the pendding list. But because the descriptors in the pendding list are only queued to cppi41 on runtime resume, the descriptor will not be queued. On runtime suspend, the list is not empty, which is causing a warning. Queue the descriptor if the device is active or resuming. Signed-off-by: Alexandre Bailon --- drivers/dma/cppi41.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c index 70d2bf7..dfc880a 100644 --- a/drivers/dma/cppi41.c +++ b/drivers/dma/cppi41.c @@ -545,6 +545,8 @@ static void cppi41_dma_issue_pending(struct dma_chan *chan) { struct cppi41_channel *c = to_cpp41_chan(chan); struct cppi41_dd *cdd = c->cdd; + unsigned long flags; + bool active; int error; error = pm_runtime_get(cdd->ddev.dev); @@ -556,7 +558,21 @@ static void cppi41_dma_issue_pending(struct dma_chan *chan) return; } - if (likely(pm_runtime_active(cdd->ddev.dev))) + active = pm_runtime_active(cdd->ddev.dev); + if (!active) { + /* + * Runtime resume may be interrupted before runtime_status + * has been updated. Test if device has resumed. + */ + if (error == -EINPROGRESS) { + spin_lock_irqsave(&cdd->lock, flags); + if (list_empty(&cdd->pending)) + active = true; + spin_unlock_irqrestore(&cdd->lock, flags); + } + } + + if (likely(active)) push_desc_queue(c); else pending_desc(c);