* [PATCH][2.6.10-rc2-bk9] Assume struct uart_state closing times are in centiseconds
@ 2004-11-26 18:16 Ian Abbott
0 siblings, 0 replies; 2+ messages in thread
From: Ian Abbott @ 2004-11-26 18:16 UTC (permalink / raw)
To: linux-serial; +Cc: Russell King
[-- Attachment #1: Type: text/plain, Size: 748 bytes --]
Hi,
The current use of close_delay and closing_wait within serial_core.c is
a little messed up for the following reasons:
* The values are scaled by uart_set_info() but not scaled back by
uart_get_info(), so the values are different unless HZ==100.
* The closing_wait value is scaled by uart_set_info() and compared to an
unscaled magic value USF_CLOSING_WAIT_NONE in uart_close().
As uart_set_info already assumes that the new values are in centisecond
units and scaling could mess up the comparison with magic values (even
if the magic values are scaled), I propose to store the raw centisecond
values in struct uart_state and scale them at the point of use. Here is
a patch to do that.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
[-- Attachment #2: serial_closing_time.patch --]
[-- Type: text/x-patch, Size: 2276 bytes --]
diff -urN linux-2.6.10-rc2-bk9/drivers/serial/serial_core.c linux-2.6.10-rc2-bk9-ia/drivers/serial/serial_core.c
--- linux-2.6.10-rc2-bk9/drivers/serial/serial_core.c 2004-11-26 17:26:07.750667256 +0000
+++ linux-2.6.10-rc2-bk9-ia/drivers/serial/serial_core.c 2004-11-26 17:46:32.523473488 +0000
@@ -751,8 +751,8 @@
port->flags = (port->flags & ~UPF_CHANGE_MASK) |
(new_serial.flags & UPF_CHANGE_MASK);
port->custom_divisor = new_serial.custom_divisor;
- state->close_delay = new_serial.close_delay * HZ / 100;
- state->closing_wait = new_serial.closing_wait * HZ / 100;
+ state->close_delay = new_serial.close_delay;
+ state->closing_wait = new_serial.closing_wait;
port->fifosize = new_serial.xmit_fifo_size;
if (state->info->tty)
state->info->tty->low_latency =
@@ -1191,7 +1191,7 @@
tty->closing = 1;
if (state->closing_wait != USF_CLOSING_WAIT_NONE)
- tty_wait_until_sent(tty, state->closing_wait);
+ tty_wait_until_sent(tty, state->closing_wait * HZ / 100);
/*
* At this point, we stop accepting input. To do this, we
@@ -1220,7 +1220,7 @@
if (state->info->blocked_open) {
if (state->close_delay) {
- msleep_interruptible(jiffies_to_msecs(state->close_delay));
+ msleep_interruptible(10 * state->close_delay);
}
} else if (!uart_console(port)) {
uart_change_pm(state, 3);
@@ -2082,8 +2082,8 @@
for (i = 0; i < drv->nr; i++) {
struct uart_state *state = drv->state + i;
- state->close_delay = 5 * HZ / 10;
- state->closing_wait = 30 * HZ;
+ state->close_delay = 50; /* .5 seconds */
+ state->closing_wait = 3000; /* 30 seconds */
init_MUTEX(&state->sem);
}
diff -urN linux-2.6.10-rc2-bk9/include/linux/serial_core.h linux-2.6.10-rc2-bk9-ia/include/linux/serial_core.h
--- linux-2.6.10-rc2-bk9/include/linux/serial_core.h 2004-11-26 17:26:14.787597480 +0000
+++ linux-2.6.10-rc2-bk9-ia/include/linux/serial_core.h 2004-11-26 17:49:09.499609488 +0000
@@ -241,8 +241,8 @@
* within.
*/
struct uart_state {
- unsigned int close_delay;
- unsigned int closing_wait;
+ unsigned int close_delay; /* units: centiseconds */
+ unsigned int closing_wait; /* units: centiseconds */
#define USF_CLOSING_WAIT_INF (0)
#define USF_CLOSING_WAIT_NONE (65535)
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH][2.6.10-rc2-bk9] Assume struct uart_state closing times are in centiseconds
@ 2004-11-26 21:29 Ian Abbott
0 siblings, 0 replies; 2+ messages in thread
From: Ian Abbott @ 2004-11-26 21:29 UTC (permalink / raw)
To: linux-serial; +Cc: Russell King
[-- Attachment #1: Type: text/plain, Size: 797 bytes --]
[Reposting due to Cc: address mix-up the first time!]
Hi,
The current use of close_delay and closing_wait within serial_core.c is
a little messed up for the following reasons:
* The values are scaled by uart_set_info() but not scaled back by
uart_get_info(), so the values are different unless HZ==100.
* The closing_wait value is scaled by uart_set_info() and compared to an
unscaled magic value USF_CLOSING_WAIT_NONE in uart_close().
As uart_set_info already assumes that the new values are in centisecond
units and scaling could mess up the comparison with magic values (even
if the magic values are scaled), I propose to store the raw centisecond
values in struct uart_state and scale them at the point of use. Here is
a patch to do that.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
[-- Attachment #2: serial_closing_time.patch --]
[-- Type: text/x-patch, Size: 2277 bytes --]
diff -urN linux-2.6.10-rc2-bk9/drivers/serial/serial_core.c linux-2.6.10-rc2-bk9-ia/drivers/serial/serial_core.c
--- linux-2.6.10-rc2-bk9/drivers/serial/serial_core.c 2004-11-26 17:26:07.750667256 +0000
+++ linux-2.6.10-rc2-bk9-ia/drivers/serial/serial_core.c 2004-11-26 17:46:32.523473488 +0000
@@ -751,8 +751,8 @@
port->flags = (port->flags & ~UPF_CHANGE_MASK) |
(new_serial.flags & UPF_CHANGE_MASK);
port->custom_divisor = new_serial.custom_divisor;
- state->close_delay = new_serial.close_delay * HZ / 100;
- state->closing_wait = new_serial.closing_wait * HZ / 100;
+ state->close_delay = new_serial.close_delay;
+ state->closing_wait = new_serial.closing_wait;
port->fifosize = new_serial.xmit_fifo_size;
if (state->info->tty)
state->info->tty->low_latency =
@@ -1191,7 +1191,7 @@
tty->closing = 1;
if (state->closing_wait != USF_CLOSING_WAIT_NONE)
- tty_wait_until_sent(tty, state->closing_wait);
+ tty_wait_until_sent(tty, state->closing_wait * HZ / 100);
/*
* At this point, we stop accepting input. To do this, we
@@ -1220,7 +1220,7 @@
if (state->info->blocked_open) {
if (state->close_delay) {
- msleep_interruptible(jiffies_to_msecs(state->close_delay));
+ msleep_interruptible(10 * state->close_delay);
}
} else if (!uart_console(port)) {
uart_change_pm(state, 3);
@@ -2082,8 +2082,8 @@
for (i = 0; i < drv->nr; i++) {
struct uart_state *state = drv->state + i;
- state->close_delay = 5 * HZ / 10;
- state->closing_wait = 30 * HZ;
+ state->close_delay = 50; /* .5 seconds */
+ state->closing_wait = 3000; /* 30 seconds */
init_MUTEX(&state->sem);
}
diff -urN linux-2.6.10-rc2-bk9/include/linux/serial_core.h linux-2.6.10-rc2-bk9-ia/include/linux/serial_core.h
--- linux-2.6.10-rc2-bk9/include/linux/serial_core.h 2004-11-26 17:26:14.787597480 +0000
+++ linux-2.6.10-rc2-bk9-ia/include/linux/serial_core.h 2004-11-26 17:49:09.499609488 +0000
@@ -241,8 +241,8 @@
* within.
*/
struct uart_state {
- unsigned int close_delay;
- unsigned int closing_wait;
+ unsigned int close_delay; /* units: centiseconds */
+ unsigned int closing_wait; /* units: centiseconds */
#define USF_CLOSING_WAIT_INF (0)
#define USF_CLOSING_WAIT_NONE (65535)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-11-26 21:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-26 21:29 [PATCH][2.6.10-rc2-bk9] Assume struct uart_state closing times are in centiseconds Ian Abbott
-- strict thread matches above, loose matches on Subject: below --
2004-11-26 18:16 Ian Abbott
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).