Re: Serial-Core: USB-Serial port current issues.

From: Luiz Fernando N. Capitulino
Date: Fri Jun 23 2006 - 13:24:03 EST


On Thu, 22 Jun 2006 09:29:40 +0100
Russell King <rmk+lkml@xxxxxxxxxxxxxxxx> wrote:

| On Wed, Jun 21, 2006 at 06:15:13PM -0300, Luiz Fernando N. Capitulino wrote:
|
| > | With get_mctrl(), the situation is slightly more complicated, because
| > | we need to atomically update tty->hw_stopped in some circumstances
| > | (that may also be modified from irq context.) Therefore, to give
| > | the driver a consistent locking picture, the spinlock is _always_
| > | held.
| >
| > Is it too bad (wrong?) to only protect the tty->hw_stopped update
| > by the spinlock? Then the call to get_mctrl() could be protected by
| > a mutex, or is it messy?
|
| Consider this scenario with what you're proposing:
|
| thread irq
|
| take mutex
| get_mctrl
| cts changes state
| take port lock
| mctrl state read
| tty->hw_stopped changed state
| release port lock
| releaes mutex
| take port lock
| update tty->hw_stopped
| release port lock
|
| Now, tty->hw_stopped does not reflect the hardware state, which will be
| buggy and can cause a loss of transmission.
|
| I'm not sure what to suggest on this one since for USB drivers you do
| need to be able to sleep in this method... but for UARTs you must not.

Neither do I. :((

I thought we could move the 'tty->hw_stopped' update to a workqueue
but it has the same problem you explained above...

Greg, any suggestions?

--
Luiz Fernando N. Capitulino
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/