3011-arm-add-new-non-shareable-ioremap.patch 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. From 707627a28924320a7a36bdb8b02c05651c0c384d Mon Sep 17 00:00:00 2001
  2. From: Pan Jiafei <Jiafei.Pan@nxp.com>
  3. Date: Fri, 8 Jul 2016 11:16:13 +0800
  4. Subject: [PATCH 11/70] arm: add new non-shareable ioremap
  5. commit 17d7448eef0fa57a0899e6a864d875e7a9082561
  6. [modify ioremap_cache_ns according to Linux v4.4.7]
  7. Signed-off-by: Pan Jiafei <Jiafei.Pan@nxp.com>
  8. Integrated-by: Zhao Qiang <qiang.zhao@nxp.com>
  9. ---
  10. arch/arm/include/asm/io.h | 4 ++++
  11. arch/arm/include/asm/mach/map.h | 4 ++--
  12. arch/arm/mm/ioremap.c | 7 +++++++
  13. arch/arm/mm/mmu.c | 9 +++++++++
  14. 4 files changed, 22 insertions(+), 2 deletions(-)
  15. --- a/arch/arm/include/asm/io.h
  16. +++ b/arch/arm/include/asm/io.h
  17. @@ -129,6 +129,7 @@ static inline u32 __raw_readl(const vola
  18. #define MT_DEVICE_NONSHARED 1
  19. #define MT_DEVICE_CACHED 2
  20. #define MT_DEVICE_WC 3
  21. +#define MT_MEMORY_RW_NS 4
  22. /*
  23. * types 4 onwards can be found in asm/mach/map.h and are undefined
  24. * for ioremap
  25. @@ -399,6 +400,9 @@ void __iomem *ioremap_wc(resource_size_t
  26. #define ioremap_wc ioremap_wc
  27. #define ioremap_wt ioremap_wc
  28. +void __iomem *ioremap_cache_ns(resource_size_t res_cookie, size_t size);
  29. +#define ioremap_cache_ns ioremap_cache_ns
  30. +
  31. void iounmap(volatile void __iomem *iomem_cookie);
  32. #define iounmap iounmap
  33. --- a/arch/arm/include/asm/mach/map.h
  34. +++ b/arch/arm/include/asm/mach/map.h
  35. @@ -21,9 +21,9 @@ struct map_desc {
  36. unsigned int type;
  37. };
  38. -/* types 0-3 are defined in asm/io.h */
  39. +/* types 0-4 are defined in asm/io.h */
  40. enum {
  41. - MT_UNCACHED = 4,
  42. + MT_UNCACHED = 5,
  43. MT_CACHECLEAN,
  44. MT_MINICLEAN,
  45. MT_LOW_VECTORS,
  46. --- a/arch/arm/mm/ioremap.c
  47. +++ b/arch/arm/mm/ioremap.c
  48. @@ -394,6 +394,13 @@ void __iomem *ioremap_wc(resource_size_t
  49. }
  50. EXPORT_SYMBOL(ioremap_wc);
  51. +void __iomem *ioremap_cache_ns(resource_size_t res_cookie, size_t size)
  52. +{
  53. + return arch_ioremap_caller(res_cookie, size, MT_MEMORY_RW_NS,
  54. + __builtin_return_address(0));
  55. +}
  56. +EXPORT_SYMBOL(ioremap_cache_ns);
  57. +
  58. /*
  59. * Remap an arbitrary physical address space into the kernel virtual
  60. * address space as memory. Needed when the kernel wants to execute
  61. --- a/arch/arm/mm/mmu.c
  62. +++ b/arch/arm/mm/mmu.c
  63. @@ -313,6 +313,13 @@ static struct mem_type mem_types[] = {
  64. .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
  65. .domain = DOMAIN_KERNEL,
  66. },
  67. + [MT_MEMORY_RW_NS] = {
  68. + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
  69. + L_PTE_XN,
  70. + .prot_l1 = PMD_TYPE_TABLE,
  71. + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_XN,
  72. + .domain = DOMAIN_KERNEL,
  73. + },
  74. [MT_ROM] = {
  75. .prot_sect = PMD_TYPE_SECT,
  76. .domain = DOMAIN_KERNEL,
  77. @@ -644,6 +651,7 @@ static void __init build_mem_type_table(
  78. }
  79. kern_pgprot |= PTE_EXT_AF;
  80. vecs_pgprot |= PTE_EXT_AF;
  81. + mem_types[MT_MEMORY_RW_NS].prot_pte |= PTE_EXT_AF | cp->pte;
  82. /*
  83. * Set PXN for user mappings
  84. @@ -672,6 +680,7 @@ static void __init build_mem_type_table(
  85. mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
  86. mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
  87. mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
  88. + mem_types[MT_MEMORY_RW_NS].prot_sect |= ecc_mask | cp->pmd;
  89. mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
  90. mem_types[MT_MEMORY_RWX_NONCACHED].prot_sect |= ecc_mask;
  91. mem_types[MT_ROM].prot_sect |= cp->pmd;