Patch "dmaengine: stm32-dma: avoid 64-bit division in stm32_dma_get_max_width" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    dmaengine: stm32-dma: avoid 64-bit division in stm32_dma_get_max_width

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     dmaengine-stm32-dma-avoid-64-bit-division-in-stm32_d.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 4577086ed03ca96e71303a2a745527124b2e1a7e
Author: Arnd Bergmann <arnd@xxxxxxxx>
Date:   Wed Nov 3 16:33:12 2021 +0100

    dmaengine: stm32-dma: avoid 64-bit division in stm32_dma_get_max_width
    
    [ Upstream commit 2498363310e9b5e5de0e104709adc35c9f3ff7d9 ]
    
    Using the % operator on a 64-bit variable is expensive and can
    cause a link failure:
    
    arm-linux-gnueabi-ld: drivers/dma/stm32-dma.o: in function `stm32_dma_get_max_width':
    stm32-dma.c:(.text+0x170): undefined reference to `__aeabi_uldivmod'
    arm-linux-gnueabi-ld: drivers/dma/stm32-dma.o: in function `stm32_dma_set_xfer_param':
    stm32-dma.c:(.text+0x1cd4): undefined reference to `__aeabi_uldivmod'
    
    As we know that we just want to check the alignment in
    stm32_dma_get_max_width(), there is no need for a full division, and
    using a simple mask is a faster replacement.
    
    Same in stm32_dma_set_xfer_param(), change this to only allow burst
    transfers if the address is a multiple of the length.
    stm32_dma_get_best_burst just after will take buf_len into account to fix
    burst in case of misalignment.
    
    Fixes: b20fd5fa310c ("dmaengine: stm32-dma: fix stm32_dma_get_max_width")
    Reported-by: kernel test robot <lkp@xxxxxxxxx>
    Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
    Signed-off-by: Amelie Delaunay <amelie.delaunay@xxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20211103153312.41483-1-amelie.delaunay@xxxxxxxxxxx
    Signed-off-by: Vinod Koul <vkoul@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c
index c276a39aa7930..7dfc743ac4338 100644
--- a/drivers/dma/stm32-dma.c
+++ b/drivers/dma/stm32-dma.c
@@ -280,7 +280,7 @@ static enum dma_slave_buswidth stm32_dma_get_max_width(u32 buf_len,
 	       max_width > DMA_SLAVE_BUSWIDTH_1_BYTE)
 		max_width = max_width >> 1;
 
-	if (buf_addr % max_width)
+	if (buf_addr & (max_width - 1))
 		max_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
 
 	return max_width;
@@ -756,7 +756,7 @@ static int stm32_dma_set_xfer_param(struct stm32_dma_chan *chan,
 		 * 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)
+		if (buf_addr & (buf_len - 1))
 			src_maxburst = 1;
 		else
 			src_maxburst = STM32_DMA_MAX_BURST;
@@ -812,7 +812,7 @@ static int stm32_dma_set_xfer_param(struct stm32_dma_chan *chan,
 		 * 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)
+		if (buf_addr & (buf_len - 1))
 			dst_maxburst = 1;
 		else
 			dst_maxburst = STM32_DMA_MAX_BURST;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux