Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753229AbcKIJr1 (ORCPT ); Wed, 9 Nov 2016 04:47:27 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:36860 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752163AbcKIJrX (ORCPT ); Wed, 9 Nov 2016 04:47:23 -0500 MIME-version: 1.0 Content-type: text/plain; charset=UTF-8 X-AuditID: cbfee61b-f796f6d000004092-8f-5822f0a941b3 Content-transfer-encoding: 8BIT Subject: Re: [PATCH] [RFC] drivers: dma-coherent: use MEMREMAP_WB instead of MEMREMAP_WC To: Brian Starkey References: <1478682609-26477-1-git-send-email-jaewon31.kim@samsung.com> <20161109092726.GA6009@e106950-lin.cambridge.arm.com> Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org From: Jaewon Kim Message-id: <5822F0AE.30101@samsung.com> Date: Wed, 09 Nov 2016 18:47:26 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 In-reply-to: <20161109092726.GA6009@e106950-lin.cambridge.arm.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprCIsWRmVeSWpSXmKPExsVy+t9jQd2VH5QiDObvNLR4dOoCo8XlXXPY LO6t+c/qwOyxZt4aRo9Nnyaxe3zeJBfAHOVmk5GamJJapJCal5yfkpmXbqsUGuKma6GkkJeY m2qrFKHrGxKkpFCWmFMK5BkZoAEH5wD3YCV9uwS3jNOzz7EWHOevOPPvF1sD4zqeLkZODgkB E4mfc9ezQNhiEhfurWcDsYUEZjFKtKzSB7F5BQQlfky+B1TDwcEsIC9x5FI2SJhZQF1i0rxF zF2MXEDlDxklGrY/BesVFoiSuPb1AhtIvYiApkTjnHiImiuMErce3mWEaDaRuN/6kBXEZhPQ lni/YBIrxC4NiUNrXzCB2CwCqhKr53wBu01UIEJi9bprzCA2p4CTxOLOiewTGIGORDhvFsJ5 s5Cct4CReRWjRGpBckFxUnquUV5quV5xYm5xaV66XnJ+7iZGcIw8k97BeHiX+yFGAQ5GJR7e jIeKEUKsiWXFlbmHGCU4mJVEeNXeK0UI8aYkVlalFuXHF5XmpBYfYjQFunEis5Rocj4wfvNK 4g1NzE3MjQ0szC0tTYyUxHkbZz8LFxJITyxJzU5NLUgtgulj4uCUamAMNeFY6fr/rQDD5i3G 5qIRm+xkSl9sFNwckmP8Y+7Sxwmzg2/fvJ3b9Fn2SHVglORXxtKej/mB3JPOVgVmM+6su357 E3eX/lMWlzN7/3Xt/Tn1QLJ5WPzZp4c/igWa1xjc/Wj5NfekqrpP56vgbyIdvkvjri7aftbv Ur2Yar361iunz8gV3LqixFKckWioxVxUnAgAYwqkiKcCAAA= X-MTR: 20000000000000000@CPGS Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1937 Lines: 56 On 2016년 11월 09일 18:27, Brian Starkey wrote: > Hi Jaewon, > > On Wed, Nov 09, 2016 at 06:10:09PM +0900, Jaewon Kim wrote: >> Commit 6b03ae0d42bf (drivers: dma-coherent: use MEMREMAP_WC for DMA_MEMORY_MA) >> added MEMREMAP_WC for DMA_MEMORY_MAP. If, however, CPU cache can be used on >> DMA_MEMORY_MAP, I think MEMREMAP_WC can be changed to MEMREMAP_WB. On my local >> ARM device, memset in dma_alloc_from_coherent sometimes takes much longer with >> MEMREMAP_WC compared to MEMREMAP_WB. >> >> Test results on AArch64 by allocating 4MB with putting trace_printk right >> before and after memset. >> MEMREMAP_WC : 11.0ms, 5.7ms, 4.2ms, 4.9ms, 5.4ms, 4.3ms, 3.5ms >> MEMREMAP_WB : 0.7ms, 0.6ms, 0.6ms, 0.6ms, 0.6ms, 0.5ms, 0.4 ms >> > > This doesn't look like a good idea to me. The point of coherent memory > is to have it non-cached, however WB will make writes hit the cache. > > Writing to the cache is of course faster than writing to RAM, but > that's not what we want to do here. > > -Brian > Hi Brian Thank you for your comment. If allocated memory will be used by TZ side, however, I think cacheable also can be used to be fast on memset in dma_alloc_from_coherent. How do you think to add another flag to distinguish this case? >> Signed-off-by: Jaewon Kim >> --- >> drivers/base/dma-coherent.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c >> index 640a7e6..0512a1d 100644 >> --- a/drivers/base/dma-coherent.c >> +++ b/drivers/base/dma-coherent.c >> @@ -33,7 +33,7 @@ static bool dma_init_coherent_memory( >> goto out; >> >> if (flags & DMA_MEMORY_MAP) >> - mem_base = memremap(phys_addr, size, MEMREMAP_WC); >> + mem_base = memremap(phys_addr, size, MEMREMAP_WB); >> else >> mem_base = ioremap(phys_addr, size); >> if (!mem_base) >> -- >> 1.9.1 >> > > >