aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJisheng Zhang <jszhang@marvell.com>2015-11-25 11:01:53 -0500
committerDaniel Lezcano <daniel.lezcano@linaro.org>2015-12-15 15:41:28 -0500
commit39d3611f2d8ff5dcba523c9081e6f5e51f066c86 (patch)
tree5c4d95695e85298df18776abb05774cc021a08a1
parent9f4165dc4e9e6dd10627b7b4d4e09c09fc01410c (diff)
clocksource/drivers/dw_apb_timer: Use {readl|writel}_relaxed in critical path
It's safe to use the relaxed version. From another side, the relaxed io accessor macros are available on all architectures now, so we can use the relaxed versions to get a trivial system performance improvement, we measured time the following functions spent on Marvell BG4CT: 4096 rounds of __apbt_read_clocksource() call: before the patch: 1263240ns on average after the patch: 1250080ns on average improved by 1% 4096 rounds of apbt_eoi() call: before the patch: 1290960ns on average after the patch: 1248240ns on average 4096 rounds of apbt_next_event() call: before the patch: 3333660ns on average after the patch: 1322040ns on average improved by 60%! Signed-off-by: Jisheng Zhang <jszhang@marvell.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
-rw-r--r--drivers/clocksource/dw_apb_timer.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/drivers/clocksource/dw_apb_timer.c b/drivers/clocksource/dw_apb_timer.c
index 3a6d9dbe315d..7f95b5347a9a 100644
--- a/drivers/clocksource/dw_apb_timer.c
+++ b/drivers/clocksource/dw_apb_timer.c
@@ -60,6 +60,17 @@ static void apbt_writel(struct dw_apb_timer *timer, u32 val,
60 writel(val, timer->base + offs); 60 writel(val, timer->base + offs);
61} 61}
62 62
63static inline u32 apbt_readl_relaxed(struct dw_apb_timer *timer, unsigned long offs)
64{
65 return readl_relaxed(timer->base + offs);
66}
67
68static inline void apbt_writel_relaxed(struct dw_apb_timer *timer, u32 val,
69 unsigned long offs)
70{
71 writel_relaxed(val, timer->base + offs);
72}
73
63static void apbt_disable_int(struct dw_apb_timer *timer) 74static void apbt_disable_int(struct dw_apb_timer *timer)
64{ 75{
65 u32 ctrl = apbt_readl(timer, APBTMR_N_CONTROL); 76 u32 ctrl = apbt_readl(timer, APBTMR_N_CONTROL);
@@ -81,7 +92,7 @@ void dw_apb_clockevent_pause(struct dw_apb_clock_event_device *dw_ced)
81 92
82static void apbt_eoi(struct dw_apb_timer *timer) 93static void apbt_eoi(struct dw_apb_timer *timer)
83{ 94{
84 apbt_readl(timer, APBTMR_N_EOI); 95 apbt_readl_relaxed(timer, APBTMR_N_EOI);
85} 96}
86 97
87static irqreturn_t dw_apb_clockevent_irq(int irq, void *data) 98static irqreturn_t dw_apb_clockevent_irq(int irq, void *data)
@@ -200,13 +211,13 @@ static int apbt_next_event(unsigned long delta,
200 struct dw_apb_clock_event_device *dw_ced = ced_to_dw_apb_ced(evt); 211 struct dw_apb_clock_event_device *dw_ced = ced_to_dw_apb_ced(evt);
201 212
202 /* Disable timer */ 213 /* Disable timer */
203 ctrl = apbt_readl(&dw_ced->timer, APBTMR_N_CONTROL); 214 ctrl = apbt_readl_relaxed(&dw_ced->timer, APBTMR_N_CONTROL);
204 ctrl &= ~APBTMR_CONTROL_ENABLE; 215 ctrl &= ~APBTMR_CONTROL_ENABLE;
205 apbt_writel(&dw_ced->timer, ctrl, APBTMR_N_CONTROL); 216 apbt_writel_relaxed(&dw_ced->timer, ctrl, APBTMR_N_CONTROL);
206 /* write new count */ 217 /* write new count */
207 apbt_writel(&dw_ced->timer, delta, APBTMR_N_LOAD_COUNT); 218 apbt_writel_relaxed(&dw_ced->timer, delta, APBTMR_N_LOAD_COUNT);
208 ctrl |= APBTMR_CONTROL_ENABLE; 219 ctrl |= APBTMR_CONTROL_ENABLE;
209 apbt_writel(&dw_ced->timer, ctrl, APBTMR_N_CONTROL); 220 apbt_writel_relaxed(&dw_ced->timer, ctrl, APBTMR_N_CONTROL);
210 221
211 return 0; 222 return 0;
212} 223}
@@ -342,7 +353,8 @@ static cycle_t __apbt_read_clocksource(struct clocksource *cs)
342 struct dw_apb_clocksource *dw_cs = 353 struct dw_apb_clocksource *dw_cs =
343 clocksource_to_dw_apb_clocksource(cs); 354 clocksource_to_dw_apb_clocksource(cs);
344 355
345 current_count = apbt_readl(&dw_cs->timer, APBTMR_N_CURRENT_VALUE); 356 current_count = apbt_readl_relaxed(&dw_cs->timer,
357 APBTMR_N_CURRENT_VALUE);
346 358
347 return (cycle_t)~current_count; 359 return (cycle_t)~current_count;
348} 360}