Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4502863ybx; Mon, 4 Nov 2019 14:28:28 -0800 (PST) X-Google-Smtp-Source: APXvYqwyo96rQxab/zRNLgz4KsXhX68RepwhJ7rkwixIqxAcBd8eTMOl5DyeuDxiKGnzw+UzwNC/ X-Received: by 2002:a50:f058:: with SMTP id u24mr32847005edl.288.1572906507934; Mon, 04 Nov 2019 14:28:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572906507; cv=none; d=google.com; s=arc-20160816; b=TjxpgaBU15mt9u7Uj5KYfRT/sJx7j4G5cFVGnpJ3iCds/5eEPlFi9Z7xI533HuDHwT LlKwLxw/TLir0bmtmIcdAI2ewOFk119q4ZXgwbwTjaXadAiJUSXajmoFe4xtQpkQzJhL IPDObmAH94kddACEE1G/dAosycA3DbcWo8B1tFs1Dgge2S0F72PDY15L/RnAWoKH2fvM pjlXGHBO7B78xbciGJ4NcFC5hJmlIfx3XjwzEdINhABeVd+QFKzuxeqyiwI6996oYxJQ 5CSfFsZBrahoYmqu5fY5QZIMSkX+l0BJU0yuxNuuhTKyWkxcycDmAzKaL6SGp6p+KfZ7 7Z5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gUlYqD76TmDcf8/seZYfJhjBvV10la0LgSHSHKOrDR8=; b=prgAsq8JYZ2T1K5cJ7GIXIJ0nxIgcw2t+PYDSugImTl+t3YMSfKojQ3dLCgEwvCaEA QKDWRwALUYT5i5aWC/QFt/jerQoMIDrPyxFWOLseVbWdo6smb+FDROCBD62kxl8uODdz LxAXaJPNTlaoGaxaELZhWG6/Wqou3i9djik23v5hNJxVFmz4iOBu6j/2kEy7o5DjSh30 x236l+DUE74kNZm1V2xD9iAUHKqcxXr8wAd7ArG9xiIwf1vPqNdG1Pdm7rkIb887bS5c lIWU1sVaCesAXjjyNoPL/IRQ8DhEStgVLztGy4NRDvikpBrsantdINDk66sqzJr1yz44 FUTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="UrQaLgC/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v20si7996496edm.254.2019.11.04.14.28.05; Mon, 04 Nov 2019 14:28:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="UrQaLgC/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730053AbfKDW0I (ORCPT + 99 others); Mon, 4 Nov 2019 17:26:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:44382 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730503AbfKDVvY (ORCPT ); Mon, 4 Nov 2019 16:51:24 -0500 Received: from localhost (6.204-14-84.ripe.coltfrance.com [84.14.204.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9D4EE21850; Mon, 4 Nov 2019 21:51:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572904284; bh=a/CrEaRPI9p2L9QvfTnm1Yau+XWCrkMuGwhTOPbUtpo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UrQaLgC//uQ7xqhXEdBQYjjZHlTwCkNTtWjftk2N4yb41Fwsi5Qf/Z9RdjjxSaI5C 6tCHU533UbL6zz5PkK5ryVPKdmokAs7P3QdEyC8HnmFutxJrz5J0oJQHf6ge/Qhv+H azACpNwo4JMW1IMqnPc4fQlkNhsTX4H4KOLJbmZc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yegor Yefremov , Tony Lindgren , Vinod Koul Subject: [PATCH 4.9 50/62] dmaengine: cppi41: Fix cppi41_dma_prep_slave_sg() when idle Date: Mon, 4 Nov 2019 22:45:12 +0100 Message-Id: <20191104211953.108084720@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191104211901.387893698@linuxfoundation.org> References: <20191104211901.387893698@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tony Lindgren commit bacdcb6675e170bb2e8d3824da220e10274f42a7 upstream. Yegor Yefremov reported that musb and ftdi uart can fail for the first open of the uart unless connected using a hub. This is because the first dma call done by musb_ep_program() must wait if cppi41 is PM runtime suspended. Otherwise musb_ep_program() continues with other non-dma packets before the DMA transfer is started causing at least ftdi uarts to fail to receive data. Let's fix the issue by waking up cppi41 with PM runtime calls added to cppi41_dma_prep_slave_sg() and return NULL if still idled. This way we have musb_ep_program() continue with PIO until cppi41 is awake. Fixes: fdea2d09b997 ("dmaengine: cppi41: Add basic PM runtime support") Reported-by: Yegor Yefremov Signed-off-by: Tony Lindgren Cc: stable@vger.kernel.org # v4.9+ Link: https://lore.kernel.org/r/20191023153138.23442-1-tony@atomide.com Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman --- drivers/dma/cppi41.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) --- a/drivers/dma/cppi41.c +++ b/drivers/dma/cppi41.c @@ -586,9 +586,22 @@ static struct dma_async_tx_descriptor *c enum dma_transfer_direction dir, unsigned long tx_flags, void *context) { struct cppi41_channel *c = to_cpp41_chan(chan); + struct dma_async_tx_descriptor *txd = NULL; + struct cppi41_dd *cdd = c->cdd; struct cppi41_desc *d; struct scatterlist *sg; unsigned int i; + int error; + + error = pm_runtime_get(cdd->ddev.dev); + if (error < 0) { + pm_runtime_put_noidle(cdd->ddev.dev); + + return NULL; + } + + if (cdd->is_suspended) + goto err_out_not_ready; d = c->desc; for_each_sg(sgl, sg, sg_len, i) { @@ -611,7 +624,13 @@ static struct dma_async_tx_descriptor *c d++; } - return &c->txd; + txd = &c->txd; + +err_out_not_ready: + pm_runtime_mark_last_busy(cdd->ddev.dev); + pm_runtime_put_autosuspend(cdd->ddev.dev); + + return txd; } static void cppi41_compute_td_desc(struct cppi41_desc *d)