mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul Menzel <pmenzel@molgen.mpg.de>
To: Javier Nieto <jgnieto@cs.stanford.edu>
Cc: luiz.dentz@gmail.com, marcel@holtmann.org,
	linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Bluetooth: hci_h5: avoid sending two SYNC messages
Date: Fri, 22 Aug 2025 13:41:41 +0200	[thread overview]
Message-ID: <06787d51-5d5e-4f74-bda6-b80cead5ed6d@molgen.mpg.de> (raw)
In-Reply-To: <20250822003912.41754-1-jgnieto@cs.stanford.edu>

Dear Javier,


Thank you for your patch.


Am 22.08.25 um 02:39 schrieb Javier Nieto:
> Previously, h5_open() called h5_link_control() to send a SYNC message.
> But h5_link_control() only enqueues the packet and requires the caller
> to call hci_uart_tx_wakeup(). Thus, after H5_SYNC_TIMEOUT ran out
> (100ms), h5_timed_event() would be called and, realizing that the state
> was still H5_UNINITIALIZED, it would re-enqueue the SYNC and call
> hci_uart_tx_wakeup(). Consequently, two SYNC packets would be sent and
> initialization would unnecessarily wait for 100ms.
> 
> The naive solution of calling hci_uart_tx_wakeup() in h5_open() does not
> work because it will only schedule tx work if the HCI_PROTO_READY bit is
> set and hci_serdev only sets it after h5_open() returns. This patch
> removes the extraneous SYNC being enqueued and makes h5_timed_event()
> wake up on the next jiffy.

Great commit message, thank you. I’d appreciate it if you documented 
your test environment, and maybe paste the logs (for the timestamps) 
before and after, so others could easily reproduce the issue.

> Signed-off-by: Javier Nieto <jgnieto@cs.stanford.edu>
> ---
>   drivers/bluetooth/hci_h5.c | 9 +++++----
>   1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c
> index d0d4420c1a0f..863ee93dd8a8 100644
> --- a/drivers/bluetooth/hci_h5.c
> +++ b/drivers/bluetooth/hci_h5.c
> @@ -213,7 +213,6 @@ static void h5_peer_reset(struct hci_uart *hu)
>   static int h5_open(struct hci_uart *hu)
>   {
>   	struct h5 *h5;
> -	const unsigned char sync[] = { 0x01, 0x7e };
>   
>   	BT_DBG("hu %p", hu);
>   
> @@ -243,9 +242,11 @@ static int h5_open(struct hci_uart *hu)
>   
>   	set_bit(HCI_UART_INIT_PENDING, &hu->hdev_flags);
>   
> -	/* Send initial sync request */
> -	h5_link_control(hu, sync, sizeof(sync));
> -	mod_timer(&h5->timer, jiffies + H5_SYNC_TIMEOUT);
> +	/*
> +	 * Wait one jiffy because the UART layer won't set HCI_UART_PROTO_READY,
> +	 * which allows us to send link packets, until this function returns.
> +	 */
> +	mod_timer(&h5->timer, jiffies + 1);
>   
>   	return 0;
>   }

Makes sense.

Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>


Kind regards,

Paul

  reply	other threads:[~2025-08-22 11:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-22  0:39 Javier Nieto
2025-08-22 11:41 ` Paul Menzel [this message]
2025-08-23 21:05   ` Javier Nieto

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=06787d51-5d5e-4f74-bda6-b80cead5ed6d@molgen.mpg.de \
    --to=pmenzel@molgen.mpg.de \
    --cc=jgnieto@cs.stanford.edu \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --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

all inboxes | Powered by JetHome®