Skip to content

Commit 097f70b

Browse files
committed
Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus
Pull MIPS fixes from Ralf Baechle: - Properly setup irq handling for ATH79 platforms - Fix bootmem mapstart calculation for contiguous maps - Handle little endian and older CPUs correct in BPF - Fix console for Fulong 2E systems - Handle FTLB correctly on R6 CPUs - Fixes for CM, GIC and MAAR support code * 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus: MIPS: Initialise MAARs on secondary CPUs MIPS: print MAAR configuration during boot MIPS: mm: compile maar_init unconditionally irqchip: mips-gic: Fix pending & mask reads for MIPS64 with 32b GIC. irqchip: mips-gic: Convert CPU numbers to VP IDs. MIPS: CM: Provide a function to map from CPU to VP ID. MIPS: Fix FTLB detection for R6 MIPS: cpu-features: Add cpu_has_ftlb MIPS: ATH79: Add irq chip ar7240-misc-intc MIPS: ATH79: Set missing irq ack handler for ar7100-misc-intc irq chip MIPS: BPF: Fix build on pre-R2 little endian CPUs MIPS: BPF: Avoid unreachable code on little endian MIPS: bootmem: Fix mapstart calculation for contiguous maps MIPS: Fix console output for Fulong2e system
2 parents e3be426 + e060f6e commit 097f70b

14 files changed

Lines changed: 290 additions & 81 deletions

File tree

Documentation/devicetree/bindings/interrupt-controller/qca,ath79-misc-intc.txt

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@ The MISC interrupt controller is a secondary controller for lower priority
44
interrupt.
55

66
Required Properties:
7-
- compatible: has to be "qca,<soctype>-cpu-intc", "qca,ar7100-misc-intc"
8-
as fallback
7+
- compatible: has to be "qca,<soctype>-cpu-intc", "qca,ar7100-misc-intc" or
8+
"qca,<soctype>-cpu-intc", "qca,ar7240-misc-intc"
99
- reg: Base address and size of the controllers memory area
1010
- interrupt-parent: phandle of the parent interrupt controller.
1111
- interrupts: Interrupt specifier for the controllers interrupt.
1212
- interrupt-controller : Identifies the node as an interrupt controller
1313
- #interrupt-cells : Specifies the number of cells needed to encode interrupt
1414
source, should be 1
1515

16+
Compatible fallback depends on the SoC. Use ar7100 for ar71xx and ar913x,
17+
use ar7240 for all other SoCs.
18+
1619
Please refer to interrupts.txt in this directory for details of the common
1720
Interrupt Controllers bindings used by client devices.
1821

@@ -28,3 +31,16 @@ Example:
2831
interrupt-controller;
2932
#interrupt-cells = <1>;
3033
};
34+
35+
Another example:
36+
37+
interrupt-controller@18060010 {
38+
compatible = "qca,ar9331-misc-intc", qca,ar7240-misc-intc";
39+
reg = <0x18060010 0x4>;
40+
41+
interrupt-parent = <&cpuintc>;
42+
interrupts = <6>;
43+
44+
interrupt-controller;
45+
#interrupt-cells = <1>;
46+
};

arch/mips/ath79/irq.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,26 @@ static int __init ath79_misc_intc_of_init(
293293

294294
return 0;
295295
}
296-
IRQCHIP_DECLARE(ath79_misc_intc, "qca,ar7100-misc-intc",
297-
ath79_misc_intc_of_init);
296+
297+
static int __init ar7100_misc_intc_of_init(
298+
struct device_node *node, struct device_node *parent)
299+
{
300+
ath79_misc_irq_chip.irq_mask_ack = ar71xx_misc_irq_mask;
301+
return ath79_misc_intc_of_init(node, parent);
302+
}
303+
304+
IRQCHIP_DECLARE(ar7100_misc_intc, "qca,ar7100-misc-intc",
305+
ar7100_misc_intc_of_init);
306+
307+
static int __init ar7240_misc_intc_of_init(
308+
struct device_node *node, struct device_node *parent)
309+
{
310+
ath79_misc_irq_chip.irq_ack = ar724x_misc_irq_ack;
311+
return ath79_misc_intc_of_init(node, parent);
312+
}
313+
314+
IRQCHIP_DECLARE(ar7240_misc_intc, "qca,ar7240-misc-intc",
315+
ar7240_misc_intc_of_init);
298316

299317
static int __init ar79_cpu_intc_of_init(
300318
struct device_node *node, struct device_node *parent)

