Skip to contentSkip to conversation

clocksource: arc_timer: add comments about locking while read GFRC

PATCH Superseded Eugeniy Paltsev 2 participants 2 messages Apr 17, 2018

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clocksource: arc_timer: add comments about locking while read GFRC

This came to light in some internal discussions and it is nice to have this documented rather than digging up the PRM (Prog Ref Manual) again.

Signed-off-by Eugeniy Paltsev <Eugeniy.Paltsev at synopsys.com>
---
 drivers/clocksource/arc_timer.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/clocksource/arc_timer.c +13 -0
index 4927355f9cbe..b594c373debc 100644
@@ -61,6 +61,19 @@ static u64 arc_read_gfrc(struct clocksource *cs)
 	unsigned long flags;
 	u32 l, h;
 
+	/*
+	 * MCIP_CMD/MCIP_READBACK registers are allocated
+	 * PER ARC CORE (not per cluster), and there are dedicated hardware
+	 * decode logic (per core) inside ARConnect to handle simultaneous
+	 * read/write accesses from cores via those two registers.
+	 * So several concurrent commands to ARConnect are OK if they are
+	 * trying to access two different sub-components (like GFRC,
+	 * inter-core interrupt, etc...). HW also support simultaneously
+	 * accessing GFRC by multiple cores.
+	 * That's why it is safe to disable hard interrupts on the local CPU
+	 * before access to GFRC instead of taking global MCIP spinlock
+	 * defined in arch/arc/kernel/mcip.c
+	 */
 	local_irq_save(flags);
 
 	__mcip_cmd(CMD_GFRC_READ_LO, 0);
Signature · 1 line
2.14.3
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Eugeniy Paltsev

This came to light in some internal discussions and it is nice to have this documented rather than digging up the PRM (Prog Ref Manual) again.

Signed-off-by Eugeniy Paltsev <Eugeniy.Paltsev at synopsys.com>

Minor nits below, otherwise LGTM !
Acked-by: Vineet Gupta <vgupta at synopsys.com>

Quoted 9 lines
---
  drivers/clocksource/arc_timer.c | 13 +++++++++++++
  1 file changed, 13 insertions(+)
drivers/clocksource/arc_timer.c +0 -0
index 4927355f9cbe..b594c373debc 100644

drivers/clocksource/arc_timer.c static u64 arc_read_gfrc(struct clocksource *cs) · line 65

Quoted 5 lines
drivers/clocksource/arc_timer.c +2 -0
@@ -61,6 +61,19 @@ static u64 arc_read_gfrc(struct clocksource *cs)
  	unsigned long flags;
  	u32 l, h;
 
+	/*
+	 * MCIP_CMD/MCIP_READBACK registers are allocated

From a programming model pov, there seems to be just one instance of
MCIP_CMD/MCIP_READBACK however micro-architecturally there's an instance PER ARC CORE.....

drivers/clocksource/arc_timer.c static u64 arc_read_gfrc(struct clocksource *cs) · line 71

Quoted 6 lines
drivers/clocksource/arc_timer.c +6 -0
+	 * PER ARC CORE (not per cluster), and there are dedicated hardware
+	 * decode logic (per core) inside ARConnect to handle simultaneous
+	 * read/write accesses from cores via those two registers.
+	 * So several concurrent commands to ARConnect are OK if they are
+	 * trying to access two different sub-components (like GFRC,
+	 * inter-core interrupt, etc...). HW also support simultaneously

s/support/supports/

Quoted 8 lines
drivers/clocksource/arc_timer.c +5 -0
+	 * accessing GFRC by multiple cores.
+	 * That's why it is safe to disable hard interrupts on the local CPU
+	 * before access to GFRC instead of taking global MCIP spinlock
+	 * defined in arch/arc/kernel/mcip.c
+	 */
  	local_irq_save(flags);
 
  	__mcip_cmd(CMD_GFRC_READ_LO, 0);