Skip to content

Commit ca122fe

Browse files
committed
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
2 parents 5e2fda4 + 8238573 commit ca122fe

File tree

8 files changed

+136
-56
lines changed

8 files changed

+136
-56
lines changed

arch/arc/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ config ARC
3939
select OF
4040
select OF_EARLY_FLATTREE
4141
select OF_RESERVED_MEM
42-
select PERF_USE_VMALLOC
42+
select PERF_USE_VMALLOC if ARC_CACHE_VIPT_ALIASING
4343
select HAVE_DEBUG_STACKOVERFLOW
4444
select HAVE_GENERIC_DMA_COHERENT
4545
select HAVE_KERNEL_GZIP

arch/arc/boot/dts/axs10x_mb.dtsi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
ranges = <0x00000000 0x0 0xe0000000 0x10000000>;
1717
interrupt-parent = <&mb_intc>;
1818

19+
creg_rst: reset-controller@11220 {
20+
compatible = "snps,axs10x-reset";
21+
#reset-cells = <1>;
22+
reg = <0x11220 0x4>;
23+
};
24+
1925
i2sclk: i2sclk@100a0 {
2026
compatible = "snps,axs10x-i2s-pll-clock";
2127
reg = <0x100a0 0x10>;
@@ -73,6 +79,8 @@
7379
clocks = <&apbclk>;
7480
clock-names = "stmmaceth";
7581
max-speed = <100>;
82+
resets = <&creg_rst 5>;
83+
reset-names = "stmmaceth";
7684
};
7785

