linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: btrsi: fix bt tx timeout issue
@ 2018-08-29  8:58 Siva Rebbagondla
  2018-08-31 13:20 ` Siva Rebbagondla
  0 siblings, 1 reply; 2+ messages in thread
From: Siva Rebbagondla @ 2018-08-29  8:58 UTC (permalink / raw)
  To: Marcel Holtmann, Johan Hedberg
  Cc: linux-bluetooth, linux-wireless, Sasidhar Mudigonda,
	Siva Rebbagondla, Sanjay Kumar Konduri

From: Sanjay Kumar Konduri <sanjay.konduri@redpinesignals.com>

observed sometimes data is coming with unaligned address from kernel
BT stack. If unaligned address is passed, some data in payload is
stripped when packet is loading to firmware and this results, BT
connection timeout is happening.

sh# hciconfig hci0 up
Can't init device hci0: hci0 command 0x0c03 tx timeout

Fixed this by moving the data to aligned address.

Signed-off-by: Sanjay Kumar Konduri <sanjay.konduri@redpinesignals.com>
Signed-off-by: Siva Rebbagondla <siva.rebbagondla@redpinesignals.com>
---
 drivers/bluetooth/btrsi.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/bluetooth/btrsi.c b/drivers/bluetooth/btrsi.c
index 60d1419..3951f7b 100644
--- a/drivers/bluetooth/btrsi.c
+++ b/drivers/bluetooth/btrsi.c
@@ -21,8 +21,9 @@
 #include <net/rsi_91x.h>
 #include <net/genetlink.h>
 
-#define RSI_HEADROOM_FOR_BT_HAL	16
+#define RSI_DMA_ALIGN	8
 #define RSI_FRAME_DESC_SIZE	16
+#define RSI_HEADROOM_FOR_BT_HAL	(RSI_FRAME_DESC_SIZE + RSI_DMA_ALIGN)
 
 struct rsi_hci_adapter {
 	void *priv;
@@ -70,6 +71,16 @@ static int rsi_hci_send_pkt(struct hci_dev *hdev, struct sk_buff *skb)
 		bt_cb(new_skb)->pkt_type = hci_skb_pkt_type(skb);
 		kfree_skb(skb);
 		skb = new_skb;
+		if (!IS_ALIGNED((unsigned long)skb->data, RSI_DMA_ALIGN)) {
+			u8 *skb_data = skb->data;
+			int skb_len = skb->len;
+
+			skb_push(skb, RSI_DMA_ALIGN);
+			skb_pull(skb, PTR_ALIGN(skb->data,
+						RSI_DMA_ALIGN) - skb->data);
+			memmove(skb->data, skb_data, skb_len);
+			skb_trim(skb, skb_len);
+		}
 	}
 
 	return h_adapter->proto_ops->coex_send_pkt(h_adapter->priv, skb,
-- 
2.7.4

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

* Re: [PATCH] Bluetooth: btrsi: fix bt tx timeout issue
  2018-08-29  8:58 [PATCH] Bluetooth: btrsi: fix bt tx timeout issue Siva Rebbagondla
@ 2018-08-31 13:20 ` Siva Rebbagondla
  0 siblings, 0 replies; 2+ messages in thread
From: Siva Rebbagondla @ 2018-08-31 13:20 UTC (permalink / raw)
  To: Marcel Holtmann, Johan Hedberg
  Cc: linux-bluetooth, Linux Wireless, Sasidhar Mudigonda,
	Siva Rebbagondla, Sanjay Kumar Konduri

On Wed, Aug 29, 2018 at 2:24 PM Siva Rebbagondla <siva8118@gmail.com> wrote:
>
> From: Sanjay Kumar Konduri <sanjay.konduri@redpinesignals.com>
>
> observed sometimes data is coming with unaligned address from kernel
> BT stack. If unaligned address is passed, some data in payload is
> stripped when packet is loading to firmware and this results, BT
> connection timeout is happening.
>
> sh# hciconfig hci0 up
> Can't init device hci0: hci0 command 0x0c03 tx timeout
>
> Fixed this by moving the data to aligned address.
>
> Signed-off-by: Sanjay Kumar Konduri <sanjay.konduri@redpinesignals.com>
> Signed-off-by: Siva Rebbagondla <siva.rebbagondla@redpinesignals.com>
> ---
>  drivers/bluetooth/btrsi.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/bluetooth/btrsi.c b/drivers/bluetooth/btrsi.c
> index 60d1419..3951f7b 100644
> --- a/drivers/bluetooth/btrsi.c
> +++ b/drivers/bluetooth/btrsi.c
> @@ -21,8 +21,9 @@
>  #include <net/rsi_91x.h>
>  #include <net/genetlink.h>
>
> -#define RSI_HEADROOM_FOR_BT_HAL        16
> +#define RSI_DMA_ALIGN  8
>  #define RSI_FRAME_DESC_SIZE    16
> +#define RSI_HEADROOM_FOR_BT_HAL        (RSI_FRAME_DESC_SIZE + RSI_DMA_ALIGN)
>
>  struct rsi_hci_adapter {
>         void *priv;
> @@ -70,6 +71,16 @@ static int rsi_hci_send_pkt(struct hci_dev *hdev, struct sk_buff *skb)
>                 bt_cb(new_skb)->pkt_type = hci_skb_pkt_type(skb);
>                 kfree_skb(skb);
>                 skb = new_skb;
> +               if (!IS_ALIGNED((unsigned long)skb->data, RSI_DMA_ALIGN)) {
> +                       u8 *skb_data = skb->data;
> +                       int skb_len = skb->len;
> +
> +                       skb_push(skb, RSI_DMA_ALIGN);
> +                       skb_pull(skb, PTR_ALIGN(skb->data,
> +                                               RSI_DMA_ALIGN) - skb->data);
> +                       memmove(skb->data, skb_data, skb_len);
> +                       skb_trim(skb, skb_len);
> +               }
>         }
>
>         return h_adapter->proto_ops->coex_send_pkt(h_adapter->priv, skb,
> --
> 2.7.4
>
Kindly ignore this.
Instead of adding linux-kernel@vger.kernel.org, I have added
linux-wireless@vger.kernel.org, which results, this
patch is showing in linux-wireless patch work.
I will resend this patch by removing, "linux-wireless" from mailing list.

Thanks,
Siva Rebbagondla.

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

end of thread, other threads:[~2018-08-31 17:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-29  8:58 [PATCH] Bluetooth: btrsi: fix bt tx timeout issue Siva Rebbagondla
2018-08-31 13:20 ` Siva Rebbagondla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).