From nobody Wed Nov 27 02:39:28 2024 Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [185.132.182.106]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7558E1EC000; Tue, 15 Oct 2024 12:16:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.132.182.106 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728994591; cv=none; b=oIz+S5kIBcLdDMMAjWv/+D2xtXEYGsq9TeHn1ukbkopgn4Z39mVaR/QknO+rIWtZ3ZY/NzVO0+WZBZkKK0Q8hS7z1QgJDv38smNj6DsQwPiEKX7FWFH1JSVKS+PRqVb+5+b6b3Y06QesxGDXoutgckaXYfUCn1AkYZVsDZpqTJo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728994591; c=relaxed/simple; bh=wdD98dh8hUdD7Br13Zty15YgoaLIF2Za0M8sk3rkhD8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=dwzynVSNBFi7M43WxRkKP7vTEl65s7kdZsownu8gf+sdQgPk3Dq1OAHP8D7prmVI9WW1zMOBgzJfCMuqllNrG9vpT+loJMxP3jSwhlTY/tPhT5XQOQvyZN3O7cmtFZqlljt7hesBL9GnZUqH02SHxZpQmZs5pbRxG4kkm0OMF+M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foss.st.com; spf=pass smtp.mailfrom=foss.st.com; dkim=pass (2048-bit key) header.d=foss.st.com header.i=@foss.st.com header.b=a/1U2B53; arc=none smtp.client-ip=185.132.182.106 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=foss.st.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=foss.st.com header.i=@foss.st.com header.b="a/1U2B53" Received: from pps.filterd (m0369458.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49FCDgww007077; Tue, 15 Oct 2024 14:16:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=selector1; bh= 20xEPx4JtIHJKB3XkmoT5ueiiLey/iQq4U2NsvYq/Ns=; b=a/1U2B53urKib74m Ja3HrZUBazeMf49Au1g9cUARiJ0XAHYE0wbVqm35HR8ptcc0VlfGODPK0u1NUsAg HrNFd1XDnsXQgjiQZF6JC8aT71Ug05c+FyiCKpaDiTambe1tVNr5RLR58s2OTFoM XJcLqpcAszgwU7kZN2PE21ue/NAIQNd+HX9W4DOsf9dd0WcMsp+Sp3kII2w4Vn0O XkpERlJ7fmR8TyG5vi9yHWMDAsPaO8Z4nSy9b2guFAhZxQzR/eyk+3JbjIuHU+Bc m6BFCacNpgpP5GB92q9dfQ2eoPKzfHNxi57kLXbY+UArnIWNqtO/zlsvyFnHzXjb Tz2i0Q== Received: from beta.dmz-ap.st.com (beta.dmz-ap.st.com [138.198.100.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 4282p12r85-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Oct 2024 14:16:17 +0200 (MEST) Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id AA2C140069; Tue, 15 Oct 2024 14:15:20 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node3.st.com [10.75.129.71]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 07D1E22233D; Tue, 15 Oct 2024 14:14:48 +0200 (CEST) Received: from localhost (10.48.87.35) by SHFDAG1NODE3.st.com (10.75.129.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.37; Tue, 15 Oct 2024 14:14:47 +0200 From: Amelie Delaunay Date: Tue, 15 Oct 2024 14:14:38 +0200 Subject: [PATCH v2 2/9] dmaengine: stm32-dma3: prevent pack/unpack thanks to DT configuration Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20241015-dma3-mp25-updates-v2-2-b63e21556ec8@foss.st.com> References: <20241015-dma3-mp25-updates-v2-0-b63e21556ec8@foss.st.com> In-Reply-To: <20241015-dma3-mp25-updates-v2-0-b63e21556ec8@foss.st.com> To: Vinod Koul , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Maxime Coquelin , Alexandre Torgue CC: , , , , , Amelie Delaunay X-Mailer: b4 0.14.2 X-ClientProxiedBy: EQNCAS1NODE4.st.com (10.75.129.82) To SHFDAG1NODE3.st.com (10.75.129.71) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 When source data width/burst and destination data width/burst are different, data are packed or unpacked in DMA3 channel FIFO, using CxTR1.PAM. Data are pushed out from DMA3 channel FIFO when the destination burst length (=3D data width * burst) is reached. If the transfer is stopped before CxBR1.BNDT =3D 0, and if some bytes are packed/unpacked in the DMA3 channel FIFO, these bytes are lost. Indeed, DMA3 channel FIFO has no flush capability, only reset. To avoid potential bytes lost, pack/unpack must be prevented by setting memory data width/burst equal to peripheral data width/burst. Memory accesses will be penalized. But it is the only way to avoid bytes lost. Prevent pack/unpack feature can be activated by setting bit 16 of DMA3 Transfer requirements bitfield (tr_conf) in device tree. Signed-off-by: Amelie Delaunay --- drivers/dma/stm32/stm32-dma3.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/dma/stm32/stm32-dma3.c b/drivers/dma/stm32/stm32-dma3.c index b9470f783f98940a99addaeef6d0a8bc07b5c54b..f793eecd2c27ca17cedd5cabbaa= 1b1beca202039 100644 --- a/drivers/dma/stm32/stm32-dma3.c +++ b/drivers/dma/stm32/stm32-dma3.c @@ -221,6 +221,7 @@ enum stm32_dma3_port_data_width { #define STM32_DMA3_DT_BREQ BIT(8) /* CTR2_BREQ */ #define STM32_DMA3_DT_PFREQ BIT(9) /* CTR2_PFREQ */ #define STM32_DMA3_DT_TCEM GENMASK(13, 12) /* CTR2_TCEM */ +#define STM32_DMA3_DT_NOPACK BIT(16) /* CTR1_PAM */ =20 /* struct stm32_dma3_chan .config_set bitfield */ #define STM32_DMA3_CFG_SET_DT BIT(0) @@ -622,6 +623,10 @@ static int stm32_dma3_chan_prep_hw(struct stm32_dma3_c= han *chan, enum dma_transf /* Set source (memory) data width and burst */ sdw =3D stm32_dma3_get_max_dw(chan->max_burst, sap_max_dw, len, src_addr= ); sbl_max =3D stm32_dma3_get_max_burst(len, sdw, chan->max_burst); + if (!!FIELD_GET(STM32_DMA3_DT_NOPACK, tr_conf)) { + sdw =3D ddw; + sbl_max =3D dbl_max; + } =20 _ctr1 |=3D FIELD_PREP(CTR1_SDW_LOG2, ilog2(sdw)); _ctr1 |=3D FIELD_PREP(CTR1_SBL_1, sbl_max - 1); @@ -652,6 +657,11 @@ static int stm32_dma3_chan_prep_hw(struct stm32_dma3_c= han *chan, enum dma_transf /* Set destination (memory) data width and burst */ ddw =3D stm32_dma3_get_max_dw(chan->max_burst, dap_max_dw, len, dst_addr= ); dbl_max =3D stm32_dma3_get_max_burst(len, ddw, chan->max_burst); + if (!!FIELD_GET(STM32_DMA3_DT_NOPACK, tr_conf) || + ((_ctr2 & CTR2_PFREQ) && ddw > sdw)) { /* Packing to wider ddw not s= upported */ + ddw =3D sdw; + dbl_max =3D sbl_max; + } =20 _ctr1 |=3D FIELD_PREP(CTR1_SDW_LOG2, ilog2(sdw)); _ctr1 |=3D FIELD_PREP(CTR1_SBL_1, sbl_max - 1); --=20 2.25.1