Commit 8e5481d9 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Greg Kroah-Hartman

serial: stm32: use mapbase instead of membase for DMA

Building this driver with a 64-bit dma_addr_t type results in
a compiler warning:

drivers/tty/serial/stm32-usart.c: In function 'stm32_of_dma_rx_probe':
drivers/tty/serial/stm32-usart.c:746:20: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
drivers/tty/serial/stm32-usart.c: In function 'stm32_of_dma_tx_probe':
drivers/tty/serial/stm32-usart.c:818:20: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]

While the type conversion here is harmless, this hints at a different
problem: we pass an __iomem pointer into a DMA engine, which expects
a phys_addr_t. This happens to work because stm32 has no MMU and
ioremap() is an identity mapping here, but it's still an incorrect
API use. Using dma_addr_t is doubly wrong here, because that would
be the result of dma_map_single() rather than the physical address.

Using the mapbase instead fixes multiple issues:

- the warning is gone
- we don't go through ioremap in error
- the cast is gone, making it use the correct resource_size_t/phys_addr_t
  type in the process.

Fixes: 34891872 ("serial: stm32: adding dma support")
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Reviewed-by: default avatarGerald Baeza <gerald.baeza@st.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 36131cdf
...@@ -743,7 +743,7 @@ static int stm32_of_dma_rx_probe(struct stm32_port *stm32port, ...@@ -743,7 +743,7 @@ static int stm32_of_dma_rx_probe(struct stm32_port *stm32port,
/* Configure DMA channel */ /* Configure DMA channel */
memset(&config, 0, sizeof(config)); memset(&config, 0, sizeof(config));
config.src_addr = (dma_addr_t)port->membase + ofs->rdr; config.src_addr = port->mapbase + ofs->rdr;
config.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; config.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
ret = dmaengine_slave_config(stm32port->rx_ch, &config); ret = dmaengine_slave_config(stm32port->rx_ch, &config);
...@@ -815,7 +815,7 @@ static int stm32_of_dma_tx_probe(struct stm32_port *stm32port, ...@@ -815,7 +815,7 @@ static int stm32_of_dma_tx_probe(struct stm32_port *stm32port,
/* Configure DMA channel */ /* Configure DMA channel */
memset(&config, 0, sizeof(config)); memset(&config, 0, sizeof(config));
config.dst_addr = (dma_addr_t)port->membase + ofs->tdr; config.dst_addr = port->mapbase + ofs->tdr;
config.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; config.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
ret = dmaengine_slave_config(stm32port->tx_ch, &config); ret = dmaengine_slave_config(stm32port->tx_ch, &config);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment