From patchwork Wed Aug 2 15:13:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13338354 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 EC07DC04A6A for ; Wed, 2 Aug 2023 15:14:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 56CE028019B; Wed, 2 Aug 2023 11:14:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4D4512801A2; Wed, 2 Aug 2023 11:14:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C9222801A1; Wed, 2 Aug 2023 11:14:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D7B972801A0 for ; Wed, 2 Aug 2023 11:14:18 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id AF6CB16074C for ; Wed, 2 Aug 2023 15:14:18 +0000 (UTC) X-FDA: 81079510596.04.D5ED0AC Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf12.hostedemail.com (Postfix) with ESMTP id 050EC40006 for ; Wed, 2 Aug 2023 15:14:16 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=MLqcg1D9; spf=none (imf12.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=1690989257; 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=eKfshkFukdi/+/58GjvlUWlADdkMvY8HIixSMpGbnWo=; b=0R75ok4hox7UhWbRX0CnMV8frgFVHbUSgkjBa4vnPdI5vEAxSLAebFfj7l9CAIz6hVaHCU nabt8PdsAyQq8La/XUCdPAX1zBmIgXK3H7Y8sV/3iCYyKvtyCDQBeGyZ9oCSbtzkFl9jXw BOlAQdODt0DIlIBlwalh5G3JgIw32Nw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690989257; a=rsa-sha256; cv=none; b=0BFvwjvxfRcbtFREZwFZUP5YhUT7qYPZ3SvBwrU6c70fH0Jhv9P7eh5Yi8Lbltu3IYUL9B OIY499P/XRqnnzVxDHKUmRHLYEtJCL0aE5qFGCJ45m2/xXg3HyPoeKbuiFA2Kp0p00qjaI /y83Z7aX0b/ppU/jB4PsSYMprv3PrOM= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=MLqcg1D9; spf=none (imf12.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=eKfshkFukdi/+/58GjvlUWlADdkMvY8HIixSMpGbnWo=; b=MLqcg1D98xvlGhipw6sUTh0JzN KUGkWju62mogqpcZMKoxUp1hI9Ou6o+dyVI0S36JjiQ0lxqZM4JzGJuGGe2TDbOEMBTQdDi+t3L55 RPv5LKZltAsWGtDwJXx84Ef+lm+cTZna2hUwwMTucrox+VqpybGO+VcKe7C/I9/kY/+8K0iEvHtuM tHD45W4AdieH9MBzHDTThyFXZqkLZrBOfkgvBPcaioOftNm+FVAoFB1lA9qv8IiP8LVLhh5nvxeC0 Xg76v3PXsUHaljyEZiqyDhF6K5xadOTgBKp9VBsVBsV7xex/8IvbcYcC6+VY/lxfaYy6VTpBdlYav 3b1FPTHA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qRDYA-00Ffkk-SE; Wed, 02 Aug 2023 15:14:10 +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, Mike Rapoport , "David S. Miller" , sparclinux@vger.kernel.org Subject: [PATCH v6 25/38] sparc32: Implement the new page table range API Date: Wed, 2 Aug 2023 16:13:53 +0100 Message-Id: <20230802151406.3735276-26-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-Stat-Signature: pc3h8m41pwn71oa3b4mmdj7gueutum3o X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 050EC40006 X-Rspam-User: X-HE-Tag: 1690989256-798430 X-HE-Meta: U2FsdGVkX19IHJTZwT9dpD+6AqQjnK1bf0lC15onaWLKhq0s9qI1cSxMJN3fRIRBNge5HA68g82WBc9KwcbpvUZZ8i8qUTxKWxr5RkBmPeFwLmLQbsoEJMCJuk05TcJq8YiZ2Nxy2xJO2OtFAmjnxJK0SDdmnS4B20H+vebilfMCt22fl8SVPMPua/S89HGZS9f1UGJBwiyi6sh4Se0e26ARC7+gypQITiDxS6Qmx0w5qHSCIiwo+W8YTOUjCY5qEeN87UKSP9GV01ZJI2LpfNXA3JONMW6mXs017/G8lS0lGF2Vp29Qht/Aa2RFxrU0ZNTE4+A2n8XcGSaDtJp28yh8vYv4euadLw1Euvr0BBUq6L+zZunT2TsQeZ9X4OWGzbV9HcGDVxwzWqORmmpCW/PmK5yhmf+5TE2P6PdIUfvb5WxFydLdkfezgREWWptVK3wA0I9PdzITwb2MZe9q9+x5Tq9fyv17hsi6ikzFsGpfMZSs2oDwoYuOb4YdaNnIvC4PhGTFPsdoCpr5bP+BjN6hVTkw2ZTwR9bFW/ZUQV7UXSqKWuQUMqwkGcRN7WsmxtuIQoy5XRgSh5rxPrQCoL9dgyZ5hhETFpcaBnanc1kPQEbT7ihDGhawXUNkCXZ9ZZdqMwZVbpGR32rG07OoNVvfHJ18nDTxEQkZQlj19u/kJIMp55qTJIB+02Mf9o3MmmMbRAePqKcSYUBHLaVpM7C7UJL0FzFk0yDbZ2TD/zrddyfuffq87wUtgy45bda8P6QjD+RlkAHMgDx5vIoE70eQ/DbVTbSkgFw/8ByKnq5MiJdUgJ0RaTkWRNbTNROZZycB2yL5LsEWwBf1+lDNM8BEADC9xMI2IOnZHqPdm0LM+SpxfmhqboVNbkFUobwe0Mqr2hA3A4Rx2C3+i4oZ1IGAFJqwujkKxBpaMuS0IQ1Hc0kF/mK9vusSmBrbsCmY0M6pVTKxE/4ZqJQ9xa9 Zoko90uS okV6toS5D/DM8S7Qrs91xkyrF7al1j+joMADpdJEGhjzQ4gChjyhn8AQPg+W6OdwRUuG0X3u55Mi3j/6KgU4upq05sAcCcHBs1SAE70UIsC3D5+DaEhuhneizKhrJa7FE5Fo5K1aaPpAkN5B9qXNaS2SoBbv+Gk/qTYwkvdccmjJcn5vRo6QesPqADPeLWsDAN7NcD03SnmXsMoIolurEeKJ+PkIJU4/pCEtj2EmST2wgMp/rItQ+Rec4KeLvGsR+hHmm3qq88p+y/9AZwH2We/ldI2FIPSDulmMw4lEG/pSMytU= 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_dcache_folio() and flush_icache_pages(). Signed-off-by: Matthew Wilcox (Oracle) Acked-by: Mike Rapoport (IBM) Cc: "David S. Miller" Cc: sparclinux@vger.kernel.org --- arch/sparc/include/asm/cacheflush_32.h | 10 ++++++++-- arch/sparc/include/asm/pgtable_32.h | 8 ++++---- arch/sparc/mm/init_32.c | 13 +++++++++++-- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/arch/sparc/include/asm/cacheflush_32.h b/arch/sparc/include/asm/cacheflush_32.h index adb6991d0455..c8dd971f0e88 100644 --- a/arch/sparc/include/asm/cacheflush_32.h +++ b/arch/sparc/include/asm/cacheflush_32.h @@ -2,6 +2,7 @@ #ifndef _SPARC_CACHEFLUSH_H #define _SPARC_CACHEFLUSH_H +#include #include #define flush_cache_all() \ @@ -16,6 +17,7 @@ sparc32_cachetlb_ops->cache_page(vma, addr) #define flush_icache_range(start, end) do { } while (0) #define flush_icache_page(vma, pg) do { } while (0) +#define flush_icache_pages(vma, pg, nr) do { } while (0) #define copy_to_user_page(vma, page, vaddr, dst, src, len) \ do { \ @@ -35,11 +37,15 @@ #define flush_page_for_dma(addr) \ sparc32_cachetlb_ops->page_for_dma(addr) -struct page; void sparc_flush_page_to_ram(struct page *page); +void sparc_flush_folio_to_ram(struct folio *folio); #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1 -#define flush_dcache_page(page) sparc_flush_page_to_ram(page) +#define flush_dcache_folio(folio) sparc_flush_folio_to_ram(folio) +static inline void flush_dcache_page(struct page *page) +{ + flush_dcache_folio(page_folio(page)); +} #define flush_dcache_mmap_lock(mapping) do { } while (0) #define flush_dcache_mmap_unlock(mapping) do { } while (0) diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h index d4330e3c57a6..315d316614ca 100644 --- a/arch/sparc/include/asm/pgtable_32.h +++ b/arch/sparc/include/asm/pgtable_32.h @@ -101,8 +101,6 @@ static inline void set_pte(pte_t *ptep, pte_t pteval) srmmu_swap((unsigned long *)ptep, pte_val(pteval)); } -#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval) - static inline int srmmu_device_memory(unsigned long x) { return ((x & 0xF0000000) != 0); @@ -256,6 +254,7 @@ static inline pte_t pte_mkyoung(pte_t pte) return __pte(pte_val(pte) | SRMMU_REF); } +#define PFN_PTE_SHIFT (PAGE_SHIFT - 4) #define pfn_pte(pfn, prot) mk_pte(pfn_to_page(pfn), prot) static inline unsigned long pte_pfn(pte_t pte) @@ -268,7 +267,7 @@ static inline unsigned long pte_pfn(pte_t pte) */ return ~0UL; } - return (pte_val(pte) & SRMMU_PTE_PMASK) >> (PAGE_SHIFT-4); + return (pte_val(pte) & SRMMU_PTE_PMASK) >> PFN_PTE_SHIFT; } #define pte_page(pte) pfn_to_page(pte_pfn(pte)) @@ -318,6 +317,7 @@ void mmu_info(struct seq_file *m); #define FAULT_CODE_USER 0x4 #define update_mmu_cache(vma, address, ptep) do { } while (0) +#define update_mmu_cache_range(vmf, vma, address, ptep, nr) do { } while (0) void srmmu_mapiorange(unsigned int bus, unsigned long xpa, unsigned long xva, unsigned int len); @@ -422,7 +422,7 @@ static inline int io_remap_pfn_range(struct vm_area_struct *vma, ({ \ int __changed = !pte_same(*(__ptep), __entry); \ if (__changed) { \ - set_pte_at((__vma)->vm_mm, (__address), __ptep, __entry); \ + set_pte(__ptep, __entry); \ flush_tlb_page(__vma, __address); \ } \ __changed; \ diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c index 9c0ea457bdf0..d96a14ffceeb 100644 --- a/arch/sparc/mm/init_32.c +++ b/arch/sparc/mm/init_32.c @@ -297,11 +297,20 @@ void sparc_flush_page_to_ram(struct page *page) { unsigned long vaddr = (unsigned long)page_address(page); - if (vaddr) - __flush_page_to_ram(vaddr); + __flush_page_to_ram(vaddr); } EXPORT_SYMBOL(sparc_flush_page_to_ram); +void sparc_flush_folio_to_ram(struct folio *folio) +{ + unsigned long vaddr = (unsigned long)folio_address(folio); + unsigned int i, nr = folio_nr_pages(folio); + + for (i = 0; i < nr; i++) + __flush_page_to_ram(vaddr + i * PAGE_SIZE); +} +EXPORT_SYMBOL(sparc_flush_folio_to_ram); + static const pgprot_t protection_map[16] = { [VM_NONE] = PAGE_NONE, [VM_READ] = PAGE_READONLY,