From patchwork Mon Jan 9 17:03:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 90538 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp177043qgi; Mon, 9 Jan 2017 09:03:50 -0800 (PST) X-Received: by 10.84.212.2 with SMTP id d2mr198424662pli.24.1483981429844; Mon, 09 Jan 2017 09:03:49 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k3si6466091pgp.76.2017.01.09.09.03.49; Mon, 09 Jan 2017 09:03:49 -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 S1758434AbdAIRDr (ORCPT + 4 others); Mon, 9 Jan 2017 12:03:47 -0500 Received: from mail-wm0-f48.google.com ([74.125.82.48]:36819 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761122AbdAIRDn (ORCPT ); Mon, 9 Jan 2017 12:03:43 -0500 Received: by mail-wm0-f48.google.com with SMTP id c85so104143384wmi.1 for ; Mon, 09 Jan 2017 09:03:42 -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=PWxMrbXJP6PA3U38WjrVoQCcjVO2QYPTLNWu+GA89pI=; b=2SGMzDfbKSYWDnxiiLy4h5QZlDWdicSTXk/1wfs7+qcgz2eOeaQrrgkeoGdsH5fOlW kW0V3Q9v22JHNjjF4uT9Dn7I6qJjeQo5DmGSzIf++xH/pGTvcNA/hgyiUpEoFKbVbLQH oS8svinWTtB9wUXBOLZwukT7MDDbpjym/vkgowijgoxOdR5lFr8ADXHjmexTuoUwiJwC LBYCqq+CZpoEBwOjqj4L44y8esMcoTncRiDkYUzVO3jebttSdVsSC62NKF7djM7lC56y A+dAzomFv7JP1+Xr8qGEXzzAfU7tVHX84gptXtbcE7FL29OieulrnHUHPuVIGohLs55Z F6Zg== 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=PWxMrbXJP6PA3U38WjrVoQCcjVO2QYPTLNWu+GA89pI=; b=m6rF1K04Waj5bm143pfbe30Lktx3VEyF/eox7M1h9WAvqqSLVJIVZ8RCj0W7WhWJN7 dfyqynfRyPX+2RbvSwg3Mxt5OHaJc3fUrMUSPNE+Jhr/rjfhER5e1qt/GJlHh+4er1Ye 84V7fSFVXvc7ioWtApdcDkEcBexdWkWDOtdS3pdywZY4LUsa7K2GpZaXmbcC5dzTNHHE hy7mRDnIi1lhL///iTClsJBLuE4gwRqg9sH+q1jRu6cZR2EKK+/tJ4BZWE8Yj12clQ/F VQ6G2RWLc1/FdUn3yBWo6FQuEW8S3k/PBKLVaw6m7KO4TTAJnU2L75QxtkS+fI1A13s2 SixQ== X-Gm-Message-State: AIkVDXI6VJtDuABT3YDQ+2J9z0jEkeXsNAEgB1Vtc2HtRWbGtJWVvMpx8wrP9pNsO7jSDkDb X-Received: by 10.28.128.150 with SMTP id b144mr694824wmd.119.1483981421774; Mon, 09 Jan 2017 09:03:41 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id l67sm19775913wmf.20.2017.01.09.09.03.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Jan 2017 09:03:41 -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, tony@atomide.com, linux-omap@vger.kernel.org, andy.shevchenko@gmail.com, Alexandre Bailon Subject: [PATCH v2 1/2] dmaengine: cppi41: Fix list not empty warning on runtime suspend Date: Mon, 9 Jan 2017 18:03:36 +0100 Message-Id: <20170109170337.6957-2-abailon@baylibre.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170109170337.6957-1-abailon@baylibre.com> References: <20170109170337.6957-1-abailon@baylibre.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@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-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 d5ba43a..025fee4 100644 --- a/drivers/dma/cppi41.c +++ b/drivers/dma/cppi41.c @@ -471,6 +471,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); @@ -482,7 +484,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);