@@ -3552,51 +3552,45 @@ static void __check_timeout(struct hci_dev *hdev, unsigned int cnt, u8 type)
35523552}
35533553
35543554/* Schedule SCO */
3555- static void hci_sched_sco (struct hci_dev * hdev )
3555+ static void hci_sched_sco (struct hci_dev * hdev , __u8 type )
35563556{
35573557 struct hci_conn * conn ;
35583558 struct sk_buff * skb ;
3559- int quote ;
3559+ int quote , * cnt ;
3560+ unsigned int pkts = hdev -> sco_pkts ;
35603561
3561- BT_DBG ( "%s " , hdev -> name );
3562+ bt_dev_dbg ( hdev , "type %u " , type );
35623563
3563- if (!hci_conn_num (hdev , SCO_LINK ) )
3564+ if (!hci_conn_num (hdev , type ) || ! pkts )
35643565 return ;
35653566
3566- while (hdev -> sco_cnt && (conn = hci_low_sent (hdev , SCO_LINK , & quote ))) {
3567- while (quote -- && (skb = skb_dequeue (& conn -> data_q ))) {
3568- BT_DBG ("skb %p len %d" , skb , skb -> len );
3569- hci_send_frame (hdev , skb );
3570-
3571- conn -> sent ++ ;
3572- if (conn -> sent == ~0 )
3573- conn -> sent = 0 ;
3574- }
3575- }
3576- }
3577-
3578- static void hci_sched_esco (struct hci_dev * hdev )
3579- {
3580- struct hci_conn * conn ;
3581- struct sk_buff * skb ;
3582- int quote ;
3583-
3584- BT_DBG ("%s" , hdev -> name );
3585-
3586- if (!hci_conn_num (hdev , ESCO_LINK ))
3587- return ;
3567+ /* Use sco_pkts if flow control has not been enabled which will limit
3568+ * the amount of buffer sent in a row.
3569+ */
3570+ if (!hci_dev_test_flag (hdev , HCI_SCO_FLOWCTL ))
3571+ cnt = & pkts ;
3572+ else
3573+ cnt = & hdev -> sco_cnt ;
35883574
3589- while (hdev -> sco_cnt && (conn = hci_low_sent (hdev , ESCO_LINK ,
3590- & quote ))) {
3575+ while (* cnt && (conn = hci_low_sent (hdev , type , & quote ))) {
35913576 while (quote -- && (skb = skb_dequeue (& conn -> data_q ))) {
35923577 BT_DBG ("skb %p len %d" , skb , skb -> len );
35933578 hci_send_frame (hdev , skb );
35943579
35953580 conn -> sent ++ ;
35963581 if (conn -> sent == ~0 )
35973582 conn -> sent = 0 ;
3583+ (* cnt )-- ;
35983584 }
35993585 }
3586+
3587+ /* Rescheduled if all packets were sent and flow control is not enabled
3588+ * as there could be more packets queued that could not be sent and
3589+ * since no HCI_EV_NUM_COMP_PKTS event will be generated the reschedule
3590+ * needs to be forced.
3591+ */
3592+ if (!pkts && !hci_dev_test_flag (hdev , HCI_SCO_FLOWCTL ))
3593+ queue_work (hdev -> workqueue , & hdev -> tx_work );
36003594}
36013595
36023596static void hci_sched_acl_pkt (struct hci_dev * hdev )
@@ -3632,8 +3626,8 @@ static void hci_sched_acl_pkt(struct hci_dev *hdev)
36323626 chan -> conn -> sent ++ ;
36333627
36343628 /* Send pending SCO packets right away */
3635- hci_sched_sco (hdev );
3636- hci_sched_esco (hdev );
3629+ hci_sched_sco (hdev , SCO_LINK );
3630+ hci_sched_sco (hdev , ESCO_LINK );
36373631 }
36383632 }
36393633
@@ -3688,8 +3682,8 @@ static void hci_sched_le(struct hci_dev *hdev)
36883682 chan -> conn -> sent ++ ;
36893683
36903684 /* Send pending SCO packets right away */
3691- hci_sched_sco (hdev );
3692- hci_sched_esco (hdev );
3685+ hci_sched_sco (hdev , SCO_LINK );
3686+ hci_sched_sco (hdev , ESCO_LINK );
36933687 }
36943688 }
36953689
@@ -3734,8 +3728,8 @@ static void hci_tx_work(struct work_struct *work)
37343728
37353729 if (!hci_dev_test_flag (hdev , HCI_USER_CHANNEL )) {
37363730 /* Schedule queues and send stuff to HCI driver */
3737- hci_sched_sco (hdev );
3738- hci_sched_esco (hdev );
3731+ hci_sched_sco (hdev , SCO_LINK );
3732+ hci_sched_sco (hdev , ESCO_LINK );
37393733 hci_sched_iso (hdev );
37403734 hci_sched_acl (hdev );
37413735 hci_sched_le (hdev );
0 commit comments