linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/1] Revert "serial: 8250: Fix max baud limit in generic 8250 port"
@ 2020-07-01 21:13 Daniel Winkler
  2020-07-01 21:13 ` [PATCH v2 1/1] " Daniel Winkler
  2020-07-01 22:37 ` [PATCH v2 0/1] " Serge Semin
  0 siblings, 2 replies; 7+ messages in thread
From: Daniel Winkler @ 2020-07-01 21:13 UTC (permalink / raw)
  To: linux-serial, linux-mediatek, Serge Semin, Alexey Malahov
  Cc: BlueZ, chromeos-bluetooth-upstreaming, stable, abhishekpandit,
	Daniel Winkler, Aaron Sierra, Andy Shevchenko,
	Greg Kroah-Hartman, Jiri Slaby, Lukas Wunner,
	Vignesh Raghavendra, linux-kernel


This change regresses the QCA6174A-3 bluetooth chip, preventing
firmware from being properly loaded. Without this change, the
chip works as intended.

The device is the Kukui Chromebook using the Mediatek chipset
and the 8250_mtk uart. Initial controller baudrate is 115200
and operating speed is 3000000. Our entire suite of bluetooth
tests now fail on this platform due to an apparent failure to
sync its firmware on initialization.

The driver is in the cros tree at drivers/bluetooth/hci_qca.c
and uses the serdev interface. Specifically, this is the
QCA_ROME chipset.


Daniel Winkler (1):
  Revert "serial: 8250: Fix max baud limit in generic 8250 port"

 drivers/tty/serial/8250/8250_port.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

-- 
2.27.0.212.ge8ba1cc988-goog


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

* [PATCH v2 1/1] Revert "serial: 8250: Fix max baud limit in generic 8250 port"
  2020-07-01 21:13 [PATCH v2 0/1] Revert "serial: 8250: Fix max baud limit in generic 8250 port" Daniel Winkler
@ 2020-07-01 21:13 ` Daniel Winkler
  2020-07-02  7:36   ` Greg Kroah-Hartman
  2020-07-01 22:37 ` [PATCH v2 0/1] " Serge Semin
  1 sibling, 1 reply; 7+ messages in thread
From: Daniel Winkler @ 2020-07-01 21:13 UTC (permalink / raw)
  To: linux-serial, linux-mediatek, Serge Semin, Alexey Malahov
  Cc: BlueZ, chromeos-bluetooth-upstreaming, stable, abhishekpandit,
	Daniel Winkler, Aaron Sierra, Andy Shevchenko,
	Greg Kroah-Hartman, Jiri Slaby, Lukas Wunner,
	Vignesh Raghavendra, linux-kernel

This reverts commit 7b668c064ec33f3d687c3a413d05e355172e6c92.

Fixes: 7b668c064ec3 ("serial: 8250: Fix max baud limit in generic 8250
port")
Cc: stable@vger.kernel.org
Signed-off-by: Daniel Winkler <danielwinkler@google.com>
---

 drivers/tty/serial/8250/8250_port.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 1632f7d25acca..e057c65ac1580 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -2618,8 +2618,6 @@ static unsigned int serial8250_get_baud_rate(struct uart_port *port,
 					     struct ktermios *termios,
 					     struct ktermios *old)
 {
-	unsigned int tolerance = port->uartclk / 100;
-
 	/*
 	 * Ask the core to calculate the divisor for us.
 	 * Allow 1% tolerance at the upper limit so uart clks marginally
@@ -2628,7 +2626,7 @@ static unsigned int serial8250_get_baud_rate(struct uart_port *port,
 	 */
 	return uart_get_baud_rate(port, termios, old,
 				  port->uartclk / 16 / UART_DIV_MAX,
-				  (port->uartclk + tolerance) / 16);
+				  port->uartclk);
 }
 
 void
-- 
2.27.0.212.ge8ba1cc988-goog


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

* Re: [PATCH v2 0/1] Revert "serial: 8250: Fix max baud limit in generic 8250 port"
  2020-07-01 21:13 [PATCH v2 0/1] Revert "serial: 8250: Fix max baud limit in generic 8250 port" Daniel Winkler
  2020-07-01 21:13 ` [PATCH v2 1/1] " Daniel Winkler