7886
ehci@0x40000 {

arch/arc/include/asm/arcregs.h

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111

1212
/* Build Configuration Registers */
1313
#define ARC_REG_AUX_DCCM 0x18 /* DCCM Base Addr ARCv2 */
14+
#define ARC_REG_ERP_CTRL 0x3F /* ARCv2 Error protection control */
1415
#define ARC_REG_DCCM_BASE_BUILD 0x61 /* DCCM Base Addr ARCompact */
1516
#define ARC_REG_CRC_BCR 0x62
1617
#define ARC_REG_VECBASE_BCR 0x68
1718
#define ARC_REG_PERIBASE_BCR 0x69
1819
#define ARC_REG_FP_BCR 0x6B /* ARCompact: Single-Precision FPU */
1920
#define ARC_REG_DPFP_BCR 0x6C /* ARCompact: Dbl Precision FPU */
21+
#define ARC_REG_ERP_BUILD 0xc7 /* ARCv2 Error protection Build: ECC/Parity */
2022
#define ARC_REG_FP_V2_BCR 0xc8 /* ARCv2 FPU */
2123
#define ARC_REG_SLC_BCR 0xce
2224
#define ARC_REG_DCCM_BUILD 0x74 /* DCCM size (common) */
@@ -32,11 +34,14 @@
3234
#define ARC_REG_D_UNCACH_BCR 0x6A
3335
#define ARC_REG_BPU_BCR 0xc0
3436
#define ARC_REG_ISA_CFG_BCR 0xc1
37+
#define ARC_REG_LPB_BUILD 0xE9 /* ARCv2 Loop Buffer Build */
3538
#define ARC_REG_RTT_BCR 0xF2
3639
#define ARC_REG_IRQ_BCR 0xF3
40+
#define ARC_REG_MICRO_ARCH_BCR 0xF9 /* ARCv2 Product revision */
3741
#define ARC_REG_SMART_BCR 0xFF
3842
#define ARC_REG_CLUSTER_BCR 0xcf
3943
#define ARC_REG_AUX_ICCM 0x208 /* ICCM Base Addr (ARCv2) */
44+
#define ARC_REG_LPB_CTRL 0x488 /* ARCv2 Loop Buffer control */
4045

4146
/* Common for ARCompact and ARCv2 status register */
4247
#define ARC_REG_STATUS32 0x0A
@@ -229,6 +234,32 @@ struct bcr_bpu_arcv2 {
229234
#endif
230235
};
231236

237+
/* Error Protection Build: ECC/Parity */
238+
struct bcr_erp {
239+
#ifdef CONFIG_CPU_BIG_ENDIAN
240+
unsigned int pad3:5, mmu:3, pad2:4, ic:3, dc:3, pad1:6, ver:8;
241+
#else
242+
unsigned int ver:8, pad1:6, dc:3, ic:3, pad2:4, mmu:3, pad3:5;
243+
#endif
244+
};
245+
246+
/* Error Protection Control */
247+
struct ctl_erp {
248+
#ifdef CONFIG_CPU_BIG_ENDIAN
249+
unsigned int pad2:27, mpd:1, pad1:2, dpd:1, dpi:1;
250+
#else
251+
unsigned int dpi:1, dpd:1, pad1:2, mpd:1, pad2:27;
252+
#endif
253+
};
254+
255+
struct bcr_lpb {
256+
#ifdef CONFIG_CPU_BIG_ENDIAN
257+
unsigned int pad:16, entries:8, ver:8;
258+
#else
259+
unsigned int ver:8, entries:8, pad:16;
260+
#endif
261+
};
262+
232263
struct bcr_generic {
233264
#ifdef CONFIG_CPU_BIG_ENDIAN
234265
unsigned int info:24, ver:8;
@@ -270,7 +301,7 @@ struct cpuinfo_arc {
270301
struct cpuinfo_arc_ccm iccm, dccm;
271302
struct {
272303
unsigned int swap:1, norm:1, minmax:1, barrel:1, crc:1, swape:1, pad1:2,
273-
fpu_sp:1, fpu_dp:1, dual_iss_enb:1, dual_iss_exist:1, pad2:4,
304+
fpu_sp:1, fpu_dp:1, dual:1, dual_enb:1, pad2:4,
274305
debug:1, ap:1, smart:1, rtt:1, pad3:4,
275306
timer0:1, timer1:1, rtc:1, gfrc:1, pad4:4;
276307
} extn;

arch/arc/kernel/perf_event.c

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -336,15 +336,12 @@ static int arc_pmu_add(struct perf_event *event, int flags)
336336
struct hw_perf_event *hwc = &event->hw;
337337
int idx = hwc->idx;
338338

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;
344-
345-
__set_bit(idx, pmu_cpu->used_mask);
346-
hwc->idx = idx;
347-
}
339+
idx = ffz(pmu_cpu->used_mask[0]);
340+
if (idx == arc_pmu->n_counters)
341+
return -EAGAIN;
342+
343+
__set_bit(idx, pmu_cpu->used_mask);
344+
hwc->idx = idx;
348345

349346
write_aux_reg(ARC_REG_PCT_INDEX, idx);
350347

@@ -377,21 +374,22 @@ static irqreturn_t arc_pmu_intr(int irq, void *dev)
377374
struct perf_sample_data data;
378375
struct arc_pmu_cpu *pmu_cpu = this_cpu_ptr(&arc_pmu_cpu);
379376
struct pt_regs *regs;
380-
int active_ints;
377+
unsigned int active_ints;
381378
int idx;
382379

383380
arc_pmu_disable(&arc_pmu->pmu);
384381

385382
active_ints = read_aux_reg(ARC_REG_PCT_INT_ACT);
383+
if (!active_ints)
384+
goto done;
386385

387386
regs = get_irq_regs();
388387

389-
for (idx = 0; idx < arc_pmu->n_counters; idx++) {
390-
struct perf_event *event = pmu_cpu->act_counter[idx];
388+
do {
389+
struct perf_event *event;
391390
struct hw_perf_event *hwc;
392391

393-
if (!(active_ints & (1 << idx)))
394-
continue;
392+
idx = __ffs(active_ints);
395393

396394
/* Reset interrupt flag by writing of 1 */
397395
write_aux_reg(ARC_REG_PCT_INT_ACT, 1 << idx);
@@ -404,19 +402,22 @@ static irqreturn_t arc_pmu_intr(int irq, void *dev)
404402
write_aux_reg(ARC_REG_PCT_INT_CTRL,
405403
read_aux_reg(ARC_REG_PCT_INT_CTRL) | (1 << idx));
406404

405+
event = pmu_cpu->act_counter[idx];
407406
hwc = &event->hw;
408407

409408
WARN_ON_ONCE(hwc->idx != idx);
410409

411410
arc_perf_event_update(event, &event->hw, event->hw.idx);
412411
perf_sample_data_init(&data, 0, hwc->last_period);
413-
if (!arc_pmu_event_set_period(event))
414-
continue;
412+
if (arc_pmu_event_set_period(event)) {
413+
if (perf_event_overflow(event, &data, regs))
414+
arc_pmu_stop(event, 0);
415+
}
415416

416-
if (perf_event_overflow(event, &data, regs))
417-
arc_pmu_stop(event, 0);
418-
}
417+
active_ints &= ~(1U << idx);
418+
} while (active_ints);
419419

420+
done:
420421
arc_pmu_enable(&arc_pmu->pmu);
421422

422423
return IRQ_HANDLED;
@@ -461,6 +462,7 @@ static int arc_pmu_device_probe(struct platform_device *pdev)
461462
pr_err("This core does not have performance counters!\n");
462463
return -ENODEV;
463464
}
465+
BUILD_BUG_ON(ARC_PERF_MAX_COUNTERS > 32);
464466
BUG_ON(pct_bcr.c > ARC_PERF_MAX_COUNTERS);
465467

466468
READ_BCR(ARC_REG_CC_BUILD, cc_bcr);

arch/arc/kernel/setup.c

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,10 @@ static void read_arc_build_cfg_regs(void)
199199
unsigned int exec_ctrl;
200200

201201
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;
204206
}
205207
}
206208

