Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp343871imm; Wed, 29 Aug 2018 01:13:49 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYLKUerjE/E31eMrV2AbDLUM31/dZ491LcqUtKeM1vP6i9wBYn8RUow7V2kpnYcwmdwizzD X-Received: by 2002:a62:c182:: with SMTP id i124-v6mr4823077pfg.248.1535530429301; Wed, 29 Aug 2018 01:13:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535530429; cv=none; d=google.com; s=arc-20160816; b=Y3nvTqGC9zZqjazSIkv2kKtEwv5SzsbVIlXCiRLZ0y2R9+uJawFIjdWkH/qR1PbJJu p4wFu4ddw6XS4b0VxtKljPljLP7Wq/3WWvYDHPNdR4i72zz0mq801yCtE0WBUo/GS01t x4Zj2oy7VqwICD9VPP7YAPXYHE+rdrEwPobPtkxEmx+0XLB5G9ACyQJSl48ZWZPIY9PF UK0Q6bkcnFCT/T6R7tJRnWMx+PVRiVRKg4S59w0Wt1ztuY70yMyjfTTJ4mZQnY+jpUdS nAZeXXRRZYoObMbAfIdjcUe6l6QZg9Ow1iiRTXT+NloFnxJaDjjkNq/lo1WMJ99Jf3Qa xe5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :reply-to:in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=+X4vZrOUG9VHHivnmMqXxW5mUMhb8mSo6pBXuDSjZU4=; b=GwDvz9OyoYJz+nGwWgmQFnG5pxCaUV/JU0UcXXWqvEE8e/bWadgYY8DaU4uLqLF3/c u1Bcj5gP14Wua2teagjwhbMHpT4/QGUZwU7rIGy6ZIkQEqWSUQPjP+avOZx2DFCPtqNK Qo8QAagaVE5lnsbLLD86m4Mxy2clsjO7dBl7HF0LVNG5GVtlDcVlVaIC9Gsnx7BL3wM2 S5K1Qr1/90SnZSMSnW5bOY5oNYuNOXXWwnFoPHneTTKnGFSJUOs9U5OizJrBr+gc0UBy usU+H9HhxRdvhsxzpFAXf1dc1V+Dob4V7uRnGnST24W/k+9KsKSA5jHj47bYmWGB7BII ZXGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="HaW/Xtkp"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f62-v6si3225011pfg.35.2018.08.29.01.13.31; Wed, 29 Aug 2018 01:13:49 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b="HaW/Xtkp"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727399AbeH2MIC (ORCPT + 99 others); Wed, 29 Aug 2018 08:08:02 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:52371 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727198AbeH2MIB (ORCPT ); Wed, 29 Aug 2018 08:08:01 -0400 Received: by mail-wm0-f67.google.com with SMTP id y139-v6so4283653wmc.2; Wed, 29 Aug 2018 01:12:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=+X4vZrOUG9VHHivnmMqXxW5mUMhb8mSo6pBXuDSjZU4=; b=HaW/XtkpgB2lcl4YDhc7adJ88Ff/MF+5VsWo7ZKb7q+4LO72Mmc2woRaDMfgRLLCHU GuVejlKLl02eZuRRQ6nXIcuaNxojApw2dqQsRue+pNafNCJxC4WfScXkwISBDIqN03NA lkb9jer7Ft5SnAdTXpBAVjbEISe3Aw6EA87Lf4indVD6tSBPjV23FvbJFvyetFvaaDKu vIsraXAPwNA7p5Y2X6mMSRvHQ5PEnDKQEZCraNddX30v5Z5MCAnvpTuDk79DZyPvFpQu CO4n5fxKrcCPW9mJfdLwx9q3ySZhXTAoOLoh8KKJHl8F7etNp0GCk7GKn563SjrNjpnf n28Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=+X4vZrOUG9VHHivnmMqXxW5mUMhb8mSo6pBXuDSjZU4=; b=CUHNlsH4pHzQjfct96cMT+13hhp+jvoRaGndXpbX9DBkrigTRkZvl+BShwA8QkwgkB T3R9/ZU7DW3+0HQg+Q4h14MhgURFV/xt3MRrbuXiJ/38YEwnFD6/zlEYblc1EQOHCxOs 9w8L2rZJSOAMh3z1vaeZZahhkG0VR4r5FScmQSHepTk9Bhq//kvFPLh6BYqCf2nrUaX8 TduoKo3VfmplnJURr8mqI9zbMAMyBrgW7f4YUve74u1QeDG3IRfLl9V15vbfVvelihXI zj/qVp+OrZ943PRllMY1mndBw4pbD/wl6UOtP0TgmPXHswTdacUVoK4r4NePmr4MU/H7 mqAA== X-Gm-Message-State: APzg51DuiIKXbExK+f2gxrohgcVZOASZ4mlzrNL5dgdxXA1v5/jHsvel 7pscFTNxe8zc5v/A7Gx1dGDOtI0+jwNC1i5Qju8= X-Received: by 2002:a1c:4c0e:: with SMTP id z14-v6mr3729433wmf.89.1535530339092; Wed, 29 Aug 2018 01:12:19 -0700 (PDT) MIME-Version: 1.0 References: <20180802141012.19970-1-andrea.merello@gmail.com> <20180802141012.19970-2-andrea.merello@gmail.com> <20180827053002.GT2388@vkoul-mobl> In-Reply-To: <20180827053002.GT2388@vkoul-mobl> Reply-To: andrea.merello@gmail.com From: Andrea Merello Date: Wed, 29 Aug 2018 10:12:06 +0200 Message-ID: Subject: Re: [PATCH v4 2/7] dmaengine: xilinx_dma: in axidma slave_sg and dma_cylic mode align split descriptors To: Vinod Cc: dan.j.williams@intel.com, michal.simek@xilinx.com, appana.durga.rao@xilinx.com, dmaengine@vger.kernel.org, v4-000linux-arm-kernel@lists.infradead.org, linux-kernel , Rob Herring , Mark Rutland , devicetree , Radhey Shyam Pandey Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 27, 2018 at 7:30 AM Vinod wrote: > > On 02-08-18, 16:10, Andrea Merello wrote: > > s/cylic/cyclic in patch title OK > > Whenever a single or cyclic transaction is prepared, the driver > > could eventually split it over several SG descriptors in order > > to deal with the HW maximum transfer length. > > > > This could end up in DMA operations starting from a misaligned > > address. This seems fatal for the HW if DRE is not enabled. > > DRE? Stands for "Data Realignment Engine". I will add this string nearby the acronym.. > > > > This patch eventually adjusts the transfer size in order to make sure > > all operations start from an aligned address. > > > > Cc: Radhey Shyam Pandey > > Signed-off-by: Andrea Merello > > Reviewed-by: Radhey Shyam Pandey > > --- > > Changes in v2: > > - don't introduce copy_mask field, rather rely on already-esistent > > copy_align field. Suggested by Radhey Shyam Pandey > > - reword title > > Changes in v3: > > - fix bug introduced in v2: wrong copy size when DRE is enabled > > - use implementation suggested by Radhey Shyam Pandey > > Changes in v4: > > - rework on the top of 1/6 > > --- > > drivers/dma/xilinx/xilinx_dma.c | 22 ++++++++++++++++++---- > > 1 file changed, 18 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c > > index a3aaa0e34cc7..aaa6de8a70e4 100644 > > --- a/drivers/dma/xilinx/xilinx_dma.c > > +++ b/drivers/dma/xilinx/xilinx_dma.c > > @@ -954,15 +954,28 @@ static int xilinx_dma_alloc_chan_resources(struct dma_chan *dchan) > > > > /** > > * xilinx_dma_calc_copysize - Calculate the amount of data to copy > > + * @chan: Driver specific DMA channel > > * @size: Total data that needs to be copied > > * @done: Amount of data that has been already copied > > * > > * Return: Amount of data that has to be copied > > */ > > -static int xilinx_dma_calc_copysize(int size, int done) > > +static int xilinx_dma_calc_copysize(struct xilinx_dma_chan *chan, > > + int size, int done) > > please align with opening brace OK > > { > > - return min_t(size_t, size - done, > > + size_t copy = min_t(size_t, size - done, > > XILINX_DMA_MAX_TRANS_LEN); > > + > > + if ((copy + done < size) && > > + chan->xdev->common.copy_align) { > > + /* > > + * If this is not the last descriptor, make sure > > + * the next one will be properly aligned > > + */ > > + copy = rounddown(copy, > > + (1 << chan->xdev->common.copy_align)); > > + } > > + return copy; > > } > > > > /** > > @@ -1804,7 +1817,7 @@ static struct dma_async_tx_descriptor *xilinx_dma_prep_slave_sg( > > * Calculate the maximum number of bytes to transfer, > > * making sure it is less than the hw limit > > */ > > - copy = xilinx_dma_calc_copysize(sg_dma_len(sg), > > + copy = xilinx_dma_calc_copysize(chan, sg_dma_len(sg), > > sg_used); > > hw = &segment->hw; > > > > @@ -1909,7 +1922,8 @@ static struct dma_async_tx_descriptor *xilinx_dma_prep_dma_cyclic( > > * Calculate the maximum number of bytes to transfer, > > * making sure it is less than the hw limit > > */ > > - copy = xilinx_dma_calc_copysize(period_len, sg_used); > > + copy = xilinx_dma_calc_copysize(chan, > > + period_len, sg_used); > > hw = &segment->hw; > > xilinx_axidma_buf(chan, hw, buf_addr, sg_used, > > period_len * i); > > -- > > 2.17.1 > > -- > ~Vinod