arch/mips/include/asm/cpu-features.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
#ifndef cpu_has_tlb
2121
#define cpu_has_tlb (cpu_data[0].options & MIPS_CPU_TLB)
2222
#endif
23+
#ifndef cpu_has_ftlb
24+
#define cpu_has_ftlb (cpu_data[0].options & MIPS_CPU_FTLB)
25+
#endif
2326
#ifndef cpu_has_tlbinv
2427
#define cpu_has_tlbinv (cpu_data[0].options & MIPS_CPU_TLBINV)
2528
#endif

arch/mips/include/asm/cpu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ enum cpu_type_enum {
385385
#define MIPS_CPU_CDMM 0x4000000000ull /* CPU has Common Device Memory Map */
386386
#define MIPS_CPU_BP_GHIST 0x8000000000ull /* R12K+ Branch Prediction Global History */
387387
#define MIPS_CPU_SP 0x10000000000ull /* Small (1KB) page support */
388+
#define MIPS_CPU_FTLB 0x20000000000ull /* CPU has Fixed-page-size TLB */
388389

389390
/*
390391
* CPU ASE encodings

arch/mips/include/asm/maar.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ static inline void write_maar_pair(unsigned idx, phys_addr_t lower,
6565
back_to_back_c0_hazard();
6666
}
6767

68+
/**
69+
* maar_init() - initialise MAARs
70+
*
71+
* Performs initialisation of MAARs for the current CPU, making use of the
72+
* platforms implementation of platform_maar_init where necessary and
73+
* duplicating the setup it provides on secondary CPUs.
74+
*/
75+
extern void maar_init(void);
76+
6877
/**
6978
* struct maar_config - MAAR configuration data
7079
* @lower: The lowest address that the MAAR pair will affect. Must be

arch/mips/include/asm/mips-cm.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ BUILD_CM_RW(reg3_mask, MIPS_CM_GCB_OFS + 0xc8)
194194
BUILD_CM_R_(gic_status, MIPS_CM_GCB_OFS + 0xd0)
195195
BUILD_CM_R_(cpc_status, MIPS_CM_GCB_OFS + 0xf0)
196196
BUILD_CM_RW(l2_config, MIPS_CM_GCB_OFS + 0x130)
197+
BUILD_CM_RW(sys_config2, MIPS_CM_GCB_OFS + 0x150)
197198

198199
/* Core Local & Core Other register accessor functions */
199200
BUILD_CM_Cx_RW(reset_release, 0x00)
@@ -316,6 +317,10 @@ BUILD_CM_Cx_R_(tcid_8_priority, 0x80)
316317
#define CM_GCR_L2_CONFIG_ASSOC_SHF 0
317318
#define CM_GCR_L2_CONFIG_ASSOC_MSK (_ULCAST_(0xff) << 0)
318319

320+
/* GCR_SYS_CONFIG2 register fields */
321+
#define CM_GCR_SYS_CONFIG2_MAXVPW_SHF 0
322+
#define CM_GCR_SYS_CONFIG2_MAXVPW_MSK (_ULCAST_(0xf) << 0)
323+
319324
/* GCR_Cx_COHERENCE register fields */
320325
#define CM_GCR_Cx_COHERENCE_COHDOMAINEN_SHF 0
321326
#define CM_GCR_Cx_COHERENCE_COHDOMAINEN_MSK (_ULCAST_(0xff) << 0)
@@ -405,4 +410,38 @@ static inline int mips_cm_revision(void)
405410
return read_gcr_rev();
406411
}
407412

413+
/**
414+
* mips_cm_max_vp_width() - return the width in bits of VP indices
415+
*
416+
* Return: the width, in bits, of VP indices in fields that combine core & VP
417+
* indices.
418+
*/
419+
static inline unsigned int mips_cm_max_vp_width(void)
420+
{
421+
extern int smp_num_siblings;
422+
423+
if (mips_cm_revision() >= CM_REV_CM3)
424+
return read_gcr_sys_config2() & CM_GCR_SYS_CONFIG2_MAXVPW_MSK;
425+
426+
return smp_num_siblings;
427+
}
428+
429+
/**
430+
* mips_cm_vp_id() - calculate the hardware VP ID for a CPU
431+
* @cpu: the CPU whose VP ID to calculate
432+
*
433+
* Hardware such as the GIC uses identifiers for VPs which may not match the
434+
* CPU numbers used by Linux. This function calculates the hardware VP
435+
* identifier corresponding to a given CPU.
436+
*
437+
* Return: the VP ID for the CPU.
438+
*/
439+
static inline unsigned int mips_cm_vp_id(unsigned int cpu)
440+
{
441+
unsigned int core = cpu_data[cpu].core;
442+
unsigned int vp = cpu_vpe_id(&cpu_data[cpu]);
443+
444+
return (core * mips_cm_max_vp_width()) + vp;
445+
}
446+
408447
#endif /* __MIPS_ASM_MIPS_CM_H__ */

