diff mbox series

[E/OEM-OSP1-B,1/1] Bluetooth: btrtl: Fix an issue that failing to download the FW which size is over 32K bytes

Message ID 20191212071050.10903-2-kai.heng.feng@canonical.com
State New
Headers show
Series Fix Realtek Bluetooth firmware download | expand

Commit Message

Kai-Heng Feng Dec. 12, 2019, 7:10 a.m. UTC
From: Max Chou <max.chou@realtek.com>

BugLink: https://bugs.launchpad.net/bugs/1856079

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>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
(cherry picked from commit cf0d9a705d81a0f581865cefe0880f29589dd06f)
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
 drivers/bluetooth/btrtl.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Kleber Sacilotto de Souza Jan. 6, 2020, 3:42 p.m. UTC | #1
On 2019-12-12 08:10, Kai-Heng Feng wrote:
> From: Max Chou <max.chou@realtek.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1856079
> 
> 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>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> (cherry picked from commit cf0d9a705d81a0f581865cefe0880f29589dd06f)
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>

Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.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 16a03882b687..d927af5ea9ab 100644
> --- a/drivers/bluetooth/btrtl.c
> +++ b/drivers/bluetooth/btrtl.c
> @@ -380,7 +380,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;
>
Stefan Bader Jan. 7, 2020, 1:01 p.m. UTC | #2
On 12.12.19 08:10, Kai-Heng Feng wrote:
> From: Max Chou <max.chou@realtek.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1856079
> 
> 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>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> (cherry picked from commit cf0d9a705d81a0f581865cefe0880f29589dd06f)
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.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 16a03882b687..d927af5ea9ab 100644
> --- a/drivers/bluetooth/btrtl.c
> +++ b/drivers/bluetooth/btrtl.c
> @@ -380,7 +380,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;
>
diff mbox series

Patch

diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c
index 16a03882b687..d927af5ea9ab 100644
--- a/drivers/bluetooth/btrtl.c
+++ b/drivers/bluetooth/btrtl.c
@@ -380,7 +380,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;