Bluetooth: hci_core: Fix not handling link timeouts propertly
[ Upstream commit 116523c8fac05d1d26f748fee7919a4ec5df67ea ]
Change that introduced the use of __check_timeout did not account for
link types properly, it always assumes ACL_LINK is used thus causing
hdev->acl_last_tx to be used even in case of LE_LINK and then again
uses ACL_LINK with hci_link_tx_to.
To fix this __check_timeout now takes the link type as parameter and
then procedure to use the right last_tx based on the link type and pass
it to hci_link_tx_to.
Fixes: 1b1d29e514
("Bluetooth: Make use of __check_timeout on hci_sched_le")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Tested-by: David Beinder <david@beinder.at>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
129f01116b
commit
b384e8fb16
@@ -4482,15 +4482,27 @@ static inline int __get_blocks(struct hci_dev *hdev, struct sk_buff *skb)
|
|||||||
return DIV_ROUND_UP(skb->len - HCI_ACL_HDR_SIZE, hdev->block_len);
|
return DIV_ROUND_UP(skb->len - HCI_ACL_HDR_SIZE, hdev->block_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __check_timeout(struct hci_dev *hdev, unsigned int cnt)
|
static void __check_timeout(struct hci_dev *hdev, unsigned int cnt, u8 type)
|
||||||
{
|
{
|
||||||
if (!hci_dev_test_flag(hdev, HCI_UNCONFIGURED)) {
|
unsigned long last_tx;
|
||||||
/* ACL tx timeout must be longer than maximum
|
|
||||||
* link supervision timeout (40.9 seconds) */
|
if (hci_dev_test_flag(hdev, HCI_UNCONFIGURED))
|
||||||
if (!cnt && time_after(jiffies, hdev->acl_last_tx +
|
return;
|
||||||
HCI_ACL_TX_TIMEOUT))
|
|
||||||
hci_link_tx_to(hdev, ACL_LINK);
|
switch (type) {
|
||||||
|
case LE_LINK:
|
||||||
|
last_tx = hdev->le_last_tx;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
last_tx = hdev->acl_last_tx;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* tx timeout must be longer than maximum link supervision timeout
|
||||||
|
* (40.9 seconds)
|
||||||
|
*/
|
||||||
|
if (!cnt && time_after(jiffies, last_tx + HCI_ACL_TX_TIMEOUT))
|
||||||
|
hci_link_tx_to(hdev, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Schedule SCO */
|
/* Schedule SCO */
|
||||||
@@ -4548,7 +4560,7 @@ static void hci_sched_acl_pkt(struct hci_dev *hdev)
|
|||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
int quote;
|
int quote;
|
||||||
|
|
||||||
__check_timeout(hdev, cnt);
|
__check_timeout(hdev, cnt, ACL_LINK);
|
||||||
|
|
||||||
while (hdev->acl_cnt &&
|
while (hdev->acl_cnt &&
|
||||||
(chan = hci_chan_sent(hdev, ACL_LINK, "e))) {
|
(chan = hci_chan_sent(hdev, ACL_LINK, "e))) {
|
||||||
@@ -4591,8 +4603,6 @@ static void hci_sched_acl_blk(struct hci_dev *hdev)
|
|||||||
int quote;
|
int quote;
|
||||||
u8 type;
|
u8 type;
|
||||||
|
|
||||||
__check_timeout(hdev, cnt);
|
|
||||||
|
|
||||||
BT_DBG("%s", hdev->name);
|
BT_DBG("%s", hdev->name);
|
||||||
|
|
||||||
if (hdev->dev_type == HCI_AMP)
|
if (hdev->dev_type == HCI_AMP)
|
||||||
@@ -4600,6 +4610,8 @@ static void hci_sched_acl_blk(struct hci_dev *hdev)
|
|||||||
else
|
else
|
||||||
type = ACL_LINK;
|
type = ACL_LINK;
|
||||||
|
|
||||||
|
__check_timeout(hdev, cnt, type);
|
||||||
|
|
||||||
while (hdev->block_cnt > 0 &&
|
while (hdev->block_cnt > 0 &&
|
||||||
(chan = hci_chan_sent(hdev, type, "e))) {
|
(chan = hci_chan_sent(hdev, type, "e))) {
|
||||||
u32 priority = (skb_peek(&chan->data_q))->priority;
|
u32 priority = (skb_peek(&chan->data_q))->priority;
|
||||||
@@ -4673,7 +4685,7 @@ static void hci_sched_le(struct hci_dev *hdev)
|
|||||||
|
|
||||||
cnt = hdev->le_pkts ? hdev->le_cnt : hdev->acl_cnt;
|
cnt = hdev->le_pkts ? hdev->le_cnt : hdev->acl_cnt;
|
||||||
|
|
||||||
__check_timeout(hdev, cnt);
|
__check_timeout(hdev, cnt, LE_LINK);
|
||||||
|
|
||||||
tmp = cnt;
|
tmp = cnt;
|
||||||
while (cnt && (chan = hci_chan_sent(hdev, LE_LINK, "e))) {
|
while (cnt && (chan = hci_chan_sent(hdev, LE_LINK, "e))) {
|
||||||
|
Reference in New Issue
Block a user