Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932147AbbFSIFB (ORCPT ); Fri, 19 Jun 2015 04:05:01 -0400 Received: from mail-wi0-f179.google.com ([209.85.212.179]:32857 "EHLO mail-wi0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752772AbbFSIEs (ORCPT ); Fri, 19 Jun 2015 04:04:48 -0400 From: Torsten Fleischer To: Cyrille Pitchen Cc: nicolas.ferre@atmel.com, ludovic.desroches@atmel.com, dan.j.williams@intel.com, vinod.koul@intel.com, dmaengine@vger.kernel.org, jiri.prchal@aksignal.cz, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, torfl6749@gmail.com Subject: Re: [PATCH linux-next 1/1] dmaengine: at_hdmac: fix residue computation Date: Fri, 19 Jun 2015 10:04:44 +0200 Message-ID: <1922467.ZSxkKTyNbQ@linux-1fbo.site> User-Agent: KMail/4.14.8 (Linux/3.16.7-21-desktop; KDE/4.14.8; x86_64; ; ) In-Reply-To: <2899583.NPB62C1E0l@linux-1fbo.site> References: <381ecf2427a6aae4b7109d930121df9f36aef81e.1434380729.git.cyrille.pitchen@atmel.com> <2899583.NPB62C1E0l@linux-1fbo.site> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1949 Lines: 59 On Tuesday 16 June 2015 at 18:11:56 Torsten Fleischer wrote: > On Monday 15 June 2015 at 17:17:51 Cyrille Pitchen wrote: [...] > > @@ -365,16 +371,13 @@ static int atc_get_bytes_left(struct dma_chan *chan, > > dma_cookie_t cookie) } > > > > /* > > > > - * For the last descriptor in the chain we can calculate > > + * For the current descriptor in the chain we can calculate > > > > * the remaining bytes using the channel's register. > > > > - * Note that the transfer width of the first and last > > - * descriptor may differ. > > > > */ > > > > - if (!desc->lli.dscr) > > - ret = atc_calc_bytes_left_from_reg(ret, atchan, desc); > > + ret = atc_calc_bytes_left_from_reg(ret, atchan); > > I see two issues here. > > First this always returns the number if remaining bytes of the current child > transfer and not of the entire hardware linked list transfer. > Oops, I was wrong with the first issue. Please ignore this. Sorry for that. > Finally, for the calculation of the remaining bytes of a hardware linked > list the value of DSCR is used to get the current child transfer. > But regarding to a running DMA transfer, reading DSCR and CTRLA is not > atomic. If you read CTRLA after DSCR then the value may not refer to the > child transfer as read from DSCR, but to a subsequent one. > Its only safe for the first transfer where CTRLA is read before DSCR and for > the last transfer where CTRLA is read after DSCR. > > > } else { > > > > /* single transfer */ > > > > - ret = atc_calc_bytes_left_from_reg(ret, atchan, desc_first); > > + ret = atc_calc_bytes_left_from_reg(ret, atchan); > > > > } > > > > return ret; > > [...] Regards, Torsten -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/