From: Marcel Holtmann <marcel@holtmann.org>
To: Johan Hedberg <johan.hedberg@intel.com>
Cc: "Wang, Arron" <arron.wang@intel.com>,
"linux-bluetooth@vger.kernel.org"
<linux-bluetooth@vger.kernel.org>
Subject: Re: [PATCH 2/2] rfkill: Set device powered even adapter is not created
Date: Thu, 19 Apr 2012 14:41:45 +0200 [thread overview]
Message-ID: <1334839305.16897.280.camel@aeonflux> (raw)
In-Reply-To: <20120419123136.GA27022@x220.ger.corp.intel.com>
Hi Johan,
> > >> --- a/src/rfkill.c
> > >> +++ b/src/rfkill.c
> > >> @@ -128,11 +128,18 @@ static gboolean rfkill_event(GIOChannel *chan,
> > >> if (id < 0)
> > >> return TRUE;
> > >>
> > >> + DBG("RFKILL unblock for hci%d", id);
> > >> +
> > >> adapter = manager_find_adapter_by_id(id);
> > >> - if (!adapter)
> > >> + if (!adapter) {
> > >> + /*
> > >> + * If device is rfkilled, the initialize operation
> > >> + * may failed and adapter is not created, then we
> > >> + * need to set the device powered directly.
> > >> + */
> > >> + adapter_ops_set_powered(id, TRUE);
> > >> return TRUE;
> > >> -
> > >> - DBG("RFKILL unblock for hci%d", id);
> > >> + }
> > >>
> > >> btd_adapter_restore_powered(adapter);
> > >
> > >This looks more like a workaround to another issue: if the kernel is
> > >aware of the adapter but user space isn't it means that something has
> > >gone wrong during the initialization process and *that* should be
> > >fixed instead of blindly attempting to power on the adapter id
> > >anyway.
> >
> > Kernel works well and can detect the adapter, Bluetooth initialize failed
> > due to when we init HCI device, we try to start the device, however the
> > device is hardware/software rfkilled. From the code, we only init the
> > adapter when the device is up, this result in the current code in rfkill.c
> > can't bring up the device because adapter is NULL. Also only the kernel
> > detected the device we can get the rfkill event, the code in rfkill.c also
> > checked the device, then it is safe to power on the device in rfkill.c
>
> Ok, now I understand the issue better. Unfortunately your approach wont
> work with the management interface since the HCI index is invalid until
> the kernel has been able to send the first basic HCI commands. The
> expectation there is also that the first mgmt command to be sent for a
> new index is read_info.
>
> I had a brief chat with Marcel and one potential solution would be to
> have a kernel side timer for rfkilled devices to let the basic HCI
> commands be sent before bringing the adapter down. This would allow user
> space to have a properly initialized adapter object and your patches
> wouldn't be needed.
I actually meant to have the pending RFKILL events to be handled in
userspace.
But sure for the RFKILL switches that are tight to a Bluetooth
controller and are part of hci_dev, we could be even smarter inside the
kernel.
Regards
Marcel
next prev parent reply other threads:[~2012-04-19 12:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-16 9:02 [PATCH 2/2] rfkill: Set device powered even adapter is not created Yu A Wang
2012-04-19 7:45 ` Johan Hedberg
2012-04-19 8:57 ` Wang, Arron
2012-04-19 12:31 ` Johan Hedberg
2012-04-19 12:41 ` Marcel Holtmann [this message]
2012-04-19 14:13 ` Johan Hedberg
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=1334839305.16897.280.camel@aeonflux \
--to=marcel@holtmann.org \
--cc=arron.wang@intel.com \
--cc=johan.hedberg@intel.com \
--cc=linux-bluetooth@vger.kernel.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 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).