Pull ARC fixes from Vineet Gupta: - Fallouts/wreckage of Cache Flush optimizations / aliasing dcache support - Fix for an interesting bug where piped input to grep was getting mysteriously clobbered * tag 'arc-v3.10-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc: ARC: lazy dcache flush broke gdb in non-aliasing configs ARC: Use enough bits for determining page's cache color ARC: Brown paper bag bug in macro for checking cache color ARC: copy_(to|from)_user() to honor usermode-access permissions ARC: [mm] Prevent stray dcache lines after__sync_icache_dcach() ARC: [TB10x] Remove redundant abilis,simple-pinctrl mechanism
Unified · Split
| @@ -37,7 +37,7 @@ · 36 unmodified lines | ||
| 37 | 37 | |
| 38 | 38 | soc100 { |
| 39 | 39 | uart@FF100000 { |
| 40 | − pinctrl-names = "abilis,simple-default"; | |
| 40 | + pinctrl-names = "default"; | |
| 41 | 41 | pinctrl-0 = <&pctl_uart0>; |
| 42 | 42 | }; |
| 43 | 43 | ethernet@FE100000 { |
| @@ -37,7 +37,7 @@ · 36 unmodified lines | ||
| 37 | 37 | |
| 38 | 38 | soc100 { |
| 39 | 39 | uart@FF100000 { |
| 40 | − pinctrl-names = "abilis,simple-default"; | |
| 40 | + pinctrl-names = "default"; | |
| 41 | 41 | pinctrl-0 = <&pctl_uart0>; |
| 42 | 42 | }; |
| 43 | 43 | ethernet@FE100000 { |
| @@ -88,8 +88,7 @@ · 87 unmodified lines | ||
| 88 | 88 | }; |
| 89 | 89 | |
| 90 | 90 | uart@FF100000 { |
| 91 | − compatible = "snps,dw-apb-uart", | |
| 92 | − "abilis,simple-pinctrl"; | |
| 91 | + compatible = "snps,dw-apb-uart"; | |
| 93 | 92 | reg = <0xFF100000 0x100>; |
| 94 | 93 | clock-frequency = <166666666>; |
| 95 | 94 | interrupts = <25 1>; |
| @@ -184,8 +183,7 @@ · 88 unmodified lines | ||
| 184 | 183 | #address-cells = <1>; |
| 185 | 184 | #size-cells = <0>; |
| 186 | 185 | cell-index = <1>; |
| 187 | − compatible = "abilis,tb100-spi", | |
| 188 | − "abilis,simple-pinctrl"; | |
| 186 | + compatible = "abilis,tb100-spi"; | |
| 189 | 187 | num-cs = <2>; |
| 190 | 188 | reg = <0xFE011000 0x20>; |
| 191 | 189 | interrupt-parent = <&tb10x_ictl>; |
| @@ -93,14 +93,16 @@ static inline int cache_is_vipt_aliasing(void) · 92 unmodified lines | ||
| 93 | 93 | #endif |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | −#define CACHE_COLOR(addr) (((unsigned long)(addr) >> (PAGE_SHIFT)) & 3) | |
| 96 | +#define CACHE_COLOR(addr) (((unsigned long)(addr) >> (PAGE_SHIFT)) & 1) | |
| 97 | 97 | |
| 98 | 98 | /* |
| 99 | 99 | * checks if two addresses (after page aligning) index into same cache set |
| 100 | 100 | */ |
| 101 | 101 | #define addr_not_cache_congruent(addr1, addr2) \ |
| 102 | +({ \ | |
| 102 | 103 | cache_is_vipt_aliasing() ? \ |
| 103 | − (CACHE_COLOR(addr1) != CACHE_COLOR(addr2)) : 0 \ | |
| 104 | + (CACHE_COLOR(addr1) != CACHE_COLOR(addr2)) : 0; \ | |
| 105 | +}) | |
| 104 | 106 | |
| 105 | 107 | #define copy_to_user_page(vma, page, vaddr, dst, src, len) \ |
| 106 | 108 | do { \ |
| @@ -19,13 +19,6 @@ · 18 unmodified lines | ||
| 19 | 19 | #define clear_page(paddr) memset((paddr), 0, PAGE_SIZE) |
| 20 | 20 | #define copy_page(to, from) memcpy((to), (from), PAGE_SIZE) |
| 21 | 21 | |
| 22 | −#ifndef CONFIG_ARC_CACHE_VIPT_ALIASING | |
| 23 | − | |
| 24 | −#define clear_user_page(addr, vaddr, pg) clear_page(addr) | |
| 25 | −#define copy_user_page(vto, vfrom, vaddr, pg) copy_page(vto, vfrom) | |
| 26 | − | |
| 27 | −#else /* VIPT aliasing dcache */ | |
| 28 | − | |
| 29 | 22 | struct vm_area_struct; |
| 30 | 23 | struct page; |
| 31 | 24 | |
| @@ -35,8 +28,6 @@ void copy_user_highpage(struct page *to, struct page *from, · 3 unmodified lines | ||
| 35 | 28 | unsigned long u_vaddr, struct vm_area_struct *vma); |
| 36 | 29 | void clear_user_page(void *to, unsigned long u_vaddr, struct page *page); |
| 37 | 30 | |
| 38 | −#endif /* CONFIG_ARC_CACHE_VIPT_ALIASING */ | |
| 39 | − | |
| 40 | 31 | #undef STRICT_MM_TYPECHECKS |
| 41 | 32 | |
| 42 | 33 | #ifdef STRICT_MM_TYPECHECKS |
| @@ -57,9 +57,9 @@ · 56 unmodified lines | ||
| 57 | 57 | |
| 58 | 58 | #define _PAGE_ACCESSED (1<<1) /* Page is accessed (S) */ |
| 59 | 59 | #define _PAGE_CACHEABLE (1<<2) /* Page is cached (H) */ |
| 60 | −#define _PAGE_EXECUTE (1<<3) /* Page has user execute perm (H) */ | |
| 61 | −#define _PAGE_WRITE (1<<4) /* Page has user write perm (H) */ | |
| 62 | −#define _PAGE_READ (1<<5) /* Page has user read perm (H) */ | |
| 60 | +#define _PAGE_U_EXECUTE (1<<3) /* Page has user execute perm (H) */ | |
| 61 | +#define _PAGE_U_WRITE (1<<4) /* Page has user write perm (H) */ | |
| 62 | +#define _PAGE_U_READ (1<<5) /* Page has user read perm (H) */ | |
| 63 | 63 | #define _PAGE_K_EXECUTE (1<<6) /* Page has kernel execute perm (H) */ |
| 64 | 64 | #define _PAGE_K_WRITE (1<<7) /* Page has kernel write perm (H) */ |
| 65 | 65 | #define _PAGE_K_READ (1<<8) /* Page has kernel perm (H) */ |
| @@ -72,9 +72,9 @@ · 6 unmodified lines | ||
| 72 | 72 | |
| 73 | 73 | /* PD1 */ |
| 74 | 74 | #define _PAGE_CACHEABLE (1<<0) /* Page is cached (H) */ |
| 75 | −#define _PAGE_EXECUTE (1<<1) /* Page has user execute perm (H) */ | |
| 76 | −#define _PAGE_WRITE (1<<2) /* Page has user write perm (H) */ | |
| 77 | −#define _PAGE_READ (1<<3) /* Page has user read perm (H) */ | |
| 75 | +#define _PAGE_U_EXECUTE (1<<1) /* Page has user execute perm (H) */ | |
| 76 | +#define _PAGE_U_WRITE (1<<2) /* Page has user write perm (H) */ | |
| 77 | +#define _PAGE_U_READ (1<<3) /* Page has user read perm (H) */ | |
| 78 | 78 | #define _PAGE_K_EXECUTE (1<<4) /* Page has kernel execute perm (H) */ |
| 79 | 79 | #define _PAGE_K_WRITE (1<<5) /* Page has kernel write perm (H) */ |
| 80 | 80 | #define _PAGE_K_READ (1<<6) /* Page has kernel perm (H) */ |
| @@ -93,7 +93,8 @@ · 12 unmodified lines | ||
| 93 | 93 | #endif |
| 94 | 94 | |
| 95 | 95 | /* Kernel allowed all permissions for all pages */ |
| 96 | −#define _K_PAGE_PERMS (_PAGE_K_EXECUTE | _PAGE_K_WRITE | _PAGE_K_READ) | |
| 96 | +#define _K_PAGE_PERMS (_PAGE_K_EXECUTE | _PAGE_K_WRITE | _PAGE_K_READ | \ | |
| 97 | + _PAGE_GLOBAL | _PAGE_PRESENT) | |
| 97 | 98 | |
| 98 | 99 | #ifdef CONFIG_ARC_CACHE_PAGES |
| 99 | 100 | #define _PAGE_DEF_CACHEABLE _PAGE_CACHEABLE |
| @@ -106,7 +107,11 @@ · 6 unmodified lines | ||
| 106 | 107 | * -by default cached, unless config otherwise |
| 107 | 108 | * -present in memory |
| 108 | 109 | */ |
| 109 | −#define ___DEF (_PAGE_PRESENT | _K_PAGE_PERMS | _PAGE_DEF_CACHEABLE) | |
| 110 | +#define ___DEF (_PAGE_PRESENT | _PAGE_DEF_CACHEABLE) | |
| 111 | + | |
| 112 | +#define _PAGE_READ (_PAGE_U_READ | _PAGE_K_READ) | |
| 113 | +#define _PAGE_WRITE (_PAGE_U_WRITE | _PAGE_K_WRITE) | |
| 114 | +#define _PAGE_EXECUTE (_PAGE_U_EXECUTE | _PAGE_K_EXECUTE) | |
| 110 | 115 | |
| 111 | 116 | /* Set of bits not changed in pte_modify */ |
| 112 | 117 | #define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_MODIFIED) |
| @@ -125,11 +130,10 @@ · 12 unmodified lines | ||
| 125 | 130 | * kernel vaddr space - visible in all addr spaces, but kernel mode only |
| 126 | 131 | * Thus Global, all-kernel-access, no-user-access, cached |
| 127 | 132 | */ |
| 128 | −#define PAGE_KERNEL __pgprot(___DEF | _PAGE_GLOBAL) | |
| 133 | +#define PAGE_KERNEL __pgprot(_K_PAGE_PERMS | _PAGE_DEF_CACHEABLE) | |
| 129 | 134 | |
| 130 | 135 | /* ioremap */ |
| 131 | −#define PAGE_KERNEL_NO_CACHE __pgprot(_PAGE_PRESENT | _K_PAGE_PERMS | \ | |
| 132 | − _PAGE_GLOBAL) | |
| 136 | +#define PAGE_KERNEL_NO_CACHE __pgprot(_K_PAGE_PERMS) | |
| 133 | 137 | |
| 134 | 138 | /************************************************************************** |
| 135 | 139 | * Mapping of vm_flags (Generic VM) to PTE flags (arch specific) |
| @@ -16,7 +16,7 @@ · 15 unmodified lines | ||
| 16 | 16 | /* Masks for actual TLB "PD"s */ |
| 17 | 17 | #define PTE_BITS_IN_PD0 (_PAGE_GLOBAL | _PAGE_PRESENT) |
| 18 | 18 | #define PTE_BITS_IN_PD1 (PAGE_MASK | _PAGE_CACHEABLE | \ |
| 19 | − _PAGE_EXECUTE | _PAGE_WRITE | _PAGE_READ | \ | |
| 19 | + _PAGE_U_EXECUTE | _PAGE_U_WRITE | _PAGE_U_READ | \ | |
| 20 | 20 | _PAGE_K_EXECUTE | _PAGE_K_WRITE | _PAGE_K_READ) |
| 21 | 21 | |
| 22 | 22 | #ifndef __ASSEMBLY__ |
| @@ -610,7 +610,7 @@ void __sync_icache_dcache(unsigned long paddr, unsigned long vaddr, int len) · 609 unmodified lines | ||
| 610 | 610 | |
| 611 | 611 | local_irq_save(flags); |
| 612 | 612 | __ic_line_inv_vaddr(paddr, vaddr, len); |
| 613 | − __dc_line_op(paddr, vaddr, len, OP_FLUSH); | |
| 613 | + __dc_line_op(paddr, vaddr, len, OP_FLUSH_N_INV); | |
| 614 | 614 | local_irq_restore(flags); |
| 615 | 615 | } |
| 616 | 616 | |
| @@ -676,6 +676,17 @@ void flush_cache_range(struct vm_area_struct *vma, unsigned long start, · 59 unmodified lines | ||
| 676 | 676 | flush_cache_all(); |
| 677 | 677 | } |
| 678 | 678 | |
| 679 | +void flush_anon_page(struct vm_area_struct *vma, struct page *page, | |
| 680 | + unsigned long u_vaddr) | |
| 681 | +{ | |
| 682 | + /* TBD: do we really need to clear the kernel mapping */ | |
| 683 | + __flush_dcache_page(page_address(page), u_vaddr); | |
| 684 | + __flush_dcache_page(page_address(page), page_address(page)); | |
| 685 | + | |
| 686 | +} | |
| 687 | + | |
| 688 | +#endif | |
| 689 | + | |
| 679 | 690 | void copy_user_highpage(struct page *to, struct page *from, |
| 680 | 691 | unsigned long u_vaddr, struct vm_area_struct *vma) |
| 681 | 692 | { |
| @@ -725,16 +736,6 @@ void clear_user_page(void *to, unsigned long u_vaddr, struct page *page) · 43 unmodified lines | ||
| 725 | 736 | set_bit(PG_arch_1, &page->flags); |
| 726 | 737 | } |
| 727 | 738 | |
| 728 | −void flush_anon_page(struct vm_area_struct *vma, struct page *page, | |
| 729 | − unsigned long u_vaddr) | |
| 730 | −{ | |
| 731 | − /* TBD: do we really need to clear the kernel mapping */ | |
| 732 | − __flush_dcache_page(page_address(page), u_vaddr); | |
| 733 | − __flush_dcache_page(page_address(page), page_address(page)); | |
| 734 | − | |
| 735 | −} | |
| 736 | − | |
| 737 | −#endif | |
| 738 | 739 | |
| 739 | 740 | /********************************************************************** |
| 740 | 741 | * Explicit Cache flush request from user space via syscall |
| @@ -444,7 +444,8 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long vaddr_unaligned, · 443 unmodified lines | ||
| 444 | 444 | * so userspace sees the right data. |
| 445 | 445 | * (Avoids the flush for Non-exec + congruent mapping case) |
| 446 | 446 | */ |
| 447 | − if (vma->vm_flags & VM_EXEC || addr_not_cache_congruent(paddr, vaddr)) { | |
| 447 | + if ((vma->vm_flags & VM_EXEC) || | |
| 448 | + addr_not_cache_congruent(paddr, vaddr)) { | |
| 448 | 449 | struct page *page = pfn_to_page(pte_pfn(*ptep)); |
| 449 | 450 | |
| 450 | 451 | int dirty = test_and_clear_bit(PG_arch_1, &page->flags); |
| @@ -277,7 +277,7 @@ ARC_ENTRY EV_TLBMissI · 276 unmodified lines | ||
| 277 | 277 | ;---------------------------------------------------------------- |
| 278 | 278 | ; VERIFY_PTE: Check if PTE permissions approp for executing code |
| 279 | 279 | cmp_s r2, VMALLOC_START |
| 280 | − mov.lo r2, (_PAGE_PRESENT | _PAGE_READ | _PAGE_EXECUTE) | |
| 280 | + mov.lo r2, (_PAGE_PRESENT | _PAGE_U_READ | _PAGE_U_EXECUTE) | |
| 281 | 281 | mov.hs r2, (_PAGE_PRESENT | _PAGE_K_READ | _PAGE_K_EXECUTE) |
| 282 | 282 | |
| 283 | 283 | and r3, r0, r2 ; Mask out NON Flag bits from PTE |
| @@ -320,9 +320,9 @@ ARC_ENTRY EV_TLBMissD · 36 unmodified lines | ||
| 320 | 320 | mov_s r2, 0 |
| 321 | 321 | lr r3, [ecr] |
| 322 | 322 | btst_s r3, ECR_C_BIT_DTLB_LD_MISS ; Read Access |
| 323 | − or.nz r2, r2, _PAGE_READ ; chk for Read flag in PTE | |
| 323 | + or.nz r2, r2, _PAGE_U_READ ; chk for Read flag in PTE | |
| 324 | 324 | btst_s r3, ECR_C_BIT_DTLB_ST_MISS ; Write Access |
| 325 | − or.nz r2, r2, _PAGE_WRITE ; chk for Write flag in PTE | |
| 325 | + or.nz r2, r2, _PAGE_U_WRITE ; chk for Write flag in PTE | |
| 326 | 326 | ; Above laddering takes care of XCHG access |
| 327 | 327 | ; which is both Read and Write |
| 328 | 328 | |
| @@ -34,31 +34,6 @@ static void __init tb10x_platform_init(void) · 33 unmodified lines | ||
| 34 | 34 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | −static void __init tb10x_platform_late_init(void) | |
| 38 | −{ | |
| 39 | − struct device_node *dn; | |
| 40 | − | |
| 41 | − /* | |
| 42 | − * Pinctrl documentation recommends setting up the iomux here for | |
| 43 | − * all modules which don't require control over the pins themselves. | |
| 44 | − * Modules which need this kind of assistance are compatible with | |
| 45 | − * "abilis,simple-pinctrl", i.e. we can easily iterate over them. | |
| 46 | − * TODO: Does this recommended method work cleanly with pins required | |
| 47 | − * by modules? | |
| 48 | − */ | |
| 49 | − for_each_compatible_node(dn, NULL, "abilis,simple-pinctrl") { | |
| 50 | − struct platform_device *pd = of_find_device_by_node(dn); | |
| 51 | − struct pinctrl *pctl; | |
| 52 | − | |
| 53 | − pctl = pinctrl_get_select(&pd->dev, "abilis,simple-default"); | |
| 54 | − if (IS_ERR(pctl)) { | |
| 55 | − int ret = PTR_ERR(pctl); | |
| 56 | − dev_err(&pd->dev, "Could not set up pinctrl: %d\n", | |
| 57 | − ret); | |
| 58 | − } | |
| 59 | − } | |
| 60 | −} | |
| 61 | − | |
| 62 | 37 | static const char *tb10x_compat[] __initdata = { |
| 63 | 38 | "abilis,arc-tb10x", |
| 64 | 39 | NULL, |
| @@ -67,5 +42,4 @@ static const char *tb10x_compat[] __initdata = { · 2 unmodified lines | ||
| 67 | 42 | MACHINE_START(TB10x, "tb10x") |
| 68 | 43 | .dt_compat = tb10x_compat, |
| 69 | 44 | .init_machine = tb10x_platform_init, |
| 70 | − .init_late = tb10x_platform_late_init, | |
| 71 | 45 | MACHINE_END |