arch/mips/include/asm/mipsregs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,8 @@
487487

488488
/* Bits specific to the MIPS32/64 PRA. */
489489
#define MIPS_CONF_MT (_ULCAST_(7) << 7)
490+
#define MIPS_CONF_MT_TLB (_ULCAST_(1) << 7)
491+
#define MIPS_CONF_MT_FTLB (_ULCAST_(4) << 7)
490492
#define MIPS_CONF_AR (_ULCAST_(7) << 10)
491493
#define MIPS_CONF_AT (_ULCAST_(3) << 13)
492494
#define MIPS_CONF_M (_ULCAST_(1) << 31)

arch/mips/kernel/cpu-probe.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -410,16 +410,18 @@ static int set_ftlb_enable(struct cpuinfo_mips *c, int enable)
410410
static inline unsigned int decode_config0(struct cpuinfo_mips *c)
411411
{
412412
unsigned int config0;
413-
int isa;
413+
int isa, mt;
414414

415415
config0 = read_c0_config();
416416

417417
/*
418418
* Look for Standard TLB or Dual VTLB and FTLB
419419
*/
420-
if ((((config0 & MIPS_CONF_MT) >> 7) == 1) ||
421-
(((config0 & MIPS_CONF_MT) >> 7) == 4))
420+
mt = config0 & MIPS_CONF_MT;
421+
if (mt == MIPS_CONF_MT_TLB)
422422
c->options |= MIPS_CPU_TLB;
423+
else if (mt == MIPS_CONF_MT_FTLB)
424+
c->options |= MIPS_CPU_TLB | MIPS_CPU_FTLB;
423425

424426
isa = (config0 & MIPS_CONF_AT) >> 13;
425427
switch (isa) {
@@ -559,15 +561,18 @@ static inline unsigned int decode_config4(struct cpuinfo_mips *c)
559561
if (cpu_has_tlb) {
560562
if (((config4 & MIPS_CONF4_IE) >> 29) == 2)
561563
c->options |= MIPS_CPU_TLBINV;
564+
562565
/*
563-
* This is a bit ugly. R6 has dropped that field from
564-
* config4 and the only valid configuration is VTLB+FTLB so
565-
* set a good value for mmuextdef for that case.
566+
* R6 has dropped the MMUExtDef field from config4.
567+
* On R6 the fields always describe the FTLB, and only if it is
568+
* present according to Config.MT.
566569
*/
567-
if (cpu_has_mips_r6)
570+
if (!cpu_has_mips_r6)
571+
mmuextdef = config4 & MIPS_CONF4_MMUEXTDEF;
572+
else if (cpu_has_ftlb)
568573
mmuextdef = MIPS_CONF4_MMUEXTDEF_VTLBSIZEEXT;
569574
else
570-
mmuextdef = config4 & MIPS_CONF4_MMUEXTDEF;
575+
mmuextdef = 0;
571576

572577
switch (mmuextdef) {
573578
case MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT:

arch/mips/kernel/setup.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ static void __init bootmem_init(void)
338338
if (end <= reserved_end)
339339
continue;
340340
#ifdef CONFIG_BLK_DEV_INITRD
341-
/* mapstart should be after initrd_end */
341+
/* Skip zones before initrd and initrd itself */
342342
if (initrd_end && end <= (unsigned long)PFN_UP(__pa(initrd_end)))
343343
continue;
344344
#endif
@@ -371,6 +371,14 @@ static void __init bootmem_init(void)
371371
max_low_pfn = PFN_DOWN(HIGHMEM_START);
372372
}
373373

374+
#ifdef CONFIG_BLK_DEV_INITRD
375+
/*
376+
* mapstart should be after initrd_end
377+
*/
378+
if (initrd_end)
379+
mapstart = max(mapstart, (unsigned long)PFN_UP(__pa(initrd_end)));
380+
#endif
381+
374382
/*
375383
* Initialize the boot-time allocator with low memory only.
376384
*/

arch/mips/kernel/smp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include <asm/mmu_context.h>
4343
#include <asm/time.h>
4444
#include <asm/setup.h>
45+
#include <asm/maar.h>
4546

4647
cpumask_t cpu_callin_map; /* Bitmask of started secondaries */
4748

@@ -157,6 +158,7 @@ asmlinkage void start_secondary(void)
157158
mips_clockevent_init();
158159
mp_ops->init_secondary();
159160
cpu_report();
161+
maar_init();
160162

161163
/*
162164
* XXX parity protection should be folded in here when it's converted

0 commit comments

Comments
 (0)