mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shuai Zhang <shuai.zhang@oss.qualcomm.com>
To: Marcel Holtmann <marcel@holtmann.org>,
	Johan Hedberg <johan.hedberg@gmail.com>,
	Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-msm@vger.kernel.org, cheng.jiang@oss.qualcomm.com,
	quic_chezhou@quicinc.com, wei.deng@oss.qualcomm.com
Subject: Re: [PATCH v1] Bluetooth: hci_sync: Fix not clearing cmd_sync_work_list on power off
Date: Mon, 19 Jan 2026 19:46:41 +0800	[thread overview]
Message-ID: <a963b9cf-006c-4fd3-a1d4-789ff10ed10b@oss.qualcomm.com> (raw)
In-Reply-To: <20251209140347.2816326-1-shuai.zhang@oss.qualcomm.com>

Hi

On 12/9/2025 10:03 PM, Shuai Zhang wrote:
> When powering off the cmd_sync_work_list may contain items which shall
> be cleared during power off as they shouldn't be run during power off
> sequence.
>
> Signed-off-by: Shuai Zhang <shuai.zhang@oss.qualcomm.com>
> ---
>   net/bluetooth/hci_sync.c | 20 +++++++++++++++-----
>   1 file changed, 15 insertions(+), 5 deletions(-)
>
> diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
> index a9f5b1a68..45b593ec7 100644
> --- a/net/bluetooth/hci_sync.c
> +++ b/net/bluetooth/hci_sync.c
> @@ -648,16 +648,22 @@ static void _hci_cmd_sync_cancel_entry(struct hci_dev *hdev,
>   	kfree(entry);
>   }
>   
> -void hci_cmd_sync_clear(struct hci_dev *hdev)
> +/* Clear remaining entries in cmd_sync_work_list */
> +static void hci_cmd_sync_list_clear(struct hci_dev *hdev)
>   {
>   	struct hci_cmd_sync_work_entry *entry, *tmp;
>   
> +	list_for_each_entry_safe(entry, tmp, &hdev->cmd_sync_work_list, list)
> +		_hci_cmd_sync_cancel_entry(hdev, entry, -ECANCELED);
> +}
> +
> +void hci_cmd_sync_clear(struct hci_dev *hdev)
> +{
>   	cancel_work_sync(&hdev->cmd_sync_work);
>   	cancel_work_sync(&hdev->reenable_adv_work);
>   
>   	mutex_lock(&hdev->cmd_sync_work_lock);
> -	list_for_each_entry_safe(entry, tmp, &hdev->cmd_sync_work_list, list)
> -		_hci_cmd_sync_cancel_entry(hdev, entry, -ECANCELED);
> +	hci_cmd_sync_list_clear(hdev);
>   	mutex_unlock(&hdev->cmd_sync_work_lock);
>   }
>   
> @@ -678,6 +684,7 @@ EXPORT_SYMBOL(hci_cmd_sync_cancel);
>    *
>    * - Set result and mark status to HCI_REQ_CANCELED
>    * - Wakeup command sync thread
> + * - Clear cmd_sync_work_list if the interface is down
>    */
>   void hci_cmd_sync_cancel_sync(struct hci_dev *hdev, int err)
>   {
> @@ -692,6 +699,9 @@ void hci_cmd_sync_cancel_sync(struct hci_dev *hdev, int err)
>   
>   		wake_up_interruptible(&hdev->req_wait_q);
>   	}
> +
> +	if (err == EHOSTDOWN || err == -EHOSTDOWN)
> +		hci_cmd_sync_list_clear(hdev);
>   }
>   EXPORT_SYMBOL(hci_cmd_sync_cancel_sync);
>   
> @@ -5260,14 +5270,14 @@ int hci_dev_close_sync(struct hci_dev *hdev)
>   		disable_delayed_work(&hdev->power_off);
>   		disable_delayed_work(&hdev->ncmd_timer);
>   		disable_delayed_work(&hdev->le_scan_disable);
> +		hci_cmd_sync_cancel_sync(hdev, ENODEV);
>   	} else {
>   		cancel_delayed_work(&hdev->power_off);
>   		cancel_delayed_work(&hdev->ncmd_timer);
>   		cancel_delayed_work(&hdev->le_scan_disable);
> +		hci_cmd_sync_cancel_sync(hdev, EHOSTDOWN);
>   	}
>   
> -	hci_cmd_sync_cancel_sync(hdev, ENODEV);
> -
>   	cancel_interleave_scan(hdev);
>   
>   	if (hdev->adv_instance_timeout) {
Kindly let me know if there are any updates.


Kindly, regard

Shuai




  reply	other threads:[~2026-01-19 11:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-09 14:03 Shuai Zhang
2026-01-19 11:46 ` Shuai Zhang [this message]
2026-01-19 12:39 ` Dmitry Baryshkov

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=a963b9cf-006c-4fd3-a1d4-789ff10ed10b@oss.qualcomm.com \
    --to=shuai.zhang@oss.qualcomm.com \
    --cc=cheng.jiang@oss.qualcomm.com \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.org \
    --cc=quic_chezhou@quicinc.com \
    --cc=wei.deng@oss.qualcomm.com \
    /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

all inboxes | Powered by JetHome®