Received: by 10.192.165.156 with SMTP id m28csp734480imm; Fri, 13 Apr 2018 07:00:46 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/QVwseXOai9bWP/P+NjYFgWTTnoHVgwQVycCBVnirDGB7MB3fSULcx2ULcMsjxDHwhRudk X-Received: by 2002:a17:902:8606:: with SMTP id f6-v6mr5381127plo.258.1523628046738; Fri, 13 Apr 2018 07:00:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523628046; cv=none; d=google.com; s=arc-20160816; b=EgKOsHgTmWTjaonaUNc3h4D9fJuK0IjiaJiSaSwhNHGTY2XTYbTIQnU7lclxGOHI6J fbS7L16Pte64+KQJgFlvTUrWlh+Q4lpQv8tVAhVyu8wwVjDkgx0ONTO73iVcF7Vrnw2q A17xBMV+ZWdtUEWvQncL89pNJVpRDyMryyfRUMqITyXsTqMAGXZiWNAHQ5Zq390DAMk3 UJo+/qGfZ9OxzkpXlSdZDZyELzFTWnJTVLNOEXjgTlCz15lCwm9fQGLHBHouIQz6VfrU iBAbSFfhfhDzU2791sLaHkDusJQKV++Tz09rLjpV4eObi6kJDFUMxuGDmsvfbPvKK0zh P3jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=zUq449mYhJpOpIOedPdzjNqNY3d//O6KSnCzUR6a7/I=; b=JLGa/hUek2AR+2c+yUnPZwSsUYUcqcopddALidMHqabRZhr4owMlbB9A4MFujQv7mh AZzvLgaiAEXWJn3uPovkPZ6aesw0vTFLPwwmjwlUdxhe06+SrUMxYFofHQi8xFxh9j6q iLaDZmst0uJCR5Mo/+rDVzq1KZS08mC+wzAXHR2w2WpPSnCqb/gMv+/D2V/30/eextNW 0HSYGH62ayrzd5CGwpQwbGRlJQhH68SQkeqLwKnHOeBsCnYE3QjRXmRifjrwEecxL/2H P8ESDP8c15RCXWlYmXgnj4XYsy0WQVW8GDrFybuP2YqrGg1t1RgO2hc2J8wPtzbSoh50 Hd6g== 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 b19si4658290pfd.254.2018.04.13.07.00.30; Fri, 13 Apr 2018 07:00:46 -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 S1754329AbeDMNwk (ORCPT + 99 others); Fri, 13 Apr 2018 09:52:40 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:26197 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754285AbeDMNwh (ORCPT ); Fri, 13 Apr 2018 09:52:37 -0400 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w3DDnJLX003986; Fri, 13 Apr 2018 15:52:19 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2haug7ru3u-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 13 Apr 2018 15:52:19 +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 7BD9459; Fri, 13 Apr 2018 13:52:18 +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 5E0D52A8F; Fri, 13 Apr 2018 13:52:18 +0000 (GMT) Received: from localhost (10.75.127.44) by SFHDAG5NODE2.st.com (10.75.127.14) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 13 Apr 2018 15:52:17 +0200 From: Pierre-Yves MORDRET To: Vinod Koul , Maxime Coquelin , Alexandre Torgue , Dan Williams , "M'boumba Cedric Madianga" , , , CC: Pierre-Yves MORDRET Subject: [PATCH v3 1/2] dmaengine: stm32-mdma: align TLEN and buffer length on burst Date: Fri, 13 Apr 2018 15:52:12 +0200 Message-ID: <1523627533-7184-2-git-send-email-pierre-yves.mordret@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523627533-7184-1-git-send-email-pierre-yves.mordret@st.com> References: <1523627533-7184-1-git-send-email-pierre-yves.mordret@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG5NODE3.st.com (10.75.127.15) 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 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: v3: * Get rid of while loop in favor of computed values --- --- drivers/dma/stm32-mdma.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/dma/stm32-mdma.c b/drivers/dma/stm32-mdma.c index daa1602..4c7634c 100644 --- a/drivers/dma/stm32-mdma.c +++ b/drivers/dma/stm32-mdma.c @@ -410,13 +410,10 @@ static enum dma_slave_buswidth stm32_mdma_get_max_width(dma_addr_t addr, static u32 stm32_mdma_get_best_burst(u32 buf_len, u32 tlen, u32 max_burst, enum dma_slave_buswidth width) { - u32 best_burst = max_burst; - u32 burst_len = best_burst * width; + u32 best_burst; - while ((burst_len > 0) && (tlen % burst_len)) { - best_burst = best_burst >> 1; - burst_len = best_burst * width; - } + best_burst = min((u32)1 << __ffs(tlen | buf_len), + max_burst * width) / width; return (best_burst > 0) ? best_burst : 1; } -- 2.7.4