2009-10-15 13:12:48

by Tomasz Chmielewski

[permalink] [raw]
Subject: 2.6.31.4: WARNING: at drivers/usb/serial/usb-serial.c:446 serial_unthrottle

I see my minicom segfaulted for some reason (probably as I closed konsole window without exiting minicom first).

And I see this warning in dmesg - anything useful?


[12966.137519] minicom[16738]: segfault at 624fff ip 00000000004174d9 sp 00007ffff5e81b30 error 4 in minicom[400000+26000]
[12966.512773] ------------[ cut here ]------------
[12966.512785] WARNING: at drivers/usb/serial/usb-serial.c:446 serial_unthrottle+0xab/0xb0 [usbserial]()
[12966.512787] Hardware name:
[12966.512788] Modules linked in: bridge stp tun af_packet radeon drm ipv6 coretemp binfmt_misc loop dm_mod cpufreq_ondemand cpufreq_conservative cpufreq_powersave acpi_cpufreq freq_table kvm_intel kvm snd_hda_codec_atihdmi snd_hda_codec_realtek snd_hda_intel snd_hda_codec snd_seq_dummy snd_hwdep snd_seq_oss snd_seq_midi_event snd_seq snd_seq_device e1000e pl2303 snd_pcm_oss i2c_i801 snd_pcm usbserial serio_raw pcspkr snd_timer sr_mod sg joydev i2c_core wmi snd_mixer_oss evdev thermal processor button snd iTCO_wdt iTCO_vendor_support soundcore snd_page_alloc ata_piix ahci libata sd_mod scsi_mod crc_t10dif raid1 ext4 jbd2 crc16 uhci_hcd ohci_hcd ehci_hcd usbhid hid usbcore [last unloaded: scsi_wait_scan]
[12966.512818] Pid: 16738, comm: minicom Not tainted 2.6.31.4-server-0.rc2.1mnb #1
[12966.512819] Call Trace:
[12966.512825] [<ffffffff8106cc95>] warn_slowpath_common+0x85/0xd0
[12966.512828] [<ffffffff8106cd07>] warn_slowpath_null+0x27/0x50
[12966.512832] [<ffffffffa02444bb>] serial_unthrottle+0xab/0xb0 [usbserial]
[12966.512835] [<ffffffff812d3ce4>] tty_unthrottle+0x54/0x80
[12966.512838] [<ffffffff812d2024>] reset_buffer_flags+0xe4/0x120
[12966.512841] [<ffffffff812d208c>] n_tty_flush_buffer+0x2c/0xb0
[12966.512843] [<ffffffff812d4f6d>] ? tty_ldisc_try+0x5d/0x80
[12966.512845] [<ffffffff812d5715>] tty_ldisc_flush+0x45/0x80
[12966.512847] [<ffffffff812d6d3a>] tty_port_close_end+0x3a/0x120
[12966.512851] [<ffffffffa0244a91>] serial_close+0xa1/0xe0 [usbserial]
[12966.512854] [<ffffffff812ceb93>] tty_release_dev+0x163/0x600
[12966.512858] [<ffffffff81235f78>] ? _atomic_dec_and_lock+0x78/0xa0
[12966.512860] [<ffffffff81235f78>] ? _atomic_dec_and_lock+0x78/0xa0
[12966.512862] [<ffffffff812cf05d>] tty_release+0x2d/0x50
[12966.512866] [<ffffffff81151ace>] __fput+0xee/0x220
[12966.512868] [<ffffffff81151c2d>] fput+0x2d/0x50
[12966.512870] [<ffffffff8114d3cc>] filp_close+0x6c/0xb0
[12966.512873] [<ffffffff8106f52f>] put_files_struct+0x8f/0x110
[12966.512875] [<ffffffff8106f608>] exit_files+0x58/0x80
[12966.512877] [<ffffffff81070141>] do_exit+0x161/0x7d0
[12966.512880] [<ffffffff81081003>] ? __dequeue_signal+0xf3/0x220
[12966.512882] [<ffffffff81070810>] do_group_exit+0x60/0xe0
[12966.512884] [<ffffffff8108174c>] get_signal_to_deliver+0x1bc/0x3c0
[12966.512888] [<ffffffff8101268b>] do_notify_resume+0xeb/0x7f0
[12966.512890] [<ffffffff8123cb88>] ? rb_erase+0x1e8/0x350
[12966.512894] [<ffffffff81043226>] ? bad_area+0x26/0x50
[12966.512898] [<ffffffff81430799>] ? do_page_fault+0x379/0x3a0
[12966.512901] [<ffffffff81013e1c>] retint_signal+0x48/0x8c
[12966.512903] ---[ end trace 9324d74be25813f7 ]---



--
Tomasz Chmielewski
http://wpkg.org


2009-10-15 15:04:11

by Alan

[permalink] [raw]
Subject: Re: 2.6.31.4: WARNING: at drivers/usb/serial/usb-serial.c:446 serial_unthrottle

On Thu, 15 Oct 2009 15:12:03 +0200
Tomasz Chmielewski <[email protected]> wrote:

