linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: Alex Lu <alex_lu@realsil.com.cn>
Cc: Johan Hedberg <johan.hedberg@gmail.com>,
	linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
	Max Chou <max.chou@realtek.com>
Subject: Re: [PATCH] Bluetooth: btusb: Use cmd_timeout to reset Realtek device
Date: Wed, 4 Sep 2019 16:23:29 +0200	[thread overview]
Message-ID: <989DBD04-B5DC-4733-8784-93B45BA9FF15@holtmann.org> (raw)
In-Reply-To: <20190903094103.GA10714@laptop-alex>

Hi Alex,

> Realtek Bluetooth controller provides a BT_DIS reset pin for hardware
> reset of it. The cmd_timeout is helpful on Realtek bluetooth controller
> where the firmware gets stuck.
> 
> Signed-off-by: Alex Lu <alex_lu@realsil.com.cn>
> ---
> drivers/bluetooth/btusb.c | 29 +++++++++++++++++++++--------
> 1 file changed, 21 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> index 31d3febed187..a626de3a3f4c 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -489,16 +489,19 @@ struct btusb_data {
> 	int (*setup_on_usb)(struct hci_dev *hdev);
> 
> 	int oob_wake_irq;   /* irq for out-of-band wake-on-bt */
> -	unsigned cmd_timeout_cnt;
> +	unsigned int cmd_timeout_cnt;
> +	unsigned int cmd_timeout_max;
> +	unsigned int reset_msecs;
> +	int reset_gpio_value;
> };
> 
> 
> -static void btusb_intel_cmd_timeout(struct hci_dev *hdev)
> +static void btusb_cmd_timeout(struct hci_dev *hdev)
> {
> 	struct btusb_data *data = hci_get_drvdata(hdev);
> 	struct gpio_desc *reset_gpio = data->reset_gpio;
> 
> -	if (++data->cmd_timeout_cnt < 5)
> +	if (++data->cmd_timeout_cnt < data->cmd_timeout_max)
> 		return;
> 
> 	if (!reset_gpio) {
> @@ -519,9 +522,9 @@ static void btusb_intel_cmd_timeout(struct hci_dev *hdev)
> 	}
> 
> 	bt_dev_err(hdev, "Initiating HW reset via gpio");
> -	gpiod_set_value_cansleep(reset_gpio, 1);
> -	msleep(100);
> -	gpiod_set_value_cansleep(reset_gpio, 0);
> +	gpiod_set_value_cansleep(reset_gpio, data->reset_gpio_value);
> +	msleep(data->reset_msecs);
> +	gpiod_set_value_cansleep(reset_gpio, !data->reset_gpio_value);
> }

I really prefer that no Realtek specifics end up in a callback that is meant for Intel hardware. So this needs to be split.

So can you just provide a btusb_rtl_cmd_timeout callback and set it in case of Realtek hardware.

Regards

Marcel


      reply	other threads:[~2019-09-04 14:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-03  9:41 [PATCH] Bluetooth: btusb: Use cmd_timeout to reset Realtek device Alex Lu
2019-09-04 14:23 ` Marcel Holtmann [this message]

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=989DBD04-B5DC-4733-8784-93B45BA9FF15@holtmann.org \
    --to=marcel@holtmann.org \
    --cc=alex_lu@realsil.com.cn \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=max.chou@realtek.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).