[U-Boot] [PATCH] nios2: convert cache flush to use dm cpu data

2015-10-06 Thread Thomas Chou
Convert cache flush to use dm cpu data. The cacheflush.c of Linux nios2 arch is copied to arch/nios2/lib/cache.c to replace the cache.S. The cache related functions in cpu.c is moved to cache.c. Both flush_dcache() and flush_icache() are replaced and removed. The flush_dcache_all() now flush icache

Re: [U-Boot] [PATCH] nios2: convert cache flush to use dm cpu data

2015-10-08 Thread Marek Vasut
On Tuesday, October 06, 2015 at 10:20:00 AM, Thomas Chou wrote: > Convert cache flush to use dm cpu data. The cacheflush.c of > Linux nios2 arch is copied to arch/nios2/lib/cache.c to replace > the cache.S. The cache related functions in cpu.c is moved > to cache.c. Both flush_dcache() and flush_ic

Re: [U-Boot] [PATCH] nios2: convert cache flush to use dm cpu data

2015-10-08 Thread Ley Foon Tan
On Fri, Oct 9, 2015 at 5:39 AM, Marek Vasut wrote: >> + >> +DECLARE_GLOBAL_DATA_PTR; >> + >> +static void __flush_dcache_all(unsigned long start, unsigned long end) >> +{ >> + unsigned long addr; >> + >> + start &= ~(gd->arch.dcache_line_size - 1); > > I'd suggest to use GENMASK() here, b

Re: [U-Boot] [PATCH] nios2: convert cache flush to use dm cpu data

2015-10-09 Thread Thomas Chou
Hi Marek, On 10/09/2015 10:49 AM, Ley Foon Tan wrote: Is this an attempt at poor-mans' rounding ? I think you want to implment something like arch/arm/cpu/arm926ejs/cache.c check_cache_range() and NOT do any rounding here. The reason for that is that if you do rounding, you might accidentally co

Re: [U-Boot] [PATCH] nios2: convert cache flush to use dm cpu data

2015-10-09 Thread Marek Vasut
On Friday, October 09, 2015 at 04:49:03 AM, Ley Foon Tan wrote: > On Fri, Oct 9, 2015 at 5:39 AM, Marek Vasut wrote: > >> + > >> +DECLARE_GLOBAL_DATA_PTR; > >> + > >> +static void __flush_dcache_all(unsigned long start, unsigned long end) > >> +{ > >> + unsigned long addr; > >> + > >> + st

Re: [U-Boot] [PATCH] nios2: convert cache flush to use dm cpu data

2015-10-09 Thread Marek Vasut
On Friday, October 09, 2015 at 10:00:26 AM, Thomas Chou wrote: > Hi Marek, > > On 10/09/2015 10:49 AM, Ley Foon Tan wrote: > >> Is this an attempt at poor-mans' rounding ? I think you want to implment > >> something like arch/arm/cpu/arm926ejs/cache.c check_cache_range() and > >> NOT do any roundi

Re: [U-Boot] [PATCH] nios2: convert cache flush to use dm cpu data

2015-10-09 Thread Thomas Chou
Hi Marek, On 10/09/2015 10:42 PM, Marek Vasut wrote: In nios2, we don't skip the flushing when the inputs are not aligned like that of arm926ejs. We always flush all cache lines in the range, even if a single byte to flush is in request. So the inputs are rounded to get the lower and upper cache

Re: [U-Boot] [PATCH] nios2: convert cache flush to use dm cpu data

2015-10-09 Thread Thomas Chou
Hi Marek, On 10/10/2015 01:55 PM, Thomas Chou wrote: Hi Marek, On 10/09/2015 10:42 PM, Marek Vasut wrote: In nios2, we don't skip the flushing when the inputs are not aligned like that of arm926ejs. We always flush all cache lines in the range, even if a single byte to flush is in request. So

Re: [U-Boot] [PATCH] nios2: convert cache flush to use dm cpu data

2015-10-10 Thread Marek Vasut
On Saturday, October 10, 2015 at 07:55:45 AM, Thomas Chou wrote: > Hi Marek, Hi, > On 10/09/2015 10:42 PM, Marek Vasut wrote: > >> In nios2, we don't skip the flushing when the inputs are not aligned > >> like that of arm926ejs. We always flush all cache lines in the range, > >> even if a single

Re: [U-Boot] [PATCH] nios2: convert cache flush to use dm cpu data

2015-10-10 Thread Marek Vasut
On Saturday, October 10, 2015 at 08:32:09 AM, Thomas Chou wrote: > Hi Marek, Hi, > On 10/10/2015 01:55 PM, Thomas Chou wrote: > > Hi Marek, > > > > On 10/09/2015 10:42 PM, Marek Vasut wrote: > >>> In nios2, we don't skip the flushing when the inputs are not aligned > >>> like that of arm926ejs.

Re: [U-Boot] [PATCH] nios2: convert cache flush to use dm cpu data

2015-10-10 Thread Thomas Chou
Hi Marek, On 10/11/2015 02:18 AM, Marek Vasut wrote: Then you'd also need means to allocate variables to aligned memory location to prevent invalid cache flush. (Linux does this with it's DMA API). We are much simpler and thus this abstraction is still not available. I wonder if the overhead of

Re: [U-Boot] [PATCH] nios2: convert cache flush to use dm cpu data

2015-10-11 Thread Marek Vasut
On Sunday, October 11, 2015 at 02:38:35 AM, Thomas Chou wrote: > Hi Marek, Hi, > On 10/11/2015 02:18 AM, Marek Vasut wrote: > > Then you'd also need means to allocate variables to aligned memory > > location to prevent invalid cache flush. (Linux does this with it's DMA > > API). We are much simp

