Skip to content

Commit 07423d0

Browse files
Eugeniy Paltsevvineetgarc
authored andcommitted
ARC: mcip: halt GFRC counter when ARC cores halt
In SMP systems, GFRC is used for clocksource. However by default the counter keeps running even when core is halted (say when debugging via a JTAG debugger). This confuses Linux timekeeping and triggers flase RCU stall splat such as below: | [ARCLinux]# while true; do ./shm_open_23-1.run-test ; done | Running with 1000 processes for 1000 objects | hrtimer: interrupt took 485060 ns | | create_cnt: 1000 | Running with 1000 processes for 1000 objects | [ARCLinux]# INFO: rcu_preempt self-detected stall on CPU | 2-...: (1 GPs behind) idle=a01/1/0 softirq=135770/135773 fqs=0 | INFO: rcu_preempt detected stalls on CPUs/tasks: | 0-...: (1 GPs behind) idle=71e/0/0 softirq=135264/135264 fqs=0 | 2-...: (1 GPs behind) idle=a01/1/0 softirq=135770/135773 fqs=0 | 3-...: (1 GPs behind) idle=4e0/0/0 softirq=134304/134304 fqs=0 | (detected by 1, t=13648 jiffies, g=31493, c=31492, q=1) Starting from ARC HS v3.0 it's possible to tie GFRC to state of up-to 4 ARC cores with help of GFRC's CORE register where we set a mask for cores which state we need to rely on. We update cpu mask every time new cpu came online instead of using hardcoded one or using mask generated from "possible_cpus" as we want it set correctly even if we run kernel on HW which has fewer cores than expected (or we launch kernel via debugger and kick fever cores than HW has) Note that GFRC halts when all cores have halted and thus relies on programming of Inter-Core-dEbug register to halt all cores when one halts. Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com> Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com> Signed-off-by: Vineet Gupta <vgupta@synopsys.com> [vgupta: rewrote changelog]
1 parent 701eda0 commit 07423d0

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

‎arch/arc/kernel/mcip.c‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,47 @@ static DEFINE_RAW_SPINLOCK(mcip_lock);
2222

2323
static char smp_cpuinfo_buf[128];
2424

25+
/*
26+
* Set mask to halt GFRC if any online core in SMP cluster is halted.
27+
* Only works for ARC HS v3.0+, on earlier versions has no effect.
28+
*/
29+
static void mcip_update_gfrc_halt_mask(int cpu)
30+
{
31+
struct bcr_generic gfrc;
32+
unsigned long flags;
33+
u32 gfrc_halt_mask;
34+
35+
READ_BCR(ARC_REG_GFRC_BUILD, gfrc);
36+
37+
/*
38+
* CMD_GFRC_SET_CORE and CMD_GFRC_READ_CORE commands were added in
39+
* GFRC 0x3 version.
40+
*/
41+
if (gfrc.ver < 0x3)
42+
return;
43+
44+
raw_spin_lock_irqsave(&mcip_lock, flags);
45+
46+
__mcip_cmd(CMD_GFRC_READ_CORE, 0);
47+
gfrc_halt_mask = read_aux_reg(ARC_REG_MCIP_READBACK);
48+
gfrc_halt_mask |= BIT(cpu);
49+
__mcip_cmd_data(CMD_GFRC_SET_CORE, 0, gfrc_halt_mask);
50+
51+
raw_spin_unlock_irqrestore(&mcip_lock, flags);
52+
}
53+
2554
static void mcip_setup_per_cpu(int cpu)
2655
{
56+
struct mcip_bcr mp;
57+
58+
READ_BCR(ARC_REG_MCIP_BCR, mp);
59+
2760
smp_ipi_irq_setup(cpu, IPI_IRQ);
2861
smp_ipi_irq_setup(cpu, SOFTIRQ_IRQ);
62+
63+
/* Update GFRC halt mask as new CPU came online */
64+
if (mp.gfrc)
65+
mcip_update_gfrc_halt_mask(cpu);
2966
}
3067

3168
static void mcip_ipi_send(int cpu)

‎include/soc/arc/mcip.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#define ARC_REG_MCIP_BCR 0x0d0
1717
#define ARC_REG_MCIP_IDU_BCR 0x0D5
18+
#define ARC_REG_GFRC_BUILD 0x0D6
1819
#define ARC_REG_MCIP_CMD 0x600
1920
#define ARC_REG_MCIP_WDATA 0x601
2021
#define ARC_REG_MCIP_READBACK 0x602
@@ -40,6 +41,8 @@ struct mcip_cmd {
4041

4142
#define CMD_GFRC_READ_LO 0x42
4243
#define CMD_GFRC_READ_HI 0x43
44+
#define CMD_GFRC_SET_CORE 0x47
45+
#define CMD_GFRC_READ_CORE 0x48
4346

4447
#define CMD_IDU_ENABLE 0x71
4548
#define CMD_IDU_DISABLE 0x72

0 commit comments

Comments
 (0)