Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp312738ybe; Wed, 4 Sep 2019 20:49:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqyAcDe1/WJt46J+UkH8mez9nA6xzC/L2+gYMz/5B5lXvluAOtFer6OqQ285IRgMjD4Y13+c X-Received: by 2002:a17:90a:303:: with SMTP id 3mr1558664pje.124.1567655394748; Wed, 04 Sep 2019 20:49:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567655394; cv=none; d=google.com; s=arc-20160816; b=uFVr0oJs4omeRJJPrAUBOghCNxeAoQTJqKC40EWRmjknrWcMmrSYS3rbNrvd8ZXgYk FbFh401o0Z5YGnSzmbAgpInLfdNXpmqafyonGVPTmOP208Ca4M48Ll2W0KdgFCGm3nWE xdEkDcp/CeflxazWYgKMBZeaYyxRfw0zq0v1Q7kpGPhEldvMd9FXDXqIrAr7SfJVaolz N37gVQQ0nhzm9foChJvlPWH5TZhGwImTIcKtpFrcAs2mYrH1V+eeU+STXFuUHc/8n/oS RqGDS4DEePTjnwDZZwAY3sqTo/pLWM7lIu7quOE7RWd3/5smgzgZx+v0ENyuIzwyUEem G84A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:authenticated-by; bh=AXPozCcb9GQvd/dQZjjhFY4pJKWYeta8FSjmNcYJY74=; b=ndoARRHsaRNJApdwfhN53FrqC7mXAVJ7s5LPPvhlUWx3CpfNlppgBTeSKJC+5Ld4F2 oFhr12qr8PIokpHFckr6nvk1S7tJ2iLqy/3ACSKZwjE9I60wKNMb/Z7UgSokjygdcDLA B/4wXaPE8IyTMz76Lumd9r9KHBwSTZqmkWf8zcUmUhZbBxSJQCcRJbfu4pbJxmnT+gg1 OoHgrc8XLXU8rq+WlGE7yKVj+kb2h9D8Kdu+OG9qjZM9d7E8exW0uhKrKHG4p6hgCEn3 Ea7TsmuztrMMQdNa26fEvshnWqe1CFbV+C+vbHBQP1UzuhffU6gmLFFEZw2qSYOpxcrX OOsg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i8si909112pjx.0.2019.09.04.20.49.22; Wed, 04 Sep 2019 20:49:54 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727544AbfIEDtS (ORCPT + 99 others); Wed, 4 Sep 2019 23:49:18 -0400 Received: from rtits2.realtek.com ([211.75.126.72]:59619 "EHLO rtits2.realtek.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728267AbfIEDtS (ORCPT ); Wed, 4 Sep 2019 23:49:18 -0400 Authenticated-By: X-SpamFilter-By: BOX Solutions SpamTrap 5.62 with qID x853n6WM023154, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (RTITCASV01.realtek.com.tw[172.21.6.18]) by rtits2.realtek.com.tw (8.15.2/2.57/5.78) with ESMTPS id x853n6WM023154 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 5 Sep 2019 11:49:06 +0800 Received: from localhost.localdomain (172.21.83.238) by RTITCASV01.realtek.com.tw (172.21.6.18) with Microsoft SMTP Server id 14.3.468.0; Thu, 5 Sep 2019 11:49:05 +0800 From: To: , , , CC: , Subject: [PATCH] Bluetooth: btrtl: Fix an issue that failing to download the FW which size is over 32K bytes Date: Thu, 5 Sep 2019 11:49:00 +0800 Message-ID: <20190905034900.1538-1-max.chou@realtek.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.21.83.238] Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Max Chou Fix the issue that when the FW size is 32K+, it will fail for the download process because of the incorrect index. When firmware patch length is over 32K, "dl_cmd->index" may >= 0x80. It will be thought as "data end" that download process will not complete. However, driver should recount the index from 1. Signed-off-by: Max Chou --- drivers/bluetooth/btrtl.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c index 0354e93e7a7c..bf3c02be6930 100644 --- a/drivers/bluetooth/btrtl.c +++ b/drivers/bluetooth/btrtl.c @@ -401,7 +401,11 @@ static int rtl_download_firmware(struct hci_dev *hdev, BT_DBG("download fw (%d/%d)", i, frag_num); - dl_cmd->index = i; + if (i > 0x7f) + dl_cmd->index = (i & 0x7f) + 1; + else + dl_cmd->index = i; + if (i == (frag_num - 1)) { dl_cmd->index |= 0x80; /* data end */ frag_len = fw_len % RTL_FRAG_LEN; -- 2.17.1