> I see my minicom segfaulted for some reason (probably as I closed konsole window without exiting minicom first).
>
> And I see this warning in dmesg - anything useful?

Looks like a very very old bug in the tty code. I have a patch for this I'm
testing for a while and will sort out properly after the kernel summit. In
the mean time have a play with the patch below which ought to do the trick.

n_tty: fix throttling

From: Alan Cox <[email protected]>

n_tty inadevertently calls throttle and unthrottle methods during its init.
This happens before the tty device is open and causes problems for the
drivers, in particular they may not have their state and locks even
initialised at this point.

Signed-off-by: Alan Cox <[email protected]>
---

drivers/char/n_tty.c | 35 ++++++++++++++++++++++++++---------
1 files changed, 26 insertions(+), 9 deletions(-)


diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c
index 2e50f4d..b45170c 100644
--- a/drivers/char/n_tty.c
+++ b/drivers/char/n_tty.c
@@ -178,26 +178,23 @@ static void reset_buffer_flags(struct tty_struct *tty)
tty->canon_head = tty->canon_data = tty->erasing = 0;
memset(&tty->read_flags, 0, sizeof tty->read_flags);
n_tty_set_room(tty);
- check_unthrottle(tty);
}

/**
- * n_tty_flush_buffer - clean input queue
+ * n_tty_do_flush - clean input queue
* @tty: terminal device
*
* Flush the input buffer. Called when the line discipline is
- * being closed, when the tty layer wants the buffer flushed (eg
- * at hangup) or when the N_TTY line discipline internally has to
- * clean the pending queue (for example some signals).
+ * being closed, or indirectly when the tty layer wants the buffer
+ * flushed (eg at hangup) or when the N_TTY line discipline internally
+ * has to clean the pending queue (for example some signals).
*
* Locking: ctrl_lock, read_lock.
*/

-static void n_tty_flush_buffer(struct tty_struct *tty)
+static void n_tty_do_flush(struct tty_struct *tty)
{
unsigned long flags;
- /* clear everything and unthrottle the driver */
- reset_buffer_flags(tty);

if (!tty->link)
return;
@@ -211,6 +208,25 @@ static void n_tty_flush_buffer(struct tty_struct *tty)
}

/**
+ * n_tty_flush_buffer - clean input queue
+ * @tty: terminal device
+ *
+ * Flush the input buffer. Called when the tty layer wants the buffer
+ * flushed (eg at hangup) or when the N_TTY line discipline internally
+ * has to clean the pending queue (for example some signals).
+ *
+ * Locking: ctrl_lock, read_lock.
+ */
+
+static void n_tty_flush_buffer(struct tty_struct *tty)
+{
+ /* clear everything and unthrottle the driver */
+ reset_buffer_flags(tty);
+ check_unthrottle(tty);
+ n_tty_do_flush(tty);
+}
+
+/**
* n_tty_chars_in_buffer - report available bytes
* @tty: tty device
*
@@ -1535,7 +1551,8 @@ static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old)

static void n_tty_close(struct tty_struct *tty)
{
- n_tty_flush_buffer(tty);
+ reset_buffer_flags(tty);
+ n_tty_do_flush(tty);
if (tty->read_buf) {
kfree(tty->read_buf);
tty->read_buf = NULL;

2009-10-19 10:03:30

by Tomasz Chmielewski

[permalink] [raw]
Subject: Re: 2.6.31.4: WARNING: at drivers/usb/serial/usb-serial.c:446 serial_unthrottle

Alan Cox wrote:
> On Thu, 15 Oct 2009 15:12:03 +0200
> Tomasz Chmielewski <[email protected]> wrote:
>
>> I see my minicom segfaulted for some reason (probably as I closed konsole window without exiting minicom first).
>>
>> And I see this warning in dmesg - anything useful?
>
> Looks like a very very old bug in the tty code. I have a patch for this I'm
> testing for a while and will sort out properly after the kernel summit. In
> the mean time have a play with the patch below which ought to do the trick.

Since I'm not able to trigger this issue any more (even without this
patch), I won't be able to tell if this patch changed anything or not.

Could be good or not, depending on how you look at it...


--
Tomasz Chmielewski
http://wpkg.org

2009-10-22 03:06:18

by Katsuhiko Nishimra

[permalink] [raw]
Subject: Re: 2.6.31.4: WARNING: at drivers/usb/serial/usb-serial.c:446 serial_unthrottle

Alan Cox wrote:
> On Thu, 15 Oct 2009 15:12:03 +0200
> Tomasz Chmielewski <[email protected]> wrote:
>
>> I see my minicom segfaulted for some reason (probably as I closed konsole window without exiting minicom first).
>>
>> And I see this warning in dmesg - anything useful?
>
> Looks like a very very old bug in the tty code. I have a patch for this I'm
> testing for a while and will sort out properly after the kernel summit. In
> the mean time have a play with the patch below which ought to do the trick.
>

Unfortunately, I reproduced this error after applying this patch into
v2.6.32-rc5. Kerneloops url for the bug is below.
http://www.kerneloops.org/submitresult.php?number=827635

This bug occured when I close minicom normally with C-A X.

Thx.