From: Johan Hedberg <johan.hedberg@gmail.com>
To: Marcel Holtmann <marcel@holtmann.org>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH v3 13/16] Bluetooth: Fix busy condition testing for EIR and class updates
Date: Fri, 1 Mar 2013 09:32:32 +0200 [thread overview]
Message-ID: <20130301073232.GC14811@x220.P-661HNU-F1> (raw)
In-Reply-To: <DCADC53A-261F-4CF0-A1CB-34DD7A49CA77@holtmann.org>
Hi Marcel,
On Thu, Feb 28, 2013, Marcel Holtmann wrote:
> > +static bool pending_eir_or_class(struct hci_dev *hdev)
> > +{
> > + struct pending_cmd *cmd;
> > +
> > + list_for_each_entry(cmd, &hdev->mgmt_pending, list) {
> > + switch (cmd->opcode) {
> > + case MGMT_OP_ADD_UUID:
> > + case MGMT_OP_REMOVE_UUID:
> > + case MGMT_OP_SET_DEV_CLASS:
> > + case MGMT_OP_SET_POWERED:
> > + return true;
> > + }
> > + }
> > +
> > + return false;
> > +}
> > +
>
> I do not like this at all. Why would we do it like this?
>
> The transaction framework should allow us to just process these one at
> a time. So even if userspace send 20 add_uuid commands at the same
> time, we would deal with them one after the other.
>
> What I am trying to understand what is the benefit of returning busy
> here.
If we have multiple commands/transactions in the queue wanting to send
the same HCI commands the problem is that the content of each HCI
command (the CoD or EIR data) should depend on the content of the
preceding HCI commands. The current EIR data or CoD (as stored in hdev
variables) depends on the last completed write HCI command for the data.
When we decide whether another command needs to be sent we compare what
we want to send based on what the current value is and not what it will
be (based on what's already in the queue).
Another problem is the handling of HCI command complete events for the
same HCI commands. We don't know which pending mgmt command should be
indicated as completed since there's no tight coupling of HCI commands
and the mgmt commands that triggered them.
Since we strictly speaking don't need to send all those write_eir or
write_cod commands in the queue but just the very last one (since that's
what ultimately takes effect once everything is complete) we could in
principle go digging into the queue and remove any earlier duplicates of
the same HCI command and reply mgmt_cmd_complete for all pending
commands when this one single HCI command completes. This is a bit messy
for several reasons. One is that we still need to ensure that the
complete callbacks for the transactions/commands we removed still get
called. Another is that this will result in some quite interesting
behavior:
1. Call add_uuid
2. Call remove_uuid with the same uuid as in 1.
3. The HCI command from 2. completes (the one from 1. was
replaced).
4. Success is returned for both mgmt commands when in fact the
UUID added in 1 never got added in reality.
Considering the fact that we queue up all commands anyway I don't really
have such a strong opinion on whether we allow potentially messed up
behavior when such queuing doesn't happen, but the above is at least an
attempt at explaining why I added this busy check.
One possible solution I can think of is that we update the CoD or EIR
value in hdev as soon as we create a HCI command to update the value, as
opposed to updating the hdev value when the HCI command completes. This
would allow us to have sensible checks on whether new HCI commands need
to be queued or not. We'd then have to have some flag to indicate that
there are pending EIR or CoD commands so that any of these mgmt commands
don't return a direct cmd_complete just because it looks like everything
is fine based on the CoD/EIR values in hdev.
Johan
next prev parent reply other threads:[~2013-03-01 7:32 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-27 7:57 [PATCH v3 00/16] Bluetooth: Add HCI transaction framework Johan Hedberg
2013-02-27 7:57 ` [PATCH v3 01/16] Bluetooth: Fix __hci_request() handling of empty requests Johan Hedberg
2013-02-27 7:57 ` [PATCH v3 02/16] Bluetooth: Split HCI init sequence into three stages Johan Hedberg
2013-02-28 19:54 ` Marcel Holtmann
2013-03-01 6:55 ` Johan Hedberg
2013-02-27 7:57 ` [PATCH v3 03/16] Bluetooth: Add initial skeleton for HCI transaction framework Johan Hedberg
2013-02-28 19:52 ` Marcel Holtmann
2013-03-01 7:04 ` Johan Hedberg
2013-03-01 7:30 ` Marcel Holtmann
2013-03-01 10:03 ` Johan Hedberg
2013-03-01 10:10 ` Johan Hedberg
2013-03-01 16:07 ` Marcel Holtmann
2013-03-01 16:13 ` Marcel Holtmann
2013-02-27 7:57 ` [PATCH v3 04/16] Bluetooth: Refactor HCI command skb creation Johan Hedberg
2013-02-27 7:57 ` [PATCH v3 05/16] Bluetooth: Introduce new hci_transaction_cmd function Johan Hedberg
2013-02-27 7:57 ` [PATCH v3 06/16] Bluetooth: Introduce a hci_transaction_from_skb function Johan Hedberg
2013-02-27 7:57 ` [PATCH v3 07/16] Bluetooth: Add transaction cmd_complete and cmd_status functions Johan Hedberg
2013-02-27 7:57 ` [PATCH v3 08/16] Bluetooth: Convert hci_request to use HCI transaction framework Johan Hedberg
2013-02-27 7:57 ` [PATCH v3 09/16] Bluetooth: Remove unused hdev->init_last_cmd Johan Hedberg
2013-02-27 7:57 ` [PATCH v3 10/16] Bluetooth: Move power on HCI command updates to their own function Johan Hedberg
2013-02-27 7:57 ` [PATCH v3 11/16] Bluetooth: Update mgmt powered HCI commands to use transactions Johan Hedberg
2013-02-27 7:57 ` [PATCH v3 12/16] Bluetooth: Wait for HCI command completion with mgmt_set_powered Johan Hedberg
2013-02-27 7:57 ` [PATCH v3 13/16] Bluetooth: Fix busy condition testing for EIR and class updates Johan Hedberg
2013-02-28 20:01 ` Marcel Holtmann
2013-03-01 7:32 ` Johan Hedberg [this message]
2013-03-01 8:00 ` Marcel Holtmann
2013-03-01 8:39 ` Johan Hedberg
2013-03-01 16:02 ` Marcel Holtmann
2013-02-27 7:57 ` [PATCH v3 14/16] Bluetooth: Fix UUID/class mgmt command response synchronization Johan Hedberg
2013-02-27 7:57 ` [PATCH v3 15/16] Bluetooth: Remove useless HCI_PENDING_CLASS flag Johan Hedberg
2013-02-27 7:57 ` [PATCH v3 16/16] Bluetooth: Remove empty HCI event handlers Johan Hedberg
2013-02-28 23:05 ` [PATCH v3 00/16] Bluetooth: Add HCI transaction framework Vinicius Costa Gomes
2013-03-01 8:46 ` 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=20130301073232.GC14811@x220.P-661HNU-F1 \
--to=johan.hedberg@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=marcel@holtmann.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