# [SOLVED] Something is subtly broken, Bluetooth can't connect

## sunset_sergal

Hello world! First time posting in the forums but I've been using Gentoo for years now.

I use PlayStation 3 controllers over Bluetooth on my desktop, and I noticed that after a kernel rebuild, I can no longer use them. They try to connect and immediately disconnect again. PlayStation 4 controllers and a Bose speaker still work fine.

I turned on debugging output for Bluez and got this in daemon.log:

```
May 22 10:48:02 sunset-desktop5 bluetoothd[3866]: src/adapter.c:connected_callback() hci0 device 04:76:6E:F4:9B:59 connected eir_len 5

May 22 10:48:02 sunset-desktop5 bluetoothd[3866]: src/adapter.c:dev_disconnected() Device 04:76:6E:F4:9B:59 disconnected, reason 3

May 22 10:48:02 sunset-desktop5 bluetoothd[3866]: src/adapter.c:adapter_remove_connection() 

May 22 10:48:02 sunset-desktop5 bluetoothd[3866]: plugins/policy.c:disconnect_cb() reason 3

May 22 10:48:02 sunset-desktop5 bluetoothd[3866]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr 04:76:6E:F4:9B:59 type 0 status 0xe

May 22 10:48:02 sunset-desktop5 bluetoothd[3866]: src/device.c:device_bonding_complete() bonding (nil) status 0x0e

May 22 10:48:02 sunset-desktop5 bluetoothd[3866]: src/device.c:device_bonding_failed() status 14

May 22 10:48:02 sunset-desktop5 bluetoothd[3866]: src/adapter.c:resume_discovery() 

May 22 10:48:03 sunset-desktop5 bluetoothd[3866]: src/adapter.c:connected_callback() hci0 device 04:76:6E:F4:9B:59 connected eir_len 5

May 22 10:48:03 sunset-desktop5 bluetoothd[3866]: src/adapter.c:dev_disconnected() Device 04:76:6E:F4:9B:59 disconnected, reason 3

May 22 10:48:03 sunset-desktop5 bluetoothd[3866]: src/adapter.c:adapter_remove_connection() 

May 22 10:48:03 sunset-desktop5 bluetoothd[3866]: plugins/policy.c:disconnect_cb() reason 3

May 22 10:48:03 sunset-desktop5 bluetoothd[3866]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr 04:76:6E:F4:9B:59 type 0 status 0xe

May 22 10:48:03 sunset-desktop5 bluetoothd[3866]: src/device.c:device_bonding_complete() bonding (nil) status 0x0e

May 22 10:48:03 sunset-desktop5 bluetoothd[3866]: src/device.c:device_bonding_failed() status 14

May 22 10:48:03 sunset-desktop5 bluetoothd[3866]: src/adapter.c:resume_discovery() 

...
```

Nothing related to Bluetooth shows up in dmesg.

I don't remember exactly what I did to troubleshoot from that point but it didn't appear to be a problem with bluetoothd. So I tried booting an older kernel, and hey, my controllers work again! So, OK, it's a kernel problem. I'll just rebuild the newer kernel, right?

This is where it gets weird. ANY kernel I build with this system is broken in the same way, doesn't matter if it's newer or older than the known-working one. And I'm absolutely sure the controllers were working on older kernels at the time they were new, just not when I rebuild a similar kernel now. So, OK, there's probably something wrong with my @system packages. This is a testing keyword system, so I'll just reboot into my stable partition and surely that one can build a working kernel, right?

... Well the first thing I did is update the stable system THEN try to update its kernel and now it can't build a working kernel anymore either. By the way, its old kernel still works too.

I think the dates the working kernels were built might be a clue to what's changed since then that might be causing the problem. So between both systems the kernels are:

4.19.27-gentoo-r1 built April 29, working

4.19.44-gentoo built May 22, NOT working

5.1.0-gentoo built May 8, working

5.1.3-gentoo built May 21, NOT working

I also tried building 5.0.17-gentoo but it didn't work either and I no longer have it installed.

tl;dr ANY kernel I build on up-to-date Gentoo amd64 OR ~amd64 system has a broken Bluetooth stack and PlayStation 3 accessories will connect then immediately disconnect.

