linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: Claire Chang <tientzu@chromium.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>,
	Balakrishna Godavarthi <bgodavar@codeaurora.org>,
	Rocky Liao <rjliao@codeaurora.org>,
	Bluez mailing list <linux-bluetooth@vger.kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Bluetooth: hci_qca: add PM support
Date: Mon, 4 Nov 2019 15:19:50 +0100	[thread overview]
Message-ID: <A80987FF-C9E1-4790-91F1-F86E405B9691@holtmann.org> (raw)
In-Reply-To: <20191031104614.165120-1-tientzu@chromium.org>

Hi Claire,

> Add PM suspend/resume callbacks for hci_qca driver.
> 
> BT host will make sure both Rx and Tx go into sleep state in
> qca_suspend. Without this, Tx may still remain in awake state, which
> prevents BTSOC from entering deep sleep. For example, BlueZ will send
> Set Event Mask to device when suspending and this will wake the device
> Rx up. However, the Tx idle timeout on the host side is 2000 ms. If the
> host is suspended before its Tx idle times out, it won't send
> HCI_IBS_SLEEP_IND to the device and the device Rx will remain awake.
> 
> We implement this by canceling relevant work in workqueue, sending
> HCI_IBS_SLEEP_IND to the device and then waiting HCI_IBS_SLEEP_IND sent
> by the device.
> 
> In order to prevent the device from being awaken again after qca_suspend
> is called, we introduce QCA_SUSPEND flag. QCA_SUSPEND is set in the
> beginning of qca_suspend to indicate system is suspending and that we'd
> like to ignore any further wake events.
> 
> With QCA_SUSPEND and spinlock, we can avoid race condition, e.g. if
> qca_enqueue acquires qca->hci_ibs_lock before qca_suspend calls
> cancel_work_sync and then qca_enqueue adds a new qca->ws_awake_device
> work after the previous one is cancelled.
> 
> If BTSOC wants to wake the whole system up after qca_suspend is called,
> it will keep sending HCI_IBS_WAKE_IND and uart driver will take care of
> waking the system. For example, uart driver will reconfigure its Rx pin
> to a normal GPIO pin and enable irq wake on that pin when suspending.
> Once host detects Rx falling, the system will begin resuming. Then, the
> BT host clears QCA_SUSPEND flag in qca_resume and begins dealing with
> normal HCI packets. By doing so, only a few HCI_IBS_WAKE_IND packets are
> lost and there is no data packet loss.
> 
> Signed-off-by: Claire Chang <tientzu@chromium.org>
> ---
> drivers/bluetooth/hci_qca.c | 127 +++++++++++++++++++++++++++++++++++-
> 1 file changed, 124 insertions(+), 3 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel


      parent reply	other threads:[~2019-11-04 14:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-31 10:46 [PATCH] Bluetooth: hci_qca: add PM support Claire Chang
2019-10-31 15:04 ` Balakrishna Godavarthi
2019-11-03 17:27 ` Balakrishna Godavarthi
2019-11-04 14:19 ` Marcel Holtmann [this message]

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=A80987FF-C9E1-4790-91F1-F86E405B9691@holtmann.org \
    --to=marcel@holtmann.org \
    --cc=bgodavar@codeaurora.org \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rjliao@codeaurora.org \
    --cc=tientzu@chromium.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).