Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1003576imw; Fri, 8 Jul 2022 16:20:29 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uDaZSDzNi3LTp8U9EOL0yxsyekOUmUGzkU68SWGGBGg1U4F/Zl46XplHPafjUneG6PxRLY X-Received: by 2002:a17:907:87b0:b0:72a:a14e:106d with SMTP id qv48-20020a17090787b000b0072aa14e106dmr6154254ejc.167.1657322429565; Fri, 08 Jul 2022 16:20:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657322429; cv=none; d=google.com; s=arc-20160816; b=rF3WIMFbYDVIG19A6FcuWQE3ufrOdd7cLE3XzefUqA1pUAmXoC4MCaT5WS1gxGj7nk Rypk38DDLNATZ60Zqqqqu4wjN0FlKVny/jsG38fa50EhPTelFGI06WhXBUG2KSrOFnJL TRt6egaeyv5t9G+9hHXicMxfkYD+09N0GbH1FZn/nTgJi6pO09ZEQVPu5pNWmYWNaT7I Plst65wPW9GgBY2WQkf3DNftl+YbHkMSdqW8T5GdqTPzXT1dWCSt0Q9SmkQde3r4EQCf +xP9Cuf9tvgIkVY4TCSRGzp0NoUo6V62qW8e1zOgMDGRIXZs3SrxSzuwcmq7n3f1OEWo FdAQ== 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=IUPSBY5O0wPXr4X6QM6WG5+hEBV1b7qpWXP+wxJALT8=; b=rF5JzOZAgJdN1wEB083b15OrIzU4hYJpbvPLDZXVMioArOvFDgx09r/Mg0L7nSfSJs 5pZN6HJJ93iWAhnhUHW59JqDqNsMvqspf8x1WN/idS3+uSnKAyKw2Op7G4rbs9XP7zbv eAU7XVCvUBTRcBsywnsqgCgutONPOFz0MzK/EM9p+35nYV25m76Cpkl9k/YCDyfv5d0L RQnZBQ7+abR4x7nkOdJRDcoz/u3ou64eRiOqQfRR9d4oGNFt8e9ue+tmJL305DFp9rN9 EmVCu/561YE+n3FsORQihXRTZITQumN2IDX/ai3aaPFgZ6g4CuOnIg4pqIGxydCcnzMD LXYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=H+8GUViL; 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 ga33-20020a1709070c2100b00726abdc7343si17831498ejc.454.2022.07.08.16.19.46; Fri, 08 Jul 2022 16:20:29 -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=H+8GUViL; 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 S237304AbiGHXTA (ORCPT + 99 others); Fri, 8 Jul 2022 19:19:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237068AbiGHXS5 (ORCPT ); Fri, 8 Jul 2022 19:18:57 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A1D241980; Fri, 8 Jul 2022 16:18:55 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id e12so102135lfr.6; Fri, 08 Jul 2022 16:18:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=IUPSBY5O0wPXr4X6QM6WG5+hEBV1b7qpWXP+wxJALT8=; b=H+8GUViLpESz1gn4xKCmTS1rrbzwh4TkMEgyRRRy/DBLz+9ECubw4caCgsfAof2keg 7+NJrnPIClRe6HBv/N2GRlAZOHmwaiMB5mSfIFrEAufm4DuF6wLAvJ4gsfll6eyWuT34 zH94HzrgXfUEWhHLhU2drLfCCC1c9xU2bsQDtQxr7kjtrUhmIk95d7jlCD/Q72jkBk0x l6pDpIOgqGjC7sdAp2KvT2W1rlZZgDMBhVVejTdB0Ac6fLK0LuaZZWofsza44+tmRKyk 0lRZ500Zn+G2hE//vc1t6eMxTBWvWt9Ziuaqvvqsvm/JqKEhAJs6soIMbHXPdGskKmrv NaEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=IUPSBY5O0wPXr4X6QM6WG5+hEBV1b7qpWXP+wxJALT8=; b=JbWMTeWluXLv80O5Ksr+FKwayD+A1J+SECGiJjV9jLJJ024EkyVnYYn53DlobFonnK eVI/HSqleLqRCbBpNRfgSMLA9p0G9ibJkMpvekTUWzDM76rgUD6yJW65AcgELliJnoZz 2bH0Ay3F3smuSkYWWcUiSYg8HJKtIOEf2Ci3u5Vxi1sA87Ub5NK+fpNLUpXceMBRk3ZJ CYeTjVPY9E6wAUySiM2WehW3U45KAVa7WrHRMb7K7gKZDBscSVuI4GnEBVsFfEPj21Fk 51MqJcVgAqGU2S/A3n6h7dWYOaAoADJBIV/DTPValyefgyeedObXAs4B8LL9D0ImDF2i Bb/g== X-Gm-Message-State: AJIora+UF/WEq9SV3a9c+6gTd6KgOQhQrmD1Rwx9lt94Ls8+Zu6WoE+L j622iJEE4iHLkUDsye4h8frEWNyrh6UzvZh4/mA= X-Received: by 2002:a05:6512:2621:b0:47f:d228:bdeb with SMTP id bt33-20020a056512262100b0047fd228bdebmr3672168lfb.121.1657322333638; Fri, 08 Jul 2022 16:18:53 -0700 (PDT) MIME-Version: 1.0 References: <20220707151420.v3.1.Iaf638bb9f885f5880ab1b4e7ae2f73dd53a54661@changeid> <20220707151420.v3.2.I39885624992dacff236aed268bdaa69107cd1310@changeid> In-Reply-To: From: Luiz Augusto von Dentz Date: Fri, 8 Jul 2022 16:18:42 -0700 Message-ID: Subject: Re: [PATCH v3 2/3] Bluetooth: Add sysfs entry to enable/disable devcoredump To: Manish Mandlik Cc: Marcel Holtmann , "linux-bluetooth@vger.kernel.org" , ChromeOS Bluetooth Upstreaming , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Johan Hedberg , Paolo Abeni , Linux Kernel Mailing List , "open list:NETWORKING [GENERAL]" 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-bluetooth@vger.kernel.org Hi Manish, On Fri, Jul 8, 2022 at 3:30 PM Manish Mandlik wrote: > > Hi Luiz, > > On Fri, Jul 8, 2022 at 11:40 AM Luiz Augusto von Dentz wrote: >> >> Hi Manish, >> >> On Fri, Jul 8, 2022 at 11:30 AM Manish Mandlik wro= te: >> > >> > Hi Luiz, >> > >> > On Fri, Jul 8, 2022 at 10:24 AM Luiz Augusto von Dentz wrote: >> >> >> >> Hi Manish, >> >> >> >> On Thu, Jul 7, 2022 at 3:15 PM Manish Mandlik w= rote: >> >> > >> >> > Since device/firmware dump is a debugging feature, we may not need = it >> >> > all the time. Add a sysfs attribute to enable/disable bluetooth >> >> > devcoredump capturing. The default state of this feature would be >> >> > disabled and it can be enabled by echoing 1 to enable_coredump sysf= s >> >> > entry as follow: >> >> > >> >> > $ echo 1 > /sys/class/bluetooth//enable_coredump >> >> > >> >> > Signed-off-by: Manish Mandlik >> >> > --- >> >> > >> >> > Changes in v3: >> >> > - New patch in the series to enable/disable feature via sysfs entry >> >> > >> >> > net/bluetooth/hci_sysfs.c | 36 +++++++++++++++++++++++++++++++++++= + >> >> > 1 file changed, 36 insertions(+) >> >> > >> >> > diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c >> >> > index 4e3e0451b08c..df0d54a5ae3f 100644 >> >> > --- a/net/bluetooth/hci_sysfs.c >> >> > +++ b/net/bluetooth/hci_sysfs.c >> >> > @@ -91,9 +91,45 @@ static void bt_host_release(struct device *dev) >> >> > module_put(THIS_MODULE); >> >> > } >> >> > >> >> > +#ifdef CONFIG_DEV_COREDUMP >> >> > +static ssize_t enable_coredump_show(struct device *dev, >> >> > + struct device_attribute *attr, >> >> > + char *buf) >> >> > +{ >> >> > + struct hci_dev *hdev =3D to_hci_dev(dev); >> >> > + >> >> > + return scnprintf(buf, 3, "%d\n", hdev->dump.enabled); >> >> > +} >> >> > + >> >> > +static ssize_t enable_coredump_store(struct device *dev, >> >> > + struct device_attribute *attr, >> >> > + const char *buf, size_t count) >> >> > +{ >> >> > + struct hci_dev *hdev =3D to_hci_dev(dev); >> >> > + >> >> > + /* Consider any non-zero value as true */ >> >> > + if (simple_strtol(buf, NULL, 10)) >> >> > + hdev->dump.enabled =3D true; >> >> > + else >> >> > + hdev->dump.enabled =3D false; >> >> > + >> >> > + return count; >> >> > +} >> >> > +DEVICE_ATTR_RW(enable_coredump); >> >> > +#endif >> >> > + >> >> > +static struct attribute *bt_host_attrs[] =3D { >> >> > +#ifdef CONFIG_DEV_COREDUMP >> >> > + &dev_attr_enable_coredump.attr, >> >> > +#endif >> >> > + NULL, >> >> > +}; >> >> > +ATTRIBUTE_GROUPS(bt_host); >> >> > + >> >> > static const struct device_type bt_host =3D { >> >> > .name =3D "host", >> >> > .release =3D bt_host_release, >> >> > + .groups =3D bt_host_groups, >> >> > }; >> >> > >> >> > void hci_init_sysfs(struct hci_dev *hdev) >> >> > -- >> >> > 2.37.0.rc0.161.g10f37bed90-goog >> >> >> >> It seems devcoredump.c creates its own sysfs entries so perhaps this >> >> should be included there and documented in sysfs-devices-coredump. >> > >> > I deliberately created it here. We need to have this entry/switch per = hci device, whereas the sysfs entry created by devcoredump.c disables the d= evcoredump feature entirely for anyone who's using it, so it can act as a g= lobal switch for the devcoredump. >> >> We should probably check if there is a reason why this is not on per >> device and anyway if seem wrong to each subsystem to come up with its >> own sysfs entries when it could be easily generalized so the userspace >> tools using those entries don't have to look into different entries >> depending on the subsystem the device belongs. > > The purpose of the base devcoredump interface is to only provide a genera= lized mechanism for drivers to dump the firmware data. It is not aware of w= hich subsystem is using it or what data is being dumped. We want to impleme= nt something on top of it only for all bluetooth drivers so that they all c= an generate firmware dumps in a common way and not worry about the synchron= izations and timeouts. That's why it made more sense to me to have a blueto= oth specific sysfs entry for enabling/disabling only the bluetooth devcored= ump interface without affecting the other users of the base devcoredump. It looks like we are not understanding each other, you are saying devcoredump only provides a generalized mechanism for the driver to dump the firmware coredump, yet we are implementing something extra to generalize it for bluetooth drivers? Making it bluetooth specific sort of defeat the purpose of a common layer in my opinion and it is not like the devcoredump.c don't already have entries inside the device sysfs directory as documented in sysfs-devices-coredump: What: /sys/devices/.../coredump Date: December 2017 Contact: Arend van Spriel Description: The /sys/devices/.../coredump attribute is only present when the device is bound to a driver, which provides the .coredump() callback. The attribute is write only. Anything written to this file will trigger the .coredump() callback. Available when CONFIG_DEV_COREDUMP is enabled. What I'm suggesting is in addition to /sys/devices/.../coredump we also have /sys/devices/.../enable_coredump, perhaps we should include in the discussion since he is listed as maintainer of DEV_COREDUMP nowadays. > Do you suggest we have this sysfs entry for bluetooth class instead? like= "/sys/class/bluetooth/enable_coredump" instead of "/sys/class/bluetooth//enable_coredump"? But the problem with this is that if we have more = than one bluetooth controller on the system, disabling one would disable th= e other as well. So to have the flexibility of controlling it for each devi= ce independently I am creating a sysfs entry for each device. IMO, the base= devcoredump class sysfs entry is not much of a use anymore as there are al= ready other systems like wifi using it. Let me know your thoughts. > >> >> >> > >> >> >> >> -- >> >> Luiz Augusto von Dentz >> > >> > >> > Regards, >> > Manish. >> >> >> >> -- >> Luiz Augusto von Dentz > > > Regards, > Manish. --=20 Luiz Augusto von Dentz