* Issues in Linux HPET example
@ 2010-09-01 12:47 Jaswinder Singh Rajput
2010-09-06 8:36 ` [PATCH] hpet: fix unwanted interrupt due to stale irq status bit Clemens Ladisch
0 siblings, 1 reply; 2+ messages in thread
From: Jaswinder Singh Rajput @ 2010-09-01 12:47 UTC (permalink / raw)
To: Linux Kernel Mailing List, the arch/x86 maintainers
Hello,
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.
[root@netbook timers]# ./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
[root@netbook timers]#
for fasync, I requested for 3 iterations but it shows 4 counts.
[root@netbook timers]# ./hpet_example fasync /dev/hpet 10 3
-hpet: executing fasync
hpet_fasync: info.hi_flags 0x0
hpet_sigio: called
hpet_sigio: called
hpet_fasync: count = 2
hpet_sigio: called
hpet_fasync: count = 3
hpet_sigio: called
hpet_fasync: count = 4
[root@netbook timers]#
How can I fix these issues.
Thanks,
--
Jaswinder Singh.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] hpet: fix unwanted interrupt due to stale irq status bit
2010-09-01 12:47 Issues in Linux HPET example Jaswinder Singh Rajput
@ 2010-09-06 8:36 ` Clemens Ladisch
0 siblings, 0 replies; 2+ messages in thread
From: Clemens Ladisch @ 2010-09-06 8:36 UTC (permalink / raw)
To: Andrew Morton, Jaswinder Singh Rajput
Cc: Linux Kernel Mailing List, the arch/x86 maintainers
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: <stable@kernel.org>
---
drivers/char/hpet.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -514,6 +514,21 @@ static int hpet_ioctl_ieon(struct hpet_d
if (irq) {
unsigned long irq_flags;
+ if (devp->hd_flags & HPET_SHARED_IRQ) {
+ /*
+ * To prevent the interrupt handler from seeing an
+ * unwanted interrupt status bit, program the timer
+ * so that it will not fire in the near future ...
+ */
+ writel(readl(&timer->hpet_config) & ~Tn_TYPE_CNF_MASK,
+ &timer->hpet_config);
+ write_counter(read_counter(&hpet->hpet_mc),
+ &timer->hpet_compare);
+ /* ... and clear any left-over status. */
+ isr = 1 << (devp - devp->hd_hpets->hp_dev);
+ writel(isr, &hpet->hpet_isr);
+ }
+
sprintf(devp->hd_name, "hpet%d", (int)(devp - hpetp->hp_dev));
irq_flags = devp->hd_flags & HPET_SHARED_IRQ
? IRQF_SHARED : IRQF_DISABLED;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-09-06 8:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-01 12:47 Issues in Linux HPET example Jaswinder Singh Rajput
2010-09-06 8:36 ` [PATCH] hpet: fix unwanted interrupt due to stale irq status bit Clemens Ladisch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox