Skip to contentSkip to conversation

Bluetooth: Fix inconsistent LE packet sending behaviors

PATCH In review Yuxin Wang 2 participants 2 messages Mar 5, 2024

Subsystems (2)
lore
Share & tools
lore

Yuxin Wang

author
#0 lore raw

PATCH 1/1 Bluetooth: Fix inconsistent LE packet sending behaviors

In the hci_sched_le function, the calculation of quote within hci_chan_sent may become incorrect after breaking from the inner while loop. The issue stems from hci_chan_sent using hdev->le_cnt instead of the updated cnt. As a result, quote may exceed cnt, leading to a negative cnt and causing further inconsistent behaviors.

This patch modifies cnt to be a pointer, aligning with the pattern used in the nearby hci_sched_iso function.

---
 net/bluetooth/hci_core.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
net/bluetooth/hci_core.c +7 -12
index 2821a42ce..785a6dde9 100644
@@ -3750,19 +3750,19 @@ static void hci_sched_le(struct hci_dev *hdev)
 {
 	struct hci_chan *chan;
 	struct sk_buff *skb;
-	int quote, cnt, tmp;
+	int quote, *cnt, tmp;
 
 	BT_DBG("%s", hdev->name);
 
 	if (!hci_conn_num(hdev, LE_LINK))
 		return;
 
-	cnt = hdev->le_pkts ? hdev->le_cnt : hdev->acl_cnt;
+	cnt = hdev->le_pkts ? &hdev->le_cnt : &hdev->acl_cnt;
 
-	__check_timeout(hdev, cnt, LE_LINK);
+	__check_timeout(hdev, *cnt, LE_LINK);
 
-	tmp = cnt;
-	while (cnt && (chan = hci_chan_sent(hdev, LE_LINK, &quote))) {
+	tmp = *cnt;
+	while (*cnt && (chan = hci_chan_sent(hdev, LE_LINK, &quote))) {
 		u32 priority = (skb_peek(&chan->data_q))->priority;
 		while (quote-- && (skb = skb_peek(&chan->data_q))) {
 			BT_DBG("chan %p skb %p len %d priority %u", chan, skb,
@@ -3777,7 +3777,7 @@ static void hci_sched_le(struct hci_dev *hdev)
 			hci_send_frame(hdev, skb);
 			hdev->le_last_tx = jiffies;
 
-			cnt--;
+			(*cnt)--;
 			chan->sent++;
 			chan->conn->sent++;
 
@@ -3787,12 +3787,7 @@ static void hci_sched_le(struct hci_dev *hdev)
 		}
 	}
 
-	if (hdev->le_pkts)
-		hdev->le_cnt = cnt;
-	else
-		hdev->acl_cnt = cnt;
-
-	if (cnt != tmp)
+	if (*cnt != tmp)
 		hci_prio_recalculate(hdev, LE_LINK);
 }
 
Signature · 1 line
2.39.2
#1 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=832651

---Test result---

Test Summary:

CheckPatch                    PASS      0.66 seconds
GitLint                       PASS      0.39 seconds
SubjectPrefix                 PASS      0.12 seconds
BuildKernel                   PASS      28.46 seconds
CheckAllWarning               PASS      32.23 seconds
CheckSparse                   PASS      37.71 seconds
CheckSmatch                   PASS      101.28 seconds
BuildKernel32                 PASS      28.33 seconds
TestRunnerSetup               PASS      509.11 seconds
TestRunner_l2cap-tester       PASS      18.12 seconds
TestRunner_iso-tester         FAIL      32.80 seconds
TestRunner_bnep-tester        PASS      4.85 seconds
TestRunner_mgmt-tester        PASS      111.60 seconds
TestRunner_rfcomm-tester      PASS      7.40 seconds
TestRunner_sco-tester         PASS      14.96 seconds
TestRunner_ioctl-tester       PASS      7.87 seconds
TestRunner_mesh-tester        PASS      5.88 seconds
TestRunner_smp-tester         PASS      6.88 seconds
TestRunner_userchan-tester    PASS      4.99 seconds
IncrementalBuild              PASS      26.17 seconds

Details
##############################
Test: TestRunner_iso-tester - FAIL
Desc: Run iso-tester with test-runner
Output:
Total: 117, Passed: 116 (99.1%), Failed: 1, Not Run: 0

Failed Test Cases
ISO Connect Suspend - Success Failed 4.189 seconds

---
Regards,
Linux Bluetooth