All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: Peter Hurley <peter@hurleysoftware.com>
Cc: Loic Poulain <loic.poulain@intel.com>,
	Frederic Danis <frederic.danis@linux.intel.com>,
	linux-bluetooth@vger.kernel.org, gregkh@linuxfoundation.org,
	jslaby@suse.cz
Subject: Re: [RFC 3/5] Bluetooth: hci_uart: Add HCIUARTSETBAUDRATE ioctl
Date: Fri, 3 Apr 2015 10:39:27 -0700	[thread overview]
Message-ID: <D74E0673-5A60-4E8F-A050-60DB4A0F43A7@holtmann.org> (raw)
In-Reply-To: <551EB5A1.9040409@hurleysoftware.com>

Hi Peter,

>>> The line discipline is always notified of line rate changes
>>> via the set_termios() method, so if you add that to the hci_ldisc,
>>> you'll be able to keep the BT device in sync with your
>>> vendor-specific commands.
>> If I'm not wrong, line discipline is notified after the tty termios change.
>> So, it's too late to send the  HCI change speed command.
>> Moreover, user space is not aware of the device behavior, the driver should
>> be the only one to manage the device and its serial link.
>> Here, user space is just a bootstrap which hands over to the driver.
> 
> You realize that you're telling me that userspace is unaware of
> this in a thread that begins with a proposed userspace ioctl change to
> the line discipline? An ioctl change that adds a new ioctl to set the
> speed in a line discipline? For which there are already lots of ioctls
> to set the line speed?

actually the problem is a little bit different here. Every Bluetooth UART chip has its default baudrate. Mostly that is 115k, but some actually have others.

The general idea was that userspace deals with opening the TTY, send the HCI commands to change the rate, then change the termios setting, attach the ldisc and then hand it to the kernel.

This is however not how at least two major Bluetooth controllers work when you have to do firmware loading. When they boot into the firmware, then baudrate falls back to default and you have to do that all over again.

So what this ioctl will just tell the kernel about is the desired baudrate that it wants to be set whenever possible. The whenever possible is important here since depending on the manufacturer that might be a total different times. And with firmware download procedures being fully vendor specific this will vary.

> Setting aside the problem with the firmware load, I see no reason why
> this can't be done within the existing line discipline framework.

So far everything has been done in hciattach tool. And it is so ugly and does not even work properly for any complex UART protocols like BCSP or 3-Wire. There is a patch for a modified 3-Wire setup from one vendor that made my eyes bleed. So what you really want is having the kernel take control over HCI from the beginning. Otherwise this goes out of control and handling exceptions like hardware error event becomes impossible.

In summary what we have to do these days is this:

- Send Reset
- Send a few basic HCI commands
- Send baud rate change command
- Change actual baud rate on the TTY
- Download firmware
- Send Reset to boot the firmware
- Change actual baud rate back to default
- Send baud rate change command
- Change actual baud rate
- Send Reset
- Standard init sequence

Now tell me how the line discipline framework helps us here? Keep in mind you have to tell the controller via HCI commands over the old baud rate to change its rate. And then change it on the TTY to match what the controller does on its side.

Regards

Marcel


  reply	other threads:[~2015-04-03 17:39 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-02 14:37 [RFC 0/5] Move HCI UART vendor specific setup to kernel Frederic Danis
2015-04-02 14:37 ` [RFC 1/5] Bluetooth: hci_uart: Add HCIUARTSETDEVTYPE ioctl Frederic Danis
2015-04-02 14:57   ` Marcel Holtmann
2015-04-02 14:37 ` [RFC 2/5] Bluetooth: hci_uart: Add BCM specific setup function Frederic Danis
2015-04-02 14:37 ` [RFC 3/5] Bluetooth: hci_uart: Add HCIUARTSETBAUDRATE ioctl Frederic Danis
2015-04-02 15:12   ` Marcel Holtmann
2015-04-03 10:54   ` Peter Hurley
2015-04-03 12:49     ` Frederic Danis
2015-04-03 13:45       ` Peter Hurley
2015-04-03 13:56         ` Peter Hurley
2015-04-03 14:18         ` Loic Poulain
2015-04-03 15:45           ` Peter Hurley
2015-04-03 17:39             ` Marcel Holtmann [this message]
2015-04-04 23:05               ` Peter Hurley
2015-04-04 23:35                 ` Marcel Holtmann
2015-04-05  1:22                   ` Peter Hurley
2015-04-05  2:29                     ` Marcel Holtmann
2015-04-10 12:07                       ` Peter Hurley
2015-04-10 16:07                         ` Marcel Holtmann
2015-04-10 16:45                           ` Peter Hurley
2015-04-10 16:58                             ` Marcel Holtmann
2015-04-02 14:37 ` [RFC 4/5] tty: Re-add external interface for tty_set_termios() Frederic Danis
2015-04-02 15:08   ` Marcel Holtmann
2015-04-02 14:37 ` [RFC 5/5] Bluetooth: hci_uart: Add BCM specific UART speed management Frederic Danis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D74E0673-5A60-4E8F-A050-60DB4A0F43A7@holtmann.org \
    --to=marcel@holtmann.org \
    --cc=frederic.danis@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.cz \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=loic.poulain@intel.com \
    --cc=peter@hurleysoftware.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.