linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: Ron Shaffer <rshaffer@codeaurora.org>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH] Bluetooth: Defer SCO setup if mode change is pending
Date: Tue, 20 Jul 2010 09:56:01 -0700	[thread overview]
Message-ID: <1279644961.4572.60.camel@localhost.localdomain> (raw)
In-Reply-To: <4C45299D.9060504@codeaurora.org>

Hi Ron,

> > @@ -385,10 +406,13 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8
> >  		acl->power_save = 1;
> >  		hci_conn_enter_active_mode(acl);
> >  
> > -		if (lmp_esco_capable(hdev))
> > -			hci_setup_sync(sco, acl->handle);
> > -		else
> > -			hci_add_sco(sco, acl->handle);
> > +		if (test_bit(HCI_CONN_MODE_CHANGE_PEND, &acl->pend)) {
> > +			/* defer SCO setup until mode change completed */
> > +			set_bit(HCI_CONN_SCO_SETUP_PEND, &acl->pend);
> > +			return sco;
> > +		}
> > +
> > +		hci_sco_setup(acl, 0x00);
> >  	}
> 
> Not in love with the "fake" status passed here, but the overall change
> to centralize this functionality provides a nice cleanup from the
> original patch and makes the code more readable and maintainable.

yeah, the 0x00 looks funny here. We could add a comment explaining it,
but it does make sense in the end.

> >  	return sco;
> > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> > index 2069c3b..461413c 100644
> > --- a/net/bluetooth/hci_event.c
> > +++ b/net/bluetooth/hci_event.c
> > @@ -775,9 +775,6 @@ static void hci_cs_sniff_mode(struct hci_dev *hdev, __u8 status)
> >  
> >  	BT_DBG("%s status 0x%x", hdev->name, status);
> >  
> > -	if (!status)
> > -		return;
> > -
> >  	cp = hci_sent_cmd_data(hdev, HCI_OP_SNIFF_MODE);
> >  	if (!cp)
> >  		return;
> > @@ -785,8 +782,13 @@ static void hci_cs_sniff_mode(struct hci_dev *hdev, __u8 status)
> >  	hci_dev_lock(hdev);
> >  
> >  	conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle));
> > -	if (conn)
> > -		clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->pend);
> > +	if (conn) {
> > +		if (status)
> > +			clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->pend);
> > +
> > +		if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->pend))
> > +			hci_sco_setup(conn, status);
> 
> Probably the subject for another patch, but has there been any reported
> issue where idle_timeout is set short enough that the timer expires
> after exit sniff mode has been requested but before the mode change
> event has been received?

I see that this could potentially happen. The timer is not suppose to be
running during that transaction. It should be only started when the mode
change has been completed. That needs fixing, but not in this patch.

Regards

Marcel



  reply	other threads:[~2010-07-20 16:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-19 18:06 [PATCH] Bluetooth: Defer SCO setup if mode change is pending Marcel Holtmann
2010-07-20  4:44 ` Ron Shaffer
2010-07-20 16:56   ` Marcel Holtmann [this message]
2010-07-22 19:45     ` [PATCH v2] " Ron Shaffer
2010-07-23  2:48       ` Marcel Holtmann
2010-07-23 15:39         ` Ron Shaffer
2010-07-25 18:41           ` Marcel Holtmann
2010-07-26 14:06             ` [PATCH v3] " Ron Shaffer
2010-07-27 19:40               ` 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=1279644961.4572.60.camel@localhost.localdomain \
    --to=marcel@holtmann.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=rshaffer@codeaurora.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).