From patchwork Mon Jul 10 20:43:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13307618 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27FC1EB64D9 for ; Mon, 10 Jul 2023 20:44:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9FEA08E0012; Mon, 10 Jul 2023 16:43:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 99F9F8E0015; Mon, 10 Jul 2023 16:43:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 72FC08E0012; Mon, 10 Jul 2023 16:43:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 35ED88E0014 for ; Mon, 10 Jul 2023 16:43:50 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 03D8A80258 for ; Mon, 10 Jul 2023 20:43:50 +0000 (UTC) X-FDA: 80996878620.30.B5D7139 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf18.hostedemail.com (Postfix) with ESMTP id 5580F1C0011 for ; Mon, 10 Jul 2023 20:43:47 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Cvh1UbtT; spf=none (imf18.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689021828; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=3eckwhASlJ5kB1LQ/if3Fo0Hxrj5Tti58CwpH+WVOLg=; b=ggo8ZOUOhFrqp0rPVrub+4tGHJwv0CpqgbB6pwFhfnJHQkhMyMAaBqX2ENjFZodJHy6d7w 9SqWFJRE3bcgFyOHEOfsZwmsVJW9dUSnhdqunQIw9NzwnU8i+V4l3ujACKMGU53CjJbA0I TkteUVesPGU1KgKys0+U/IGyC0wA38I= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689021828; a=rsa-sha256; cv=none; b=g3Ak1BWLAelnev7iJ14zOuCqSPjExgck3YFAxpEBJ/xFZA6GeC6P1SIJ7eKNBgkBe+v0Z5 HxgPU10AA61jYlR1QQWC4F8r/EPD+mYm7s197ET3Fj0X7wZECPmyz8ftLUjlYqcxllPE/I 1xeZ2xtDDjXvB026JVui/NSyOaCtn14= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Cvh1UbtT; spf=none (imf18.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=3eckwhASlJ5kB1LQ/if3Fo0Hxrj5Tti58CwpH+WVOLg=; b=Cvh1UbtToEDk9/QV9A82rA+pgO ZTVGf7qezP8ORX82Pd9066sJeOM5dE7LJVSdU72VBPOJJePCnnmx2XPj4ovyJ6l2tseqYrpT30eCK U+OfkAb85sMFzp4gY6kAmZ3KHrVUGYUv1fcbj6hZfNkAAMJWS9kq6rLqMWHlXH3D8AU8Y4Fzo2ksa rYBNjIHm+ngWuRRZxot/g5zHA3FmaazW2bANzxCp7m6yvQvNfshhbM4XpxK/qAQ9ssoe/TgzTYC2B 1gy6zazOwafB2OLz5giRT6S2BdKpDM2fRB9CnJTd+dM1btzR+GYIvpVPyQG3p8ZOUcLjb7krJ5nyw 9ExiL9KQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qIxjS-00EupG-Rz; Mon, 10 Jul 2023 20:43:42 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven , Mike Rapoport , linux-m68k@lists.linux-m68k.org Subject: [PATCH v5 15/38] m68k: Implement the new page table range API Date: Mon, 10 Jul 2023 21:43:16 +0100 Message-Id: <20230710204339.3554919-16-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230710204339.3554919-1-willy@infradead.org> References: <20230710204339.3554919-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 5580F1C0011 X-Rspam-User: X-Stat-Signature: x9nqh8jiyhm34fn6enn6k6p6gc9h89th X-Rspamd-Server: rspam03 X-HE-Tag: 1689021827-296206 X-HE-Meta: U2FsdGVkX19huY5qklNdx2RmK8dOEY/rlPk+TfGtWasVLi48FQxi2E873K4JkrDdHtgrgnZVL/xy+HA3ZB8FZCUMDqFs9bbyGJn5nSKZoRVpRPIXYQoV1Ubr7mnH7a4bQ3PIdtlj3xoYIzC0bN/PsYJU9iKh6Cm8XJollagazQfRsCVBDG8gZIzo46n/T3wicB6CsOFbWTzXcSMZtWTi7JboVEeZX86aI9/HsmtPsxOalMoNNJfcWeuEPu29wKiTS6N2hYTDSXmkeSc90PJNUaz9ZiQFGY10F17LAxJIziq1xMMfM+b7l9eedEXFcbFkvLsPgnnjBHDtwG2wE5H8+s72NAZ6/HH5p6STFJlcWXBUanuLMcMKlE4yHqWHldK3nx90WhAtne04IQeuP5inegYTSfjrfXOVWl6oXjUZU8Ol1KooQ2Bz5mfxYr7eD5gDHB2RAYNUz1aiGMgIBsTLGyZhb9OmRrY9vdVTiVZEEFpejHT+u0wL2BxLU6T7x2Rn8e/gYX5zrKwRu52DWba3PNrMeflLVmygReC01pdCXDdpmdzo1yU6lJDXaaXBQZOcNZQeCdKoraqeiCHGIEVDwR8+zgbiU7TXWo9DE/EEX5c48Vhdj+HTaWugOlP7+O6MN2djD6+YS5OYMZhRvgyeUZ2RniyKzlC1tJhDF2dF5tg2drf3DvyFN7xedQ8a4eniOkwPjSAq48W6WaduW0JLAbZJhno1UUSgjWFMTsM26UuV6Pbvyt+cUDY5q6umeorHpcYqIRn8mICf86lqrtUikaideroZr63K5yp+Fycva/a8RJzNRZtfkAWOWwiJV+2zUUDGqncuA0NZkzkMEzkPajfZclSihyEDyUQSJ2eKJkuPnsXaHzq+m0Y1OPw9O5xKEChbiX9MXPpu6aXKPB1FY/TQsx+OZHmdamwpAqddR513NlTm8FVvvmjzXbFf0W/if/JN/47RXbw48knXOVg 6Owsvx3Q DGiNm57Kdhd1QjhyjJR5HDlxJZyqFcX75Wi2eURtSIvVYTnGHSwB2DsDlmYLl/J49/0P1plu1OzMWtltF+95ErUxg37eKKM4OeZOq+219qgpYStqTt2QKgzfyzP2do0rEveniFac0dUee7etyubWjJOKMa9K155tR88tVY5AdXrIvNC7pEGVc36S7pzNjxZXwMkfNnWd02N36wP5uWc5nP6jARMjkTEtcw030LnkQUvg1QFhg0toTLBdG1kZY6rUTDxuEVyiU8ldIOWXQpyn+6K/aPut4QR3kaU2Fb8f72N1xP4Q= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Add PFN_PTE_SHIFT, update_mmu_cache_range(), flush_icache_pages() and flush_dcache_folio(). Signed-off-by: Matthew Wilcox (Oracle) Tested-by: Geert Uytterhoeven Acked-by: Mike Rapoport (IBM) Cc: linux-m68k@lists.linux-m68k.org --- arch/m68k/include/asm/cacheflush_mm.h | 27 ++++++++++++++++-------- arch/m68k/include/asm/mcf_pgtable.h | 1 + arch/m68k/include/asm/motorola_pgtable.h | 1 + arch/m68k/include/asm/pgtable_mm.h | 10 +++++---- arch/m68k/include/asm/sun3_pgtable.h | 1 + arch/m68k/mm/motorola.c | 2 +- 6 files changed, 28 insertions(+), 14 deletions(-) diff --git a/arch/m68k/include/asm/cacheflush_mm.h b/arch/m68k/include/asm/cacheflush_mm.h index 1ac55e7b47f0..88eb85e81ef6 100644 --- a/arch/m68k/include/asm/cacheflush_mm.h +++ b/arch/m68k/include/asm/cacheflush_mm.h @@ -220,24 +220,29 @@ static inline void flush_cache_page(struct vm_area_struct *vma, unsigned long vm /* Push the page at kernel virtual address and clear the icache */ /* RZ: use cpush %bc instead of cpush %dc, cinv %ic */ -static inline void __flush_page_to_ram(void *vaddr) +static inline void __flush_pages_to_ram(void *vaddr, unsigned int nr) { if (CPU_IS_COLDFIRE) { unsigned long addr, start, end; addr = ((unsigned long) vaddr) & ~(PAGE_SIZE - 1); start = addr & ICACHE_SET_MASK; - end = (addr + PAGE_SIZE - 1) & ICACHE_SET_MASK; + end = (addr + nr * PAGE_SIZE - 1) & ICACHE_SET_MASK; if (start > end) { flush_cf_bcache(0, end); end = ICACHE_MAX_ADDR; } flush_cf_bcache(start, end); } else if (CPU_IS_040_OR_060) { - __asm__ __volatile__("nop\n\t" - ".chip 68040\n\t" - "cpushp %%bc,(%0)\n\t" - ".chip 68k" - : : "a" (__pa(vaddr))); + unsigned long paddr = __pa(vaddr); + + do { + __asm__ __volatile__("nop\n\t" + ".chip 68040\n\t" + "cpushp %%bc,(%0)\n\t" + ".chip 68k" + : : "a" (paddr)); + paddr += PAGE_SIZE; + } while (--nr); } else { unsigned long _tmp; __asm__ __volatile__("movec %%cacr,%0\n\t" @@ -249,10 +254,14 @@ static inline void __flush_page_to_ram(void *vaddr) } #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1 -#define flush_dcache_page(page) __flush_page_to_ram(page_address(page)) +#define flush_dcache_page(page) __flush_pages_to_ram(page_address(page), 1) +#define flush_dcache_folio(folio) \ + __flush_pages_to_ram(folio_address(folio), folio_nr_pages(folio)) #define flush_dcache_mmap_lock(mapping) do { } while (0) #define flush_dcache_mmap_unlock(mapping) do { } while (0) -#define flush_icache_page(vma, page) __flush_page_to_ram(page_address(page)) +#define flush_icache_pages(vma, page, nr) \ + __flush_pages_to_ram(page_address(page), nr) +#define flush_icache_page(vma, page) flush_icache_pages(vma, page, 1) extern void flush_icache_user_page(struct vm_area_struct *vma, struct page *page, unsigned long addr, int len); diff --git a/arch/m68k/include/asm/mcf_pgtable.h b/arch/m68k/include/asm/mcf_pgtable.h index 43e8da8465f9..772b7e7b0654 100644 --- a/arch/m68k/include/asm/mcf_pgtable.h +++ b/arch/m68k/include/asm/mcf_pgtable.h @@ -291,6 +291,7 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte) return pte; } +#define PFN_PTE_SHIFT PAGE_SHIFT #define pmd_pfn(pmd) (pmd_val(pmd) >> PAGE_SHIFT) #define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT)) diff --git a/arch/m68k/include/asm/motorola_pgtable.h b/arch/m68k/include/asm/motorola_pgtable.h index ec0dc19ab834..38d5e5edc3e1 100644 --- a/arch/m68k/include/asm/motorola_pgtable.h +++ b/arch/m68k/include/asm/motorola_pgtable.h @@ -112,6 +112,7 @@ static inline void pud_set(pud_t *pudp, pmd_t *pmdp) #define pte_present(pte) (pte_val(pte) & (_PAGE_PRESENT | _PAGE_PROTNONE)) #define pte_clear(mm,addr,ptep) ({ pte_val(*(ptep)) = 0; }) +#define PFN_PTE_SHIFT PAGE_SHIFT #define pte_page(pte) virt_to_page(__va(pte_val(pte))) #define pte_pfn(pte) (pte_val(pte) >> PAGE_SHIFT) #define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot)) diff --git a/arch/m68k/include/asm/pgtable_mm.h b/arch/m68k/include/asm/pgtable_mm.h index b93c41fe2067..dbdf1c2b2f66 100644 --- a/arch/m68k/include/asm/pgtable_mm.h +++ b/arch/m68k/include/asm/pgtable_mm.h @@ -31,8 +31,6 @@ do{ \ *(pteptr) = (pteval); \ } while(0) -#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval) - /* PMD_SHIFT determines the size of the area a second-level page table can map */ #if CONFIG_PGTABLE_LEVELS == 3 @@ -138,11 +136,15 @@ extern void kernel_set_cachemode(void *addr, unsigned long size, int cmode); * tables contain all the necessary information. The Sun3 does, but * they are updated on demand. */ -static inline void update_mmu_cache(struct vm_area_struct *vma, - unsigned long address, pte_t *ptep) +static inline void update_mmu_cache_range(struct vm_fault *vmf, + struct vm_area_struct *vma, unsigned long address, + pte_t *ptep, unsigned int nr) { } +#define update_mmu_cache(vma, addr, ptep) \ + update_mmu_cache_range(NULL, vma, addr, ptep, 1) + #endif /* !__ASSEMBLY__ */ /* MMU-specific headers */ diff --git a/arch/m68k/include/asm/sun3_pgtable.h b/arch/m68k/include/asm/sun3_pgtable.h index 9e7bf8a5f8f8..0cc39a88ce55 100644 --- a/arch/m68k/include/asm/sun3_pgtable.h +++ b/arch/m68k/include/asm/sun3_pgtable.h @@ -105,6 +105,7 @@ static inline void pte_clear (struct mm_struct *mm, unsigned long addr, pte_t *p pte_val (*ptep) = 0; } +#define PFN_PTE_SHIFT 0 #define pte_pfn(pte) (pte_val(pte) & SUN3_PAGE_PGNUM_MASK) #define pfn_pte(pfn, pgprot) \ ({ pte_t __pte; pte_val(__pte) = pfn | pgprot_val(pgprot); __pte; }) diff --git a/arch/m68k/mm/motorola.c b/arch/m68k/mm/motorola.c index c75984e2d86b..8bca46e51e94 100644 --- a/arch/m68k/mm/motorola.c +++ b/arch/m68k/mm/motorola.c @@ -81,7 +81,7 @@ static inline void cache_page(void *vaddr) void mmu_page_ctor(void *page) { - __flush_page_to_ram(page); + __flush_pages_to_ram(page, 1); flush_tlb_kernel_page(page); nocache_page(page); }