Merge tag 'arc-4.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc

Pull ARC updates from Vineet Gupta:

- more changes for HS48 cores: supporting MMUv5, detecting new
micro-arch gizmos

- axs10x platform wiring up reset driver merged in this cycle

- ARC perf driver optimizations

* tag 'arc-4.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc:
ARC: perf: avoid vmalloc backed mmap
ARCv2: perf: optimize given that num counters <= 32
ARCv2: perf: tweak overflow interrupt
ARC: [plat-axs10x] DTS: Add reset controller node to manage ethernet reset
ARCv2: boot log: updates for HS48: dual-issue, ECC, Loop Buffer
ARCv2: Accomodate HS48 MMUv5 by relaxing MMU ver checking
ARC: [plat-axs10x] auto-select AXS101 or AXS103 given the ISA config

+135 -55
+1 -1
arch/arc/Kconfig
··· 39 39 select OF 40 40 select OF_EARLY_FLATTREE 41 41 select OF_RESERVED_MEM 42 - select PERF_USE_VMALLOC 42 + select PERF_USE_VMALLOC if ARC_CACHE_VIPT_ALIASING 43 43 select HAVE_DEBUG_STACKOVERFLOW 44 44 select HAVE_GENERIC_DMA_COHERENT 45 45 select HAVE_KERNEL_GZIP
+8
arch/arc/boot/dts/axs10x_mb.dtsi
··· 16 16 ranges = <0x00000000 0x0 0xe0000000 0x10000000>; 17 17 interrupt-parent = <&mb_intc>; 18 18 19 + creg_rst: reset-controller@11220 { 20 + compatible = "snps,axs10x-reset"; 21 + #reset-cells = <1>; 22 + reg = <0x11220 0x4>; 23 + }; 24 + 19 25 i2sclk: i2sclk@100a0 { 20 26 compatible = "snps,axs10x-i2s-pll-clock"; 21 27 reg = <0x100a0 0x10>; ··· 79 73 clocks = <&apbclk>; 80 74 clock-names = "stmmaceth"; 81 75 max-speed = <100>; 76 + resets = <&creg_rst 5>; 77 + reset-names = "stmmaceth"; 82 78 }; 83 79 84 80 ehci@0x40000 {
+32 -1
arch/arc/include/asm/arcregs.h
··· 11 11 12 12 /* Build Configuration Registers */ 13 13 #define ARC_REG_AUX_DCCM 0x18 /* DCCM Base Addr ARCv2 */ 14 + #define ARC_REG_ERP_CTRL 0x3F /* ARCv2 Error protection control */ 14 15 #define ARC_REG_DCCM_BASE_BUILD 0x61 /* DCCM Base Addr ARCompact */ 15 16 #define ARC_REG_CRC_BCR 0x62 16 17 #define ARC_REG_VECBASE_BCR 0x68 17 18 #define ARC_REG_PERIBASE_BCR 0x69 18 19 #define ARC_REG_FP_BCR 0x6B /* ARCompact: Single-Precision FPU */ 19 20 #define ARC_REG_DPFP_BCR 0x6C /* ARCompact: Dbl Precision FPU */ 21 + #define ARC_REG_ERP_BUILD 0xc7 /* ARCv2 Error protection Build: ECC/Parity */ 20 22 #define ARC_REG_FP_V2_BCR 0xc8 /* ARCv2 FPU */ 21 23 #define ARC_REG_SLC_BCR 0xce 22 24 #define ARC_REG_DCCM_BUILD 0x74 /* DCCM size (common) */ ··· 34 32 #define ARC_REG_D_UNCACH_BCR 0x6A 35 33 #define ARC_REG_BPU_BCR 0xc0 36 34 #define ARC_REG_ISA_CFG_BCR 0xc1 35 + #define ARC_REG_LPB_BUILD 0xE9 /* ARCv2 Loop Buffer Build */ 37 36 #define ARC_REG_RTT_BCR 0xF2 38 37 #define ARC_REG_IRQ_BCR 0xF3 38 + #define ARC_REG_MICRO_ARCH_BCR 0xF9 /* ARCv2 Product revision */ 39 39 #define ARC_REG_SMART_BCR 0xFF 40 40 #define ARC_REG_CLUSTER_BCR 0xcf 41 41 #define ARC_REG_AUX_ICCM 0x208 /* ICCM Base Addr (ARCv2) */ 42 + #define ARC_REG_LPB_CTRL 0x488 /* ARCv2 Loop Buffer control */ 42 43 43 44 /* Common for ARCompact and ARCv2 status register */ 44 45 #define ARC_REG_STATUS32 0x0A ··· 234 229 #endif 235 230 }; 236 231 232 + /* Error Protection Build: ECC/Parity */ 233 + struct bcr_erp { 234 + #ifdef CONFIG_CPU_BIG_ENDIAN 235 + unsigned int pad3:5, mmu:3, pad2:4, ic:3, dc:3, pad1:6, ver:8; 236 + #else 237 + unsigned int ver:8, pad1:6, dc:3, ic:3, pad2:4, mmu:3, pad3:5; 238 + #endif 239 + }; 240 + 241 + /* Error Protection Control */ 242 + struct ctl_erp { 243 + #ifdef CONFIG_CPU_BIG_ENDIAN 244 + unsigned int pad2:27, mpd:1, pad1:2, dpd:1, dpi:1; 245 + #else 246 + unsigned int dpi:1, dpd:1, pad1:2, mpd:1, pad2:27; 247 + #endif 248 + }; 249 + 250 + struct bcr_lpb { 251 + #ifdef CONFIG_CPU_BIG_ENDIAN 252 + unsigned int pad:16, entries:8, ver:8; 253 + #else 254 + unsigned int ver:8, entries:8, pad:16; 255 + #endif 256 + }; 257 + 237 258 struct bcr_generic { 238 259 #ifdef CONFIG_CPU_BIG_ENDIAN 239 260 unsigned int info:24, ver:8; ··· 301 270 struct cpuinfo_arc_ccm iccm, dccm; 302 271 struct { 303 272 unsigned int swap:1, norm:1, minmax:1, barrel:1, crc:1, swape:1, pad1:2, 304 - fpu_sp:1, fpu_dp:1, dual_iss_enb:1, dual_iss_exist:1, pad2:4, 273 + fpu_sp:1, fpu_dp:1, dual:1, dual_enb:1, pad2:4, 305 274 debug:1, ap:1, smart:1, rtt:1, pad3:4, 306 275 timer0:1, timer1:1, rtc:1, gfrc:1, pad4:4; 307 276 } extn;
+20 -18
arch/arc/kernel/perf_event.c
··· 336 336 struct hw_perf_event *hwc = &event->hw; 337 337 int idx = hwc->idx; 338 338 339 - if (__test_and_set_bit(idx, pmu_cpu->used_mask)) { 340 - idx = find_first_zero_bit(pmu_cpu->used_mask, 341 - arc_pmu->n_counters); 342 - if (idx == arc_pmu->n_counters) 343 - return -EAGAIN; 339 + idx = ffz(pmu_cpu->used_mask[0]); 340 + if (idx == arc_pmu->n_counters) 341 + return -EAGAIN; 344 342 345 - __set_bit(idx, pmu_cpu->used_mask); 346 - hwc->idx = idx; 347 - } 343 + __set_bit(idx, pmu_cpu->used_mask); 344 + hwc->idx = idx; 348 345 349 346 write_aux_reg(ARC_REG_PCT_INDEX, idx); 350 347 ··· 374 377 struct perf_sample_data data; 375 378 struct arc_pmu_cpu *pmu_cpu = this_cpu_ptr(&arc_pmu_cpu); 376 379 struct pt_regs *regs; 377 - int active_ints; 380 + unsigned int active_ints; 378 381 int idx; 379 382 380 383 arc_pmu_disable(&arc_pmu->pmu); 381 384 382 385 active_ints = read_aux_reg(ARC_REG_PCT_INT_ACT); 386 + if (!active_ints) 387 + goto done; 383 388 384 389 regs = get_irq_regs(); 385 390 386 - for (idx = 0; idx < arc_pmu->n_counters; idx++) { 387 - struct perf_event *event = pmu_cpu->act_counter[idx]; 391 + do { 392 + struct perf_event *event; 388 393 struct hw_perf_event *hwc; 389 394 390 - if (!(active_ints & (1 << idx))) 391 - continue; 395 + idx = __ffs(active_ints); 392 396 393 397 /* Reset interrupt flag by writing of 1 */ 394 398 write_aux_reg(ARC_REG_PCT_INT_ACT, 1 << idx); ··· 402 404 write_aux_reg(ARC_REG_PCT_INT_CTRL, 403 405 read_aux_reg(ARC_REG_PCT_INT_CTRL) | (1 << idx)); 404 406 407 + event = pmu_cpu->act_counter[idx]; 405 408 hwc = &event->hw; 406 409 407 410 WARN_ON_ONCE(hwc->idx != idx); 408 411 409 412 arc_perf_event_update(event, &event->hw, event->hw.idx); 410 413 perf_sample_data_init(&data, 0, hwc->last_period); 411 - if (!arc_pmu_event_set_period(event)) 412 - continue; 414 + if (arc_pmu_event_set_period(event)) { 415 + if (perf_event_overflow(event, &data, regs)) 416 + arc_pmu_stop(event, 0); 417 + } 413 418 414 - if (perf_event_overflow(event, &data, regs)) 415 - arc_pmu_stop(event, 0); 416 - } 419 + active_ints &= ~(1U << idx); 420 + } while (active_ints); 417 421 422 + done: 418 423 arc_pmu_enable(&arc_pmu->pmu); 419 424 420 425 return IRQ_HANDLED; ··· 462 461 pr_err("This core does not have performance counters!\n"); 463 462 return -ENODEV; 464 463 } 464 + BUILD_BUG_ON(ARC_PERF_MAX_COUNTERS > 32); 465 465 BUG_ON(pct_bcr.c > ARC_PERF_MAX_COUNTERS); 466 466 467 467 READ_BCR(ARC_REG_CC_BUILD, cc_bcr);
+39 -4
arch/arc/kernel/setup.c
··· 199 199 unsigned int exec_ctrl; 200 200 201 201 READ_BCR(AUX_EXEC_CTRL, exec_ctrl); 202 - cpu->extn.dual_iss_exist = 1; 203 - cpu->extn.dual_iss_enb = exec_ctrl & 1; 202 + cpu->extn.dual_enb = exec_ctrl & 1; 203 + 204 + /* dual issue always present for this core */ 205 + cpu->extn.dual = 1; 204 206 } 205 207 } 206 208 ··· 255 253 cpu_id, cpu->name, cpu->details, 256 254 is_isa_arcompact() ? "ARCompact" : "ARCv2", 257 255 IS_AVAIL1(cpu->isa.be, "[Big-Endian]"), 258 - IS_AVAIL3(cpu->extn.dual_iss_exist, cpu->extn.dual_iss_enb, " Dual-Issue")); 256 + IS_AVAIL3(cpu->extn.dual, cpu->extn.dual_enb, " Dual-Issue ")); 259 257 260 258 n += scnprintf(buf + n, len - n, "Timers\t\t: %s%s%s%s%s%s\nISA Extn\t: ", 261 259 IS_AVAIL1(cpu->extn.timer0, "Timer0 "), ··· 295 293 296 294 if (cpu->bpu.ver) 297 295 n += scnprintf(buf + n, len - n, 298 - "BPU\t\t: %s%s match, cache:%d, Predict Table:%d\n", 296 + "BPU\t\t: %s%s match, cache:%d, Predict Table:%d", 299 297 IS_AVAIL1(cpu->bpu.full, "full"), 300 298 IS_AVAIL1(!cpu->bpu.full, "partial"), 301 299 cpu->bpu.num_cache, cpu->bpu.num_pred); 302 300 301 + if (is_isa_arcv2()) { 302 + struct bcr_lpb lpb; 303 + 304 + READ_BCR(ARC_REG_LPB_BUILD, lpb); 305 + if (lpb.ver) { 306 + unsigned int ctl; 307 + ctl = read_aux_reg(ARC_REG_LPB_CTRL); 308 + 309 + n += scnprintf(buf + n, len - n, " Loop Buffer:%d %s", 310 + lpb.entries, 311 + IS_DISABLED_RUN(!ctl)); 312 + } 313 + } 314 + 315 + n += scnprintf(buf + n, len - n, "\n"); 303 316 return buf; 304 317 } 305 318 ··· 342 325 n += scnprintf(buf + n, len - n, "Extn [CCM]\t: DCCM @ %x, %d KB / ICCM: @ %x, %d KB\n", 343 326 cpu->dccm.base_addr, TO_KB(cpu->dccm.sz), 344 327 cpu->iccm.base_addr, TO_KB(cpu->iccm.sz)); 328 + 329 + if (is_isa_arcv2()) { 330 + 331 + /* Error Protection: ECC/Parity */ 332 + struct bcr_erp erp; 333 + READ_BCR(ARC_REG_ERP_BUILD, erp); 334 + 335 + if (erp.ver) { 336 + struct ctl_erp ctl; 337 + READ_BCR(ARC_REG_ERP_CTRL, ctl); 338 + 339 + /* inverted bits: 0 means enabled */ 340 + n += scnprintf(buf + n, len - n, "Extn [ECC]\t: %s%s%s%s%s%s\n", 341 + IS_AVAIL3(erp.ic, !ctl.dpi, "IC "), 342 + IS_AVAIL3(erp.dc, !ctl.dpd, "DC "), 343 + IS_AVAIL3(erp.mmu, !ctl.mpd, "MMU ")); 344 + } 345 + } 345 346 346 347 n += scnprintf(buf + n, len - n, "OS ABI [v%d]\t: %s\n", 347 348 EF_ARC_OSABI_CURRENT >> 8,
+33 -24
arch/arc/mm/tlb.c
··· 762 762 tmp = read_aux_reg(ARC_REG_MMU_BCR); 763 763 mmu->ver = (tmp >> 24); 764 764 765 - if (mmu->ver <= 2) { 766 - mmu2 = (struct bcr_mmu_1_2 *)&tmp; 767 - mmu->pg_sz_k = TO_KB(0x2000); 768 - mmu->sets = 1 << mmu2->sets; 769 - mmu->ways = 1 << mmu2->ways; 770 - mmu->u_dtlb = mmu2->u_dtlb; 771 - mmu->u_itlb = mmu2->u_itlb; 772 - } else if (mmu->ver == 3) { 773 - mmu3 = (struct bcr_mmu_3 *)&tmp; 774 - mmu->pg_sz_k = 1 << (mmu3->pg_sz - 1); 775 - mmu->sets = 1 << mmu3->sets; 776 - mmu->ways = 1 << mmu3->ways; 777 - mmu->u_dtlb = mmu3->u_dtlb; 778 - mmu->u_itlb = mmu3->u_itlb; 779 - mmu->sasid = mmu3->sasid; 765 + if (is_isa_arcompact()) { 766 + if (mmu->ver <= 2) { 767 + mmu2 = (struct bcr_mmu_1_2 *)&tmp; 768 + mmu->pg_sz_k = TO_KB(0x2000); 769 + mmu->sets = 1 << mmu2->sets; 770 + mmu->ways = 1 << mmu2->ways; 771 + mmu->u_dtlb = mmu2->u_dtlb; 772 + mmu->u_itlb = mmu2->u_itlb; 773 + } else { 774 + mmu3 = (struct bcr_mmu_3 *)&tmp; 775 + mmu->pg_sz_k = 1 << (mmu3->pg_sz - 1); 776 + mmu->sets = 1 << mmu3->sets; 777 + mmu->ways = 1 << mmu3->ways; 778 + mmu->u_dtlb = mmu3->u_dtlb; 779 + mmu->u_itlb = mmu3->u_itlb; 780 + mmu->sasid = mmu3->sasid; 781 + } 780 782 } else { 781 783 mmu4 = (struct bcr_mmu_4 *)&tmp; 782 784 mmu->pg_sz_k = 1 << (mmu4->sz0 - 1); ··· 820 818 821 819 void arc_mmu_init(void) 822 820 { 823 - char str[256]; 824 821 struct cpuinfo_arc_mmu *mmu = &cpuinfo_arc700[smp_processor_id()].mmu; 822 + char str[256]; 823 + int compat = 0; 825 824 826 825 pr_info("%s", arc_mmu_mumbojumbo(0, str, sizeof(str))); 827 826 ··· 837 834 */ 838 835 BUILD_BUG_ON(!IS_ALIGNED(STACK_TOP, PMD_SIZE)); 839 836 840 - /* For efficiency sake, kernel is compile time built for a MMU ver 841 - * This must match the hardware it is running on. 842 - * Linux built for MMU V2, if run on MMU V1 will break down because V1 843 - * hardware doesn't understand cmds such as WriteNI, or IVUTLB 844 - * On the other hand, Linux built for V1 if run on MMU V2 will do 845 - * un-needed workarounds to prevent memcpy thrashing. 846 - * Similarly MMU V3 has new features which won't work on older MMU 837 + /* 838 + * Ensure that MMU features assumed by kernel exist in hardware. 839 + * For older ARC700 cpus, it has to be exact match, since the MMU 840 + * revisions were not backwards compatible (MMUv3 TLB layout changed 841 + * so even if kernel for v2 didn't use any new cmds of v3, it would 842 + * still not work. 843 + * For HS cpus, MMUv4 was baseline and v5 is backwards compatible 844 + * (will run older software). 847 845 */ 848 - if (mmu->ver != CONFIG_ARC_MMU_VER) { 846 + if (is_isa_arcompact() && mmu->ver == CONFIG_ARC_MMU_VER) 847 + compat = 1; 848 + else if (is_isa_arcv2() && mmu->ver >= CONFIG_ARC_MMU_VER) 849 + compat = 1; 850 + 851 + if (!compat) { 849 852 panic("MMU ver %d doesn't match kernel built for %d...\n", 850 853 mmu->ver, CONFIG_ARC_MMU_VER); 851 854 }
+2
arch/arc/plat-axs10x/Kconfig
··· 14 14 select MIGHT_HAVE_PCI 15 15 select GENERIC_IRQ_CHIP 16 16 select GPIOLIB 17 + select AXS101 if ISA_ARCOMPACT 18 + select AXS103 if ISA_ARCV2 17 19 help 18 20 Support for the ARC AXS10x Software Development Platforms. 19 21
-7
arch/arc/plat-axs10x/axs10x.c
··· 111 111 112 112 axs10x_enable_gpio_intc_wire(); 113 113 114 - /* 115 - * Reset ethernet IP core. 116 - * TODO: get rid of this quirk after axs10x reset driver (or simple 117 - * reset driver) will be available in upstream. 118 - */ 119 - iowrite32((1 << 5), (void __iomem *) CREG_MB_SW_RESET); 120 - 121 114 scnprintf(mb, 32, "MainBoard v%d", mb_rev); 122 115 axs10x_print_board_ver(CREG_MB_VER, mb); 123 116 }