Re: [PATCH] serial: core: don't set console cflag to zero

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05/26/2015 09:37 PM, Duan Andy wrote:
> From: Peter Hurley <peter@xxxxxxxxxxxxxxxxxx>
>> On 05/26/2015 10:26 AM, Duan Andy wrote:
>>>> On 05/04/2015 03:56 AM, Fugang Duan wrote:
>>>>> From: "Fugang Duan" <B38611@xxxxxxxxxxxxx>
>>>>>
>>>>> In android without shell environment (androidboot.selinux enable),
>>>>> do suspend/resume test, console terminal has no message print out.
>>>>> The issue is reproduced at i.MX serial platforms like i.MX6Q/DL/SX.
>>>>>
>>>>> In common code, cons->cflag is cleared to zero in
>>>>> .uart_port_startup(), but after resume back, use the cons->cflag to
>>>>> set
>>>> termios.
>>>>> ......................
>>>>> uart_port_startup->
>>>>>     uport->cons->cflag = 0;
>>>>>
>>>>> uart_resume_port()->
>>>>>     termios.c_cflga = uport->cons->cflag;
>>>>>         ...
>>>>>     uport->ops->set_termios(uport, &termios, NULL);
>>>>> ......................
>>>>>
>>>>> If the console baud rate is 115200 bps, after Android resume back,
>>>>> the console baud rate is initialized to 9600 bps.  So the patch save
>>>>> the
>>>> console cflag.
>>>>>
>>>>> Signed-off-by: Fugang Duan <B38611@xxxxxxxxxxxxx>
>>>>> ---
>>>>>  drivers/tty/serial/serial_core.c |    5 ++---
>>>>>  1 files changed, 2 insertions(+), 3 deletions(-)
>>>>>
>>>>> diff --git a/drivers/tty/serial/serial_core.c
>>>>> b/drivers/tty/serial/serial_core.c
>>>>> index 0b7bb12..4b21091 100644
>>>>> --- a/drivers/tty/serial/serial_core.c
>>>>> +++ b/drivers/tty/serial/serial_core.c
>>>>> @@ -162,10 +162,9 @@ static int uart_port_startup(struct tty_struct
>>>>> *tty, struct uart_state *state,
>>>>>
>>>>>  	retval = uport->ops->startup(uport);
>>>>>  	if (retval == 0) {
>>>>> -		if (uart_console(uport) && uport->cons->cflag) {
>>>>> +		if (uart_console(uport) && uport->cons->cflag)
>>>>>  			tty->termios.c_cflag = uport->cons->cflag;
>>>>> -			uport->cons->cflag = 0;
>>>>
>>>> NAK. Please fix your userspace, which is opening the serial port used
>>>> by the console with incompatible line settings.
>>>
>>> In Android with shell environment, and there have no app to open the
> with -> without
>> serial port, how to fix it in userspace ?
>>
>> The only way that uart_port_startup() is called is if userspace opens the
>> serial port.
> 
> Thanks for your suggestion.  I don't know other vendor how to do it in Android without shell environment.
> Anyway, user space must open the serial port.

Let me explain how the line settings are handled when a serial console
has been specified on the command line.

Initially, the line settings are either inherited from the boot loader
or, if specified on the command line, initialized when the console is
registered.

When the tty used by the console is opened from userspace, it inherits
the line settings from the console. Simply opening the tty _does not_
change the line settings.

If system suspend/resume happens in this state, the current tty line
settings are used to restore the line state: these settings are still
_identical to the initial console settings_.

If the userspace process changes the line settings, the kernel driver
has no choice but to comply. For example, the user may lack the privileges
to change the kernel command line but has the necessary privileges to open
the serial port and may be correcting the line settings. Or, the user may
be reconfiguring the port for use with a modem, and the baud rate is too
high.

IOW, the userspace terminal line settings have higher priority than the
initial console line settings.

If system suspend/resume happens in this state, the current tty line
settings are used (which no longer match the initial console settings).
However, the driver was specifically commanded to do so because
userspace changed the line settings.

So again, you need to fix your userspace because it is setting the terminal
line settings to something other than the console settings.

Regards,
Peter Hurley
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux