lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Mon, 25 Jan 2021 18:51:27 +0100
From:   Marcel Holtmann <marcel@...tmann.org>
To:     Abhishek Pandit-Subedi <abhishekpandit@...omium.org>
Cc:     CrosBT Upstreaming <chromeos-bluetooth-upstreaming@...omium.org>,
        Miao-chen Chou <mcchou@...omium.org>, michaelfsun@...gle.com,
        Bluetooth Kernel Mailing List 
        <linux-bluetooth@...r.kernel.org>,
        Archie Pusaka <apusaka@...omium.org>,
        Johan Hedberg <johan.hedberg@...il.com>,
        Luiz Augusto von Dentz <luiz.dentz@...il.com>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/3] Bluetooth: btusb: Expose reset gpio to debugfs

Hi Abhishek,

> If btusb has a reset gpio, expose it to userspace so we can toggle the
> reset gpio directly. This is useful for testing and error recovery.
> 
> Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@...omium.org>
> Reviewed-by: Miao-chen Chou <mcchou@...omium.org>
> ---
> 
> drivers/bluetooth/btusb.c | 46 +++++++++++++++++++++++++++++++++++++++
> 1 file changed, 46 insertions(+)
> 
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> index 880e9cd4ee713..702be1871ed88 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -6,6 +6,7 @@
>  *  Copyright (C) 2005-2008  Marcel Holtmann <marcel@...tmann.org>
>  */
> 
> +#include <linux/debugfs.h>
> #include <linux/dmi.h>
> #include <linux/module.h>
> #include <linux/usb.h>
> @@ -574,6 +575,46 @@ static void btusb_toggle_gpio(struct gpio_desc *desc, unsigned int duration)
> 	gpiod_set_value_cansleep(desc, 0);
> }
> 
> +#ifdef CONFIG_DEBUG_FS
> +static ssize_t btusb_debugfs_has_reset_gpio(struct file *file,
> +					    char __user *user_buf,
> +					    size_t count, loff_t *ppos)
> +{
> +	struct hci_dev *hdev = file->private_data;
> +	struct btusb_data *data = hci_get_drvdata(hdev);
> +	char buf[3];
> +
> +	buf[0] = data->reset_gpio ? 'Y' : 'N';
> +	buf[1] = '\n';
> +	buf[2] = '\0';
> +
> +	return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
> +}
> +
> +static ssize_t btusb_debugfs_reset_gpio(struct file *file,
> +					const char __user *user_buf,
> +					size_t count, loff_t *ppos)
> +{
> +	struct hci_dev *hdev = file->private_data;
> +	struct btusb_data *data = hci_get_drvdata(hdev);
> +
> +	if (!data->reset_gpio)
> +		return -EOPNOTSUPP;
> +
> +	bt_dev_warn(hdev, "Debugfs triggering HW reset via gpio");
> +	btusb_toggle_gpio(data->reset_gpio, data->reset_duration_ms);
> +
> +	return count;
> +}
> +
> +static const struct file_operations reset_gpio_fops = {
> +	.open		= simple_open,
> +	.read		= btusb_debugfs_has_reset_gpio,
> +	.write		= btusb_debugfs_reset_gpio,
> +	.llseek		= default_llseek,
> +};
> +#endif

while I am not convinced that this is the right way, I am fine doing it temporarily. However, please lets create the debugfs file only when a reset GPIO is available and skip the read callback. Only the write one should be supported since there is no point to read the status. The pure existence of the debugfs should indicate support for a HW reset.

Regards

Marcel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