From: Robert Hancock <hancockr@shaw.ca>
To: Giampaolo Tomassoni <g.tomassoni@libero.it>
Cc: Linux Kernel ML <linux-kernel@vger.kernel.org>
Subject: Re: R: How to avoid serial port buffer overruns?
Date: Fri, 18 Aug 2006 08:30:50 -0600 [thread overview]
Message-ID: <44E5CF1A.6000506@shaw.ca> (raw)
In-Reply-To: <fa.x+yVoyTCbDO6PUepCOmW0pYaloQ@ifi.uio.no>
Giampaolo Tomassoni wrote:
> I beg your pardon: I'm not used that much to interrupts handling in Linux, but this piece of code from sound/drivers/serial-u16550.c in a linux-2.6.16:
>
> static irqreturn_t snd_uart16550_interrupt(int irq, void *dev_id, struct pt_regs *regs)
> {
> snd_uart16550_t *uart;
>
> uart = (snd_uart16550_t *) dev_id;
> spin_lock(&uart->open_lock);
> if (uart->filemode == SERIAL_MODE_NOT_OPENED) {
> spin_unlock(&uart->open_lock);
> return IRQ_NONE;
> }
> inb(uart->base + UART_IIR); /* indicate to the UART that the interrupt has been serviced */
> snd_uart16550_io_loop(uart);
> spin_unlock(&uart->open_lock);
> return IRQ_HANDLED;
> }
>
> means to me that IRQ_HANDLED is returned even when the interrupt is not issued by the specific UART. This may lead to problems when two or more uarts share the same irq line and the irq line is edge-triggered instead of level-triggered, as is the case with ISA.
>
> To my knowledge, IRQ_HANDLED should be returned when an interrupt had been served by that specific device handler. Returning a IRQ_HANDLED when the device didn't request for service, in the best case cuases interrupt latencies, in the worst (like in an ISA environment) impairs servicing requests from devices sharing the same IRQ line.
>
> The byte returned from inb(uart->base + UART_IIR) can be used to detect if this is the requesting UART.
>
> Am I wrong?
IRQ_HANDLED vs. IRQ_NONE has no effect on what interrupt handlers are
called, etc. It is only used to detect if an interrupt is firing without
being handled by any driver, in this case the kernel can detect this and
disable the interrupt.
I'm not sure exactly why the driver is returning IRQ_HANDLED all the
time, but edge-triggered interrupts are always tricky and there may be a
case where it can't reliably detect this. Returning IRQ_HANDLED is the
safe thing to do if you cannot be sure if your device raised an
interrupt or not.
--
Robert Hancock Saskatoon, SK, Canada
To email, remove "nospam" from hancockr@nospamshaw.ca
Home Page: http://www.roberthancock.com/
next parent reply other threads:[~2006-08-18 14:30 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <fa.ZZ2a/l3Zs8tqngLkenc7k5Pc5LM@ifi.uio.no>
[not found] ` <fa.x+yVoyTCbDO6PUepCOmW0pYaloQ@ifi.uio.no>
2006-08-18 14:30 ` Robert Hancock [this message]
2006-08-18 14:58 ` R: R: How to avoid serial port buffer overruns? Giampaolo Tomassoni
2006-08-18 15:34 ` linux-os (Dick Johnson)
2006-08-16 23:28 Lee Revell
2006-08-17 0:15 ` R: " Giampaolo Tomassoni
2006-08-18 8:48 ` Giampaolo Tomassoni
2006-08-18 17:00 ` Lee Revell
2006-08-18 17:04 ` Russell King
2006-08-18 17:30 ` Lee Revell
2006-08-18 18:34 ` Russell King
2006-08-18 18:52 ` Lee Revell
2006-08-18 19:01 ` Russell King
2006-08-18 19:07 ` Russell King
2006-08-18 19:09 ` Lee Revell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44E5CF1A.6000506@shaw.ca \
--to=hancockr@shaw.ca \
--cc=g.tomassoni@libero.it \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.