Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp3086489ybn; Fri, 27 Sep 2019 00:30:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqyaVv8Pg7n7lToob0Jes7D3EMSxM+zqT7CVFupRvDcqvRUzgEu/lwjrII1jolD8XjRLaBxa X-Received: by 2002:aa7:d4c5:: with SMTP id t5mr2940855edr.154.1569569420538; Fri, 27 Sep 2019 00:30:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569569420; cv=none; d=google.com; s=arc-20160816; b=BGuP80F4LZZud9uHyMEKf1a4tDELMZjrR81MxGTFbV0lB1Q27OOWGhVXBsIxMF9mNn R3AnxTESiHXw8UxR7latq/Qxj1AJK3I/7jgKirIQnmcez4LJ9tI1rX/WoXTbzlf/DIiR bsvAQVGUJ+o7uj7DMa/3KC1cj/k4XQE348tQsjXioDGATH+Ml5x2HQ3a6SQrLo2NiHRc 44a5OPuKq9LWb4YArVXsWbs69QtRt7R1YWD5J3k15HSe9+8mM3+KKeihKxpMFFntvlN2 RlusODf14syJmogDisbgyESm/sQt5kWvR5IqlINZxktD7eo4ieSI2w+kqTvcRePMSKpm lZCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :dlp-reaction:dlp-version:dlp-product:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from; bh=sfctwsKBI2L/bVypsc/RyJe01oojf894ravv+EkB5kI=; b=Y2WRV9+QJOdDAwZUMY8u/nyy/7eQmXECnRmayyz1A2l6NoEphZbn//nIXfJNngzFo1 IDBR30Y7YK03zAH2gMHynUL8P8fARizDBVw0DGXS/tkwbhoZGSks55zmiYkDADtwZL0Q 6mythStFNwd2MFLbuvnD+f9BYp08J3UaY11iRYLX6sY4k2DMXnkmYsxh8Dwfsus4ap3e Cn7GiYN4AInCi/I1bP8ez7O2vIu5N5KVzyh0LZ+mBljdnNsPC0iSsiafJnf/y1dUJiBs Vq9hBY+G+SNSBWBDilCUC8rAcKT7ld3RvaYfIu9LgFZNEW4i/T1LwKEOH7v6FYFiDzIx PLzA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ga6si2288201ejb.309.2019.09.27.00.29.48; Fri, 27 Sep 2019 00:30:20 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725820AbfI0H3m convert rfc822-to-8bit (ORCPT + 99 others); Fri, 27 Sep 2019 03:29:42 -0400 Received: from mga12.intel.com ([192.55.52.136]:60400 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725812AbfI0H3l (ORCPT ); Fri, 27 Sep 2019 03:29:41 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Sep 2019 00:29:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,554,1559545200"; d="scan'208";a="273727566" Received: from pgsmsx112.gar.corp.intel.com ([10.108.55.201]) by orsmga001.jf.intel.com with ESMTP; 27 Sep 2019 00:29:40 -0700 Received: from pgsmsx106.gar.corp.intel.com (10.221.44.98) by PGSMSX112.gar.corp.intel.com (10.108.55.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 27 Sep 2019 15:27:46 +0800 Received: from pgsmsx105.gar.corp.intel.com ([169.254.4.30]) by PGSMSX106.gar.corp.intel.com ([169.254.9.23]) with mapi id 14.03.0439.000; Fri, 27 Sep 2019 15:27:46 +0800 From: "Bag, Amit K" To: Marcel Holtmann CC: "linux-bluetooth@vger.kernel.org" , "Srivatsa, Ravishankar" , "Tumkur Narayan, Chethan" , "Hegde, Raghuram" Subject: RE: [PATCH] Bluetooth: btusb: Trigger Intel FW download error recovery Thread-Topic: [PATCH] Bluetooth: btusb: Trigger Intel FW download error recovery Thread-Index: AQHVdDZ8SxjBrsJBVUGWo2sTd/IkjKc+jbWAgACTsUA= Date: Fri, 27 Sep 2019 07:27:45 +0000 Message-ID: References: <1569480202-10560-1-git-send-email-amit.k.bag@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNTQzODk5ZTgtMTgxNi00NDBhLWE1Y2YtYjZmMTg2NjdhNzYwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiUEt4ejZGWmxWcXloQzVwa2VScEZCWTVPb1wvR3hFT1VnS2ZTM05zVW9HTzlZQjdYRjN4S0ExUmNGa0N2WFVLZ2MifQ== dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [172.30.20.206] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org >Hi Amit, > >> Sometimes during FW data download stage, in case of an error is >> encountered the controller device could not be recovered. To recover >> from such failures send Intel hard Reset to re-trigger FW download in >> following error scenarios: >> >> 1. Intel Read version command error >> 2. Firmware download timeout >> 3. Failure in Intel Soft Reset for switching to operational FW 4. Boot >> timeout for switching to operaional FW >> >> Signed-off-by: Raghuram Hegde >> Signed-off-by: Chethan T N >> Signed-off-by: Amit K Bag >> --- >> drivers/bluetooth/btintel.c | 39 >> +++++++++++++++++++++++++++++++++++++++ >> drivers/bluetooth/btintel.h | 6 ++++++ >> drivers/bluetooth/btusb.c | 20 ++++++++++++++++---- >> 3 files changed, 61 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c >> index bb99c8653aab..fdec9c53b48d 100644 >> --- a/drivers/bluetooth/btintel.c >> +++ b/drivers/bluetooth/btintel.c >> @@ -709,6 +709,45 @@ int btintel_download_firmware(struct hci_dev >> *hdev, const struct firmware *fw, } >> EXPORT_SYMBOL_GPL(btintel_download_firmware); >> >> +void btintel_retry_fw_download(struct hci_dev *hdev) { >> + /* Send Intel Reset command. This will result in >> + * re-enumeration of BT controller. >> + * >> + * Intel Reset parameter description: >> + * reset_param[0] => reset_type : 0x01 (Hard reset), >> + 0x00 (Soft reset) >> + * reset_param[1] => patch_enable : 0x01 (Enable), >> + * 0x00 (Do not enable) >> + * reset_param[2] => ddc_reload : 0x01 (Reload), >> + * 0x00 (Do not reload) >> + * reset_param[3] => boot_option: 0x00 (Current image), >> + 0x01 (Specified boot address) >> + * reset_param[4] to reset_param[7] => Boot address >> + * >> + */ >> + static const u8 reset_param[] = { 0x01, 0x01, 0x01, 0x00, >> + 0x00, 0x00, 0x00, 0x00 }; pplease use intel_reset structure and add the comments when assigning the fields. >> + struct sk_buff *skb; >> + >> + skb = __hci_cmd_sync(hdev, 0xfc01, sizeof(reset_param), >> + reset_param, HCI_INIT_TIMEOUT); pplease align the second line according to the coding style. >> + if (IS_ERR(skb)) { >> + bt_dev_err(hdev, "FW download error recovery failed (%ld)", >> + PTR_ERR(skb)); SSame as above. >> + return; >> + } >> + bt_dev_info(hdev, "Intel reset sent to retry FW download"); >> + kfree_skb(skb); EExtra empty line here. >> + /* Current Intel BT controllers(ThP/JfP) hold the USB reset >> + * lines for 2ms when it receives Intel Reset in bootloader mode. >> + * Whereas, the upcoming Intel BT controllers will hold USB reset >> + * for 150ms. To keep the delay generic, 150ms is chosen here. >> + */ >> + msleep(150); >> +} >> +EXPORT_SYMBOL_GPL(btintel_retry_fw_download); >> + II do not like the name here. Using btintel_reset_to_bootloader would be better. Since the function itself is not going to do the firmware retry. It will just drop you back into boot loader. HHowever the more important question is what happens if you send this command. Is the device re-enumerating on USB? Or after the 150ms we just have to redo the firmware download. >> MODULE_AUTHOR("Marcel Holtmann "); >> MODULE_DESCRIPTION("Bluetooth support for Intel devices ver " >> VERSION); MODULE_VERSION(VERSION); diff --git >> a/drivers/bluetooth/btintel.h b/drivers/bluetooth/btintel.h index >> 3d846190f2bf..d04d3c7cb513 100644 >> --- a/drivers/bluetooth/btintel.h >> +++ b/drivers/bluetooth/btintel.h >> @@ -87,6 +87,7 @@ int btintel_read_boot_params(struct hci_dev *hdev, >> struct intel_boot_params *params); int >> btintel_download_firmware(struct hci_dev *dev, const struct firmware *fw, >> u32 *boot_param); >> +void btintel_retry_fw_download(struct hci_dev *hdev); >> #else >> >> static inline int btintel_check_bdaddr(struct hci_dev *hdev) @@ -181,4 >> +182,9 @@ static inline int btintel_download_firmware(struct hci_dev >> *dev, { >> return -EOPNOTSUPP; >> } >> + >> +static inline void btintel_retry_fw_download(struct hci_dev *hdev) { >> + return -EOPNOTSUPP; >> +} >> #endif >> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c >> index a9c35ebb30f8..7a763bd856ba 100644 >> --- a/drivers/bluetooth/btusb.c >> +++ b/drivers/bluetooth/btusb.c >> @@ -1846,8 +1846,11 @@ static int btusb_setup_intel(struct hci_dev *hdev) >> * firmware variant, revision and build number. >> */ >> err = btintel_read_version(hdev, &ver); >> - if (err) >> + if (err) { >> + bt_dev_err(hdev, "Intel Read version failed (%d)", err); >> + btintel_retry_fw_download(hdev); >> return err; >> + } >> >> bt_dev_info(hdev, "read Intel version: %02x%02x%02x%02x%02x%02x%02x%02x%02x", >> ver.hw_platform, ver.hw_variant, ver.hw_revision, @@ -2326,9 >> +2329,13 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) >> >> /* Start firmware downloading and get boot parameter */ >> err = btintel_download_firmware(hdev, fw, &boot_param); >> - if (err < 0) >> + if (err < 0) { >> + /* When FW download fails, send Intel Reset to retry >> + * FW download. >> + */ >> + btintel_retry_fw_download(hdev); >> goto done; > >Is this actually going to work? If you jump to done, then you end up sending intel soft reset and then waiting for the device to boot. If you are lucky it times out, if not, then you end up loading DCC now. > >If the device re-enumerates on USB, then we need an extra jump point to just release the firmware memory and then just exit hdev->setup. If are suppose to just retry, then we need to actually start over. > >So have you actually tested this by randomly failing each step in the firmware download process. > We send hard reset which will re-emumerates BT USB device and initialize usb driver. We have tested all the scenario and its working fine.