aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/hpet.c
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2010-10-26 17:22:13 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-26 19:52:11 -0400
commit96e9694df446d1154ec2f4fdba8908588b9cba38 (patch)
tree09f667548a5e6bb465bdaac45d35d69b2cff9a39 /drivers/char/hpet.c
parenta56d5318716d120e040294bb258901ba89fb9c90 (diff)
hpet: fix unwanted interrupt due to stale irq status bit
Jaswinder Singh Rajput wrote: > By executing Documentation/timers/hpet_example.c > > for polling, I requested for 3 iterations but it seems iteration work > for only 2 as first expired time is always very small. > > # ./hpet_example poll /dev/hpet 10 3 > -hpet: executing poll > hpet_poll: info.hi_flags 0x0 > hpet_poll: expired time = 0x13 > hpet_poll: revents = 0x1 > hpet_poll: data 0x1 > hpet_poll: expired time = 0x1868c > hpet_poll: revents = 0x1 > hpet_poll: data 0x1 > hpet_poll: expired time = 0x18645 > hpet_poll: revents = 0x1 > hpet_poll: data 0x1 Clearing the HPET interrupt enable bit disables interrupt generation but does not disable the timer, so the interrupt status bit will still be set when the timer elapses. If another interrupt arrives before the timer has been correctly programmed (due to some other device on the same interrupt line, or CONFIG_DEBUG_SHIRQ), this results in an extra unwanted interrupt event because the status bit is likely to be set from comparator matches that happened before the device was opened. Therefore, we have to ensure that the interrupt status bit is and stays cleared until we actually program the timer. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Reported-by: Jaswinder Singh Rajput <jaswinderlinux@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: john stultz <johnstul@us.ibm.com> Cc: Bob Picco <bpicco@redhat.com> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/hpet.c')
-rw-r--r--drivers/char/hpet.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 84e6a7e673b7..a2cbb828e92a 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -465,6 +465,21 @@ static int hpet_ioctl_ieon(struct hpet_dev *devp)
465 if (irq) { 465 if (irq) {
466 unsigned long irq_flags; 466 unsigned long irq_flags;
467 467
468 if (devp->hd_flags & HPET_SHARED_IRQ) {
469 /*
470 * To prevent the interrupt handler from seeing an
471 * unwanted interrupt status bit, program the timer
472 * so that it will not fire in the near future ...
473 */
474 writel(readl(&timer->hpet_config) & ~Tn_TYPE_CNF_MASK,
475 &timer->hpet_config);
476 write_counter(read_counter(&hpet->hpet_mc),
477 &timer->hpet_compare);
478 /* ... and clear any left-over status. */
479 isr = 1 << (devp - devp->hd_hpets->hp_dev);
480 writel(isr, &hpet->hpet_isr);
481 }
482
468 sprintf(devp->hd_name, "hpet%d", (int)(devp - hpetp->hp_dev)); 483 sprintf(devp->hd_name, "hpet%d", (int)(devp - hpetp->hp_dev));
469 irq_flags = devp->hd_flags & HPET_SHARED_IRQ 484 irq_flags = devp->hd_flags & HPET_SHARED_IRQ
470 ? IRQF_SHARED : IRQF_DISABLED; 485 ? IRQF_SHARED : IRQF_DISABLED;