From patchwork Tue Feb 28 21:37:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 62619 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3267326wrd; Tue, 28 Feb 2023 13:39:31 -0800 (PST) X-Google-Smtp-Source: AK7set/fkW4RAvO7B8ODBhnz2K/A6FZKOVZ+G1Td5WSR2jcCt86BDVwIkWnV43PdUk4pYApjkOMt X-Received: by 2002:a17:903:2305:b0:19a:a673:4ee2 with SMTP id d5-20020a170903230500b0019aa6734ee2mr5332359plh.31.1677620370769; Tue, 28 Feb 2023 13:39:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677620370; cv=none; d=google.com; s=arc-20160816; b=R17Y7DXMmmQebT2ymAGN9XX+dIN918baRAG8X3xgfERapLHopDnzGJ6bwJM7Mni+cL gqJY8Pz6PH2IW0yRkzMip57D+bvAEvYENZ1qKUxiaX6NmKQP9Hp7kVRQ8DkGQh6Vitik bfxgFj2UTOFAuW1casOLvKDhncpBOEUPo+/4Ouhp3MsVy1uv0X/Mn5/F0kGn36fbT6JL OC8HvdpWUqUUdIOnCRtprAqQhYkT7i7+XzykVTLEXLluHITvSCYgoS/YDtsf6zHwf6M8 r84AVb+OamHesQM+WqmJDxpaqJkkXZcwjuhsxwZG1drswOgaosbqFYIvRikEiK9OIRJ+ 9Llw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jco2/brYdWe0hU6YkAHAWSfRYtcsxYQg52X9PqtqDX0=; b=duKx18Dh76D0Yhd6sVQ93C+wRQjUBTLfVgwovMxbNki4AyDH4xEy/CIK+RhHLXCW7s dh6BBTWNY1nPKXFx7nzTd/md5GP/TH/y7O2UTuS67JzRicU75zeVXLSuN0DQggNA9hgY bBQdo5fvhfyQy97HrVRqL2N+zLzZpTYt4gtWHJpbG3gqWgPh5IAScmqYb+ECpsF5gIIg iq4aOZ7ZcmYFdPFI4qKrLmN+UrwGl2Dq7QC+zi0QxgJNoTyHulUtC82dmrVf9Fu+npHl lOAZGUxC2HCL2sfM2D9kVHCinOTVV3yGRCiL5uavR4oqK3JM0cKnaNfDDLFFPBhpcZbk 1Jkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=MylEPx10; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b8-20020a633408000000b004fbcd0785casi10597061pga.207.2023.02.28.13.39.17; Tue, 28 Feb 2023 13:39:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=MylEPx10; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230015AbjB1ViH (ORCPT + 99 others); Tue, 28 Feb 2023 16:38:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229827AbjB1Vhr (ORCPT ); Tue, 28 Feb 2023 16:37:47 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C035B34332; Tue, 28 Feb 2023 13:37:42 -0800 (PST) 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=jco2/brYdWe0hU6YkAHAWSfRYtcsxYQg52X9PqtqDX0=; b=MylEPx10D9cki0lh9U/HhXaSjh 5VXaWVx/v0ZIYexIBTVZVd4Dj6AHZ3hAgeXILq/jVFyUoUXkSff4Pmo799mtlnuZ0suzfkXCafxG8 nzpSeo6aYtWeN0Oecw+5ERf9nBoatUgG8DvKR73bfIwWILec/CNHG3S552x7G5Xe2282okADGciuV NoISRFOqmdfyLi6xuOq6nfQHWs66T+MpGVc0tQ3PdjyjUaDP1L8Vi6afNGu4eFFgnkOuUOKAgSkVi F6oRG/BpdUZiixspN/rpIE6HbXVFicUqaxpOtNAakyxly5l1gLJlVLaMSEsZts0QfwNmUnsxp6vgV C/jNhgTw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pX7fI-0018pJ-SN; Tue, 28 Feb 2023 21:37:40 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org, linux-arch@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, Michal Simek Subject: [PATCH v3 14/34] microblaze: Implement the new page table range API Date: Tue, 28 Feb 2023 21:37:17 +0000 Message-Id: <20230228213738.272178-15-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-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759112457939333844?= X-GMAIL-MSGID: =?utf-8?q?1759112457939333844?= Add set_ptes(), update_mmu_cache_range(), flush_icache_pages() and flush_dcache_folio(). Also change the calling convention for set_pte() to be the same as other architectures. Signed-off-by: Matthew Wilcox (Oracle) Cc: Michal Simek --- arch/microblaze/include/asm/cacheflush.h | 8 ++++++++ arch/microblaze/include/asm/pgtable.h | 17 ++++++++++++----- arch/microblaze/include/asm/tlbflush.h | 4 +++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/arch/microblaze/include/asm/cacheflush.h b/arch/microblaze/include/asm/cacheflush.h index 39f8fb6768d8..e6641ff98cb3 100644 --- a/arch/microblaze/include/asm/cacheflush.h +++ b/arch/microblaze/include/asm/cacheflush.h @@ -74,6 +74,14 @@ do { \ flush_dcache_range((unsigned) (addr), (unsigned) (addr) + PAGE_SIZE); \ } while (0); +static void flush_dcache_folio(struct folio *folio) +{ + unsigned long addr = folio_pfn(folio) << PAGE_SHIFT; + + flush_dcache_range(addr, addr + folio_size(folio)); +} +#define flush_dcache_folio flush_dcache_folio + #define flush_cache_page(vma, vmaddr, pfn) \ flush_dcache_range(pfn << PAGE_SHIFT, (pfn << PAGE_SHIFT) + PAGE_SIZE); diff --git a/arch/microblaze/include/asm/pgtable.h b/arch/microblaze/include/asm/pgtable.h index d1b8272abcd9..a01e1369b486 100644 --- a/arch/microblaze/include/asm/pgtable.h +++ b/arch/microblaze/include/asm/pgtable.h @@ -330,18 +330,25 @@ static inline unsigned long pte_update(pte_t *p, unsigned long clr, /* * set_pte stores a linux PTE into the linux page table. */ -static inline void set_pte(struct mm_struct *mm, unsigned long addr, - pte_t *ptep, pte_t pte) +static inline void set_pte(pte_t *ptep, pte_t pte) { *ptep = pte; } -static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, - pte_t *ptep, pte_t pte) +static inline void set_ptes(struct mm_struct *mm, unsigned long addr, + pte_t *ptep, pte_t pte, unsigned int nr) { - *ptep = pte; + for (;;) { + set_pte(ptep, pte); + if (--nr == 0) + break; + ptep++; + pte_val(pte) += 1 << PFN_SHIFT_OFFSET; + } } +#define set_pte_at(mm, addr, ptep, pte) set_ptes(mm, addr, ptep, pte, 1) + #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long address, pte_t *ptep) diff --git a/arch/microblaze/include/asm/tlbflush.h b/arch/microblaze/include/asm/tlbflush.h index 2038168ed128..1b179e5e9062 100644 --- a/arch/microblaze/include/asm/tlbflush.h +++ b/arch/microblaze/include/asm/tlbflush.h @@ -33,7 +33,9 @@ static inline void local_flush_tlb_range(struct vm_area_struct *vma, #define flush_tlb_kernel_range(start, end) do { } while (0) -#define update_mmu_cache(vma, addr, ptep) do { } while (0) +#define update_mmu_cache_range(vma, addr, ptep, nr) do { } while (0) +#define update_mmu_cache(vma, addr, pte) \ + update_mmu_cache_range(vma, addr, ptep, 1) #define flush_tlb_all local_flush_tlb_all #define flush_tlb_mm local_flush_tlb_mm