Skip to content

Commit 72d861f

Browse files
committed
ARC: boot log: eliminate struct cpuinfo_arc #1: mm
This is first step in eliminating struct cpuinfo_arc[NR_CPUS] Back when we had just ARCompact ISA, the idea was to read/bit-fiddle the BCRs once and and cache decoded information in a global struct ready to use. With ARCv2 it was modified to contained abstract / ISA agnostic information. However with ARCv3 there 's too much disparity to abstract in common structures. So drop the entire decode once and store paradigm. Afterall there's only 2 users of this machinery anyways: boot printing and cat /proc/cpuinfo. None is performance critical to warrant locking away resident memory per cpu. This patch is first step in that direction - decouples struct cpuinfo_arc_mmu from global struct cpuinfo_arc - mmu code still has a trimmed down static version of struct cpuinfo_arc_mmu to cache information needed in performance critical code such as tlb flush routines - folds read_decode_mmu_bcr() into arc_mmu_mumbojumbo() - setup_processor() directly calls arc_mmu_init() and not via arc_cpu_init() Tested-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Signed-off-by: Vineet Gupta <[email protected]>
1 parent 1918693 commit 72d861f

File tree

4 files changed

+58
-67
lines changed

4 files changed

+58
-67
lines changed

arch/arc/include/asm/arcregs.h

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,27 @@ struct bcr_uarch_build_arcv2 {
185185
#endif
186186
};
187187

