Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp762445ybe; Wed, 4 Sep 2019 07:24:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqzlGh9VzJkp6S1A7hyY+NBlFbofsjWyx6CQ3ZrJpNkt4rjCqEja7YWn2GgluaXeV0L3CYnQ X-Received: by 2002:a17:902:74c7:: with SMTP id f7mr37010102plt.263.1567607078579; Wed, 04 Sep 2019 07:24:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567607078; cv=none; d=google.com; s=arc-20160816; b=qA+rq2+6MeGFsutRQhnURED41cunb/B/+R4tTpXe4753nTJbFKiW7zZC8/Cq8o9pdn z/iuOY9BIDKp1YkL8AyDPjVjbWoSfUTBETxuDXtNpT7qR1VeDTrsosCXGXLR2EjSc35d JKvHA9OzbGSnYROERhO03T7x3s0mSlBHeqfjRSsR0jbvjXux+x7Zy8FT6v9D9jQ3vKF8 1dXNkan3c8UDGXeDY9iJLmM5atyP5yE7Mrc5fpRDMwPfcNcKG5WUsPcFy1lGg4LzK6SQ uv9XfUGTwOUeyKBJ/owccngJjua2bnXpkMhVXstduyuES6EuRBvB/HqkKDNtNWNNGHYf 8JOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=G9nZIpb/ZqgYK8sNtfnaCGU7DqEeWVbx2gPdDQAX1fo=; b=E7Rw7LqW14qz8NP8lqrwnJG1Dg2FmxJTK1jXHM21yNB8xEKTFTv/oIhdGQDlg5AD8a 2KmhKtNDo0y9tBEBJdAGbz689dwWOt/bFyRfpRE+v9S7MUAcoBh4npQNSuIyj17AUuqD +I7zdvQcmUMaYGsF1qbYqxEgBAYnj70APX+d7gM9DtolhukcLJ9+SyS36p8gkt+CXHb7 wDGev84s4/aH0cvwvyWUIVnLzKkFOBUfhrM51xtKVJD/qWGSHmLSAmMGM9B/aL3pOhGr bObq2BrUsDQ1HjUtS/HQ3/BwMEED7Opy0zak+zJlaAF5wAQQ0FLC1XGwsAartIgqrysi FoJQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k131si17346192pgc.525.2019.09.04.07.24.21; Wed, 04 Sep 2019 07:24:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731000AbfIDOXb convert rfc822-to-8bit (ORCPT + 99 others); Wed, 4 Sep 2019 10:23:31 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:52632 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730880AbfIDOXb (ORCPT ); Wed, 4 Sep 2019 10:23:31 -0400 Received: from marcel-macbook.fritz.box (p4FEFC197.dip0.t-ipconnect.de [79.239.193.151]) by mail.holtmann.org (Postfix) with ESMTPSA id 8C9A6CECB0; Wed, 4 Sep 2019 16:32:17 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: [PATCH] Bluetooth: btusb: Use cmd_timeout to reset Realtek device From: Marcel Holtmann In-Reply-To: <20190903094103.GA10714@laptop-alex> Date: Wed, 4 Sep 2019 16:23:29 +0200 Cc: Johan Hedberg , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, Max Chou Content-Transfer-Encoding: 8BIT Message-Id: <989DBD04-B5DC-4733-8784-93B45BA9FF15@holtmann.org> References: <20190903094103.GA10714@laptop-alex> To: Alex Lu X-Mailer: Apple Mail (2.3445.104.11) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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 > --- > 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