[RFC PATCH v2] android: ion: How to properly clean caches for uncached allocations

2018-11-01 Thread Liam Mark
apping. Please let me know if this is heading in the right direction and if there are any concerns. Signed-off-by: Liam Mark --- drivers/staging/android/ion/ion.c | 146 +- drivers/staging/android/ion/ion.h | 9 +++ 2 files changed, 152 insertions(+), 3 del

Re: [RFC PATCH v2] android: ion: How to properly clean caches for uncached allocations

2018-11-06 Thread Liam Mark
On Fri, 2 Nov 2018, John Stultz wrote: > On Thu, Nov 1, 2018 at 3:15 PM, Liam Mark wrote: > > Based on the suggestions from Laura I created a first draft for a change > > which will attempt to ensure that uncached mappings are only applied to > > ION memory who's cac

Re: [RFC PATCH v2] android: ion: How to properly clean caches for uncached allocations

2018-11-26 Thread Liam Mark
hich > certainly seem to be related to what you're trying to fix here. > > On Thu, Nov 01, 2018 at 03:15:06PM -0700, Liam Mark wrote: > >Based on the suggestions from Laura I created a first draft for a change > >which will attempt to ensure that uncached mappings are onl

Re: [RFC PATCH v2] android: ion: How to properly clean caches for uncached allocations

2018-11-27 Thread Liam Mark
On Tue, 27 Nov 2018, Brian Starkey wrote: > Hi Liam, > > On Mon, Nov 26, 2018 at 08:59:44PM -0800, Liam Mark wrote: > > On Tue, 20 Nov 2018, Brian Starkey wrote: > > > > > Hi Liam, > > > > > > I'm missing a bit of context here, but I did re

Re: [RFC PATCH v2] android: ion: How to properly clean caches for uncached allocations

2018-11-28 Thread Liam Mark
On Wed, 28 Nov 2018, Brian Starkey wrote: > Hi Liam, > > On Tue, Nov 27, 2018 at 10:46:07PM -0800, Liam Mark wrote: > > On Tue, 27 Nov 2018, Brian Starkey wrote: > > > > > Hi Liam, > > > > > > On Mon, Nov 26, 2018 at 08:59:44PM -0800, Liam Mark w

Re: [PATCH v3] staging: android: ion: Add implementation of dma_buf_vmap and dma_buf_vunmap

2018-12-15 Thread Liam Mark
On Tue, 6 Feb 2018, Alexey Skidanov wrote: > > > On 02/07/2018 01:56 AM, Laura Abbott wrote: > > On 01/31/2018 10:10 PM, Alexey Skidanov wrote: > >> > >> On 01/31/2018 03:00 PM, Greg KH wrote: > >>> On Wed, Jan 31, 2018 at 02:03:42PM +0200, Alexey Skidanov wrote: > Any driver may access sha

Re: [PATCH v3] staging: android: ion: Add implementation of dma_buf_vmap and dma_buf_vunmap

2018-12-17 Thread Liam Mark
On Sun, 16 Dec 2018, Alexey Skidanov wrote: > > > On 12/16/18 7:20 AM, Liam Mark wrote: > > On Tue, 6 Feb 2018, Alexey Skidanov wrote: > > > >> > >> > >> On 02/07/2018 01:56 AM, Laura Abbott wrote: > >>> On 01/31/2018 10:10 PM, Alexe

Re: [PATCH v3] staging: android: ion: Add implementation of dma_buf_vmap and dma_buf_vunmap

2019-01-04 Thread Liam Mark
On Tue, 18 Dec 2018, Alexey Skidanov wrote: > >>> I was wondering if we could re-open the discussion on adding support to > >>> ION for dma_buf_vmap. > >>> It seems like the patch was not taken as the reviewers wanted more > >>> evidence of an upstream use case. > >>> > >>> Here would be my upst

Re: [PATCH 13/14] staging: android: ion: Do not sync CPU cache on map/unmap

2019-01-14 Thread Liam Mark
On Fri, 11 Jan 2019, Andrew F. Davis wrote: > Buffers may not be mapped from the CPU so skip cache maintenance here. > Accesses from the CPU to a cached heap should be bracketed with > {begin,end}_cpu_access calls so maintenance should not be needed anyway. > > Signed-off-by: Andrew F. Davis > -

Re: [PATCH 13/14] staging: android: ion: Do not sync CPU cache on map/unmap

2019-01-15 Thread Liam Mark
On Tue, 15 Jan 2019, Andrew F. Davis wrote: > On 1/14/19 11:13 AM, Liam Mark wrote: > > On Fri, 11 Jan 2019, Andrew F. Davis wrote: > > > >> Buffers may not be mapped from the CPU so skip cache maintenance here. > >> Accesses from the CPU to a cached heap should

