Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

spi: more tx_buf/rx_buf removal

Merge series from David Lechner <dlechner@baylibre.com>:

I found a couple more controller drivers that were checking if the
tx_buf and rx_buf fields in the spi_transfer structure were set by a
peripheral driver that I missed in [1]. These checks can be removed
as well.

[1]: https://lore.kernel.org/linux-spi/20240325-spi-remove-is_dma_mapped-v2-1-d08d62b61f1c@baylibre.com/

+19 -36
+10 -19
drivers/spi/spi-au1550.c
··· 314 314 315 315 hw->tx = t->tx_buf; 316 316 hw->rx = t->rx_buf; 317 - dma_tx_addr = t->tx_dma; 318 - dma_rx_addr = t->rx_dma; 319 317 320 318 /* 321 - * check if buffers are already dma mapped, map them otherwise: 322 319 * - first map the TX buffer, so cache data gets written to memory 323 320 * - then map the RX buffer, so that cache entries (with 324 321 * soon-to-be-stale data) get removed ··· 323 326 * use temp rx buffer (preallocated or realloc to fit) for rx dma 324 327 */ 325 328 if (t->tx_buf) { 326 - if (t->tx_dma == 0) { /* if DMA_ADDR_INVALID, map it */ 327 - dma_tx_addr = dma_map_single(hw->dev, 328 - (void *)t->tx_buf, 329 - t->len, DMA_TO_DEVICE); 330 - if (dma_mapping_error(hw->dev, dma_tx_addr)) 331 - dev_err(hw->dev, "tx dma map error\n"); 332 - } 329 + dma_tx_addr = dma_map_single(hw->dev, (void *)t->tx_buf, 330 + t->len, DMA_TO_DEVICE); 331 + if (dma_mapping_error(hw->dev, dma_tx_addr)) 332 + dev_err(hw->dev, "tx dma map error\n"); 333 333 } 334 334 335 335 if (t->rx_buf) { 336 - if (t->rx_dma == 0) { /* if DMA_ADDR_INVALID, map it */ 337 - dma_rx_addr = dma_map_single(hw->dev, 338 - (void *)t->rx_buf, 339 - t->len, DMA_FROM_DEVICE); 340 - if (dma_mapping_error(hw->dev, dma_rx_addr)) 341 - dev_err(hw->dev, "rx dma map error\n"); 342 - } 336 + dma_rx_addr = dma_map_single(hw->dev, (void *)t->rx_buf, 337 + t->len, DMA_FROM_DEVICE); 338 + if (dma_mapping_error(hw->dev, dma_rx_addr)) 339 + dev_err(hw->dev, "rx dma map error\n"); 343 340 } else { 344 341 if (t->len > hw->dma_rx_tmpbuf_size) { 345 342 int ret; ··· 389 398 DMA_FROM_DEVICE); 390 399 } 391 400 /* unmap buffers if mapped above */ 392 - if (t->rx_buf && t->rx_dma == 0) 401 + if (t->rx_buf) 393 402 dma_unmap_single(hw->dev, dma_rx_addr, t->len, 394 403 DMA_FROM_DEVICE); 395 - if (t->tx_buf && t->tx_dma == 0) 404 + if (t->tx_buf) 396 405 dma_unmap_single(hw->dev, dma_tx_addr, t->len, 397 406 DMA_TO_DEVICE); 398 407
+4 -10
drivers/spi/spi-fsl-cpm.c
··· 98 98 mpc8xxx_spi_write_reg(&reg_base->command, SPCOM_STR); 99 99 } 100 100 101 - int fsl_spi_cpm_bufs(struct mpc8xxx_spi *mspi, 102 - struct spi_transfer *t, bool is_dma_mapped) 101 + int fsl_spi_cpm_bufs(struct mpc8xxx_spi *mspi, struct spi_transfer *t) 103 102 { 104 103 struct device *dev = mspi->dev; 105 104 struct fsl_spi_reg __iomem *reg_base = mspi->reg_base; 106 105 107 - if (is_dma_mapped) { 108 - mspi->map_tx_dma = 0; 109 - mspi->map_rx_dma = 0; 110 - } else { 111 - mspi->map_tx_dma = 1; 112 - mspi->map_rx_dma = 1; 113 - } 106 + mspi->map_tx_dma = 1; 107 + mspi->map_rx_dma = 1; 114 108 115 109 if (!t->tx_buf) { 116 110 mspi->tx_dma = mspi->dma_dummy_tx; ··· 141 147 return -ENOMEM; 142 148 } 143 149 } else if (t->tx_buf) { 144 - mspi->tx_dma = t->tx_dma; 150 + mspi->tx_dma = 0; 145 151 } 146 152 147 153 if (mspi->map_rx_dma) {
+2 -3
drivers/spi/spi-fsl-cpm.h
··· 20 20 #ifdef CONFIG_FSL_SOC 21 21 extern void fsl_spi_cpm_reinit_txrx(struct mpc8xxx_spi *mspi); 22 22 extern int fsl_spi_cpm_bufs(struct mpc8xxx_spi *mspi, 23 - struct spi_transfer *t, bool is_dma_mapped); 23 + struct spi_transfer *t); 24 24 extern void fsl_spi_cpm_bufs_complete(struct mpc8xxx_spi *mspi); 25 25 extern void fsl_spi_cpm_irq(struct mpc8xxx_spi *mspi, u32 events); 26 26 extern int fsl_spi_cpm_init(struct mpc8xxx_spi *mspi); ··· 28 28 #else 29 29 static inline void fsl_spi_cpm_reinit_txrx(struct mpc8xxx_spi *mspi) { } 30 30 static inline int fsl_spi_cpm_bufs(struct mpc8xxx_spi *mspi, 31 - struct spi_transfer *t, 32 - bool is_dma_mapped) { return 0; } 31 + struct spi_transfer *t) { return 0; } 33 32 static inline void fsl_spi_cpm_bufs_complete(struct mpc8xxx_spi *mspi) { } 34 33 static inline void fsl_spi_cpm_irq(struct mpc8xxx_spi *mspi, u32 events) { } 35 34 static inline int fsl_spi_cpm_init(struct mpc8xxx_spi *mspi) { return 0; }
+3 -4
drivers/spi/spi-fsl-spi.c
··· 249 249 return 0; 250 250 } 251 251 252 - static int fsl_spi_bufs(struct spi_device *spi, struct spi_transfer *t, 253 - bool is_dma_mapped) 252 + static int fsl_spi_bufs(struct spi_device *spi, struct spi_transfer *t) 254 253 { 255 254 struct mpc8xxx_spi *mpc8xxx_spi = spi_controller_get_devdata(spi->controller); 256 255 struct fsl_spi_reg __iomem *reg_base; ··· 273 274 reinit_completion(&mpc8xxx_spi->done); 274 275 275 276 if (mpc8xxx_spi->flags & SPI_CPM_MODE) 276 - ret = fsl_spi_cpm_bufs(mpc8xxx_spi, t, is_dma_mapped); 277 + ret = fsl_spi_cpm_bufs(mpc8xxx_spi, t); 277 278 else 278 279 ret = fsl_spi_cpu_bufs(mpc8xxx_spi, t, len); 279 280 if (ret) ··· 352 353 if (status < 0) 353 354 return status; 354 355 if (t->len) 355 - status = fsl_spi_bufs(spi, t, !!t->tx_dma || !!t->rx_dma); 356 + status = fsl_spi_bufs(spi, t); 356 357 if (status > 0) 357 358 return -EMSGSIZE; 358 359