All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Hedberg <johan.hedberg@gmail.com>
To: Marcel Holtmann <marcel@holtmann.org>
Cc: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>,
	BlueZ development <linux-bluetooth@vger.kernel.org>
Subject: Re: [BUG] Set Powered=true doesn't power up the adapter
Date: Tue, 28 May 2013 10:13:06 +0300	[thread overview]
Message-ID: <20130528071306.GA31172@x220> (raw)
In-Reply-To: <1E509939-3804-43E0-A047-09CCD38A4713@holtmann.org>

Hi Marcel,

On Wed, May 22, 2013, Marcel Holtmann wrote:
> > If I send any Set Powered command after the controller is unblocked, while
> > there's still one pending command in the queue, this command will fail, and I
> > won't be able to bring the controller up, unless I force a HCI_RESET command.
> > 
> > So it seems that we need a way to mark an hdev as rfkill blocked.
> > 
> > Does anyone else have any other ideas?
> 
> my wild guess right now is that this is the problem:
> 
> 	static void hci_power_on(struct work_struct *work)
> 	{
> 	        struct hci_dev *hdev = container_of(work, struct hci_dev, power_on);
> 
> 	        BT_DBG("%s", hdev->name);
> 
> 	        if (hci_dev_open(hdev->id) < 0)
> 	                return;
> 
> 	        if (test_bit(HCI_AUTO_OFF, &hdev->dev_flags))
> 	                queue_delayed_work(hdev->req_workqueue, &hdev->power_off,
> 	                                   HCI_AUTO_OFF_TIMEOUT);
> 
> 	        if (test_and_clear_bit(HCI_SETUP, &hdev->dev_flags))
> 	                mgmt_index_added(hdev);
> 	}
> 
> In case hci_dev_open() fails and rfkill would be one example for that,
> we do not return an error back to the mgmt command that originates
> this power on.
> 
> Of course there is the initial adapter power on and there is the mgmt
> triggered power on. And my guess is that these two are racing against
> each other.

It seems you're right about the cause. I just sent a patch to fix it.
With the patch I get this behavior:

jh@qemu~/src/bluez{master}$ sudo rfkill list
0: hci0: Bluetooth
	Soft blocked: no
	Hard blocked: no
jh@qemu~/src/bluez{master}$ sudo rfkill block 0
jh@qemu~/src/bluez{master}$ sudo tools/btmgmt power on
Set Powered for hci0 failed with status 0x03 (Failed)

Johan

  reply	other threads:[~2013-05-28  7:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-21  2:07 [BUG] Set Powered=true doesn't power up the adapter Alex Deymo
     [not found] ` <CAE6HaMnFF7ym+FCWpVHCi=7=OJZeaS+uiF_qQDKHgpbzLUUu_w@mail.gmail.com>
2013-05-22  3:55   ` Fwd: " Vinicius Gomes
2013-05-22  6:47     ` Marcel Holtmann
2013-05-22 17:22       ` Vinicius Costa Gomes
2013-05-22 17:49         ` Marcel Holtmann
2013-05-28  7:13           ` Johan Hedberg [this message]
2013-05-28  7:36             ` Marcel Holtmann
2013-05-28  7:49               ` Johan Hedberg
2013-05-28  8:09                 ` Marcel Holtmann
2013-05-29 21:51             ` Alex Deymo
2013-05-30  2:04               ` Marcel Holtmann
2013-05-22  6:45 ` Marcel Holtmann

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=20130528071306.GA31172@x220 \
    --to=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=vinicius.gomes@openbossa.org \
    /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.