From patchwork Mon Aug 17 15:15:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 266387 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CB7BC433E1 for ; Mon, 17 Aug 2020 16:04:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F31E920772 for ; Mon, 17 Aug 2020 16:04:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597680265; bh=a8h1xJEDGoLV5AE9Kc/sZSDbotZOKj9Z8iiWloJaKXg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=sGdS89JYugtzsX72e/FRLk1YtWgfoYZMgJo8k3JU8iqUZUcaD0VSrrFU530wCh/u5 5/Q+7bIUB0PGOWePYLMpVrsJ4iMfYw5XM99axqyllP58B974OWS/DhTflDvC6/KXJx 2Y4XWokUPBiSSurJ1Lt2lf8+u3gTmrT6o7Ea9RU4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388297AbgHQQEX (ORCPT ); Mon, 17 Aug 2020 12:04:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:51666 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388272AbgHQQD4 (ORCPT ); Mon, 17 Aug 2020 12:03:56 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5402920748; Mon, 17 Aug 2020 16:03:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597680235; bh=a8h1xJEDGoLV5AE9Kc/sZSDbotZOKj9Z8iiWloJaKXg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RlUiCeIQm8Sk71/WsJ6sd8jFKP4NINo7R4m+xvvfRF4or6c8QmtvX0ueHR7aeVmqH defdZWvzApEiwrPFfHeg01XwtnfAEWeNCc4Q4mSiJeGso74k3meAI04R2zb1NgAfts qG7pkUScgTAqEl+KBsQAro+8Eubx+X3AGeHjLUv4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Chen , Sean Wang , Marcel Holtmann , Sasha Levin Subject: [PATCH 5.4 106/270] Bluetooth: btusb: fix up firmware download sequence Date: Mon, 17 Aug 2020 17:15:07 +0200 Message-Id: <20200817143801.060828373@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143755.807583758@linuxfoundation.org> References: <20200817143755.807583758@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Sean Wang [ Upstream commit f645125711c80f9651e4a57403d799070c6ad13b ] Data RAM on the device have to be powered on before starting to download the firmware. Fixes: a1c49c434e15 ("Bluetooth: btusb: Add protocol support for MediaTek MT7668U USB devices") Co-developed-by: Mark Chen Signed-off-by: Mark Chen Signed-off-by: Sean Wang Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin --- drivers/bluetooth/btusb.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 9c3b063e1a1f7..f3f0529564da0 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -2792,7 +2792,7 @@ static int btusb_mtk_setup_firmware(struct hci_dev *hdev, const char *fwname) const u8 *fw_ptr; size_t fw_size; int err, dlen; - u8 flag; + u8 flag, param; err = request_firmware(&fw, fwname, &hdev->dev); if (err < 0) { @@ -2800,6 +2800,20 @@ static int btusb_mtk_setup_firmware(struct hci_dev *hdev, const char *fwname) return err; } + /* Power on data RAM the firmware relies on. */ + param = 1; + wmt_params.op = BTMTK_WMT_FUNC_CTRL; + wmt_params.flag = 3; + wmt_params.dlen = sizeof(param); + wmt_params.data = ¶m; + wmt_params.status = NULL; + + err = btusb_mtk_hci_wmt_sync(hdev, &wmt_params); + if (err < 0) { + bt_dev_err(hdev, "Failed to power on data RAM (%d)", err); + return err; + } + fw_ptr = fw->data; fw_size = fw->size;