Skip to content

Commit e835a65

Browse files
committed
Merge tag 'arc-4.5-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc
Pull ARC fixes from Vineet Gupta: "I've been sitting on some of these fixes for a while. - Corner case of returning to delay slot from interrupt - Changing default interrupt prioiry level - Kconfig'ize support for super pages - Other minor fixes" * tag 'arc-4.5-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc: ARC: mm: Introduce explicit super page size support ARCv2: intc: Allow interruption by lowest priority interrupt ARCv2: Check for LL-SC livelock only if LLSC is enabled ARC: shrink cpuinfo by not saving full timer BCR ARCv2: clocksource: Rename GRTC -> GFRC ... ARCv2: STAR 9000950267: Handle return from intr to Delay Slot #2
2 parents 0cbb0b9 + 37eda9d commit e835a65

File tree

11 files changed

+119
-61
lines changed

11 files changed

+119
-61
lines changed

arch/arc/Kconfig

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,19 @@ config ARC_PAGE_SIZE_4K
338338

339339
endchoice
340340

341+
choice
342+
prompt "MMU Super Page Size"
343+
depends on ISA_ARCV2 && TRANSPARENT_HUGEPAGE
344+
default ARC_HUGEPAGE_2M
345+
346+
config ARC_HUGEPAGE_2M
347+
bool "2MB"
348+
349+
config ARC_HUGEPAGE_16M
350+
bool "16MB"
351+
352+
endchoice
353+
341354
if ISA_ARCOMPACT
342355

343356
config ARC_COMPACT_IRQ_LEVELS
@@ -410,7 +423,7 @@ config ARC_HAS_RTC
410423
default n
411424
depends on !SMP
412425

413-
config ARC_HAS_GRTC
426+
config ARC_HAS_GFRC
414427
bool "SMP synchronized 64-bit cycle counter"
415428
default y
416429
depends on SMP
@@ -566,6 +579,12 @@ endmenu
566579
endmenu # "ARC Architecture Configuration"
567580

568581
source "mm/Kconfig"
582+
583+
config FORCE_MAX_ZONEORDER
584+
int "Maximum zone order"
585+
default "12" if ARC_HUGEPAGE_16M
586+
default "11"
587+
569588
source "net/Kconfig"
570589
source "drivers/Kconfig"
571590
source "fs/Kconfig"

arch/arc/configs/vdk_hs38_smp_defconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ CONFIG_ARC_PLAT_AXS10X=y
1616
CONFIG_AXS103=y
1717
CONFIG_ISA_ARCV2=y
1818
CONFIG_SMP=y
19-
# CONFIG_ARC_HAS_GRTC is not set
19+
# CONFIG_ARC_HAS_GFRC is not set
2020
CONFIG_ARC_UBOOT_SUPPORT=y
2121
CONFIG_ARC_BUILTIN_DTB_NAME="vdk_hs38_smp"
2222
CONFIG_PREEMPT=y

