From patchwork Wed Nov 21 23:50:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 10693293 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 A37B414DE for ; Wed, 21 Nov 2018 23:50:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 844972C1D3 for ; Wed, 21 Nov 2018 23:50:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A12C2C869; Wed, 21 Nov 2018 23:50:32 +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 286162C1D3 for ; Wed, 21 Nov 2018 23:50:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390704AbeKVK1C (ORCPT ); Thu, 22 Nov 2018 05:27:02 -0500 Received: from mail-pl1-f201.google.com ([209.85.214.201]:42266 "EHLO mail-pl1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388115AbeKVK1C (ORCPT ); Thu, 22 Nov 2018 05:27:02 -0500 Received: by mail-pl1-f201.google.com with SMTP id w7-v6so11676544plp.9 for ; Wed, 21 Nov 2018 15:50:25 -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=9yOrdV2TLiTL2pouOn6XHh+pt39jlPzRRrz2vTRoPFs=; b=kR4cQ4vyF5j5iB8+8SgJFo3TOUgrh66V6LYHVf9PU1lPG2/73pmAWCJruSU2BvidpM P3UA9PmflBRBriaGzTgi5HB2LFe1oqHiPkuHacNZnOyH9/VcbYqjaD7ue5vxC2uDSatb XZMW/B9jUmnhLkVWDeoochlkuCuBOl1/NG1XrIjuHF7NbTDeCJvrhD8q9tkI2rDE/Eat hDATM8Aj/7uqD++HxU+CciJTtWNT4mFIrCmtzkrcTU6Xk+CdTUSasPqWR6vbD1FiqXB6 VBQN0H32+H5xPN/JfgEqZJqm9n23nHat31xeLC5NsAkU3deE6bTdzj8axFbBq00TUdN0 z+rA== 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=9yOrdV2TLiTL2pouOn6XHh+pt39jlPzRRrz2vTRoPFs=; b=fRKJoPIZdz7GiNiHl3U0oWeFSSizyDHqlCXwkDAmrsYavtpAv5GnfcebgAXC37j5Fh W1naeuQ22qozpEjuFcW0FxZPQ4pZQuEtLk/1E7x00JQf+DXGQmOSFIuKWTsTdQkSGPeH xy1VDmaCsfy+rSmJqaRNsHBpgAdgZsPUsFEhgh9io7CqNIXwtytddnolo0kpV94KA25p AdqtnXZhFK5URaMDeUy4mSzlB1EcLDtMw7zYzSHr5pF4w4295FdQ+HmElIH1g9HUhOnn D1vcyKs4+1BGtsbO2rAY9uAUOwwvndr3mBkQ7oJfkTY82AaZaKJ9JXUDZQ+1xd4zUrJe KF7Q== X-Gm-Message-State: AA+aEWZaYnV6ArWMdD5eKqFUkztyfbc6FyPxhrJkTa1+gIkhfQbVoZOf kLhI6IoNc24BPz6mroeBHNGuS75YEapB X-Google-Smtp-Source: AFSGD/Ux6mqo4fsQ7lC6NrD7qSsbFbiTTKb0yA3lOZ1/WhjBWBNwzwlZeY74SwysCTKwGcQa/PYuPtSeNa1n X-Received: by 2002:a17:902:8b87:: with SMTP id ay7mr3340434plb.94.1542844225490; Wed, 21 Nov 2018 15:50:25 -0800 (PST) Date: Wed, 21 Nov 2018 15:50:16 -0800 In-Reply-To: <20181117010748.24347-1-rajatja@google.com> Message-Id: <20181121235020.29461-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 v3 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 Acked-by: Greg Kroah-Hartman Tested-by: Sukumar Ghorai --- v3: same as v1 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 Wed Nov 21 23:50:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 10693301 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 662DB14DE for ; Wed, 21 Nov 2018 23:51:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 571D62C860 for ; Wed, 21 Nov 2018 23:51:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A5F32C880; Wed, 21 Nov 2018 23:51:09 +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 C12692C860 for ; Wed, 21 Nov 2018 23:51:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390715AbeKVK1G (ORCPT ); Thu, 22 Nov 2018 05:27:06 -0500 Received: from mail-pl1-f202.google.com ([209.85.214.202]:46864 "EHLO mail-pl1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390709AbeKVK1F (ORCPT ); Thu, 22 Nov 2018 05:27:05 -0500 Received: by mail-pl1-f202.google.com with SMTP id m1-v6so11616505plb.13 for ; Wed, 21 Nov 2018 15:50:29 -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=nltjIZyBe3wkrQeEwGuPazv0ZnVMsX5gwUqKQk+rGtk=; b=rfbu1OPuYuBbcI9UB3GpAZNhb0Zb2y+RLFHhv8R1xbJX+7X9PzZptWDqj7sfTuW6bq CGpyWgBWgxoI6XoXE+iphyqj5nUuQV4xyXByY++D7Itjr2wteuEGyBBl8DvuRJintewY Lu++pXG7olb0WpzZgMsIsAf/FY1NW00KLS2tb0GDDSugt2KgiKQ4v/6D0+rG4Cy+YZNA eyhbNIOtvbPLdSG0WBwIanr2goiU3z4mLOTGUJDFjRgsceiEoZHH0Om8Lz0a6FpD3utJ ymFAxmJ5tpjL2jpVeMRfFuCR4ozHe+eUfsbdZ+5LOYV2DkA6PNWFfSnUqHQewjvOsMHb Hoeg== 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=nltjIZyBe3wkrQeEwGuPazv0ZnVMsX5gwUqKQk+rGtk=; b=Uk9eiEdbaroWt+DJgwveaxFe+r/Yj2H9Yq4+SPn/Z5NJ3MpXTuOXLPNy7iLD99PZPm ixidX1OHi0wxPVxbTbCJfyFLeDsqF4bhsw6mtp+R23zPx5x8Yv+ryVvkK4dUiDujNx+E kMFT9RaI1+sXaxS2UrUfdFk4lmvtWPrtfkgF1LR1O7Tvuq1ik+6dRX92Y1pUvCUxX+60 YuZPNKTvwbSuVWLEg0nZUUu8qCz+PTAIbDXi46Bi8aJhkrPPYI92sw6Dd8Rm3dY1NmN/ Ca68kdDKs1Q/h9oSmzRgUFvZU9cooaRHP9ufZoEItSs+S8F83Todh3VKv/6IC5wk+UvC RmDQ== X-Gm-Message-State: AGRZ1gI4JIEr4Vf+97sGr9yO5iE1zabp5rUT5sZukeAY7/Wv1OfzRMZD jWgdqbi3Ty7JdStmk6vU+DM0EWvpqgDk X-Google-Smtp-Source: AJdET5e+SUcQRCWwsuYBdHV52/cHxD6Ta0jykLaj/9/rCiD8/LhlDBQlGJc1FAJIZHQk/wPYN3rFxsM4G3fq X-Received: by 2002:a62:c07:: with SMTP id u7mr3836130pfi.58.1542844228691; Wed, 21 Nov 2018 15:50:28 -0800 (PST) Date: Wed, 21 Nov 2018 15:50:17 -0800 In-Reply-To: <20181121235020.29461-1-rajatja@google.com> Message-Id: <20181121235020.29461-2-rajatja@google.com> Mime-Version: 1.0 References: <20181117010748.24347-1-rajatja@google.com> <20181121235020.29461-1-rajatja@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH v3 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) Acked-by: Greg Kroah-Hartman Tested-by: Sukumar Ghorai --- v3: same as v1 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 Wed Nov 21 23:50:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 10693295 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 01C9413B5 for ; Wed, 21 Nov 2018 23:50:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8B7B2C1D3 for ; Wed, 21 Nov 2018 23:50:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DCAA92C869; Wed, 21 Nov 2018 23:50:37 +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 797AD2C1D3 for ; Wed, 21 Nov 2018 23:50:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390748AbeKVK1K (ORCPT ); Thu, 22 Nov 2018 05:27:10 -0500 Received: from mail-io1-f74.google.com ([209.85.166.74]:40838 "EHLO mail-io1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388031AbeKVK1J (ORCPT ); Thu, 22 Nov 2018 05:27:09 -0500 Received: by mail-io1-f74.google.com with SMTP id g6-v6so6757779iom.7 for ; Wed, 21 Nov 2018 15:50: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=ocDM1LbkKNji8o5absN8u+LSfXhmwVAzLCbs3C5cHds=; b=mpd7iLCah+Z9Gu6vxhKiFF10xJnX1KHQVw3lpU8SyL1suAVcHf8AF/KNn1OkJDg+yT gjkNvCIzW9xj2ove5q4YmnFiDcC/EIBbFNX0S1Irzl8ARWZfoDp+5W5XRA/YuCxXO/Dp NSKAZdc4hVs4AztyLeaWUoLHWHCgPcDSFKHtP5zSk1ZU+t2nIWRLlWqKWTxdBRy3HGzO lNtYrskbMkKcWPB0VAsmv0DW6SuHd3HxheJwujsRI3xBBS9UCYTXpWPL/QgU7p5qIyba huh59ItTGrMk6uIaXUEonH7Jn0caALosC5F0liOzTfX42VEMh1oJII87MRhQA68TZwbt jzRQ== 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=ocDM1LbkKNji8o5absN8u+LSfXhmwVAzLCbs3C5cHds=; b=BQ0OF0T7vYpBurYMMO7R9z1TwJNFgGCLtqmt72Axi8Iy5ZJY/rY/JdE/NKNDGCiUhh LMpk0f7/eYtO1+ppc4crYYoE0U5P7ANMsh2hASQy8krMurrYQ4QSbpLgIy5BwaVPwLcO mXrJyamgIdINUk8/15pkdC0ww8tfdOBWWcC7PKaFTzH93dGDshQXtidDsppUlY3/Fjip jS1qpCIcH/Lzv2kj46cjcPey0p3vw3FpR2wja2jvAvfhMMj23YVwskbgKX0vg5DVwBN3 zGPLjCZealM9zMiPYHLMusky3lrclaw3oT6EkrFvsGex7pJYFFezy1JAwlGzf3H7rH1F f3mQ== X-Gm-Message-State: AA+aEWZG55vBGPH2wLQJZOL4+IdKld49Af3qRG6qRpc1NjPWbUneM7A8 yikfjkm0005+NMWpcslv8wesfogsZekJ X-Google-Smtp-Source: AFSGD/VWHTw4LLRgcchZIk+vaapC6bhpBHLgFkmsbKMxr4zP6VfNpmzz3LYh/UzX6On2fcu40OBbMpoLwGpg X-Received: by 2002:a24:41d4:: with SMTP id b81mr5300566itd.0.1542844232253; Wed, 21 Nov 2018 15:50:32 -0800 (PST) Date: Wed, 21 Nov 2018 15:50:18 -0800 In-Reply-To: <20181121235020.29461-1-rajatja@google.com> Message-Id: <20181121235020.29461-3-rajatja@google.com> Mime-Version: 1.0 References: <20181117010748.24347-1-rajatja@google.com> <20181121235020.29461-1-rajatja@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH v3 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 --- v3: same as v1 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 Wed Nov 21 23:50:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 10693299 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 4642213B5 for ; Wed, 21 Nov 2018 23:50:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3828A2C1D3 for ; Wed, 21 Nov 2018 23:50:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2BCD52C869; Wed, 21 Nov 2018 23:50:54 +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 CA47A2C1D3 for ; Wed, 21 Nov 2018 23:50:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390757AbeKVK1M (ORCPT ); Thu, 22 Nov 2018 05:27:12 -0500 Received: from mail-pl1-f201.google.com ([209.85.214.201]:47267 "EHLO mail-pl1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390753AbeKVK1M (ORCPT ); Thu, 22 Nov 2018 05:27:12 -0500 Received: by mail-pl1-f201.google.com with SMTP id g12-v6so11423661plo.14 for ; Wed, 21 Nov 2018 15:50:35 -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=llDdmAfd5neVL7V7AaHSFjHSVY2TklPB0DGlVFe6mac=; b=OBnXMpZ1eau311w8wuovXTZgOd7JgndO1bVATFdK9mETs3+bGpF7Wao8Sdke4W6wds q31Vb8IsNHnrb++0/wFGYx7TLOQPH50+44IEZ6UtgBje4Zca7kb3AlACezP8qwN/Qcaa VxCcjJfTxsGk2xTuQr7lUMmj7+9KGUi3RH2a7gXYnkuSXT570+cw9gcSer5nE/gueeoq rxCFVxpYuZdGuhmB8/1uY54FVDty7bdplAb7pXoesCUh9mHCP6IVuRWhZP8yy+VEAGSw V1x54Sd0roR4kYqwnP6LdOkfnxm+5BdmmzBJxBeB3yVMbnL31mgsyjGFuqm/+XWVjCRh Rl+w== 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=llDdmAfd5neVL7V7AaHSFjHSVY2TklPB0DGlVFe6mac=; b=ECC3gUfvuPPYtb+rkgvsKWN83yZT4293AW2995071TCSPW2QagDBQ/OL2+OnCRecMJ oxaOjtXxj/ZrYM6J53OCF/4EwebLsf5iJdgt9Uf6SC/V4clu7aGTVpTKO/vrJSd/1aZP +X51rxFVlIfuJ1ToUzlEXpy48KYMhDfHLEX4qBbjq5Xk/o8uAcsZF8yIxL1ar8RcMLy+ VBFGQQfjQf9MoaKPO5mOoEft2g1OJp9FuuMxgKkrtZYazotb2XJjZfsApT0v6re5p9ZC YFetoIZuNMvvBoD04AGbLg7CozEA4Jzg12xcP4HHOiRYnKYXyaUE8JDnSS0LrHbpSyh8 oTtw== X-Gm-Message-State: AGRZ1gI+puAx+YD8Bdz/ruzBtdCyHO0XWSVsuEjNSCEMjBuGCabwXw0p 8ayiUL73GL4DQsVPiI8JtX4Ds3o0BQY9 X-Google-Smtp-Source: AJdET5fs+P1UUmSx0AyK/kmNUhbo6v6jNhIe8nVPh/v1JfQvGidUweh5dh2nKJnHABPZy2w9+GAMufyGUH0p X-Received: by 2002:a62:f247:: with SMTP id y7mr3857992pfl.105.1542844235255; Wed, 21 Nov 2018 15:50:35 -0800 (PST) Date: Wed, 21 Nov 2018 15:50:19 -0800 In-Reply-To: <20181121235020.29461-1-rajatja@google.com> Message-Id: <20181121235020.29461-4-rajatja@google.com> Mime-Version: 1.0 References: <20181117010748.24347-1-rajatja@google.com> <20181121235020.29461-1-rajatja@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH v3 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 --- v3: same as v1 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 Wed Nov 21 23:50:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 10693297 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 90A5F14DE for ; Wed, 21 Nov 2018 23:50:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80F8F2C1D3 for ; Wed, 21 Nov 2018 23:50:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7501A2C869; Wed, 21 Nov 2018 23:50:49 +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 0378C2C1D3 for ; Wed, 21 Nov 2018 23:50:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403777AbeKVK1Q (ORCPT ); Thu, 22 Nov 2018 05:27:16 -0500 Received: from mail-qk1-f201.google.com ([209.85.222.201]:38510 "EHLO mail-qk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403772AbeKVK1P (ORCPT ); Thu, 22 Nov 2018 05:27:15 -0500 Received: by mail-qk1-f201.google.com with SMTP id v64so8012470qka.5 for ; Wed, 21 Nov 2018 15:50:39 -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=49KNIZPrfArthj9ro1doAHEAjCBEwzm+6FuKhqdEH8Y=; b=kAV5XAUTMCOMF7BB20c0IuXEJl+JXkxU1jiix9TVaZss2RhqRQhlbB9HvQLVvNYDRW KGRSQsxCIQg0p7vVh3VMLlnmfHFMSZ9AR2K+KiU7rB9/1nOPuYKL0v4WdsZVOe7F1Zf/ XZoxgFAXcDh4zqNKF4vjLmxdvVc4IsuP7QaicZ3lct2vQ4QR0e8XIE6Y7swNiKZ5agYh hNRMpJsi7CdTlsFnGLmkx7de77j+Y4oSyeeyT3AATktcPD/YpFZU3sEkqJjQ/Aoc9a/R Trsk2EOB38fiQj57i9Ghj6aGl1CSWs/fV0URG2erbmQHsmKcS222XFMcCjmKe0CkTwJm a59g== 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=49KNIZPrfArthj9ro1doAHEAjCBEwzm+6FuKhqdEH8Y=; b=MXUqkBKtSfSLSxRCVE2e2J+KYZ/Jp8cXVcKCT/Yu8Kf/Kl7ySJz2o1zfhTlKmAr7SR jjE80LA+iDX8GIiNrqDTrU1T795wvUgjrBRcruY7RNvIOM0IICfXkREr2bvrUJgjMb6t gThOTCC0Rzlr6Z+qqUcfLZ82D+ctp2pOHhJ4F1lVoFFFFVZ6T2PhMWlncE7pFdaPlDdA 1UWAd/q8XsVyQiRPD1S+4DQV+wk2TEVUwmhFvN33spRYvjPtxkUtOvM9r2CC9fMFbOAj g7fh+WNER0EbgufGNdA4zPjPevza3uo0CJ8SYvLZahzOU00Zb1B38bRCPhP6R3wOJ1vk YO4g== X-Gm-Message-State: AA+aEWbwrxYTzyVzJHq8r5P8pFrJ9OMWuopS0jhWWAzl++X7kz4H1MZI Mq57jH7aYRifl/yWtNAIJOalM21Zn6B7 X-Google-Smtp-Source: AFSGD/WnVgvVzCatQXeW5JG0m4sbonAQMQGPIW0trfOIVbOXlspNjZ8KgKkznzch9kg8XeWk5cQ+reOT/NZP X-Received: by 2002:a0c:98c6:: with SMTP id g6mr5314556qvd.46.1542844238510; Wed, 21 Nov 2018 15:50:38 -0800 (PST) Date: Wed, 21 Nov 2018 15:50:20 -0800 In-Reply-To: <20181121235020.29461-1-rajatja@google.com> Message-Id: <20181121235020.29461-5-rajatja@google.com> Mime-Version: 1.0 References: <20181117010748.24347-1-rajatja@google.com> <20181121235020.29461-1-rajatja@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog Subject: [PATCH v3 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 --- v3: Better error handling for gpiod_get_optional() v2: Handle the EPROBE_DEFER case. drivers/bluetooth/btusb.c | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index e8e148480c91..e7631f770fae 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,26 @@ 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. + */ + 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 +2940,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 +3054,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 (IS_ERR(reset_gpio)) { + err = PTR_ERR(reset_gpio); + goto out_free_dev; + } else if (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 +3119,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 +3260,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 +3305,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); }