Re: [PATCH 13/14] staging: android: ion: Do not sync CPU cache on map/unmap

2019-01-16 Thread Liam Mark
On Wed, 16 Jan 2019, Andrew F. Davis wrote: > On 1/15/19 1:05 PM, Laura Abbott wrote: > > On 1/15/19 10:38 AM, Andrew F. Davis wrote: > >> On 1/15/19 11:45 AM, Liam Mark wrote: > >>> On Tue, 15 Jan 2019, Andrew F. Davis wrote: > >>> > >>>>

Re: [PATCH 13/14] staging: android: ion: Do not sync CPU cache on map/unmap

2019-01-16 Thread Liam Mark
On Wed, 16 Jan 2019, Andrew F. Davis wrote: > On 1/16/19 9:19 AM, Brian Starkey wrote: > > Hi :-) > > > > On Tue, Jan 15, 2019 at 12:40:16PM -0600, Andrew F. Davis wrote: > >> On 1/15/19 12:38 PM, Andrew F. Davis wrote: > >>> On 1/15/19 11:45 AM, L

Re: [PATCH 13/14] staging: android: ion: Do not sync CPU cache on map/unmap

2019-01-17 Thread Liam Mark
On Thu, 17 Jan 2019, Andrew F. Davis wrote: > On 1/16/19 4:48 PM, Liam Mark wrote: > > On Wed, 16 Jan 2019, Andrew F. Davis wrote: > > > >> On 1/15/19 1:05 PM, Laura Abbott wrote: > >>> On 1/15/19 10:38 AM, Andrew F. Davis wrote: > >>>> On 1/

Re: [PATCH 13/14] staging: android: ion: Do not sync CPU cache on map/unmap

2019-01-17 Thread Liam Mark
On Thu, 17 Jan 2019, Andrew F. Davis wrote: > On 1/16/19 4:54 PM, Liam Mark wrote: > > On Wed, 16 Jan 2019, Andrew F. Davis wrote: > > > >> On 1/16/19 9:19 AM, Brian Starkey wrote: > >>> Hi :-) > >>> > >>> On Tue, Jan 15, 2019 at 12:4

[PATCH 2/4] staging: android: ion: Restrict cache maintenance to dma mapped memory

2019-01-18 Thread Liam Mark
("staging: android: ion: Call dma_map_sg for syncing and mapping") Signed-off-by: Liam Mark --- drivers/staging/android/ion/ion.c | 26 +- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android

[PATCH 1/4] staging: android: ion: Support cpu access during dma_buf_detach

2019-01-18 Thread Liam Mark
Fixes: 2a55e7b5e544 ("staging: android: ion: Call dma_map_sg for syncing and mapping") Signed-off-by: Liam Mark --- drivers/staging/android/ion/ion.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/

[PATCH 3/4] dma-buf: add support for mapping with dma mapping attributes

2019-01-18 Thread Liam Mark
Add support for configuring dma mapping attributes when mapping and unmapping memory through dma_buf_map_attachment and dma_buf_unmap_attachment. Signed-off-by: Liam Mark --- include/linux/dma-buf.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/dma-buf.h b/include/linux

[PATCH 0/4] ION stability and perf changes

2019-01-18 Thread Liam Mark
Some stability changes to improve ION robustness and a perf related change to make it easier for clients to avoid unnecessary cache maintenance, such as when buffers are clean and haven't had any CPU access. Liam Mark (4): staging: android: ion: Support cpu access during dma_buf_d

[PATCH 4/4] staging: android: ion: Support for mapping with dma mapping attributes

2019-01-18 Thread Liam Mark
been accessed by the CPU. Signed-off-by: Liam Mark --- drivers/staging/android/ion/ion.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 1fe633a7fdba..0aae845b20ba 100644 --- a/drivers/staging/androi

Re: [PATCH 2/4] staging: android: ion: Restrict cache maintenance to dma mapped memory

2019-01-18 Thread Liam Mark
On Fri, 18 Jan 2019, Andrew F. Davis wrote: > On 1/18/19 12:37 PM, Liam Mark wrote: > > The ION begin_cpu_access and end_cpu_access functions use the > > dma_sync_sg_for_cpu and dma_sync_sg_for_device APIs to perform cache > > maintenance. > > > > Curren

Re: [PATCH 3/4] dma-buf: add support for mapping with dma mapping attributes

