tlb-pteaex.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * arch/sh/mm/tlb-pteaex.c
  3. *
  4. * TLB operations for SH-X3 CPUs featuring PTE ASID Extensions.
  5. *
  6. * Copyright (C) 2009 Paul Mundt
  7. *
  8. * This file is subject to the terms and conditions of the GNU General Public
  9. * License. See the file "COPYING" in the main directory of this archive
  10. * for more details.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/mm.h>
  14. #include <linux/io.h>
  15. #include <asm/mmu_context.h>
  16. #include <asm/cacheflush.h>
  17. void __update_tlb(struct vm_area_struct *vma, unsigned long address, pte_t pte)
  18. {
  19. unsigned long flags, pteval, vpn;
  20. /*
  21. * Handle debugger faulting in for debugee.
  22. */
  23. if (vma && current->active_mm != vma->vm_mm)
  24. return;
  25. local_irq_save(flags);
  26. /* Set PTEH register */
  27. vpn = address & MMU_VPN_MASK;
  28. __raw_writel(vpn, MMU_PTEH);
  29. /* Set PTEAEX */
  30. __raw_writel(get_asid(), MMU_PTEAEX);
  31. pteval = pte.pte_low;
  32. /* Set PTEA register */
  33. #ifdef CONFIG_X2TLB
  34. /*
  35. * For the extended mode TLB this is trivial, only the ESZ and
  36. * EPR bits need to be written out to PTEA, with the remainder of
  37. * the protection bits (with the exception of the compat-mode SZ
  38. * and PR bits, which are cleared) being written out in PTEL.
  39. */
  40. __raw_writel(pte.pte_high, MMU_PTEA);
  41. #endif
  42. /* Set PTEL register */
  43. pteval &= _PAGE_FLAGS_HARDWARE_MASK; /* drop software flags */
  44. #ifdef CONFIG_CACHE_WRITETHROUGH
  45. pteval |= _PAGE_WT;
  46. #endif
  47. /* conveniently, we want all the software flags to be 0 anyway */
  48. __raw_writel(pteval, MMU_PTEL);
  49. /* Load the TLB */
  50. asm volatile("ldtlb": /* no output */ : /* no input */ : "memory");
  51. local_irq_restore(flags);
  52. }
  53. /*
  54. * While SH-X2 extended TLB mode splits out the memory-mapped I/UTLB
  55. * data arrays, SH-X3 cores with PTEAEX split out the memory-mapped
  56. * address arrays. In compat mode the second array is inaccessible, while
  57. * in extended mode, the legacy 8-bit ASID field in address array 1 has
  58. * undefined behaviour.
  59. */
  60. void local_flush_tlb_one(unsigned long asid, unsigned long page)
  61. {
  62. jump_to_uncached();
  63. __raw_writel(page, MMU_UTLB_ADDRESS_ARRAY | MMU_PAGE_ASSOC_BIT);
  64. __raw_writel(asid, MMU_UTLB_ADDRESS_ARRAY2 | MMU_PAGE_ASSOC_BIT);
  65. __raw_writel(page, MMU_ITLB_ADDRESS_ARRAY | MMU_PAGE_ASSOC_BIT);
  66. __raw_writel(asid, MMU_ITLB_ADDRESS_ARRAY2 | MMU_PAGE_ASSOC_BIT);
  67. back_to_cached();
  68. }
  69. void local_flush_tlb_all(void)
  70. {
  71. unsigned long flags, status;
  72. int i;
  73. /*
  74. * Flush all the TLB.
  75. */
  76. local_irq_save(flags);
  77. jump_to_uncached();
  78. status = __raw_readl(MMUCR);
  79. status = ((status & MMUCR_URB) >> MMUCR_URB_SHIFT);
  80. if (status == 0)
  81. status = MMUCR_URB_NENTRIES;
  82. for (i = 0; i < status; i++)
  83. __raw_writel(0x0, MMU_UTLB_ADDRESS_ARRAY | (i << 8));
  84. for (i = 0; i < 4; i++)
  85. __raw_writel(0x0, MMU_ITLB_ADDRESS_ARRAY | (i << 8));
  86. back_to_cached();
  87. ctrl_barrier();
  88. local_irq_restore(flags);
  89. }