Linux-Bluetooth Archive on lore.kernel.org
 help / color / Atom feed
* 回收: [PATCH] Bluetooth: btrtl: Fix an issue that failing to download the FW which size is over 32K bytes
@ 2019-09-05  5:26 Max Chou
  0 siblings, 0 replies; 4+ messages in thread
From: Max Chou @ 2019-09-05  5:26 UTC (permalink / raw)
  To: marcel, johan.hedberg, linux-bluetooth, linux-kernel; +Cc: alex_lu, Max Chou

Max Chou §Æ±æ¦^¦¬³o«Ê¶l¥ó [[PATCH] Bluetooth: btrtl: Fix an issue that failing to download the FW which size is over 32K bytes]¡C

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] Bluetooth: btrtl: Fix an issue that failing to download the FW which size is over 32K bytes
@ 2019-09-05  3:49 max.chou
  0 siblings, 0 replies; 4+ messages in thread
From: max.chou @ 2019-09-05  3:49 UTC (permalink / raw)
  To: marcel, johan.hedberg, linux-bluetooth, linux-kernel; +Cc: alex_lu, max.chou

From: Max Chou <max.chou@realtek.com>

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 <max.chou@realtek.com>
---
 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Bluetooth: btrtl: Fix an issue that failing to download the FW which size is over 32K bytes
  2019-09-02  9:08 max.chou
@ 2019-09-04 14:01 ` Marcel Holtmann
  0 siblings, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2019-09-04 14:01 UTC (permalink / raw)
  To: Max Chou; +Cc: Johan Hedberg, linux-bluetooth, linux-kernel, alex_lu

Hi Max,

> Fix the issue that when the FW size is 32K+, it will fail for the download
> process because of the incorrect index.
> 
> Signed-off-by: Max Chou <max.chou@realtek.com>
> ---
> drivers/bluetooth/btrtl.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c
> index 0354e93e7a7c..215896af0259 100644
> --- a/drivers/bluetooth/btrtl.c
> +++ b/drivers/bluetooth/btrtl.c
> @@ -389,6 +389,7 @@ static int rtl_download_firmware(struct hci_dev *hdev,
> 	int frag_len = RTL_FRAG_LEN;
> 	int ret = 0;
> 	int i;
> +	int j;
> 	struct sk_buff *skb;
> 	struct hci_rp_read_local_version *rp;
> 
> @@ -401,7 +402,12 @@ 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)
> +			j = (i & 0x7f) + 1;
> +		else
> +			j = i;
> +
> +		dl_cmd->index = j;

so this seems rather complicated with the extra variable.

		if (i > 0x7f)
			dl_cmd->index = (i & 0x7f) + 1;
		else
			dl_cmd->index = i;

And I would prefer to have a small comment above on why this is done this way.

Regards

Marcel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] Bluetooth: btrtl: Fix an issue that failing to download the FW which size is over 32K bytes
@ 2019-09-02  9:08 max.chou
  2019-09-04 14:01 ` Marcel Holtmann
  0 siblings, 1 reply; 4+ messages in thread
From: max.chou @ 2019-09-02  9:08 UTC (permalink / raw)
  To: marcel, johan.hedberg, linux-bluetooth, linux-kernel; +Cc: alex_lu, max.chou

From: Max Chou <max.chou@realtek.com>

Fix the issue that when the FW size is 32K+, it will fail for the download
process because of the incorrect index.

Signed-off-by: Max Chou <max.chou@realtek.com>
---
 drivers/bluetooth/btrtl.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c
index 0354e93e7a7c..215896af0259 100644
--- a/drivers/bluetooth/btrtl.c
+++ b/drivers/bluetooth/btrtl.c
@@ -389,6 +389,7 @@ static int rtl_download_firmware(struct hci_dev *hdev,
 	int frag_len = RTL_FRAG_LEN;
 	int ret = 0;
 	int i;
+	int j;
 	struct sk_buff *skb;
 	struct hci_rp_read_local_version *rp;
 
@@ -401,7 +402,12 @@ 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)
+			j = (i & 0x7f) + 1;
+		else
+			j = i;
+
+		dl_cmd->index = j;
 		if (i == (frag_num - 1)) {
 			dl_cmd->index |= 0x80; /* data end */
 			frag_len = fw_len % RTL_FRAG_LEN;
-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-05  5:26 回收: [PATCH] Bluetooth: btrtl: Fix an issue that failing to download the FW which size is over 32K bytes Max Chou
  -- strict thread matches above, loose matches on Subject: below --
2019-09-05  3:49 max.chou
2019-09-02  9:08 max.chou
2019-09-04 14:01 ` Marcel Holtmann

Linux-Bluetooth Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-bluetooth/0 linux-bluetooth/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-bluetooth linux-bluetooth/ https://lore.kernel.org/linux-bluetooth \
		linux-bluetooth@vger.kernel.org linux-bluetooth@archiver.kernel.org
	public-inbox-index linux-bluetooth


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-bluetooth


AGPL code for this site: git clone https://public-inbox.org/ public-inbox