|
18 | 18 | /* A copy of the ASID from the PID reg is kept in asid_cache */
|
19 | 19 | DEFINE_PER_CPU(unsigned int, asid_cache) = MM_CTXT_FIRST_CYCLE;
|
20 | 20 |
|
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; |
22 | 24 |
|
23 | 25 | /*
|
24 | 26 | * Utility Routine to erase a J-TLB entry
|
@@ -131,7 +133,7 @@ static void tlb_entry_insert(unsigned int pd0, phys_addr_t pd1)
|
131 | 133 |
|
132 | 134 | noinline void local_flush_tlb_all(void)
|
133 | 135 | {
|
134 |
| - struct cpuinfo_arc_mmu *mmu = &cpuinfo_arc700[smp_processor_id()].mmu; |
| 136 | + struct cpuinfo_arc_mmu *mmu = &mmuinfo; |
135 | 137 | unsigned long flags;
|
136 | 138 | unsigned int entry;
|
137 | 139 | 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,
|
560 | 562 | * the cpuinfo structure for later use.
|
561 | 563 | * No Validation is done here, simply read/convert the BCRs
|
562 | 564 | */
|
563 |
| -void read_decode_mmu_bcr(void) |
| 565 | +char *arc_mmu_mumbojumbo(int c, char *buf, int len) |
564 | 566 | {
|
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; |
587 | 573 |
|
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); |
590 | 576 |
|
591 | 577 | if (is_isa_arcompact() && mmu->ver == 3) {
|
592 |
| - mmu3 = (struct bcr_mmu_3 *)&tmp; |
| 578 | + mmu3 = (struct bcr_mmu_3 *)&bcr; |
593 | 579 | mmu->pg_sz_k = 1 << (mmu3->pg_sz - 1);
|
594 | 580 | mmu->sets = 1 << mmu3->sets;
|
595 | 581 | 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; |
599 | 585 | } else {
|
600 |
| - mmu4 = (struct bcr_mmu_4 *)&tmp; |
| 586 | + mmu4 = (struct bcr_mmu_4 *)&bcr; |
601 | 587 | mmu->pg_sz_k = 1 << (mmu4->sz0 - 1);
|
602 | 588 | mmu->s_pg_sz_m = 1 << (mmu4->sz1 - 11);
|
603 | 589 | mmu->sets = 64 << mmu4->n_entry;
|
604 | 590 | 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; |
609 | 595 | }
|
610 |
| -} |
611 | 596 |
|
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)":""); |
622 | 601 |
|
623 | 602 | 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)); |
629 | 609 |
|
630 | 610 | return buf;
|
631 | 611 | }
|
632 | 612 |
|
633 | 613 | int pae40_exist_but_not_enab(void)
|
634 | 614 | {
|
635 |
| - return pae_exists && !is_pae40_enabled(); |
| 615 | + return mmuinfo.pae && !is_pae40_enabled(); |
636 | 616 | }
|
637 | 617 |
|
638 | 618 | void arc_mmu_init(void)
|
639 | 619 | {
|
640 |
| - struct cpuinfo_arc_mmu *mmu = &cpuinfo_arc700[smp_processor_id()].mmu; |
641 |
| - char str[256]; |
| 620 | + struct cpuinfo_arc_mmu *mmu = &mmuinfo; |
642 | 621 | int compat = 0;
|
643 | 622 |
|
644 |
| - pr_info("%s", arc_mmu_mumbojumbo(0, str, sizeof(str))); |
645 |
| - |
646 | 623 | /*
|
647 | 624 | * Can't be done in processor.h due to header include dependencies
|
648 | 625 | */
|
@@ -719,7 +696,7 @@ volatile int dup_pd_silent; /* Be silent abt it or complain (default) */
|
719 | 696 | void do_tlb_overlap_fault(unsigned long cause, unsigned long address,
|
720 | 697 | struct pt_regs *regs)
|
721 | 698 | {
|
722 |
| - struct cpuinfo_arc_mmu *mmu = &cpuinfo_arc700[smp_processor_id()].mmu; |
| 699 | + struct cpuinfo_arc_mmu *mmu = &mmuinfo; |
723 | 700 | unsigned long flags;
|
724 | 701 | int set, n_ways = mmu->ways;
|
725 | 702 |
|
|
0 commit comments