public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Wessel <jason.wessel@windriver.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: gregkh@suse.de, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] usb console,usb-serial: pass initial console baud on to first tty open
Date: Wed, 16 Sep 2009 23:17:36 -0500	[thread overview]
Message-ID: <4AB1B860.4080105@windriver.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0909162344350.24376-100000@netrider.rowland.org>

Alan Stern wrote:
> On Wed, 16 Sep 2009, Jason Wessel wrote:
>
>   
>> Alan Stern wrote:
>>     
>>> On Wed, 16 Sep 2009, Jason Wessel wrote:
>>>
>>>   
>>>       
>>>> The first open of the usb serial HW has the termios initialized to the
>>>> default of 9600 baud, and this will override what ever was setup via
>>>> the original console initialization.
>>>>     
>>>>         
>>> I don't understand.  The first open of the console hardware occurs in 
>>> console.c as part of usb_console_setup(), and it uses the baud rate 
>>> passed in via the console options.  Why does anything need to get 
>>> saved?
>>>   
>>>       
>> The initialization in console.c is done with a dummy tty structure that
>> is thrown away.  It is thrown away because it was not connected to any
>> device handle.
>>
>> Any new tty that is opened defaults to 9600 baud, for the mct_u232
>> driver as an example, if you boot the system with
>> console=ttyUSB0,115200, when mingetty starts it will inherit 9600 from
>> the first tty that is opened, vs reading the value from the HW.  Even if
>> you have a pl2303 and boot with the 115200 baud, you can run "stty -a <
>> /dev/ttyUSB0" and you will see it reports it is running at 9600.  The
>> pl2303 driver just happens to work because it handles the baud differently.
>>
>> I elected to save the baud because:
>>
>> 1) There was no uniform interface to read the current baud from the usb
>> hardware
>>
>> 2) There was no documented API for getting tty to attach when you create
>> the initial console.
>>
>> If there is a better way to fix this, it would be good to continue the
>> discussion.
>>     
>
> I guess a better approach would be not to throw away the "dummy" tty 
> structure, thereby keeping the termios structure as well.  But I don't 
> know if this is practical.
>
> How do other serial console drivers handle this?
>
>   

My answer goes back to the point #1.

If we take the 8250 driver for example,  it reads the HW and force sets
the baud into the termios structure of the real tty.   There are several
layers but in the example case in 8250.c, the serial8250_set_termios()
calls uart_get_baud_rate() to establish "the baud rate to use".

As far as I could tell even the uart based serial drivers use a dummy
termios structure for the initial setup of the console, but do so with
stack memory instead of heap memory.

It looked like the API for the tty subsystem was gradually changing such
that the ldisc structure could ultimately get shared for use with the
console, but this work is not complete, so we are somewhere in between.

The question is what is an acceptable solution?

Depending on the route you go you could modify part of the tty
subsystem, the high level usb serial API to work similarly to the uart
based serial api.

Jason.


  reply	other threads:[~2009-09-17  4:17 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-17  3:08 [PATCH 0/3] usb console: 2.6.32 regression fixes Jason Wessel
2009-09-17  3:08 ` [PATCH 1/3] usb console: fix mutex lock regression Jason Wessel
2009-09-17  3:08   ` [PATCH 2/3] usb console,usb-serial: fix regression use of serial->console Jason Wessel
2009-09-17  3:08     ` [PATCH 3/3] usb console,usb-serial: pass initial console baud on to first tty open Jason Wessel
2009-09-17  3:32       ` Alan Stern
2009-09-17  3:40         ` Jason Wessel
2009-09-17  3:46           ` Alan Stern
2009-09-17  4:17             ` Jason Wessel [this message]
2009-09-17  9:14               ` Alan Cox
2009-09-17 12:16                 ` Jason Wessel
2009-09-17 13:08                   ` Alan Cox
2009-09-17 13:19                     ` Alan Cox
2009-09-17 14:17                       ` Jason Wessel
2009-09-17 16:02                         ` Alan Cox
2009-09-22 20:54                           ` Jason Wessel
2009-09-29 17:24                             ` How to handle console devices Alan Stern
2009-09-29 22:47                               ` Alan Cox
2009-09-17  3:30     ` [PATCH 2/3] usb console,usb-serial: fix regression use of serial->console Alan Stern
2009-09-17  3:32       ` Jason Wessel
2009-09-17  3:25   ` [PATCH 1/3] usb console: fix mutex lock regression Alan Stern
2009-09-17  3:32     ` Jason Wessel
2009-09-18 17:16     ` Greg KH

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=4AB1B860.4080105@windriver.com \
    --to=jason.wessel@windriver.com \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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