188+
struct bcr_mmu_3 {
189+
#ifdef CONFIG_CPU_BIG_ENDIAN
190+
unsigned int ver:8, ways:4, sets:4, res:3, sasid:1, pg_sz:4,
191+
u_itlb:4, u_dtlb:4;
192+
#else
193+
unsigned int u_dtlb:4, u_itlb:4, pg_sz:4, sasid:1, res:3, sets:4,
194+
ways:4, ver:8;
195+
#endif
196+
};
197+
198+
struct bcr_mmu_4 {
199+
#ifdef CONFIG_CPU_BIG_ENDIAN
200+
unsigned int ver:8, sasid:1, sz1:4, sz0:4, res:2, pae:1,
201+
n_ways:2, n_entry:2, n_super:2, u_itlb:3, u_dtlb:3;
202+
#else
203+
/* DTLB ITLB JES JE JA */
204+
unsigned int u_dtlb:3, u_itlb:3, n_super:2, n_entry:2, n_ways:2,
205+
pae:1, res:2, sz0:4, sz1:4, sasid:1, ver:8;
206+
#endif
207+
};
208+
188209
struct bcr_mpy {
189210
#ifdef CONFIG_CPU_BIG_ENDIAN
190211
unsigned int pad:8, x1616:8, dsp:4, cycles:2, type:2, ver:8;
@@ -307,11 +328,6 @@ struct bcr_generic {
307328
* Generic structures to hold build configuration used at runtime
308329
*/
309330

310-
struct cpuinfo_arc_mmu {
311-
unsigned int ver:4, pg_sz_k:8, s_pg_sz_m:8, pad:10, sasid:1, pae:1;
312-
unsigned int sets:12, ways:4, u_dtlb:8, u_itlb:8;
313-
};
314-
315331
struct cpuinfo_arc_cache {
316332
unsigned int sz_k:14, line_len:8, assoc:4, alias:1, vipt:1, pad:4;
317333
};
@@ -326,7 +342,6 @@ struct cpuinfo_arc_ccm {
326342

327343
struct cpuinfo_arc {
328344
struct cpuinfo_arc_cache icache, dcache, slc;
329-
struct cpuinfo_arc_mmu mmu;
330345
struct cpuinfo_arc_bpu bpu;
331346
struct bcr_identity core;
332347
struct bcr_isa_arcv2 isa;

arch/arc/include/asm/setup.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ long __init arc_get_mem_sz(void);
3636

3737
extern void arc_mmu_init(void);
3838
extern char *arc_mmu_mumbojumbo(int cpu_id, char *buf, int len);
39-
extern void read_decode_mmu_bcr(void);
4039

4140
extern void arc_cache_init(void);
4241
extern char *arc_cache_mumbojumbo(int cpu_id, char *buf, int len);

arch/arc/kernel/setup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ static void read_arc_build_cfg_regs(void)
186186
/* Read CCM BCRs for boot reporting even if not enabled in Kconfig */
187187
read_decode_ccm_bcr(cpu);
188188

189-
read_decode_mmu_bcr();
190189
read_decode_cache_bcr();
191190

192191
if (is_isa_arcompact()) {
@@ -256,7 +255,7 @@ static void read_arc_build_cfg_regs(void)
256255
cpu->isa.be = IS_ENABLED(CONFIG_CPU_BIG_ENDIAN);
257256

258257
/* there's no direct way to distinguish 750 vs. 770 */
259-
if (unlikely(cpu->core.family < 0x34 || cpu->mmu.ver < 3))
258+
if (unlikely(cpu->core.family < 0x34))
260259
cpu->name = "ARC750";
261260
} else {
262261
cpu->isa = isa;
@@ -463,6 +462,7 @@ void setup_processor(void)
463462
arc_init_IRQ();
464463

465464
pr_info("%s", arc_cpu_mumbojumbo(cpu_id, str, sizeof(str)));
465+
pr_info("%s", arc_mmu_mumbojumbo(cpu_id, str, sizeof(str)));
466466

467467
arc_mmu_init();
468468
arc_cache_init();

arch/arc/mm/tlb.c

Lines changed: 35 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
/* A copy of the ASID from the PID reg is kept in asid_cache */
1919
DEFINE_PER_CPU(unsigned int, asid_cache) = MM_CTXT_FIRST_CYCLE;
2020

21-
static int __read_mostly pae_exists;
21+
static struct cpuinfo_arc_mmu {
22+
unsigned int ver, pg_sz_k, s_pg_sz_m, pae, sets, ways;
23+
} mmuinfo;
2224

2325
/*
2426
* Utility Routine to erase a J-TLB entry
@@ -131,7 +133,7 @@ static void tlb_entry_insert(unsigned int pd0, phys_addr_t pd1)
131133

132134
noinline void local_flush_tlb_all(void)
133135
{
134-
struct cpuinfo_arc_mmu *mmu = &cpuinfo_arc700[smp_processor_id()].mmu;
136+
struct cpuinfo_arc_mmu *mmu = &mmuinfo;
135137
unsigned long flags;
136138
unsigned int entry;
137139
int num_tlb = mmu->sets * mmu->ways;
@@ -560,89 +562,64 @@ void local_flush_pmd_tlb_range(struct vm_area_struct *vma, unsigned long start,
560562
* the cpuinfo structure for later use.
561563
* No Validation is done here, simply read/convert the BCRs
562564
*/
563-
void read_decode_mmu_bcr(void)
565+
char *arc_mmu_mumbojumbo(int c, char *buf, int len)
564566
{
565-
struct cpuinfo_arc_mmu *mmu = &cpuinfo_arc700[smp_processor_id()].mmu;
566-
unsigned int tmp;
567-
struct bcr_mmu_3 {
568-
#ifdef CONFIG_CPU_BIG_ENDIAN
569-
unsigned int ver:8, ways:4, sets:4, res:3, sasid:1, pg_sz:4,
570-
u_itlb:4, u_dtlb:4;
571-
#else
572-
unsigned int u_dtlb:4, u_itlb:4, pg_sz:4, sasid:1, res:3, sets:4,
573-
ways:4, ver:8;
574-
#endif
575-
} *mmu3;
576-
577-
struct bcr_mmu_4 {
578-
#ifdef CONFIG_CPU_BIG_ENDIAN
579-
unsigned int ver:8, sasid:1, sz1:4, sz0:4, res:2, pae:1,
580-
n_ways:2, n_entry:2, n_super:2, u_itlb:3, u_dtlb:3;
581-
#else
582-
/* DTLB ITLB JES JE JA */
583-
unsigned int u_dtlb:3, u_itlb:3, n_super:2, n_entry:2, n_ways:2,
584-
pae:1, res:2, sz0:4, sz1:4, sasid:1, ver:8;
585-
#endif
586-
} *mmu4;
567+
struct cpuinfo_arc_mmu *mmu = &mmuinfo;
568+
unsigned int bcr, u_dtlb, u_itlb, sasid;
569+
struct bcr_mmu_3 *mmu3;
570+
struct bcr_mmu_4 *mmu4;
571+
char super_pg[64] = "";
572+
int n = 0;
587573

588-
tmp = read_aux_reg(ARC_REG_MMU_BCR);
589-
mmu->ver = (tmp >> 24);
574+
bcr = read_aux_reg(ARC_REG_MMU_BCR);
575+
mmu->ver = (bcr >> 24);
590576

591577
if (is_isa_arcompact() && mmu->ver == 3) {
592-
mmu3 = (struct bcr_mmu_3 *)&tmp;
578+
mmu3 = (struct bcr_mmu_3 *)&bcr;
593579
mmu->pg_sz_k = 1 << (mmu3->pg_sz - 1);
594580
mmu->sets = 1 << mmu3->sets;
595581
mmu->ways = 1 << mmu3->ways;
596-
mmu->u_dtlb = mmu3->u_dtlb;
597-
mmu->u_itlb = mmu3->u_itlb;
598-
mmu->sasid = mmu3->sasid;
582+
u_dtlb = mmu3->u_dtlb;
583+
u_itlb = mmu3->u_itlb;
584+
sasid = mmu3->sasid;
599585
} else {
600-
mmu4 = (struct bcr_mmu_4 *)&tmp;
586+
mmu4 = (struct bcr_mmu_4 *)&bcr;
601587
mmu->pg_sz_k = 1 << (mmu4->sz0 - 1);
602588
mmu->s_pg_sz_m = 1 << (mmu4->sz1 - 11);
603589
mmu->sets = 64 << mmu4->n_entry;
604590
mmu->ways = mmu4->n_ways * 2;
605-
mmu->u_dtlb = mmu4->u_dtlb * 4;
606-
mmu->u_itlb = mmu4->u_itlb * 4;
607-
mmu->sasid = mmu4->sasid;
608-
pae_exists = mmu->pae = mmu4->pae;
591+
u_dtlb = mmu4->u_dtlb * 4;
592+
u_itlb = mmu4->u_itlb * 4;
593+
sasid = mmu4->sasid;
594+
mmu->pae = mmu4->pae;
609595
}
610-
}
611596

612-
char *arc_mmu_mumbojumbo(int cpu_id, char *buf, int len)
613-
{
614-
int n = 0;
615-
struct cpuinfo_arc_mmu *p_mmu = &cpuinfo_arc700[cpu_id].mmu;
616-
char super_pg[64] = "";
617-
618-
if (p_mmu->s_pg_sz_m)
619-
scnprintf(super_pg, 64, "%dM Super Page %s",
620-
p_mmu->s_pg_sz_m,
621-
IS_USED_CFG(CONFIG_TRANSPARENT_HUGEPAGE));
597+
if (mmu->s_pg_sz_m)
598+
scnprintf(super_pg, 64, "/%dM%s",
599+
mmu->s_pg_sz_m,
600+
IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) ? " (THP enabled)":"");
622601

623602
n += scnprintf(buf + n, len - n,
624-
"MMU [v%x]\t: %dk PAGE, %s, swalk %d lvl, JTLB %d (%dx%d), uDTLB %d, uITLB %d%s%s\n",
625-
p_mmu->ver, p_mmu->pg_sz_k, super_pg, CONFIG_PGTABLE_LEVELS,
626-
p_mmu->sets * p_mmu->ways, p_mmu->sets, p_mmu->ways,
627-
p_mmu->u_dtlb, p_mmu->u_itlb,
628-
IS_AVAIL2(p_mmu->pae, ", PAE40 ", CONFIG_ARC_HAS_PAE40));
603+
"MMU [v%x]\t: %dk%s, swalk %d lvl, JTLB %dx%d, uDTLB %d, uITLB %d%s%s%s\n",
604+
mmu->ver, mmu->pg_sz_k, super_pg, CONFIG_PGTABLE_LEVELS,
605+
mmu->sets, mmu->ways,
606+
u_dtlb, u_itlb,
607+
IS_AVAIL1(sasid, ", SASID"),
608+
IS_AVAIL2(mmu->pae, ", PAE40 ", CONFIG_ARC_HAS_PAE40));
629609

630610
return buf;
631611
}
632612

633613
int pae40_exist_but_not_enab(void)
634614
{
635-
return pae_exists && !is_pae40_enabled();
615+
return mmuinfo.pae && !is_pae40_enabled();
636616
}
637617

638618
void arc_mmu_init(void)
639619
{
640-
struct cpuinfo_arc_mmu *mmu = &cpuinfo_arc700[smp_processor_id()].mmu;
641-
char str[256];
620+
struct cpuinfo_arc_mmu *mmu = &mmuinfo;
642621
int compat = 0;
643622

644-
pr_info("%s", arc_mmu_mumbojumbo(0, str, sizeof(str)));
645-
646623
/*
647624
* Can't be done in processor.h due to header include dependencies
648625
*/
@@ -719,7 +696,7 @@ volatile int dup_pd_silent; /* Be silent abt it or complain (default) */
719696
void do_tlb_overlap_fault(unsigned long cause, unsigned long address,
720697
struct pt_regs *regs)
721698
{
722-
struct cpuinfo_arc_mmu *mmu = &cpuinfo_arc700[smp_processor_id()].mmu;
699+
struct cpuinfo_arc_mmu *mmu = &mmuinfo;
723700
unsigned long flags;
724701
int set, n_ways = mmu->ways;
725702

0 commit comments

Comments
 (0)