From: Zhao Li <enderaoelyther@gmail.com>
To: Loic Poulain <loic.poulain@oss.qualcomm.com>
Cc: Marcel Holtmann <marcel@holtmann.org>,
Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
Michael McAllister <me@michaelmcallister.org>,
stable@vger.kernel.org
Subject: Re: [PATCH v2] Bluetooth: hci_serdev: stop write_work before closing the port
Date: Sat, 21 Nov 2026 20:28:32 +0800 [thread overview]
Message-ID: <20261121122833.7545-1-enderaoelyther@gmail.com> (raw)
In-Reply-To: <CAFEp6-37+O4BoSL414Njogr-34G7se-8Nu+O7B0zjBY1Jw7UWg@mail.gmail.com>
On Fri, Nov 20, 2026 at 02:39:41PM +0100, Loic Poulain wrote:
> > + cancel_work_sync(&hu->write_work);
> > + clear_bit(HCI_UART_SENDING, &hu->tx_state);
> > + clear_bit(HCI_UART_TX_WAKEUP, &hu->tx_state);
>
> Looks like you are mostly re-doing what has already been done in
> hci_uart_flush()...
> Wouldn't it be simpler to have a hci_uart_flush parameter to not
> reschedule tx on flush?
Good point. The only reason hci_uart_close() has to stop TX a second
time is that hci_uart_flush() unconditionally re-enables write_work at
the end.
Skipping just the final wakeup replay wouldn't be enough, though. Once
hci_uart_flush() re-enables write_work and clears HCI_UART_SENDING, a
serdev write_wakeup callback can still queue write_work before
serdev_device_close() runs.
Instead, we can split out a __hci_uart_flush(hdev, bool resume_tx)
helper (since hci_uart_flush() itself is the hdev->flush callback):
- Normal flushes pass resume_tx = true and behave as today.
- With HCI_QUIRK_NON_PERSISTENT_SETUP, hci_uart_close() passes
resume_tx = false, leaving write_work disabled and HCI_UART_SENDING
set across the close.
- After clearing HCI_UART_PROTO_READY under hu->proto_lock (to drain
in-flight wakeups) and calling serdev_device_close(), hci_uart_close()
clears HCI_UART_TX_WAKEUP, re-enables write_work, and clears
HCI_UART_SENDING for the next open.
That drops the duplicate cancel_work_sync() and tx_skb cleanup while
keeping write_work completely disabled until the port is closed.
I'll send a v3 along these lines.
Thanks,
Zhao
prev parent reply other threads:[~2026-11-21 12:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 6:20 [PATCH v2] Bluetooth: hci_serdev: stop write_work before closing the port Zhao Li
2026-11-20 13:26 ` [v2] " bluez.test.bot
2026-11-20 13:39 ` [PATCH v2] " Loic Poulain
2026-11-21 12:28 ` Zhao Li [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=20261121122833.7545-1-enderaoelyther@gmail.com \
--to=enderaoelyther@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=loic.poulain@oss.qualcomm.com \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=me@michaelmcallister.org \
--cc=stable@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.