From patchwork Mon Nov 19 23:04:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 10689603 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7F3716C5 for ; Mon, 19 Nov 2018 23:04:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6ED012A782 for ; Mon, 19 Nov 2018 23:04:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62EF62A7BB; Mon, 19 Nov 2018 23:04:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4FD02A782 for ; Mon, 19 Nov 2018 23:04:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732041AbeKTJaV (ORCPT ); Tue, 20 Nov 2018 04:30:21 -0500 Received: from mail-it1-f202.google.com ([209.85.166.202]:52620 "EHLO mail-it1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732014AbeKTJaV (ORCPT ); Tue, 20 Nov 2018 04:30:21 -0500 Received: by mail-it1-f202.google.com with SMTP id o205so516307itc.2 for ; Mon, 19 Nov 2018 15:04:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=ht0KyOh1qyTCyJTWR8FJ0kQ4r9NOG2ZYRU0qkbwdVxg=; b=NTzqh7XqPizW3LKbTLltZA7fs5TZVy6YJa+uBgWCyXcCuDjwNOHnE90YECCJFl8FvE uoXHXt67YbqemX5mGaAADP2IVDXGQSkq/IHOC734rhxeKtpB3211zgGt5coW7/2ot0I9 x8ByhgXEXPiRtYbSi2e8cc+vg2Sb/L2aYJbfYJp+NQYgqZ12i0hEs3ORn1nvzcQR0Ora oCJFdJUTOZSVtGWZOSG7iMuoxmw76YL85sTE08wsAPfPvWIYorai0xvULf2Qcw5jtzMT aFIZMsrXaY2SbiA2xoIAu2VF6QhKq1gCZ6RjYD+s7tFSq0oCmMB3INb7JXeCAmEr+VZg kqRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ht0KyOh1qyTCyJTWR8FJ0kQ4r9NOG2ZYRU0qkbwdVxg=; b=ZAs/doA4Tsn0td+wYDQMcvcOCGTi3LdezxX5p7/TDC6yXeXaKUWf1EEXrPQ0YJUN5+ s6kgzy0WnVVNN4cMtl057Bs0zTQtcG0e8tj51Bcclq5VaOU52NvxBKtaJmdjTd5GuyQN hD59rTKwCZrK684Qso9zux99/uh9VG/G5pXwGd07X/ka8pUgJKbWLoe7V6QhMl+BuNgJ WNjKEejuS2KxpJmsGGZC7yGPuI5rDB1mwr5UrqbWal9T3ZzW7JHAQi3c0Xb25HJNG1+p kIFyJW+54UpcoZnR/9SRECr9i4q3oAEhyd/7+ztGCwUsnNYRwg29kqFFP3nrzRIODTY0 OAiA== X-Gm-Message-State: AA+aEWbRs8otWC9Kvq5fdYkgijcRnvx71SLzd7XA7I3zTg2QVar8Wt86 twCF4CVVxV3Go77Lm+IZ+aEAZYjT4g3g X-Google-Smtp-Source: AJdET5epn00g1R5JWP1cMzk7X7UcKhiKt2pnk87nH5GZlOdyRhKGMBnmCcHOOT0PbwbEFr++W09Y8yN8z+bu X-Received: by 2002:a24:6cb:: with SMTP id 194-v6mr55049itv.18.1542668663035; Mon, 19 Nov 2018 15:04:23 -0800 (PST) Date: Mon, 19 Nov 2018 15:04:05 -0800 In-Reply-To: <20181117010748.24347-1-rajatja@google.com> Message-Id: <20181119230409.258121-1-rajatja@google.com> Mime-Version: 1.0 References: <20181117010748.24347-1-rajatja@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH v2 1/5] usb: split code locating ACPI companion into port and device From: Rajat Jain To: Marcel Holtmann , Johan Hedberg , Greg Kroah-Hartman , "David S. Miller" , Dmitry Torokhov , Rajat Jain , Alex Hung , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, netdev@vger.kernel.org Cc: rajatxjain@gmail.com, dtor@google.com, raghuram.hegde@intel.com, chethan.tumkur.narayan@intel.com, sukumar.ghorai@intel.com Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Dmitry Torokhov In preparation for handling embedded USB devices let's split usb_acpi_find_companion() into usb_acpi_find_companion_for_device() and usb_acpi_find_companion_for_port(). Signed-off-by: Dmitry Torokhov Signed-off-by: Rajat Jain --- v2: same as v1 drivers/usb/core/usb-acpi.c | 133 +++++++++++++++++++----------------- 1 file changed, 72 insertions(+), 61 deletions(-) diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c index e221861b3187..8ff73c83e8e8 100644 --- a/drivers/usb/core/usb-acpi.c +++ b/drivers/usb/core/usb-acpi.c @@ -139,12 +139,79 @@ static struct acpi_device *usb_acpi_find_port(struct acpi_device *parent, return acpi_find_child_device(parent, raw, false); } -static struct acpi_device *usb_acpi_find_companion(struct device *dev) +static struct acpi_device * +usb_acpi_get_companion_for_port(struct usb_port *port_dev) { struct usb_device *udev; struct acpi_device *adev; acpi_handle *parent_handle; + int port1; + + /* Get the struct usb_device point of port's hub */ + udev = to_usb_device(port_dev->dev.parent->parent); + + /* + * The root hub ports' parent is the root hub. The non-root-hub + * ports' parent is the parent hub port which the hub is + * connected to. + */ + if (!udev->parent) { + adev = ACPI_COMPANION(&udev->dev); + port1 = usb_hcd_find_raw_port_number(bus_to_hcd(udev->bus), + port_dev->portnum); + } else { + parent_handle = usb_get_hub_port_acpi_handle(udev->parent, + udev->portnum); + if (!parent_handle) + return NULL; + + acpi_bus_get_device(parent_handle, &adev); + port1 = port_dev->portnum; + } + + return usb_acpi_find_port(adev, port1); +} + +static struct acpi_device * +usb_acpi_find_companion_for_port(struct usb_port *port_dev) +{ + struct acpi_device *adev; + struct acpi_pld_info *pld; + acpi_handle *handle; + acpi_status status; + + adev = usb_acpi_get_companion_for_port(port_dev); + if (!adev) + return NULL; + + handle = adev->handle; + status = acpi_get_physical_device_location(handle, &pld); + if (!ACPI_FAILURE(status) && pld) { + port_dev->location = USB_ACPI_LOCATION_VALID + | pld->group_token << 8 | pld->group_position; + port_dev->connect_type = usb_acpi_get_connect_type(handle, pld); + ACPI_FREE(pld); + } + return adev; +} + +static struct acpi_device * +usb_acpi_find_companion_for_device(struct usb_device *udev) +{ + struct acpi_device *adev; + + if (!udev->parent) + return NULL; + + /* root hub is only child (_ADR=0) under its parent, the HC */ + adev = ACPI_COMPANION(udev->dev.parent); + return acpi_find_child_device(adev, 0, false); +} + + +static struct acpi_device *usb_acpi_find_companion(struct device *dev) +{ /* * In the ACPI DSDT table, only usb root hub and usb ports are * acpi device nodes. The hierarchy like following. @@ -158,66 +225,10 @@ static struct acpi_device *usb_acpi_find_companion(struct device *dev) * So all binding process is divided into two parts. binding * root hub and usb ports. */ - if (is_usb_device(dev)) { - udev = to_usb_device(dev); - if (udev->parent) - return NULL; - - /* root hub is only child (_ADR=0) under its parent, the HC */ - adev = ACPI_COMPANION(dev->parent); - return acpi_find_child_device(adev, 0, false); - } else if (is_usb_port(dev)) { - struct usb_port *port_dev = to_usb_port(dev); - int port1 = port_dev->portnum; - struct acpi_pld_info *pld; - acpi_handle *handle; - acpi_status status; - - /* Get the struct usb_device point of port's hub */ - udev = to_usb_device(dev->parent->parent); - - /* - * The root hub ports' parent is the root hub. The non-root-hub - * ports' parent is the parent hub port which the hub is - * connected to. - */ - if (!udev->parent) { - struct usb_hcd *hcd = bus_to_hcd(udev->bus); - int raw; - - raw = usb_hcd_find_raw_port_number(hcd, port1); - - adev = usb_acpi_find_port(ACPI_COMPANION(&udev->dev), - raw); - - if (!adev) - return NULL; - } else { - parent_handle = - usb_get_hub_port_acpi_handle(udev->parent, - udev->portnum); - if (!parent_handle) - return NULL; - - acpi_bus_get_device(parent_handle, &adev); - - adev = usb_acpi_find_port(adev, port1); - - if (!adev) - return NULL; - } - handle = adev->handle; - status = acpi_get_physical_device_location(handle, &pld); - if (ACPI_FAILURE(status) || !pld) - return adev; - - port_dev->location = USB_ACPI_LOCATION_VALID - | pld->group_token << 8 | pld->group_position; - port_dev->connect_type = usb_acpi_get_connect_type(handle, pld); - ACPI_FREE(pld); - - return adev; - } + if (is_usb_device(dev)) + return usb_acpi_find_companion_for_device(to_usb_device(dev)); + else if (is_usb_port(dev)) + return usb_acpi_find_companion_for_port(to_usb_port(dev)); return NULL; } From patchwork Mon Nov 19 23:04:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 10689605 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 394F313AD for ; Mon, 19 Nov 2018 23:04:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2AAFA2A782 for ; Mon, 19 Nov 2018 23:04:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E0F42A7BB; Mon, 19 Nov 2018 23:04:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A55702A782 for ; Mon, 19 Nov 2018 23:04:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732073AbeKTJaZ (ORCPT ); Tue, 20 Nov 2018 04:30:25 -0500 Received: from mail-pg1-f201.google.com ([209.85.215.201]:50657 "EHLO mail-pg1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732068AbeKTJaZ (ORCPT ); Tue, 20 Nov 2018 04:30:25 -0500 Received: by mail-pg1-f201.google.com with SMTP id u17so7269162pgn.17 for ; Mon, 19 Nov 2018 15:04:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=hozA7Ab9Mbo9dP4gWzek1tXXv9KaEdb0RAgi2ZqAK7A=; b=kNN3V41Qzl7VMMMjqPuUBqaprYPthA6N4Txzdkq/UT8nCXoc8FSn0r0uLsCroW+mm+ Up4i7WbNMfRfe2D6Kz2I8tbhi/4Crx41wITmLIbnjGzuT0PsKBEpcVDi4bMkKAclhfdg 2S7+C0PQGe6wR4BMipewGmJmR31hCPumKJTwOp77qmHcPUnaq+nSDQUvz5kxnhbkjtT9 K6UsWb87A0mfyc1cVUeciEolkJzx1y2pXeGphR/hfzabwoZCqiEJft0Gk4SUHGeTluVQ tOiiirdzJe3yLIdxKebkMuOO+3qXTUF+XJLp/t87ENKhmt2qFZJ4Ow9IoPiJA9F07nbX vfsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=hozA7Ab9Mbo9dP4gWzek1tXXv9KaEdb0RAgi2ZqAK7A=; b=pD0hFiZjUIDkMOReN1UCSPORRi0o8mtOuNNC6n4fOfCVvRm8Ko/WVID4KpLVCYGzIz UwSRkpRlCO1Uehw7BQND5ssU5y/5P0oTIBFwi4FkIAxgeFNwYQB8JobCtrjVlp6aofGZ or+O80zZossXFqXk0Ld1539hm8VAmJElJxhvKQcz3v8ERHoEUxC4LHYz0XG11uw0YSDy 6NMIIC12MxTswC3Ep0NVp3OUKnrcTMqxNEEUtGQzBilr+5cXXN2vFu9LXErRTyAylXbw kSXWlK5PRwIUOpiKwby5c8OYCmauzpR3vk1phChN/D25A9QYQLfGQbdalhqNhlDVyYFZ UWmQ== X-Gm-Message-State: AGRZ1gLNuajb53DgSmGSVLuxFbL/z9w5LF0jd0+b5wTdHvgrhUeEiRsq Y6bFk2SFco+U+FkwtuOFtCcJJqf2WltG X-Google-Smtp-Source: AJdET5ecBZzURnJmtWNOpDzYUP6gzTjRvxiu7VaSkfzZWHs94/8LDuHXzrAweriKyMCS4ZZr3ce5wPTctIw9 X-Received: by 2002:a63:2c13:: with SMTP id s19mr7793541pgs.75.1542668667066; Mon, 19 Nov 2018 15:04:27 -0800 (PST) Date: Mon, 19 Nov 2018 15:04:06 -0800 In-Reply-To: <20181119230409.258121-1-rajatja@google.com> Message-Id: <20181119230409.258121-2-rajatja@google.com> Mime-Version: 1.0 References: <20181117010748.24347-1-rajatja@google.com> <20181119230409.258121-1-rajatja@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH v2 2/5] usb: assign ACPI companions for embedded USB devices From: Rajat Jain To: Marcel Holtmann , Johan Hedberg , Greg Kroah-Hartman , "David S. Miller" , Dmitry Torokhov , Rajat Jain , Alex Hung , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, netdev@vger.kernel.org Cc: rajatxjain@gmail.com, dtor@google.com, raghuram.hegde@intel.com, chethan.tumkur.narayan@intel.com, sukumar.ghorai@intel.com Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Dmitry Torokhov USB devices permanently connected to USB ports may be described in ACPI tables and share ACPI devices with ports they are connected to. See [1] for details. This will allow us to describe sideband resources for devices, such as, for example, hard reset line for BT USB controllers. [1] https://docs.microsoft.com/en-us/windows-hardware/drivers/bringup/other-acpi-namespace-objects#acpi-namespace-hierarchy-and-adr-for-embedded-usb-devices Signed-off-by: Dmitry Torokhov Signed-off-by: Rajat Jain (changed how we get the usb_port) --- v2: same as v1 drivers/usb/core/usb-acpi.c | 44 +++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c index 8ff73c83e8e8..9043d7242d67 100644 --- a/drivers/usb/core/usb-acpi.c +++ b/drivers/usb/core/usb-acpi.c @@ -200,30 +200,56 @@ static struct acpi_device * usb_acpi_find_companion_for_device(struct usb_device *udev) { struct acpi_device *adev; + struct usb_port *port_dev; + struct usb_hub *hub; + + if (!udev->parent) { + /* root hub is only child (_ADR=0) under its parent, the HC */ + adev = ACPI_COMPANION(udev->dev.parent); + return acpi_find_child_device(adev, 0, false); + } - if (!udev->parent) + hub = usb_hub_to_struct_hub(udev->parent); + if (!hub) return NULL; - /* root hub is only child (_ADR=0) under its parent, the HC */ - adev = ACPI_COMPANION(udev->dev.parent); - return acpi_find_child_device(adev, 0, false); + /* + * This is an embedded USB device connected to a port and such + * devices share port's ACPI companion. + */ + port_dev = hub->ports[udev->portnum - 1]; + return usb_acpi_get_companion_for_port(port_dev); } - static struct acpi_device *usb_acpi_find_companion(struct device *dev) { /* - * In the ACPI DSDT table, only usb root hub and usb ports are - * acpi device nodes. The hierarchy like following. + * The USB hierarchy like following: + * * Device (EHC1) * Device (HUBN) * Device (PR01) * Device (PR11) * Device (PR12) + * Device (FN12) + * Device (FN13) * Device (PR13) * ... - * So all binding process is divided into two parts. binding - * root hub and usb ports. + * where HUBN is root hub, and PRNN are USB ports and devices + * connected to them, and FNNN are individualk functions for + * connected composite USB devices. PRNN and FNNN may contain + * _CRS and other methods describing sideband resources for + * the connected device. + * + * On the kernel side both root hub and embedded USB devices are + * represented as instances of usb_device structure, and ports + * are represented as usb_port structures, so the whole process + * is split into 2 parts: finding companions for devices and + * finding companions for ports. + * + * Note that we do not handle individual functions of composite + * devices yet, for that we would need to assign companions to + * devices corresponding to USB interfaces. */ if (is_usb_device(dev)) return usb_acpi_find_companion_for_device(to_usb_device(dev)); From patchwork Mon Nov 19 23:04:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 10689607 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5C59D6C5 for ; Mon, 19 Nov 2018 23:04:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E67A2A782 for ; Mon, 19 Nov 2018 23:04:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 42B162A7BB; Mon, 19 Nov 2018 23:04:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6C442A782 for ; Mon, 19 Nov 2018 23:04:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732120AbeKTJaa (ORCPT ); Tue, 20 Nov 2018 04:30:30 -0500 Received: from mail-qk1-f201.google.com ([209.85.222.201]:41473 "EHLO mail-qk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732079AbeKTJa3 (ORCPT ); Tue, 20 Nov 2018 04:30:29 -0500 Received: by mail-qk1-f201.google.com with SMTP id n68so71498449qkn.8 for ; Mon, 19 Nov 2018 15:04:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=/jmvSk73ZJvN/rJikoGCnBxiMJ8mGKQz9fKupKHZVnc=; b=qXY1/LFiLarQRhLrkWROxeQeHmYfzgfPgdLh4bHm5Scg9+m1STMxr9SnF6o28Nqe/A /B9/Um33GOCytCDB/1bgNYsyXpINQq8NykqhWbCeo29WJKN3kgMGs5U4ejeZPqtrrurw wxv/OQsjYMtY9phIeW3T2o+MJOXSYGQcRROkyofom9Nvri7gguq2z0V2r6MvuhcJ9mgi +vir91iYwnQH6SO/rSFbN454vx2qQEALJa3Eji5528kEp7k6Ne2LZmvFuM7EgTZD1f+5 9SSEqja1Oep0Et8s93A4r2EIA1slufqUtEddwugxAGN862OrY3HPrW4NqITlWV5EN6J/ TA1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=/jmvSk73ZJvN/rJikoGCnBxiMJ8mGKQz9fKupKHZVnc=; b=e82ba/WnT2h6276EtJqDEL5VdUycF2VMQGEf5/T/YYyOZuxHsal9OyODvK7tag8ymI ETg/fJOXfq45qa2/SOcNwAAQLAq7Yjig4tT1x1CSAqdaYjfisQzlPEzGvdjfTHc79SEw phYhZvGR5K2gLLvRfDYBqcSQeQg+0YOpuDjuVE75tHnvPaoonFgzC+agX9SBIzbCQ1t4 C7EIb1yUHxcQ10D7XDaZboQsrngBdlq3hAmuTpCK3q+W7MIHzuxVJQrRbYE6v51CnSE4 9vTC5ALidwwnht56ILEe+Hz+1tU3umqTdWQtDrrhNP+XG7DdP7E2NrdWaF5Vsr4CBwVb KWjA== X-Gm-Message-State: AGRZ1gJA1ZhASZe8+zGw9oVHDZXukcJAAm80813y23GtMdZ82hMBwZHo WXTilGDG6H+mDlQslQ56+BpCIdgkGWSD X-Google-Smtp-Source: AFSGD/Va7z8PSmAcKHGrEIJjGnGQ2ajacMfWtcwgJvkglit2D6XwXzEKf0fAdwfTe6LOle4ydkE6yf4YDgKJ X-Received: by 2002:ac8:244a:: with SMTP id d10mr10227616qtd.15.1542668670179; Mon, 19 Nov 2018 15:04:30 -0800 (PST) Date: Mon, 19 Nov 2018 15:04:07 -0800 In-Reply-To: <20181119230409.258121-1-rajatja@google.com> Message-Id: <20181119230409.258121-3-rajatja@google.com> Mime-Version: 1.0 References: <20181117010748.24347-1-rajatja@google.com> <20181119230409.258121-1-rajatja@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH v2 3/5] Bluetooth: Reset Bluetooth chip after multiple command timeouts From: Rajat Jain To: Marcel Holtmann , Johan Hedberg , Greg Kroah-Hartman , "David S. Miller" , Dmitry Torokhov , Rajat Jain , Alex Hung , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, netdev@vger.kernel.org Cc: rajatxjain@gmail.com, dtor@google.com, raghuram.hegde@intel.com, chethan.tumkur.narayan@intel.com, sukumar.ghorai@intel.com Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a quirk and a hook to allow the HCI core to reset the BT chip if needed (after a number of timed out commands). Use that new hook to initiate BT chip reset if the controller fails to respond to certain number of commands (currently 5) including the HCI reset commands. This is done based on a newly introduced quirk. This is done based on some initial work by Intel. Signed-off-by: Rajat Jain --- v2: same as v1 include/net/bluetooth/hci.h | 8 ++++++++ include/net/bluetooth/hci_core.h | 2 ++ net/bluetooth/hci_core.c | 15 +++++++++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index c36dc1e20556..af02fa5ffe54 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -192,6 +192,14 @@ enum { * */ HCI_QUIRK_NON_PERSISTENT_SETUP, + + /* When this quirk is set, hw_reset() would be run to reset the + * hardware, after a certain number of commands (currently 5) + * time out because the device fails to respond. + * + * This quirk should be set before hci_register_dev is called. + */ + HCI_QUIRK_HW_RESET_ON_TIMEOUT, }; /* HCI device flags */ diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index e5ea633ea368..b86218304b80 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -313,6 +313,7 @@ struct hci_dev { unsigned int acl_cnt; unsigned int sco_cnt; unsigned int le_cnt; + unsigned int timeout_cnt; unsigned int acl_mtu; unsigned int sco_mtu; @@ -437,6 +438,7 @@ struct hci_dev { int (*post_init)(struct hci_dev *hdev); int (*set_diag)(struct hci_dev *hdev, bool enable); int (*set_bdaddr)(struct hci_dev *hdev, const bdaddr_t *bdaddr); + void (*hw_reset)(struct hci_dev *hdev); }; #define HCI_PHY_HANDLE(handle) (handle & 0xff) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 7352fe85674b..ab3a6a8b7ba6 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2569,13 +2569,24 @@ static void hci_cmd_timeout(struct work_struct *work) struct hci_dev *hdev = container_of(work, struct hci_dev, cmd_timer.work); + hdev->timeout_cnt++; if (hdev->sent_cmd) { struct hci_command_hdr *sent = (void *) hdev->sent_cmd->data; u16 opcode = __le16_to_cpu(sent->opcode); - bt_dev_err(hdev, "command 0x%4.4x tx timeout", opcode); + bt_dev_err(hdev, "command 0x%4.4x tx timeout (cnt = %u)", + opcode, hdev->timeout_cnt); } else { - bt_dev_err(hdev, "command tx timeout"); + bt_dev_err(hdev, "command tx timeout (cnt = %u)", + hdev->timeout_cnt); + } + + if (test_bit(HCI_QUIRK_HW_RESET_ON_TIMEOUT, &hdev->quirks) && + hdev->timeout_cnt >= 5) { + hdev->timeout_cnt = 0; + if (hdev->hw_reset) + hdev->hw_reset(hdev); + return; } atomic_set(&hdev->cmd_cnt, 1); From patchwork Mon Nov 19 23:04:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 10689611 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 453681709 for ; Mon, 19 Nov 2018 23:04:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3776A2A782 for ; Mon, 19 Nov 2018 23:04:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B4AB2A7BB; Mon, 19 Nov 2018 23:04:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCD062A782 for ; Mon, 19 Nov 2018 23:04:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732126AbeKTJab (ORCPT ); Tue, 20 Nov 2018 04:30:31 -0500 Received: from mail-pg1-f201.google.com ([209.85.215.201]:38174 "EHLO mail-pg1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732124AbeKTJab (ORCPT ); Tue, 20 Nov 2018 04:30:31 -0500 Received: by mail-pg1-f201.google.com with SMTP id k125so3195pga.5 for ; Mon, 19 Nov 2018 15:04:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=ZerO0x85S+KXn/eWjn2EIwWcOtUjMTo6CrHKJ6cTlG0=; b=pt9I7ormK9h9+8r2hg8AmgjQkbcKJ9Yndj0BnG+HfwD8qxm9b0wYagZUP2IjG9OlzJ KEofOyQGFEvY2CVHlGOYU1U2KX9bhw3b/nj8AmJV4JcsIG/SbttDHAw3QcpXScZKIYuu Qtshz2DH3flU00r2o7CtXkB8rX7kY+2WbYXH3A3uRC+XBIB2mQuUHoP2ntMuo/c1nOxa pmGyVjwANThkHAEIHRmS9NmNvokgm3N637K/CnPv3f+kKMPvYGqzXSOfbWTHT4PDcFhW MAsoNoFlkgjNbPwCm9EvXb58vkBH6Y5JFCIzbLCIqshjyvfAFLAQT/8B2QrtXEU4BRyy f4jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ZerO0x85S+KXn/eWjn2EIwWcOtUjMTo6CrHKJ6cTlG0=; b=sgXoZqg3w/WKwkqQNiyiNB5jdtvASvhGSg2IK1zr4EzvsCkg3OiolwVZ++i44c4Ula NZTMj1ozXvWp+cPRTBxgkZgRJXuvX2kRP7HXdZ9ieEtTv5bKLQo0Dc1isat0FdCbDDh2 lMcWNJ8g1Oms0TE5QY7BI6wEwxnm46VOo7uq8dWQhFWe0nTZxjqV2lJZY2nFQJW/UDba UwIStFyV0vs363/DUfWYH2DEsj7OcW1Mk9h4PtL8sqyi9Umy8BR4mgqEid61l/ucZwpo FX+3qxzA7K92hMur8u0nRyDSjC71HjQUV49QmysUwS2/PqgAdqdk1XoNwQnEDjhreITB Ct6A== X-Gm-Message-State: AGRZ1gLf04D5xoJZgYI+Yz7aYGt0ITHuxqBEzvIPMJOSFAvAoOhnmJcs kh8XRLQCIJRKRjJYzJk3eTkSt9AF1orD X-Google-Smtp-Source: AJdET5ecx09neK3Gebcooqd0Np39UZYoF7Xdhoi+LyR3KCIxcNPS6HXQaJmcJchFOO/wWeB6oXbZBERahsSM X-Received: by 2002:a62:8a41:: with SMTP id y62-v6mr8164482pfd.70.1542668673264; Mon, 19 Nov 2018 15:04:33 -0800 (PST) Date: Mon, 19 Nov 2018 15:04:08 -0800 In-Reply-To: <20181119230409.258121-1-rajatja@google.com> Message-Id: <20181119230409.258121-4-rajatja@google.com> Mime-Version: 1.0 References: <20181117010748.24347-1-rajatja@google.com> <20181119230409.258121-1-rajatja@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH v2 4/5] Bluetooth: btusb: Collect the common Intel assignments together From: Rajat Jain To: Marcel Holtmann , Johan Hedberg , Greg Kroah-Hartman , "David S. Miller" , Dmitry Torokhov , Rajat Jain , Alex Hung , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, netdev@vger.kernel.org Cc: rajatxjain@gmail.com, dtor@google.com, raghuram.hegde@intel.com, chethan.tumkur.narayan@intel.com, sukumar.ghorai@intel.com Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The BTUSB_INTEL and BTUSB_INTEL_NEW have common functions & quirks are assigned to hdev structure. Lets collect them together instead of repeating them in different code branches. Signed-off-by: Rajat Jain --- v2: same as v1 drivers/bluetooth/btusb.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 7439a7eb50ac..e8e148480c91 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -3077,28 +3077,25 @@ static int btusb_probe(struct usb_interface *intf, data->diag = usb_ifnum_to_if(data->udev, ifnum_base + 2); } #endif + if (id->driver_info & BTUSB_INTEL || + id->driver_info & BTUSB_INTEL_NEW) { - if (id->driver_info & BTUSB_INTEL) { hdev->manufacturer = 2; - hdev->setup = btusb_setup_intel; - hdev->shutdown = btusb_shutdown_intel; - hdev->set_diag = btintel_set_diag_mfg; hdev->set_bdaddr = btintel_set_bdaddr; set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks); set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); set_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks); - } - if (id->driver_info & BTUSB_INTEL_NEW) { - hdev->manufacturer = 2; - hdev->send = btusb_send_frame_intel; - hdev->setup = btusb_setup_intel_new; - hdev->hw_error = btintel_hw_error; - hdev->set_diag = btintel_set_diag; - hdev->set_bdaddr = btintel_set_bdaddr; - set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks); - set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); - set_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks); + if (id->driver_info & BTUSB_INTEL) { + hdev->setup = btusb_setup_intel; + hdev->shutdown = btusb_shutdown_intel; + hdev->set_diag = btintel_set_diag_mfg; + } else { + hdev->send = btusb_send_frame_intel; + hdev->setup = btusb_setup_intel_new; + hdev->hw_error = btintel_hw_error; + hdev->set_diag = btintel_set_diag; + } } if (id->driver_info & BTUSB_MARVELL) From patchwork Mon Nov 19 23:04:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 10689609 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B90DD6C5 for ; Mon, 19 Nov 2018 23:04:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7FD82A782 for ; Mon, 19 Nov 2018 23:04:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B97F2A7BB; Mon, 19 Nov 2018 23:04:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85DA82A782 for ; Mon, 19 Nov 2018 23:04:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732138AbeKTJae (ORCPT ); Tue, 20 Nov 2018 04:30:34 -0500 Received: from mail-qk1-f202.google.com ([209.85.222.202]:43695 "EHLO mail-qk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732079AbeKTJae (ORCPT ); Tue, 20 Nov 2018 04:30:34 -0500 Received: by mail-qk1-f202.google.com with SMTP id z126so72140495qka.10 for ; Mon, 19 Nov 2018 15:04:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=uunCudW0fot0kDo/jeeOPd18t40N78uRVjkv0yBK6zA=; b=lOk71o3NxeCWm9bJNYIMXN4I+aUUIwxSptyVPuHV8z2duzNewaXh2mGFbrBapiNHv1 6IoabAVkJ7Ygx/OOSZW7nEtTI4265YnShh/Fgvb2cOuIglufftZhJIfHmlXoSgsmlxAp CRuWiJwoFJ9k5DXpEK27kw1Dm4VQQWt6xIFScQ7DFtp7bezYqbSgfbVdzQxWxNrZU1wd xX77LONY/tQudNeE2p4z7BDhq+kryGu9LvFqRKDlSAn1EamPfaWuRpk+ZKlKq1BkL4ro j+wYkD/AO4eHKPDw7dSv2tvx11WfxlOEraEHtHamUaN5V042vG7Azob0gWNP1IWbZErl 1DcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=uunCudW0fot0kDo/jeeOPd18t40N78uRVjkv0yBK6zA=; b=fOT4p1JH4VRhLUn1z6h945z86HWF+yElez1uTyVSUarTNnSc8MalERRaiPnm2DuCJ9 OYjmj+1QKH2s7VbwScDVvHVdEGStG2R8B6ucrljlWPR/+neiGQ76uQ9v/xpQyfZPSezY 34P095YjnRJwQ1YKn9ifbCwdfHuJYfp0dH8vNMpEY7j3xLeXBRx5NW02YDSf3IMVLRJ6 iE79oPs9488799VBU0MsWZ8sVl4SDfIG1Y8pr+5KbdMZohBThGb/4PE/CYgtMFzn0/Z9 5w26bn09P9qndRMnGWTbOaL9UWCLw0K5mJwivQGUpE2HKzJXkJnLndlqBH8hr4L5CLVU mRiA== X-Gm-Message-State: AA+aEWZcX6ywj7EfWlD4FerE92UhOp4pNz7XBfzhVXPLO34pPZbQUst8 Q00Df0CrhTEBEiFfJL/Dpe9ehvuAGkgp X-Google-Smtp-Source: AFSGD/UmypK1BXBSOWjH9ly9xBG5GYKA/SVJn/QG/4r71X12BbayHM465co2I8oBcCyTQt+PcqR5+6BN3iyf X-Received: by 2002:ac8:17af:: with SMTP id o44mr12329594qtj.24.1542668676210; Mon, 19 Nov 2018 15:04:36 -0800 (PST) Date: Mon, 19 Nov 2018 15:04:09 -0800 In-Reply-To: <20181119230409.258121-1-rajatja@google.com> Message-Id: <20181119230409.258121-5-rajatja@google.com> Mime-Version: 1.0 References: <20181117010748.24347-1-rajatja@google.com> <20181119230409.258121-1-rajatja@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH v2 5/5] Bluetooth: btusb: Use the hw_reset method to allow resetting the BT chip From: Rajat Jain To: Marcel Holtmann , Johan Hedberg , Greg Kroah-Hartman , "David S. Miller" , Dmitry Torokhov , Rajat Jain , Alex Hung , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, netdev@vger.kernel.org Cc: rajatxjain@gmail.com, dtor@google.com, raghuram.hegde@intel.com, chethan.tumkur.narayan@intel.com, sukumar.ghorai@intel.com Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the platform provides it, use the reset gpio to reset the BT chip (requested by the HCI core if needed). This has been found helpful on some of Intel bluetooth controllers where the firmware gets stuck and the only way out is a hard reset pin provided by the platform. Signed-off-by: Rajat Jain --- v2: Handle the EPROBE_DEFER case. drivers/bluetooth/btusb.c | 42 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index e8e148480c91..bf522cfe68c1 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -475,6 +476,8 @@ struct btusb_data { struct usb_endpoint_descriptor *diag_tx_ep; struct usb_endpoint_descriptor *diag_rx_ep; + struct gpio_desc *reset_gpio; + __u8 cmdreq_type; __u8 cmdreq; @@ -490,6 +493,28 @@ struct btusb_data { int oob_wake_irq; /* irq for out-of-band wake-on-bt */ }; + +static void btusb_hw_reset(struct hci_dev *hdev) +{ + struct btusb_data *data = hci_get_drvdata(hdev); + struct gpio_desc *reset_gpio = data->reset_gpio; + + /* + * Toggle the hard reset line if the platform provides one. The reset + * is going to yank the device off the USB and then replug. So doing + * once is enough. The cleanup is handled correctly on the way out + * (standard USB disconnect), and the new device is detected cleanly + * and bound to the driver again like it should be. + */ + if (reset_gpio) { + bt_dev_dbg(hdev, "%s: Initiating HW reset via gpio", __func__); + clear_bit(HCI_QUIRK_HW_RESET_ON_TIMEOUT, &hdev->quirks); + gpiod_set_value(reset_gpio, 1); + mdelay(100); + gpiod_set_value(reset_gpio, 0); + } +} + static inline void btusb_free_frags(struct btusb_data *data) { unsigned long flags; @@ -2917,6 +2942,7 @@ static int btusb_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct usb_endpoint_descriptor *ep_desc; + struct gpio_desc *reset_gpio; struct btusb_data *data; struct hci_dev *hdev; unsigned ifnum_base; @@ -3030,6 +3056,16 @@ static int btusb_probe(struct usb_interface *intf, SET_HCIDEV_DEV(hdev, &intf->dev); + reset_gpio = gpiod_get_optional(&data->udev->dev, "reset", + GPIOD_OUT_LOW); + if (PTR_ERR(reset_gpio) == -EPROBE_DEFER) { + err = -EPROBE_DEFER; + goto out_free_dev; + } else if (!IS_ERR(reset_gpio)) { + data->reset_gpio = reset_gpio; + hdev->hw_reset = btusb_hw_reset; + } + hdev->open = btusb_open; hdev->close = btusb_close; hdev->flush = btusb_flush; @@ -3085,6 +3121,7 @@ static int btusb_probe(struct usb_interface *intf, set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks); set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); set_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks); + set_bit(HCI_QUIRK_HW_RESET_ON_TIMEOUT, &hdev->quirks); if (id->driver_info & BTUSB_INTEL) { hdev->setup = btusb_setup_intel; @@ -3225,6 +3262,8 @@ static int btusb_probe(struct usb_interface *intf, return 0; out_free_dev: + if (data->reset_gpio) + gpiod_put(data->reset_gpio); hci_free_dev(hdev); return err; } @@ -3268,6 +3307,9 @@ static void btusb_disconnect(struct usb_interface *intf) if (data->oob_wake_irq) device_init_wakeup(&data->udev->dev, false); + if (data->reset_gpio) + gpiod_put(data->reset_gpio); + hci_free_dev(hdev); }