All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] serial: 8250: Add flag so drivers can avoid probe
@ 2017-03-24  3:20 Joel Stanley
  2017-03-24  8:25 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Stanley @ 2017-03-24  3:20 UTC (permalink / raw)
  To: openbmc

The probe assumes the other end will be reading bytes out of the buffer
in order to probe the port at driver init. In some cases the other
end cannot be relied upon to read these bytes, so provide a flag for
them to skip this step.

Bit 16 was chosen as the flags are a int and the top bits are taken.

Signed-off-by: Joel Stanley <joel@jms.id.au>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 drivers/tty/serial/8250/8250_port.c | 2 +-
 drivers/tty/serial/aspeed-vuart.c   | 2 +-
 include/linux/serial_core.h         | 1 +
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 427dd789c0e5..90994e0389df 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -2167,7 +2167,7 @@ int serial8250_do_startup(struct uart_port *port)
 		serial_port_out(port, UART_LCR, 0);
 	}
 
-	if (port->irq) {
+	if (port->irq && !(up->port.flags & UPF_NO_THRE_TEST)) {
 		unsigned char iir1;
 		/*
 		 * Test for UARTs that do not reassert THRE when the
diff --git a/drivers/tty/serial/aspeed-vuart.c b/drivers/tty/serial/aspeed-vuart.c
index 42ccb380af41..b9559025d710 100644
--- a/drivers/tty/serial/aspeed-vuart.c
+++ b/drivers/tty/serial/aspeed-vuart.c
@@ -260,7 +260,7 @@ static int ast_vuart_probe(struct platform_device *pdev)
 	port.port.type = PORT_16550A;
 	port.port.uartclk = clk;
 	port.port.flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF
-		| UPF_FIXED_PORT | UPF_FIXED_TYPE;
+		| UPF_FIXED_PORT | UPF_FIXED_TYPE | UPF_NO_THRE_TEST;
 
 	if (of_find_property(np, "no-loopback-test", NULL))
 		port.port.flags |= UPF_SKIP_TEST;
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index a3d7c0d4a03e..2d1fb7423999 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -193,6 +193,7 @@ struct uart_port {
 #define UPF_NO_TXEN_TEST	((__force upf_t) (1 << 15))
 #define UPF_MAGIC_MULTIPLIER	((__force upf_t) ASYNC_MAGIC_MULTIPLIER /* 16 */ )
 
+#define UPF_NO_THRE_TEST	((__force upf_t) (1 << 19))
 /* Port has hardware-assisted h/w flow control */
 #define UPF_AUTO_CTS		((__force upf_t) (1 << 20))
 #define UPF_AUTO_RTS		((__force upf_t) (1 << 21))
-- 
2.11.0

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

* Re: [PATCH] serial: 8250: Add flag so drivers can avoid probe
  2017-03-24  3:20 [PATCH] serial: 8250: Add flag so drivers can avoid probe Joel Stanley
@ 2017-03-24  8:25 ` Benjamin Herrenschmidt
  2017-03-27 22:52   ` Joel Stanley
  0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Herrenschmidt @ 2017-03-24  8:25 UTC (permalink / raw)
  To: Joel Stanley, openbmc

On Fri, 2017-03-24 at 13:50 +1030, Joel Stanley wrote:
> The probe assumes the other end will be reading bytes out of the
> buffer
> in order to probe the port at driver init. In some cases the other
> end cannot be relied upon to read these bytes, so provide a flag for
> them to skip this step.
> 
> Bit 16 was chosen as the flags are a int and the top bits are taken.
> 
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

Only nit: "The probe" is unclear. "The probing of THRE irq behaviour"
would be more precise. There are other forms of probing in that
driver :-)

Cheers,
Ben.