@ 2020-07-01 22:37 ` Serge Semin
  2020-07-02  4:11   ` Lukas Wunner
  2020-07-02  7:37   ` Greg Kroah-Hartman
  1 sibling, 2 replies; 7+ messages in thread
From: Serge Semin @ 2020-07-01 22:37 UTC (permalink / raw)
  To: Daniel Winkler
  Cc: Serge Semin, linux-serial, linux-mediatek, Alexey Malahov, BlueZ,
	chromeos-bluetooth-upstreaming, stable, abhishekpandit,
	Aaron Sierra, Andy Shevchenko, Greg Kroah-Hartman, Jiri Slaby,
	Lukas Wunner, Vignesh Raghavendra, linux-kernel

On Wed, Jul 01, 2020 at 02:13:36PM -0700, Daniel Winkler wrote:
> 
> This change regresses the QCA6174A-3 bluetooth chip, preventing
> firmware from being properly loaded. Without this change, the
> chip works as intended.
> 
> The device is the Kukui Chromebook using the Mediatek chipset
> and the 8250_mtk uart. Initial controller baudrate is 115200
> and operating speed is 3000000. Our entire suite of bluetooth
> tests now fail on this platform due to an apparent failure to
> sync its firmware on initialization.

Ok. It's mediatek 8250 driver, which is responsible for the failure.
Then we'll have two options:

1) Add a new capability like UART_CAP_NO16DIV and take it into account
   in the serial8250_get_baud_rate() method.
 
I don't have a documentation for the Mediatek UART port, but it seems to me
that that controller calculates the baud rate differently from the standard
8250 port. A standard 8250 port does that by the next formulae:
  baud = uartclk / (16 * divisor).
While it seems to me that the Mediatek port uses the formulae like:
  baud = uartclk / divisor. (Please, correct me if I'm wrong)
If so, then we could introduce a new capability like UART_CAP_NO16DIV. The
8250_mtk driver will add it to the 8250-port capabilities field. The
serial8250_get_baud_rate() method should be altered in a way so one would check
whether the UART_CAP_NO16DIV flag is set and if it is then the
uart_get_baud_rate() function will be called without uartclk normalized by the
factor of 16.

2) Manually call serial8250_do_set_divisor() in the custom set_termios()
   callback.

Just add the uart_update_timeout() and serial8250_do_set_divisor() methods
invocation into the mtk8250_set_termios() function, which the original commit
81bb549fdf14 ("serial: 8250_mtk: support big baud rate") author should have
done in the first place.

-Sergey

> 
> The driver is in the cros tree at drivers/bluetooth/hci_qca.c
> and uses the serdev interface. Specifically, this is the
> QCA_ROME chipset.
> 
> 
> Daniel Winkler (1):
>   Revert "serial: 8250: Fix max baud limit in generic 8250 port"
> 
>  drivers/tty/serial/8250/8250_port.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> -- 
> 2.27.0.212.ge8ba1cc988-goog
> 

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

* Re: [PATCH v2 0/1] Revert "serial: 8250: Fix max baud limit in generic 8250 port"
  2020-07-01 22:37 ` [PATCH v2 0/1] " Serge Semin
