From patchwork Mon Apr 3 06:20:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 96591 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp1737171qgd; Sun, 2 Apr 2017 23:21:22 -0700 (PDT) X-Received: by 10.99.55.75 with SMTP id g11mr16008572pgn.224.1491200482277; Sun, 02 Apr 2017 23:21:22 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f3si13251347pln.45.2017.04.02.23.21.22; Sun, 02 Apr 2017 23:21:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751141AbdDCGVV (ORCPT + 3 others); Mon, 3 Apr 2017 02:21:21 -0400 Received: from mailout3.w1.samsung.com ([210.118.77.13]:40936 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750992AbdDCGVU (ORCPT ); Mon, 3 Apr 2017 02:21:20 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0ONT006FZLNGR900@mailout3.w1.samsung.com>; Mon, 03 Apr 2017 07:21:16 +0100 (BST) Received: from eusmges2.samsung.com (unknown [203.254.199.241]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170403062116eucas1p1479c4e9f319d0b20474e70cb0f8311a0~xzu6k5wzx1227212272eucas1p1_; Mon, 3 Apr 2017 06:21:15 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2.samsung.com (EUCPMTA) with SMTP id D4.38.04459.BD9E1E85; Mon, 3 Apr 2017 07:21:15 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170403062115eucas1p25b1504b3441f1195129bbedad261494c~xzu5rlh100647006470eucas1p2N; Mon, 3 Apr 2017 06:21:15 +0000 (GMT) X-AuditID: cbfec7f1-f796e6d00000116b-3c-58e1e9dbea9e Received: from eusync2.samsung.com ( [203.254.199.212]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 9D.E5.17452.F4AE1E85; Mon, 3 Apr 2017 07:23:11 +0100 (BST) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0ONT006EQLNBVO80@eusync2.samsung.com>; Mon, 03 Apr 2017 07:21:14 +0100 (BST) From: Marek Szyprowski To: linux-samsung-soc@vger.kernel.org, linux-serial@vger.kernel.org Cc: Marek Szyprowski , Sylwester Nawrocki , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz , Greg Kroah-Hartman , Seung-Woo Kim , Joonyoung Shim , Inki Dae , stable@vger.kernel.org Subject: [PATCH v3 1/3] serial: samsung: Use right device for DMA-mapping calls Date: Mon, 03 Apr 2017 08:20:59 +0200 Message-id: <1491200468-28463-1-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFIsWRmVeSWpSXmKPExsWy7djPc7q3Xz6MMDi5W9ti44z1rBbNi9ez WUy6P4HF4sW9iywW589vYLeYcX4fk8WZxb3sFmuP3GW3OPymndViwcZHjBYzJr9kc+D22LSq k81j/9w17B59W1YxenzeJBfAEsVlk5Kak1mWWqRvl8CVsWnKOtaCNumKl7tbWRo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iZ17X4ONEhbwl7iy4B2YzSKgKnG/dRELiM0r4CHxr2EJG8Q6OYmTxyazTmDkXsDIsIpR JLW0ODc9t9hQrzgxt7g0L10vOT93EyMweLcd+7l5B+OljcGHGAU4GJV4eDWcH0YIsSaWFVfm HmKU4GBWEuFVugMU4k1JrKxKLcqPLyrNSS0+xGgKtHwis5Rocj4wsvJK4g1NDM0tDY2MLSzM jYyUxHlLPlwJFxJITyxJzU5NLUgtgulj4uCUamAsXMhm28k1ffKunKvZBneC1m3YEv2y+/eV r4sVHmRqhStt/ylZt/tR+WWFqPUvz8ds5V2ydde6Xc4OUnfm2NY+X2w+zfjTYou1GmFrNq68 wjNxSs/Gd9nXLOpv7b9uf2K6sNxmt4mflbQyyteyupqzcJp8nHCOv2uRBr/n4clGkgEmbrPL mI/1KLEUZyQaajEXFScCAHq5mtl0AgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170403062115eucas1p25b1504b3441f1195129bbedad261494c X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?utf-8?q?Marek_Szyprowski=1BSRPOL-Kernel_=28TP=29=1B?= =?utf-8?b?7IK87ISx7KCE7J6QG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Global-Sender: =?utf-8?q?Marek_Szyprowski=1BSRPOL-Kernel_=28TP=29=1BSam?= =?utf-8?q?sung_Electronics=1BSenior_Software_Engineer?= X-Sender-Code: =?utf-8?q?C10=1BEHQ=1BC10CD02CD027392?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170403062115eucas1p25b1504b3441f1195129bbedad261494c X-RootMTR: 20170403062115eucas1p25b1504b3441f1195129bbedad261494c References: Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org 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) [] (unwind_backtrace) from [] (show_stack+0x20/0x24) [] (show_stack) from [] (dump_stack+0x84/0xa0) [] (dump_stack) from [] (__warn+0x14c/0x180) [] (__warn) from [] (warn_slowpath_fmt+0x48/0x50) [] (warn_slowpath_fmt) from [] (check_sync+0x520/0x9f4) [] (check_sync) from [] (debug_dma_sync_single_for_device+0x88/0xc8) [] (debug_dma_sync_single_for_device) from [] (s3c24xx_serial_start_tx_dma+0x100/0x2f8) [] (s3c24xx_serial_start_tx_dma) from [] (s3c24xx_serial_tx_chars+0x198/0x33c) Reported-by: Seung-Woo Kim Fixes: 62c37eedb74c8 ("serial: samsung: add dma reqest/release functions") CC: stable@vger.kernel.org # v4.0+ Signed-off-by: Marek Szyprowski Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Krzysztof Kozlowski --- v3: - extended commit message v2: - fixed commit id in 'fixes' tag, added 'reviewed-by' tag --- drivers/tty/serial/samsung.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Reviewed-by: Krzysztof Kozlowski Reviewed-by: Krzysztof Kozlowski diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c index 7a17aedbf902..9f3759bdb44f 100644 --- a/drivers/tty/serial/samsung.c +++ b/drivers/tty/serial/samsung.c @@ -901,14 +901,13 @@ static int s3c24xx_serial_request_dma(struct s3c24xx_uart_port *p) return -ENOMEM; } - dma->rx_addr = dma_map_single(dma->rx_chan->device->dev, dma->rx_buf, + dma->rx_addr = dma_map_single(p->port.dev, dma->rx_buf, dma->rx_size, DMA_FROM_DEVICE); spin_lock_irqsave(&p->port.lock, flags); /* TX buffer */ - dma->tx_addr = dma_map_single(dma->tx_chan->device->dev, - p->port.state->xmit.buf, + dma->tx_addr = dma_map_single(p->port.dev, p->port.state->xmit.buf, UART_XMIT_SIZE, DMA_TO_DEVICE); spin_unlock_irqrestore(&p->port.lock, flags); @@ -922,7 +921,7 @@ static void s3c24xx_serial_release_dma(struct s3c24xx_uart_port *p) if (dma->rx_chan) { dmaengine_terminate_all(dma->rx_chan); - dma_unmap_single(dma->rx_chan->device->dev, dma->rx_addr, + dma_unmap_single(p->port.dev, dma->rx_addr, dma->rx_size, DMA_FROM_DEVICE); kfree(dma->rx_buf); dma_release_channel(dma->rx_chan); @@ -931,7 +930,7 @@ static void s3c24xx_serial_release_dma(struct s3c24xx_uart_port *p) if (dma->tx_chan) { dmaengine_terminate_all(dma->tx_chan); - dma_unmap_single(dma->tx_chan->device->dev, dma->tx_addr, + dma_unmap_single(p->port.dev, dma->tx_addr, UART_XMIT_SIZE, DMA_TO_DEVICE); dma_release_channel(dma->tx_chan); dma->tx_chan = NULL;