@@ -1157,15 +1157,19 @@ static void stm32_spi_dma_rx_cb(void *data)
11571157 * stm32_spi_dma_config - configure dma slave channel depending on current
11581158 * transfer bits_per_word.
11591159 * @spi: pointer to the spi controller data structure
1160+ * @dma_chan: pointer to the DMA channel
11601161 * @dma_conf: pointer to the dma_slave_config structure
11611162 * @dir: direction of the dma transfer
11621163 */
11631164static void stm32_spi_dma_config (struct stm32_spi * spi ,
1165+ struct dma_chan * dma_chan ,
11641166 struct dma_slave_config * dma_conf ,
11651167 enum dma_transfer_direction dir )
11661168{
11671169 enum dma_slave_buswidth buswidth ;
1170+ struct dma_slave_caps caps ;
11681171 u32 maxburst ;
1172+ int ret ;
11691173
11701174 if (spi -> cur_bpw <= 8 )
11711175 buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE ;
@@ -1184,6 +1188,11 @@ static void stm32_spi_dma_config(struct stm32_spi *spi,
11841188 maxburst = 1 ;
11851189 }
11861190
1191+ /* Get the DMA channel caps, and adjust maxburst if possible */
1192+ ret = dma_get_slave_caps (dma_chan , & caps );
1193+ if (!ret )
1194+ maxburst = min (maxburst , caps .max_burst );
1195+
11871196 memset (dma_conf , 0 , sizeof (struct dma_slave_config ));
11881197 dma_conf -> direction = dir ;
11891198 if (dma_conf -> direction == DMA_DEV_TO_MEM ) { /* RX */
@@ -1366,7 +1375,7 @@ static int stm32_spi_transfer_one_dma(struct stm32_spi *spi,
13661375
13671376 rx_dma_desc = NULL ;
13681377 if (spi -> rx_buf && spi -> dma_rx ) {
1369- stm32_spi_dma_config (spi , & rx_dma_conf , DMA_DEV_TO_MEM );
1378+ stm32_spi_dma_config (spi , spi -> dma_rx , & rx_dma_conf , DMA_DEV_TO_MEM );
13701379 dmaengine_slave_config (spi -> dma_rx , & rx_dma_conf );
13711380
13721381 /* Enable Rx DMA request */
@@ -1382,7 +1391,7 @@ static int stm32_spi_transfer_one_dma(struct stm32_spi *spi,
13821391
13831392 tx_dma_desc = NULL ;
13841393 if (spi -> tx_buf && spi -> dma_tx ) {
1385- stm32_spi_dma_config (spi , & tx_dma_conf , DMA_MEM_TO_DEV );
1394+ stm32_spi_dma_config (spi , spi -> dma_tx , & tx_dma_conf , DMA_MEM_TO_DEV );
13861395 dmaengine_slave_config (spi -> dma_tx , & tx_dma_conf );
13871396
13881397 tx_dma_desc = dmaengine_prep_slave_sg (
0 commit comments