mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@osdl.org>
To: Andrew Morton <akpm@osdl.org>
Cc: Marcel Sebek <sebek64@post.cz>,
	linux-kernel@vger.kernel.org, Alan Cox <alan@lxorguk.ukuu.org.uk>
Subject: Re: [2.6.9-rc3-bk1] Sleeping function called from invalid context
Date: Sat, 2 Oct 2004 12:08:12 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.58.0410021201340.2301@ppc970.osdl.org> (raw)
In-Reply-To: <20041001205658.7c2b8ecf.akpm@osdl.org>



On Fri, 1 Oct 2004, Andrew Morton wrote:
> 
> In rc3 change_termios() was altered so that it calls
> (*tty->driver->set_termios)() under spin_lock_irqsave(tty_termios_lock).
> 
> But ftdi_set_termios() wants to perform USB I/O, which involves sleeping
> allocations all over the place.

Alan, my first reaction was "that's just a buggy driver", but looking at 
the reason for it (telling the device at the other end to change it's 
speed), it's clearly not the driver. The new spinlock is just wrong.

We might be able to change it to a per-tty semaphore instead, which sounds 
reasonably safe, but in the meantime I don't think we have any other 
choice than to just leave the driver/ldisc routines unprotected. They 
should be just reading the state, after all.

I'm committing this temporary fix..

		Linus
----
===== drivers/char/tty_ioctl.c 1.13 vs edited =====
--- 1.13/drivers/char/tty_ioctl.c	2004-09-29 14:27:20 -07:00
+++ edited/drivers/char/tty_ioctl.c	2004-10-02 12:06:40 -07:00
@@ -145,6 +145,13 @@
 			wake_up_interruptible(&tty->link->read_wait);
 		}
 	}
+
+	/*
+	 * Fixme! We should really try to protect the driver and ldisc
+	 * termios usage too. But they need to be able to sleep, so
+	 * the global termios spinlock is not the right thing.
+	 */
+	spin_unlock_irqrestore(&tty_termios_lock, flags);
 	   
 	if (tty->driver->set_termios)
 		(*tty->driver->set_termios)(tty, &old_termios);
@@ -155,7 +162,6 @@
 			(ld->set_termios)(tty, &old_termios);
 		tty_ldisc_deref(ld);
 	}
-	spin_unlock_irqrestore(&tty_termios_lock, flags);
 }
 
 static int set_termios(struct tty_struct * tty, void __user *arg, int opt)

  reply	other threads:[~2004-10-02 19:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-01 20:35 Marcel Sebek
2004-10-02  3:56 ` Andrew Morton
2004-10-02 19:08   ` Linus Torvalds [this message]
2004-10-02 18:57     ` Alan Cox

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=Pine.LNX.4.58.0410021201340.2301@ppc970.osdl.org \
    --to=torvalds@osdl.org \
    --cc=akpm@osdl.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sebek64@post.cz \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®