@ 2020-07-02  4:11   ` Lukas Wunner
  2020-07-02  8:46     ` Andy Shevchenko
  2020-07-02  7:37   ` Greg Kroah-Hartman
  1 sibling, 1 reply; 7+ messages in thread
From: Lukas Wunner @ 2020-07-02  4:11 UTC (permalink / raw)
  To: Serge Semin
  Cc: Daniel Winkler, Serge Semin, linux-serial, linux-mediatek,
	Alexey Malahov, BlueZ, chromeos-bluetooth-upstreaming, stable,
	abhishekpandit, Aaron Sierra, Andy Shevchenko,
	Greg Kroah-Hartman, Jiri Slaby, Vignesh Raghavendra,
	linux-kernel

On Thu, Jul 02, 2020 at 01:37:13AM +0300, Serge Semin wrote:
> 1) Add a new capability like UART_CAP_NO16DIV and take it into account
>    in the serial8250_get_baud_rate() method.
>  
> I don't have a documentation for the Mediatek UART port, but it seems to me
> that that controller calculates the baud rate differently from the standard
> 8250 port. A standard 8250 port does that by the next formulae:
>   baud = uartclk / (16 * divisor).
> While it seems to me that the Mediatek port uses the formulae like:
>   baud = uartclk / divisor. (Please, correct me if I'm wrong)

8250_bcm2835aux.c seems to suffer from a similar issue and
solves it like this in the ->probe hook:

	/* the HW-clock divider for bcm2835aux is 8,
	 * but 8250 expects a divider of 16,
	 * so we have to multiply the actual clock by 2
	 * to get identical baudrates.
	 */
	up.port.uartclk = clk_get_rate(data->clk) * 2;


> 2) Manually call serial8250_do_set_divisor() in the custom set_termios()
>    callback.
> 
> Just add the uart_update_timeout() and serial8250_do_set_divisor() methods
> invocation into the mtk8250_set_termios() function, which the original commit
> 81bb549fdf14 ("serial: 8250_mtk: support big baud rate") author should have
> done in the first place.

That sound preferable as adding new quirks into core code feels
like a case of midlayer fallacy:

https://blog.ffwll.ch/2016/12/midlayers-once-more-with-feeling.html

Thanks,

Lukas

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

* Re: [PATCH v2 1/1] Revert "serial: 8250: Fix max baud limit in generic 8250 port"
  2020-07-01 21:13 ` [PATCH v2 1/1] " Daniel Winkler
@ 2020-07-02  7:36   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 7+ messages in thread
From: Greg Kroah-Hartman @ 2020-07-02  7:36 UTC (permalink / raw)
  To: Daniel Winkler
  Cc: linux-serial, linux-mediatek, Serge Semin, Alexey Malahov, BlueZ,
	chromeos-bluetooth-upstreaming, stable, abhishekpandit,
	Aaron Sierra, Andy Shevchenko, Jiri Slaby, Lukas Wunner,
	Vignesh Raghavendra, linux-kernel

On Wed, Jul 01, 2020 at 02:13:37PM -0700, Daniel Winkler wrote:
> This reverts commit 7b668c064ec33f3d687c3a413d05e355172e6c92.
> 

I need a reason _why_ to revert this in the changelog text.  Your 0/1
comments would be great to see in here, otherwise I have no idea what is
going on when I look at the kernel changelog in the future.