Re: [U-Boot] [PATCH] nios2: convert cache flush to use dm cpu data

2015-10-11 Thread Thomas Chou
Hi Marek, On 10/11/2015 08:15 PM, Marek Vasut wrote: On Sunday, October 11, 2015 at 02:38:35 AM, Thomas Chou wrote: Hi Marek, Hi, On 10/11/2015 02:18 AM, Marek Vasut wrote: Then you'd also need means to allocate variables to aligned memory location to prevent invalid cache flush. (Linux do

Re: [U-Boot] [PATCH] nios2: convert cache flush to use dm cpu data

2015-10-12 Thread Marek Vasut
On Monday, October 12, 2015 at 02:34:16 AM, Thomas Chou wrote: > Hi Marek, Hi! > On 10/11/2015 08:15 PM, Marek Vasut wrote: > > On Sunday, October 11, 2015 at 02:38:35 AM, Thomas Chou wrote: > >> Hi Marek, > > > > Hi, > > > >> On 10/11/2015 02:18 AM, Marek Vasut wrote: > >>> Then you'd also nee

Re: [U-Boot] [PATCH] nios2: convert cache flush to use dm cpu data

2015-10-12 Thread Thomas Chou
Hi Marek, On 10/12/2015 06:30 PM, Marek Vasut wrote: There are also DEFINE_CACHE_ALIGN_BUFFER() and ALLOC_CACHE_ALIGN_BUFFER() macros which can be used to allocate such stuff on stack. And you sometimes do want to allocate things on stack instead of using malloc(). Thanks for sharing this. S

Re: [U-Boot] [PATCH] nios2: convert cache flush to use dm cpu data

2015-10-12 Thread Marek Vasut
On Monday, October 12, 2015 at 03:12:18 PM, Thomas Chou wrote: > Hi Marek, > > On 10/12/2015 06:30 PM, Marek Vasut wrote: > > There are also DEFINE_CACHE_ALIGN_BUFFER() and ALLOC_CACHE_ALIGN_BUFFER() > > macros which can be used to allocate such stuff on stack. And you > > sometimes do want to all

Re: [U-Boot] [PATCH] nios2: convert cache flush to use dm cpu data

2015-10-12 Thread Wolfgang Denk
Dear Marek, In message <201510121529.45730.ma...@denx.de> you wrote: > > That is bad bad bad, that's even nastier. We really need to fix the drivers, > not paper over it in the cache ops. Full ACK here. > > To solve problem like this, the only solution is to enforce the rule to > > allocate DMA

Re: [U-Boot] [PATCH] nios2: convert cache flush to use dm cpu data

2015-10-12 Thread Thomas Chou
Hi Marek, On 10/12/2015 09:29 PM, Marek Vasut wrote: On Monday, October 12, 2015 at 03:12:18 PM, Thomas Chou wrote: Hi Marek, On 10/12/2015 06:30 PM, Marek Vasut wrote: There are also DEFINE_CACHE_ALIGN_BUFFER() and ALLOC_CACHE_ALIGN_BUFFER() macros which can be used to allocate such stuff on

Re: [U-Boot] [PATCH] nios2: convert cache flush to use dm cpu data

2015-10-16 Thread Marek Vasut
On Tuesday, October 13, 2015 at 03:04:44 AM, Thomas Chou wrote: > Hi Marek, Hi! > On 10/12/2015 09:29 PM, Marek Vasut wrote: > > On Monday, October 12, 2015 at 03:12:18 PM, Thomas Chou wrote: > >> Hi Marek, > >> > >> On 10/12/2015 06:30 PM, Marek Vasut wrote: > >>> There are also DEFINE_CACHE_AL

Re: [U-Boot] [PATCH] nios2: convert cache flush to use dm cpu data

2015-10-16 Thread Thomas Chou
Hi Marek, On 10/17/2015 07:03 AM, Marek Vasut wrote: I would suggest the "cache alignment check and skip" be removed from cache flush ops, and say out the DMA buffer allocation rule loudly in README, and enforce it by guardianship. What exactly do you envision by this "guardianship" ? I mean

Re: [U-Boot] [PATCH] nios2: convert cache flush to use dm cpu data

2015-10-17 Thread Marek Vasut
On Saturday, October 17, 2015 at 05:22:41 AM, Thomas Chou wrote: > Hi Marek, Hi! > On 10/17/2015 07:03 AM, Marek Vasut wrote: > >> I would suggest the "cache alignment check and skip" be removed from > >> cache flush ops, and say out the DMA buffer allocation rule loudly in > >> README, and enfor