aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Szyprowski <m.szyprowski@samsung.com>2017-04-03 02:20:59 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-05-20 08:28:41 -0400
commitc5689e0ab6e18d4b8b01ffc00f36be5a8a70aa41 (patch)
tree3cb63be568e70d804da1a1a44dc529e95abbe692
parent64a599ac5dcca722e9bcec3fe1e42d9f1774f229 (diff)
serial: samsung: Use right device for DMA-mapping calls
commit 768d64f491a530062ddad50e016fb27125f8bd7c upstream. Driver should provide its own struct device for all DMA-mapping calls instead of extracting device pointer from DMA engine channel. Although this is harmless from the driver operation perspective on ARM architecture, it is always good to use the DMA mapping API in a proper way. This patch fixes following DMA API debug warning: WARNING: CPU: 0 PID: 0 at lib/dma-debug.c:1241 check_sync+0x520/0x9f4 samsung-uart 12c20000.serial: DMA-API: device driver tries to sync DMA memory it has not allocated [device address=0x000000006df0f580] [size=64 bytes] Modules linked in: CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.11.0-rc1-00137-g07ca963 #51 Hardware name: SAMSUNG EXYNOS (Flattened Device Tree) [<c011aaa4>] (unwind_backtrace) from [<c01127c0>] (show_stack+0x20/0x24) [<c01127c0>] (show_stack) from [<c06ba5d8>] (dump_stack+0x84/0xa0) [<c06ba5d8>] (dump_stack) from [<c0139528>] (__warn+0x14c/0x180) [<c0139528>] (__warn) from [<c01395a4>] (warn_slowpath_fmt+0x48/0x50) [<c01395a4>] (warn_slowpath_fmt) from [<c0729058>] (check_sync+0x520/0x9f4) [<c0729058>] (check_sync) from [<c072967c>] (debug_dma_sync_single_for_device+0x88/0xc8) [<c072967c>] (debug_dma_sync_single_for_device) from [<c0803c10>] (s3c24xx_serial_start_tx_dma+0x100/0x2f8) [<c0803c10>] (s3c24xx_serial_start_tx_dma) from [<c0804338>] (s3c24xx_serial_tx_chars+0x198/0x33c) Reported-by: Seung-Woo Kim <sw0312.kim@samsung.com> Fixes: 62c37eedb74c8 ("serial: samsung: add dma reqest/release functions") Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org> Reviewed-by: Shuah Khan <shuahkh@osg.samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/serial/samsung.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
index 3e2ef4fd7382..d65f92bcd0f1 100644
--- a/drivers/tty/serial/samsung.c
+++ b/drivers/tty/serial/samsung.c
@@ -906,14 +906,13 @@ static int s3c24xx_serial_request_dma(struct s3c24xx_uart_port *p)
906 return -ENOMEM; 906 return -ENOMEM;
907 } 907 }
908 908
909 dma->rx_addr = dma_map_single(dma->rx_chan->device->dev, dma->rx_buf, 909 dma->rx_addr = dma_map_single(p->port.dev, dma->rx_buf,
910 dma->rx_size, DMA_FROM_DEVICE); 910 dma->rx_size, DMA_FROM_DEVICE);
911 911
912 spin_lock_irqsave(&p->port.lock, flags); 912 spin_lock_irqsave(&p->port.lock, flags);
913 913
914 /* TX buffer */ 914 /* TX buffer */
915 dma->tx_addr = dma_map_single(dma->tx_chan->device->dev, 915 dma->tx_addr = dma_map_single(p->port.dev, p->port.state->xmit.buf,
916 p->port.state->xmit.buf,
917 UART_XMIT_SIZE, DMA_TO_DEVICE); 916 UART_XMIT_SIZE, DMA_TO_DEVICE);
918 917
919 spin_unlock_irqrestore(&p->port.lock, flags); 918 spin_unlock_irqrestore(&p->port.lock, flags);
@@ -927,7 +926,7 @@ static void s3c24xx_serial_release_dma(struct s3c24xx_uart_port *p)
927 926
928 if (dma->rx_chan) { 927 if (dma->rx_chan) {
929 dmaengine_terminate_all(dma->rx_chan); 928 dmaengine_terminate_all(dma->rx_chan);
930 dma_unmap_single(dma->rx_chan->device->dev, dma->rx_addr, 929 dma_unmap_single(p->port.dev, dma->rx_addr,
931 dma->rx_size, DMA_FROM_DEVICE); 930 dma->rx_size, DMA_FROM_DEVICE);
932 kfree(dma->rx_buf); 931 kfree(dma->rx_buf);
933 dma_release_channel(dma->rx_chan); 932 dma_release_channel(dma->rx_chan);
@@ -936,7 +935,7 @@ static void s3c24xx_serial_release_dma(struct s3c24xx_uart_port *p)
936 935
937 if (dma->tx_chan) { 936 if (dma->tx_chan) {
938 dmaengine_terminate_all(dma->tx_chan); 937 dmaengine_terminate_all(dma->tx_chan);
939 dma_unmap_single(dma->tx_chan->device->dev, dma->tx_addr, 938 dma_unmap_single(p->port.dev, dma->tx_addr,
940 UART_XMIT_SIZE, DMA_TO_DEVICE); 939 UART_XMIT_SIZE, DMA_TO_DEVICE);
941 dma_release_channel(dma->tx_chan); 940 dma_release_channel(dma->tx_chan);
942 dma->tx_chan = NULL; 941 dma->tx_chan = NULL;