linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] serial: 8250_early: simplify serial_putc()
@ 2015-10-24  4:17 Masahiro Yamada
  2015-10-24  4:17 ` [PATCH v2 1/2] serial: 8250_early: do not save and restore IER in write callback Masahiro Yamada
  2015-10-24  4:17 ` [PATCH v2 2/2] serial: 8250_early: squash wait_for_xmitr() into serial_putc() Masahiro Yamada
  0 siblings, 2 replies; 7+ messages in thread
From: Masahiro Yamada @ 2015-10-24  4:17 UTC (permalink / raw)
  To: linux-serial
  Cc: Masahiro Yamada, Vineet Gupta, Kevin Cernekee, Jiri Slaby,
	Rob Herring, Peter Hurley, linux-kernel, Wang Long,
	Greg Kroah-Hartman


Changes in v2:
  - split into two patches

Masahiro Yamada (2):
  serial: 8250_early: do not save and restore IER in write callback
  serial: 8250_early: squash wait_for_xmitr() into serial_putc()

 drivers/tty/serial/8250/8250_early.c | 20 ++------------------
 1 file changed, 2 insertions(+), 18 deletions(-)

-- 
1.9.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/2] serial: 8250_early: do not save and restore IER in write callback
  2015-10-24  4:17 [PATCH v2 0/2] serial: 8250_early: simplify serial_putc() Masahiro Yamada
@ 2015-10-24  4:17 ` Masahiro Yamada
  2015-10-27 13:54   ` Peter Hurley
  2015-10-24  4:17 ` [PATCH v2 2/2] serial: 8250_early: squash wait_for_xmitr() into serial_putc() Masahiro Yamada
  1 sibling, 1 reply; 7+ messages in thread
From: Masahiro Yamada @ 2015-10-24  4:17 UTC (permalink / raw)
  To: linux-serial
  Cc: Masahiro Yamada, Vineet Gupta, Kevin Cernekee, Jiri Slaby,
	Rob Herring, Peter Hurley, linux-kernel, Greg Kroah-Hartman

The IER has already been masked in early_serial8250_setup(), there is
no reason to save and restore it every time early_serial8250_write()
is called.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 drivers/tty/serial/8250/8250_early.c | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index 7aff3d8..559b681 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -99,20 +99,8 @@ static void __init early_serial8250_write(struct console *console,
 {
 	struct earlycon_device *device = console->data;
 	struct uart_port *port = &device->port;
-	unsigned int ier;
-
-	/* Save the IER and disable interrupts preserving the UUE bit */
-	ier = serial8250_early_in(port, UART_IER);
-	if (ier)
-		serial8250_early_out(port, UART_IER, ier & UART_IER_UUE);
 
 	uart_console_write(port, s, count, serial_putc);
-
-	/* Wait for transmitter to become empty and restore the IER */
-	wait_for_xmitr(port);
-
-	if (ier)
-		serial8250_early_out(port, UART_IER, ier);
 }
 
 static void __init init_port(struct earlycon_device *device)
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/2] serial: 8250_early: squash wait_for_xmitr() into serial_putc()
  2015-10-24  4:17 [PATCH v2 0/2] serial: 8250_early: simplify serial_putc() Masahiro Yamada
  2015-10-24  4:17 ` [PATCH v2 1/2] serial: 8250_early: do not save and restore IER in write callback Masahiro Yamada
@ 2015-10-24  4:17 ` Masahiro Yamada
  1 sibling, 0 replies; 7+ messages in thread
From: Masahiro Yamada @ 2015-10-24  4:17 UTC (permalink / raw)
  To: linux-serial
  Cc: Masahiro Yamada, Vineet Gupta, Kevin Cernekee, Jiri Slaby,
	Rob Herring, Peter Hurley, linux-kernel, Wang Long,
	Greg Kroah-Hartman

Now, wait_for_xmitr() is only called from serial_putc(), and both
are short enough.  They can be merged into a single function.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 drivers/tty/serial/8250/8250_early.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index 559b681..19aca19 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -76,21 +76,17 @@ static void __init serial8250_early_out(struct uart_port *port, int offset, int
 
 #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
 
-static void __init wait_for_xmitr(struct uart_port *port)
+static void __init serial_putc(struct uart_port *port, int c)
 {
 	unsigned int status;
 
 	for (;;) {
 		status = serial8250_early_in(port, UART_LSR);
 		if ((status & BOTH_EMPTY) == BOTH_EMPTY)
-			return;
+			break;
 		cpu_relax();
 	}
-}
 
-static void __init serial_putc(struct uart_port *port, int c)
-{
-	wait_for_xmitr(port);
 	serial8250_early_out(port, UART_TX, c);
 }
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] serial: 8250_early: do not save and restore IER in write callback
  2015-10-24  4:17 ` [PATCH v2 1/2] serial: 8250_early: do not save and restore IER in write callback Masahiro Yamada
