Received: by 10.192.165.156 with SMTP id m28csp656965imm; Fri, 13 Apr 2018 05:48:19 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+6AZtIRJFIotMvA7lCDOzrlqJpWTBduDaLDC95jEdhZtRTIm+h2DiaP23gOJTHjhsqmnfM X-Received: by 10.98.160.92 with SMTP id r89mr11299157pfe.235.1523623699396; Fri, 13 Apr 2018 05:48:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523623699; cv=none; d=google.com; s=arc-20160816; b=Farx2dUlODmWEiE8CRLJATsV4x/kxc002B0t4IyVp4L70oa8Hb1yvpwGnB6sG3VtS9 lX5eIa6uUWKHhD7N28wEH0jsYh/MXAKoLZLU2TGRV7KH5UvG739V0KWlycN0nfvBVlqo cEJOHFduobRlgHAL7S5Bsk7idjdQ+QCmUOdfU6kE4A6NNBaUyjCVQ+WVnR/WJWR+FBZ+ H3KOrO1O8QKyIrozE4gsAMRGOqpaBN5GRhj+P91UMNdug57EnqPhYu1HCxSDo4vXS/q1 bgY2EhcpSEzR/8GC5YznNiwi8ev0BO4MLarNI0CWFJu2A/KJXpjEIYOUdh/FjgzUgz6W kkgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:arc-authentication-results; bh=mMJyaR7gH1qTsjVdllmzevlpwei2bbde2WKe/nQgzk4=; b=pC60fimUxYUufA7BWHPQDgvYA0hBXr0SgrpocAO4fMOPfuPgnPyOUfthgkqk8l+NWh 6CMDCeqq9QKU2j1Iqk9AH5xF3LP5wqAqUuwPHGg91Frbvvnp3HKLUd7R0YVlMD1WCMX2 pItwvV5wveBlQP+n0F/GavGkG35XQAkzgwGleY02sCE8VJGJ/pjCg2uzAZUyH4nA0u3c /GltMjBS0nKI4z2kEJrT9GQpTiYIoUn06c8Ql+k2v12diHoPg6s37hKXpp1nu2XV61Ij PoQ5gHTZAVIl38aOB6KqQGh9MKi39HlBFqiyevLSQV5tYv0fUUKY3c5SK8nK9gbFsLmh M1GQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y101-v6si5460240plh.188.2018.04.13.05.48.05; Fri, 13 Apr 2018 05:48:19 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754857AbeDMMbH (ORCPT + 99 others); Fri, 13 Apr 2018 08:31:07 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:38822 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753981AbeDMMbG (ORCPT ); Fri, 13 Apr 2018 08:31:06 -0400 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w3DCTLlA014107; Fri, 13 Apr 2018 14:30:43 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2h9fwr55r2-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 13 Apr 2018 14:30:43 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 863533F; Fri, 13 Apr 2018 12:30:42 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node2.st.com [10.75.127.14]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 646A1282F; Fri, 13 Apr 2018 12:30:42 +0000 (GMT) Received: from [10.201.23.236] (10.75.127.50) by SFHDAG5NODE2.st.com (10.75.127.14) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 13 Apr 2018 14:30:41 +0200 Subject: Re: [PATCH v2 1/2] dmaengine: stm32-mdma: align TLEN and buffer length on burst To: Robin Murphy , Vinod Koul , Maxime Coquelin , Alexandre Torgue , Dan Williams , "M'boumba Cedric Madianga" , , , References: <1523457879-9869-1-git-send-email-pierre-yves.mordret@st.com> <1523457879-9869-2-git-send-email-pierre-yves.mordret@st.com> <9a2a267c-2b0b-0d6a-c762-47e7d37f84ea@arm.com> <22bd0af7-9820-57c5-9215-8185839d7d27@st.com> <7ab2cfcd-07ed-e380-727a-727e78cc0336@arm.com> From: Pierre Yves MORDRET Message-ID: <847f092a-d1f9-8902-e1ae-f65dc2f0db7c@st.com> Date: Fri, 13 Apr 2018 14:30:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <7ab2cfcd-07ed-e380-727a-727e78cc0336@arm.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.75.127.50] X-ClientProxiedBy: SFHDAG5NODE2.st.com (10.75.127.14) To SFHDAG5NODE2.st.com (10.75.127.14) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-04-13_05:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/13/2018 01:09 PM, Robin Murphy wrote: > On 13/04/18 10:45, Pierre Yves MORDRET wrote: >> Hi Robin >> >> On 04/11/2018 05:14 PM, Robin Murphy wrote: >>> On 11/04/18 15:44, Pierre-Yves MORDRET wrote: >>>> Both buffer Transfer Length (TLEN if any) and transfer size have to be >>>> aligned on burst size (burst beats*bus width). >>>> >>>> Signed-off-by: Pierre-Yves MORDRET >>>> --- >>>> Version history: >>>> v1: >>>> * Initial >>>> v2: >>>> --- >>>> --- >>>> drivers/dma/stm32-mdma.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/dma/stm32-mdma.c b/drivers/dma/stm32-mdma.c >>>> index daa1602..fbcffa2 100644 >>>> --- a/drivers/dma/stm32-mdma.c >>>> +++ b/drivers/dma/stm32-mdma.c >>>> @@ -413,7 +413,7 @@ static u32 stm32_mdma_get_best_burst(u32 buf_len, u32 tlen, u32 max_burst, >>>> u32 best_burst = max_burst; >>>> u32 burst_len = best_burst * width; >>>> >>>> - while ((burst_len > 0) && (tlen % burst_len)) { >>>> + while ((burst_len > 0) && (((tlen | buf_len) & (burst_len - 1)) != 0)) { >>>> best_burst = best_burst >> 1; >>>> burst_len = best_burst * width; >>>> } >>> >>> FWIW, doesn't that whole loop come down to just: >>> >>> burst_len = min(ffs(tlen | buf_len), max_burst * width); >> >> No sure it ends as expected. or I miss something or don't understand this statement >> I tried with "relevant value" : i.e. best_burst = 32, Tlen=128(default) and >> buf_len = 64, width= 4. This statements gets me something wrong output => 7 >> instead of 16 * 4. >> I doubt :) > > Heh, seems I confused myself halfway through and started thinking > max_burst and width were the exponents x rather than the values 2^x... > > A more representative guess should be: > > min(1 << __ffs(tlen | buf_len), max_burst * width); > > but the general point I was trying to make is that a loop checking > whether the bottom n bits of something are zero for different values of > n is unnecessary when n can simply be calculated directly*. > > Robin. Got the point. I figure how to compute this value with __ffs. Your last statement doesn't provide the good value, but the spirit is here. I just have to adjust with what I want. Thx > > > * in the case of this "just the lowest set bit" idiom there's also the > shift-free ((x & (x - 1)) ^ x), but as well as being unreadable it's > generally less efficient than (1 << __ffs(x)) for most modern ISAs. >