From patchwork Wed Aug 2 15:13:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13338340 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 AACB7C04A6A for ; Wed, 2 Aug 2023 15:14:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9C30F280143; Wed, 2 Aug 2023 11:14:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 59F43280193; Wed, 2 Aug 2023 11:14:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0182A28018F; Wed, 2 Aug 2023 11:14:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A73AF280190 for ; Wed, 2 Aug 2023 11:14:14 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 77BB7A074D for ; Wed, 2 Aug 2023 15:14:14 +0000 (UTC) X-FDA: 81079510428.21.A2A524A Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf29.hostedemail.com (Postfix) with ESMTP id C5FBD120014 for ; Wed, 2 Aug 2023 15:14:11 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=N45c28Qi; dmarc=none; spf=none (imf29.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690989251; 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=SSWlIbtVHyzx0IrHBw3ENR0Y2jRs7ctUUXoAlk1kgWA=; b=l77kF2inco5wfqnNCy+ax+kzBHG8uxyHp8NkEFXvMmrliHRYELdUvBaopDyLHbtXdW6VX5 lfqybTnb2toUGOOkXFS4j827iJA+Vp0wcQEg9JhErDJ902aWoKkDo4ioPZZGnRdOxkYKoR CfGS9JIaFAEQm0R5pfYPvjq1wztTgCY= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=N45c28Qi; dmarc=none; spf=none (imf29.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690989251; a=rsa-sha256; cv=none; b=FftwyjIxUa4RXS0ddpUkF47tgB0MzFA4dWQdpJnOTdLWpC2WAj3JXj4AK9mjwzaEbsQlvW pSTL0ORqdKpBoK9lTI1N2i6vI2cOao++FPU0pxp/oZeZoQzg2LQxRaGLFZ36QPHdF8+8R6 YNAyEDFtG8cTZ0rCIrZUpEIyWSzDNKU= 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=SSWlIbtVHyzx0IrHBw3ENR0Y2jRs7ctUUXoAlk1kgWA=; b=N45c28QiG3NCBqqfDCaIM2/rzo MbeEoAbXGTkYx2HBvbU6IhlBEfdz09JHTND5p0SQeJ/zpkU2qEXMLiLBiqH3VV2YbJwgPtZg6vg4e oGrupFpc/y81/W6hUQcZwKt+CN82FS8179+nNNzdBjBBk7U8zbCwf4kESfIXoLuNtr5m44IEZuK4s ON4GF/Ik5yFMtcEh/xMGYifpdvC8W0HXc0kycFvzqryWCLo68SOUkXpci8scab1DyKZaRXWXGPCWi KxOh4BZNcx2uv0Ie/1TMqqb8meNNXD/JevfiEOW+JIsGKgbB2kposmwJwDfoXI5Hh0n9a6r0E1RMJ vjMx3Jbg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qRDY9-00Ffjf-HY; Wed, 02 Aug 2023 15:14:09 +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 v6 15/38] m68k: Implement the new page table range API Date: Wed, 2 Aug 2023 16:13:43 +0100 Message-Id: <20230802151406.3735276-16-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230802151406.3735276-1-willy@infradead.org> References: <20230802151406.3735276-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: C5FBD120014 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: g139cpa4hk71orun9jnkiaz51u69eqz6 X-HE-Tag: 1690989251-936095 X-HE-Meta: U2FsdGVkX1+3YRSxuv19lHi9/fmSxsFWEbiHdZ9wAMP9PT/NHBdzSzyLkhZ7tL59NVblRJSpxvwLRjH+nn7VStg34WZqCRMLl2EsT56YSb+6tlGrdzF9fHjTgwNoy+FNMTe8bmXqYC2RDg10xoIOD3Sb8ZIzKzdGZtFBeBUajQliNdXrvTIiN45K1UhMJZ7jm2yF7VhO2F2Ng1Jtg+TLEXRTuQhrFtZaJZzKuw04194uDJAIs1HQNNs/GtI7FrtJTkMTnzfqp+MGQhMjN+fqpgYRqPXlKu733k3CoHUSPHRCkpIaKVSf+cnkDOXQyOH4R14iASSFkQs/vHljJQ94rQvxk4LOs//BdKrYEwQ3iOQId1zngigQMB31X3aX5NyXS9h+m364fL3H0AX8kqzt5zRqogePP/bou8AuopuAm2V7xRMlByeCLZIRZP/GiZwn9Sw9H9g9G87q2m4gAG5pm1sZK9jvWGSLzIeG/WKiz/w7TLuUuVZknAx7XwqVq8K/58Oci6wHnB7C2YU/EMmMxZxdB75iHlkpbt9zpUiMNeuYgvdYla5PqrS6XG06dfdDIrsx6fVs7ihpvP7OLyOT802uZTHQ/jWq6FKnP6DnzjYUNndASxHC6La5y/kI432noa97rytGoz2FjHCbpB7fAochy4s7ypcbGbD74bR8nKwTNpHXzNgh61p9pdjXyxwLgY8OeXmHweIA+V+vU8RlvGLhsSVv9IjbJPV4YWQJR2E2smd5xJJiXepqylPI7A3co4T46zGC3fE6kuWsLgr4BgfrlYwj4S6m8xQOPd0LuKGL+HSlFMfBjkKZIt635VfR4sL0lPMQVxfFjwMVStVBqmS+g+qIl69IeO3c0ogO3FDC04ZMLqEvUOXnpcVcK0RDy2cYMmHbPf3GItEGSffMzLKe06l9c2f5fW/r7q29GqKtFtL8OgyADXt8LQgyEIm8gu8PJTBH7Rvw5OuSlSr ozmenyCi jOiRdJ+hfYWX3Nzpgl2fLWNqS4FkBtiyFRDjFtv0JwEgxj8usROoj8uBCNp3XVCl1F0OQJ9e0KLpYWymgGJQs1PcObKfauhnb1VpP1J8XOQdnDnUr0o2cpfgZT8RwhTvszTOHFmPj1C9+Loa26MD8kB+4Osfo97z6CoFHv2MDg8OzchbZV35i2gj7rJnkQrXUq49ssOG/Zygcn7LERTsgDMBSN9/w1DYDB4tMz7IB7Lzbekq5UYW21XdCIti1zFhNE2qiihVK20vZ3uEU8QxDKY361yFRHqq8jfg6AX9Z0om0c08= 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); }