Skip to content

Commit 3ef0665

Browse files
chenhuacairalfbaechle
authored andcommitted
MIPS: hpet: Increase HPET_MIN_PROG_DELTA and decrease HPET_MIN_CYCLES
At first, we prefer to use mips clockevent device, so we decrease the rating of hpet clockevent device. For hpet, if HPET_MIN_PROG_DELTA (minimum delta of hpet programming) is too small and HPET_MIN_CYCLES (threshold of -ETIME checking) is too large, then hpet_next_event() can easily return -ETIME. After commit c6eb3f7 ("hrtimer: Get rid of hrtimer softirq") this will cause a RCU stall. So, HPET_MIN_PROG_DELTA must be sufficient that we don't re-trip the -ETIME check -- if we do, we will return -ETIME, forward the next event time, try to set it, return -ETIME again, and basically lock the system up. Meanwhile, HPET_MIN_CYCLES doesn't need to be too large, 16 cycles is enough. This solution is similar to commit f9eccf2 ("clocksource/drivers /vt8500: Increase the minimum delta"). By the way, this patch ensures hpet count/compare to be 32-bit long. Signed-off-by: Huacai Chen <chenhc@lemote.com> Cc: John Crispin <john@phrozen.org> Cc: Steven J . Hill <Steven.Hill@imgtec.com> Cc: Fuxin Zhang <zhangfx@lemote.com> Cc: Zhangjin Wu <wuzhangjin@gmail.com> Cc: linux-mips@linux-mips.org Cc: stable@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/13819/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent 07d6957 commit 3ef0665

File tree

1 file changed

+7
-7
lines changed
  • arch/mips/loongson64/loongson-3

1 file changed

+7
-7
lines changed

arch/mips/loongson64/loongson-3/hpet.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#define SMBUS_PCI_REG64 0x64
1414
#define SMBUS_PCI_REGB4 0xb4
1515

16-
#define HPET_MIN_CYCLES 64
17-
#define HPET_MIN_PROG_DELTA (HPET_MIN_CYCLES + (HPET_MIN_CYCLES >> 1))
16+
#define HPET_MIN_CYCLES 16
17+
#define HPET_MIN_PROG_DELTA (HPET_MIN_CYCLES * 12)
1818

1919
static DEFINE_SPINLOCK(hpet_lock);
2020
DEFINE_PER_CPU(struct clock_event_device, hpet_clockevent_device);
@@ -157,14 +157,14 @@ static int hpet_tick_resume(struct clock_event_device *evt)
157157
static int hpet_next_event(unsigned long delta,
158158
struct clock_event_device *evt)
159159
{
160-
unsigned int cnt;
161-
int res;
160+
u32 cnt;
161+
s32 res;
162162

163163
cnt = hpet_read(HPET_COUNTER);
164-
cnt += delta;
164+
cnt += (u32) delta;
165165
hpet_write(HPET_T0_CMP, cnt);
166166

167-
res = (int)(cnt - hpet_read(HPET_COUNTER));
167+
res = (s32)(cnt - hpet_read(HPET_COUNTER));
168168

169169
return res < HPET_MIN_CYCLES ? -ETIME : 0;
170170
}
@@ -230,7 +230,7 @@ void __init setup_hpet_timer(void)
230230

231231
cd = &per_cpu(hpet_clockevent_device, cpu);
232232
cd->name = "hpet";
233-
cd->rating = 320;
233+
cd->rating = 100;
234234
cd->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT;
235235
cd->set_state_shutdown = hpet_set_state_shutdown;
236236
cd->set_state_periodic = hpet_set_state_periodic;

0 commit comments

Comments
 (0)