2019-01-18 Thread Liam Mark
On Fri, 18 Jan 2019, Laura Abbott wrote: > On 1/18/19 10:37 AM, Liam Mark wrote: > > Add support for configuring dma mapping attributes when mapping > > and unmapping memory through dma_buf_map_attachment and > > dma_buf_unmap_attachment. > > > > Signed-off-by:

Re: [PATCH 13/14] staging: android: ion: Do not sync CPU cache on map/unmap

2019-01-18 Thread Liam Mark
On Fri, 18 Jan 2019, Andrew F. Davis wrote: > On 1/17/19 7:04 PM, Liam Mark wrote: > > On Thu, 17 Jan 2019, Andrew F. Davis wrote: > > > >> On 1/16/19 4:48 PM, Liam Mark wrote: > >>> On Wed, 16 Jan 2019, Andrew F. Davis wrote: > >>> > >>&

Re: [PATCH 3/4] dma-buf: add support for mapping with dma mapping attributes

2019-01-21 Thread Liam Mark
On Mon, 21 Jan 2019, Christoph Hellwig wrote: > On Sat, Jan 19, 2019 at 08:50:41AM -0800, Laura Abbott wrote: > > > And who is going to decide which ones to pass? And who documents > > > which ones are safe? > > > > > > I'd much rather have explicit, well documented dma-buf flags that > > > migh

Re: [PATCH 13/14] staging: android: ion: Do not sync CPU cache on map/unmap

2019-01-21 Thread Liam Mark
On Mon, 21 Jan 2019, Andrew F. Davis wrote: > On 1/18/19 3:43 PM, Liam Mark wrote: > > On Fri, 18 Jan 2019, Andrew F. Davis wrote: > > > >> On 1/17/19 7:04 PM, Liam Mark wrote: > >>> On Thu, 17 Jan 2019, Andrew F. Davis wrote: > >>> > >>&

Re: [PATCH 13/14] staging: android: ion: Do not sync CPU cache on map/unmap

2019-01-21 Thread Liam Mark
On Fri, 18 Jan 2019, Andrew F. Davis wrote: > On 1/17/19 7:11 PM, Liam Mark wrote: > > On Thu, 17 Jan 2019, Andrew F. Davis wrote: > > > >> On 1/16/19 4:54 PM, Liam Mark wrote: > >>> On Wed, 16 Jan 2019, Andrew F. Davis wrote: > >>> > >&

Re: [PATCH 3/4] dma-buf: add support for mapping with dma mapping attributes

2019-01-21 Thread Liam Mark
On Mon, 21 Jan 2019, Andrew F. Davis wrote: > On 1/21/19 1:44 PM, Liam Mark wrote: > > On Mon, 21 Jan 2019, Christoph Hellwig wrote: > > > >> On Sat, Jan 19, 2019 at 08:50:41AM -0800, Laura Abbott wrote: > >>>> And who is going to decide which ones to pas

Re: [PATCH 3/4] dma-buf: add support for mapping with dma mapping attributes

2019-01-21 Thread Liam Mark
On Mon, 21 Jan 2019, Christoph Hellwig wrote: > On Mon, Jan 21, 2019 at 11:44:10AM -0800, Liam Mark wrote: > > The main use case is for allowing clients to pass in > > DMA_ATTR_SKIP_CPU_SYNC in order to skip the default cache maintenance > > which happens in dma_b

Re: [PATCH 3/4] dma-buf: add support for mapping with dma mapping attributes

