From patchwork Thu Apr 26 11:13:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 134506 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp2130530lji; Thu, 26 Apr 2018 04:13:34 -0700 (PDT) X-Google-Smtp-Source: AIpwx491A6cPQliqq3advhsr1A8VHUrb4HR085FMqcxKqSFKF5eoRVLDDCpJtoFX830v+btXIutJ X-Received: by 10.98.137.16 with SMTP id v16mr31430135pfd.13.1524741214420; Thu, 26 Apr 2018 04:13:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524741214; cv=none; d=google.com; s=arc-20160816; b=T0+OKnwf0+ttZgRezUR7z751bgGIwhwZLjuXWoFKNRvKVz2TGagVsXRqNVc2EK3KC9 /e7gtkcrcYhCVI1uhDBWYPQu7IJr4O9DSrQnlOJvv8aya6hEzJUOwAT/5AYAeC0KkYpS OqCj5MkC9gjLMTMU1ej1azuvyA8FXZOOinKRpWLsZEVtp81YbnxzKkPUj9BKLFPhZDTJ LI3N0nK237QAwXpCkZC0OXLbx+9Ecg8USOtQkawAQ7O/pljnoIeLuioUEdw+0iKXwQoB 57kVqwP3ReOtZO/21uAXtENLDhvek5U2PNnnee3uupposKFTSvcgfECUJi8eBT+p0UTe XalQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=D8E88isIbVsNncOi8zzhf/t42yUuXNhYagDYCzwIiFI=; b=NZ8Hw3/MBP0fnkGoeNsGrY7jhvT0bB7tDPiTIIdXY8l2xxXPFWAJ0HJbubS5Mhqagn cbbXnA3VsQcum0OrGEtWoAzSGHO97BR4SP1xgG0wgiFWugL8BGkqZLf0aZGNlGOly2Gz bepsGny7jqyAHH2s4EewgyP+BF+EY+aU2eSP2A1zwWha9Pce9KumOuFppzNXDRL2YyVO sgvQu78EcrlSn8z1P4jBn8Lo+D8KpcnUB1XCHOs064BCnSsgIe6Tz55KsYS+BH3Z8Lv1 dAWcsHHJnnNhVymItL40+S5OddOuD7/r5AEiWEW2fycW8Dvz2kZ23Ij06kavzAtHRuOA eylg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jl1eI6YP; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f38-v6si17584718plb.44.2018.04.26.04.13.34; Thu, 26 Apr 2018 04:13:34 -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; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jl1eI6YP; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755209AbeDZLNc (ORCPT + 1 other); Thu, 26 Apr 2018 07:13:32 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:39470 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755171AbeDZLNb (ORCPT ); Thu, 26 Apr 2018 07:13:31 -0400 Received: by mail-wm0-f67.google.com with SMTP id b21so12536127wme.4 for ; Thu, 26 Apr 2018 04:13:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=lqT0lbK7pBsE/GXqMIlCOn4lL7TwkuimP5Sqz3uAFmM=; b=jl1eI6YP02p0Hg4c5mDPVf2cdI8pJ1Kf88Q26NnaECGReCTtRnBPijDz1Ziauh4qZa sS8ods/2ZEAklxo4lC30edn1PFOOrZGqMWYiTRsOzrKiwVO8IBddhv25QAbizmYHGl2K spR6LEIWlIN5I8nQjibRywGm1wPmFeqCaPMXM= 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; bh=lqT0lbK7pBsE/GXqMIlCOn4lL7TwkuimP5Sqz3uAFmM=; b=sdkBC67/5OFduUfSJ3nC+efZR3CWrF+zixgG24MJeJ8V9lY88TCX/DjfW31nRg7e17 x7KWOEfcbGQiE0TLP4BRXOPtxGvlNnOj3EVfFU+oqoP9YjLgB/XX0t+9UWT4/dSTQzEb VIEpD9eIBIj1jLZ0MOqRj8d8Bzln/olW9RvURM12bpaBkt6pkV4GOxH5LTZzYvOwUYLC 92JN41ShwgutEKwWpR6lYMabfzo9bm0t2LDewks8TzfURPLLQ0I7zlop1PsAhvqVm+iR dEgtYSLiVaNDniqSLBUUHkz9N6QkSYCy8bfHmXF91RCMlOjml71ZUwGND0EZp2ZsWasx T38Q== X-Gm-Message-State: ALQs6tDJ6fbTRXNsU4To5uJTODkDbzkZ0X59NjsKwRKpxTcr/i9Lb9le D2K2rLI3h1eZtIF85U7Swqr8Qw== X-Received: by 10.28.58.81 with SMTP id h78mr17218059wma.110.1524741210324; Thu, 26 Apr 2018 04:13:30 -0700 (PDT) Received: from lpoulain-ThinkPad-T470p.home (LFbn-1-10589-161.w90-89.abo.wanadoo.fr. [90.89.181.161]) by smtp.gmail.com with ESMTPSA id x81-v6sm18967036wrb.23.2018.04.26.04.13.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Apr 2018 04:13:29 -0700 (PDT) From: Loic Poulain To: marcel@holtmann.org, johan.hedberg@gmail.com Cc: linux-bluetooth@vger.kernel.org, bgodavar@codeaurora.org, Loic Poulain Subject: [PATCH v3 1/2] Bluetooth: Add __hci_cmd_send function Date: Thu, 26 Apr 2018 13:13:26 +0200 Message-Id: <1524741207-19753-1-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This function allows to send a HCI command without expecting any controller event/response in return. This is allowed for vendor- specific commands only. Signed-off-by: Loic Poulain --- v2: Only allow vendor-specific command to be unresponded Rename function to __hci_cmd_send v3: no change include/net/bluetooth/hci_core.h | 2 ++ net/bluetooth/hci_core.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index b619a19..893bbbb 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1393,6 +1393,8 @@ struct sk_buff *__hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen, const void *param, u32 timeout); struct sk_buff *__hci_cmd_sync_ev(struct hci_dev *hdev, u16 opcode, u32 plen, const void *param, u8 event, u32 timeout); +int __hci_cmd_send(struct hci_dev *hdev, u16 opcode, u32 plen, + const void *param); int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, const void *param); diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 40d260f..b0ee9ed 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3422,6 +3422,37 @@ int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, return 0; } +int __hci_cmd_send(struct hci_dev *hdev, u16 opcode, u32 plen, + const void *param) +{ + struct sk_buff *skb; + + if (hci_opcode_ogf(opcode) != 0x3f) { + /* A controller receiving a command shall respond with either + * a Command Status Event or a Command Complete Event. + * Therefore, all standard HCI commands must be sent via the + * standard API, using hci_send_cmd or hci_cmd_sync helpers. + * Some vendors do not comply with this rule for vendor-specific + * commands and do not return any event. We want to support + * unresponded commands for such cases only. + */ + bt_dev_err(hdev, "unresponded command not supported"); + return -EINVAL; + } + + skb = hci_prepare_cmd(hdev, opcode, plen, param); + if (!skb) { + bt_dev_err(hdev, "no memory for command (opcode 0x%4.4x)", + opcode); + return -ENOMEM; + } + + hci_send_frame(hdev, skb); + + return 0; +} +EXPORT_SYMBOL(__hci_cmd_send); + /* Get data from the previously sent command */ void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode) { From patchwork Thu Apr 26 11:13:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 134507 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp2130834lji; Thu, 26 Apr 2018 04:13:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZplMf380lAz5eNNswhIWsHBfmfL8HEsLsm3nNGXOH022uxEN+brUhHLGoIPVzbIpBAUXD8U X-Received: by 10.101.80.204 with SMTP id s12mr7709317pgp.313.1524741229089; Thu, 26 Apr 2018 04:13:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524741229; cv=none; d=google.com; s=arc-20160816; b=k7vXl427uoAddjsBMaAuH3znlHrY8NewQ6QcrZvC5RZNrMXGdI5WEY7VBdVWGdVf+T PEvHodtgmO3mafHHJm5Z51LnTJp+8sumA2+wVlA45YfF/4A+SgOaWrUF2tNBsm2AYIcQ +HSTGBCcjD8Dhj3pu68pavmKTQJtYG97Iip25cEYD8n8zasHa1jXzkkzE0gXVcVN+Omv 5EdPNDjUm+Jj/rPzn+sqv8HWZIHkbhUhljkqVFFTmPg5BVrz74ztUGvug41jWyFUPpnN +aIr+6FpQfTzyudYnAciJ/TudfgUbGHarJ4KxDSNrZs84m92//fXsvvjP0SKVy93U5wO F0DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=cKv1/aQa2O+gtux9nnVGrcMkIguZn035VkEvGPxmkFE=; b=aCJB3TU7rtemHZRKlZVdChuVxQ5ikPRk+eGTlSukVQh58Nu1rRnyr8v2ITop9rSlWP UEs6io3kWnr2LM+Y/yk33ik/OEYkkn3sV4exO9W2nJmoHyqFuR+4XsKPvvqnVQG194mE UmO9j7HHx0PIN1/r4TiYivLia0fFhpZmGRj+V1k2Zkr5HcE+mqnUuL3Zj84lRykwY/W2 zWJ+qSeSKF+5QfDixVWl9qNaebhuD8C54FjFdY+pw/rkrHGf41/E6LZjPLE7HdWnDZd5 s3X4L4q8cLhf+a3s33jg13cV3zoHqkzbb0PbApSE70AoflHdmRQdSOI9gySkMVaUKtlo ri4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=W1h1HhSx; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3-v6si19132588pld.2.2018.04.26.04.13.48; Thu, 26 Apr 2018 04:13:49 -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; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=W1h1HhSx; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754648AbeDZLNr (ORCPT + 1 other); Thu, 26 Apr 2018 07:13:47 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:35169 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755171AbeDZLNd (ORCPT ); Thu, 26 Apr 2018 07:13:33 -0400 Received: by mail-wm0-f65.google.com with SMTP id o78so12521931wmg.0 for ; Thu, 26 Apr 2018 04:13:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SVNu1GnLasPA1+AFZR7YY6nNPpfjHmmT7KbtaTkOUkY=; b=W1h1HhSxZMjIosIVoUZjizv5Xcf+LWhTs4IFdm/V0gQj0DTSaBKKBaG8TT+s3YMwDa aKgAXrDmcB9BgWO50S8xTzeGn82A1OV0gKPWlkPeiDMZQcI1d7zjB4NWhxKpgtkNBvrA TRiXIY0mSpzTHx9z3wn21HC2kQjrvStGuxvXQ= 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:in-reply-to :references; bh=SVNu1GnLasPA1+AFZR7YY6nNPpfjHmmT7KbtaTkOUkY=; b=D7pPNM2PlUtWXUGX//Xg/UTBqibeAPVNOJoZBP4IwHiwEVhwBP0ro2c1hmbKxryEV1 A2Y5o7VudqHflkRDHy4l+P1yVsWU9MDEbJ+HEWjIxQmzgD8ONyhWshYR4YlGrefOSoIG 5nFnkjpRxo1ORfhn6O48Y2H64MMG+CxfO1QbSa1viJGRFgtRxks/kEfwB1Fy/SLaHrTv a6xpFDxSNDrEBb+fq1ahCXQp4jPPiXyIjSBRAXOqLFhcCLbqvBiujHx0UIIR91Cenu+P VechYD+nFp2eu52l2vDn6p4D47TfmpHMA3qVc/Oed0eBWDW/fGxtQSH7TcVqryRn61PU Y4tg== X-Gm-Message-State: ALQs6tCVl4ZvdcDAs7jomcLmMRZBywG3Aem51+PwWEuGTbe2aLiHJYIK OorbBMLuX16AwvFoDmJ30IuB5Qz6gKA= X-Received: by 10.28.91.203 with SMTP id p194mr19204925wmb.52.1524741212089; Thu, 26 Apr 2018 04:13:32 -0700 (PDT) Received: from lpoulain-ThinkPad-T470p.home (LFbn-1-10589-161.w90-89.abo.wanadoo.fr. [90.89.181.161]) by smtp.gmail.com with ESMTPSA id x81-v6sm18967036wrb.23.2018.04.26.04.13.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Apr 2018 04:13:31 -0700 (PDT) From: Loic Poulain To: marcel@holtmann.org, johan.hedberg@gmail.com Cc: linux-bluetooth@vger.kernel.org, bgodavar@codeaurora.org, Loic Poulain Subject: [PATCH v3 2/2] Bluetooth: btqca: Add AR3002 rampatch support Date: Thu, 26 Apr 2018 13:13:27 +0200 Message-Id: <1524741207-19753-2-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524741207-19753-1-git-send-email-loic.poulain@linaro.org> References: <1524741207-19753-1-git-send-email-loic.poulain@linaro.org> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch adds rampatch download compatibility for ROME >= 3.2. Starting with ROME 3.2, the 'download mode' field of the rampatch header indicates if the controller acknowledges (or not) the received rampatch segments. If not, we need to send all the segments without expecting any event from the controller (except for the last segment). Goal is (I assume) to speed-up rampatch download. This fixes BT on Dragonboard-600c P2 which includes the following BT controller: hci0: ROME Patch Version Request hci0: Product:0x00000008 hci0: Patch :0x00000111 hci0: ROM :0x00000302 hci0: SOC :0x00000023 Signed-off-by: Loic Poulain --- v2: Do not check rome version, byte is reserved or dedicated to dnld mode v3: coding-style, one line if statement drivers/bluetooth/btqca.c | 104 ++++++++++++++++++++++------------------------ drivers/bluetooth/btqca.h | 11 ++++- 2 files changed, 59 insertions(+), 56 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/bluetooth/btqca.c b/drivers/bluetooth/btqca.c index 2793d41..8219816 100644 --- a/drivers/bluetooth/btqca.c +++ b/drivers/bluetooth/btqca.c @@ -127,28 +127,41 @@ static void rome_tlv_check_data(struct rome_config *config, BT_DBG("TLV Type\t\t : 0x%x", type_len & 0x000000ff); BT_DBG("Length\t\t : %d bytes", length); + config->dnld_mode = ROME_SKIP_EVT_NONE; + switch (config->type) { case TLV_TYPE_PATCH: tlv_patch = (struct tlv_type_patch *)tlv->data; - BT_DBG("Total Length\t\t : %d bytes", + + /* For Rome version 1.1 to 3.1, all segment commands + * are acked by a vendor specific event (VSE). + * For Rome >= 3.2, the download mode field indicates + * if VSE is skipped by the controller. + * In case VSE is skipped, only the last segment is acked. + */ + config->dnld_mode = tlv_patch->download_mode; + + BT_DBG("Total Length : %d bytes", le32_to_cpu(tlv_patch->total_size)); - BT_DBG("Patch Data Length\t : %d bytes", + BT_DBG("Patch Data Length : %d bytes", le32_to_cpu(tlv_patch->data_length)); BT_DBG("Signing Format Version : 0x%x", tlv_patch->format_version); - BT_DBG("Signature Algorithm\t : 0x%x", + BT_DBG("Signature Algorithm : 0x%x", tlv_patch->signature); - BT_DBG("Reserved\t\t : 0x%x", - le16_to_cpu(tlv_patch->reserved1)); - BT_DBG("Product ID\t\t : 0x%04x", + BT_DBG("Download mode : 0x%x", + tlv_patch->download_mode); + BT_DBG("Reserved : 0x%x", + tlv_patch->reserved1); + BT_DBG("Product ID : 0x%04x", le16_to_cpu(tlv_patch->product_id)); - BT_DBG("Rom Build Version\t : 0x%04x", + BT_DBG("Rom Build Version : 0x%04x", le16_to_cpu(tlv_patch->rom_build)); - BT_DBG("Patch Version\t\t : 0x%04x", + BT_DBG("Patch Version : 0x%04x", le16_to_cpu(tlv_patch->patch_version)); - BT_DBG("Reserved\t\t : 0x%x", + BT_DBG("Reserved : 0x%x", le16_to_cpu(tlv_patch->reserved2)); - BT_DBG("Patch Entry Address\t : 0x%x", + BT_DBG("Patch Entry Address : 0x%x", le32_to_cpu(tlv_patch->entry)); break; @@ -194,8 +207,8 @@ static void rome_tlv_check_data(struct rome_config *config, } } -static int rome_tlv_send_segment(struct hci_dev *hdev, int idx, int seg_size, - const u8 *data) +static int rome_tlv_send_segment(struct hci_dev *hdev, int seg_size, + const u8 *data, enum rome_tlv_dnld_mode mode) { struct sk_buff *skb; struct edl_event_hdr *edl; @@ -203,12 +216,14 @@ static int rome_tlv_send_segment(struct hci_dev *hdev, int idx, int seg_size, u8 cmd[MAX_SIZE_PER_TLV_SEGMENT + 2]; int err = 0; - BT_DBG("%s: Download segment #%d size %d", hdev->name, idx, seg_size); - cmd[0] = EDL_PATCH_TLV_REQ_CMD; cmd[1] = seg_size; memcpy(cmd + 2, data, seg_size); + if (mode == ROME_SKIP_EVT_VSE_CC || mode == ROME_SKIP_EVT_VSE) + return __hci_cmd_send(hdev, EDL_PATCH_CMD_OPCODE, seg_size + 2, + cmd); + skb = __hci_cmd_sync_ev(hdev, EDL_PATCH_CMD_OPCODE, seg_size + 2, cmd, HCI_VENDOR_PKT, HCI_INIT_TIMEOUT); if (IS_ERR(skb)) { @@ -245,47 +260,12 @@ static int rome_tlv_send_segment(struct hci_dev *hdev, int idx, int seg_size, return err; } -static int rome_tlv_download_request(struct hci_dev *hdev, - const struct firmware *fw) -{ - const u8 *buffer, *data; - int total_segment, remain_size; - int ret, i; - - if (!fw || !fw->data) - return -EINVAL; - - total_segment = fw->size / MAX_SIZE_PER_TLV_SEGMENT; - remain_size = fw->size % MAX_SIZE_PER_TLV_SEGMENT; - - BT_DBG("%s: Total segment num %d remain size %d total size %zu", - hdev->name, total_segment, remain_size, fw->size); - - data = fw->data; - for (i = 0; i < total_segment; i++) { - buffer = data + i * MAX_SIZE_PER_TLV_SEGMENT; - ret = rome_tlv_send_segment(hdev, i, MAX_SIZE_PER_TLV_SEGMENT, - buffer); - if (ret < 0) - return -EIO; - } - - if (remain_size) { - buffer = data + total_segment * MAX_SIZE_PER_TLV_SEGMENT; - ret = rome_tlv_send_segment(hdev, total_segment, remain_size, - buffer); - if (ret < 0) - return -EIO; - } - - return 0; -} - static int rome_download_firmware(struct hci_dev *hdev, struct rome_config *config) { const struct firmware *fw; - int ret; + const u8 *segment; + int ret, remain, i = 0; bt_dev_info(hdev, "ROME Downloading %s", config->fwname); @@ -298,10 +278,24 @@ static int rome_download_firmware(struct hci_dev *hdev, rome_tlv_check_data(config, fw); - ret = rome_tlv_download_request(hdev, fw); - if (ret) { - BT_ERR("%s: Failed to download file: %s (%d)", hdev->name, - config->fwname, ret); + segment = fw->data; + remain = fw->size; + while (remain > 0) { + int segsize = min(MAX_SIZE_PER_TLV_SEGMENT, remain); + + bt_dev_dbg(hdev, "Send segment %d, size %d", i++, segsize); + + remain -= segsize; + /* The last segment is always acked regardless download mode */ + if (!remain || segsize < MAX_SIZE_PER_TLV_SEGMENT) + config->dnld_mode = ROME_SKIP_EVT_NONE; + + ret = rome_tlv_send_segment(hdev, segsize, segment, + config->dnld_mode); + if (ret) + break; + + segment += segsize; } release_firmware(fw); diff --git a/drivers/bluetooth/btqca.h b/drivers/bluetooth/btqca.h index 65e994b..13d77fd 100644 --- a/drivers/bluetooth/btqca.h +++ b/drivers/bluetooth/btqca.h @@ -61,6 +61,13 @@ enum qca_bardrate { QCA_BAUDRATE_RESERVED }; +enum rome_tlv_dnld_mode { + ROME_SKIP_EVT_NONE, + ROME_SKIP_EVT_VSE, + ROME_SKIP_EVT_CC, + ROME_SKIP_EVT_VSE_CC +}; + enum rome_tlv_type { TLV_TYPE_PATCH = 1, TLV_TYPE_NVM @@ -70,6 +77,7 @@ struct rome_config { u8 type; char fwname[64]; uint8_t user_baud_rate; + enum rome_tlv_dnld_mode dnld_mode; }; struct edl_event_hdr { @@ -94,7 +102,8 @@ struct tlv_type_patch { __le32 data_length; __u8 format_version; __u8 signature; - __le16 reserved1; + __u8 download_mode; + __u8 reserved1; __le16 product_id; __le16 rom_build; __le16 patch_version;