MIPS: Extend plat_* abstractions, cache support
cover MIPS: Extend plat_* abstractions, cache support
Hi,
I am upgrading an SoC to the 2.6.29.1 kernel from an earlier version, and in the process I am switching over the old board support customizations to use the newer, cleaner plat_* functions. I found two cases where the plat_* functions did not provide enough information, so I had to modify the API:
plat_unmap_dma_mem() - Our handler needs to know the size and direction of the DMA mapping. This information is not encoded in the DMA address, so it needed to be passed in explicitly.
plat_dma_addr_to_phys() - The bus<->physical address mappings differ based on which bus is being used. It is not always possible to infer which bus is being used from the bus address alone, so I added a "struct device" to the function definition.
Also, our MIPS core uses 64-byte D$ lines, so I needed to generate the corresponding blast* functions.
These patches apply against the linux-mips.org GIT tree.
PATCH 1/3 MIPS: Add size and direction arguments to plat_unmap_dma_mem()
--- .../include/asm/mach-cavium-octeon/dma-coherence.h | 3 ++- arch/mips/include/asm/mach-generic/dma-coherence.h | 3 ++- arch/mips/include/asm/mach-ip27/dma-coherence.h | 3 ++- arch/mips/include/asm/mach-ip32/dma-coherence.h | 3 ++- arch/mips/include/asm/mach-jazz/dma-coherence.h | 3 ++- arch/mips/include/asm/mach-lemote/dma-coherence.h | 3 ++- arch/mips/mm/dma-default.c | 8 ++++---- 7 files changed, 16 insertions(+), 10 deletions(-)
arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h +2 -1
@@ -35,7 +35,8 @@ static inline unsigned long plat_dma_addr_to_phys(dma_addr_t dma_addr)return dma_addr; } -static inline void plat_unmap_dma_mem (struct device *dev,dma_addr_t dma_addr) +static inline void plat_unmap_dma_mem (struct device *dev,dma_addr_t dma_addr, +size_t size,enum dma_data_direction direction) {octeon_unmap_dma_mem (dev, dma_addr); }
arch/mips/include/asm/mach-generic/dma-coherence.h +2 -1
@@ -28,7 +28,8 @@ static inline unsigned long plat_dma_addr_to_phys(dma_addr_t dma_addr)return dma_addr; } -static inline void plat_unmap_dma_mem (struct device *dev,dma_addr_t dma_addr) +static inline void plat_unmap_dma_mem (struct device *dev,dma_addr_t dma_addr, +size_t size,enum dma_data_direction direction) { }
arch/mips/include/asm/mach-ip27/dma-coherence.h +2 -1
@@ -38,7 +38,8 @@ static unsigned long plat_dma_addr_to_phys(dma_addr_t dma_addr)return dma_addr & ~(0xffUL <<56 ); } -static inline void plat_unmap_dma_mem (struct device *dev,dma_addr_t dma_addr) +static inline void plat_unmap_dma_mem (struct device *dev,dma_addr_t dma_addr, +size_t size,enum dma_data_direction direction) { }
arch/mips/include/asm/mach-ip32/dma-coherence.h +2 -1
@@ -60,7 +60,8 @@ static unsigned long plat_dma_addr_to_phys(dma_addr_t dma_addr)return addr; } -static inline void plat_unmap_dma_mem (struct device *dev,dma_addr_t dma_addr) +static inline void plat_unmap_dma_mem (struct device *dev,dma_addr_t dma_addr, +size_t size,enum dma_data_direction direction) { }
arch/mips/include/asm/mach-jazz/dma-coherence.h +2 -1
@@ -27,7 +27,8 @@ static unsigned long plat_dma_addr_to_phys(dma_addr_t dma_addr)return vdma_log2phys (dma_addr); } -static void plat_unmap_dma_mem (struct device *dev,dma_addr_t dma_addr) +static void plat_unmap_dma_mem (struct device *dev,dma_addr_t dma_addr, +size_t size,enum dma_data_direction direction) {vdma_free (dma_addr); }
arch/mips/include/asm/mach-lemote/dma-coherence.h +2 -1
@@ -30,7 +30,8 @@ static inline unsigned long plat_dma_addr_to_phys(dma_addr_t dma_addr)return dma_addr &0x7fffffff ; } -static inline void plat_unmap_dma_mem (struct device *dev,dma_addr_t dma_addr) +static inline void plat_unmap_dma_mem (struct device *dev,dma_addr_t dma_addr, +size_t size,enum dma_data_direction direction) { }
arch/mips/mm/dma-default.c +4 -4
@@ -111,7 +111,7 @@ EXPORT_SYMBOL(dma_alloc_coherent);void dma_free_noncoherent (struct device *dev,size_t size,void *vaddr,dma_addr_t dma_handle) { -plat_unmap_dma_mem (dev, dma_handle); +plat_unmap_dma_mem (dev, dma_handle, size,DMA_BIDIRECTIONAL );free_pages ((unsigned long ) vaddr,get_order (size)); }
@@ -122,7 +122,7 @@ void dma_free_coherent(struct device *dev, size_t size, void *vaddr, {unsigned long addr = (unsigned long ) vaddr; -plat_unmap_dma_mem (dev, dma_handle); +plat_unmap_dma_mem (dev, dma_handle, size,DMA_BIDIRECTIONAL );if (!plat_device_is_coherent (dev)) addr =CAC_ADDR (addr);
@@ -173,7 +173,7 @@ void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,__dma_sync (dma_addr_to_virt (dma_addr), size, direction); -plat_unmap_dma_mem (dev, dma_addr); +plat_unmap_dma_mem (dev, dma_addr, size, direction); }EXPORT_SYMBOL (dma_unmap_single);
@@ -232,7 +232,7 @@ void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,if (addr)__dma_sync (addr, sg->length, direction); } -plat_unmap_dma_mem (dev, sg->dma_address); +plat_unmap_dma_mem (dev, sg->dma_address, sg->length, direction); } }
Signature · 1 line
1.5.3.6
PATCH 2/3 MIPS: Pass struct device to plat_dma_addr_to_phys()
In reply to Kevin Cernekee--- .../include/asm/mach-cavium-octeon/dma-coherence.h | 3 ++- arch/mips/include/asm/mach-generic/dma-coherence.h | 3 ++- arch/mips/include/asm/mach-ip27/dma-coherence.h | 3 ++- arch/mips/include/asm/mach-ip32/dma-coherence.h | 3 ++- arch/mips/include/asm/mach-jazz/dma-coherence.h | 3 ++- arch/mips/include/asm/mach-lemote/dma-coherence.h | 3 ++- arch/mips/mm/dma-default.c | 15 ++++++++------- 7 files changed, 20 insertions(+), 13 deletions(-)
arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h +2 -1
@@ -30,7 +30,8 @@ static inline dma_addr_t plat_map_dma_mem_page(struct device *dev,return octeon_map_dma_mem (dev,page_address (page),PAGE_SIZE ); } -static inline unsigned long plat_dma_addr_to_phys (dma_addr_t dma_addr) +static inline unsigned long plat_dma_addr_to_phys (struct device *dev, +dma_addr_t dma_addr) {return dma_addr; }
arch/mips/include/asm/mach-generic/dma-coherence.h +2 -1
@@ -23,7 +23,8 @@ static inline dma_addr_t plat_map_dma_mem_page(struct device *dev,return page_to_phys (page); } -static inline unsigned long plat_dma_addr_to_phys (dma_addr_t dma_addr) +static inline unsigned long plat_dma_addr_to_phys (struct device *dev, +dma_addr_t dma_addr) {return dma_addr; }
arch/mips/include/asm/mach-ip27/dma-coherence.h +2 -1
@@ -33,7 +33,8 @@ static dma_addr_t plat_map_dma_mem_page(struct device *dev, struct page *page)return pa; } -static unsigned long plat_dma_addr_to_phys (dma_addr_t dma_addr) +static unsigned long plat_dma_addr_to_phys (struct device *dev, +dma_addr_t dma_addr) {return dma_addr & ~(0xffUL <<56 ); }
arch/mips/include/asm/mach-ip32/dma-coherence.h +2 -1
@@ -50,7 +50,8 @@ static dma_addr_t plat_map_dma_mem_page(struct device *dev, struct page *page) }/* This is almost certainly wrong but it's what dma-ip32.c used to use */ -static unsigned long plat_dma_addr_to_phys (dma_addr_t dma_addr) +static unsigned long plat_dma_addr_to_phys (struct device *dev, +dma_addr_t dma_addr) {unsigned long addr = dma_addr &RAM_OFFSET_MASK ;
arch/mips/include/asm/mach-jazz/dma-coherence.h +2 -1
@@ -22,7 +22,8 @@ static dma_addr_t plat_map_dma_mem_page(struct device *dev, struct page *page)return vdma_alloc (page_to_phys (page),PAGE_SIZE ); } -static unsigned long plat_dma_addr_to_phys (dma_addr_t dma_addr) +static unsigned long plat_dma_addr_to_phys (struct device *dev, +dma_addr_t dma_addr) {return vdma_log2phys (dma_addr); }
arch/mips/include/asm/mach-lemote/dma-coherence.h +2 -1
@@ -25,7 +25,8 @@ static inline dma_addr_t plat_map_dma_mem_page(struct device *dev,return page_to_phys (page) |0x80000000 ; } -static inline unsigned long plat_dma_addr_to_phys (dma_addr_t dma_addr) +static inline unsigned long plat_dma_addr_to_phys (struct device *dev, +dma_addr_t dma_addr) {return dma_addr &0x7fffffff ; }
arch/mips/mm/dma-default.c +8 -7
@@ -20,9 +20,10 @@#include <dma-coherence.h> -static inline unsigned long dma_addr_to_virt (dma_addr_t dma_addr) +static inline unsigned long dma_addr_to_virt (struct device *dev, +dma_addr_t dma_addr) { -unsigned long addr =plat_dma_addr_to_phys (dma_addr); +unsigned long addr =plat_dma_addr_to_phys (dev, dma_addr);return (unsigned long )phys_to_virt (addr); }
@@ -170,7 +171,7 @@ void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, enum dma_data_direction direction) {if (cpu_is_noncoherent_r10000 (dev)) -__dma_sync (dma_addr_to_virt (dma_addr), size, +__dma_sync (dma_addr_to_virt (dev, dma_addr), size, direction);plat_unmap_dma_mem (dev, dma_addr, size, direction);
@@ -246,7 +247,7 @@ void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle,if (cpu_is_noncoherent_r10000 (dev)) {unsigned long addr; - addr =dma_addr_to_virt (dma_handle); + addr =dma_addr_to_virt (dev, dma_handle);__dma_sync (addr, size, direction); } }
@@ -262,7 +263,7 @@ void dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle,if (!plat_device_is_coherent (dev)) {unsigned long addr; - addr =dma_addr_to_virt (dma_handle); + addr =dma_addr_to_virt (dev, dma_handle);__dma_sync (addr, size, direction); } }
@@ -277,7 +278,7 @@ void dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle,if (cpu_is_noncoherent_r10000 (dev)) {unsigned long addr; - addr =dma_addr_to_virt (dma_handle); + addr =dma_addr_to_virt (dev, dma_handle);__dma_sync (addr + offset, size, direction); } }
@@ -293,7 +294,7 @@ void dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,if (!plat_device_is_coherent (dev)) {unsigned long addr; - addr =dma_addr_to_virt (dma_handle); + addr =dma_addr_to_virt (dev, dma_handle);__dma_sync (addr + offset, size, direction); } }
Signature · 1 line
1.5.3.6
PATCH 3/3 MIPS: Support 64-byte D-cache line size
In reply to Kevin Cernekee--- arch/mips/include/asm/r4kcache.h | 1 + arch/mips/mm/c-r4k.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 0 deletions(-)
arch/mips/include/asm/r4kcache.h +1 -0
@@ -399,6 +399,7 @@ __BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 16) __BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 32) __BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 32) __BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 32) +__BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 64) __BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 64) __BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 64)__BUILD_BLAST_CACHE (s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD,128 )
arch/mips/mm/c-r4k.c +12 -0
@@ -100,6 +100,12 @@ static inline void r4k_blast_dcache_page_dc32(unsigned long addr)blast_dcache32_page (addr); } +static inline void r4k_blast_dcache_page_dc64 (unsigned long addr) +{ +R4600_HIT_CACHEOP_WAR_IMPL ; +blast_dcache64_page (addr); +} +static void __cpuinit r4k_blast_dcache_page_setup (void ) {unsigned long dc_lsize =cpu_dcache_line_size ();
@@ -110,6 +116,8 @@ static void __cpuinit r4k_blast_dcache_page_setup(void) r4k_blast_dcache_page = blast_dcache16_page; else if (dc_lsize == 32) r4k_blast_dcache_page = r4k_blast_dcache_page_dc32; + else if (dc_lsize == 64) + r4k_blast_dcache_page = r4k_blast_dcache_page_dc64; }static void (* r4k_blast_dcache_page_indexed)(unsigned long addr);
@@ -124,6 +132,8 @@ static void __cpuinit r4k_blast_dcache_page_indexed_setup(void) r4k_blast_dcache_page_indexed = blast_dcache16_page_indexed; else if (dc_lsize == 32) r4k_blast_dcache_page_indexed = blast_dcache32_page_indexed; + else if (dc_lsize == 64) + r4k_blast_dcache_page_indexed = blast_dcache64_page_indexed; }static void (* r4k_blast_dcache)(void );
@@ -138,6 +148,8 @@ static void __cpuinit r4k_blast_dcache_setup(void) r4k_blast_dcache = blast_dcache16; else if (dc_lsize == 32) r4k_blast_dcache = blast_dcache32; + else if (dc_lsize == 64) + r4k_blast_dcache = blast_dcache64; }/* force code alignment (used for TX49XX_ICACHE_INDEX_INV_WAR) */
Signature · 1 line
1.5.3.6
Now , I have ported suspend2 code (based on 2.4.21 patch) into mips architecture, my kernel version is 2.4.21.
My Environment:
kernel:2.4.21
Architecture:mips 32: 4KEc
tty device : only has a serial port.
Now, we have finish 99% work-load, but at last ,we found a problem, kernel panic after resume code has been executed completely , kernel code has return the code after hibernate. but system have not return console, it happened kernel panic.
in resume code, I added debugging code, I am sure, resume code has been executed completely.
including ,reading pageset1 and pageset2,and copy kernel to original location, restore cpu context and unfroze processes.
Could you please give me some ideas and suggestions ? thanks very much!
----------
Error output is like this;
Waking 5: bdflush.
Waking 6: kupdated.
Waking 7: mtdblockd.
Waking 8: khubd.
Waking 65: lircd.
Waking 67: inetd.
Waking 80: pure-ftpd.
Waking 81: sh.
Waking 86: hibernate.
Waking 163: hibernate.
Waking 164: tee.
About to restore original console. swsusp_default_console_level = 1
console_loglevel=7default_message_loglevel = 4 orig_default_message_loglevel=0
at end of do_software_suspend
Kernel unaligned instruction access in unaligned.c::do_ade, line 446:
CPU Regs : =========================================================== $0 : 00000000 80290000 00000100 fffdffff 00000007 00000006 802342cc 820e83d4 $8 : 00000000 00000000 00000000 820e83dc 820e83f4 820e8000 80278010 00000000 $16: 8028f7b8 0000debe 00001ebe 802a53a0 0000dee0 7fff7d48 00000004 00000014
$24: 8200000c 2abe4090 820e8000 820e9e70 00000000 0000000a
Hi : 0000007a
Lo : 000000b7
epc : 0000000a Tainted: G Z
Status: 10008403
Cause : 10800010
PrId : 0001906c
Process init (pid: 1, stackpage=820e8000)show_stack ============================================================
Stack: 80287ce0 0000003e 0000003c 800b93cc 00000000 00000400 80111bb0 00000000 00001ee0 ffffffff 0000dee0 10008400 00000001 800b9460 0000000b 00000189 00000004 00000001 10008400 802a4fc4 80287cf0 10008400 00000001 0000000a 80287ce0 0000003c 800b9ac0 800b99bc 80239200 10008400 802391bc 80239200 802a4fc2 802a4fc4 800b9868 820b6d94 00000189 820b72e0 80238b12 7fff7ba8 00000022 00000000 8028a23c 80287cdc 80239200 802391bc 802391bc 80239200 80287cdc 00000014 00000005 800da9e4 80238af0 19669944 83feb000 8028a9d4 00000202 00000000 0000000b 7fff7ba8 00000000 00000001 00008400 820b1ea0 00000000 00000002 8028a9d4 00000003 820e9ef8 00000002 00000000 7fff7ba8 0000000b 00000000 7fff7a28 7fff7d48 00000004 00000014 00000000 2ab61a30 00000000 00000000 2abe7bf0 7fff79b8 00000005 0040709c 00000000 00000000 2ab61a94 00000008 00008413 10800020 fbbffffe fb7fefff ffffdffb bbefefef fdf67ffe b6e5efbd f7f7fff6 efedffff
show_trace =============================================================
Call Trace:
[<800b93cc>__call_console_drivers ]
[<80111bb0>do_select]
[<800b9460> _call_console_drivers ]
[<800b9ac0>release_console_sem]
[<800b99bc>release_console_sem]
[<80239200>] [<802391bc>] [<80239200>] [<800b9868>] [<80238b12>] [<80239200>]
[<802391bc>] [<802391bc>] [<80239200>] [<800da9e4>] [<80238af0>]show_code ==============================================================
Code:<7>init: Forwarding exception at [<800acfe0>] (80256a18)
(Bad address in epc)
Kernel panic: Attempted to kill init! UART_MSR_ANY_DELTA
===================================Error Output End ======================
Ralf Baechle
AppliedQuoted 15 lines · Kevin Cernekee
I am upgrading an SoC to the 2.6.29.1 kernel from an earlier version, and in the process I am switching over the old board support customizations to use the newer, cleaner plat_* functions. I found two cases where the plat_* functions did not provide enough information, so I had to modify the API:
plat_unmap_dma_mem()- Our handler needs to know the size and direction of the DMA mapping. This information is not encoded in the DMA address, so it needed to be passed in explicitly.
plat_dma_addr_to_phys()- The bus<->physical address mappings differ based on which bus is being used. It is not always possible to infer which bus is being used from the bus address alone, so I added a "struct device" to the function definition.
Quoted 4 lines
Also, our MIPS core uses 64-byte D$ lines, so I needed to generate the corresponding blast* functions.
These patches apply against the linux-mips.org GIT tree.
Queued for 2.6.31. Thanks Kevin!
Which SoC port are you working on btw?
Ralf