All of lore.kernel.org
 help / color / mirror / Atom feed
From: Manish Mandlik <mmandlik@google.com>
To: marcel@holtmann.org, luiz.dentz@gmail.com
Cc: linux-bluetooth@vger.kernel.org,
	chromeos-bluetooth-upstreaming@chromium.org,
	Manish Mandlik <mmandlik@google.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Johan Hedberg <johan.hedberg@gmail.com>,
	Paolo Abeni <pabeni@redhat.com>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH v3 2/3] Bluetooth: Add sysfs entry to enable/disable devcoredump
Date: Thu,  7 Jul 2022 15:15:15 -0700	[thread overview]
Message-ID: <20220707151420.v3.2.I39885624992dacff236aed268bdaa69107cd1310@changeid> (raw)
In-Reply-To: <20220707151420.v3.1.Iaf638bb9f885f5880ab1b4e7ae2f73dd53a54661@changeid>

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 sysfs
entry as follow:

$ echo 1 > /sys/class/bluetooth/<device>/enable_coredump

Signed-off-by: Manish Mandlik <mmandlik@google.com>
---

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 = 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 = to_hci_dev(dev);
+
+	/* Consider any non-zero value as true */
+	if (simple_strtol(buf, NULL, 10))
+		hdev->dump.enabled = true;
+	else
+		hdev->dump.enabled = false;
+
+	return count;
+}
+DEVICE_ATTR_RW(enable_coredump);
+#endif
+
+static struct attribute *bt_host_attrs[] = {
+#ifdef CONFIG_DEV_COREDUMP
+	&dev_attr_enable_coredump.attr,
+#endif
+	NULL,
+};
+ATTRIBUTE_GROUPS(bt_host);
+
 static const struct device_type bt_host = {
 	.name    = "host",
 	.release = bt_host_release,
+	.groups = bt_host_groups,
 };
 
 void hci_init_sysfs(struct hci_dev *hdev)
-- 
2.37.0.rc0.161.g10f37bed90-goog


  reply	other threads:[~2022-07-07 22:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-07 22:15 [PATCH v3 1/3] Bluetooth: Add support for devcoredump Manish Mandlik
2022-07-07 22:15 ` Manish Mandlik [this message]
2022-07-08  6:52   ` [PATCH v3 2/3] Bluetooth: Add sysfs entry to enable/disable devcoredump kernel test robot
2022-07-08 17:24   ` Luiz Augusto von Dentz
     [not found]     ` <CAGPPCLDBVwaXNbr6_wsj-M+Lbdbn6CbZippHYS5F-2vREBPHbg@mail.gmail.com>
2022-07-08 18:40       ` Luiz Augusto von Dentz
     [not found]         ` <CAGPPCLAUjB+K7SV=jv0sD=Gssrw1XSNgfHdj06=DxAUd4O12Fg@mail.gmail.com>
2022-07-08 23:18           ` Luiz Augusto von Dentz
2022-07-07 22:15 ` [PATCH v3 3/3] Bluetooth: btusb: Add Intel devcoredump support Manish Mandlik
2022-07-07 23:01 ` [v3,1/3] Bluetooth: Add support for devcoredump bluez.test.bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220707151420.v3.2.I39885624992dacff236aed268bdaa69107cd1310@changeid \
    --to=mmandlik@google.com \
    --cc=chromeos-bluetooth-upstreaming@chromium.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=johan.hedberg@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.