2019-01-21 Thread Liam Mark
On Mon, 21 Jan 2019, Christoph Hellwig wrote: > On Mon, Jan 21, 2019 at 12:20:42PM -0800, Liam Mark wrote: > > I have left this to clients, but if they own the buffer they can have the > > knowledge as to whether CPU access is needed in that use case (example for > > post-p

Re: [PATCH 3/4] dma-buf: add support for mapping with dma mapping attributes

2019-01-21 Thread Liam Mark
On Mon, 21 Jan 2019, Andrew F. Davis wrote: > On 1/21/19 2:20 PM, Liam Mark wrote: > > On Mon, 21 Jan 2019, Andrew F. Davis wrote: > > > >> On 1/21/19 1:44 PM, Liam Mark wrote: > >>> On Mon, 21 Jan 2019, Christoph Hellwig wrote: > >>> > >>

Re: [PATCH 4/4] staging: android: ion: Support for mapping with dma mapping attributes

2019-01-22 Thread Liam Mark
On Mon, 21 Jan 2019, Brian Starkey wrote: > Hi Liam, > > On Fri, Jan 18, 2019 at 10:37:47AM -0800, Liam Mark wrote: > > Add support for configuring dma mapping attributes when mapping > > and unmapping memory through dma_buf_map_attachment and > > dma_buf_unmap_attac

Re: [PATCH 3/4] dma-buf: add support for mapping with dma mapping attributes

2019-01-22 Thread Liam Mark
On Tue, 22 Jan 2019, Andrew F. Davis wrote: > On 1/21/19 4:18 PM, Liam Mark wrote: > > On Mon, 21 Jan 2019, Andrew F. Davis wrote: > > > >> On 1/21/19 2:20 PM, Liam Mark wrote: > >>> On Mon, 21 Jan 2019, Andrew F. Davis wrote: > >>> > >>&

Re: [PATCH 3/4] dma-buf: add support for mapping with dma mapping attributes

2019-01-22 Thread Liam Mark
On Tue, 22 Jan 2019, Andrew F. Davis wrote: > On 1/21/19 4:12 PM, Liam Mark wrote: > > On Mon, 21 Jan 2019, Christoph Hellwig wrote: > > > >> On Mon, Jan 21, 2019 at 11:44:10AM -0800, Liam Mark wrote: > >>> The main use case is for allowing clients to pass

Re: [PATCH 13/14] staging: android: ion: Do not sync CPU cache on map/unmap

2019-01-22 Thread Liam Mark
On Mon, 21 Jan 2019, Brian Starkey wrote: > Hi, > > Sorry for being a bit sporadic on this. I was out travelling last week > with little time for email. > > On Fri, Jan 18, 2019 at 11:16:31AM -0600, Andrew F. Davis wrote: > > On 1/17/19 7:11 PM, Liam Mark wrote: &

Re: [PATCH 2/4] staging: android: ion: Restrict cache maintenance to dma mapped memory

2019-01-29 Thread Liam Mark
On Fri, 18 Jan 2019, Liam Mark wrote: > On Fri, 18 Jan 2019, Andrew F. Davis wrote: > > > On 1/18/19 12:37 PM, Liam Mark wrote: > > > The ION begin_cpu_access and end_cpu_access functions use the > > > dma_sync_sg_for_cpu and dma_sync_sg_for_device APIs to p

RE: [PATCH v3] staging: android: ion: Add implementation of dma_buf_vmap and dma_buf_vunmap

2019-01-29 Thread Liam Mark
On Fri, 4 Jan 2019, Skidanov, Alexey wrote: > > > > -Original Message- > > From: Liam Mark [mailto:lm...@codeaurora.org] > > Sent: Friday, January 04, 2019 19:42 > > To: Skidanov, Alexey > > Cc: Laura Abbott ; Greg KH ; > > de...@

Re: [Linaro-mm-sig] [PATCH 2/4] staging: android: ion: Restrict cache maintenance to dma mapped memory

2019-02-28 Thread Liam Mark
+ Sumit Hi Sumit, Do you have any thoughts on this patch? It fixes a potential crash in on older kernel and I think limiting begin/end_cpu_access to only apply cache maintenance when the buffer is dma mapped makes sense from a logical perspective and performance perspective. On Wed, 6 Feb

[PATCH] staging: android: ion: Zero CMA allocated memory

2018-01-19 Thread Liam Mark
Since the CMA API is now used directly the allocated memory is no longer automatically zeroed. Explicitly zero CMA allocated memory to ensure that no data is exposed to userspace. Change-Id: I08e143707a0d31610821a7f16826c262bf3c1999 Signed-off-by: Liam Mark --- drivers/staging/android/ion

Re: [PATCH] staging: android: ion: Zero CMA allocated memory

2018-01-22 Thread Liam Mark
On Fri, 19 Jan 2018, Dan Carpenter wrote: > On Fri, Jan 19, 2018 at 11:16:47AM -0800, Liam Mark wrote: > > Since the CMA API is now used directly the allocated memory is no longer > > automatically zeroed. > > > > Explicitly zero CMA allocated memory to ensure tha

Re: [PATCH] staging: android: ion: Zero CMA allocated memory

2018-01-22 Thread Liam Mark
On Sat, 20 Jan 2018, Greg KH wrote: > On Fri, Jan 19, 2018 at 11:16:47AM -0800, Liam Mark wrote: > > Since the CMA API is now used directly the allocated memory is no longer > > automatically zeroed. > > > > Explicitly zero CMA allocated memory to ensure that no data

[PATCH v2] staging: android: ion: Zero CMA allocated memory

2018-01-22 Thread Liam Mark
("staging: android: ion: Use CMA APIs directly") Signed-off-by: Liam Mark --- Changes in v2: - Clean up the commit message. - Add 'Fixes:' drivers/staging/android/ion/ion_cma_heap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/android/ion/ion_cma_hea

Re: [PATCH v2] staging: android: ion: Zero CMA allocated memory

2018-01-24 Thread Liam Mark
On Wed, 24 Jan 2018, Laura Abbott wrote: > On 01/22/2018 09:46 AM, Liam Mark wrote: > > Since commit 204f672255c2 ("staging: android: ion: Use CMA APIs directly") > > the CMA API is now used directly and therefore the allocated memory is no > > longer automatica

[PATCH v3] staging: android: ion: Zero CMA allocated memory

2018-01-26 Thread Liam Mark
("staging: android: ion: Use CMA APIs directly") Signed-off-by: Liam Mark --- Changes in v2: - Clean up the commit message. - Add 'Fixes:' Changes in v3: - Add support for highmem pages drivers/staging/android/ion/ion_cma_heap.c | 17 + 1 file changed,

[PATCH] staging: android: ion: Initialize dma_address of new sg list

2018-02-09 Thread Liam Mark
Fix the dup_sg_table function to initialize the dma_address of the new sg list entries instead of the source dma_address entries. Fixes: 17fd283f3870 ("staging: android: ion: Duplicate sg_table") Signed-off-by: Liam Mark --- drivers/staging/android/ion/ion.c | 2 +- 1 file changed, 1

[PATCH] staging: android: ion: Restrict cache maintenance to dma mapped memory

2018-02-09 Thread Liam Mark
pping") Signed-off-by: Liam Mark --- drivers/staging/android/ion/ion.c | 16 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index f480885e346b..e5df5272823d 100644 --- a/drivers/staging/android

Re: [PATCH] staging: android: ion: Initialize dma_address of new sg list

2018-02-12 Thread Liam Mark
On Mon, 12 Feb 2018, Dan Carpenter wrote: > On Fri, Feb 09, 2018 at 10:16:56PM -0800, Liam Mark wrote: > > Fix the dup_sg_table function to initialize the dma_address of the new > > sg list entries instead of the source dma_address entries. > > > > Fixes: 17fd283f3

Re: [PATCH] staging: android: ion: Restrict cache maintenance to dma mapped memory

2018-02-12 Thread Liam Mark
On Mon, 12 Feb 2018, Laura Abbott wrote: > On 02/09/2018 10:21 PM, Liam Mark wrote: > > The ION begin_cpu_access and end_cpu_access functions use the > > dma_sync_sg_for_cpu and dma_sync_sg_for_device APIs to perform cache > > maintenance. > > > > Curren

Re: [PATCH] staging: android: ion: Initialize dma_address of new sg list

2018-02-16 Thread Liam Mark
On Thu, 15 Feb 2018, Laura Abbott wrote: > On 02/12/2018 01:25 PM, Liam Mark wrote: > > > > On Mon, 12 Feb 2018, Dan Carpenter wrote: > > > > > On Fri, Feb 09, 2018 at 10:16:56PM -0800, Liam Mark wrote: > > > > Fix the dup_sg_table function to initia

Re: [PATCH] staging: android: ion: Initialize dma_address of new sg list

2018-02-16 Thread Liam Mark
On Fri, 16 Feb 2018, Greg KH wrote: > On Fri, Feb 09, 2018 at 10:16:56PM -0800, Liam Mark wrote: > > Fix the dup_sg_table function to initialize the dma_address of the new > > sg list entries instead of the source dma_address entries. > > > > Fixes: 17fd283f3

[PATCH v2] staging: android: ion: Initialize dma_address of new sg list

2018-02-16 Thread Liam Mark
Fix the dup_sg_table function to initialize the dma_address of the new sg list entries instead of the source dma_address entries. Since ION duplicates the sg_list this issue does not appear to result in an actual bug. Signed-off-by: Liam Mark Acked-by: Laura Abbott --- Changes in v2: - Add

[RFC] android: ion: How to properly clean caches for uncached allocations

2018-02-28 Thread Liam Mark
where there is minimal CPU access and therefore uncached memory performs better. Signed-off-by: Liam Mark --- drivers/staging/android/ion/ion.c | 16 drivers/staging/android/ion/ion.h | 5 - drivers/staging/android/ion/ion_cma_heap.c| 3

Re: [RFC] android: ion: How to properly clean caches for uncached allocations

2018-03-08 Thread Liam Mark
On Wed, 7 Mar 2018, Laura Abbott wrote: > On 02/28/2018 09:18 PM, Liam Mark wrote: > > The issue: > > > > Currently in ION if you allocate uncached memory it is possible that there > > are still dirty lines in the cache. And often these dirty lines in the > &g