mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alan Cox <gnomes@lxorguk.ukuu.org.uk>
To: taoyuhong <taoyuhong@huawei.com>
Cc: <gregkh@linuxfoundation.org>, <jslaby@suse.com>,
	<zhaoshenglong@huawei.com>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] tty: fix flush_to_ldisc() oops before tty_open is done
Date: Wed, 25 Oct 2017 20:25:29 +0100	[thread overview]
Message-ID: <20171025202529.299d9c72@alans-desktop> (raw)
In-Reply-To: <1508897735-30968-1-git-send-email-taoyuhong@huawei.com>

> When tty_open() is opening a serial tty at the first time, after
> alloc_tty_struct() is called, before tty->ops->open() is finished.

That's kind of unavoidable.

> Serial driever like pl011 on ARM is ready to setup kworker threads
> to receive data with flush_to_ldisc(). Serial input at this time
> window can trigger kernel oops.

So you shouldn't be queueing I/O at this point.

> On the other side, flush_to_ldisc() can also oops on a hung-up tty.

flush_to_ldisc takes a reference to the tty ldisc so when it's called
from tty_schedule_flip all should be good. 

> Serial driver may has problem, but tty driver can easily handle these 2
> oops problems by:
> 
> 1. Skip data transfer of hung-up tty, in flush_to_ldisc()

No because you may have data you need to drain. If the tty has become
null then the data is dropped anyway, likewise if there is no bound ldisc
to send it to.

> 2. Mark hungup to tty_struct created by tty_openi(), which will be cleaned
>    at the end of tty_open().

You shouldn't be looking at the tty structure, the tty structure is an
object whose lifetime is not aligned to your port. You should be looking
in the tty port structure.

Your port->ops->activate() is called at the point when your port is
activated, and you have other port methods to handle the other cases if
you need to synchronize with them.

Alan

  parent reply	other threads:[~2017-10-25 19:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-25  2:15 taoyuhong
2017-10-25  7:00 ` Greg KH
     [not found]   ` <5D766B1447A5304684CEC38F253A9297415D8B47@DGGEMA503-MBX.china.huawei.com>
2017-10-27  8:52     ` 答复: " Greg KH
2017-10-27  9:57       ` 答复: " taoyuhong
2017-10-25 19:25 ` Alan Cox [this message]
     [not found]   ` <5D766B1447A5304684CEC38F253A9297415D8B6F@DGGEMA503-MBX.china.huawei.com>
2017-10-26 14:31     ` Alan Cox
     [not found]       ` <5D766B1447A5304684CEC38F253A92974180F3A2@DGGEMA503-MBX.china.huawei.com>
2017-11-03 14:37         ` 答复: " gregkh

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=20171025202529.299d9c72@alans-desktop \
    --to=gnomes@lxorguk.ukuu.org.uk \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=taoyuhong@huawei.com \
    --cc=zhaoshenglong@huawei.com \
    /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

Powered by JetHome