linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ] device: wait GATT client ready before service accept() if no cache
@ 2023-02-23 19:14 Pauli Virtanen
  2023-02-23 20:40 ` [BlueZ] " bluez.test.bot
  2023-02-23 21:10 ` [PATCH BlueZ] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Pauli Virtanen @ 2023-02-23 19:14 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Pauli Virtanen

On device ATT attach, do not immediately call accept() for profiles, if
there is no cached data in GATT database. Instead, wait for service
resolution to complete, as likely accept() cannot succeed before that.

Several profiles (bap, vcp, midi, deviceinfo) assume that GATT
attributes are available when their accept() is called, returning
success even if not.  In this case, the services never find the remote
attributes and are not operable.  Other profiles (hog, batt, ...) fail
their accept which prompts core to retry after discovery, and work
correctly also in this case.

Fix the failing services by waiting for service resolution as necessary,
so profiles can assume the GATT DB has some content.
---

Notes:
    This fixes the issue with BAP client being broken when there is no GATT
    cache.
    
    On my setup, btd_settings_gatt_db_load often fails with EIO, even though
    the files are there. Apparently, in some cases the saved cache data is
    not loadable, need to figure out later why it happens.

 src/device.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/device.c b/src/device.c
index 28b93eb9a..d270421cc 100644
--- a/src/device.c
+++ b/src/device.c
@@ -5155,10 +5155,11 @@ static void gatt_client_init(struct btd_device *device)
 	g_attrib_attach_client(device->attrib, device->client);
 
 	/*
-	 * Notify notify existing service about the new connection so they can
-	 * react to notifications while discovering services
+	 * If we have cache, notify existing service about the new connection
+	 * so they can react to notifications while discovering services
 	 */
-	device_accept_gatt_profiles(device);
+	if (!gatt_db_isempty(device->db))
+		device_accept_gatt_profiles(device);
 
 	device->gatt_ready_id = bt_gatt_client_ready_register(device->client,
 							gatt_client_ready_cb,
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [BlueZ] device: wait GATT client ready before service accept() if no cache
  2023-02-23 19:14 [PATCH BlueZ] device: wait GATT client ready before service accept() if no cache Pauli Virtanen
@ 2023-02-23 20:40 ` bluez.test.bot
  2023-02-23 21:10 ` [PATCH BlueZ] " patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2023-02-23 20:40 UTC (permalink / raw)
  To: linux-bluetooth, pav

[-- Attachment #1: Type: text/plain, Size: 1512 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=724435

---Test result---

Test Summary:
CheckPatch                    PASS      0.49 seconds
GitLint                       FAIL      0.59 seconds
BuildEll                      PASS      26.78 seconds
BluezMake                     PASS      970.99 seconds
MakeCheck                     PASS      11.77 seconds
MakeDistcheck                 PASS      151.46 seconds
CheckValgrind                 PASS      245.01 seconds
CheckSmatch                   PASS      328.16 seconds
bluezmakeextell               PASS      98.01 seconds
IncrementalBuild              PASS      875.90 seconds
ScanBuild                     PASS      1023.96 seconds

Details
##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
[BlueZ] device: wait GATT client ready before service accept() if no cache

WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search
21: B2 Line has trailing whitespace: "    "


---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH BlueZ] device: wait GATT client ready before service accept() if no cache
  2023-02-23 19:14 [PATCH BlueZ] device: wait GATT client ready before service accept() if no cache Pauli Virtanen
  2023-02-23 20:40 ` [BlueZ] " bluez.test.bot
@ 2023-02-23 21:10 ` patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2023-02-23 21:10 UTC (permalink / raw)
  To: Pauli Virtanen; +Cc: linux-bluetooth

Hello:

This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Thu, 23 Feb 2023 19:14:44 +0000 you wrote:
> On device ATT attach, do not immediately call accept() for profiles, if
> there is no cached data in GATT database. Instead, wait for service
> resolution to complete, as likely accept() cannot succeed before that.
> 
> Several profiles (bap, vcp, midi, deviceinfo) assume that GATT
> attributes are available when their accept() is called, returning
> success even if not.  In this case, the services never find the remote
> attributes and are not operable.  Other profiles (hog, batt, ...) fail
> their accept which prompts core to retry after discovery, and work
> correctly also in this case.
> 
> [...]

Here is the summary with links:
  - [BlueZ] device: wait GATT client ready before service accept() if no cache
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=46a5d2beccb2

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-02-23 21:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-23 19:14 [PATCH BlueZ] device: wait GATT client ready before service accept() if no cache Pauli Virtanen
2023-02-23 20:40 ` [BlueZ] " bluez.test.bot
2023-02-23 21:10 ` [PATCH BlueZ] " patchwork-bot+bluetooth

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).