From patchwork Tue Feb 28 21:37:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13155259 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 7E10AC7EE32 for ; Tue, 28 Feb 2023 21:38:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 377126B00A1; Tue, 28 Feb 2023 16:38:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 28BE56B00A2; Tue, 28 Feb 2023 16:38:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 12AEF6B00A3; Tue, 28 Feb 2023 16:38:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 021D26B00A1 for ; Tue, 28 Feb 2023 16:38:04 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C0E98C0CE3 for ; Tue, 28 Feb 2023 21:38:03 +0000 (UTC) X-FDA: 80518013646.03.57A1A3A Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf14.hostedemail.com (Postfix) with ESMTP id 13DF4100012 for ; Tue, 28 Feb 2023 21:38:00 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=HmCkTVEx; spf=none (imf14.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=1677620281; 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=hq3kISoFqRozP9bJJptL5dM/gm/mC87Ff3e3oJGmMC0=; b=yH6eJobEsBWSw88wJc17/ORrfKmKFBBsjT+NrBhdXXb1M4lzQWxTXbhVFqhy/1UsH+MTJx GYYMLuYHbkAFTd5AeLojdz6UIuSS7mSRsZBdj6qYj4eiA0NG2BZCl5QdZAWGqclqoooDra jWBgJAxtSg/zTliUq3I5Afl2y9tielw= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=HmCkTVEx; spf=none (imf14.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677620281; a=rsa-sha256; cv=none; b=JgKJw2qAR5NWzXz2F1sfg5dM0ayjKTFR6lnPUYBLpnFNx8/Str856tdaOF+Cw8zDFn4CJU EZVc50X8HdIcpsKOXog2tXMmQ5ONfyoTT8le8btG6mdGkHy2xeUuoIQrsgIRdIu/mJVNl2 19wSfRDVSmxciIxVcCVnlsq6uoo1fCk= 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=hq3kISoFqRozP9bJJptL5dM/gm/mC87Ff3e3oJGmMC0=; b=HmCkTVEx+/alS0XUELP9sviI0P XwT1wjtUe1UHwQkomBTxZ6s1g3pshmPH1hg8a7HjTzZqpZFzAUALurqF54RkhBf6hfWtHZZNcdFPR ARLhyIau0aDSwhLJkNu02P21NBw4Ksxam8xdlreRAHM7wnnddFKZXuif2FyJQONCZT/CZRR6pkG3a mO3MySAvI7RlNwsACfgqbsabTJBLW1X7YctVMHvkuujOGmlicHDytDEFtyjarwsFi8pZMwyQ43ayb gqJwIpJyk3fXgoXXvzzhiWHzpvGUeOjRAegjyuVrn+dH/asF3DIhdh8K/NmzVwCCO085Ss1V0QznX t15DgCmA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pX7fJ-0018qC-TJ; Tue, 28 Feb 2023 21:37:41 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org, linux-arch@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, "David S. Miller" , sparclinux@vger.kernel.org Subject: [PATCH v3 23/34] sparc32: Implement the new page table range API Date: Tue, 28 Feb 2023 21:37:26 +0000 Message-Id: <20230228213738.272178-24-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230228213738.272178-1-willy@infradead.org> References: <20230228213738.272178-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 13DF4100012 X-Stat-Signature: 71abrbwydwbztn96mgedycfssstbfu8o X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1677620280-249013 X-HE-Meta: U2FsdGVkX19MtO6ylQj58c49lxZVMoXveP2+Fk6q2U9dAeppN+6GUpJK8y0mp9ow0BcSgcAowtPqyXzIstmjBYYXL409EKMQ63BVgNn9YjfbYJ9BuvbGlIdbkg2Q8OyLRiNrGLxPVwzhjJ1rMjAnSHmAfLhr8e5kwCm5koIUM0hd45OV7Hxv1DunufouLST2YuMEPH+dk4ITE4FX3RxqDrqzJk2pZ9BmyFQkYo9S17UHD36Mw3wtgDZGx80L+SFUpL2MdHakCLu6viCnhebrx5PqxSseyM6n1DiumGd6/71XKxj3DEoXYSVhRlKDWoSiWOuh2YydB5sIRM9HJwbNJSBL8GSeuDdJtqYfDmcX2lEYRK8hWQFzAjWijXxbiNQ3XmR1kzxEl/XzIDoAJEtYBJx4KoG2hZSLCkIOmRM1sPA5gow/p/9ta4KgsvX955jB9nVgDr5yJs580Rp1LFBie6whn8JsHXInVFtQrpbGMv8CB7O6k+y57MMUN2kuJpnU73/vQg7vcFY96MiBNcF0brnCkUpn69BsszbnZwAvdMnhCfCmTQCDFi8EJFY+16GUgAH962KYNMV6z8h0yFjjm4a6C4/EmWxI+Jd9Z3pcyFuIJObGbv2i+K6x1XlqQoBjuRnu48h0XFGPx0mGoJBo+2ETgtWKED/424W8D6L9IuP2RJGHPWrCnbTlxki7s3bwCyOEhFnf6TR6d7RzpgOv3gy5aRKPJiZKCWoKY5qEV6+4mH9jRR6Rbhwsce63Zn6g8ucCJzrqem2NyhzVI6Tq/Vuydqe8jGXZfoZV72wMTe6xvNsYPY0kVTXsYhR+q6hte0B4xNSabqJNU/PL+QJxYI/xXZNUGVoB/+/9ZHUO+14b9mrAMmZjuLIG41/uGNRatZpEDJ+Mwnn9HWYH5dQJJG9IjhI0mDXVv4TYRIZF/LKqSZ1glgI1DDlCdxaQSWD6LuPwtQqJpf890cma7ms UspyODJh pfN2g+w/maWFqL/hkOwhgY+WDo2yFsw1eOkUWDxcQ5OyKMu8pnmZxd5IlOET1OQHfDHmy7jxaL5V5kt8v8AmtAvoUJDPwKW/Q/NvRJe0NzxB2WhLAog3XLXExi2nZRLw24S2i5TaQDG7qE/OH6Z6pQwoaaWQmGpwyCqQ2Sh32G2P7oWzTzCtmEkO7OCSybSxhTwtROxYolviLuvmFDhOgymE+NJrOSpijZm2AeOrEh4b5eOi6bJDqMlY7K7ltdxdy06yQbyHKCX/Wayz+FMXMb745xr8JftIMNpiiH/6cQ8bvwuDNv9lC5NxtG0omTlxmiiZ/ 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 set_ptes(), update_mmu_cache_range(), flush_dcache_folio() and flush_icache_pages(). Signed-off-by: Matthew Wilcox (Oracle) Cc: "David S. Miller" Cc: sparclinux@vger.kernel.org --- arch/sparc/include/asm/cacheflush_32.h | 9 +++++++-- arch/sparc/include/asm/pgtable_32.h | 15 ++++++++++++++- arch/sparc/mm/init_32.c | 13 +++++++++++-- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/arch/sparc/include/asm/cacheflush_32.h b/arch/sparc/include/asm/cacheflush_32.h index adb6991d0455..8dba35d63328 100644 --- a/arch/sparc/include/asm/cacheflush_32.h +++ b/arch/sparc/include/asm/cacheflush_32.h @@ -16,6 +16,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 +36,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..47ae55ea1837 100644 --- a/arch/sparc/include/asm/pgtable_32.h +++ b/arch/sparc/include/asm/pgtable_32.h @@ -101,7 +101,19 @@ 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 void set_ptes(struct mm_struct *mm, unsigned long addr, + pte_t *ptep, pte_t pte, unsigned int nr) +{ + for (;;) { + set_pte(ptep, pte); + if (--nr == 0) + break; + ptep++; + pte_val(pte) += PAGE_SIZE; + } +} + +#define set_pte_at(mm, addr, ptep, pte) set_ptes(mm, addr, ptep, pte, 1) static inline int srmmu_device_memory(unsigned long x) { @@ -318,6 +330,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(vma, address, ptep, nr) do { } while (0) void srmmu_mapiorange(unsigned int bus, unsigned long xpa, unsigned long xva, unsigned int len); 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,