bluetooth cf slow (10KB/sec), lots of dmesg spam
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:hci0bcsp_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:bnep0bcsp_recv: Short BCSP packetbcsp_recv: Out-of-order packet arrived, got 5 expected 4bcsp_recv: Out-of-order packet arrived, got 6 expected 4 SysRq : Changing Loglevel
Loglevel set to 1bcsp_recv: Short BCSP packetbcsp_recv: Out-of-order packet arrived, got 1 expected 0bcsp_recv: Out-of-order packet arrived, got 2 expected 0bcsp_recv: Out-of-order packet arrived, got 3 expected 0bcsp_recv: Short BCSP packet
...bcsp_recv: Out-of-order packet arrived, got 2 expected 7bcsp_recv: Short BCSP packetbcsp_recv: Out-of-order packet arrived, got 7 expected 6bcsp_recv: Out-of-order packet arrived, got 0 expected 6bcsp_recv: Out-of-order packet arrived, got 1 expected 6bcsp_recv: Short BCSP packetbcsp_recv: Error in BCSP hdr checksumbcsp_recv: Out-of-order packet arrived, got 4 expected 2bcsp_recv: Out-of-order packet arrived, got 5 expected 2bcsp_recv: Short BCSP packetbcsp_recv: Out-of-order packet arrived, got 2 expected 1bcsp_recv: Out-of-order packet arrived, got 3 expected 1bcsp_recv: Out-of-order packet arrived, got 4 expected 1bcsp_unslip_one_byte: Invalid byte 00 after esc bytebcsp_recv: Out-of-order packet arrived, got 4 expected 3bcsp_recv: Out-of-order packet arrived, got 5 expected 3bcsp_recv: Out-of-order packet arrived, got 6 expected 3bcsp_recv: Short BCSP packet
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 1 line
I believe the problem is 115200 bitrate between system and CF serial;
and lack of flow control I assume ?
Quoted 2 lines
I did setserial
baud_base921600, 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
Hi!
Quoted 3 lines
Quoted 1 line
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...)
Quoted 9 lines
Quoted 2 lines
I did setserial
baud_base921600, 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) = 3ioctl(3, TCFLSH, 0x2) = 0ioctl(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 ...}) = 0ioctl(3, TCFLSH, 0x2) = 0ioctl(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
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 1 line
ioctl(3, SNDCTL_TMR_START or TCSETS, {B921600 -opost -isig -icanon -echo ...})= 0
It's certainly trying
Quoted 2 lines
...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.
Quoted 3 lines
...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
Quoted 6 lines · Alan Cox
Quoted 1 line
ioctl(3, SNDCTL_TMR_START or TCSETS, {B921600 -opost -isig -icanon -echo ...})= 0It's certainly trying
Quoted 2 lines
...set 921K using TCSETS/B921600... and kernel says ok, but ...
Quoted 7 lines
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.
Quoted 8 lines
Quoted 3 lines
...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
drivers/serial/8250.c +30 -4
@@ -7,6 +7,9 @@* * Copyright (C) 2001 Russell King. * +* 2005/09/16: Enabled higher baud rates for 16C95x. +* (Mathias Adam <[email protected]>) +* * 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 intelse 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);
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html