arch/arc/include/asm/arcregs.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,14 +349,13 @@ struct cpuinfo_arc {
349349
struct cpuinfo_arc_bpu bpu;
350350
struct bcr_identity core;
351351
struct bcr_isa isa;
352-
struct bcr_timer timers;
353352
unsigned int vec_base;
354353
struct cpuinfo_arc_ccm iccm, dccm;
355354
struct {
356355
unsigned int swap:1, norm:1, minmax:1, barrel:1, crc:1, pad1:3,
357356
fpu_sp:1, fpu_dp:1, pad2:6,
358357
debug:1, ap:1, smart:1, rtt:1, pad3:4,
359-
pad4:8;
358+
timer0:1, timer1:1, rtc:1, gfrc:1, pad4:4;
360359
} extn;
361360
struct bcr_mpy extn_mpy;
362361
struct bcr_extn_xymem extn_xymem;

arch/arc/include/asm/irqflags-arcv2.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@
3030
/* Was Intr taken in User Mode */
3131
#define AUX_IRQ_ACT_BIT_U 31
3232

33-
/* 0 is highest level, but taken by FIRQs, if present in design */
34-
#define ARCV2_IRQ_DEF_PRIO 0
33+
/*
34+
* User space should be interruptable even by lowest prio interrupt
35+
* Safe even if actual interrupt priorities is fewer or even one
36+
*/
37+
#define ARCV2_IRQ_DEF_PRIO 15
3538

3639
/* seed value for status register */
3740
#define ISA_INIT_STATUS_BITS (STATUS_IE_MASK | STATUS_AD_MASK | \

arch/arc/include/asm/mcip.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ struct mcip_cmd {
3939
#define CMD_DEBUG_SET_MASK 0x34
4040
#define CMD_DEBUG_SET_SELECT 0x36
4141

42-
#define CMD_GRTC_READ_LO 0x42
43-
#define CMD_GRTC_READ_HI 0x43
42+
#define CMD_GFRC_READ_LO 0x42
43+
#define CMD_GFRC_READ_HI 0x43
4444

4545
#define CMD_IDU_ENABLE 0x71
4646
#define CMD_IDU_DISABLE 0x72

arch/arc/include/asm/pgtable.h

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -179,37 +179,44 @@
179179
#define __S111 PAGE_U_X_W_R
180180

181181
/****************************************************************
182-
* Page Table Lookup split
182+
* 2 tier (PGD:PTE) software page walker
183183
*
184-
* We implement 2 tier paging and since this is all software, we are free
185-
* to customize the span of a PGD / PTE entry to suit us
186-
*
187-
* 32 bit virtual address
184+
* [31] 32 bit virtual address [0]
188185
* -------------------------------------------------------
189-
* | BITS_FOR_PGD | BITS_FOR_PTE | BITS_IN_PAGE |
186+
* | | <------------ PGDIR_SHIFT ----------> |
187+
* | | |
188+
* | BITS_FOR_PGD | BITS_FOR_PTE | <-- PAGE_SHIFT --> |
190189
* -------------------------------------------------------
191190
* | | |
192191
* | | --> off in page frame
193-
* | |
194192
* | ---> index into Page Table
195-
* |
196193
* ----> index into Page Directory
194+
*
195+
* In a single page size configuration, only PAGE_SHIFT is fixed
196+
* So both PGD and PTE sizing can be tweaked
197+
* e.g. 8K page (PAGE_SHIFT 13) can have
198+
* - PGDIR_SHIFT 21 -> 11:8:13 address split
199+
* - PGDIR_SHIFT 24 -> 8:11:13 address split
200+
*
201+
* If Super Page is configured, PGDIR_SHIFT becomes fixed too,
202+
* so the sizing flexibility is gone.
197203
*/
198204

199-
#define BITS_IN_PAGE PAGE_SHIFT
200-
201-
/* Optimal Sizing of Pg Tbl - based on MMU page size */
202-
#if defined(CONFIG_ARC_PAGE_SIZE_8K)
203-
#define BITS_FOR_PTE 8 /* 11:8:13 */
204-
#elif defined(CONFIG_ARC_PAGE_SIZE_16K)
205-
#define BITS_FOR_PTE 8 /* 10:8:14 */
206-
#elif defined(CONFIG_ARC_PAGE_SIZE_4K)
207-
#define BITS_FOR_PTE 9 /* 11:9:12 */
205+
#if defined(CONFIG_ARC_HUGEPAGE_16M)
206+
#define PGDIR_SHIFT 24
207+
#elif defined(CONFIG_ARC_HUGEPAGE_2M)
208+
#define PGDIR_SHIFT 21
209+
#else
210+
/*
211+
* Only Normal page support so "hackable" (see comment above)
212+
* Default value provides 11:8:13 (8K), 11:9:12 (4K)
213+
*/
214+
#define PGDIR_SHIFT 21
208215
#endif
209216

210-
#define BITS_FOR_PGD (32 - BITS_FOR_PTE - BITS_IN_PAGE)
217+
#define BITS_FOR_PTE (PGDIR_SHIFT - PAGE_SHIFT)
218+
#define BITS_FOR_PGD (32 - PGDIR_SHIFT)
211219

212-
#define PGDIR_SHIFT (32 - BITS_FOR_PGD)
213220
#define PGDIR_SIZE (1UL << PGDIR_SHIFT) /* vaddr span, not PDG sz */
214221
#define PGDIR_MASK (~(PGDIR_SIZE-1))
215222

arch/arc/kernel/entry-arcv2.S

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,11 @@ debug_marker_syscall:
211211
; (since IRQ NOT allowed in DS in ARCv2, this can only happen if orig
212212
; entry was via Exception in DS which got preempted in kernel).
213213
;
214-
; IRQ RTIE won't reliably restore DE bit and/or BTA, needs handling
214+
; IRQ RTIE won't reliably restore DE bit and/or BTA, needs workaround
215+
;
216+
; Solution is return from Intr w/o any delay slot quirks into a kernel trampoline
217+
; and from pure kernel mode return to delay slot which handles DS bit/BTA correctly
218+
215219
.Lintr_ret_to_delay_slot:
216220
debug_marker_ds:
217221

@@ -222,18 +226,23 @@ debug_marker_ds:
222226
ld r2, [sp, PT_ret]
223227
ld r3, [sp, PT_status32]
224228

229+
; STAT32 for Int return created from scratch
230+
; (No delay dlot, disable Further intr in trampoline)
231+
225232
bic r0, r3, STATUS_U_MASK|STATUS_DE_MASK|STATUS_IE_MASK|STATUS_L_MASK
226233
st r0, [sp, PT_status32]
227234

228235
mov r1, .Lintr_ret_to_delay_slot_2
229236
st r1, [sp, PT_ret]
230237

238+
; Orig exception PC/STAT32 safekept @orig_r0 and @event stack slots
231239
st r2, [sp, 0]
232240
st r3, [sp, 4]
233241

234242
b .Lisr_ret_fast_path
235243

236244
.Lintr_ret_to_delay_slot_2:
245+
; Trampoline to restore orig exception PC/STAT32/BTA/AUX_USER_SP
237246
sub sp, sp, SZ_PT_REGS
238247
st r9, [sp, -4]
239248

@@ -243,11 +252,19 @@ debug_marker_ds:
243252
ld r9, [sp, 4]
244253
sr r9, [erstatus]
245254

255+
; restore AUX_USER_SP if returning to U mode
256+
bbit0 r9, STATUS_U_BIT, 1f
257+
ld r9, [sp, PT_sp]
258+
sr r9, [AUX_USER_SP]
259+
260+
1:
246261
ld r9, [sp, 8]
247262
sr r9, [erbta]
248263

249264
ld r9, [sp, -4]
250265
add sp, sp, SZ_PT_REGS
266+
267+
; return from pure kernel mode to delay slot
251268
rtie
252269

253270
END(ret_from_exception)

arch/arc/kernel/intc-arcv2.c

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <linux/irqchip.h>
1515
#include <asm/irq.h>
1616

17+
static int irq_prio;
18+
1719
/*
1820
* Early Hardware specific Interrupt setup
1921
* -Called very early (start_kernel -> setup_arch -> setup_processor)
@@ -24,6 +26,14 @@ void arc_init_IRQ(void)
2426
{
2527
unsigned int tmp;
2628

29+
struct irq_build {
30+
#ifdef CONFIG_CPU_BIG_ENDIAN
31+
unsigned int pad:3, firq:1, prio:4, exts:8, irqs:8, ver:8;
32+
#else
33+
unsigned int ver:8, irqs:8, exts:8, prio:4, firq:1, pad:3;
34+
#endif
35+
} irq_bcr;
36+
2737
struct aux_irq_ctrl {
2838
#ifdef CONFIG_CPU_BIG_ENDIAN
2939
unsigned int res3:18, save_idx_regs:1, res2:1,
@@ -46,28 +56,25 @@ void arc_init_IRQ(void)
4656

4757
WRITE_AUX(AUX_IRQ_CTRL, ictrl);
4858

49-
/* setup status32, don't enable intr yet as kernel doesn't want */
50-
tmp = read_aux_reg(0xa);
51-
tmp |= ISA_INIT_STATUS_BITS;
52-
tmp &= ~STATUS_IE_MASK;
53-
asm volatile("flag %0 \n"::"r"(tmp));
54-
5559
/*
5660
* ARCv2 core intc provides multiple interrupt priorities (upto 16).
5761
* Typical builds though have only two levels (0-high, 1-low)
5862
* Linux by default uses lower prio 1 for most irqs, reserving 0 for
5963
* NMI style interrupts in future (say perf)
60-
*
61-
* Read the intc BCR to confirm that Linux default priority is avail
62-
* in h/w
63-
*
64-
* Note:
65-
* IRQ_BCR[27..24] contains N-1 (for N priority levels) and prio level
66-
* is 0 based.
6764
*/
68-
tmp = (read_aux_reg(ARC_REG_IRQ_BCR) >> 24 ) & 0xF;
69-
if (ARCV2_IRQ_DEF_PRIO > tmp)
70-
panic("Linux default irq prio incorrect\n");
65+
66+
READ_BCR(ARC_REG_IRQ_BCR, irq_bcr);
67+
68+
irq_prio = irq_bcr.prio; /* Encoded as N-1 for N levels */
69+
pr_info("archs-intc\t: %d priority levels (default %d)%s\n",
70+
irq_prio + 1, irq_prio,
71+
irq_bcr.firq ? " FIRQ (not used)":"");
72+
73+
/* setup status32, don't enable intr yet as kernel doesn't want */
74+
tmp = read_aux_reg(0xa);
75+
tmp |= STATUS_AD_MASK | (irq_prio << 1);
76+
tmp &= ~STATUS_IE_MASK;
77+
asm volatile("flag %0 \n"::"r"(tmp));
7178
}
7279

7380
static void arcv2_irq_mask(struct irq_data *data)
@@ -86,7 +93,7 @@ void arcv2_irq_enable(struct irq_data *data)
8693
{
8794
/* set default priority */
8895
write_aux_reg(AUX_IRQ_SELECT, data->irq);
89-
write_aux_reg(AUX_IRQ_PRIORITY, ARCV2_IRQ_DEF_PRIO);
96+
write_aux_reg(AUX_IRQ_PRIORITY, irq_prio);
9097

9198
/*
9299
* hw auto enables (linux unmask) all by default

arch/arc/kernel/mcip.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ static void mcip_probe_n_setup(void)
9696
#ifdef CONFIG_CPU_BIG_ENDIAN
9797
unsigned int pad3:8,
9898
idu:1, llm:1, num_cores:6,
99-
iocoh:1, grtc:1, dbg:1, pad2:1,
99+
iocoh:1, gfrc:1, dbg:1, pad2:1,
100100
msg:1, sem:1, ipi:1, pad:1,
101101
ver:8;
102102
#else
103103
unsigned int ver:8,
104104
pad:1, ipi:1, sem:1, msg:1,
105-
pad2:1, dbg:1, grtc:1, iocoh:1,
105+
pad2:1, dbg:1, gfrc:1, iocoh:1,
106106
num_cores:6, llm:1, idu:1,
107107
pad3:8;
108108
#endif
@@ -116,7 +116,7 @@ static void mcip_probe_n_setup(void)
116116
IS_AVAIL1(mp.ipi, "IPI "),
117117
IS_AVAIL1(mp.idu, "IDU "),
118118
IS_AVAIL1(mp.dbg, "DEBUG "),
119-
IS_AVAIL1(mp.grtc, "GRTC"));
119+
IS_AVAIL1(mp.gfrc, "GFRC"));
120120

121121
idu_detected = mp.idu;
122122

@@ -125,8 +125,8 @@ static void mcip_probe_n_setup(void)
125125
__mcip_cmd_data(CMD_DEBUG_SET_MASK, 0xf, 0xf);
126126
}
127127

128-
if (IS_ENABLED(CONFIG_ARC_HAS_GRTC) && !mp.grtc)
129-
panic("kernel trying to use non-existent GRTC\n");
128+
if (IS_ENABLED(CONFIG_ARC_HAS_GFRC) && !mp.gfrc)
129+
panic("kernel trying to use non-existent GFRC\n");
130130
}
131131

132132
struct plat_smp_ops plat_smp_ops = {

arch/arc/kernel/setup.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ struct cpuinfo_arc cpuinfo_arc700[NR_CPUS];
4545
static void read_arc_build_cfg_regs(void)
4646
{
4747
struct bcr_perip uncached_space;
48+
struct bcr_timer timer;
4849
struct bcr_generic bcr;
4950
struct cpuinfo_arc *cpu = &cpuinfo_arc700[smp_processor_id()];
5051
unsigned long perip_space;
@@ -53,7 +54,11 @@ static void read_arc_build_cfg_regs(void)
5354
READ_BCR(AUX_IDENTITY, cpu->core);
5455
READ_BCR(ARC_REG_ISA_CFG_BCR, cpu->isa);
5556

56-
READ_BCR(ARC_REG_TIMERS_BCR, cpu->timers);
57+
READ_BCR(ARC_REG_TIMERS_BCR, timer);
58+
cpu->extn.timer0 = timer.t0;
59+
cpu->extn.timer1 = timer.t1;
60+
cpu->extn.rtc = timer.rtc;
61+
5762
cpu->vec_base = read_aux_reg(AUX_INTR_VEC_BASE);
5863

5964
READ_BCR(ARC_REG_D_UNCACH_BCR, uncached_space);
@@ -208,9 +213,9 @@ static char *arc_cpu_mumbojumbo(int cpu_id, char *buf, int len)
208213
(unsigned int)(arc_get_core_freq() / 10000) % 100);
209214

210215
n += scnprintf(buf + n, len - n, "Timers\t\t: %s%s%s%s\nISA Extn\t: ",
211-
IS_AVAIL1(cpu->timers.t0, "Timer0 "),
212-
IS_AVAIL1(cpu->timers.t1, "Timer1 "),
213-
IS_AVAIL2(cpu->timers.rtc, "64-bit RTC ",
216+
IS_AVAIL1(cpu->extn.timer0, "Timer0 "),
217+
IS_AVAIL1(cpu->extn.timer1, "Timer1 "),
218+
IS_AVAIL2(cpu->extn.rtc, "Local-64-bit-Ctr ",
214219
CONFIG_ARC_HAS_RTC));
215220

216221
n += i = scnprintf(buf + n, len - n, "%s%s%s%s%s",
@@ -293,13 +298,13 @@ static void arc_chk_core_config(void)
293298
struct cpuinfo_arc *cpu = &cpuinfo_arc700[smp_processor_id()];
294299
int fpu_enabled;
295300

296-
if (!cpu->timers.t0)
301+
if (!cpu->extn.timer0)
297302
panic("Timer0 is not present!\n");
298303

299-
if (!cpu->timers.t1)
304+
if (!cpu->extn.timer1)
300305
panic("Timer1 is not present!\n");
301306

302-
if (IS_ENABLED(CONFIG_ARC_HAS_RTC) && !cpu->timers.rtc)
307+
if (IS_ENABLED(CONFIG_ARC_HAS_RTC) && !cpu->extn.rtc)
303308
panic("RTC is not present\n");
304309

305310
#ifdef CONFIG_ARC_HAS_DCCM
@@ -334,6 +339,7 @@ static void arc_chk_core_config(void)
334339
panic("FPU non-existent, disable CONFIG_ARC_FPU_SAVE_RESTORE\n");
335340

336341
if (is_isa_arcv2() && IS_ENABLED(CONFIG_SMP) && cpu->isa.atomic &&
342+
IS_ENABLED(CONFIG_ARC_HAS_LLSC) &&
337343
!IS_ENABLED(CONFIG_ARC_STAR_9000923308))
338344
panic("llock/scond livelock workaround missing\n");
339345
}

0 commit comments

Comments
 (0)