* bluetooth cf slow (10KB/sec), lots of dmesg spam
@ 2009-11-29 15:58 Pavel Machek
2009-11-30 15:39 ` Alan Cox
0 siblings, 1 reply; 5+ messages in thread
From: Pavel Machek @ 2009-11-29 15:58 UTC (permalink / raw)
To: linux-bluetooth, Marcel Holtmann, kernel list
Hi!
I'm using CF bluetooth card:
toy:~# setserial -av /dev/ttyS0
/dev/ttyS0, Line 0, UART: 16950/954, Port: 0xc48202f8, IRQ: 201
Baud_base: 921600, close_delay: 50, divisor: 0
closing_wait: 3000
Flags: spd_normal skip_test
toy:~# hciconfig
hci0: Type: UART
BD Address: 00:10:60:AB:25:9A ACL MTU: 192:8 SCO MTU: 64:8
UP RUNNING PSCAN ISCAN
RX bytes:1612262 acl:5084 sco:0 events:3602 errors:0
TX bytes:507156 acl:3779 sco:0 commands:28 errors:0
...and it mostly works, but slowly, and with tons of complains. Card
is:
toy:~# lspcmcia -v
Socket 0 Bridge: [pxa2xx-pcmcia] (bus ID: pxa2xx-pcmcia)
Configuration: state: on ready: yes
Voltage: 3.3V Vcc: 3.3V Vpp: 0.0V
Socket 0 Device 0: [serial_cs] (bus ID: 0.0)
Configuration: state: on
Product Name: Compact Flash Bluetooth Card
Identification: manf_id: 0x0279 card_id: 0x950b
function: 2 (serial)
prod_id(1): "Compact Flash" (0x95521410)
prod_id(2): "Bluetooth Card" (0x7664fb1d)
prod_id(3): --- (---)
prod_id(4): --- (---)
I believe the problem is 115200 bitrate between system and CF serial;
I did setserial baud_base 921600, but that does not seem to speed it
up. Do I need to do some special magic to enable high speed?
Any ideas?
Pavel
PM: Adding info for No Bus:hci0
bcsp_recv: Out-of-order packet arrived, got 1 expected 0
PM: Adding info for No Bus:rfcomm1
PM: Adding info for No Bus:hci0:41
PM: Adding info for No Bus:bnep0
bcsp_recv: Short BCSP packet
bcsp_recv: Out-of-order packet arrived, got 5 expected 4
bcsp_recv: Out-of-order packet arrived, got 6 expected 4
SysRq : Changing Loglevel
Loglevel set to 1
bcsp_recv: Short BCSP packet
bcsp_recv: Out-of-order packet arrived, got 1 expected 0
bcsp_recv: Out-of-order packet arrived, got 2 expected 0
bcsp_recv: Out-of-order packet arrived, got 3 expected 0
bcsp_recv: Short BCSP packet
...
bcsp_recv: Out-of-order packet arrived, got 2 expected 7
bcsp_recv: Short BCSP packet
bcsp_recv: Out-of-order packet arrived, got 7 expected 6
bcsp_recv: Out-of-order packet arrived, got 0 expected 6
bcsp_recv: Out-of-order packet arrived, got 1 expected 6
bcsp_recv: Short BCSP packet
bcsp_recv: Error in BCSP hdr checksum
bcsp_recv: Out-of-order packet arrived, got 4 expected 2
bcsp_recv: Out-of-order packet arrived, got 5 expected 2
bcsp_recv: Short BCSP packet
bcsp_recv: Out-of-order packet arrived, got 2 expected 1
bcsp_recv: Out-of-order packet arrived, got 3 expected 1
bcsp_recv: Out-of-order packet arrived, got 4 expected 1
bcsp_unslip_one_byte: Invalid byte 00 after esc byte
bcsp_recv: Out-of-order packet arrived, got 4 expected 3
bcsp_recv: Out-of-order packet arrived, got 5 expected 3
bcsp_recv: Out-of-order packet arrived, got 6 expected 3
bcsp_recv: Short BCSP packet
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: bluetooth cf slow (10KB/sec), lots of dmesg spam
2009-11-30 15:39 ` Alan Cox
@ 2009-11-29 16:44 ` Pavel Machek
2009-11-30 23:57 ` Alan Cox
0 siblings, 1 reply; 5+ messages in thread
From: Pavel Machek @ 2009-11-29 16:44 UTC (permalink / raw)
To: Alan Cox; +Cc: linux-bluetooth, Marcel Holtmann, kernel list
Hi!
> > I believe the problem is 115200 bitrate between system and CF serial;
>
> and lack of flow control I assume ?
I guess so. (But flow control can be hard for bluetooth, I guess. Data
are coming from the air...)
> > I did setserial baud_base 921600, but that does not seem to speed it
> > up. Do I need to do some special magic to enable high speed?
>
> Just set the baud rate to 921600. You may need to write an app to do this
> directly via the TERMIOS2 ioctl because it seems three years ago is a bit
> quick for the glibc maintainers to keep up.
>
> Basically set the baud to BOTHER, set the ispeed = ospeed = 921600 and
> the kernel will do its best to give you your request
hciattach seems to do this:
...
open("/dev/ttyBT", O_RDWR|O_NOCTTY) = 3
ioctl(3, TCFLSH, 0x2) = 0
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 -opost -isig -icanon -echo ...}) = 0
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 -opost -isig -icanon -echo ...}) = 0
ioctl(3, SNDCTL_TMR_START or TCSETS, {B115200 -opost -isig -icanon -echo ...}) = 0
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 -opost -isig -icanon -echo ...}) = 0
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 -opost -isig -icanon -echo ...}) = 0
ioctl(3, SNDCTL_TMR_START or TCSETS, {B921600 -opost -isig -icanon -echo ...}) = 0
...set 921K using TCSETS/B921600... and kernel says ok, but ...
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 -opost -isig -icanon -echo ...}) = 0
ioctl(3, TCFLSH, 0x2) = 0
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 -opost -isig -icanon -echo ...}) = 0
...we are still at 115200... I wonder if 921600 is the right speed to
use after all? Any other speeds I should try? (and can 400MHz arm
handle 921K on serial line?)
...when I was setting 921600 baud_base, I basically broke it so that
it used 115200, right? I guess I should play a bit more...
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: bluetooth cf slow (10KB/sec), lots of dmesg spam
2009-11-29 15:58 bluetooth cf slow (10KB/sec), lots of dmesg spam Pavel Machek
@ 2009-11-30 15:39 ` Alan Cox
2009-11-29 16:44 ` Pavel Machek
0 siblings, 1 reply; 5+ messages in thread
From: Alan Cox @ 2009-11-30 15:39 UTC (permalink / raw)
To: Pavel Machek; +Cc: linux-bluetooth, Marcel Holtmann, kernel list
> I believe the problem is 115200 bitrate between system and CF serial;
and lack of flow control I assume ?
> I did setserial baud_base 921600, but that does not seem to speed it
> up. Do I need to do some special magic to enable high speed?
Just set the baud rate to 921600. You may need to write an app to do this
directly via the TERMIOS2 ioctl because it seems three years ago is a bit
quick for the glibc maintainers to keep up.
Basically set the baud to BOTHER, set the ispeed = ospeed = 921600 and
the kernel will do its best to give you your request
Alan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: bluetooth cf slow (10KB/sec), lots of dmesg spam
2009-11-29 16:44 ` Pavel Machek
@ 2009-11-30 23:57 ` Alan Cox
2009-12-01 12:37 ` Pavel Machek
0 siblings, 1 reply; 5+ messages in thread
From: Alan Cox @ 2009-11-30 23:57 UTC (permalink / raw)
To: Pavel Machek; +Cc: linux-bluetooth, Marcel Holtmann, kernel list
> ioctl(3, SNDCTL_TMR_START or TCSETS, {B921600 -opost -isig -icanon -echo ...}) = 0
It's certainly trying
>
> ...set 921K using TCSETS/B921600... and kernel says ok, but ...
Careful: termios is one of those "gotcha" ioctls. It returns 0 to say
"stuff happened" and returns a termios struct which contains the results
- which may not be what you requested.
So a set to an unsupported rate (too high for the chip clock) will
produce a response of 0 and return the baud rate you actually got given.
> ...we are still at 115200... I wonder if 921600 is the right speed to
> use after all? Any other speeds I should try? (and can 400MHz arm
> handle 921K on serial line?)
It's pushing it on an x86 with a 16550A. You've got about 14 character
times of worst case latency permitted and 14 x 10 bits isn't a lot at
that rate. Some of the clones have much bigger FIFOs so it may depend
what you actually have.
Alan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: bluetooth cf slow (10KB/sec), lots of dmesg spam
2009-11-30 23:57 ` Alan Cox
@ 2009-12-01 12:37 ` Pavel Machek
0 siblings, 0 replies; 5+ messages in thread
From: Pavel Machek @ 2009-12-01 12:37 UTC (permalink / raw)
To: Alan Cox; +Cc: linux-bluetooth, Marcel Holtmann, kernel list
On Mon 2009-11-30 23:57:39, Alan Cox wrote:
> > ioctl(3, SNDCTL_TMR_START or TCSETS, {B921600 -opost -isig -icanon -echo ...}) = 0
>
> It's certainly trying
> >
> > ...set 921K using TCSETS/B921600... and kernel says ok, but ...
>
> Careful: termios is one of those "gotcha" ioctls. It returns 0 to say
> "stuff happened" and returns a termios struct which contains the results
> - which may not be what you requested.
>
> So a set to an unsupported rate (too high for the chip clock) will
> produce a response of 0 and return the baud rate you actually got
> given.
Ok, that part seems to work.
> > ...we are still at 115200... I wonder if 921600 is the right speed to
> > use after all? Any other speeds I should try? (and can 400MHz arm
> > handle 921K on serial line?)
>
> It's pushing it on an x86 with a 16550A. You've got about 14 character
> times of worst case latency permitted and 14 x 10 bits isn't a lot at
> that rate. Some of the clones have much bigger FIFOs so it may depend
> what you actually have.
/dev/ttyBT, Line 0, UART: 16950/954, Port: 0x9100, IRQ: 16
...so hopefully it has bigger buffers.
This patch was flying around for about forever and seems vaguely
related, but... the card seems to only be detected with divisor of 8,
not even divisor of 1 seems to work :-(.
Pavel
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 737b4c9..8540343 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -7,6 +7,9 @@
*
* Copyright (C) 2001 Russell King.
*
+ * 2005/09/16: Enabled higher baud rates for 16C95x.
+ * (Mathias Adam <a2@adamis.de>)
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -2229,6 +2232,14 @@ static unsigned int serial8250_get_divisor(struct uart_port *port, unsigned int
else if ((port->flags & UPF_MAGIC_MULTIPLIER) &&
baud == (port->uartclk/8))
quot = 0x8002;
+ /*
+ * For 16C950s UART_TCR is used in combination with divisor==1
+ * to achieve baud rates up to baud_base*4.
+ */
+ else if ((port->type == PORT_16C950) &&
+ baud > (port->uartclk/16))
+ quot = 1;
+
else
quot = uart_get_divisor(port, baud);
@@ -2242,7 +2253,7 @@ serial8250_set_termios(struct uart_port *port, struct ktermios *termios,
struct uart_8250_port *up = (struct uart_8250_port *)port;
unsigned char cval, fcr = 0;
unsigned long flags;
- unsigned int baud, quot;
+ unsigned int baud, quot, max_baud;
switch (termios->c_cflag & CSIZE) {
case CS5:
@@ -2274,9 +2285,11 @@ serial8250_set_termios(struct uart_port *port, struct ktermios *termios,
/*
* Ask the core to calculate the divisor for us.
*/
- baud = uart_get_baud_rate(port, termios, old,
- port->uartclk / 16 / 0xffff,
- port->uartclk / 16);
+ max_baud = port->uartclk/16;
+ if (up->port.type == PORT_16C950)
+ max_baud = port->uartclk/4;
+ baud = uart_get_baud_rate(port, termios, old, max_baud / 0xffff,
+ max_baud / 16);
quot = serial8250_get_divisor(port, baud);
/*
@@ -2313,6 +2326,19 @@ serial8250_set_termios(struct uart_port *port, struct ktermios *termios,
spin_lock_irqsave(&up->port.lock, flags);
/*
+ * 16C950 supports additional prescaler ratios between 1:16 and 1:4
+ * thus increasing max baud rate to uartclk/4.
+ */
+ if (up->port.type == PORT_16C950) {
+ if (baud == port->uartclk/4)
+ serial_icr_write(up, UART_TCR, 0x4);
+ else if (baud == port->uartclk/8)
+ serial_icr_write(up, UART_TCR, 0x8);
+ else
+ serial_icr_write(up, UART_TCR, 0);
+ }
+
+ /*
* Update the per-port timeout.
*/
uart_update_timeout(port, termios->c_cflag, baud);
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-12-01 12:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-29 15:58 bluetooth cf slow (10KB/sec), lots of dmesg spam Pavel Machek
2009-11-30 15:39 ` Alan Cox
2009-11-29 16:44 ` Pavel Machek
2009-11-30 23:57 ` Alan Cox
2009-12-01 12:37 ` Pavel Machek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox