Does anybody know conn->power_save variable in hci_conn.c?
Dear bluez developer!
/*bluetooth kernel hci_conn.c */
382 void hci_conn_enter_active_mode(struct hci_conn *conn) 383 {
384 struct hci_dev *hdev = conn->hdev;
385
386 BT_DBG("conn %p mode %d", conn, conn->mode);
387
388 if (test_bit(HCI_RAW, &hdev->flags))
389 return;
390
391 if (conn->mode != HCI_CM_SNIFF || !conn->power_save)
392 goto timer;
393
394 if (!test_and_set_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->pend)) {
395 struct hci_cp_exit_sniff_mode cp; 396 cp.handle = __cpu_to_le16(conn->handle); 397 hci_send_cmd(hdev, OGF_LINK_POLICY,
398 OCF_EXIT_SNIFF_MODE, sizeof(cp), &cp);
399 }
400
401 timer:
402 if (hdev->idle_timeout > 0)
403 mod_timer(&conn->idle_timer,
404 jiffies + msecs_to_jiffies(hdev->idle_timeout));
405 }
406
If possible, could you explain why this code checks !conn->power_save var.?
Without this , if conn->mode==HCI_CM_SNIFF , we simply exit sniff mode,"OCF_EXIT_SNIFF_MODE".
As far as I understood, whenever conn->mode is HCI_CM_SNIFF conn->power_save is 0.
The reason is that hci_mode_change_evt() set conn->power_save as "0" when conn->mode !=HCI_CM_ACTIVE.
Consequently we don't need to check that variable.
Regards
Chanyeol.
Marcel Holtmann
maintainerHi Chan-Yeol,
Quoted 32 lines
/*bluetooth kernel
hci_conn.c*/
382 voidhci_conn_enter_active_mode(struct hci_conn *conn)383 {
384 structhci_dev*hdev =conn->hdev;
385
386BT_DBG("conn %p mode %d", conn, conn->mode);
387
388 if (test_bit(HCI_RAW, &hdev->flags))
389 return;
390
391 if (conn->mode!=HCI_CM_SNIFF|| !conn->power_save)
392 goto timer;
393
394 if (!test_and_set_bit(HCI_CONN_MODE_CHANGE_PEND,&conn->pend)) {395 struct hci_cp_exit_sniff_mode cp; 396 cp.handle = __cpu_to_le16(conn->handle); 397 hci_send_cmd(hdev, OGF_LINK_POLICY,398
OCF_EXIT_SNIFF_MODE, sizeof(cp), &cp);
399 }
400
401 timer:
402 if (hdev->idle_timeout> 0)
403 mod_timer(&conn->idle_timer,
404 jiffies +msecs_to_jiffies(hdev->idle_timeout));
405 }
406If possible, could you explain why this code checks !conn->power_save var.?
Without this , if conn->mode==HCI_CM_SNIFF , we simply exit sniff mode,"OCF_EXIT_SNIFF_MODE".
Quoted 6 lines
As far as I understood, whenever
conn->modeisHCI_CM_SNIFFconn->power_saveis 0.
The reason is thathci_mode_change_evt()setconn->power_saveas "0" whenconn->mode!=HCI_CM_ACTIVE.Consequently we don't need to check that variable.
we do need that variable, because otherwise devices like HID which do active sniff mode management fall over if we always try to exit sniff mode only for a few bytes.
Regards
Marcel
Hi Marcel,
Quoted 6 lines
Quoted 6 lines
/*bluetooth kernel
hci_conn.c*/
382 voidhci_conn_enter_active_mode(struct hci_conn *conn)383 {
384 structhci_dev*hdev =conn->hdev;
385
386BT_DBG("conn %p mode %d", conn, conn->mode);
Quoted 8 lines
Quoted 8 lines
387
388 if (test_bit(HCI_RAW, &hdev->flags))
389 return;
390
391 if (conn->mode!=HCI_CM_SNIFF|| !conn->power_save)
392 goto timer;
393
394 if (!test_and_set_bit(HCI_CONN_MODE_CHANGE_PEND,
&conn->pend)) {
Quoted 4 lines
Quoted 4 lines
395 struct hci_cp_exit_sniff_mode cp; 396 cp.handle = __cpu_to_le16(conn->handle); 397 hci_send_cmd(hdev, OGF_LINK_POLICY,398
OCF_EXIT_SNIFF_MODE, sizeof(cp),
&cp);
Quoted 6 lines
Quoted 6 lines
399 }
400
401 timer:
402 if (hdev->idle_timeout> 0)
403 mod_timer(&conn->idle_timer,
404 jiffies +
msecs_to_jiffies(hdev->idle_timeout));
Quoted 4 lines
Quoted 4 lines
405 }
406If possible, could you explain why this code checks !conn->power_save
var.?
Quoted 5 lines
Quoted 5 lines
Without this , if conn->mode==HCI_CM_SNIFF , we simply exit sniff mode,"OCF_EXIT_SNIFF_MODE".
As far as I understood, whenever
conn->modeisHCI_CM_SNIFF
conn->power_save
Quoted 2 lines
Quoted 2 lines
is 0.
The reason is thathci_mode_change_evt()setconn->power_saveas "0"
when
Quoted 7 lines
Quoted 3 lines
conn->mode!=HCI_CM_ACTIVE.Consequently we don't need to check that variable.
we do need that variable, because otherwise devices like HID which do active sniff mode management fall over if we always try to exit sniff mode only for a few bytes.
In case of HID, active sniff mode could be no problem because its data rate is light compared to other profile.
But other case such as Sony Ericsson HBH-DS970,980 A2DP profile , it could be problem.
As you may already know,
they request sniff mode while HFP so their connection is too late... It made AVDTP signal so slow..
Without conn->power_save variable check procedure, I found Sony Headset works well! because they exit sniff mode
Consequently, I think conn->power_save variable procedure should be removed except only HID case.
If you think this is totally Sony headset problem, could you explain that?
Please comment my idea.
Regards
Chanyeol
Marcel Holtmann
maintainerHi Chan-Yeol,
Quoted 58 lines
Quoted 6 lines
Quoted 6 lines
/*bluetooth kernel
hci_conn.c*/
382 voidhci_conn_enter_active_mode(struct hci_conn *conn)383 {
384 structhci_dev*hdev =conn->hdev;
385
386BT_DBG("conn %p mode %d", conn, conn->mode);Quoted 8 lines
Quoted 8 lines
387
388 if (test_bit(HCI_RAW, &hdev->flags))
389 return;
390
391 if (conn->mode!=HCI_CM_SNIFF|| !conn->power_save)
392 goto timer;
393
394 if (!test_and_set_bit(HCI_CONN_MODE_CHANGE_PEND,
&conn->pend)) {Quoted 4 lines
Quoted 4 lines
395 struct hci_cp_exit_sniff_mode cp; 396 cp.handle = __cpu_to_le16(conn->handle); 397 hci_send_cmd(hdev, OGF_LINK_POLICY,398
OCF_EXIT_SNIFF_MODE, sizeof(cp),&cp);
Quoted 6 lines
Quoted 6 lines
399 }
400
401 timer:
402 if (hdev->idle_timeout> 0)
403 mod_timer(&conn->idle_timer,
404 jiffies +
msecs_to_jiffies(hdev->idle_timeout));Quoted 4 lines
Quoted 4 lines
405 }
406If possible, could you explain why this code checks !conn->power_save
var.?
Quoted 5 lines
Quoted 5 lines
Without this , if conn->mode==HCI_CM_SNIFF , we simply exit sniff mode,"OCF_EXIT_SNIFF_MODE".
As far as I understood, whenever
conn->modeisHCI_CM_SNIFF
conn->power_saveQuoted 2 lines
Quoted 2 lines
is 0.
The reason is thathci_mode_change_evt()setconn->power_saveas "0"when
Quoted 7 lines
Quoted 3 lines
conn->mode!=HCI_CM_ACTIVE.Consequently we don't need to check that variable.
we do need that variable, because otherwise devices like HID which do active sniff mode management fall over if we always try to exit sniff mode only for a few bytes.
In case of HID, active sniff mode could be no problem because its data rate is light compared to other profile.
But other case such as Sony Ericsson HBH-DS970,980 A2DP profile , it could be problem.
As you may already know,
they request sniff mode while HFP so their connection is too late... It made AVDTP signal so slow..
Quoted 6 lines
Without
conn->power_savevariable check procedure, I found Sony Headset works well! because they exit sniff mode
Consequently, I thinkconn->power_savevariable procedure should be removed except only HID case.If you think this is totally Sony headset problem, could you explain that?
it is a headset problem since it is too stupid to get out of sniff mode even when it put itself into it and then tries to actively transmit data. However we can ensure to leave sniff mode in that case, but that needs to be a per socket option.
As I said, if you have a HID device, you have to let the HID device control the sniff mode since it knows best anyway.
Regards
Marcel
Hi Marcel,
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 7 lines
Quoted 7 lines
/*bluetooth kernel
hci_conn.c*/
382 voidhci_conn_enter_active_mode(struct hci_conn *conn)390
391 if (conn->mode!=HCI_CM_SNIFF|| !conn->power_save)
392 goto timer;
393
394 if (!test_and_set_bit(HCI_CONN_MODE_CHANGE_PEND,
&conn->pend)) {Quoted 6 lines
Quoted 6 lines
395 struct hci_cp_exit_sniff_mode cp; 396 cp.handle = __cpu_to_le16(conn->handle); 397 hci_send_cmd(hdev, OGF_LINK_POLICY,398
OCF_EXIT_SNIFF_MODE, sizeof(cp),If possible, could you explain why this code checks !conn->power_save
var.?
Quoted 5 lines
Quoted 5 lines
Without this , if conn->mode==HCI_CM_SNIFF , we simply exit sniff mode,"OCF_EXIT_SNIFF_MODE".
As far as I understood, whenever
conn->modeisHCI_CM_SNIFF
conn->power_saveQuoted 2 lines
Quoted 2 lines
is 0.
The reason is thathci_mode_change_evt()setconn->power_saveas "0"when
Quoted 4 lines
Quoted 3 lines
conn->mode!=HCI_CM_ACTIVE.Consequently we don't need to check that variable.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
we do need that variable, because otherwise devices like HID which do active sniff mode management fall over if we always try to exit sniff mode only for a few bytes.
In case of HID, active sniff mode could be no problem because its data rate is light compared to other profile.
But other case such as Sony Ericsson HBH-DS970,980 A2DP profile , it
could
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
be problem.
As you may already know,
they request sniff mode while HFP so their connection is too late... It made AVDTP signal so slow..Without
conn->power_savevariable check procedure, I found Sony Headset works well! because they exit sniff mode
Consequently, I thinkconn->power_savevariable procedure should be
removed
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
except only HID case.
If you think this is totally Sony headset problem, could you explain
that?
Quoted 9 lines
Quoted 9 lines
it is a headset problem since it is too stupid to get out of sniff mode even when it put itself into it and then tries to actively transmit data. However we can ensure to leave sniff mode in that case, but that needs to be a per socket option.
As I said, if you have a HID device, you have to let the HID device control the sniff mode since it knows best anyway.
Thanks to you
I could conclude this problem is from the stupid headset.
But we can't ignore these kind of headset-.-;,
As you know this headset is so popular and their family model has the same problem unfortunately.
Moreover I check another phone[CSR or commercial stack] wakes up sniff mode.
So I have a plan to patch our kernel like below,
1. Simply remove conn->power_save check procedure:
This option is only used for HID profile(as far as I know) and currently we don't support HID.
But I worry about this, because another profiles may need this option and this patch apply to all the ACL connection...
Could you tell me the side effect of this patch except HID profile case?
2. Socket Option by Febien Chevalier:
I think this is similar with your recommendation.
In BlueZ-dev mailing list, socket option patch is already proposed by Fabien Chevalier [[email protected]]
But I couldn't find the conclusion ,its patch and your comments.
His last patch is located on "
http://marc.info/?l=linux-bluetooth&m=122142307223008&w=2"
I think this option is more safe, because this patch is only for user-selected connection.
On a long term view, it's recommended to accept this kind of problem and path BlueZ kernel.
because many user may suffer from this headset , and they don't think this problem due to the headset.
[The reason is that another commercial stack device supports this well]
Regards
Chanyeol
Marcel Holtmann
maintainerHi Chan-Yeol,
Quoted 70 lines
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 7 lines
Quoted 7 lines
/*bluetooth kernel
hci_conn.c*/
382 voidhci_conn_enter_active_mode(struct hci_conn *conn)390
391 if (conn->mode!=HCI_CM_SNIFF|| !conn->power_save)
392 goto timer;
393
394 if (!test_and_set_bit(HCI_CONN_MODE_CHANGE_PEND,
&conn->pend)) {Quoted 6 lines
Quoted 6 lines
395 struct hci_cp_exit_sniff_mode cp; 396 cp.handle = __cpu_to_le16(conn->handle); 397 hci_send_cmd(hdev, OGF_LINK_POLICY,398
OCF_EXIT_SNIFF_MODE, sizeof(cp),If possible, could you explain why this code checks !conn->power_save
var.?
Quoted 5 lines
Quoted 5 lines
Without this , if conn->mode==HCI_CM_SNIFF , we simply exit sniff mode,"OCF_EXIT_SNIFF_MODE".
As far as I understood, whenever
conn->modeisHCI_CM_SNIFF
conn->power_saveQuoted 2 lines
Quoted 2 lines
is 0.
The reason is thathci_mode_change_evt()setconn->power_saveas "0"when
Quoted 4 lines
Quoted 3 lines
conn->mode!=HCI_CM_ACTIVE.Consequently we don't need to check that variable.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
we do need that variable, because otherwise devices like HID which do active sniff mode management fall over if we always try to exit sniff mode only for a few bytes.
In case of HID, active sniff mode could be no problem because its data rate is light compared to other profile.
But other case such as Sony Ericsson HBH-DS970,980 A2DP profile , it
could
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
be problem.
As you may already know,
they request sniff mode while HFP so their connection is too late... It made AVDTP signal so slow..Without
conn->power_savevariable check procedure, I found Sony Headset works well! because they exit sniff mode
Consequently, I thinkconn->power_savevariable procedure should beremoved
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
except only HID case.
If you think this is totally Sony headset problem, could you explain
that?
Quoted 9 lines
Quoted 9 lines
it is a headset problem since it is too stupid to get out of sniff mode even when it put itself into it and then tries to actively transmit data. However we can ensure to leave sniff mode in that case, but that needs to be a per socket option.
As I said, if you have a HID device, you have to let the HID device control the sniff mode since it knows best anyway.
Thanks to you
I could conclude this problem is from the stupid headset.But we can't ignore these kind of headset-.-;,
As you know this headset is so popular and their family model has the same problem unfortunately.
Moreover I check another phone[CSR or commercial stack] wakes up sniff mode.So I have a plan to patch our kernel like below,
Quoted 7 lines
1. Simply remove
conn->power_savecheck procedure:
This option is only used for HID profile(as far as I know) and currently we don't support HID.
But I worry about this, because another profiles may need this option and this patch apply to all the ACL connection...Could you tell me the side effect of this patch except HID profile case?
it might and if it does, don't come here and ask us for debugging your kernel.
Quoted 10 lines
2. Socket Option by Febien Chevalier:
I think this is similar with your recommendation.In BlueZ-dev mailing list, socket option patch is already proposed by Fabien Chevalier [[email protected]]
But I couldn't find the conclusion ,its patch and your comments.His last patch is located on "
http://marc.info/?l=linux-bluetooth&m=122142307223008&w=2"
Quoted 8 lines
I think this option is more safe, because this patch is only for user-selected connection.
On a long term view, it's recommended to accept this kind of problem and path BlueZ kernel.
because many user may suffer from this headset , and they don't think this problem due to the headset.
[The reason is that another commercial stack device supports this well]
We are using SOL_BLUETOOTH now. So that needs fixing and some other aspects of the patch are not good enough for upstream inclusion.
Regards
Marcel