From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42B7CECE587 for ; Tue, 1 Oct 2019 22:03:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1CDB721A4A for ; Tue, 1 Oct 2019 22:03:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728660AbfJAWD3 (ORCPT ); Tue, 1 Oct 2019 18:03:29 -0400 Received: from muru.com ([72.249.23.125]:35072 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726521AbfJAWD2 (ORCPT ); Tue, 1 Oct 2019 18:03:28 -0400 Received: from atomide.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTPS id 5FBCC811B; Tue, 1 Oct 2019 22:03:57 +0000 (UTC) Date: Tue, 1 Oct 2019 15:03:21 -0700 From: Tony Lindgren To: Yegor Yefremov Cc: Johan Hovold , Sebastian Reichel , linux-omap@vger.kernel.org, vkoul@kernel.org, Bin Liu , linux-usb , Andrey Skvortsov , giulio.benetti@benettiengineering.com, Sebastian Andrzej Siewior , Peter Ujfalusi Subject: Re: musb: cppi41: broken high speed FTDI functionality when connected to musb directly Message-ID: <20191001220321.GK5610@atomide.com> References: <20190927155738.GF5610@atomide.com> <20190930145711.GG5610@atomide.com> <20190930152330.GH5610@atomide.com> <20190930195411.6porqtm7tlokgel3@earth.universe> <20191001080339.GF13531@localhost> <20191001164351.GJ5610@atomide.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191001164351.GJ5610@atomide.com> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Hi, * Tony Lindgren [191001 16:52]: > * Yegor Yefremov [191001 09:20]: > > I've tried to increase the autosuspend_delay_ms and to set control to > > "on" but nothing changes. Below you can see the output of my testing > > script [1] (Py2 only). As one can see, the first cycle i.e. after the > > port is open for the first time, fails. But the subsequent cycle is > > successful. If you invoke the script again, everything repeats. > > > > I've also made printk() in cppi41_run_queue() and it looks like this > > routine will be called from cppi41_dma_issue_pending() only in the > > beginning of the second test cycle. > > So sounds like for you intially cppi41_dma_issue_pending() has > !cdd->is_suspended and just adds the request to the queue. And > then cppi41_run_queue() never gets called if this happens while > we have cppi41_runtime_resume() is still running? I got it reproducable here by adding msleep(500) to the beginning of cppi41_runtime_resume() :) Otherwise I'm only able to trigger the issue maybe one out of 20 tries it seems. Turns out the first dma call done by musb_ep_program() must wait if cppi41 is PM runtime suspended. Otherwise musb_ep_program() continues with other PIO packets before the DMA transfer is started. The patch below fixes it for me with a pm_runtime_get_sync() in device_prep_slave_sg, so adding Peter and Vinod to Cc. The other way to fix this would be to just wake up cpp41 in cppi41_dma_prep_slave_sg() and return NULL so that we can have musb_ep_program() continue with PIO while cppi41 is asleep. Anyways, care to try it out and see if it fixes your issue? Regards, Tony 8< ------------------ diff --git a/drivers/dma/ti/cppi41.c b/drivers/dma/ti/cppi41.c --- a/drivers/dma/ti/cppi41.c +++ b/drivers/dma/ti/cppi41.c @@ -586,9 +586,18 @@ static struct dma_async_tx_descriptor *cppi41_dma_prep_slave_sg( enum dma_transfer_direction dir, unsigned long tx_flags, void *context) { struct cppi41_channel *c = to_cpp41_chan(chan); + struct cppi41_dd *cdd = c->cdd; struct cppi41_desc *d; struct scatterlist *sg; unsigned int i; + int error; + + error = pm_runtime_get_sync(cdd->ddev.dev); + if (error < 0) { + pm_runtime_put_noidle(cdd->ddev.dev); + + return NULL; + } d = c->desc; for_each_sg(sgl, sg, sg_len, i) { @@ -611,6 +620,9 @@ static struct dma_async_tx_descriptor *cppi41_dma_prep_slave_sg( d++; } + pm_runtime_mark_last_busy(cdd->ddev.dev); + pm_runtime_put_autosuspend(cdd->ddev.dev); + return &c->txd; } -- 2.23.0