Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1144050rwr; Wed, 3 May 2023 10:43:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ75pTb6vt7bivfvy5LM1JPZN00i6lQPvylFpynnNwGi4GXvNR4GpHOVWa38I+dHQrYowmWn X-Received: by 2002:a17:903:2450:b0:1ab:19ff:3a20 with SMTP id l16-20020a170903245000b001ab19ff3a20mr1001789pls.54.1683135831684; Wed, 03 May 2023 10:43:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683135831; cv=none; d=google.com; s=arc-20160816; b=S1fkJkVe08jSmB0MIC+CI8s4foLKTCBTfxbe0XKA7sPdJ1rh7l21dz+msKC2d/1kuJ +pXKYa5f/jFt+k8ODYGj2b6ArIYHk+zVUGhZSDfpmZ50W3HELj+J1U68raQcnP4MsukY 2Jv/VDlXXs5eZyF7l9R5H3jyiNVDVwXcpLpDZ0uwoNx9/buwe+eu2CIIFGHoWWBSL+rV QPEBlsIRpM+99KM8zjOk1Wj5R5nwP1ZuaGKqsfU38lL9K+RRX0Mcq58E+JsnyKkDChR8 TJXjXflZEiu/e3+LGNE7ds2DjEjWkyP1qRjJFGqxRXBvgE99QoJBHw80yqOCw7gNjZsi FDYw== 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=XqIFFECjD8VbhTkVXBRW7iw73ClVU9Rx1DVSjMQg4AI=; b=RDYUqV8xhmLJYJSIIABjb4Hkrm01c/pZP0Pr0TWy6ehB0qiF2JNasuxzvhNQKmc45L 8ITgxhdy9y/45s+UStYOwbmQ3kN+j0yPsBoQJ2m6ca0FqR4u/InJZgWnE3oLyLO0HBnZ wXtKbuPwD4XWhsBCGTgIzYBkSl0inKEZXnzgPup5cd0++cXzT2hHYcxQd573shK0yAio wZdv/5/F/Qn5ZYNQoETOifHm8RIcVcgxAPthWTwm/2BuZwbmtDSvVVvnTLizUyVgbbeS 0sJgEKYGuudPKXBKzO3WBXDNZkWhl+LJ+nsDHGHE244Be4+lVgS7r1vPmEotqKNlF7Le IfXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="bkI/H/0R"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 f12-20020a170902ce8c00b001a97262fe53si27838178plg.552.2023.05.03.10.43.39; Wed, 03 May 2023 10:43:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=20221208 header.b="bkI/H/0R"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S229772AbjECReX (ORCPT + 99 others); Wed, 3 May 2023 13:34:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbjECReW (ORCPT ); Wed, 3 May 2023 13:34:22 -0400 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8995AC; Wed, 3 May 2023 10:34:20 -0700 (PDT) Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2a8dd1489b0so54372701fa.3; Wed, 03 May 2023 10:34:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683135259; x=1685727259; 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=XqIFFECjD8VbhTkVXBRW7iw73ClVU9Rx1DVSjMQg4AI=; b=bkI/H/0RlNbJpxMKaE08VNPaEMX7VGjhwLUeyFtckK/cp88nmGMTBJKDedNpmrkny0 PrY0Nk2uy406S0HQ4FV9zlP0FC/MoJV33b5FInYHwRD/qPY3imf19obSMfi6kmIpzcvU S+rrro7FK8NvGuk8U4e9x0uiyeOTWlFwdAhk98+j5fPl7H8Mjpr/gKdEJpWPtip5rQqL nXqxfZO8+iJ9gf0wR2cbnqjvTMhoJ6Yh+4jqJQ7hojgAC4uLhEIu6G5qJh1TqFaviwi/ HdS8sMeifnzXvqzHSLlHNRScTL6BTp2z4q0WH1+T1WmsG0tKRjGkMZ/yKJ5JrvPEsnVJ fMPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683135259; x=1685727259; 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=XqIFFECjD8VbhTkVXBRW7iw73ClVU9Rx1DVSjMQg4AI=; b=kMx/ja9NOpUnhfC1TqJs5T6dUx30jxn/Rx769nCjgC6mE4zWFsDZSaHhO5JDH1B0Br B1P8WCMzXWPRWzfLFBTWlojuVdmFHLsBLgCtRcJAAVWaRX6+8/qvfOAHcnLxXrB1Th9w wk6PuX6XY3MAOFyHeukOoSucHEFINYC/wSUthqtriX0YrmY9PJuN7VLMp3Ws3HSXXH0f 2Aut4D0NkpDGhGtMNgTpsrhrx2ykY7yRqoc0HYQft4kVcFwan2Lq8oSymBk2D8NiySON fqNJTO69ClzToFNsGWWa7t9J5ShZrsPSJx1/FQ06ndYgVmc2VROEChHXIMNWcillrV3k +14A== X-Gm-Message-State: AC+VfDzSvx4b7jsF1E/EKuNIENOO8vpZ94RK5hH5ULCisdyv3kFOlcJO Fdy98ypxKPPbMTadttkW/CcjnruklpKYfO4TgUI= X-Received: by 2002:a2e:94ca:0:b0:2a8:e670:c3cc with SMTP id r10-20020a2e94ca000000b002a8e670c3ccmr228651ljh.16.1683135258825; Wed, 03 May 2023 10:34:18 -0700 (PDT) MIME-Version: 1.0 References: <20230424124852.12625-1-johan+linaro@kernel.org> <20230424124852.12625-2-johan+linaro@kernel.org> In-Reply-To: From: Luiz Augusto von Dentz Date: Wed, 3 May 2023 10:34:06 -0700 Message-ID: Subject: Re: [PATCH 1/2] Bluetooth: fix debugfs registration To: Johan Hovold Cc: Johan Hovold , Marcel Holtmann , Johan Hedberg , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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-kernel@vger.kernel.org Hi Johan, On Wed, May 3, 2023 at 12:04=E2=80=AFAM Johan Hovold wro= te: > > On Tue, May 02, 2023 at 04:37:51PM -0700, Luiz Augusto von Dentz wrote: > > Hi Johan, > > > > On Mon, Apr 24, 2023 at 5:50=E2=80=AFAM Johan Hovold wrote: > > > > > > Since commit ec6cef9cd98d ("Bluetooth: Fix SMP channel registration f= or > > > unconfigured controllers") the debugfs interface for unconfigured > > > controllers will be created when the controller is configured. > > > > > > There is however currently nothing preventing a controller from being > > > configured multiple time (e.g. setting the device address using btmgm= t) > > > which results in failed attempts to register the already registered > > > debugfs entries: > > > > > > debugfs: File 'features' in directory 'hci0' already present! > > > debugfs: File 'manufacturer' in directory 'hci0' already pres= ent! > > > debugfs: File 'hci_version' in directory 'hci0' already prese= nt! > > > ... > > > debugfs: File 'quirk_simultaneous_discovery' in directory 'hc= i0' already present! > > > > > > Add a controller flag to avoid trying to register the debugfs interfa= ce > > > more than once. > > > > > > Fixes: ec6cef9cd98d ("Bluetooth: Fix SMP channel registration for unc= onfigured controllers") > > > Cc: stable@vger.kernel.org # 4.0 > > > Signed-off-by: Johan Hovold > > > --- > > > > diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c > > > index 632be1267288..a8785126df75 100644 > > > --- a/net/bluetooth/hci_sync.c > > > +++ b/net/bluetooth/hci_sync.c > > > @@ -4501,6 +4501,9 @@ static int hci_init_sync(struct hci_dev *hdev) > > > !hci_dev_test_flag(hdev, HCI_CONFIG)) > > > return 0; > > > > > > + if (hci_dev_test_and_set_flag(hdev, HCI_DEBUGFS_CREATED)) > > > + return 0; > > > > Can't we just use HCI_SETUP like we do with in create_basic: > > > > if (hci_dev_test_flag(hdev, HCI_SETUP)) > > hci_debugfs_create_basic(hdev); > > > > Actually we might as well move these checks directly inside the > > hci_debugfs function to make sure these only take effect during the > > setup/first init. > > The problem is that commit ec6cef9cd98d ("Bluetooth: Fix SMP channel > registration for unconfigured controllers") started deferring creation > of most parts of the debugfs interface until the controller is > configured (e.g. as some information is not available until then). > > Moving everything back to setup-time would effectively revert that. Not moving back but just doing something like: diff --git a/net/bluetooth/hci_debugfs.c b/net/bluetooth/hci_debugfs.c index ec0df2f9188e..a6e94c29fc5a 100644 --- a/net/bluetooth/hci_debugfs.c +++ b/net/bluetooth/hci_debugfs.c @@ -310,6 +310,9 @@ DEFINE_INFO_ATTRIBUTE(firmware_info, fw_info); void hci_debugfs_create_common(struct hci_dev *hdev) { + if (!hci_dev_test_flag(hdev, HCI_SETUP)) + return; + debugfs_create_file("features", 0444, hdev->debugfs, hdev, &features_fops); debugfs_create_u16("manufacturer", 0444, hdev->debugfs, > Perhaps the interface can be changed in some way so that everything is > again registered at setup-time (e.g. with placeholder values instead of > conditionally created attributes), but that would at least not be > something that we could backport. > > > > hci_debugfs_create_common(hdev); > > > > > > if (lmp_bredr_capable(hdev)) > > Johan --=20 Luiz Augusto von Dentz