powerpc/ptdump: Display size of BATs
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Tue, 19 May 2020 05:48:52 +0000 (05:48 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 26 May 2020 12:22:18 +0000 (22:22 +1000)
Display the size of areas mapped with BATs.

For that, the size display for pages is refactorised.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/acf764eee231f0358e66ca9e819f052804055acc.1589866984.git.christophe.leroy@csgroup.eu
arch/powerpc/mm/ptdump/bats.c
arch/powerpc/mm/ptdump/ptdump.c
arch/powerpc/mm/ptdump/ptdump.h

index d3a5d6b318d186781cff4d23f8d762a0cc0aaca7..d6c660f63d71354f555704c1d3c6f32716f443eb 100644 (file)
@@ -10,6 +10,8 @@
 #include <asm/pgtable.h>
 #include <asm/cpu_has_feature.h>
 
+#include "ptdump.h"
+
 static char *pp_601(int k, int pp)
 {
        if (pp == 0)
@@ -42,6 +44,7 @@ static void bat_show_601(struct seq_file *m, int idx, u32 lower, u32 upper)
 #else
        seq_printf(m, "0x%08x ", pbn);
 #endif
+       pt_dump_size(m, size);
 
        seq_printf(m, "Kernel %s User %s", pp_601(k & 2, pp), pp_601(k & 1, pp));
 
@@ -88,6 +91,7 @@ static void bat_show_603(struct seq_file *m, int idx, u32 lower, u32 upper, bool
 #else
        seq_printf(m, "0x%08x ", brpn);
 #endif
+       pt_dump_size(m, size);
 
        if (k == 1)
                seq_puts(m, "User ");
index d92bb8ea229c5324c933b38c1cda5ee3d0306241..1f97668853e3dfa9e0e5b0a5f106c7b70f41aa3e 100644 (file)
@@ -112,6 +112,19 @@ static struct addr_marker address_markers[] = {
                seq_putc(m, c);         \
 })
 
+void pt_dump_size(struct seq_file *m, unsigned long size)
+{
+       static const char units[] = "KMGTPE";
+       const char *unit = units;
+
+       /* Work out what appropriate unit to use */
+       while (!(size & 1023) && unit[1]) {
+               size >>= 10;
+               unit++;
+       }
+       pt_dump_seq_printf(m, "%9lu%c ", size, *unit);
+}
+
 static void dump_flag_info(struct pg_state *st, const struct flag_info
                *flag, u64 pte, int num)
 {
@@ -146,8 +159,6 @@ static void dump_flag_info(struct pg_state *st, const struct flag_info
 
 static void dump_addr(struct pg_state *st, unsigned long addr)
 {
-       static const char units[] = "KMGTPE";
-       const char *unit = units;
        unsigned long delta;
 
 #ifdef CONFIG_PPC64
@@ -164,13 +175,7 @@ static void dump_addr(struct pg_state *st, unsigned long addr)
                pt_dump_seq_printf(st->seq, " " REG " ", st->start_pa);
                delta = (addr - st->start_address) >> 10;
        }
-       /* Work out what appropriate unit to use */
-       while (!(delta & 1023) && unit[1]) {
-               delta >>= 10;
-               unit++;
-       }
-       pt_dump_seq_printf(st->seq, "%9lu%c", delta, *unit);
-
+       pt_dump_size(st->seq, delta);
 }
 
 static void note_prot_wx(struct pg_state *st, unsigned long addr)
index 5d513636de73a1cfe8fb0da407898f7c8da38312..154efae96ae095ef41b3d09754af9d0766837cae 100644 (file)
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #include <linux/types.h>
+#include <linux/seq_file.h>
 
 struct flag_info {
        u64             mask;
@@ -17,3 +18,5 @@ struct pgtable_level {
 };
 
 extern struct pgtable_level pg_level[5];
+
+void pt_dump_size(struct seq_file *m, unsigned long delta);