All of lore.kernel.org
 help / color / mirror / Atom feed
From: John David Anglin <dave.anglin@bell.net>
To: linux-parisc@vger.kernel.org
Cc: Helge Deller <deller@gmx.de>, Deller <deller@kernel.org>,
	James Bottomley <James.Bottomley@hansenpartnership.com>
Subject: [PATCH] parisc: Fix invalidate/flush vmap routines
Date: Fri, 18 Mar 2022 22:24:22 +0000	[thread overview]
Message-ID: <YjUGloM6ji+4Ii9k@mx3210.localdomain> (raw)

[-- Attachment #1: Type: text/plain, Size: 1969 bytes --]

Cache move-in for virtual accesses is controlled by the TLB.  Thus,
we must generally purge TLB entries before flushing.  The flush routines
must use TLB entries that inhibit cache move-in.

Signed-off-by: John David Anglin <dave.anglin@bell.net>
---

diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c
index 94150b91c96f..a7c68d14ba94 100644
--- a/arch/parisc/kernel/cache.c
+++ b/arch/parisc/kernel/cache.c
@@ -633,16 +619,23 @@ void flush_kernel_vmap_range(void *vaddr, int size)
 {
 	unsigned long start = (unsigned long)vaddr;
 	unsigned long end = start + size;
+	unsigned long physaddr;
 
+	flush_tlb_kernel_range(start, end);
 	if ((!IS_ENABLED(CONFIG_SMP) || !arch_irqs_disabled()) &&
 	    (unsigned long)size >= parisc_cache_flush_threshold) {
-		flush_tlb_kernel_range(start, end);
 		flush_data_cache();
 		return;
 	}
 
-	flush_kernel_dcache_range_asm(start, end);
-	flush_tlb_kernel_range(start, end);
+	preempt_disable();
+	while (start <= end) {
+		physaddr = lpa(start);
+		if (physaddr)
+			flush_dcache_page_asm(physaddr, start);
+		start += PAGE_SIZE;
+	}
+	preempt_enable();
 }
 EXPORT_SYMBOL(flush_kernel_vmap_range);
 
@@ -650,15 +643,22 @@ void invalidate_kernel_vmap_range(void *vaddr, int size)
 {
 	unsigned long start = (unsigned long)vaddr;
 	unsigned long end = start + size;
+	unsigned long physaddr;
 
+	flush_tlb_kernel_range(start, end);
 	if ((!IS_ENABLED(CONFIG_SMP) || !arch_irqs_disabled()) &&
 	    (unsigned long)size >= parisc_cache_flush_threshold) {
-		flush_tlb_kernel_range(start, end);
 		flush_data_cache();
 		return;
 	}
 
-	purge_kernel_dcache_range_asm(start, end);
-	flush_tlb_kernel_range(start, end);
+	preempt_disable();
+	while (start <= end) {
+		physaddr = lpa(start);
+		if (physaddr)
+			purge_dcache_page_asm(physaddr, start);
+		start += PAGE_SIZE;
+	}
+	preempt_enable();
 }
 EXPORT_SYMBOL(invalidate_kernel_vmap_range);


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

                 reply	other threads:[~2022-03-18 22:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YjUGloM6ji+4Ii9k@mx3210.localdomain \
    --to=dave.anglin@bell.net \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=deller@gmx.de \
    --cc=deller@kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.