If needed I could provide the kconfig but 1) it's cousins to allmodconfig so it's a big paste and 2) I don't think it's relevant since I can use the exact same config from the working kernel to build a broken kernel.

emerge --info from the ~amd64 system:

```
Portage 2.3.66 (python 3.6.8-final-0, default/linux/amd64/17.0/desktop, gcc-9.1.0, glibc-2.29-r2, 5.1.3-gentoo x86_64)

=================================================================

System uname: Linux-5.1.3-gentoo-x86_64-AMD_Ryzen_5_2400G_with_Radeon_Vega_Graphics-with-gentoo-2.6

KiB Mem:    32095744 total,  25080316 free

KiB Swap:   16760824 total,  16760824 free

Timestamp of repository gentoo: Tue, 21 May 2019 23:04:37 +0000

Head commit of repository gentoo: cf7b51a305a4d43435ba8f3b8d383089495c8c80

Timestamp of repository Case_Of: Sat, 18 May 2019 19:53:10 +0000

Head commit of repository Case_Of: e8df11497bb7d4d3dee35fa4b2263f1f517c9849

Head commit of repository spring: d082038f1dd8aefd9de89153e5d322dc9a02e21c

Timestamp of repository steam-overlay: Fri, 17 May 2019 19:45:39 +0000

Head commit of repository steam-overlay: 5960464b6badba4ede25436987d56ec6e89d3f4d

Timestamp of repository sunset-repo: Tue, 21 May 2019 00:48:33 +0000

sh bash 5.0_p7

ld GNU ld (Gentoo 2.32 p2) 2.32.0

distcc 3.3.2 x86_64-pc-linux-gnu [disabled]

ccache version 3.7.1 [disabled]

app-shells/bash:          5.0_p7::gentoo

dev-java/java-config:     2.2.0-r4::gentoo

dev-lang/perl:            5.28.2-r1::gentoo

dev-lang/python:          2.7.16::gentoo, 3.6.8::gentoo

dev-util/ccache:          3.7.1::gentoo

dev-util/cmake:           3.14.4::gentoo

sys-apps/baselayout:      2.6-r1::gentoo

sys-apps/openrc:          0.41.2::gentoo

sys-apps/sandbox:         2.17::gentoo

sys-devel/autoconf:       2.13-r1::gentoo, 2.69-r4::gentoo

sys-devel/automake:       1.11.6-r3::gentoo, 1.16.1-r1::gentoo

sys-devel/binutils:       2.32-r1::gentoo

sys-devel/gcc:            8.3.0-r1::gentoo, 9.1.0::gentoo

sys-devel/gcc-config:     2.0::gentoo

sys-devel/libtool:        2.4.6-r5::gentoo

sys-devel/make:           4.2.1-r4::gentoo

sys-kernel/linux-headers: 5.0-r1::gentoo (virtual/os-headers)

sys-libs/glibc:           2.29-r2::gentoo

Repositories:

gentoo

    location: /usr/portage

    sync-type: git

    sync-uri: https://github.com/gentoo-mirror/gentoo

    priority: -1000

Case_Of

    location: /var/db/repos/Case_Of

    sync-type: git

    sync-uri: https://github.com/gentoo-mirror/Case_Of.git

    masters: gentoo

spring

    location: /var/db/repos/spring

    sync-type: git

    sync-uri: git://github.com/springlobby/overlay.git

    masters: gentoo

steam-overlay

    location: /var/db/repos/steam-overlay

    sync-type: git

    sync-uri: https://github.com/gentoo-mirror/steam-overlay.git

    masters: gentoo

crossdev

    location: /var/db/repos/crossdev

    masters: gentoo

    priority: 9999

sunset-repo

    location: /home/anony/Documents/sunset-repo

    masters: gentoo

    priority: 9999

Installed sets: @esteam, @pidgin-extra

ACCEPT_KEYWORDS="amd64 ~amd64"

ACCEPT_LICENSE="* -@EULA"

CBUILD="x86_64-pc-linux-gnu"

CFLAGS="-march=znver1 -O2 -ggdb -pipe"

CHOST="x86_64-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/gnupg/qualified.txt"

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"

CXXFLAGS="-march=znver1 -O2 -ggdb -pipe"

DISTDIR="/usr/portage/distfiles"

EMERGE_DEFAULT_OPTS=" --keep-going --buildpkg-exclude "virtual/* sys-kernel/*-sources""

ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"

FCFLAGS="-march=znver1 -O2 -ggdb -pipe"

FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs buildpkg cgroup compressdebug config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch parallel-install pid-sandbox preserve-libs protect-owned sandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"

FFLAGS="-march=znver1 -O2 -ggdb -pipe"

GENTOO_MIRRORS="ftp://ftp.gtlib.gatech.edu/pub/gentoo  ftp://mirrors.rit.edu/gentoo/  ftp://ftp.ussg.iu.edu/pub/linux/gentoo  ftp://mirror.csclub.uwaterloo.ca/gentoo-distfiles/  ftp://mirrors.tera-byte.com/pub/gentoo"

LANG="en_US.utf8"

LDFLAGS="-Wl,-O1 -Wl,--as-needed"

MAKEOPTS="-j8"

PKGDIR="/var/packages"

PORTAGE_CONFIGROOT="/"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"

PORTAGE_TMPDIR="/var/tmp"

USE="X a52 aac acl acpi alsa amd64 berkdb bluetooth branding bzip2 cairo caps cdda cddb cdr cli crypt cups curl cvs cxx d3d9 dbus dri dts dvd dvdr egl elogind emboss encode exif fam ffmpeg flac fortran gd gdbm gif gimp git glamor gles1 gles2 gmp gpm gtk gtk3 ibus iconv icu ios ipod ipv6 jpeg jpeg2k lcms ldap libnotify libsamplerate libtirpc lz4 mad mng mod modplug mp3 mp4 mpeg mtp multilib mysql ncurses nls nptl offensive ogg openal opengl openmp opus pam pango pcre pdf pm-utils png policykit ppds qt5 readline samba sdl seccomp speex spell spice sqlite ssl startup-notification subversion svg taglib tcpd threads tiff truetype udev udisks unicode upower usb usbredir vaapi vdpau vim-syntax vnc vorbis webp wxwidgets x264 xattr xcb xinerama xml xpm xv xvid zeroconf zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="keyboard mouse synaptics wacom evdev" KERNEL="linux" L10N="en en-US en-GB es es-AR es-ES es-MX fr fr-FR fr-CA" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" NETBEANS_MODULES="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6 php7-1" POSTGRES_TARGETS="postgres9_5 postgres10" PYTHON_SINGLE_TARGET="python3_6" PYTHON_TARGETS="python2_7 python3_6" QEMU_SOFTMMU_TARGETS="aarch64 alpha arm hppa i386 m68k mips mips64 mips64el mipsel ppc ppc64 riscv32 riscv64 s390x sh4 sh4eb sparc64 x86_64" QEMU_USER_TARGETS="aarch64 alpha arm hppa i386 m68k mips mips64 mips64el mipsel ppc ppc64 riscv32 riscv64 s390x sh4 sh4eb sparc64 x86_64 armeb mipsn32 mipsn32el ppc64abi32 ppc64le" RUBY_TARGETS="ruby24" USERLAND="GNU" VIDEO_CARDS="nouveau amdgpu radeon radeonsi vesa" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"

Unset:  CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
```

Last edited by sunset_sergal on Mon May 27, 2019 5:01 pm; edited 1 time in total

----------

## netfab

Hi,

Kernel huge regression. Have a look here :

https://bugs.gentoo.org/686758

https://bugzilla.kernel.org/show_bug.cgi?id=203643

----------

## Ant P.

Between May 8 and now, did you switch to GCC 9.1? Try the older one.

----------

## sunset_sergal

Thank you both for replying!

Ant P: I did try an older GCC but it didn't help. And the kernel that worked was also built with GCC 9.1 so I didn't think that was the problem.

netfab: I looked at the pages you linked and ended up applying the RFC patch from the kernel mailing list to =sys-kernel/gentoo-sources-5.1.4 which fixed the problem for that kernel. This is good enough for me until the fix is in a released kernel, so I'll see if I can mark this thread solved.

----------

