From: Dimitris <dimitris.on.linux@gmail.com>
To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH BlueZ 1/1] Refactor btd_device_is_connected
Date: Thu, 4 Apr 2024 11:25:41 -0700 [thread overview]
Message-ID: <18bbe5d0-a77a-4180-a468-1026ae16c4ac@gmail.com> (raw)
In-Reply-To: <CABBYNZLmff+NWTp3=5S5g8nx=KxJ0=PgxT7v9viO_hS=U15=1g@mail.gmail.com>
Hi Luiz,
On 4/4/24 09:16, Luiz Augusto von Dentz wrote:
>>> I guess the problem is that some service is indicating it is still
>>> connected though?
>>
>> Newbie question for sure, but: As this is happening in the code path for
>> "disabling bluetooth", shouldn't services already be disconnected here?
>
> That is exactly what I would like to know, why is there a service
> still indicating it is connected if the controller is rfkilled, so
> while this should break it back to the old behavior we still need to
> fix the service that is causing the problem so perhaps we need to
> print its profile/drive name and figure out what is the driver that is
> causing it.
>
I added a debug kludge:
> diff --git a/src/device.c b/src/device.c
> index 74dd67a09..c461a6a3a 100644
> --- a/src/device.c
> +++ b/src/device.c
> @@ -344,7 +344,15 @@ static GSList *find_service_with_state(GSList *list,
> struct btd_service *service = l->data;
>
> if (btd_service_get_state(service) == state)
> + {
> + char name[256];
> + device_get_name(btd_service_get_device(service), name, 256);
> + info("Found service: err: %d, device: %s",
> + btd_service_get_error(service),
> + name
> + );
> return l;
> + }
> }
>
> return NULL;
> @@ -3282,7 +3290,12 @@ bool btd_device_is_connected(struct btd_device *dev)
>
> bool btd_device_bearer_is_connected(struct btd_device *dev)
> {
> - return dev->bredr_state.connected || dev->le_state.connected;
> + if(dev->bredr_state.connected || dev->le_state.connected)
> + return true;
> + else {
> + find_service_with_state(dev->services, BTD_SERVICE_STATE_CONNECTED);
> + return false;
> + };
> }
>
> static void clear_temporary_timer(struct btd_device *dev)
And it seems that every device I have available triggers this: MX
Master 3 mouse, Google Pixel Buds Pro, Google Pixel 7. Ran experiments
with each one of the devices being connected when running rfkill block:
> Apr 04 11:06:31 bluetoothd[331222]: Found service: err: 0, device: MX Master 3
> Apr 04 11:06:46 bluetoothd[331222]: Found service: err: 0, device: MX Master 3
> Apr 04 11:06:58 bluetoothd[331222]: Found service: err: 0, device: MX Master 3
> Apr 04 11:07:28 bluetoothd[331222]: Found service: err: 0, device: coral buds
> Apr 04 11:07:29 bluetoothd[331222]: Found service: err: 0, device: coral buds
> Apr 04 11:07:29 bluetoothd[331222]: Found service: err: 0, device: coral buds
> Apr 04 11:07:29 bluetoothd[331222]: src/profile.c:ext_io_disconnected() Unable to get io data for Hands-Free Voice gateway: getpeername: Transport endpoint is not connected (107)
> Apr 04 11:08:01 bluetoothd[331222]: Found service: err: 0, device: coral buds
> Apr 04 11:08:01 bluetoothd[331222]: src/profile.c:ext_io_disconnected() Unable to get io data for Hands-Free Voice gateway: getpeername: Transport endpoint is not connected (107)
> Apr 04 11:08:40 bluetoothd[331222]: Found service: err: 0, device: coral buds
> Apr 04 11:08:40 bluetoothd[331222]: src/profile.c:ext_io_disconnected() Unable to get io data for Hands-Free Voice gateway: getpeername: Transport endpoint is not connected (107)
> Apr 04 11:09:47 bluetoothd[331222]: Found service: err: 0, device: p7
> Apr 04 11:09:47 bluetoothd[331222]: src/profile.c:ext_io_disconnected() Unable to get io data for Hands-Free unit: getpeername: Transport endpoint is not connected (107)
The BT adapter is a Mediatek MT7922 WiFi/BT M2 adapter, seems to be
using the btmtk driver.
In parallel, I've sent a V3 of the "bring back previous behavior" patch
with the new function named btd_device_bearer_is_connected.
D.
next prev parent reply other threads:[~2024-04-04 18:25 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-03 20:52 [PATCH BlueZ 0/1] Fixes busy loop when disabling Dimitris
2024-04-03 20:52 ` [PATCH BlueZ 1/1] Revert "device: Consider service state on device_is_connected" Dimitris
2024-04-03 22:39 ` Fixes busy loop when disabling bluez.test.bot
2024-04-04 6:24 ` [PATCH BlueZ 1/1] Revert "device: Consider service state on device_is_connected" Paul Menzel
2024-04-04 6:35 ` Dimitris
2024-04-04 2:45 ` [PATCH BlueZ 0/1] V2: Fix busy loop when disabling BT Dimitris
2024-04-04 2:45 ` [PATCH BlueZ 1/1] Refactor btd_device_is_connected Dimitris
2024-04-04 4:40 ` V2: Fix busy loop when disabling BT bluez.test.bot
2024-04-04 14:59 ` [PATCH BlueZ 1/1] Refactor btd_device_is_connected Luiz Augusto von Dentz
2024-04-04 15:52 ` Dimitris
2024-04-04 16:16 ` Luiz Augusto von Dentz
2024-04-04 18:25 ` Dimitris [this message]
2024-04-04 18:30 ` [PATCH BlueZ 0/1] V3: Fix busy loop when disabling BT Dimitris
2024-04-04 18:30 ` [PATCH BlueZ 1/1] refactor bearer connected test Dimitris
2024-04-04 20:07 ` V3: Fix busy loop when disabling BT bluez.test.bot
2024-04-04 18:50 ` [PATCH BlueZ 0/1] " patchwork-bot+bluetooth
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=18bbe5d0-a77a-4180-a468-1026ae16c4ac@gmail.com \
--to=dimitris.on.linux@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.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;
as well as URLs for NNTP newsgroup(s).