powerpc/powernv/memtrace: Fix dcache flushing

Started by Sandipan Das on Apr 30, 2021 · 4 messages from 3 authors · Last reply May 1, 2021

Subsystems (2)

Maintainers (2)

STALE2036d

open the first message on its own page

Message details and related content
Trace memory is cleared and the corresponding dcache lines
are flushed after allocation. However, this should not be
done using the PFN. This adds the missing __va() conversion.

Fixes: 2ac02e5ecec0 ("powerpc/mm: Remove dcache flush from memory remove.")
Signed-off-by: Sandipan Das <redacted>
---
 arch/powerpc/platforms/powernv/memtrace.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/memtrace.c b/arch/powerpc/platforms/powernv/memtrace.c
index 71c1262589fe..a31f13814f2e 100644
--- a/arch/powerpc/platforms/powernv/memtrace.c
+++ b/arch/powerpc/platforms/powernv/memtrace.c
@@ -104,8 +104,8 @@ static void memtrace_clear_range(unsigned long start_pfn,
 	 * Before we go ahead and use this range as cache inhibited range
 	 * flush the cache.
 	 */
-	flush_dcache_range_chunked(PFN_PHYS(start_pfn),
-				   PFN_PHYS(start_pfn + nr_pages),
+	flush_dcache_range_chunked((unsigned long)__va(PFN_PHYS(start_pfn)),
+				   (unsigned long)__va(PFN_PHYS(start_pfn + nr_pages)),
 				   FLUSH_CHUNK_SIZE);
 }
 
-- 
2.25.1
Message details and related content
Sandipan Das [off-list ref] writes:
Trace memory is cleared and the corresponding dcache lines
are flushed after allocation. However, this should not be
done using the PFN. This adds the missing __va() conversion.
Reviewed-by: Aneesh Kumar K.V <redacted>
quoted hunk
Fixes: 2ac02e5ecec0 ("powerpc/mm: Remove dcache flush from memory remove.")
Signed-off-by: Sandipan Das <redacted>
---
 arch/powerpc/platforms/powernv/memtrace.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/memtrace.c b/arch/powerpc/platforms/powernv/memtrace.c
index 71c1262589fe..a31f13814f2e 100644
--- a/arch/powerpc/platforms/powernv/memtrace.c
+++ b/arch/powerpc/platforms/powernv/memtrace.c
@@ -104,8 +104,8 @@ static void memtrace_clear_range(unsigned long start_pfn,
 	 * Before we go ahead and use this range as cache inhibited range
 	 * flush the cache.
 	 */
-	flush_dcache_range_chunked(PFN_PHYS(start_pfn),
-				   PFN_PHYS(start_pfn + nr_pages),
+	flush_dcache_range_chunked((unsigned long)__va(PFN_PHYS(start_pfn)),
+				   (unsigned long)__va(PFN_PHYS(start_pfn + nr_pages)),
 				   FLUSH_CHUNK_SIZE);
 }
 
-- 
2.25.1
Message details and related content

Le 30/04/2021 à 09:55, Sandipan Das a écrit :
quoted hunk
Trace memory is cleared and the corresponding dcache lines
are flushed after allocation. However, this should not be
done using the PFN. This adds the missing __va() conversion.

Fixes: 2ac02e5ecec0 ("powerpc/mm: Remove dcache flush from memory remove.")
Signed-off-by: Sandipan Das <redacted>
---
  arch/powerpc/platforms/powernv/memtrace.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/memtrace.c b/arch/powerpc/platforms/powernv/memtrace.c
index 71c1262589fe..a31f13814f2e 100644
--- a/arch/powerpc/platforms/powernv/memtrace.c
+++ b/arch/powerpc/platforms/powernv/memtrace.c
@@ -104,8 +104,8 @@ static void memtrace_clear_range(unsigned long start_pfn,
  	 * Before we go ahead and use this range as cache inhibited range
  	 * flush the cache.
  	 */
-	flush_dcache_range_chunked(PFN_PHYS(start_pfn),
-				   PFN_PHYS(start_pfn + nr_pages),
+	flush_dcache_range_chunked((unsigned long)__va(PFN_PHYS(start_pfn)),
+				   (unsigned long)__va(PFN_PHYS(start_pfn + nr_pages)),
Can you use pfn_to_virt() instead ?
  				   FLUSH_CHUNK_SIZE);
  }
  
Message details and related content
On 30/04/21 2:12 pm, Christophe Leroy wrote:

Le 30/04/2021 à 09:55, Sandipan Das a écrit :
quoted
Trace memory is cleared and the corresponding dcache lines
are flushed after allocation. However, this should not be
done using the PFN. This adds the missing __va() conversion.

Fixes: 2ac02e5ecec0 ("powerpc/mm: Remove dcache flush from memory remove.")
Signed-off-by: Sandipan Das <redacted>
---
  arch/powerpc/platforms/powernv/memtrace.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/memtrace.c b/arch/powerpc/platforms/powernv/memtrace.c
index 71c1262589fe..a31f13814f2e 100644
--- a/arch/powerpc/platforms/powernv/memtrace.c
+++ b/arch/powerpc/platforms/powernv/memtrace.c
@@ -104,8 +104,8 @@ static void memtrace_clear_range(unsigned long start_pfn,
       * Before we go ahead and use this range as cache inhibited range
       * flush the cache.
       */
-    flush_dcache_range_chunked(PFN_PHYS(start_pfn),
-                   PFN_PHYS(start_pfn + nr_pages),
+    flush_dcache_range_chunked((unsigned long)__va(PFN_PHYS(start_pfn)),
+                   (unsigned long)__va(PFN_PHYS(start_pfn + nr_pages)),
Can you use pfn_to_virt() instead ?
quoted
                     FLUSH_CHUNK_SIZE);
  }
 
Sure, that looks cleaner. Thanks for the suggestion.

- Sandipan
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help