> Fixes: 7b668c064ec3 ("serial: 8250: Fix max baud limit in generic 8250
> port")

Nit, in the future, this line does not need to be wrapped at all, just
let it go the full length please.

thanks,

greg k-h

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

* Re: [PATCH v2 0/1] Revert "serial: 8250: Fix max baud limit in generic 8250 port"
  2020-07-01 22:37 ` [PATCH v2 0/1] " Serge Semin
  2020-07-02  4:11   ` Lukas Wunner
@ 2020-07-02  7:37   ` Greg Kroah-Hartman
  1 sibling, 0 replies; 7+ messages in thread
From: Greg Kroah-Hartman @ 2020-07-02  7:37 UTC (permalink / raw)
  To: Serge Semin
  Cc: Daniel Winkler, Serge Semin, linux-serial, linux-mediatek,
	Alexey Malahov, BlueZ, chromeos-bluetooth-upstreaming, stable,
	abhishekpandit, Aaron Sierra, Andy Shevchenko, Jiri Slaby,
	Lukas Wunner, Vignesh Raghavendra, linux-kernel

On Thu, Jul 02, 2020 at 01:37:13AM +0300, Serge Semin wrote:
> On Wed, Jul 01, 2020 at 02:13:36PM -0700, Daniel Winkler wrote:
> > 
> > This change regresses the QCA6174A-3 bluetooth chip, preventing
> > firmware from being properly loaded. Without this change, the
> > chip works as intended.
> > 
> > The device is the Kukui Chromebook using the Mediatek chipset
> > and the 8250_mtk uart. Initial controller baudrate is 115200
> > and operating speed is 3000000. Our entire suite of bluetooth
> > tests now fail on this platform due to an apparent failure to
> > sync its firmware on initialization.
> 
> Ok. It's mediatek 8250 driver, which is responsible for the failure.
> Then we'll have two options:
> 
> 1) Add a new capability like UART_CAP_NO16DIV and take it into account
>    in the serial8250_get_baud_rate() method.
>  
> I don't have a documentation for the Mediatek UART port, but it seems to me
> that that controller calculates the baud rate differently from the standard
> 8250 port. A standard 8250 port does that by the next formulae:
>   baud = uartclk / (16 * divisor).
> While it seems to me that the Mediatek port uses the formulae like:
>   baud = uartclk / divisor. (Please, correct me if I'm wrong)
> If so, then we could introduce a new capability like UART_CAP_NO16DIV. The
> 8250_mtk driver will add it to the 8250-port capabilities field. The
> serial8250_get_baud_rate() method should be altered in a way so one would check
> whether the UART_CAP_NO16DIV flag is set and if it is then the
> uart_get_baud_rate() function will be called without uartclk normalized by the
> factor of 16.
> 
> 2) Manually call serial8250_do_set_divisor() in the custom set_termios()
>    callback.
> 
> Just add the uart_update_timeout() and serial8250_do_set_divisor() methods
> invocation into the mtk8250_set_termios() function, which the original commit
> 81bb549fdf14 ("serial: 8250_mtk: support big baud rate") author should have
> done in the first place.

Sounds like a sane fix, thanks for looking into this.

greg k-h

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

* Re: [PATCH v2 0/1] Revert "serial: 8250: Fix max baud limit in generic 8250 port"
  2020-07-02  4:11   ` Lukas Wunner
@ 2020-07-02  8:46     ` Andy Shevchenko
  0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2020-07-02  8:46 UTC (permalink / raw)
  To: Lukas Wunner
  Cc: Serge Semin, Daniel Winkler, Serge Semin, linux-serial,
	linux-mediatek, Alexey Malahov, BlueZ,
	chromeos-bluetooth-upstreaming, stable, abhishekpandit,
	Aaron Sierra, Greg Kroah-Hartman, Jiri Slaby,
	Vignesh Raghavendra, linux-kernel

On Thu, Jul 02, 2020 at 06:11:52AM +0200, Lukas Wunner wrote:
> On Thu, Jul 02, 2020 at 01:37:13AM +0300, Serge Semin wrote:
> > 1) Add a new capability like UART_CAP_NO16DIV and take it into account
> >    in the serial8250_get_baud_rate() method.
> >  
> > I don't have a documentation for the Mediatek UART port, but it seems to me
> > that that controller calculates the baud rate differently from the standard
> > 8250 port. A standard 8250 port does that by the next formulae:
> >   baud = uartclk / (16 * divisor).
> > While it seems to me that the Mediatek port uses the formulae like:
> >   baud = uartclk / divisor. (Please, correct me if I'm wrong)
> 
> 8250_bcm2835aux.c seems to suffer from a similar issue and
> solves it like this in the ->probe hook:
> 
> 	/* the HW-clock divider for bcm2835aux is 8,
> 	 * but 8250 expects a divider of 16,
> 	 * so we have to multiply the actual clock by 2
> 	 * to get identical baudrates.
> 	 */
> 	up.port.uartclk = clk_get_rate(data->clk) * 2;

8250_mid for example lies about UART clock due to this. It has a comment in the
code in its ->set_termios().

Yes, we have a lot of possibilities here to fix, I guess. We have custom
termios callback, also get and set divisor and so on.

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2020-07-02  8:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-01 21:13 [PATCH v2 0/1] Revert "serial: 8250: Fix max baud limit in generic 8250 port" Daniel Winkler
2020-07-01 21:13 ` [PATCH v2 1/1] " Daniel Winkler
2020-07-02  7:36   ` Greg Kroah-Hartman
2020-07-01 22:37 ` [PATCH v2 0/1] " Serge Semin
2020-07-02  4:11   ` Lukas Wunner
2020-07-02  8:46     ` Andy Shevchenko
2020-07-02  7:37   ` Greg Kroah-Hartman

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).