Skip to contentSkip to conversation

core: retry connect_dbus() several times

PATCH In review Adam Lee 4 participants 7 messages Feb 28, 2014 – Mar 3, 2014 Bluetooth drivers

lore
Share & tools
lore

Adam Lee

author
#0 lore raw

PATCH 1/1 core: retry connect_dbus() several times

Sometimes the hardware, especially which needs firmware patching, is not yet ready when connect_dbus().

---
 src/main.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
src/main.c +12 -3
index b3136fc..cf1f8fa 100644
@@ -491,6 +491,7 @@ int main(int argc, char *argv[])
 	GKeyFile *config;
 	guint signal, watchdog;
 	const char *watchdog_usec;
+	uint8_t reconnect_times = 3;
 
 	init_defaults();
 
@@ -527,9 +528,17 @@ int main(int argc, char *argv[])
 
 	parse_config(config);
 
-	if (connect_dbus() < 0) {
-		error("Unable to get on D-Bus");
-		exit(1);
+	/* Reconnect several times in case the hardware is not ready */
+	while (reconnect_times--) {
+		if (connect_dbus() == 0)
+			break;
+
+		if (reconnect_times != 1) {
+			usleep(500 * 1000);
+		} else {
+			error("Unable to get on D-Bus");
+			exit(1);
+		}
 	}
 
 	if (option_experimental)
Signature · 1 line
1.9.0
maintainer
#1 lore raw

Hi Adadm,

Quoted 2 lines

Sometimes the hardware, especially which needs firmware patching, is not yet ready when connect_dbus().

this makes no sense. Connecting to D-Bus has nothing to do with firmware patching. What are you exactly fixing here?

Regards

Marcel

author
#2 lore raw
Quoted 7 lines · Marcel Holtmann

Hi Adadm,

Quoted 2 lines

Sometimes the hardware, especially which needs firmware patching, is not yet ready when connect_dbus().

this makes no sense. Connecting to D-Bus has nothing to do with firmware patching. What are you exactly fixing here?

connect_dbus() fails sometimes with Intel 7260 bluetooth, sleeping 0.5s before executing bluetoothd workarounds it. I assume the firmware patching slows down hardware initialization then fails to connect.

Any other possibility? I'm not a D-Bus guru :)

Signature · 2 lines
Adam Lee
http://adam8157.info
maintainer
#3 lore raw

Hi Adam,

Quoted 11 lines
Quoted 5 lines
Quoted 2 lines

Sometimes the hardware, especially which needs firmware patching, is not yet ready when connect_dbus().

this makes no sense. Connecting to D-Bus has nothing to do with firmware patching. What are you exactly fixing here?

connect_dbus() fails sometimes with Intel 7260 bluetooth, sleeping 0.5s before executing bluetoothd workarounds it. I assume the firmware patching slows down hardware initialization then fails to connect.

Any other possibility? I'm not a D-Bus guru :)

it has nothing to do with D-Bus. You need to find the root cause.

Regards

Marcel

#4 lore raw
In reply to Adam Lee

Hi Adam,

Quoted 5 lines · Adam Lee

connect_dbus() fails sometimes with Intel 7260 bluetooth, sleeping 0.5s before executing bluetoothd workarounds it. I assume the firmware patching slows down hardware initialization then fails to connect.

Any other possibility? I'm not a D-Bus guru :)

Please provide more details, e.g. the bluetoothd logs showing the problems, btmon output and which steps you are using to reproduce it. If you are using bluetoothctl, tell us which commands you are using.

Best Regards,

Signature · 3 lines
Anderson Lizardo
http://www.indt.org/?lang=en
INdT - Manaus - Brazil
#5 lore raw

Hi Adam,

Quoted 7 lines · Anderson Lizardo

Hi Adam,

Quoted 4 lines · Adam Lee

connect_dbus() fails sometimes with Intel 7260 bluetooth, sleeping 0.5s before executing bluetoothd workarounds it. I assume the firmware patching slows down hardware initialization then fails to connect.

Quoted 5 lines
Quoted 1 line

Any other possibility? I'm not a D-Bus guru :)

Please provide more details, e.g. the bluetoothd logs showing the problems, btmon output and which steps you are using to reproduce it. If you are using bluetoothctl, tell us which commands you are using.

My guess is that either your driver is not using .setup hook to do the firmware patching or it is returning before it has fully initialize the hardware, so please also add more information what is happening on the driver side.

Signature · 1 line
Luiz Augusto von Dentz
author
#6 lore raw
Quoted 13 lines · Luiz Augusto von Dentz

Hi Adam,

Quoted 9 lines · Anderson Lizardo

Hi Adam,

Quoted 5 lines · Adam Lee

connect_dbus() fails sometimes with Intel 7260 bluetooth, sleeping 0.5s before executing bluetoothd workarounds it. I assume the firmware patching slows down hardware initialization then fails to connect.

Any other possibility? I'm not a D-Bus guru :)

Quoted 8 lines
Quoted 3 lines

Please provide more details, e.g. the bluetoothd logs showing the problems, btmon output and which steps you are using to reproduce it. If you are using bluetoothctl, tell us which commands you are using.

My guess is that either your driver is not using .setup hook to do the firmware patching or it is returning before it has fully initialize the hardware, so please also add more information what is happening on the driver side.

Hi, all

Please check https://bugs.launchpad.net/bugs/1221618

It's already fixed in btusb. However, if it's related to initialization as Luiz and I guessed, maybe other hardwares have this issue too, that's the reason I submitted that harmless retry "workaround" into BlueZ. (have no objection to NAK)

Signature · 2 lines
Adam Lee
http://adam8157.info