Merge tag 'x86-entry-2020-10-12' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-microblaze.git] / arch / m68k / mm / motorola.c
index 904c2a6..3a653f0 100644 (file)
@@ -45,6 +45,31 @@ unsigned long mm_cachebits;
 EXPORT_SYMBOL(mm_cachebits);
 #endif
 
+/* Prior to calling these routines, the page should have been flushed
+ * from both the cache and ATC, or the CPU might not notice that the
+ * cache setting for the page has been changed. -jskov
+ */
+static inline void nocache_page(void *vaddr)
+{
+       unsigned long addr = (unsigned long)vaddr;
+
+       if (CPU_IS_040_OR_060) {
+               pte_t *ptep = virt_to_kpte(addr);
+
+               *ptep = pte_mknocache(*ptep);
+       }
+}
+
+static inline void cache_page(void *vaddr)
+{
+       unsigned long addr = (unsigned long)vaddr;
+
+       if (CPU_IS_040_OR_060) {
+               pte_t *ptep = virt_to_kpte(addr);
+
+               *ptep = pte_mkcache(*ptep);
+       }
+}
 
 /*
  * Motorola 680x0 user's manual recommends using uncached memory for address
@@ -201,8 +226,8 @@ static pte_t * __init kernel_page_table(void)
 {
        pte_t *pte_table = last_pte_table;
 
-       if (((unsigned long)last_pte_table & ~PAGE_MASK) == 0) {
-               pte_table = (pte_t *)memblock_alloc_low(PAGE_SIZE, PAGE_SIZE);
+       if (PAGE_ALIGNED(last_pte_table)) {
+               pte_table = memblock_alloc_low(PAGE_SIZE, PAGE_SIZE);
                if (!pte_table) {
                        panic("%s: Failed to allocate %lu bytes align=%lx\n",
                                        __func__, PAGE_SIZE, PAGE_SIZE);
@@ -249,9 +274,8 @@ static pmd_t * __init kernel_ptr_table(void)
        }
 
        last_pmd_table += PTRS_PER_PMD;
-       if (((unsigned long)last_pmd_table & ~PAGE_MASK) == 0) {
-               last_pmd_table = (pmd_t *)memblock_alloc_low(PAGE_SIZE,
-                                                          PAGE_SIZE);
+       if (PAGE_ALIGNED(last_pmd_table)) {
+               last_pmd_table = memblock_alloc_low(PAGE_SIZE, PAGE_SIZE);
                if (!last_pmd_table)
                        panic("%s: Failed to allocate %lu bytes align=%lx\n",
                              __func__, PAGE_SIZE, PAGE_SIZE);