@ 2015-10-27 13:54   ` Peter Hurley
  2015-10-28  3:27     ` Masahiro Yamada
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Hurley @ 2015-10-27 13:54 UTC (permalink / raw)
  To: Masahiro Yamada, linux-serial
  Cc: Vineet Gupta, Kevin Cernekee, Jiri Slaby, Rob Herring,
	linux-kernel, Greg Kroah-Hartman

Hi Masahiro,

On 10/24/2015 12:17 AM, Masahiro Yamada wrote:
> The IER has already been masked in early_serial8250_setup(), there is
> no reason to save and restore it every time early_serial8250_write()
> is called.
> 
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
> 
>  drivers/tty/serial/8250/8250_early.c | 12 ------------
>  1 file changed, 12 deletions(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
> index 7aff3d8..559b681 100644
> --- a/drivers/tty/serial/8250/8250_early.c
> +++ b/drivers/tty/serial/8250/8250_early.c
> @@ -99,20 +99,8 @@ static void __init early_serial8250_write(struct console *console,
>  {
>  	struct earlycon_device *device = console->data;
>  	struct uart_port *port = &device->port;
> -	unsigned int ier;
> -
> -	/* Save the IER and disable interrupts preserving the UUE bit */
> -	ier = serial8250_early_in(port, UART_IER);
> -	if (ier)
> -		serial8250_early_out(port, UART_IER, ier & UART_IER_UUE);
>  
>  	uart_console_write(port, s, count, serial_putc);



> -
> -	/* Wait for transmitter to become empty and restore the IER */
> -	wait_for_xmitr(port);

This wait_for_xmitr() change needs to be in patch 2/2.

Regards,
Peter Hurley

> -
> -	if (ier)
> -		serial8250_early_out(port, UART_IER, ier);
>  }
>  
>  static void __init init_port(struct earlycon_device *device)
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] serial: 8250_early: do not save and restore IER in write callback
  2015-10-27 13:54   ` Peter Hurley
@ 2015-10-28  3:27     ` Masahiro Yamada
  2015-10-28 14:36       ` Peter Hurley
  0 siblings, 1 reply; 7+ messages in thread
From: Masahiro Yamada @ 2015-10-28  3:27 UTC (permalink / raw)
  To: Peter Hurley
  Cc: linux-serial, Vineet Gupta, Kevin Cernekee, Jiri Slaby,
	Rob Herring, Linux Kernel Mailing List, Greg Kroah-Hartman

Hi Peter,

2015-10-27 22:54 GMT+09:00 Peter Hurley <peter@hurleysoftware.com>:
> Hi Masahiro,
>
> On 10/24/2015 12:17 AM, Masahiro Yamada wrote:
>> The IER has already been masked in early_serial8250_setup(), there is
>> no reason to save and restore it every time early_serial8250_write()
>> is called.
>>
>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>> ---
>>
>>  drivers/tty/serial/8250/8250_early.c | 12 ------------
>>  1 file changed, 12 deletions(-)
>>
>> diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
>> index 7aff3d8..559b681 100644
>> --- a/drivers/tty/serial/8250/8250_early.c
>> +++ b/drivers/tty/serial/8250/8250_early.c
>> @@ -99,20 +99,8 @@ static void __init early_serial8250_write(struct console *console,
>>  {
>>       struct earlycon_device *device = console->data;
>>       struct uart_port *port = &device->port;
>> -     unsigned int ier;
>> -
>> -     /* Save the IER and disable interrupts preserving the UUE bit */
>> -     ier = serial8250_early_in(port, UART_IER);
>> -     if (ier)
>> -             serial8250_early_out(port, UART_IER, ier & UART_IER_UUE);
>>
>>       uart_console_write(port, s, count, serial_putc);
>
>
>
>> -
>> -     /* Wait for transmitter to become empty and restore the IER */
>> -     wait_for_xmitr(port);
>
> This wait_for_xmitr() change needs to be in patch 2/2.
>


Why?

We no longer restore the IER.
We no longer have to wait here, either.



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] serial: 8250_early: do not save and restore IER in write callback
  2015-10-28  3:27     ` Masahiro Yamada
@ 2015-10-28 14:36       ` Peter Hurley
  2015-10-29  5:21         ` Masahiro Yamada
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Hurley @ 2015-10-28 14:36 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-serial, Vineet Gupta, Kevin Cernekee, Jiri Slaby,
	Rob Herring, Linux Kernel Mailing List, Greg Kroah-Hartman

On 10/27/2015 11:27 PM, Masahiro Yamada wrote:
> Hi Peter,
> 
> 2015-10-27 22:54 GMT+09:00 Peter Hurley <peter@hurleysoftware.com>:
>> Hi Masahiro,
>>
>> On 10/24/2015 12:17 AM, Masahiro Yamada wrote:
>>> The IER has already been masked in early_serial8250_setup(), there is
>>> no reason to save and restore it every time early_serial8250_write()
>>> is called.
>>>
>>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>>> ---
>>>
>>>  drivers/tty/serial/8250/8250_early.c | 12 ------------
>>>  1 file changed, 12 deletions(-)
>>>
>>> diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
>>> index 7aff3d8..559b681 100644
>>> --- a/drivers/tty/serial/8250/8250_early.c
>>> +++ b/drivers/tty/serial/8250/8250_early.c
>>> @@ -99,20 +99,8 @@ static void __init early_serial8250_write(struct console *console,
>>>  {
>>>       struct earlycon_device *device = console->data;
>>>       struct uart_port *port = &device->port;
>>> -     unsigned int ier;
>>> -
>>> -     /* Save the IER and disable interrupts preserving the UUE bit */
>>> -     ier = serial8250_early_in(port, UART_IER);
>>> -     if (ier)
>>> -             serial8250_early_out(port, UART_IER, ier & UART_IER_UUE);
>>>
>>>       uart_console_write(port, s, count, serial_putc);
>>
>>
>>
>>> -
>>> -     /* Wait for transmitter to become empty and restore the IER */
>>> -     wait_for_xmitr(port);
>>
>> This wait_for_xmitr() change needs to be in patch 2/2.
>>
> 
> 
> Why?

Because if someone reports a regression bisected to this commit,
we won't know if the regression is because we're not saving/restoring IER
or because the transmitter is still running.

Regards,
Peter Hurley


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] serial: 8250_early: do not save and restore IER in write callback
  2015-10-28 14:36       ` Peter Hurley
@ 2015-10-29  5:21         ` Masahiro Yamada
  0 siblings, 0 replies; 7+ messages in thread
From: Masahiro Yamada @ 2015-10-29  5:21 UTC (permalink / raw)
  To: Peter Hurley
  Cc: linux-serial, Vineet Gupta, Kevin Cernekee, Jiri Slaby,
	Rob Herring, Linux Kernel Mailing List, Greg Kroah-Hartman

2015-10-28 23:36 GMT+09:00 Peter Hurley <peter@hurleysoftware.com>:
> On 10/27/2015 11:27 PM, Masahiro Yamada wrote:
>> Hi Peter,
>>
>> 2015-10-27 22:54 GMT+09:00 Peter Hurley <peter@hurleysoftware.com>:
>>> Hi Masahiro,
>>>
>>> On 10/24/2015 12:17 AM, Masahiro Yamada wrote:
>>>> The IER has already been masked in early_serial8250_setup(), there is
>>>> no reason to save and restore it every time early_serial8250_write()
>>>> is called.
>>>>
>>>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>>>> ---
>>>>
>>>>  drivers/tty/serial/8250/8250_early.c | 12 ------------
>>>>  1 file changed, 12 deletions(-)
>>>>
>>>> diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
>>>> index 7aff3d8..559b681 100644
>>>> --- a/drivers/tty/serial/8250/8250_early.c
>>>> +++ b/drivers/tty/serial/8250/8250_early.c
>>>> @@ -99,20 +99,8 @@ static void __init early_serial8250_write(struct console *console,
>>>>  {
>>>>       struct earlycon_device *device = console->data;
>>>>       struct uart_port *port = &device->port;
>>>> -     unsigned int ier;
>>>> -
>>>> -     /* Save the IER and disable interrupts preserving the UUE bit */
>>>> -     ier = serial8250_early_in(port, UART_IER);
>>>> -     if (ier)
>>>> -             serial8250_early_out(port, UART_IER, ier & UART_IER_UUE);
>>>>
>>>>       uart_console_write(port, s, count, serial_putc);
>>>
>>>
>>>
>>>> -
>>>> -     /* Wait for transmitter to become empty and restore the IER */
>>>> -     wait_for_xmitr(port);
>>>
>>> This wait_for_xmitr() change needs to be in patch 2/2.
>>>
>>
>>
>> Why?
>
> Because if someone reports a regression bisected to this commit,
> we won't know if the regression is because we're not saving/restoring IER
> or because the transmitter is still running.
>

Good point.

I will send v3.
Thanks!



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-10-29  5:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-24  4:17 [PATCH v2 0/2] serial: 8250_early: simplify serial_putc() Masahiro Yamada
2015-10-24  4:17 ` [PATCH v2 1/2] serial: 8250_early: do not save and restore IER in write callback Masahiro Yamada
2015-10-27 13:54   ` Peter Hurley
2015-10-28  3:27     ` Masahiro Yamada
2015-10-28 14:36       ` Peter Hurley
2015-10-29  5:21         ` Masahiro Yamada
2015-10-24  4:17 ` [PATCH v2 2/2] serial: 8250_early: squash wait_for_xmitr() into serial_putc() Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).