Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4276301yba; Mon, 29 Apr 2019 17:11:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxzqPzUwuXi0sI3pPunoNqym/WYgCy38nLnRcx4KOztx4loXdEZ9ZGjDc+RzyeI+0NvUpUO X-Received: by 2002:a63:e051:: with SMTP id n17mr19854167pgj.19.1556583062275; Mon, 29 Apr 2019 17:11:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556583062; cv=none; d=google.com; s=arc-20160816; b=O7tkKqt/4mLNlAPO7KUI5Ue9nMis30aSoXilHrmezykIOamd9ZE8DqlGS6sZrj20vt XvyOtE8fyUEwTQHs8lLd6H0UsmizaG3TeEw7nS/NyiQKhZntUUDbI03Ap0GoIRYgLPQq +pELCJG+MWgeeYovt0VMIxqm660WX9Bxod0pvx6x7oPEwrfzZszPcnAR+eUWhaWcNsfJ ZsTbDlZkUF0aSoZarHlDDO7Csf8OCB5ZYOwM+BnLlco6THbi/85Lvm5p8QJYBwQKHl/e SQ5hh8mEsw059U+ojZXt5jfcQMo7oFtj6y1OeiV7WZKjja/oh7Ozatefph7QU2bbIISe fYAA== 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=Y8Pf9UXyzPjlpRjHiYMPtrNDJ8/3UQU5riBkZSYp9gs=; b=AZL3Q1lui6vGVmYi2kzLzeZ17Tx1x0I1EWNeGG+qxJBceonw4/atZnAXRzVdnRS887 IqonungjqR7r7VZzxSjAvuB1CDuKtpZypVSKYkg36tGvnG/ESDmtI9ylQjw62E1eqyHl LMyJLerh7bMfCn/9XnSXIPFj8VVwf+AMqIqjGCg+MGXQZnDXOo2YktWhzEpMT5lHLwdu gCDrSAwyQ/sb8Xnk2Uk2ssmRdkUaShskH5iaXtGguyzfIbygcdS9m6876b73t7IXpp7c u1PpC+G6RJlAZHGojPMcDo3S4Ik3SvycueGFig4h2vGHmPQtSki1EDuiY1c6NgfgtX3a Gdhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=k7Kw5N91; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j6si6441327pgi.464.2019.04.29.17.10.31; Mon, 29 Apr 2019 17:11:02 -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=pass header.i=@chromium.org header.s=google header.b=k7Kw5N91; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729083AbfD3AKa (ORCPT + 99 others); Mon, 29 Apr 2019 20:10:30 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:37072 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728844AbfD3AKa (ORCPT ); Mon, 29 Apr 2019 20:10:30 -0400 Received: by mail-pl1-f196.google.com with SMTP id z8so5869733pln.4 for ; Mon, 29 Apr 2019 17:10:29 -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=Y8Pf9UXyzPjlpRjHiYMPtrNDJ8/3UQU5riBkZSYp9gs=; b=k7Kw5N91Pxko0ghZG+tFO44IQLSLmLpxnt3s2C4Ka8pDBJI7mim2Lk2dlUKF8ZLNot RfLDsDUUUc+VFe0qPlwHOA5zqLJvvxwtOGg/7Hb0GR8p7ebNzp7Us5YVQoeiIhu9Ltwr Ao2kyZGey9qZR1awyZuwdaSkWY17AaOxzyawc= 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=Y8Pf9UXyzPjlpRjHiYMPtrNDJ8/3UQU5riBkZSYp9gs=; b=DbmfnrO+ReDR51yhcU98xIaotlDXOqOBqhWN1sR3pIYWD46EOluyxf+RcB5laiTbVu OmZ1yrSIsYU2pxKdfbXCnY6fx5PBvIzQAI6jVZKPk1GTqe267dFP0qeXwL2z38+w0RMS lG4amIwPx4HUYNY49ng/h5kvAbVlXFAzIbtWgT9CYj8qKoHbBfgv6RrTYDArEEjeYQVh qW8cyHUAM7MOGH5d0JnH4p2GGT9y4dv8RIfZ2Su09tQmY329mctLLYtuQwRlxye6qBRj MU46jSc41/i2Ecpi+niO/rk29MSZmVOTEPXux2kKxigvizJr+024JkAQ/b2C3xd94ueV tUPA== X-Gm-Message-State: APjAAAWfR+ui0FXdF+/FPFFvmvVw88TD2IaC7CVuajl3EH7t+cYskcDn CEDRNA5T6WmeEeddL/e+0vj/Eg== X-Received: by 2002:a17:902:7b8e:: with SMTP id w14mr48845254pll.202.1556583029384; Mon, 29 Apr 2019 17:10:29 -0700 (PDT) Received: from localhost ([2620:15c:202:1:75a:3f6e:21d:9374]) by smtp.gmail.com with ESMTPSA id n65sm59063555pga.92.2019.04.29.17.10.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Apr 2019 17:10:28 -0700 (PDT) From: Matthias Kaehlcke To: Marcel Holtmann , Johan Hedberg Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, Balakrishna Godavarthi , Harish Bandi , Rocky Liao , Matthias Kaehlcke Subject: [PATCH v8] Bluetooth: btqca: inject command complete event during fw download Date: Mon, 29 Apr 2019 17:10:24 -0700 Message-Id: <20190430001024.209688-1-mka@chromium.org> X-Mailer: git-send-email 2.21.0.593.g511ec345e18-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Balakrishna Godavarthi From: Balakrishna Godavarthi Latest qualcomm chips are not sending an command complete event for every firmware packet sent to chip. They only respond with a vendor specific event for the last firmware packet. This optimization will decrease the BT ON time. Due to this we are seeing a timeout error message logs on the console during firmware download. Now we are injecting a command complete event once we receive an vendor specific event for the last RAM firmware packet. Signed-off-by: Balakrishna Godavarthi Tested-by: Matthias Kaehlcke Reviewed-by: Matthias Kaehlcke Signed-off-by: Matthias Kaehlcke --- Changes in v8: - renamed QCA_HCI_CC_SUCCESS to QCA_HCI_CC_OPCODE - use 0xFC00 as opcode of the injected event instead of 0 - added Matthias' tags from the v7 review --- drivers/bluetooth/btqca.c | 39 ++++++++++++++++++++++++++++++++++++++- drivers/bluetooth/btqca.h | 3 +++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/btqca.c b/drivers/bluetooth/btqca.c index cc12eecd9e4d..ef765ea881b8 100644 --- a/drivers/bluetooth/btqca.c +++ b/drivers/bluetooth/btqca.c @@ -144,6 +144,7 @@ static void qca_tlv_check_data(struct rome_config *config, * In case VSE is skipped, only the last segment is acked. */ config->dnld_mode = tlv_patch->download_mode; + config->dnld_type = config->dnld_mode; BT_DBG("Total Length : %d bytes", le32_to_cpu(tlv_patch->total_size)); @@ -264,6 +265,31 @@ static int qca_tlv_send_segment(struct hci_dev *hdev, int seg_size, return err; } +static int qca_inject_cmd_complete_event(struct hci_dev *hdev) +{ + struct hci_event_hdr *hdr; + struct hci_ev_cmd_complete *evt; + struct sk_buff *skb; + + skb = bt_skb_alloc(sizeof(*hdr) + sizeof(*evt) + 1, GFP_KERNEL); + if (!skb) + return -ENOMEM; + + hdr = skb_put(skb, sizeof(*hdr)); + hdr->evt = HCI_EV_CMD_COMPLETE; + hdr->plen = sizeof(*evt) + 1; + + evt = skb_put(skb, sizeof(*evt)); + evt->ncmd = 1; + evt->opcode = HCI_OP_NOP; + + skb_put_u8(skb, QCA_HCI_CC_SUCCESS); + + hci_skb_pkt_type(skb) = HCI_EVENT_PKT; + + return hci_recv_frame(hdev, skb); +} + static int qca_download_firmware(struct hci_dev *hdev, struct rome_config *config) { @@ -297,11 +323,22 @@ static int qca_download_firmware(struct hci_dev *hdev, ret = qca_tlv_send_segment(hdev, segsize, segment, config->dnld_mode); if (ret) - break; + goto out; segment += segsize; } + /* Latest qualcomm chipsets are not sending a command complete event + * for every fw packet sent. They only respond with a vendor specific + * event for the last packet. This optimization in the chip will + * decrease the BT in initialization time. Here we will inject a command + * complete event to avoid a command timeout error message. + */ + if ((config->dnld_type == ROME_SKIP_EVT_VSE_CC || + config->dnld_type == ROME_SKIP_EVT_VSE)) + return qca_inject_cmd_complete_event(hdev); + +out: release_firmware(fw); return ret; diff --git a/drivers/bluetooth/btqca.h b/drivers/bluetooth/btqca.h index 4c4fe2b5b7b7..595abcdaed2d 100644 --- a/drivers/bluetooth/btqca.h +++ b/drivers/bluetooth/btqca.h @@ -41,6 +41,8 @@ #define QCA_WCN3990_POWERON_PULSE 0xFC #define QCA_WCN3990_POWEROFF_PULSE 0xC0 +#define QCA_HCI_CC_OPCODE 0xFC00 + enum qca_baudrate { QCA_BAUDRATE_115200 = 0, QCA_BAUDRATE_57600, @@ -82,6 +84,7 @@ struct rome_config { char fwname[64]; uint8_t user_baud_rate; enum rome_tlv_dnld_mode dnld_mode; + enum rome_tlv_dnld_mode dnld_type; }; struct edl_event_hdr { -- 2.21.0.593.g511ec345e18-goog