160-kmap_coherent.patch 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. From: Jeff Hansen <jhansen@cardaccess-inc.com>
  2. Subject: [PATCH] kmap_coherent
  3. On ASUS WL-500gP there are some "Data bus error"s when executing simple
  4. commands liks "ps" or "cat /proc/1/cmdline".
  5. This fixes OpenWrt ticket #1485: https://dev.openwrt.org/ticket/1485
  6. ---
  7. --- a/arch/mips/include/asm/cpu-features.h
  8. +++ b/arch/mips/include/asm/cpu-features.h
  9. @@ -160,6 +160,9 @@
  10. #ifndef cpu_has_local_ebase
  11. #define cpu_has_local_ebase 1
  12. #endif
  13. +#ifndef cpu_use_kmap_coherent
  14. +#define cpu_use_kmap_coherent 1
  15. +#endif
  16. /*
  17. * I-Cache snoops remote store. This only matters on SMP. Some multiprocessors
  18. --- a/arch/mips/include/asm/mach-bcm47xx/cpu-feature-overrides.h
  19. +++ b/arch/mips/include/asm/mach-bcm47xx/cpu-feature-overrides.h
  20. @@ -79,4 +79,6 @@
  21. #define cpu_scache_line_size() 0
  22. #define cpu_has_vz 0
  23. +#define cpu_use_kmap_coherent 0
  24. +
  25. #endif /* __ASM_MACH_BCM47XX_CPU_FEATURE_OVERRIDES_H */
  26. --- a/arch/mips/mm/c-r4k.c
  27. +++ b/arch/mips/mm/c-r4k.c
  28. @@ -645,7 +645,7 @@ static inline void local_r4k_flush_cache
  29. */
  30. map_coherent = (cpu_has_dc_aliases &&
  31. page_mapped(page) && !Page_dcache_dirty(page));
  32. - if (map_coherent)
  33. + if (map_coherent && cpu_use_kmap_coherent)
  34. vaddr = kmap_coherent(page, addr);
  35. else
  36. vaddr = kmap_atomic(page);
  37. @@ -670,7 +670,7 @@ static inline void local_r4k_flush_cache
  38. }
  39. if (vaddr) {
  40. - if (map_coherent)
  41. + if (map_coherent && cpu_use_kmap_coherent)
  42. kunmap_coherent();
  43. else
  44. kunmap_atomic(vaddr);
  45. --- a/arch/mips/mm/init.c
  46. +++ b/arch/mips/mm/init.c
  47. @@ -164,7 +164,7 @@ void copy_user_highpage(struct page *to,
  48. void *vfrom, *vto;
  49. vto = kmap_atomic(to);
  50. - if (cpu_has_dc_aliases &&
  51. + if (cpu_has_dc_aliases && cpu_use_kmap_coherent &&
  52. page_mapped(from) && !Page_dcache_dirty(from)) {
  53. vfrom = kmap_coherent(from, vaddr);
  54. copy_page(vto, vfrom);
  55. @@ -186,7 +186,7 @@ void copy_to_user_page(struct vm_area_st
  56. struct page *page, unsigned long vaddr, void *dst, const void *src,
  57. unsigned long len)
  58. {
  59. - if (cpu_has_dc_aliases &&
  60. + if (cpu_has_dc_aliases && cpu_use_kmap_coherent &&
  61. page_mapped(page) && !Page_dcache_dirty(page)) {
  62. void *vto = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK);
  63. memcpy(vto, src, len);
  64. @@ -204,7 +204,7 @@ void copy_from_user_page(struct vm_area_
  65. struct page *page, unsigned long vaddr, void *dst, const void *src,
  66. unsigned long len)
  67. {
  68. - if (cpu_has_dc_aliases &&
  69. + if (cpu_has_dc_aliases && cpu_use_kmap_coherent &&
  70. page_mapped(page) && !Page_dcache_dirty(page)) {
  71. void *vfrom = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK);
  72. memcpy(dst, vfrom, len);