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: 89871 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp8556849qgi; Wed, 4 Jan 2017 08:10:31 -0800 (PST) X-Received: by 10.99.115.76 with SMTP id d12mr122579655pgn.56.1483546231227; Wed, 04 Jan 2017 08:10:31 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h4si37933plb.248.2017.01.04.08.10.31; Wed, 04 Jan 2017 08:10:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-usb-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-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031434AbdADQK3 (ORCPT + 4 others); Wed, 4 Jan 2017 11:10:29 -0500 Received: from mail-wm0-f52.google.com ([74.125.82.52]:37918 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965501AbdADQK1 (ORCPT ); Wed, 4 Jan 2017 11:10:27 -0500 Received: by mail-wm0-f52.google.com with SMTP id k184so264879456wme.1 for ; Wed, 04 Jan 2017 08:09: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=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=ufFiUe6KxjIVgDIQxmEvR46nkwCz+T0RpJCAIWYojAXNhgl49G3SrjAI1ZD0/JHm7L pAEvJ4pYqA1XK5y6A+C7BmvjN7mb4H3JIy/iyJSad3Ry2mfSaOkw45VCi/HQWpyYDibM aautoLJ/HV4kq4J79GyiqVhaGFPM8BJ0oDdX9F34WCt3ixOp+c7faX3fKbRdU2tQ/qz8 N/DXhThrCYAm/Yxnyexikk2KufCf6MlagGzdUvjeIbPJyZtp2HRXUmRHbHIyTfCQfaac +P/RZ9bisWo95n0jf6/0jS/EYSkZV6y+q7mc4TKCxoUA5aIg8QGJC/LbeXOJljEcUA46 6KpA== X-Gm-Message-State: AIkVDXLuBUwne8fU6os+gFkKkC9gyCBYSxTjWiyP2doeuwmT/TBC+CIw4UjPPBm5811W3mYq 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: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 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(-) -- 2.10.2 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" 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 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);