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: 13155229 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 62366C7EE31 for ; Tue, 28 Feb 2023 21:37:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0EFFC6B0075; Tue, 28 Feb 2023 16:37:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 017A96B0073; Tue, 28 Feb 2023 16:37:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD9376B0078; Tue, 28 Feb 2023 16:37:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id A98C96B0073 for ; Tue, 28 Feb 2023 16:37:44 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 6DBB11A0C93 for ; Tue, 28 Feb 2023 21:37:44 +0000 (UTC) X-FDA: 80518012848.28.79F4C19 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf14.hostedemail.com (Postfix) with ESMTP id 964AD100010 for ; Tue, 28 Feb 2023 21:37:42 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=MylEPx10; 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=1677620262; 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=jco2/brYdWe0hU6YkAHAWSfRYtcsxYQg52X9PqtqDX0=; b=rgZzrVZDkd6/USdpvLExj/jDuJ92y+4oapDhAkUnMs/7pXazFGf/MDbUTCTVXWC4lAF9nc Wh3q9XvLZ5lg23dAx1URfQ1JxzlJji1l785NENFCZEj11lRNEo3Cm6u9DN5DPu9dl0mre0 iRSyn9hEQfnp4PUqw0bZJoH6vOYT5As= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=MylEPx10; 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=1677620263; a=rsa-sha256; cv=none; b=H2oxZxcBSoeq1ay8EKxB2ptRKHqKevHQDIrWZ90Qy2XNN5VttHBsVI+7mKTU10AU9TQ7mF wd8hiuYhkNGQN5LUeDmC9yJQdNtTsRn+Y6T8Grtm0zhY631j3jHzCOH1Tt+qk635Po+dVl rgqZzh2f2PW8vitZdY74DDKzHKQkJu4= 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-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 964AD100010 X-Stat-Signature: 5xkk1g6na4ipu5agsa6e5wdqkyfwusat X-Rspam-User: X-HE-Tag: 1677620262-739931 X-HE-Meta: U2FsdGVkX186oK+MAYl+/O3aeWNrCgStP4Wl6ZqXs4CfUyF9cNSzC0KxLZjyeH0rDQ8+k70AM2I2l2pdPq5o9v+sH/dMLkMFWEsKFPuOYljnhYEoL9SKt/UoDr44/PCug0mfvCeh/4r15hyUya6sQh13E/BZa2TLhddpobM4kZ+8fPvgdpLk0dqw9jy98jZ2yybNViUl7NdsjIs4g0nr15/SUS3nHUHMOzdUE+tTvaG+OYc7LGpXGDwzplM+42GEAT9F0u/nQNXxO9iU3F3vQgPbpcom/8hSxMKkdMAcrkbSielE19sL3fYno1bywNv5fZdYAa2QH7teocLHp0btaQ+wS4ep821tq9M2BkVOirEGRNiL6jtCCGrZc9bRI2VDwM68JfWRZPOUg2DJvHYKPEyFalOr8OSqEPJmUmxr5MdDMJcyEO7PllF/TTfPUMtJVgoOoU7JLN3yBDUU6FdjRGczcxezwo4meIRso3cpPCK80DTPhymBS9510vaC3SwGYx2TMkuC7I2vhTH7fu7SOYO4ARmcZOxKZKsm3Jr7ttZ2isdsdZGaa9I4nuAYc1+IXZ2aWVWBh7pSgu+W5urDA8gPfecMePtYWxDGRP9Ucv0saBGGkgGbwEPoz/wSMCJj0pxdZLuugElt0Sd4UtYlhl1xNzDrUOUhn0NGg10FM/e1tcsXjlsPS93wG0Fd+9/0XUgy29Y0F9J0WvkCnmT6YbmJcXEiiCvcPEAHa7DM0FVge8p1+zlP3gfuXVuDE2iy3zct95jnhSaLHmg378Op42lrZjCoRX8cuAW+5avEI7rfVhEiHU4QCBmCMuAz4lP9ik/stxdSdAekRUcG/hh3VaQUeIOpyFb3VdGzKedqy/AsSK6AIUXwbLu8ISwS7qYWpJQ9SsiQ+h39cwroqObQMBgzx7DWlpVM1yMFbPEh+gaG/D0vV1SKGFx7XmovMqvNyHXru76+5Q02QEV87yE +TMcjJXb C7C+O6N3ksMidTJBXyIdAn7T9mBJT60tKAeEotc/ui/veyDlCqGKGT1VUeRyErSTrNLAE4n2Yf0ak8YwacRf+xW1HZCCA8sVpA74KfOlItSOve5/pE9NHwSLHqDwkVoCdvNbKHpDYjs/9eMpM+03aKcbwqIFCAtC2wO/UiwxHl93DMzj1KsveypYY42krDuGkjK5NOOWH0kVn3ZbAQAoYsvBE5ve60Ha1pc0NLAtZXfnPTjRkEg0wUqHEZkG5dYspcXqd 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_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