> ---
>  drivers/tty/serial/8250/8250_port.c | 2 +-
>  drivers/tty/serial/aspeed-vuart.c   | 2 +-
>  include/linux/serial_core.h         | 1 +
>  3 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_port.c
> b/drivers/tty/serial/8250/8250_port.c
> index 427dd789c0e5..90994e0389df 100644
> --- a/drivers/tty/serial/8250/8250_port.c
> +++ b/drivers/tty/serial/8250/8250_port.c
> @@ -2167,7 +2167,7 @@ int serial8250_do_startup(struct uart_port
> *port)
>  		serial_port_out(port, UART_LCR, 0);
>  	}
>  
> -	if (port->irq) {
> +	if (port->irq && !(up->port.flags & UPF_NO_THRE_TEST)) {
>  		unsigned char iir1;
>  		/*
>  		 * Test for UARTs that do not reassert THRE when the
> diff --git a/drivers/tty/serial/aspeed-vuart.c
> b/drivers/tty/serial/aspeed-vuart.c
> index 42ccb380af41..b9559025d710 100644
> --- a/drivers/tty/serial/aspeed-vuart.c
> +++ b/drivers/tty/serial/aspeed-vuart.c
> @@ -260,7 +260,7 @@ static int ast_vuart_probe(struct platform_device
> *pdev)
>  	port.port.type = PORT_16550A;
>  	port.port.uartclk = clk;
>  	port.port.flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF
> -		| UPF_FIXED_PORT | UPF_FIXED_TYPE;
> +		| UPF_FIXED_PORT | UPF_FIXED_TYPE |
> UPF_NO_THRE_TEST;
>  
>  	if (of_find_property(np, "no-loopback-test", NULL))
>  		port.port.flags |= UPF_SKIP_TEST;
> diff --git a/include/linux/serial_core.h
> b/include/linux/serial_core.h
> index a3d7c0d4a03e..2d1fb7423999 100644
> --- a/include/linux/serial_core.h
> +++ b/include/linux/serial_core.h
> @@ -193,6 +193,7 @@ struct uart_port {
>  #define UPF_NO_TXEN_TEST	((__force upf_t) (1 << 15))
>  #define UPF_MAGIC_MULTIPLIER	((__force upf_t)
> ASYNC_MAGIC_MULTIPLIER /* 16 */ )
>  
> +#define UPF_NO_THRE_TEST	((__force upf_t) (1 << 19))
>  /* Port has hardware-assisted h/w flow control */
>  #define UPF_AUTO_CTS		((__force upf_t) (1 << 20))
>  #define UPF_AUTO_RTS		((__force upf_t) (1 << 21))

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

* Re: [PATCH] serial: 8250: Add flag so drivers can avoid probe
  2017-03-24  8:25 ` Benjamin Herrenschmidt
@ 2017-03-27 22:52   ` Joel Stanley
  0 siblings, 0 replies; 3+ messages in thread
From: Joel Stanley @ 2017-03-27 22:52 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: OpenBMC Maillist, Jeremy Kerr

On Fri, Mar 24, 2017 at 6:55 PM, Benjamin Herrenschmidt
<benh@kernel.crashing.org> wrote:
> On Fri, 2017-03-24 at 13:50 +1030, Joel Stanley wrote:
>> The probe assumes the other end will be reading bytes out of the
>> buffer
>> in order to probe the port at driver init. In some cases the other
>> end cannot be relied upon to read these bytes, so provide a flag for
>> them to skip this step.
>>
>> Bit 16 was chosen as the flags are a int and the top bits are taken.
>>
>> Signed-off-by: Joel Stanley <joel@jms.id.au>
>> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>
> Only nit: "The probe" is unclear. "The probing of THRE irq behaviour"
> would be more precise. There are other forms of probing in that
> driver :-)

Good clarification. I applied this to dev-4.7 with the fix to the
commit message you suggested.

The vuart driver has not been submitted upstream. I will send it out
with this fix included.

Cheers,

Joel

>
> Cheers,
> Ben.
>
>> ---
>>  drivers/tty/serial/8250/8250_port.c | 2 +-
>>  drivers/tty/serial/aspeed-vuart.c   | 2 +-
>>  include/linux/serial_core.h         | 1 +
>>  3 files changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/tty/serial/8250/8250_port.c
>> b/drivers/tty/serial/8250/8250_port.c
>> index 427dd789c0e5..90994e0389df 100644
>> --- a/drivers/tty/serial/8250/8250_port.c
>> +++ b/drivers/tty/serial/8250/8250_port.c
>> @@ -2167,7 +2167,7 @@ int serial8250_do_startup(struct uart_port
>> *port)
>>               serial_port_out(port, UART_LCR, 0);
>>       }
>>
>> -     if (port->irq) {
>> +     if (port->irq && !(up->port.flags & UPF_NO_THRE_TEST)) {
>>               unsigned char iir1;
>>               /*
>>                * Test for UARTs that do not reassert THRE when the
>> diff --git a/drivers/tty/serial/aspeed-vuart.c
>> b/drivers/tty/serial/aspeed-vuart.c
>> index 42ccb380af41..b9559025d710 100644
>> --- a/drivers/tty/serial/aspeed-vuart.c
>> +++ b/drivers/tty/serial/aspeed-vuart.c
>> @@ -260,7 +260,7 @@ static int ast_vuart_probe(struct platform_device
>> *pdev)
>>       port.port.type = PORT_16550A;
>>       port.port.uartclk = clk;
>>       port.port.flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF
>> -             | UPF_FIXED_PORT | UPF_FIXED_TYPE;
>> +             | UPF_FIXED_PORT | UPF_FIXED_TYPE |
>> UPF_NO_THRE_TEST;
>>
>>       if (of_find_property(np, "no-loopback-test", NULL))
>>               port.port.flags |= UPF_SKIP_TEST;
>> diff --git a/include/linux/serial_core.h
>> b/include/linux/serial_core.h
>> index a3d7c0d4a03e..2d1fb7423999 100644
>> --- a/include/linux/serial_core.h
>> +++ b/include/linux/serial_core.h
>> @@ -193,6 +193,7 @@ struct uart_port {
>>  #define UPF_NO_TXEN_TEST     ((__force upf_t) (1 << 15))
>>  #define UPF_MAGIC_MULTIPLIER ((__force upf_t)
>> ASYNC_MAGIC_MULTIPLIER /* 16 */ )
>>
>> +#define UPF_NO_THRE_TEST     ((__force upf_t) (1 << 19))
>>  /* Port has hardware-assisted h/w flow control */
>>  #define UPF_AUTO_CTS         ((__force upf_t) (1 << 20))
>>  #define UPF_AUTO_RTS         ((__force upf_t) (1 << 21))

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

end of thread, other threads:[~2017-03-27 22:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-24  3:20 [PATCH] serial: 8250: Add flag so drivers can avoid probe Joel Stanley
2017-03-24  8:25 ` Benjamin Herrenschmidt
2017-03-27 22:52   ` Joel Stanley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.