@@ -253,7 +255,7 @@ static char *arc_cpu_mumbojumbo(int cpu_id, char *buf, int len)
253255
cpu_id, cpu->name, cpu->details,
254256
is_isa_arcompact() ? "ARCompact" : "ARCv2",
255257
IS_AVAIL1(cpu->isa.be, "[Big-Endian]"),
256-
IS_AVAIL3(cpu->extn.dual_iss_exist, cpu->extn.dual_iss_enb, " Dual-Issue"));
258+
IS_AVAIL3(cpu->extn.dual, cpu->extn.dual_enb, " Dual-Issue "));
257259

258260
n += scnprintf(buf + n, len - n, "Timers\t\t: %s%s%s%s%s%s\nISA Extn\t: ",
259261
IS_AVAIL1(cpu->extn.timer0, "Timer0 "),
@@ -293,11 +295,26 @@ static char *arc_cpu_mumbojumbo(int cpu_id, char *buf, int len)
293295

294296
if (cpu->bpu.ver)
295297
n += scnprintf(buf + n, len - n,
296-
"BPU\t\t: %s%s match, cache:%d, Predict Table:%d\n",
298+
"BPU\t\t: %s%s match, cache:%d, Predict Table:%d",
297299
IS_AVAIL1(cpu->bpu.full, "full"),
298300
IS_AVAIL1(!cpu->bpu.full, "partial"),
299301
cpu->bpu.num_cache, cpu->bpu.num_pred);
300302

303+
if (is_isa_arcv2()) {
304+
struct bcr_lpb lpb;
305+
306+
READ_BCR(ARC_REG_LPB_BUILD, lpb);
307+
if (lpb.ver) {
308+
unsigned int ctl;
309+
ctl = read_aux_reg(ARC_REG_LPB_CTRL);
310+
311+
n += scnprintf(buf + n, len - n, " Loop Buffer:%d %s",
312+
lpb.entries,
313+
IS_DISABLED_RUN(!ctl));
314+
}
315+
}
316+
317+
n += scnprintf(buf + n, len - n, "\n");
301318
return buf;
302319
}
303320

@@ -326,6 +343,24 @@ static char *arc_extn_mumbojumbo(int cpu_id, char *buf, int len)
326343
cpu->dccm.base_addr, TO_KB(cpu->dccm.sz),
327344
cpu->iccm.base_addr, TO_KB(cpu->iccm.sz));
328345

