Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp788009ybt; Wed, 24 Jun 2020 11:12:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8ZfftpHwWfzOMvZd7X0sIdOMc3zm3ra3RkpxP5PDei9MddLSIlXVDGTooq4EUN6b7pK2n X-Received: by 2002:a05:6402:1217:: with SMTP id c23mr27818233edw.270.1593022359369; Wed, 24 Jun 2020 11:12:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593022359; cv=none; d=google.com; s=arc-20160816; b=RxMUPuVRgAWM9ZzSpfZcut+qk7m8+nsWdSQlINQm2poQabXCDLwyMx8iSl9Y1+0UBO ONTfYRLgET0842OcDtb7Y5cmlT+Y2IZkksOqQt8I+DO5PDuKZSJKRNIm/AMagD5mL4iL 7Vtx4Iqunmh0pKsmILBT9bWh7zGqh1girPPLGxLwUj7Yo33hTeN7e3qmNH2RKy0xQPib 5zueF+GXWglbMd0erYHPZuhU58N+Xdi7c/TU8rYg5hoKeLnU7ofarbZ3dyi0Y0UezPjg nEc/9okCUf395wOeNk/6LuvW5t4ATovyN2i0yzazmJ54wi5pmpulN2avvt2ScMIpO5TC sBWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=422RvCVMwHIgJq8oJttIGIf/8JjnkP+mRkDXzBdPXT8=; b=L/0pQcui6D7bdEbEleQjBIUfHKWytXlJCPrTriNPM2r01/WtwFaBTt8CYTcb+TZnXm 6PoCDi7VcUT6PmbYCgkEOgDoP+SPUfffDbKthv2Hnkt5yQ7ZBWYAGc/nw3IaiOf2U+sF 6WOJqV6kFW9CSIuEiitEKeehfFI9VIR5FoIax4tHq+Q3/86I+GankdfSdiMy9ktcnRbf WPN8fhcU6DgvbjMyNOxFbVBxun78gbnga31mBmXyrMZQd8sf1HGwz7veiEIVNmeDrptc YGduPHrG/VXaYBXNbcr+NVeOnUjSzj92sdu9+So0srjUNmnrb2H5HIyJ1xvDEgO6Oluh n1QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=WZQlmjlW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b22si8683732edt.334.2020.06.24.11.12.16; Wed, 24 Jun 2020 11:12:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=WZQlmjlW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405752AbgFXSLw (ORCPT + 99 others); Wed, 24 Jun 2020 14:11:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405601AbgFXSLv (ORCPT ); Wed, 24 Jun 2020 14:11:51 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51427C061796 for ; Wed, 24 Jun 2020 11:11:51 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id f2so1353776plr.8 for ; Wed, 24 Jun 2020 11:11:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=422RvCVMwHIgJq8oJttIGIf/8JjnkP+mRkDXzBdPXT8=; b=WZQlmjlWEQ1UkJeisUgXi12IFZ6FlsnfN2wqfWi8/FVPnx/OJBTsDqSDl+FXmzFiyM 6oBl5B6cOoZ/WjlUjxWskPl5yHIn3rERO++NtLEvpKmIYyhhUX4CiOwXhw7PhBLBIR0s lxwGO1QQCRUN+VZdtOEsTPYmlCio5gvwj+m4Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=422RvCVMwHIgJq8oJttIGIf/8JjnkP+mRkDXzBdPXT8=; b=Nu+y96FDQO4xULBtfsfTh5E9YeattIFIeUx1dQZBGn8G2f4qXAP+rp5QpXbOVLsnqd dTWfPt5O5SqO21G8ALybnC3LugHioprZqcC4sGaTvHc8FPbddnaVQDcv+FG6UVZoJECA /cNoZdjguXJ4DZgwiztkohwJMRd836m0l1Lne+VOPVRSFEq4tBZB8gqzhvtHHFUNvPCK 6CnOOBwxxmOy2SlwUaSd5pHYFKG0suP4EuW6G54Jk6IsuzFknOL6zEMWwXhS1hdmGJUl J8M5+HfSR8JbJCAHz8iAXSACeFHzmtpm4hW3kXPTYL8v6fmgvgCy+N99dRnrvJ10cv3D yPxQ== X-Gm-Message-State: AOAM533b3tc56oT7ZOTFfCQH/toRSPZ4iv7rBdrXE144Ey6/RPISPjgJ HP1/AjiWPYM5PVXF7sGaQIVMrg== X-Received: by 2002:a17:90b:1087:: with SMTP id gj7mr30297077pjb.124.1593022310574; Wed, 24 Jun 2020 11:11:50 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:e09a:8d06:a338:aafb]) by smtp.gmail.com with ESMTPSA id 127sm16139674pgf.5.2020.06.24.11.11.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 11:11:50 -0700 (PDT) From: Abhishek Pandit-Subedi To: rjliao@codeaurora.org, marcel@holtmann.org, linux-bluetooth@vger.kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-usb@vger.kernel.org, linux-pm@vger.kernel.org, Abhishek Pandit-Subedi , Johan Hedberg , linux-kernel@vger.kernel.org Subject: [PATCH v2] Bluetooth: btusb: Reset port on cmd timeout Date: Wed, 24 Jun 2020 11:11:44 -0700 Message-Id: <20200624111128.v2.1.Ibae403db54245c458d14297f1892c77c5055da41@changeid> X-Mailer: git-send-email 2.27.0.111.gc72c7da667-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org QCA_ROME sometimes gets into a state where it is unresponsive to commands. Since it doesn't have support for a reset gpio, reset the usb port when this occurs instead. Signed-off-by: Abhishek Pandit-Subedi --- On Chromebooks with this chipset, we encountered cmd_timeout after running suspend stress test for hundreds of iterations. Without a recovery mechanism, continued cmd_timeout failures eventually caused the suspend stress test to fail. This change will just reset the port that the Bluetooth chip is on when cmd_timeout is encountered. At the very least, the driver will unload and stop affecting suspend. It doesn't seem to restore the BT controller to a good state however (this still requires a power cycle). Changes in v2: - Renamed btusb_generic_usb_cmd_timeout to btusb_qca_cmd_timeout - Updated commit note drivers/bluetooth/btusb.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index e42fdd625eb023..df46b2a34c1803 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -573,6 +573,22 @@ static void btusb_rtl_cmd_timeout(struct hci_dev *hdev) gpiod_set_value_cansleep(reset_gpio, 0); } +static void btusb_qca_cmd_timeout(struct hci_dev *hdev) +{ + struct btusb_data *data = hci_get_drvdata(hdev); + int err; + + if (++data->cmd_timeout_cnt < 5) + return; + + bt_dev_err(hdev, "Multiple cmd timeouts seen. Resetting usb device."); + err = usb_autopm_get_interface(data->intf); + if (!err) + usb_queue_reset_device(data->intf); + else + bt_dev_err(hdev, "Failed usb_autopm_get_interface with %d", err); +} + static inline void btusb_free_frags(struct btusb_data *data) { unsigned long flags; @@ -3964,6 +3980,7 @@ static int btusb_probe(struct usb_interface *intf, if (id->driver_info & BTUSB_QCA_ROME) { data->setup_on_usb = btusb_setup_qca; hdev->set_bdaddr = btusb_set_bdaddr_ath3012; + hdev->cmd_timeout = btusb_qca_cmd_timeout; set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); btusb_check_needs_reset_resume(intf); } -- 2.27.0.111.gc72c7da667-goog