Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp248790rwl; Thu, 30 Mar 2023 15:28:24 -0700 (PDT) X-Google-Smtp-Source: AKy350aBnYakC2x+2KV3B58sN51cODMYWqSIUtqSwiwHJeiM/mIqTSsR37wTKggG86gwSq9Bq5kS X-Received: by 2002:a17:902:d488:b0:1a1:a531:460f with SMTP id c8-20020a170902d48800b001a1a531460fmr27832998plg.50.1680215304342; Thu, 30 Mar 2023 15:28:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680215304; cv=none; d=google.com; s=arc-20160816; b=S/4LN7KqncTjxDQ8mIbTY0QHuT+qcvUafBE3m6oJcK+1YVDR2Z+g50J7Ppf9t3bJxO HhWp5AmzZV8cLUhbgNcduDB5rdxko/Yu+KZ/KI99nKZxMleJBArxnlLwkgbFrqraZ7ir xdUc4+pix+yeMSQqNZFx4Ukm6vnN3psRLlRnB0R0rHCvz9z/YV83lAIZDmi0uwiHZPyG MPivWa/eCYN0+KX5D+n0Tv9oq1uf4/0iYQCPneblJ9kn45J35wmY3jqPhRIWq0VTVM0n 3aMsdwK7GAk1ctnePlB0Mjv08PV7XxCwZ0Wc+8WrXzKki1+pPha0y5LaZBj3fOTMg/Xh BEhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=/PgkNQgo8x0DC6BNHtD9VdT/F1pDHbNRv8SasvQmLCM=; b=coKDaa+UdzF6ws3WSDFpjGHFRstqZqZ4Nv4JgU8ohMte/2mTGzoDgT4nGAT1YivOL9 jqRcUPcMxuoY+vmjdIp9oT8KeW4Z1TU2Rf0SKueMSeivokd4iQiTmaKXDuQvk5qX2Pw5 ojVyT6N7ItLLZbq8GSK8p+1vZtX+5QTvarnz0NdlqyrLzV8WZC7H+HQ3YHK4V1yZxvUS XlYBl6Rk+cMgMCsS0dae1H76OJFqa7ggnKUlUwnwqDQhikF33hJcPo49v9kdz9FGu0th zPRP9lD9GUVJV6EyhZrr+NsNClwwrXbUOeM9rZBQYcYQreznUVclwz8kRZH7Hnn3Ixlc 01ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LG6cG8ud; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z8-20020a170902708800b0019955f0dc48si555467plk.527.2023.03.30.15.28.07; Thu, 30 Mar 2023 15:28:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LG6cG8ud; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230305AbjC3W0D (ORCPT + 99 others); Thu, 30 Mar 2023 18:26:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230282AbjC3W0B (ORCPT ); Thu, 30 Mar 2023 18:26:01 -0400 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D609BCA31 for ; Thu, 30 Mar 2023 15:25:59 -0700 (PDT) Received: by mail-lj1-x234.google.com with SMTP id e9so5905426ljq.4 for ; Thu, 30 Mar 2023 15:25:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680215158; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=/PgkNQgo8x0DC6BNHtD9VdT/F1pDHbNRv8SasvQmLCM=; b=LG6cG8uddXcDf2n33RE7IBBrWMcUsPdFXWCfBghn9+9yT+S8rcraU8Lth8d5EpjLG7 n9MhyLHoihwj89P+L8oUD4xpoFIpnX0KQFDh2YW1gVTwTEQ8Pr1GGYvV8wrcokoOtWFT UNQ3NwFtx50GMTqHk84eWAIS+bZimOiM4rO/iCGFVC7bDCkl27xi8h0Jnw7nIW3gmtqu YJ152l4rRwrxE9PBzd2sr5Z0UiIikF+F7hFSh8MYXOteNDPYCi2ffEpo0ZDA8Th16y/0 Om0nCqSEoWo+kNQZ58bvk2DzpsAXyd7PtMsJkIATHukf6tGFN72mnTdZk0QTaK7L00+D a41Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680215158; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/PgkNQgo8x0DC6BNHtD9VdT/F1pDHbNRv8SasvQmLCM=; b=IZCM1k0rmQS48qvdDb8Ycee5TICqOV5Vb9QQZYji+48Zetp76J+BjtMh1QA9e5VATC SUQMpOKpZ5PXibgy+3vd5bqjC7lHcthSf+j4Lp/zFHEjEL+6IdnzNiCVv89/lM6EaF+C vBXZYnln7Hbw42pVO/0clC5KbqXvkAJNczXl50iyzlw88TuONT8OiHoZNtPxayJjnuK9 SfXQ7i8juWp9PO5O2E42FRqjEEZ3tR/bEU9DIvSexL5z8H4PkoTLHYp57BVTFGQqM6o5 CDPPD27s4D3LVcwfuKGAVijqcM9QgRMb4YYa82YOuLX8ebdTP/QlCXLziKWzyS1cHftv AzzA== X-Gm-Message-State: AAQBX9c4AOqrIIZIhxeVAC+/HuOIpO7Y4xD266jdRCaFc447Eu4E0RK0 WLmuE/plIIZC5FEXZrQhkuPG+qHlY5YVcMDXKFuAQUuQ3o8= X-Received: by 2002:a2e:a307:0:b0:2a6:18c0:2b41 with SMTP id l7-20020a2ea307000000b002a618c02b41mr1318102lje.0.1680215157568; Thu, 30 Mar 2023 15:25:57 -0700 (PDT) MIME-Version: 1.0 References: <20230330211233.102136-1-hdegoede@redhat.com> <39877b39f5575cbfc89e567cb082741b47d02654.camel@hadess.net> In-Reply-To: <39877b39f5575cbfc89e567cb082741b47d02654.camel@hadess.net> From: Luiz Augusto von Dentz Date: Thu, 30 Mar 2023 15:25:46 -0700 Message-ID: Subject: Re: [PATCH] adapter: Use regular discovery for filters which only have discoverable set To: Bastien Nocera Cc: Hans de Goede , linux-bluetooth@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Bastien, On Thu, Mar 30, 2023 at 3:08=E2=80=AFPM Bastien Nocera = wrote: > > Top posting to comment on the subject. It should have "[BlueZ PATCH]" > as the prefix so that the user-space CI runs on it. It should be fine in this case CI seem to have figured it out without it: https://patchwork.kernel.org/project/bluetooth/patch/20230330211855.102798-= 1-hdegoede@redhat.com/ > On Thu, 2023-03-30 at 23:12 +0200, Hans de Goede wrote: > > discovery_filter_to_mgmt_cp() does not add > > discovery_filter.discoverable > > to the created mgmt_cp_start_service_discovery struct. > > > > Instead update_discovery_filter() seprately checks > > client->discovery_filter->discoverable for all clients. > > "separately". > > > This means that for discovery-filters which only have the > > discoverable > > flag set, to put the adapter in discoverable mode while discovering, > > the created mgmt_cp_start_service_discovery struct is empty. > > > > This empty mgmt_cp_start_service_discovery struct then gets send > > "sent" > > > to the kernel as part of a MGMT_OP_START_SERVICE_DISCOVERY msg > > by start_discovery_timeout(). > > > > This use of an empty filter with MGMT_OP_START_SERVICE_DISCOVERY > > causes some bluetooth devices to not get seen with some (most?) > > Broadcom bluetooth adapters. This problem has been observed with > > the following Broadcom models: BCM4343A0, BCM43430A1, BCM43341B0 . > > > > On these models the following 2 devices were not being discovered > > when starting a scan with a filter with just discoverable set > > in the filter (as gnome-bluetooth does): > > > > Device 09:02:01:03:0F:87 (public) > > Name: Bluetooth 3.0 Keyboard > > Alias: Bluetooth 3.0 Keyboard > > Class: 0x00000540 > > Icon: input-keyboard > > Paired: yes > > Bonded: yes > > Trusted: yes > > Blocked: no > > Connected: yes > > WakeAllowed: yes > > LegacyPairing: yes > > UUID: Service Discovery Serve.. (00001000-0000-1000-8000- > > 00805f9b34fb) > > UUID: Human Interface Device... (00001124-0000-1000-8000- > > 00805f9b34fb) > > UUID: PnP Information (00001200-0000-1000-8000- > > 00805f9b34fb) > > Modalias: bluetooth:v05ACp022Cd011B > > > > Device 00:60:D1:00:00:34 (public) > > Name: Bluetooth Mouse > > Alias: Bluetooth Mouse > > Class: 0x00002580 > > Icon: input-mouse > > Paired: yes > > Bonded: yes > > Trusted: yes > > Blocked: no > > Connected: yes > > WakeAllowed: yes > > LegacyPairing: no > > UUID: Human Interface Device... (00001124-0000-1000-8000- > > 00805f9b34fb) > > UUID: PnP Information (00001200-0000-1000-8000- > > 00805f9b34fb) > > Modalias: usb:v0103p0204d001E > > > > Since setting the discoverable flag on a filter only is a way to > > automatically put the adapter in discoverable mode itself while > > it is discovering; and since this does not any device filtering > > at all; modify merge_discovery_filters() to treat discovery with > > such filters as regular unfiltered discovery. > > > > This results in start_discovery_timeout() starting regular > > discovery through a MGMT_OP_START_DISCOVERY message and this > > fixes these 2 example devices not getting discovered by the > > mentioned Broadcom BT adapter models. > > > > Link: > > https://gitlab.gnome.org/GNOME/gnome-bluetooth/-/merge_requests/163 > > --- > > Note the same argument can be made for the pattern and duplicate part > > of > > the filters which also get handled outside of the kernel filter. > > But I prefer to keep the first patch small and targetted at solving > > things > > not working with the gnome-bluetooth filter settings. > > > > Also I'm not familiar enough with the code to say with certainty that > > filters with just a pattern or the duplicate flag set (or a > > combination) > > should also be treated as unfiltered discovery. > > --- > > src/adapter.c | 17 ++++++++++++++++- > > 1 file changed, 16 insertions(+), 1 deletion(-) > > > > diff --git a/src/adapter.c b/src/adapter.c > > index 7947160a6..cc7f891d9 100644 > > --- a/src/adapter.c > > +++ b/src/adapter.c > > @@ -2192,6 +2192,7 @@ static int merge_discovery_filters(struct > > btd_adapter *adapter, int *rssi, > > bool empty_uuid =3D false; > > bool has_regular_discovery =3D false; > > bool has_filtered_discovery =3D false; > > + uint8_t adapter_scan_type =3D get_scan_type(adapter); > > > > for (l =3D adapter->discovery_list; l !=3D NULL; l =3D > > g_slist_next(l)) { > > struct discovery_client *client =3D l->data; > > @@ -2202,6 +2203,20 @@ static int merge_discovery_filters(struct > > btd_adapter *adapter, int *rssi, > > continue; > > } > > > > + /* > > + * Detect empty filter with only discoverable > > + * (which does not require a kernel filter) set. > > + */ > > + if (item->uuids =3D=3D NULL && > > + item->pathloss =3D=3D DISTANCE_VAL_INVALID && > > + item->rssi =3D=3D DISTANCE_VAL_INVALID && > > + item->type =3D=3D adapter_scan_type && > > + item->duplicate =3D=3D false && > > + item->pattern =3D=3D NULL) { > > I would have split this chunky "if" into a separate function, but > otherwise the logic looks good. > > Reviewed-by: Bastien Nocera > > > + has_regular_discovery =3D true; > > + continue; > > + } > > + > > has_filtered_discovery =3D true; > > > > *transport |=3D item->type; > > @@ -2251,7 +2266,7 @@ static int merge_discovery_filters(struct > > btd_adapter *adapter, int *rssi, > > * It there is both regular and filtered scan > > running, then > > * clear whole fitler to report all devices. > > */ > > - *transport =3D get_scan_type(adapter); > > + *transport =3D adapter_scan_type; > > *rssi =3D HCI_RSSI_INVALID; > > g_slist_free(*uuids); > > *uuids =3D NULL; > --=20 Luiz Augusto von Dentz