1.4.1-bluetooth-sync.patch 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. From 640b53438c20818b3e344343b58b1f1765606a85 Mon Sep 17 00:00:00 2001
  2. From: Martin Pitt <martin.pitt@ubuntu.com>
  3. Date: Mon, 31 Jan 2011 15:30:01 +0100
  4. Subject: [PATCH] 49bluetooth: Wait for btusb module to get unused
  5. The 49bluetooth hook disables /proc/acpi/ibm/bluetooth but this isn't
  6. synchronous, i. e. it doesn't wait until the module usage count actually drops
  7. to 0. Due to that, it's impossible to add btusb to SUSPEND_MODULES (on some
  8. models/older kernels you need to do that to fix suspend problems), as at that
  9. point the module is still in use.
  10. On my system (ThinkPad X201) the module takes between 0.3 and 0.5 seconds to
  11. unload, so use 100 ms wait steps with a timeout of 2 seconds.
  12. Bug: https://bugs.freedesktop.org//show_bug.cgi?id=33759
  13. Bug-Ubuntu: https://launchpad.net/bugs/698331
  14. ---
  15. pm/sleep.d/49bluetooth | 9 +++++++++
  16. 1 files changed, 9 insertions(+), 0 deletions(-)
  17. diff --git a/pm/sleep.d/49bluetooth b/pm/sleep.d/49bluetooth
  18. index d46ba49..0dc1909 100755
  19. --- a/pm/sleep.d/49bluetooth
  20. +++ b/pm/sleep.d/49bluetooth
  21. @@ -12,6 +12,15 @@ suspend_bluetooth()
  22. if grep -q enabled /proc/acpi/ibm/bluetooth; then
  23. savestate ibm_bluetooth enable
  24. echo disable > /proc/acpi/ibm/bluetooth
  25. +
  26. + # wait for up to 2 seconds for the module to actually get
  27. + # unused
  28. + TIMEOUT=20
  29. + while [ $TIMEOUT -ge 0 ]; do
  30. + [ `cat /sys/module/btusb/refcnt` = 0 ] && break
  31. + TIMEOUT=$((TIMEOUT-1))
  32. + sleep 0.1
  33. + done
  34. else
  35. savestate ibm_bluetooth disable
  36. fi
  37. --
  38. 1.7.2.3