Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966253AbcKXPVK (ORCPT ); Thu, 24 Nov 2016 10:21:10 -0500 Received: from smtp5-g21.free.fr ([212.27.42.5]:51014 "EHLO smtp5-g21.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966014AbcKXPVG (ORCPT ); Thu, 24 Nov 2016 10:21:06 -0500 Subject: Re: Tearing down DMA transfer setup after DMA client has finished To: Mans Rullgard Cc: dmaengine@vger.kernel.org, Vinod Koul , Linus Walleij , Dan Williams , LKML , Linux ARM , Jon Mason , Mark Brown , Lars-Peter Clausen , Lee Jones , Laurent Pinchart , Arnd Bergmann , Maxime Ripard , Dave Jiang , Peter Ujfalusi , Bartlomiej Zolnierkiewicz , Sebastian Frias , Thibaud Cornic , Russell King References: <58356EA8.2010806@free.fr> <58358E79.5050404@free.fr> <5836C69A.3030309@free.fr> From: Mason Message-ID: <58370530.5080605@free.fr> Date: Thu, 24 Nov 2016 16:20:16 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0 SeaMonkey/2.40 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2095 Lines: 58 On 24/11/2016 15:17, M?ns Rullg?rd wrote: > Mason wrote: > >> [ 35.085854] SETUP DMA >> [ 35.088272] START NAND TRANSFER >> [ 35.091670] tangox_dma_pchan_start from tangox_dma_irq >> [ 35.096882] tango_dma_callback from vchan_complete >> [ 45.102513] DONE FAKE SPINNING >> >> So the IRQ rolls in, the ISR calls tangox_dma_pchan_start, >> which calls tangox_dma_pchan_detach to tear down the sbox >> setup; and only sometime later does the DMA framework call >> my callback function. > > Yes, I realised this soon after I said it. The dma driver could be > rearranged to make it work though. There is a way to make the tasklet run and invoke the callback before the interrupt service routine proceeds? Can you say more about this? >> So far, the work-arounds I've tested are: >> >> 1) delay sbox tear-down by 10 ?s in tangox_dma_pchan_detach. >> 2) statically setup sbox in probe, and never touch it henceforth. >> >> WA1 is fragile, it might break for devices other than NFC. >> WA2 is what I used when I wrote the NFC driver. >> >> Can tangox_dma_irq() be changed to have the framework call >> the client's callback *before* tangox_dma_pchan_start? >> >> (Thinking out loud) The DMA_PREP_INTERRUPT requests that the >> DMA framework invoke the callback from tasklet context, >> maybe a different flag DMA_PREP_INTERRUPT_EX can request >> calling the call-back directly from within the ISR? >> >> (Looking at existing flags) Could I use DMA_CTRL_ACK? >> Description sounds like some kind hand-shake between >> client and dmaengine. >> >> Grepping for DMA_PREP_INTERRUPT, I don't see where the framework >> checks that flag to spawn the tasklet? Or is that up to each >> driver individually? > > Those flags all have defined meanings and abusing them for other things > is a bad idea. As far as possible, device drivers should work with any > dma driver. I was asking about introducing a new flag, not abusing existing flags. (I don't understand the semantics of DMA_CTRL_ACK.) (FWIW, both the NFC and the MBUS agent are custom designs, not third-party IP blocks.) Regards.