Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1602819pxb; Mon, 11 Oct 2021 09:16:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlLrfZ4XSFjN26VZEiMyBpMJ60dShEQFwFVxvXHxB3rbuGEIzbSGQ9yXXNsHQ29zut4i36 X-Received: by 2002:a17:906:3913:: with SMTP id f19mr26544333eje.357.1633969015467; Mon, 11 Oct 2021 09:16:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633969015; cv=none; d=google.com; s=arc-20160816; b=m2sQ4pGxXpeTXbAXfu/WIaT0ZqbtXtBnsBI3f0EF/t9ohBRPhZJffOKTyiFJXoaC05 wNo/GnZloeOYAYIgfNyOITbSmRJIbkskazK/IVMi9KEsPqYpc8e/A4v+sptRIeUXxfoj NYpdTbMKI27Tqi3yhP/BYOzx+/71KgseE+uOsG5gf6P+CTEujcP5aIf1d+8lJnNka07Y PlKxtsA/obhMcVbjzIlzNKE29RNhFzrQ4+U4RFfEFPLD+1SzfJmUuBInTKafvTxpvCZO Z0wjhx5F8i7kjzBZQn3mCsUqagGj2V5zRWYeaOhzLx3aZ3Uhh4FlPAu/jJgntg95WBBn GY0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xcge6Tmp8n1Scab5wy+5ZALoDl294NFVjrwUjkjXu/Q=; b=Yej7SW20pl+xvpkMTn0MCLwgUEwTCAfcP4MXAjwuVZmRz1zO9mvdyRYpt8Ivxf55Ty 2YdACw3hWevGu8/YU329hKw4NBoxWZY7jobpna+EATJOAdMOjO/K2II84lUIhMINTUd0 MbxiMG/vFI0V0vwYc1+fJv1Mx7p9nOFk6v4Me1/c9zPdPy2A1q2qzBu2le3Lnz5PJCRv kb0FPG9vZZif/lYRUyQap4MV06rkk69lUd+70TVQeAvEk7jZs6SPpCjY+7aWBj2JOmMA HL/tnjj9ggqiQel8XVMLeLy8ZawHNT8Q2TaliXeh8tj1K+unBjKVbBSFIDFQohbig7nP 98Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=EsqTpSAU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g7si12348300edk.180.2021.10.11.09.16.31; Mon, 11 Oct 2021 09:16:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=EsqTpSAU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235658AbhJKJp2 (ORCPT + 99 others); Mon, 11 Oct 2021 05:45:28 -0400 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:51862 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235626AbhJKJpV (ORCPT ); Mon, 11 Oct 2021 05:45:21 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19B7vWne014070; Mon, 11 Oct 2021 11:43:09 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=selector1; bh=xcge6Tmp8n1Scab5wy+5ZALoDl294NFVjrwUjkjXu/Q=; b=EsqTpSAUtYI9/6GlAWdAUvACFFkiZPukMajqPObihvVMPWzTXsRWmS4Xz0XWpazynxqs /39JsSUZ1Ve06TdZU298DIAjLS+S//VkRq2VPiLpyhU5R0sVqIx5BLiYjTQADfze0MAm iY8ITJsnyjf8qvxTKLz6vcpP/40sfPn4RsEctGoqW+Q8yWOHlxdZeXG1N9uurDQZbBi6 Mylredubg2sXYU51yNy/lJZhzvi3BU+XPa/OlpKzdPC2occt1PEi0rlBPqT45fQQYWPg FziT8INl0suqcTcOV5mm68zxwsvEunNv6Jy9S0PI0uiYgbfzHkYZpagp992uZcMrCNTt aw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 3bmasq2my0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Oct 2021 11:43:09 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 3F81310002A; Mon, 11 Oct 2021 11:43:09 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag2node2.st.com [10.75.127.5]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 3839021B50C; Mon, 11 Oct 2021 11:43:09 +0200 (CEST) Received: from localhost (10.75.127.45) by SFHDAG2NODE2.st.com (10.75.127.5) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 11 Oct 2021 11:43:08 +0200 From: Amelie Delaunay To: Vinod Koul , Maxime Coquelin , Alexandre Torgue CC: , , , , Amelie Delaunay , Pierre-Yves Mordret Subject: [PATCH 3/3] dmaengine: stm32-dma: fix burst in case of unaligned memory address Date: Mon, 11 Oct 2021 11:42:59 +0200 Message-ID: <20211011094259.315023-4-amelie.delaunay@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211011094259.315023-1-amelie.delaunay@foss.st.com> References: <20211011094259.315023-1-amelie.delaunay@foss.st.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG2NODE2.st.com (10.75.127.5) To SFHDAG2NODE2.st.com (10.75.127.5) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-10-11_03,2021-10-07_02,2020-04-07_01 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Theorically, address pointers used by STM32 DMA must be chosen so as to ensure that all transfers within a burst block are aligned on the address boundary equal to the size of the transfer. If this is always the case for peripheral addresses on STM32, it is not for memory addresses if the user doesn't respect this alignment constraint. To avoid a weird behavior of the DMA controller in this case (no error triggered but data are not transferred as expected), force no burst. Signed-off-by: Amelie Delaunay --- drivers/dma/stm32-dma.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c index 6e4ef44941ef..2283c500f4ce 100644 --- a/drivers/dma/stm32-dma.c +++ b/drivers/dma/stm32-dma.c @@ -753,8 +753,14 @@ static int stm32_dma_set_xfer_param(struct stm32_dma_chan *chan, if (src_bus_width < 0) return src_bus_width; - /* Set memory burst size */ - src_maxburst = STM32_DMA_MAX_BURST; + /* + * Set memory burst size - burst not possible if address is not aligned on + * the address boundary equal to the size of the transfer + */ + if (buf_addr % buf_len) + src_maxburst = 1; + else + src_maxburst = STM32_DMA_MAX_BURST; src_best_burst = stm32_dma_get_best_burst(buf_len, src_maxburst, fifoth, @@ -803,8 +809,14 @@ static int stm32_dma_set_xfer_param(struct stm32_dma_chan *chan, if (dst_bus_width < 0) return dst_bus_width; - /* Set memory burst size */ - dst_maxburst = STM32_DMA_MAX_BURST; + /* + * Set memory burst size - burst not possible if address is not aligned on + * the address boundary equal to the size of the transfer + */ + if (buf_addr % buf_len) + dst_maxburst = 1; + else + dst_maxburst = STM32_DMA_MAX_BURST; dst_best_burst = stm32_dma_get_best_burst(buf_len, dst_maxburst, fifoth, -- 2.25.1