From 3c33e655e878b04a5e7452a85376642c2f3e486a Mon Sep 17 00:00:00 2001 From: Nathan Rossi Date: Wed, 8 May 2013 13:43:57 +1000 Subject: linux-xlnx: Add microblaze support and patches * Include the soc-family.inc for SOC conditional variable use * Add microblaze patches Signed-off-by: Nathan Rossi --- recipes-kernel/linux/linux-xlnx.inc | 39 ++---------- .../microblaze_Do_not_use_r6_in_head.S.patch | 69 ++++++++++++++++++++++ .../microblaze_Fix_free_init_pages_function.patch | 68 +++++++++++++++++++++ .../linux-xlnx/microblaze_Fix_initrd_support.patch | 52 ++++++++++++++++ recipes-kernel/linux/linux-xlnx_3.8.bb | 15 ++--- 5 files changed, 202 insertions(+), 41 deletions(-) create mode 100644 recipes-kernel/linux/linux-xlnx/microblaze_Do_not_use_r6_in_head.S.patch create mode 100644 recipes-kernel/linux/linux-xlnx/microblaze_Fix_free_init_pages_function.patch create mode 100644 recipes-kernel/linux/linux-xlnx/microblaze_Fix_initrd_support.patch diff --git a/recipes-kernel/linux/linux-xlnx.inc b/recipes-kernel/linux/linux-xlnx.inc index 7b2319be..3528edaf 100644 --- a/recipes-kernel/linux/linux-xlnx.inc +++ b/recipes-kernel/linux/linux-xlnx.inc @@ -1,48 +1,19 @@ -# -# To use linux-xlnx in your layer, create a -# linux-yocto-xlnx.bbappend file containing at least the following -# lines: -# -# FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" -# COMPATIBLE_MACHINE_yourmachine = "yourmachine" -# -# You must also provide a Linux kernel configuration. The most direct -# method is to copy your .config to files/defconfig in your layer, -# in the same directory as the bbappend and add file://defconfig to -# your SRC_URI. -# -# -# Notes: -# -# patches: patches can be merged into to the source git tree itself, -# added via the SRC_URI, or controlled via a BSP -# configuration. -# -# example configuration addition: -# SRC_URI += "file://smp.cfg" -# example patch addition (for kernel v3.4 only): -# SRC_URI += "file://0001-linux-version-tweak.patch -# example feature addition (for kernel v3.4 only): -# SRC_URI += "file://feature.scc" -# - inherit kernel # This version extension should match CONFIG_LOCALVERSION in defconfig LINUX_VERSION_EXTENSION ?= "-xilinx" require recipes-kernel/linux/linux-yocto.inc +require conf/machine/include/soc-family.inc -FILESEXTRAPATHS_prepend := "${THISDIR}/linux-xlnx:" +# MicroBlaze is a uImage target, but its not called 'uImage' +DEPENDS_microblaze += "u-boot-mkimage-native" -# Override SRC_URI in a bbappend file to point at a different source -# tree if you do not want to build from Linus' tree. +FILESEXTRAPATHS_prepend := "${THISDIR}/linux-xlnx:" SRC_URI = "git://github.com/Xilinx/linux-xlnx;protocol=git;nocheckout=1" PR = "r1" PV = "${LINUX_VERSION}${LINUX_VERSION_EXTENSION}+git${SRCPV}" -# Override COMPATIBLE_MACHINE to include your machine in a bbappend -# file. +# Override COMPATIBLE_MACHINE to include your machine in a bbappend file. COMPATIBLE_MACHINE = "zynq|microblazeel" - diff --git a/recipes-kernel/linux/linux-xlnx/microblaze_Do_not_use_r6_in_head.S.patch b/recipes-kernel/linux/linux-xlnx/microblaze_Do_not_use_r6_in_head.S.patch new file mode 100644 index 00000000..abed47cc --- /dev/null +++ b/recipes-kernel/linux/linux-xlnx/microblaze_Do_not_use_r6_in_head.S.patch @@ -0,0 +1,69 @@ +From: Michal Simek +Subject: [LINUX PATCH 1/3] microblaze: Do not use r6 in head.S + +r6 stores pointer to ramdisk and shouldn't +be used before it is passed to machine_early_init. + +Signed-off-by: Michal Simek +--- + arch/microblaze/kernel/head.S | 20 ++++++++++---------- + 1 file changed, 10 insertions(+), 10 deletions(-) + +diff --git a/arch/microblaze/kernel/head.S b/arch/microblaze/kernel/head.S +index eef84de..a8ce682 100644 +--- a/arch/microblaze/kernel/head.S ++++ b/arch/microblaze/kernel/head.S +@@ -112,16 +112,16 @@ no_fdt_arg: + * copy command line directly to cmd_line placed in data section. + */ + beqid r5, skip /* Skip if NULL pointer */ +- or r6, r0, r0 /* incremment */ ++ or r11, r0, r0 /* incremment */ + ori r4, r0, cmd_line /* load address of command line */ + tophys(r4,r4) /* convert to phys address */ + ori r3, r0, COMMAND_LINE_SIZE - 1 /* number of loops */ + _copy_command_line: + /* r2=r5+r6 - r5 contain pointer to command line */ +- lbu r2, r5, r6 ++ lbu r2, r5, r11 + beqid r2, skip /* Skip if no data */ +- sb r2, r4, r6 /* addr[r4+r6]= r2*/ +- addik r6, r6, 1 /* increment counting */ ++ sb r2, r4, r11 /* addr[r4+r6]= r2*/ ++ addik r11, r11, 1 /* increment counting */ + bgtid r3, _copy_command_line /* loop for all entries */ + addik r3, r3, -1 /* decrement loop */ + addik r5, r4, 0 /* add new space for command line */ +@@ -131,13 +131,13 @@ skip: + + #ifdef NOT_COMPILE + /* save bram context */ +- or r6, r0, r0 /* incremment */ ++ or r11, r0, r0 /* incremment */ + ori r4, r0, TOPHYS(_bram_load_start) /* save bram context */ + ori r3, r0, (LMB_SIZE - 4) + _copy_bram: +- lw r7, r0, r6 /* r7 = r0 + r6 */ +- sw r7, r4, r6 /* addr[r4 + r6] = r7*/ +- addik r6, r6, 4 /* increment counting */ ++ lw r7, r0, r11 /* r7 = r0 + r6 */ ++ sw r7, r4, r11 /* addr[r4 + r6] = r7*/ ++ addik r11, r11, 4 /* increment counting */ + bgtid r3, _copy_bram /* loop for all entries */ + addik r3, r3, -4 /* descrement loop */ + #endif +@@ -303,8 +303,8 @@ jump_over2: + * the exception vectors, using a 4k real==virtual mapping. + */ + /* Use temporary TLB_ID for LMB - clear this temporary mapping later */ +- ori r6, r0, MICROBLAZE_LMB_TLB_ID +- mts rtlbx,r6 ++ ori r11, r0, MICROBLAZE_LMB_TLB_ID ++ mts rtlbx,r11 + + ori r4,r0,(TLB_WR | TLB_EX) + ori r3,r0,(TLB_VALID | TLB_PAGESZ(PAGESZ_4K)) +-- +1.8.2.1 + + diff --git a/recipes-kernel/linux/linux-xlnx/microblaze_Fix_free_init_pages_function.patch b/recipes-kernel/linux/linux-xlnx/microblaze_Fix_free_init_pages_function.patch new file mode 100644 index 00000000..c32f8809 --- /dev/null +++ b/recipes-kernel/linux/linux-xlnx/microblaze_Fix_free_init_pages_function.patch @@ -0,0 +1,68 @@ +From: Michal Simek +Subject: [LINUX PATCH 2/3] microblaze: Fix free_init_pages function + +- fce() is used only in init.c file - let's use static +- start and end addresses should be page align +- remove additional addr variable +- use pr_info instead of printk(KERN_INFO...) +- use __free_page(page) instead of free_page(start) + it is faster because of no checking, + if ramdisk is out of the kernel you will get kernel panic anyway + +Signed-off-by: Michal Simek +--- + arch/microblaze/include/asm/setup.h | 1 - + arch/microblaze/mm/init.c | 20 +++++++++++++------- + 2 files changed, 13 insertions(+), 8 deletions(-) + +diff --git a/arch/microblaze/include/asm/setup.h b/arch/microblaze/include/asm/setup.h +index 0e0b0a5..f05df56 100644 +--- a/arch/microblaze/include/asm/setup.h ++++ b/arch/microblaze/include/asm/setup.h +@@ -46,7 +46,6 @@ void machine_shutdown(void); + void machine_halt(void); + void machine_power_off(void); + +-void free_init_pages(char *what, unsigned long begin, unsigned long end); + extern void *alloc_maybe_bootmem(size_t size, gfp_t mask); + extern void *zalloc_maybe_bootmem(size_t size, gfp_t mask); + +diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c +index ce80823..09affec 100644 +--- a/arch/microblaze/mm/init.c ++++ b/arch/microblaze/mm/init.c +@@ -236,17 +236,23 @@ void __init setup_memory(void) + paging_init(); + } + +-void free_init_pages(char *what, unsigned long begin, unsigned long end) ++static void free_init_pages(char *what, unsigned long start, unsigned long end) + { +- unsigned long addr; ++ if (start >= end) ++ return; + +- for (addr = begin; addr < end; addr += PAGE_SIZE) { +- ClearPageReserved(virt_to_page(addr)); +- init_page_count(virt_to_page(addr)); +- free_page(addr); ++ start = PAGE_DOWN(start); ++ end = PAGE_UP(end); ++ ++ pr_info("Freeing %s: %ldk freed\n", what, (end - start) >> 10); ++ ++ for (; start < end; start += PAGE_SIZE) { ++ struct page *page = virt_to_page(start); ++ ClearPageReserved(page); ++ init_page_count(page); ++ __free_page(page); + totalram_pages++; + } +- printk(KERN_INFO "Freeing %s: %ldk freed\n", what, (end - begin) >> 10); + } + + #ifdef CONFIG_BLK_DEV_INITRD +-- +1.8.2.1 + + diff --git a/recipes-kernel/linux/linux-xlnx/microblaze_Fix_initrd_support.patch b/recipes-kernel/linux/linux-xlnx/microblaze_Fix_initrd_support.patch new file mode 100644 index 00000000..7c4b6f76 --- /dev/null +++ b/recipes-kernel/linux/linux-xlnx/microblaze_Fix_initrd_support.patch @@ -0,0 +1,52 @@ +From: Michal Simek +Subject: [LINUX PATCH 3/3] microblaze: Fix initrd support + +Initrd/ramdisk support has been never validated. + +Signed-off-by: Michal Simek +--- + arch/microblaze/mm/init.c | 20 ++++++-------------- + 1 file changed, 6 insertions(+), 14 deletions(-) + +diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c +index 09affec..f394ad8 100644 +--- a/arch/microblaze/mm/init.c ++++ b/arch/microblaze/mm/init.c +@@ -258,16 +258,7 @@ static void free_init_pages(char *what, unsigned long start, unsigned long end) + #ifdef CONFIG_BLK_DEV_INITRD + void free_initrd_mem(unsigned long start, unsigned long end) + { +- int pages = 0; +- for (; start < end; start += PAGE_SIZE) { +- ClearPageReserved(virt_to_page(start)); +- init_page_count(virt_to_page(start)); +- free_page(start); +- totalram_pages++; +- pages++; +- } +- printk(KERN_NOTICE "Freeing initrd memory: %dk freed\n", +- (int)(pages * (PAGE_SIZE / 1024))); ++ free_init_pages("initrd memory", start, end); + } + #endif + +@@ -438,10 +429,11 @@ asmlinkage void __init mmu_init(void) + + #if defined(CONFIG_BLK_DEV_INITRD) + /* Remove the init RAM disk from the available memory. */ +-/* if (initrd_start) { +- mem_pieces_remove(&phys_avail, __pa(initrd_start), +- initrd_end - initrd_start, 1); +- }*/ ++ if (initrd_start) { ++ unsigned long size; ++ size = initrd_end - initrd_start; ++ memblock_reserve(virt_to_phys(initrd_start), size); ++ } + #endif /* CONFIG_BLK_DEV_INITRD */ + + /* Initialize the MMU hardware */ +-- +1.8.2.1 + + diff --git a/recipes-kernel/linux/linux-xlnx_3.8.bb b/recipes-kernel/linux/linux-xlnx_3.8.bb index 0d6fc448..bdcc47a7 100644 --- a/recipes-kernel/linux/linux-xlnx_3.8.bb +++ b/recipes-kernel/linux/linux-xlnx_3.8.bb @@ -1,12 +1,13 @@ # See include file for common information include linux-xlnx.inc -# Kernel version and SRCREV correspond to: -# github.com/Xilinx v14.5 tag -# If required for a custom layer: -# Override SRCREV to point to a different commit in a bbappend file to -# Or add patches as required - -# This version doesn't build in Poky 1.3, patch required http://patches.openembedded.org/patch/38283/ +# Kernel version and SRCREV correspond to: github.com/Xilinx v14.5 tag LINUX_VERSION = "3.8" SRCREV = "6a0bedad60e2bca8d9b50bf81b9895e29e31a6d7" + +# MicroBlaze patches +SRC_URI_append = " \ + file://microblaze_Do_not_use_r6_in_head.S.patch \ + file://microblaze_Fix_free_init_pages_function.patch \ + file://microblaze_Fix_initrd_support.patch \ + " -- cgit v1.2.3-54-g00ecf