Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5429434imm; Tue, 18 Sep 2018 09:22:38 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYdE3+c7K3HeIKQqE2cxR6yjtz5razsEZEHvu1XNrldKgAQisD7GXf+mIWW3Kd8Dr6bG+go X-Received: by 2002:a63:f966:: with SMTP id q38-v6mr27782200pgk.213.1537287758310; Tue, 18 Sep 2018 09:22:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537287758; cv=none; d=google.com; s=arc-20160816; b=xsbUeiHae3Gq1pzeTNGC2935Acb42NJgaVgFfRNM/z9u0qjQvtwrWt+FDHTCrGz2MV /sdrk3Z9rTrGpiwuXBpexAtzuscPSdYiS3KN96B97OZ4SzDz5rBeL/r98oxrTOOkG1qX D6du/3T+XgYvTpVAStkhp2ryc8bicL+8eboTZDLHnYh+2dyC++Lv4yjKulKiJwfw/bWZ fcO0ykge9IgtObbrblXjDezUXZJTI/Dm7E8L4kAzpJsQwQMYA/NICsV70pPELbUOuSLK R7lXu4u7FEjNwEVFiaLKBKk41ApgPD/mIboiJOMhGEEC8eQktg5ZYZO9F4uYWvE7it0z YQBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=MuobFc996Ug9zPYbdWlgATsb4yzW6xdeLqJLVbrJmMQ=; b=WlWNRrzDV5O/YmxZ6l18U/1/JTn2mYNOMz3UNNeVyG2SAEHYsojT0wiJK/onMvlPGF T0+54Uksmaovu9o8RHnfNsO66ys5UraKVoeZsBrHOHjO+jY0mtplpDbKOteIvK04GpOi 2A5rBXHT2fXWZ4UynHlhSAdl3+ggr0W6T2ngftiJkMWL8DrvRwryQEUYsCS1w4C5yCht p5b8gi1r7djBBqzPPKEoFgnO3VkYy7Rb5ggtsVcOiHt2rS7DXhphyt49Z/eW1IHKbDVQ eJivSer9uGT93g/eax1NX9a8yBYXj5ukwoN8KRjMCAZXmNtJvpB8FSWkeglB8TAZjHdE mvTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tud0K7Er; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d36-v6si18076028pgm.97.2018.09.18.09.22.18; Tue, 18 Sep 2018 09:22:38 -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=@kernel.org header.s=default header.b=tud0K7Er; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730615AbeIRVyY (ORCPT + 99 others); Tue, 18 Sep 2018 17:54:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:55556 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730334AbeIRVyX (ORCPT ); Tue, 18 Sep 2018 17:54:23 -0400 Received: from localhost (unknown [209.121.128.187]) (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 819A52150B; Tue, 18 Sep 2018 16:21:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1537287665; bh=yOng9FEcz1WWqTE/jqE7taJmULEXhXYr1TsF18QSnbE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tud0K7ErDQu3NE/DhVrdXoBMFds2Y/hNMKTxx5LKxUgznkngBKGrvyCO2yt8jxzwZ +0NkXW+Ntf5CglIQiYbBbXu+Nq0h02DjxEeb5F04vOrKyuMKU5/sC5YnIZDpkwB7fi 2RQsCl8cDVTnSXCbP3GhEAacsEX8pd1gqmOtGocY= Date: Tue, 18 Sep 2018 09:21:05 -0700 From: Vinod To: Andrea Merello Cc: dan.j.williams@intel.com, michal.simek@xilinx.com, appana.durga.rao@xilinx.com, dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, devicetree@vger.kernel.org, radhey.shyam.pandey@xilinx.com Subject: Re: [PATCH v5 2/7] dmaengine: xilinx_dma: in axidma slave_sg and dma_cyclic mode align split descriptors Message-ID: <20180918162105.GC2613@vkoul-mobl> References: <20180907062502.8241-1-andrea.merello@gmail.com> <20180907062502.8241-2-andrea.merello@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180907062502.8241-2-andrea.merello@gmail.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07-09-18, 08:24, Andrea Merello wrote: > 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 (Data Realignment Engine) > is not enabled. > > 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 > Changes in v5: > - fix typo in commit title > - add hint about "DRE" meaning in commit message > --- > 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) align to preceeding line opening brace please > { > - return min_t(size_t, size - done, > + size_t copy = min_t(size_t, size - done, > XILINX_DMA_MAX_TRANS_LEN); so we can do this way in patch 1: size t copy; copy = min_t(size_t, size - done, XILINX_DMA_MAX_TRANS_LEN); return copy; and then add these here, feels like we are redoing change introduced in patch 1.. > + 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), why not keep chan in patch 1 and add only handling in patch 2, seems less churn to me.. -- ~Vinod