346+
if (is_isa_arcv2()) {
347+
348+
/* Error Protection: ECC/Parity */
349+
struct bcr_erp erp;
350+
READ_BCR(ARC_REG_ERP_BUILD, erp);
351+
352+
if (erp.ver) {
353+
struct ctl_erp ctl;
354+
READ_BCR(ARC_REG_ERP_CTRL, ctl);
355+
356+
/* inverted bits: 0 means enabled */
357+
n += scnprintf(buf + n, len - n, "Extn [ECC]\t: %s%s%s%s%s%s\n",
358+
IS_AVAIL3(erp.ic, !ctl.dpi, "IC "),
359+
IS_AVAIL3(erp.dc, !ctl.dpd, "DC "),
360+
IS_AVAIL3(erp.mmu, !ctl.mpd, "MMU "));
361+
}
362+
}
363+
329364
n += scnprintf(buf + n, len - n, "OS ABI [v%d]\t: %s\n",
330365
EF_ARC_OSABI_CURRENT >> 8,
331366
EF_ARC_OSABI_CURRENT == EF_ARC_OSABI_V3 ?

arch/arc/mm/tlb.c

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -762,21 +762,23 @@ void read_decode_mmu_bcr(void)
762762
tmp = read_aux_reg(ARC_REG_MMU_BCR);
763763
mmu->ver = (tmp >> 24);
764764

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+
}
780782
} else {
781783
mmu4 = (struct bcr_mmu_4 *)&tmp;
782784
mmu->pg_sz_k = 1 << (mmu4->sz0 - 1);
@@ -818,8 +820,9 @@ int pae40_exist_but_not_enab(void)
818820

819821
void arc_mmu_init(void)
820822
{
821-
char str[256];
822823
struct cpuinfo_arc_mmu *mmu = &cpuinfo_arc700[smp_processor_id()].mmu;
824+
char str[256];
825+
int compat = 0;
823826

824827
pr_info("%s", arc_mmu_mumbojumbo(0, str, sizeof(str)));
825828

@@ -834,15 +837,21 @@ void arc_mmu_init(void)
834837
*/
835838
BUILD_BUG_ON(!IS_ALIGNED(STACK_TOP, PMD_SIZE));
836839

837-
/* For efficiency sake, kernel is compile time built for a MMU ver
838-
* This must match the hardware it is running on.
839-
* Linux built for MMU V2, if run on MMU V1 will break down because V1
840-
* hardware doesn't understand cmds such as WriteNI, or IVUTLB
841-
* On the other hand, Linux built for V1 if run on MMU V2 will do
842-
* un-needed workarounds to prevent memcpy thrashing.
843-
* Similarly MMU V3 has new features which won't work on older MMU
840+
/*
841+
* Ensure that MMU features assumed by kernel exist in hardware.
842+
* For older ARC700 cpus, it has to be exact match, since the MMU
843+
* revisions were not backwards compatible (MMUv3 TLB layout changed
844+
* so even if kernel for v2 didn't use any new cmds of v3, it would
845+
* still not work.
846+
* For HS cpus, MMUv4 was baseline and v5 is backwards compatible
847+
* (will run older software).
844848
*/
845-
if (mmu->ver != CONFIG_ARC_MMU_VER) {
849+
if (is_isa_arcompact() && mmu->ver == CONFIG_ARC_MMU_VER)
850+
compat = 1;
851+
else if (is_isa_arcv2() && mmu->ver >= CONFIG_ARC_MMU_VER)
852+
compat = 1;
853+
854+
if (!compat) {
846855
panic("MMU ver %d doesn't match kernel built for %d...\n",
847856
mmu->ver, CONFIG_ARC_MMU_VER);
848857
}

arch/arc/plat-axs10x/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ menuconfig ARC_PLAT_AXS10X
1414
select MIGHT_HAVE_PCI
1515
select GENERIC_IRQ_CHIP
1616
select GPIOLIB
17+
select AXS101 if ISA_ARCOMPACT
18+
select AXS103 if ISA_ARCV2
1719
help
1820
Support for the ARC AXS10x Software Development Platforms.
1921

arch/arc/plat-axs10x/axs10x.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,6 @@ static void __init axs10x_early_init(void)
111111

112112
axs10x_enable_gpio_intc_wire();
113113

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-
121114
scnprintf(mb, 32, "MainBoard v%d", mb_rev);
122115
axs10x_print_board_ver(CREG_MB_VER, mb);
123116
}

0 commit comments

Comments
 (0)