Bug fixes for Qualcomm BT chip wcn3990
The below issues are found in the recent testing.
1. Observed device is not going into off state or not responding. As wcn3990 require a power pulses to turn on the irrespctive of igniting regulators, it was observed that power on or power off pulses are not in sync with respective to chip.
The below patch will help us to wait until byte is pushed on to wires.
* Bluetooth: hci_qca: use wait_until_sent() for power pulses
2. Observed Chip responding when we are in sleep.
This is due to turn on flow control during change baudrate request. The below patch will only pull the RTS line high instead of turning off the flow.
* Bluetooth: hci_qca: Pull RTS line high for baudrate change command.
3. Observed stray bytes observed after hdev->shutdown. Qualcomm bt chip wcn3990, will turn of regulators when hci down. This is via hdev->shutdown(), once hdev->shutdown() is called, it is not required to send reset command.
* Bluetooth: hci_qca: clear HCI_QUIRK_RESET_ON_CLOSE flag.
4. Frame reassembly errors splashing on console.
wcn3990 requires will use multiple baudrates during booting stage. i.e. 2400 bps while sending power off pulse
115200 bps while sending power on pulse
port close
port open
set baudrate to 115200 request the chip version.
during above process, we are seeing some stray bytes coming up on the UART Rx FIFO it could be due to frequent baudrate change.
This patch will stop the frame reassembly errors.
* Bluetooth: hci_qca: Fix frame reassembly errors for wcn3990
Note:
This patches are on top of below patches posted in patch work for hci_qca
https://lore.kernel.org/patchwork/patch/1005631/
https://lore.kernel.org/patchwork/patch/1004372/
Balakrishna Godavarthi (4):
Bluetooth: hci_qca: use wait_until_sent() for power pulses
Bluetooth: hci_qca: Pull RTS line high for baudrate change command
Bluetooth: hci_qca: clear HCI_QUIRK_RESET_ON_CLOSE flag
Bluetooth: hci_qca: Fix frame reassembly errors for wcn3990
drivers/bluetooth/hci_qca.c | 66 +++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 25 deletions(-)
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 1/4 Bluetooth: hci_qca: use wait_until_sent() for power pulses
wcn3990 requires a power pulse to turn ON/OFF along with regulators. Sometimes we are observing the power pulses are sent out with some time delay, due to queuing these commands. This is causing synchronization issues with chip, which intern delay the chip setup or may end up with communication issues.
--- drivers/bluetooth/hci_qca.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)
drivers/bluetooth/hci_qca.c +9 -13
@@ -1016,8 +1016,7 @@ static inline void host_set_baudrate(struct hci_uart *hu, unsigned int speed)static int qca_send_power_pulse (struct hci_dev *hdev,u8 cmd) {struct hci_uart *hu =hci_get_drvdata (hdev); -struct qca_data *qca = hu->priv; -struct sk_buff *skb; +int ret;/* These power pulses are single byte command which are sent * at required baudrate to wcn3990. On wcn3990, we have an external
@@ -1030,18 +1029,14 @@ static int qca_send_power_pulse(struct hci_dev *hdev, u8 cmd)* sending power pulses to SoC. */ bt_dev_dbg (hdev,"sending power pulse %02x to SoC" , cmd); - - skb =bt_skb_alloc (sizeof (cmd),GFP_KERNEL ); -if (!skb) -return -ENOMEM ; -hci_uart_set_flow_control (hu, true); + ret =serdev_device_write (hu->serdev, &cmd,sizeof (cmd),0 ); +if (ret <0 ) { +bt_dev_err (hdev,"failed to send power pulse %02x to SoC" , cmd); +return ret; + } -skb_put_u8 (skb, cmd); -hci_skb_pkt_type (skb) =HCI_COMMAND_PKT ; - -skb_queue_tail (&qca->txq, skb); -hci_uart_tx_wakeup (hu); +serdev_device_wait_until_sent (hu->serdev,0 );/* Wait for 100 uS for SoC to settle down */ usleep_range (100 ,200 );
@@ -1283,7 +1278,8 @@ static void qca_power_shutdown(struct hci_uart *hu)host_set_baudrate (hu,2400 );hci_uart_set_flow_control (hu, true); -serdev_device_write_buf (serdev, &cmd,sizeof (cmd)); +serdev_device_write (serdev, &cmd,sizeof (cmd),0 ); +serdev_device_wait_until_sent (serdev,0 );hci_uart_set_flow_control (hu, false);qca_power_setup (hu, false); }
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 2/4 Bluetooth: hci_qca: Pull RTS line high for baudrate change command
In reply to Balakrishna GodavarthiThis patch will pull the RTS line high instead of turning off the flow control, while changing baudrate of host and chip.
--- drivers/bluetooth/hci_qca.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
drivers/bluetooth/hci_qca.c +12 -11
@@ -963,7 +963,6 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate)struct hci_uart *hu =hci_get_drvdata (hdev);struct qca_data *qca = hu->priv;struct sk_buff *skb; -struct qca_serdev *qcadev;u8 cmd[] = {0x01 ,0x48 ,0xFC ,0x01 ,0x00 };if (baudrate >QCA_BAUDRATE_3200000 )
@@ -977,13 +976,6 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate)return -ENOMEM ; } -/* Disabling hardware flow control is mandatory while -* sending change baudrate request to wcn3990 SoC. -*/ - qcadev =serdev_device_get_drvdata (hu->serdev); -if (qcadev->btsoc_type ==QCA_WCN3990 ) -hci_uart_set_flow_control (hu, true); -/* Assign commands to change baudrate and packet type. */ skb_put_data (skb, cmd,sizeof (cmd));hci_skb_pkt_type (skb) =HCI_COMMAND_PKT ;
@@ -999,9 +991,6 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate)schedule_timeout (msecs_to_jiffies (BAUDRATE_SETTLE_TIMEOUT_MS ));set_current_state (TASK_RUNNING ); -if (qcadev->btsoc_type ==QCA_WCN3990 ) -hci_uart_set_flow_control (hu, false); -return 0 ; }
@@ -1086,6 +1075,7 @@ static int qca_check_speeds(struct hci_uart *hu)static int qca_set_speed (struct hci_uart *hu,enum qca_speed_type speed_type) {unsigned int speed, qca_baudrate; +struct qca_serdev *qcadev;int ret;if (speed_type ==QCA_INIT_SPEED ) {
@@ -1097,6 +1087,14 @@ static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type)if (!speed)return 0 ; +/* Pulling RTS line to high is mandatory while sending change +* baudrate request to SoC and also while setting the host +* baudrate. +*/ + qcadev =serdev_device_get_drvdata (hu->serdev); +if (qcadev->btsoc_type ==QCA_WCN3990 ) +serdev_device_set_rts (hu->serdev, false); + qca_baudrate =qca_get_baudrate_value (speed);bt_dev_dbg (hu->hdev,"Set UART speed to %d" , speed); ret =qca_set_baudrate (hu->hdev, qca_baudrate);
@@ -1104,6 +1102,9 @@ static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type)return ret;host_set_baudrate (hu, speed); + +if (qcadev->btsoc_type ==QCA_WCN3990 ) +serdev_device_set_rts (hu->serdev, true); }return 0 ;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 3/4 Bluetooth: hci_qca: clear HCI_QUIRK_RESET_ON_CLOSE flag
In reply to Balakrishna GodavarthiDuring hci down we are sending reset command to chip, which is not required for wcn3990, as hdev->shutdown() will turn off the regulators.
--- drivers/bluetooth/hci_qca.c | 1 + 1 file changed, 1 insertion(+)
drivers/bluetooth/hci_qca.c +1 -0
@@ -1190,6 +1190,7 @@ static int qca_setup(struct hci_uart *hu)*/ set_bit (HCI_QUIRK_NON_PERSISTENT_SETUP , &hdev->quirks);set_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks); +clear_bit (HCI_QUIRK_RESET_ON_CLOSE , &hdev->quirks); hu->hdev->shutdown = qca_power_off; ret =qca_wcn3990_init (hu);if (ret)
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 4/4 Bluetooth: hci_qca: Fix frame reassembly errors for wcn3990
In reply to Balakrishna Godavarthi[ 176.929612] Bluetooth: hci_qca.c:qca_recv() hci0: Frame reassembly failed (-84) [ 176.945734] Bluetooth: hci_qca.c:qca_recv() hci0: Frame reassembly failed (-84) [ 176.953298] Bluetooth: hci_qca.c:qca_recv() hci0: Frame reassembly failed (-84) [ 177.010660] Bluetooth: hci_qca.c:qca_recv() hci0: Frame reassembly failed (-84) [ 177.067633] Bluetooth: hci_qca.c:qca_recv() hci0: Frame reassembly failed (-84)
The above errors log on console due to receiving of stray bytes when wcn3990 boot up's i.e. when during initial setup procedure.
--- drivers/bluetooth/hci_qca.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/bluetooth/hci_qca.c +19 -1
@@ -56,6 +56,7 @@/* Controller states */ #define STATE_IN_BAND_SLEEP_ENABLED 1 +#define STATE_DISCARD_RX 2#define IBS_WAKE_RETRANS_TIMEOUT_MS 100#define IBS_TX_IDLE_TIMEOUT_MS 2000
@@ -511,6 +512,7 @@ static int qca_open(struct hci_uart *hu) }else { hu->init_speed = qcadev->init_speed; hu->oper_speed = qcadev->oper_speed; +set_bit (STATE_DISCARD_RX , &qca->flags); ret =qca_power_setup (hu, true);if (ret) {destroy_workqueue (qca->workqueue);
@@ -903,6 +905,13 @@ static int qca_recv(struct hci_uart *hu, const void *data, int count)if (!test_bit (HCI_UART_REGISTERED , &hu->flags))return -EUNATCH ; +/* We discard Rx data received while device is in booting +* stage, this is due multiple baudrate switch is causing +* UART to read some garbage data. +*/ +if (test_bit (STATE_DISCARD_RX , &qca->flags)) +return 0 ; + qca->rx_skb =h4_recv_buf (hu->hdev, qca->rx_skb, data, count, qca_recv_pkts,ARRAY_SIZE (qca_recv_pkts));if (IS_ERR (qca->rx_skb)) {
@@ -1192,10 +1201,12 @@ static int qca_setup(struct hci_uart *hu)set_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks);clear_bit (HCI_QUIRK_RESET_ON_CLOSE , &hdev->quirks); hu->hdev->shutdown = qca_power_off; + ret =qca_wcn3990_init (hu);if (ret)return ret; +clear_bit (STATE_DISCARD_RX , &qca->flags); ret =qca_read_soc_version (hdev, &soc_ver);if (ret)return ret;
@@ -1278,8 +1289,15 @@ static void qca_power_shutdown(struct hci_uart *hu)struct serdev_device *serdev = hu->serdev;unsigned char cmd =QCA_WCN3990_POWEROFF_PULSE ; -host_set_baudrate (hu,2400 ); +/* From this point we go into power off state, +* disable IBS and discard all the queued data. +*/ +clear_bit (STATE_IN_BAND_SLEEP_ENABLED , &qca->flags); +set_bit (STATE_DISCARD_RX , &qca->flags); +qca_flush (hu); +hci_uart_set_flow_control (hu, true); +host_set_baudrate (hu,2400 );serdev_device_write (serdev, &cmd,sizeof (cmd),0 );serdev_device_wait_until_sent (serdev,0 );hci_uart_set_flow_control (hu, false);
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Marcel Holtmann
maintainerRe: [PATCH v1 3/4] Bluetooth: hci_qca: clear HCI_QUIRK_RESET_ON_CLOSE flag
In reply to Balakrishna GodavarthiHi Balakrishna,
Quoted 14 lines
During hci down we are sending reset command to chip, which is not required for wcn3990, as
hdev->shutdown()will turn off the regulators.Signed-off-by Balakrishna Godavarthi <[email protected]>---
drivers/bluetooth/hci_qca.c| 1 +1 file changed, 1 insertion(+)drivers/bluetooth/hci_qca.c +0
-0
drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 1196
Quoted 7 lines
drivers/bluetooth/hci_qca.c +1
-0@@ -1190,6 +1190,7 @@ static int qca_setup(struct hci_uart *hu)*/ set_bit (HCI_QUIRK_NON_PERSISTENT_SETUP , &hdev->quirks);set_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks); +clear_bit (HCI_QUIRK_RESET_ON_CLOSE , &hdev->quirks); hu->hdev->shutdown = qca_power_off; ret =qca_wcn3990_init (hu);if (ret)
I am pretty certain that you didn’t want this quirk:
/* When this quirk is set, the HCI Reset command is send when
* closing the transport instead of when opening it.
This quirk is for Bluetooth 1.0b devices where the HCI_Reset behavior was not clear or for devices that actually misbehave with the initial HCI_Reset.
In addition, you commit message is totally misleading. That is not what is happening with this quirk.
Regards
Marcel
Re: [PATCH v1 3/4] Bluetooth: hci_qca: clear HCI_QUIRK_RESET_ON_CLOSE flag
Hi Marcel,
Quoted 34 lines · Marcel Holtmann
Hi Balakrishna,
Quoted 14 lines
During hci down we are sending reset command to chip, which is not required for wcn3990, as
hdev->shutdown()will turn off the regulators.Signed-off-by Balakrishna Godavarthi <[email protected]>---
drivers/bluetooth/hci_qca.c| 1 +1 file changed, 1 insertion(+)drivers/bluetooth/hci_qca.c +0
-0drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 1196
Quoted 7 lines
drivers/bluetooth/hci_qca.c +1
-0@@ -1190,6 +1190,7 @@ static int qca_setup(struct hci_uart *hu)*/ set_bit (HCI_QUIRK_NON_PERSISTENT_SETUP , &hdev->quirks);set_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks); +clear_bit (HCI_QUIRK_RESET_ON_CLOSE , &hdev->quirks); hu->hdev->shutdown = qca_power_off; ret =qca_wcn3990_init (hu);if (ret)I am pretty certain that you didn’t want this quirk:
/* When this quirk is set, the HCI Reset command is send when
* closing the transport instead of when opening it.
This quirk is for Bluetooth 1.0b devices where the
HCI_Resetbehavior was not clear or for devices that actually misbehave with the initialHCI_Reset.
Quoted 6 lines
In addition, you commit message is totally misleading. That is not what is happening with this quirk.
Regards
Marcel
My intention was reset command is not required when we do an hci down.
this is because of hdev->shutdown will turn off the regulators.
It is like turning off the chip. sending reset command after turning off the chip is not required.
I understand the usage of the quirk, will update the commit text.
Signature · 2 lines
Regards Balakrishna.
Marcel Holtmann
maintainerRe: [PATCH v1 3/4] Bluetooth: hci_qca: clear HCI_QUIRK_RESET_ON_CLOSE flag
Hi Balakrishna,
Quoted 30 lines
Quoted 21 lines
Quoted 12 lines
During hci down we are sending reset command to chip, which is not required for wcn3990, as
hdev->shutdown()will turn off the regulators.Signed-off-by Balakrishna Godavarthi <[email protected]>---
drivers/bluetooth/hci_qca.c| 1 +1 file changed, 1 insertion(+)drivers/bluetooth/hci_qca.c +0
-0drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 1196
Quoted 7 lines
drivers/bluetooth/hci_qca.c +1
-0@@ -1190,6 +1190,7 @@ static int qca_setup(struct hci_uart *hu)*/ set_bit (HCI_QUIRK_NON_PERSISTENT_SETUP , &hdev->quirks);set_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks); +clear_bit (HCI_QUIRK_RESET_ON_CLOSE , &hdev->quirks); hu->hdev->shutdown = qca_power_off; ret =qca_wcn3990_init (hu);if (ret)I am pretty certain that you didn’t want this quirk:
/* When this quirk is set, the HCI Reset command is send whenQuoted 8 lines
* closing the transport instead of when opening it.
This quirk is for Bluetooth 1.0b devices where theHCI_Resetbehavior was not clear or for devices that actually misbehave with the initialHCI_Reset.
In addition, you commit message is totally misleading. That is not what is happening with this quirk.
Regards
Marcel
Quoted 5 lines
My intention was reset command is not required when we do an hci down.
this is because ofhdev->shutdownwill turn off the regulators.
It is like turning off the chip. sending reset command after turning off the chip is not required.I understand the usage of the quirk, will update the commit text.
you are papering over the issue. Actually hci_serdev.c:hci_uart_register_device() is the culprit with the legacy code copied over from hci_ldisc.c:hci_uart_register_dev(). I think there is no point doing all this legacy line discipline quirk handling until it is really needed. The serdev drivers are all for recent hardware.
That said, having moved over to a btuart.c approach and killed the whole hci_serdev.c thing would have been a lot better here. You will keep running in weird situations where 18 year old code keeps surprising you.
Regards
Marcel
Re: [PATCH v1 3/4] Bluetooth: hci_qca: clear HCI_QUIRK_RESET_ON_CLOSE flag
Hi Marcel,
Quoted 45 lines · Marcel Holtmann
Hi Balakrishna,
Quoted 30 lines
Quoted 21 lines
Quoted 12 lines
During hci down we are sending reset command to chip, which is not required for wcn3990, as
hdev->shutdown()will turn off the regulators.Signed-off-by Balakrishna Godavarthi <[email protected]>---
drivers/bluetooth/hci_qca.c| 1 +1 file changed, 1 insertion(+)drivers/bluetooth/hci_qca.c +0
-0drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 1196
Quoted 7 lines
drivers/bluetooth/hci_qca.c +1
-0@@ -1190,6 +1190,7 @@ static int qca_setup(struct hci_uart *hu)*/ set_bit (HCI_QUIRK_NON_PERSISTENT_SETUP , &hdev->quirks);set_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks); +clear_bit (HCI_QUIRK_RESET_ON_CLOSE , &hdev->quirks); hu->hdev->shutdown = qca_power_off; ret =qca_wcn3990_init (hu);if (ret)I am pretty certain that you didn’t want this quirk:
/* When this quirk is set, the HCI Reset command is send whenQuoted 8 lines
* closing the transport instead of when opening it.
This quirk is for Bluetooth 1.0b devices where theHCI_Resetbehavior was not clear or for devices that actually misbehave with the initialHCI_Reset.
In addition, you commit message is totally misleading. That is not what is happening with this quirk.
Regards
MarcelQuoted 5 lines
My intention was reset command is not required when we do an hci down.
this is because ofhdev->shutdownwill turn off the regulators.
It is like turning off the chip. sending reset command after turning off the chip is not required.I understand the usage of the quirk, will update the commit text.
you are papering over the issue. Actually hci_serdev.c:hci_uart_register_device() is the culprit with the legacy code copied over from hci_ldisc.c:hci_uart_register_dev(). I think there is no point doing all this legacy line discipline quirk handling until it is really needed. The serdev drivers are all for recent hardware.
Quoted 4 lines
That said, having moved over to a
btuart.capproach and killed the wholehci_serdev.cthing would have been a lot better here. You will keep running in weird situations where 18 year old code keeps surprising you.
[Bala]: even i feel the same. they are lot such kind of HACK's we need to do with current arch.
when can we expect btuart.c merged to bt-next. i think having
btuart will helps us to have the control of
vendor porto's call's like in btusb.c
Quoted 4 lines
Regards
Marcel
Signature · 2 lines
Regards Balakrishna.
Re: [PATCH v1 3/4] Bluetooth: hci_qca: clear HCI_QUIRK_RESET_ON_CLOSE flag
Hi Marcel,
Quoted 53 lines · Balakrishna Godavarthi
Hi Marcel,
Quoted 45 lines · Marcel Holtmann
Hi Balakrishna,
Quoted 30 lines
Quoted 21 lines
Quoted 12 lines
During hci down we are sending reset command to chip, which is not required for wcn3990, as
hdev->shutdown()will turn off the regulators.Signed-off-by Balakrishna Godavarthi <[email protected]>---
drivers/bluetooth/hci_qca.c| 1 +1 file changed, 1 insertion(+)drivers/bluetooth/hci_qca.c +0
-0drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 1196
Quoted 7 lines
drivers/bluetooth/hci_qca.c +1
-0@@ -1190,6 +1190,7 @@ static int qca_setup(struct hci_uart *hu)*/ set_bit (HCI_QUIRK_NON_PERSISTENT_SETUP , &hdev->quirks);set_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks); +clear_bit (HCI_QUIRK_RESET_ON_CLOSE , &hdev->quirks); hu->hdev->shutdown = qca_power_off; ret =qca_wcn3990_init (hu);if (ret)I am pretty certain that you didn’t want this quirk:
/* When this quirk is set, the HCI Reset command is send whenQuoted 8 lines
* closing the transport instead of when opening it.
This quirk is for Bluetooth 1.0b devices where theHCI_Resetbehavior was not clear or for devices that actually misbehave with the initialHCI_Reset.
In addition, you commit message is totally misleading. That is not what is happening with this quirk.
Regards
MarcelQuoted 5 lines
My intention was reset command is not required when we do an hci down.
this is because ofhdev->shutdownwill turn off the regulators.
It is like turning off the chip. sending reset command after turning off the chip is not required.I understand the usage of the quirk, will update the commit text.
you are papering over the issue. Actually hci_serdev.c:hci_uart_register_device() is the culprit with the legacy code copied over from hci_ldisc.c:hci_uart_register_dev(). I think there is no point doing all this legacy line discipline quirk handling until it is really needed. The serdev drivers are all for recent hardware.
Quoted 4 lines
That said, having moved over to a
btuart.capproach and killed the wholehci_serdev.cthing would have been a lot better here. You will keep running in weird situations where 18 year old code keeps surprising you.
Quoted 10 lines
[Bala]: even i feel the same. they are lot such kind of HACK's we need to do with current arch.
when can we expectbtuart.cmerged to bt-next. i think having
btuart will helps us to have the control of
vendor porto's call's like inbtusb.cQuoted 4 lines
Regards
Marcel
I need some clarification, do you expect some thing like this https://github.com/torvalds/linux/blob/master/drivers/bluetooth/btmtkuart.c for Qualcomm BT chip too. it looks it is completely avoided hci_serdev.c interface.
Signature · 2 lines
Regards Balakrishna.
Re: [PATCH v1 1/4] Bluetooth: hci_qca: use wait_until_sent() for power pulses
In reply to Balakrishna GodavarthiQuoted 40 lines · Balakrishna Godavarthi
wcn3990 requires a power pulse to turn ON/OFF along with regulators. Sometimes we are observing the power pulses are sent out with some time delay, due to queuing these commands. This is causing synchronization issues with chip, which intern delay the chip setup or may end up with communication issues.
Signed-off-by Balakrishna Godavarthi <[email protected]>--- drivers/bluetooth/hci_qca.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)drivers/bluetooth/hci_qca.c +6
-7@@ -1016,8 +1016,7 @@ static inline void host_set_baudrate(struct hci_uart *hu, unsigned int speed)static int qca_send_power_pulse (struct hci_dev *hdev,u8 cmd) {struct hci_uart *hu =hci_get_drvdata (hdev); -struct qca_data *qca = hu->priv; -struct sk_buff *skb; +int ret;/* These power pulses are single byte command which are sent * at required baudrate to wcn3990. On wcn3990, we have an external @@ -1030,18 +1029,14 @@ static int qca_send_power_pulse(struct hci_dev *hdev, u8 cmd)* sending power pulses to SoC. */ bt_dev_dbg (hdev,"sending power pulse %02x to SoC" , cmd); - - skb =bt_skb_alloc (sizeof (cmd),GFP_KERNEL ); -if (!skb) -return -ENOMEM ; -hci_uart_set_flow_control (hu, true); + ret =serdev_device_write (hu->serdev, &cmd,sizeof (cmd),0 ); +if (ret <0 ) { +bt_dev_err (hdev,"failed to send power pulse %02x to SoC" , cmd); +return ret; + }
drivers/bluetooth/hci_qca.c static int qca_send_power_pulse(struct hci_dev *hdev, u8 cmd) · line 1042
Quoted 10 lines
drivers/bluetooth/hci_qca.c +1
-5-skb_put_u8 (skb, cmd); -hci_skb_pkt_type (skb) =HCI_COMMAND_PKT ; - -skb_queue_tail (&qca->txq, skb); -hci_uart_tx_wakeup (hu); +serdev_device_wait_until_sent (hu->serdev,0 );/* Wait for 100 uS for SoC to settle down */ usleep_range (100 ,200 );
Is the delay still needed now that we wait for the pulse to be sent? I didn't observe any problems without it in a few dozens of iterations.
drivers/bluetooth/hci_qca.c static void qca_power_shutdown(struct hci_uart *hu) · line 1283
Quoted 8 lines
drivers/bluetooth/hci_qca.c +2
-1@@ -1283,7 +1278,8 @@ static void qca_power_shutdown(struct hci_uart *hu)host_set_baudrate (hu,2400 );hci_uart_set_flow_control (hu, true); -serdev_device_write_buf (serdev, &cmd,sizeof (cmd)); +serdev_device_write (serdev, &cmd,sizeof (cmd),0 ); +serdev_device_wait_until_sent (serdev,0 );hci_uart_set_flow_control (hu, false);
You could call qca_send_power_pulse(hdev, QCA_WCN3990_POWEROFF_PULSE) instead, as an earlier patch set did before skbs were used to send the power pulse.
You can also consider to set the baudrate in qca_send_power_pulse() depending on the power pulse. On the plus side this would reduce a bit of clutter in the callers of qca_send_power_pulse(), on the negative side it would be harder to follow when baudrate changes occur (not sure this is a problem). Up to you, just an idea.
Thanks
Matthias
Re: [PATCH v1 2/4] Bluetooth: hci_qca: Pull RTS line high for baudrate change command
In reply to Balakrishna GodavarthiQuoted 2 lines · Balakrishna Godavarthi
This patch will pull the RTS line high instead of turning off the flow control, while changing baudrate of host and chip.
Please don't only describe what is changed, but also why this change is necessary.
IIUC the BT chip honors flow control during baudrate changes, however it sometimes sends 'garbage' which results in "Bluetooth: hci0: Frame reassembly failed (-84)" messages.
Quoted 50 lines
Signed-off-by Balakrishna Godavarthi <[email protected]>--- drivers/bluetooth/hci_qca.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)drivers/bluetooth/hci_qca.c +1
-11@@ -963,7 +963,6 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate)struct hci_uart *hu =hci_get_drvdata (hdev);struct qca_data *qca = hu->priv;struct sk_buff *skb; -struct qca_serdev *qcadev;u8 cmd[] = {0x01 ,0x48 ,0xFC ,0x01 ,0x00 };if (baudrate >QCA_BAUDRATE_3200000 )@@ -977,13 +976,6 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate)return -ENOMEM ; } -/* Disabling hardware flow control is mandatory while -* sending change baudrate request to wcn3990 SoC. -*/ - qcadev =serdev_device_get_drvdata (hu->serdev); -if (qcadev->btsoc_type ==QCA_WCN3990 ) -hci_uart_set_flow_control (hu, true); -/* Assign commands to change baudrate and packet type. */ skb_put_data (skb, cmd,sizeof (cmd));hci_skb_pkt_type (skb) =HCI_COMMAND_PKT ;@@ -999,9 +991,6 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate)schedule_timeout (msecs_to_jiffies (BAUDRATE_SETTLE_TIMEOUT_MS ));set_current_state (TASK_RUNNING ); -if (qcadev->btsoc_type ==QCA_WCN3990 ) -hci_uart_set_flow_control (hu, false); -return 0 ; }@@ -1086,6 +1075,7 @@ static int qca_check_speeds(struct hci_uart *hu)static int qca_set_speed (struct hci_uart *hu,enum qca_speed_type speed_type) {unsigned int speed, qca_baudrate; +struct qca_serdev *qcadev;int ret;if (speed_type ==QCA_INIT_SPEED ) {
drivers/bluetooth/hci_qca.c static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type) · line 1093
Quoted 7 lines
drivers/bluetooth/hci_qca.c +4
-0@@ -1097,6 +1087,14 @@ static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type)if (!speed)return 0 ; +/* Pulling RTS line to high is mandatory while sending change +* baudrate request to SoC and also while setting the host +* baudrate. +*/
Instead of just stating that this is 'mandatory' explain why it is needed. Also better say 'Deassert RTS' instead of the more lower level 'Pulling RTS line to high'. It could be something like 'Deassert RTS to prevent the BT controller from sending garbage during the baudrate change.'
Quoted 8 lines
drivers/bluetooth/hci_qca.c +4
-0+ qcadev =serdev_device_get_drvdata (hu->serdev); +if (qcadev->btsoc_type ==QCA_WCN3990 ) +serdev_device_set_rts (hu->serdev, false); + qca_baudrate =qca_get_baudrate_value (speed);bt_dev_dbg (hu->hdev,"Set UART speed to %d" , speed); ret =qca_set_baudrate (hu->hdev, qca_baudrate);
drivers/bluetooth/hci_qca.c static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type) · line 1110
Quoted 9 lines
drivers/bluetooth/hci_qca.c +3
-0@@ -1104,6 +1102,9 @@ static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type)return ret;host_set_baudrate (hu, speed); + +if (qcadev->btsoc_type ==QCA_WCN3990 ) +serdev_device_set_rts (hu->serdev, true); }return 0 ;
Re: [PATCH v1 3/4] Bluetooth: hci_qca: clear HCI_QUIRK_RESET_ON_CLOSE flag
In reply to Balakrishna GodavarthiQuoted 14 lines · Balakrishna Godavarthi
Hi Marcel,
Quoted 11 lines · Marcel Holtmann
Hi Balakrishna,
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
During hci down we are sending reset command to chip, which is not required for wcn3990, as
hdev->shutdown()will turn off the regulators.Signed-off-by Balakrishna Godavarthi <[email protected]>---
drivers/bluetooth/hci_qca.c| 1 +1 file changed, 1 insertion(+)drivers/bluetooth/hci_qca.c +0
-0
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 1193
Quoted 8 lines
index
8301663f0004..97b57e0f4725100644drivers/bluetooth/hci_qca.c +1
-0@@ -1190,6 +1190,7 @@ static int qca_setup(struct hci_uart *hu)*/ set_bit (HCI_QUIRK_NON_PERSISTENT_SETUP , &hdev->quirks);set_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks); +clear_bit (HCI_QUIRK_RESET_ON_CLOSE , &hdev->quirks);
This patch doesn't apply cleanly against bluetooth-next, looks like you have the unrelated "Bluetooth: hci_qca: Set HCI_QUIRK_USE_BDADDR_PROPERTY for wcn3990"
(https://lore.kernel.org/patchwork/patch/1004372/) in your tree.
Quoted 33 lines
Quoted 28 lines
Quoted 14 lines
Quoted 13 lines
drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 1196
Quoted 3 lines
drivers/bluetooth/hci_qca.c +0
-0hu->hdev->shutdown = qca_power_off; ret =qca_wcn3990_init (hu);if (ret)I am pretty certain that you didn’t want this quirk:
/* When this quirk is set, the HCI Reset command is send when
* closing the transport instead of when opening it.
This quirk is for Bluetooth 1.0b devices where theHCI_Resetbehavior was not clear or for devices that actually misbehave with the initialHCI_Reset.
In addition, you commit message is totally misleading. That is not what is happening with this quirk.
Regards
MarcelQuoted 6 lines
My intention was reset command is not required when we do an hci down. this is because of
hdev->shutdownwill turn off the regulators. It is like turning off the chip. sending reset command after turning off the chip is not required.I understand the usage of the quirk, will update the commit text.
you are papering over the issue. Actually hci_serdev.c:hci_uart_register_device() is the culprit with the legacy code copied over from hci_ldisc.c:hci_uart_register_dev(). I think there is no point doing all this legacy line discipline quirk handling until it is really needed. The serdev drivers are all for recent hardware.
Quoted 4 lines
That said, having moved over to a
btuart.capproach and killed the wholehci_serdev.cthing would have been a lot better here. You will keep running in weird situations where 18 year old code keeps surprising you.
Quoted 5 lines
[Bala]: even i feel the same. they are lot such kind of HACK's we need to do with current arch.
when can we expectbtuart.cmerged to bt-next. i think having btuart
will helps us to have the control of
vendor porto's call's like inbtusb.c
btuart was initially part of the 'add support for Bluetooth on MT7622 SoC' series (https://lore.kernel.org/patchwork/patch/960806/), but was dropped with v6
(https://lore.kernel.org/patchwork/project/lkml/list/?series=360046)
upon Marcel's request: 'Frankly I prefer to keep the btuart.c driver for drivers that really just use H:4 as transport protocol. If the protocol is only H:4 alike and has extra headers, then it should be a separate driver.' (https://lore.kernel.org/patchwork/patch/960806/#1148426).
Cheers
Matthias
Re: [PATCH v1 1/4] Bluetooth: hci_qca: use wait_until_sent() for power pulses
In reply to Matthias KaehlckeHi Matthias,
Quoted 51 lines · Matthias Kaehlcke
Quoted 50 lines · Balakrishna Godavarthi
wcn3990 requires a power pulse to turn ON/OFF along with regulators. Sometimes we are observing the power pulses are sent out with some time delay, due to queuing these commands. This is causing synchronization issues with chip, which intern delay the chip setup or may end up with communication issues.
Signed-off-by Balakrishna Godavarthi <[email protected]>--- drivers/bluetooth/hci_qca.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)drivers/bluetooth/hci_qca.c +1
-2@@ -1016,8 +1016,7 @@ static inline void host_set_baudrate(struct hci_uart *hu, unsigned int speed)static int qca_send_power_pulse (struct hci_dev *hdev,u8 cmd) {struct hci_uart *hu =hci_get_drvdata (hdev); -struct qca_data *qca = hu->priv; -struct sk_buff *skb; +int ret;/* These power pulses are single byte command which are sent drivers/bluetooth/hci_qca.c +6
-10* at required baudrate to wcn3990. On wcn3990, we have an external @@ -1030,18 +1029,14 @@ static int qca_send_power_pulse(struct hci_dev*hdev, u8 cmd) * sending power pulses to SoC. */ bt_dev_dbg (hdev,"sending power pulse %02x to SoC" , cmd); - - skb =bt_skb_alloc (sizeof (cmd),GFP_KERNEL ); -if (!skb) -return -ENOMEM ; -hci_uart_set_flow_control (hu, true); + ret =serdev_device_write (hu->serdev, &cmd,sizeof (cmd),0 ); +if (ret <0 ) { +bt_dev_err (hdev,"failed to send power pulse %02x to SoC" , cmd); +return ret; + } -skb_put_u8 (skb, cmd); -hci_skb_pkt_type (skb) =HCI_COMMAND_PKT ; - -skb_queue_tail (&qca->txq, skb); -hci_uart_tx_wakeup (hu); +serdev_device_wait_until_sent (hu->serdev,0 );
Quoted 6 lines
Quoted 2 lines
drivers/bluetooth/hci_qca.c +0
-0/* Wait for 100 uS for SoC to settle down */
usleep_range(100, 200);Is the delay still needed now that we wait for the pulse to be sent? I didn't observe any problems without it in a few dozens of iterations.
[Bala]: chip require some time to boot up
so this delay will helps us to be in sync with the chip. for now we will go with this delay, if really required we can change
100us to some where
around 10us.
Quoted 14 lines
drivers/bluetooth/hci_qca.c static void qca_power_shutdown(struct hci_uart · line 1284
Quoted 9 lines
drivers/bluetooth/hci_qca.c +2
-1@@ -1283,7 +1278,8 @@ static void qca_power_shutdown(struct hci_uart *hu)host_set_baudrate (hu,2400 );hci_uart_set_flow_control (hu, true); -serdev_device_write_buf (serdev, &cmd,sizeof (cmd)); +serdev_device_write (serdev, &cmd,sizeof (cmd),0 ); +serdev_device_wait_until_sent (serdev,0 );hci_uart_set_flow_control (hu, false);You could call
qca_send_power_pulse(hdev, QCA_WCN3990_POWEROFF_PULSE)instead, as an earlier patch set did before skbs were used to send the power pulse.
[Bala]: will update.
Quoted 6 lines
You can also consider to set the baudrate in
qca_send_power_pulse()depending on the power pulse. On the plus side this would reduce a bit of clutter in the callers ofqca_send_power_pulse(), on the negative side it would be harder to follow when baudrate changes occur (not sure this is a problem). Up to you, just an idea.
[Bala]: moving bd change request to power_pulse has both plus & minus side.
but my opinion is let us we leave qca_send_power_pulse() to be
generic
might be feature chip will use the same function with an
different bd.
Quoted 3 lines
Thanks
Matthias
Signature · 2 lines
Regards Balakrishna.
Re: [PATCH v1 2/4] Bluetooth: hci_qca: Pull RTS line high for baudrate change command
In reply to Matthias KaehlckeHi Matthias,
Quoted 11 lines · Matthias Kaehlcke
Quoted 2 lines · Balakrishna Godavarthi
This patch will pull the RTS line high instead of turning off the flow control, while changing baudrate of host and chip.
Please don't only describe what is changed, but also why this change is necessary.
IIUC the BT chip honors flow control during baudrate changes, however it sometimes sends 'garbage' which results in "Bluetooth: hci0: Frame reassembly failed (-84)" messages.
[Bala]: will update the commit text.
Quoted 58 lines
Quoted 58 lines
Signed-off-by Balakrishna Godavarthi <[email protected]>--- drivers/bluetooth/hci_qca.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)drivers/bluetooth/hci_qca.c +0
-1@@ -963,7 +963,6 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate)struct hci_uart *hu =hci_get_drvdata (hdev);struct qca_data *qca = hu->priv;struct sk_buff *skb; -struct qca_serdev *qcadev;u8 cmd[] = {0x01 ,0x48 ,0xFC ,0x01 ,0x00 };drivers/bluetooth/hci_qca.c +0
-7if (baudrate >QCA_BAUDRATE_3200000 )@@ -977,13 +976,6 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate)return -ENOMEM ; } -/* Disabling hardware flow control is mandatory while -* sending change baudrate request to wcn3990 SoC. -*/ - qcadev =serdev_device_get_drvdata (hu->serdev); -if (qcadev->btsoc_type ==QCA_WCN3990 ) -hci_uart_set_flow_control (hu, true); -/* Assign commands to change baudrate and packet type. */ skb_put_data (skb, cmd,sizeof (cmd));drivers/bluetooth/hci_qca.c +1
-3hci_skb_pkt_type (skb) =HCI_COMMAND_PKT ;@@ -999,9 +991,6 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate)schedule_timeout (msecs_to_jiffies (BAUDRATE_SETTLE_TIMEOUT_MS ));set_current_state (TASK_RUNNING ); -if (qcadev->btsoc_type ==QCA_WCN3990 ) -hci_uart_set_flow_control (hu, false); -return 0 ; }@@ -1086,6 +1075,7 @@ static int qca_check_speeds(struct hci_uart *hu)static int qca_set_speed (struct hci_uart *hu,enum qca_speed_type speed_type) {unsigned int speed, qca_baudrate; +struct qca_serdev *qcadev;int ret;drivers/bluetooth/hci_qca.c +0
-0if (speed_type ==QCA_INIT_SPEED ) {@@ -1097,6 +1087,14 @@ static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type)if (!speed)return 0 ;
Quoted 11 lines
drivers/bluetooth/hci_qca.c static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type) · line 1093
Quoted 4 lines
drivers/bluetooth/hci_qca.c +4
-0+/* Pulling RTS line to high is mandatory while sending change +* baudrate request to SoC and also while setting the host +* baudrate. +*/ Instead of just stating that this is 'mandatory' explain why it is needed. Also better say 'Deassert RTS' instead of the more lower level 'Pulling RTS line to high'. It could be something like 'Deassert RTS to prevent the BT controller from sending garbage during the baudrate change.'
[Bala]: will update the comment.
Quoted 17 lines
Quoted 17 lines
drivers/bluetooth/hci_qca.c +4
-0+ qcadev =serdev_device_get_drvdata (hu->serdev); +if (qcadev->btsoc_type ==QCA_WCN3990 ) +serdev_device_set_rts (hu->serdev, false); + qca_baudrate =qca_get_baudrate_value (speed);bt_dev_dbg (hu->hdev,"Set UART speed to %d" , speed);drivers/bluetooth/hci_qca.c +3
-0ret =qca_set_baudrate (hu->hdev, qca_baudrate);@@ -1104,6 +1102,9 @@ static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type)return ret;host_set_baudrate (hu, speed); + +if (qcadev->btsoc_type ==QCA_WCN3990 ) +serdev_device_set_rts (hu->serdev, true); }
Quoted 3 lines
Quoted 1 line
return 0;
Tested-by Matthias Kaehlcke <[email protected]>
Thanks for testing.
Signature · 2 lines
Regards Balakrishna.
Re: [PATCH v1 3/4] Bluetooth: hci_qca: clear HCI_QUIRK_RESET_ON_CLOSE flag
In reply to Matthias KaehlckeHi Matthias,
Quoted 20 lines · Matthias Kaehlcke
Quoted 19 lines · Balakrishna Godavarthi
Hi Marcel,
Quoted 16 lines · Marcel Holtmann
Hi Balakrishna,
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
During hci down we are sending reset command to chip, which is not required for wcn3990, as
hdev->shutdown()will turn off the regulators.Signed-off-by Balakrishna Godavarthi <[email protected]>---
drivers/bluetooth/hci_qca.c| 1 +1 file changed, 1 insertion(+)drivers/bluetooth/hci_qca.c +0
-0@@ -1190,6 +1190,7 @@ static int qca_setup(struct hci_uart *hu)*/
Quoted 9 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 1193
Quoted 3 lines
drivers/bluetooth/hci_qca.c +1
-0set_bit (HCI_QUIRK_NON_PERSISTENT_SETUP , &hdev->quirks);set_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks); +clear_bit (HCI_QUIRK_RESET_ON_CLOSE , &hdev->quirks);This patch doesn't apply cleanly against bluetooth-next, looks like you have the unrelated "Bluetooth:
hci_qca: SetHCI_QUIRK_USE_BDADDR_PROPERTYfor wcn3990"
(https://lore.kernel.org/patchwork/patch/1004372/) in your tree.
[Bala]: this patch is on top of https://lore.kernel.org/patchwork/patch/1004372/.
will remove the dependency and update the patch.
Quoted 49 lines
Quoted 33 lines
Quoted 28 lines
Quoted 14 lines
Quoted 13 lines
drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 1196
Quoted 3 lines
drivers/bluetooth/hci_qca.c +0
-0hu->hdev->shutdown = qca_power_off; ret =qca_wcn3990_init (hu);if (ret)I am pretty certain that you didn’t want this quirk:
/* When this quirk is set, the HCI Reset command is send when
* closing the transport instead of when opening it.
This quirk is for Bluetooth 1.0b devices where theHCI_Resetbehavior was not clear or for devices that actually misbehave with the initialHCI_Reset.
In addition, you commit message is totally misleading. That is not what is happening with this quirk.
Regards
MarcelQuoted 6 lines
My intention was reset command is not required when we do an hci down. this is because of
hdev->shutdownwill turn off the regulators. It is like turning off the chip. sending reset command after turning off the chip is not required.I understand the usage of the quirk, will update the commit text.
you are papering over the issue. Actually hci_serdev.c:hci_uart_register_device() is the culprit with the legacy code copied over from hci_ldisc.c:hci_uart_register_dev(). I think there is no point doing all this legacy line discipline quirk handling until it is really needed. The serdev drivers are all for recent hardware.
Quoted 4 lines
That said, having moved over to a
btuart.capproach and killed the wholehci_serdev.cthing would have been a lot better here. You will keep running in weird situations where 18 year old code keeps surprising you.Quoted 6 lines
[Bala]: even i feel the same. they are lot such kind of HACK's we need to do with current arch.
when can we expectbtuart.cmerged to bt-next. i think having
btuart
will helps us to have the control of
vendor porto's call's like inbtusb.cbtuart was initially part of the 'add support for Bluetooth on MT7622 SoC' series (https://lore.kernel.org/patchwork/patch/960806/), but was dropped with v6
(https://lore.kernel.org/patchwork/project/lkml/list/?series=360046)
upon Marcel's request: 'Frankly I prefer to keep thebtuart.cdriver for drivers that really just use H:4 as transport protocol. If the protocol is only H:4 alike and has extra headers, then it should be a separate driver.' (https://lore.kernel.org/patchwork/patch/960806/#1148426).
Quoted 3 lines
Cheers
Matthias
[Bala]: currently our main moto is to make this driver to be stable for both rome and wcn3990.
we will look into working on btuart.c type driver for future
qualcomm BT devices.
Signature · 2 lines
Regards Balakrishna.
Marcel Holtmann
maintainerRe: [PATCH v1 3/4] Bluetooth: hci_qca: clear HCI_QUIRK_RESET_ON_CLOSE flag
In reply to Balakrishna GodavarthiHi Balakrishna,
Quoted 48 lines
Quoted 48 lines
Quoted 33 lines
Quoted 29 lines
Quoted 21 lines
Quoted 12 lines
During hci down we are sending reset command to chip, which is not required for wcn3990, as
hdev->shutdown()will turn off the regulators.Signed-off-by Balakrishna Godavarthi <[email protected]>---
drivers/bluetooth/hci_qca.c| 1 +1 file changed, 1 insertion(+)drivers/bluetooth/hci_qca.c +0
-0drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 1196
Quoted 7 lines
drivers/bluetooth/hci_qca.c +1
-0@@ -1190,6 +1190,7 @@ static int qca_setup(struct hci_uart *hu)*/ set_bit (HCI_QUIRK_NON_PERSISTENT_SETUP , &hdev->quirks);set_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks); +clear_bit (HCI_QUIRK_RESET_ON_CLOSE , &hdev->quirks); hu->hdev->shutdown = qca_power_off; ret =qca_wcn3990_init (hu);if (ret)I am pretty certain that you didn’t want this quirk:
/* When this quirk is set, the HCI Reset command is send whenQuoted 8 lines
* closing the transport instead of when opening it.
This quirk is for Bluetooth 1.0b devices where theHCI_Resetbehavior was not clear or for devices that actually misbehave with the initialHCI_Reset.
In addition, you commit message is totally misleading. That is not what is happening with this quirk.
Regards
MarcelQuoted 4 lines
My intention was reset command is not required when we do an hci down.
this is because ofhdev->shutdownwill turn off the regulators.
It is like turning off the chip. sending reset command after turning off the chip is not required. I understand the usage of the quirk, will update the commit text.Quoted 10 lines
you are papering over the issue. Actually hci_serdev.c:hci_uart_register_device() is the culprit with the legacy code copied over from hci_ldisc.c:hci_uart_register_dev(). I think there is no point doing all this legacy line discipline quirk handling until it is really needed. The serdev drivers are all for recent hardware.
That said, having moved over to abtuart.capproach and killed the wholehci_serdev.cthing would have been a lot better here. You will keep running in weird situations where 18 year old code keeps surprising you.[Bala]: even i feel the same. they are lot such kind of HACK's we need to do with current arch.
when can we expectbtuart.cmerged to bt-next. i think having
btuart will helps us to have the control of
vendor porto's call's like inbtusb.c
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Regards
MarcelI need some clarification, do you expect some thing like this https://github.com/torvalds/linux/blob/master/drivers/bluetooth/btmtkuart.c for Qualcomm BT chip too. it looks it is completely avoided
hci_serdev.cinterface.
you tell me actually. Are you using the H:4 transport or do you have an extra protocol layer / framing below it. If you do, then use your own driver, but if the transport is H:4 with vendor packets and vendor setup, then btuart.c (which is not yet upstream) should be your target.
For the MTK hardware it was obvious that it was better served as a separate driver. For QCA serial it really depends on how much extra protocol you have to run. So this might be an exercise in trying QCA serial as a separate driver and then go from there.
It is clear that the baggage from hci_ldisc.c etc is in the way for serdev based systems.
Regards
Marcel
Re: [PATCH v1 3/4] Bluetooth: hci_qca: clear HCI_QUIRK_RESET_ON_CLOSE flag
Hi Marcel,
Quoted 68 lines · Marcel Holtmann
Hi Balakrishna,
Quoted 49 lines
Quoted 49 lines
Quoted 34 lines
Quoted 30 lines
Quoted 21 lines
Quoted 12 lines
During hci down we are sending reset command to chip, which is not required for wcn3990, as
hdev->shutdown()will turn off the regulators.Signed-off-by Balakrishna Godavarthi <[email protected]>---
drivers/bluetooth/hci_qca.c| 1 +1 file changed, 1 insertion(+)drivers/bluetooth/hci_qca.c +0
-0drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 1196
Quoted 7 lines
drivers/bluetooth/hci_qca.c +1
-0@@ -1190,6 +1190,7 @@ static int qca_setup(struct hci_uart *hu)*/ set_bit (HCI_QUIRK_NON_PERSISTENT_SETUP , &hdev->quirks);set_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks); +clear_bit (HCI_QUIRK_RESET_ON_CLOSE , &hdev->quirks); hu->hdev->shutdown = qca_power_off; ret =qca_wcn3990_init (hu);if (ret)I am pretty certain that you didn’t want this quirk:
/* When this quirk is set, the HCI Reset command is sendQuoted 9 lines
when
* closing the transport instead of when opening it.
This quirk is for Bluetooth 1.0b devices where theHCI_Resetbehavior was not clear or for devices that actually misbehave with the initialHCI_Reset.
In addition, you commit message is totally misleading. That is not what is happening with this quirk.
Regards
MarcelQuoted 4 lines
My intention was reset command is not required when we do an hci down.
this is because ofhdev->shutdownwill turn off the regulators.
It is like turning off the chip. sending reset command after turning off the chip is not required. I understand the usage of the quirk, will update the commit text.Quoted 10 lines
you are papering over the issue. Actually hci_serdev.c:hci_uart_register_device() is the culprit with the legacy code copied over from hci_ldisc.c:hci_uart_register_dev(). I think there is no point doing all this legacy line discipline quirk handling until it is really needed. The serdev drivers are all for recent hardware.
That said, having moved over to abtuart.capproach and killed the wholehci_serdev.cthing would have been a lot better here. You will keep running in weird situations where 18 year old code keeps surprising you.[Bala]: even i feel the same. they are lot such kind of HACK's we need to do with current arch.
when can we expectbtuart.cmerged to bt-next. i think having
btuart will helps us to have the control of
vendor porto's call's like inbtusb.cQuoted 5 lines
Quoted 2 lines
Quoted 2 lines
Regards
MarcelI need some clarification, do you expect some thing like this https://github.com/torvalds/linux/blob/master/drivers/bluetooth/btmtkuart.c for Qualcomm BT chip too. it looks it is completely avoided
hci_serdev.cinterface.you tell me actually. Are you using the H:4 transport or do you have an extra protocol layer / framing below it. If you do, then use your own driver, but if the transport is H:4 with vendor packets and vendor setup, then
btuart.c(which is not yet upstream) should be your target.For the MTK hardware it was obvious that it was better served as a separate driver. For QCA serial it really depends on how much extra protocol you have to run. So this might be an exercise in trying QCA serial as a separate driver and then go from there.
Quoted 6 lines
It is clear that the baggage from
hci_ldisc.cetc is in the way for serdev based systems.Regards
Marcel
[Bala]:
From my experience of serdev and ldisc, I prefer to go as MTK, here
are the reasons
1.If btuart maintains same generic way as hci_serdev, hardware
vendors will not have control on of
port opening and close. Because qca want to close port when we do
hci down where as hci_serdev it is not possible to do.
This is an important feature for power saving of the device.
2. I think btuart will have common recv_handle to handle all the
received data irrespective to the vendors.
but in our case, we will receive debug logs as ACL packet which
is not possible to bypass as diagnostic packet.
The same with the susb system restart events too. So, I feel that
having an different driver as same as MTK will help us.
Signature · 2 lines
Regards Balakrishna.
Re: [PATCH v1 1/4] Bluetooth: hci_qca: use wait_until_sent() for power pulses
In reply to Balakrishna GodavarthiQuoted 26 lines · Balakrishna Godavarthi
wcn3990 requires a power pulse to turn ON/OFF along with regulators. Sometimes we are observing the power pulses are sent out with some time delay, due to queuing these commands. This is causing synchronization issues with chip, which intern delay the chip setup or may end up with communication issues.
Signed-off-by Balakrishna Godavarthi <[email protected]>--- drivers/bluetooth/hci_qca.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)drivers/bluetooth/hci_qca.c +1
-2@@ -1016,8 +1016,7 @@ static inline void host_set_baudrate(struct hci_uart *hu, unsigned int speed)static int qca_send_power_pulse (struct hci_dev *hdev,u8 cmd) {struct hci_uart *hu =hci_get_drvdata (hdev); -struct qca_data *qca = hu->priv; -struct sk_buff *skb; +int ret;/* These power pulses are single byte command which are sent * at required baudrate to wcn3990. On wcn3990, we have an external
drivers/bluetooth/hci_qca.c static int qca_send_power_pulse(struct hci_dev *hdev, u8 cmd) · line 1033
Quoted 10 lines
drivers/bluetooth/hci_qca.c +1
-5@@ -1030,18 +1029,14 @@ static int qca_send_power_pulse(struct hci_dev *hdev, u8 cmd)* sending power pulses to SoC. */ bt_dev_dbg (hdev,"sending power pulse %02x to SoC" , cmd); - - skb =bt_skb_alloc (sizeof (cmd),GFP_KERNEL ); -if (!skb) -return -ENOMEM ; -hci_uart_set_flow_control (hu, true); + ret =serdev_device_write (hu->serdev, &cmd,sizeof (cmd),0 );
Don't you want a non-zero timeout here? Otherwise you might as well call serdev_device_write() directly.
Also have you made sure that serdev_device_write_wakeup() is called in the drivers write-wakeup callback as serdev_device_write() requires?
See this series in case what you really wanted was to wait indefinitely (you can use MAX_SCHEDULE_TIMEOUT):
https://lkml.kernel.org/r/<[email protected]>
Quoted 15 lines
drivers/bluetooth/hci_qca.c +5
-5+if (ret <0 ) { +bt_dev_err (hdev,"failed to send power pulse %02x to SoC" , cmd); +return ret; + } -skb_put_u8 (skb, cmd); -hci_skb_pkt_type (skb) =HCI_COMMAND_PKT ; - -skb_queue_tail (&qca->txq, skb); -hci_uart_tx_wakeup (hu); +serdev_device_wait_until_sent (hu->serdev,0 );/* Wait for 100 uS for SoC to settle down */ usleep_range (100 ,200 );
drivers/bluetooth/hci_qca.c static void qca_power_shutdown(struct hci_uart *hu) · line 1281
Quoted 5 lines
drivers/bluetooth/hci_qca.c +1
-1@@ -1283,7 +1278,8 @@ static void qca_power_shutdown(struct hci_uart *hu)host_set_baudrate (hu,2400 );hci_uart_set_flow_control (hu, true); -serdev_device_write_buf (serdev, &cmd,sizeof (cmd)); +serdev_device_write (serdev, &cmd,sizeof (cmd),0 );
Same here.
drivers/bluetooth/hci_qca.c static void qca_power_shutdown(struct hci_uart *hu) · line 1285
Quoted 4 lines
drivers/bluetooth/hci_qca.c +1
-0+serdev_device_wait_until_sent (serdev,0 );hci_uart_set_flow_control (hu, false);qca_power_setup (hu, false); }
Johan
Re: [PATCH v1 4/4] Bluetooth: hci_qca: Fix frame reassembly errors for wcn3990
In reply to Balakrishna GodavarthiQuoted 8 lines · Balakrishna Godavarthi
[ 176.929612] Bluetooth: hci_qca.c:qca_recv() hci0: Frame reassembly failed (-84) [ 176.945734] Bluetooth: hci_qca.c:qca_recv() hci0: Frame reassembly failed (-84) [ 176.953298] Bluetooth: hci_qca.c:qca_recv() hci0: Frame reassembly failed (-84) [ 177.010660] Bluetooth: hci_qca.c:qca_recv() hci0: Frame reassembly failed (-84) [ 177.067633] Bluetooth: hci_qca.c:qca_recv() hci0: Frame reassembly failed (-84)The above errors log on console due to receiving of stray bytes when wcn3990 boot up's i.e. when during initial setup procedure.
Please shortly introduce the topic instead of starting with the log messages.
Quoted 26 lines
Signed-off-by Balakrishna Godavarthi <[email protected]>--- drivers/bluetooth/hci_qca.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)drivers/bluetooth/hci_qca.c +2
-0@@ -56,6 +56,7 @@/* Controller states */ #define STATE_IN_BAND_SLEEP_ENABLED 1 +#define STATE_DISCARD_RX 2#define IBS_WAKE_RETRANS_TIMEOUT_MS 100#define IBS_TX_IDLE_TIMEOUT_MS 2000@@ -511,6 +512,7 @@ static int qca_open(struct hci_uart *hu) }else { hu->init_speed = qcadev->init_speed; hu->oper_speed = qcadev->oper_speed; +set_bit (STATE_DISCARD_RX , &qca->flags); ret =qca_power_setup (hu, true);if (ret) {destroy_workqueue (qca->workqueue);
drivers/bluetooth/hci_qca.c static int qca_recv(struct hci_uart *hu, const void *data, int count) · line 911
Quoted 7 lines
drivers/bluetooth/hci_qca.c +4
-0@@ -903,6 +905,13 @@ static int qca_recv(struct hci_uart *hu, const void *data, int count)if (!test_bit (HCI_UART_REGISTERED , &hu->flags))return -EUNATCH ; +/* We discard Rx data received while device is in booting +* stage, this is due multiple baudrate switch is causing +* UART to read some garbage data. +*/
This isn't entirely correct. I saw frame reassembly errors before qca_wcn3990_init() is called, i.e. no baudrate changes. Some of the garbage seems to be sent shortly after powering on the controller.
Quoted 26 lines
drivers/bluetooth/hci_qca.c +7
-1+if (test_bit (STATE_DISCARD_RX , &qca->flags)) +return 0 ; + qca->rx_skb =h4_recv_buf (hu->hdev, qca->rx_skb, data, count, qca_recv_pkts,ARRAY_SIZE (qca_recv_pkts));if (IS_ERR (qca->rx_skb)) {@@ -1192,10 +1201,12 @@ static int qca_setup(struct hci_uart *hu)set_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks);clear_bit (HCI_QUIRK_RESET_ON_CLOSE , &hdev->quirks); hu->hdev->shutdown = qca_power_off; + ret =qca_wcn3990_init (hu);if (ret)return ret; +clear_bit (STATE_DISCARD_RX , &qca->flags); ret =qca_read_soc_version (hdev, &soc_ver);if (ret)return ret;@@ -1278,8 +1289,15 @@ static void qca_power_shutdown(struct hci_uart *hu)struct serdev_device *serdev = hu->serdev;unsigned char cmd =QCA_WCN3990_POWEROFF_PULSE ; -host_set_baudrate (hu,2400 ); +/* From this point we go into power off state, +* disable IBS and discard all the queued data.
drivers/bluetooth/hci_qca.c static void qca_power_shutdown(struct hci_uart *hu) · line 1303
Quoted 10 lines
drivers/bluetooth/hci_qca.c +6
-0+*/ +clear_bit (STATE_IN_BAND_SLEEP_ENABLED , &qca->flags); +set_bit (STATE_DISCARD_RX , &qca->flags); +qca_flush (hu); +hci_uart_set_flow_control (hu, true); +host_set_baudrate (hu,2400 );serdev_device_write (serdev, &cmd,sizeof (cmd),0 );serdev_device_wait_until_sent (serdev,0 );hci_uart_set_flow_control (hu, false);
This change won't win a beauty price, but it seems it is needed to suppress the 'frame reassembly' spam, unless the controller can be convinced to stop sending garbage in the first place.
Re: [PATCH v1 4/4] Bluetooth: hci_qca: Fix frame reassembly errors for wcn3990
Hi Matthias,
Quoted 7 lines · Matthias Kaehlcke
Quoted 6 lines · Balakrishna Godavarthi
[ 176.929612] Bluetooth: hci_qca.c:qca_recv() hci0: Frame reassembly failed (-84) [ 176.945734] Bluetooth: hci_qca.c:qca_recv() hci0: Frame reassembly failed (-84) [ 176.953298] Bluetooth: hci_qca.c:qca_recv() hci0: Frame reassembly failed (-84) [ 177.010660] Bluetooth: hci_qca.c:qca_recv() hci0: Frame reassembly failed (-84) [ 177.067633] Bluetooth: hci_qca.c:qca_recv() hci0: Frame reassembly failed (-84)
Quoted 6 lines
Quoted 2 lines
The above errors log on console due to receiving of stray bytes when wcn3990 boot up's i.e. when during initial setup procedure.
Please shortly introduce the topic instead of starting with the log messages.
[Bala]: will update.
Quoted 30 lines
Quoted 30 lines
Signed-off-by Balakrishna Godavarthi <[email protected]>--- drivers/bluetooth/hci_qca.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)drivers/bluetooth/hci_qca.c +2
-0@@ -56,6 +56,7 @@/* Controller states */ #define STATE_IN_BAND_SLEEP_ENABLED 1 +#define STATE_DISCARD_RX 2#define IBS_WAKE_RETRANS_TIMEOUT_MS 100#define IBS_TX_IDLE_TIMEOUT_MS 2000@@ -511,6 +512,7 @@ static int qca_open(struct hci_uart *hu) }else { hu->init_speed = qcadev->init_speed; hu->oper_speed = qcadev->oper_speed; +set_bit (STATE_DISCARD_RX , &qca->flags); ret =qca_power_setup (hu, true);if (ret) {destroy_workqueue (qca->workqueue);@@ -903,6 +905,13 @@ static int qca_recv(struct hci_uart *hu, const void *data, int count)if (!test_bit (HCI_UART_REGISTERED , &hu->flags))return -EUNATCH ;
Quoted 9 lines
drivers/bluetooth/hci_qca.c static int qca_recv(struct hci_uart *hu, const void *data, int count) · line 911
Quoted 4 lines
drivers/bluetooth/hci_qca.c +4
-0+/* We discard Rx data received while device is in booting +* stage, this is due multiple baudrate switch is causing +* UART to read some garbage data. +*/ This isn't entirely correct. I saw frame reassembly errors before
qca_wcn3990_init()is called, i.e. no baudrate changes. Some of the garbage seems to be sent shortly after powering on the controller.
[Bala]: yes your correct, will update the comment.
Quoted 33 lines
Quoted 33 lines
drivers/bluetooth/hci_qca.c +3
-0+if (test_bit (STATE_DISCARD_RX , &qca->flags)) +return 0 ; + qca->rx_skb =h4_recv_buf (hu->hdev, qca->rx_skb, data, count, qca_recv_pkts,ARRAY_SIZE (qca_recv_pkts));drivers/bluetooth/hci_qca.c +9
-1if (IS_ERR (qca->rx_skb)) {@@ -1192,10 +1201,12 @@ static int qca_setup(struct hci_uart *hu)set_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks);clear_bit (HCI_QUIRK_RESET_ON_CLOSE , &hdev->quirks); hu->hdev->shutdown = qca_power_off; + ret =qca_wcn3990_init (hu);if (ret)return ret; +clear_bit (STATE_DISCARD_RX , &qca->flags); ret =qca_read_soc_version (hdev, &soc_ver);if (ret)return ret;@@ -1278,8 +1289,15 @@ static void qca_power_shutdown(struct hci_uart *hu)struct serdev_device *serdev = hu->serdev;unsigned char cmd =QCA_WCN3990_POWEROFF_PULSE ; -host_set_baudrate (hu,2400 ); +/* From this point we go into power off state, +* disable IBS and discard all the queued data. +*/ +clear_bit (STATE_IN_BAND_SLEEP_ENABLED , &qca->flags); +set_bit (STATE_DISCARD_RX , &qca->flags); +qca_flush (hu); +hci_uart_set_flow_control (hu, true);
Quoted 9 lines
Quoted 4 lines
drivers/bluetooth/hci_qca.c +1
-0+host_set_baudrate (hu,2400 );serdev_device_write (serdev, &cmd,sizeof (cmd),0 );serdev_device_wait_until_sent (serdev,0 );
hci_uart_set_flow_control(hu, false);This change won't win a beauty price, but it seems it is needed to suppress the 'frame reassembly' spam, unless the controller can be convinced to stop sending garbage in the first place.
[Bala]: This is due to serdev_open function call before we trun on the regulators.
where we don't have control over serdev open and close calls.
Quoted 1 line
Tested-by Matthias Kaehlcke <[email protected]>
[Bala]: Thanks for testing.
Signature · 2 lines
Regards Balakrishna.
Re: [PATCH v1 1/4] Bluetooth: hci_qca: use wait_until_sent() for power pulses
In reply to Johan HovoldHi Johan,
Quoted 34 lines · Johan Hovold
Quoted 33 lines · Balakrishna Godavarthi
wcn3990 requires a power pulse to turn ON/OFF along with regulators. Sometimes we are observing the power pulses are sent out with some time delay, due to queuing these commands. This is causing synchronization issues with chip, which intern delay the chip setup or may end up with communication issues.
Signed-off-by Balakrishna Godavarthi <[email protected]>--- drivers/bluetooth/hci_qca.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)drivers/bluetooth/hci_qca.c +1
-2@@ -1016,8 +1016,7 @@ static inline void host_set_baudrate(struct hci_uart *hu, unsigned int speed)static int qca_send_power_pulse (struct hci_dev *hdev,u8 cmd) {struct hci_uart *hu =hci_get_drvdata (hdev); -struct qca_data *qca = hu->priv; -struct sk_buff *skb; +int ret;/* These power pulses are single byte command which are sent drivers/bluetooth/hci_qca.c +0
-2* at required baudrate to wcn3990. On wcn3990, we have an external @@ -1030,18 +1029,14 @@ static int qca_send_power_pulse(struct hci_dev*hdev, u8 cmd) * sending power pulses to SoC. */ bt_dev_dbg (hdev,"sending power pulse %02x to SoC" , cmd); - - skb =bt_skb_alloc (sizeof (cmd),GFP_KERNEL );
Quoted 9 lines
drivers/bluetooth/hci_qca.c static int qca_send_power_pulse(struct hci_dev *hdev, u8 cmd) · line 1033
Quoted 5 lines
drivers/bluetooth/hci_qca.c +1
-3-if (!skb) -return -ENOMEM ; -hci_uart_set_flow_control (hu, true); + ret =serdev_device_write (hu->serdev, &cmd,sizeof (cmd),0 );Don't you want a non-zero timeout here? Otherwise you might as well call
serdev_device_write()directly.
[Bala]: we need an in definite timeout for these commands. will use HCI_UART_TX_WAKEUP.
Quoted 8 lines
Also have you made sure that
serdev_device_write_wakeup()is called in the drivers write-wakeup callback asserdev_device_write()requires?See this series in case what you really wanted was to wait indefinitely (you can use
MAX_SCHEDULE_TIMEOUT):https://lkml.kernel.org/r/<[email protected]>
[Bala]: thanks for pointers. from https://lore.kernel.org/patchwork/patch/1012358/
it was clear to me that i need call below functions in order to
wait until full data is sent.
serdev_device_write_wakeup()
serdev_device_write()
serdev_device_wait_until_sent()
correct me whether my understanding is correct.
Quoted 30 lines
Quoted 15 lines
drivers/bluetooth/hci_qca.c +5
-5+if (ret <0 ) { +bt_dev_err (hdev,"failed to send power pulse %02x to SoC" , cmd); +return ret; + } -skb_put_u8 (skb, cmd); -hci_skb_pkt_type (skb) =HCI_COMMAND_PKT ; - -skb_queue_tail (&qca->txq, skb); -hci_uart_tx_wakeup (hu); +serdev_device_wait_until_sent (hu->serdev,0 );/* Wait for 100 uS for SoC to settle down */ drivers/bluetooth/hci_qca.c +0
-0usleep_range (100 ,200 );drivers/bluetooth/hci_qca.c static void qca_power_shutdown(struct hci_uart · line 1282
Quoted 6 lines
drivers/bluetooth/hci_qca.c +1
-1@@ -1283,7 +1278,8 @@ static void qca_power_shutdown(struct hci_uart *hu)host_set_baudrate (hu,2400 );hci_uart_set_flow_control (hu, true); -serdev_device_write_buf (serdev, &cmd,sizeof (cmd)); +serdev_device_write (serdev, &cmd,sizeof (cmd),0 );Same here.
Quoted 4 lines
drivers/bluetooth/hci_qca.c +1
-0+serdev_device_wait_until_sent (serdev,0 );hci_uart_set_flow_control (hu, false);qca_power_setup (hu, false);}
Johan
Signature · 2 lines
Regards Balakrishna.
Re: [PATCH v1 1/4] Bluetooth: hci_qca: use wait_until_sent() for power pulses
Quoted 62 lines · Balakrishna Godavarthi
Hi Johan,
Quoted 34 lines · Johan Hovold
Quoted 33 lines · Balakrishna Godavarthi
wcn3990 requires a power pulse to turn ON/OFF along with regulators. Sometimes we are observing the power pulses are sent out with some time delay, due to queuing these commands. This is causing synchronization issues with chip, which intern delay the chip setup or may end up with communication issues.
Signed-off-by Balakrishna Godavarthi <[email protected]>--- drivers/bluetooth/hci_qca.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)drivers/bluetooth/hci_qca.c +1
-2@@ -1016,8 +1016,7 @@ static inline void host_set_baudrate(struct hci_uart *hu, unsigned int speed)static int qca_send_power_pulse (struct hci_dev *hdev,u8 cmd) {struct hci_uart *hu =hci_get_drvdata (hdev); -struct qca_data *qca = hu->priv; -struct sk_buff *skb; +int ret;/* These power pulses are single byte command which are sent drivers/bluetooth/hci_qca.c +0
-2* at required baudrate to wcn3990. On wcn3990, we have an external @@ -1030,18 +1029,14 @@ static int qca_send_power_pulse(struct hci_dev*hdev, u8 cmd) * sending power pulses to SoC. */ bt_dev_dbg (hdev,"sending power pulse %02x to SoC" , cmd); - - skb =bt_skb_alloc (sizeof (cmd),GFP_KERNEL );Quoted 8 lines
drivers/bluetooth/hci_qca.c static int qca_send_power_pulse(struct hci_dev *hdev, u8 cmd) · line 1033
Quoted 5 lines
drivers/bluetooth/hci_qca.c +1
-3-if (!skb) -return -ENOMEM ; -hci_uart_set_flow_control (hu, true); + ret =serdev_device_write (hu->serdev, &cmd,sizeof (cmd),0 );Don't you want a non-zero timeout here? Otherwise you might as well call
serdev_device_write()directly.[Bala]: we need an in definite timeout for these commands. will use
HCI_UART_TX_WAKEUP.Quoted 7 lines
Also have you made sure that
serdev_device_write_wakeup()is called in the drivers write-wakeup callback asserdev_device_write()requires?See this series in case what you really wanted was to wait indefinitely (you can use
MAX_SCHEDULE_TIMEOUT):https://lkml.kernel.org/r/<[email protected]>[Bala]: thanks for pointers. from
https://lore.kernel.org/patchwork/patch/1012358/
it was clear to me that i need call below functions in order to
wait until full data is sent.
Quoted 5 lines
serdev_device_write_wakeup()
serdev_device_write()
serdev_device_wait_until_sent()correct me whether my understanding is correct.
No, serdev_device_write_wakeup() needs to be called from the serdev driver's write_wakeup() callback (as defined in struct struct serdev_device_ops).
Either use serdev_device_write_wakeup() as the callback, or call it from your driver's custom write_wakeup() callback.
Hmm, I see now that the callbacks are set in hci_uart_register_device() to hci_serdev_client_ops, which is shared by all serdev BT drivers. You may be able to just add the call to the callback defined there so that all Bluetooth drivers can use serdev_device_write().
Johan