Skip to content

Commit 9cca493

Browse files
shuaz-shuaiche-jiang
authored andcommitted
Bluetooth: hci_qca: Convert timeout from jiffies to ms
Since the timer uses jiffies as its unit rather than ms, the timeout value must be converted from ms to jiffies when configuring the timer. Otherwise, the intended 8s timeout is incorrectly set to approximately 33s. To improve readability, embed msecs_to_jiffies() directly in the macro definitions and drop the _MS suffix from macros that now yield jiffies values: MEMDUMP_TIMEOUT, FW_DOWNLOAD_TIMEOUT, IBS_DISABLE_SSR_TIMEOUT, CMD_TRANS_TIMEOUT, and IBS_BTSOC_TX_IDLE_TIMEOUT. IBS_WAKE_RETRANS_TIMEOUT_MS and IBS_HOST_TX_IDLE_TIMEOUT_MS are intentionally left unchanged. Their values are stored in the struct fields wake_retrans and tx_idle_delay, which hold ms values at runtime and can be modified via debugfs. The msecs_to_jiffies() conversion happens at each call site against the field value, so it cannot be embedded in the macro. Depends on commit c347ca1 ("Bluetooth: hci_qca: Fix missing wakeup during SSR memdump handling"). Cc: stable@vger.kernel.org Fixes: d841502 ("Bluetooth: hci_qca: Collect controller memory dump during SSR") Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de> Acked-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Signed-off-by: Shuai Zhang <shuai.zhang@oss.qualcomm.com>
1 parent 10b91ca commit 9cca493

1 file changed

Lines changed: 16 additions & 17 deletions

File tree

drivers/bluetooth/hci_qca.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,12 @@
4848
#define HCI_MAX_IBS_SIZE 10
4949

5050
#define IBS_WAKE_RETRANS_TIMEOUT_MS 100
51-
#define IBS_BTSOC_TX_IDLE_TIMEOUT_MS 200
51+
#define IBS_BTSOC_TX_IDLE_TIMEOUT msecs_to_jiffies(200)
5252
#define IBS_HOST_TX_IDLE_TIMEOUT_MS 2000
53-
#define CMD_TRANS_TIMEOUT_MS 100
54-
#define MEMDUMP_TIMEOUT_MS 8000
55-
#define IBS_DISABLE_SSR_TIMEOUT_MS \
56-
(MEMDUMP_TIMEOUT_MS + FW_DOWNLOAD_TIMEOUT_MS)
57-
#define FW_DOWNLOAD_TIMEOUT_MS 3000
53+
#define CMD_TRANS_TIMEOUT msecs_to_jiffies(100)
54+
#define MEMDUMP_TIMEOUT msecs_to_jiffies(8000)
55+
#define FW_DOWNLOAD_TIMEOUT msecs_to_jiffies(3000)
56+
#define IBS_DISABLE_SSR_TIMEOUT (MEMDUMP_TIMEOUT + FW_DOWNLOAD_TIMEOUT)
5857

5958
/* susclk rate */
6059
#define SUSCLK_RATE_32KHZ 32768
@@ -1096,7 +1095,7 @@ static void qca_controller_memdump(struct work_struct *work)
10961095

10971096
queue_delayed_work(qca->workqueue,
10981097
&qca->ctrl_memdump_timeout,
1099-
msecs_to_jiffies(MEMDUMP_TIMEOUT_MS));
1098+
MEMDUMP_TIMEOUT);
11001099
skb_pull(skb, sizeof(qca_memdump->ram_dump_size));
11011100
qca_memdump->current_seq_no = 0;
11021101
qca_memdump->received_dump = 0;
@@ -1369,7 +1368,7 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate)
13691368

13701369
if (hu->serdev)
13711370
serdev_device_wait_until_sent(hu->serdev,
1372-
msecs_to_jiffies(CMD_TRANS_TIMEOUT_MS));
1371+
CMD_TRANS_TIMEOUT);
13731372

13741373
/* Give the controller time to process the request */
13751374
switch (qca_soc_type(hu)) {
@@ -1401,8 +1400,8 @@ static inline void host_set_baudrate(struct hci_uart *hu, unsigned int speed)
14011400

14021401
static int qca_send_power_pulse(struct hci_uart *hu, bool on)
14031402
{
1403+
int timeout = CMD_TRANS_TIMEOUT;
14041404
int ret;
1405-
int timeout = msecs_to_jiffies(CMD_TRANS_TIMEOUT_MS);
14061405
u8 cmd = on ? QCA_WCN3990_POWERON_PULSE : QCA_WCN3990_POWEROFF_PULSE;
14071406

14081407
/* These power pulses are single byte command which are sent
@@ -1607,7 +1606,7 @@ static void qca_wait_for_dump_collection(struct hci_dev *hdev)
16071606
struct qca_data *qca = hu->priv;
16081607

16091608
wait_on_bit_timeout(&qca->flags, QCA_MEMDUMP_COLLECTION,
1610-
TASK_UNINTERRUPTIBLE, MEMDUMP_TIMEOUT_MS);
1609+
TASK_UNINTERRUPTIBLE, MEMDUMP_TIMEOUT);
16111610

16121611
clear_bit(QCA_MEMDUMP_COLLECTION, &qca->flags);
16131612
}
@@ -2591,7 +2590,7 @@ static void qca_serdev_remove(struct serdev_device *serdev)
25912590
static void qca_serdev_shutdown(struct serdev_device *serdev)
25922591
{
25932592
int ret;
2594-
int timeout = msecs_to_jiffies(CMD_TRANS_TIMEOUT_MS);
2593+
int timeout = CMD_TRANS_TIMEOUT;
25952594
struct qca_serdev *qcadev = serdev_device_get_drvdata(serdev);
25962595
struct hci_uart *hu = &qcadev->serdev_hu;
25972596
struct hci_dev *hdev = hu->hdev;
@@ -2648,7 +2647,7 @@ static int __maybe_unused qca_suspend(struct device *dev)
26482647
bool tx_pending = false;
26492648
int ret = 0;
26502649
u8 cmd;
2651-
u32 wait_timeout = 0;
2650+
unsigned long wait_timeout = 0;
26522651

26532652
set_bit(QCA_SUSPENDING, &qca->flags);
26542653

@@ -2669,15 +2668,15 @@ static int __maybe_unused qca_suspend(struct device *dev)
26692668
if (test_bit(QCA_IBS_DISABLED, &qca->flags) ||
26702669
test_bit(QCA_SSR_TRIGGERED, &qca->flags)) {
26712670
wait_timeout = test_bit(QCA_SSR_TRIGGERED, &qca->flags) ?
2672-
IBS_DISABLE_SSR_TIMEOUT_MS :
2673-
FW_DOWNLOAD_TIMEOUT_MS;
2671+
IBS_DISABLE_SSR_TIMEOUT :
2672+
FW_DOWNLOAD_TIMEOUT;
26742673

26752674
/* QCA_IBS_DISABLED flag is set to true, During FW download
26762675
* and during memory dump collection. It is reset to false,
26772676
* After FW download complete.
26782677
*/
26792678
wait_on_bit_timeout(&qca->flags, QCA_IBS_DISABLED,
2680-
TASK_UNINTERRUPTIBLE, msecs_to_jiffies(wait_timeout));
2679+
TASK_UNINTERRUPTIBLE, wait_timeout);
26812680

26822681
if (test_bit(QCA_IBS_DISABLED, &qca->flags)) {
26832682
bt_dev_err(hu->hdev, "SSR or FW download time out");
@@ -2729,7 +2728,7 @@ static int __maybe_unused qca_suspend(struct device *dev)
27292728

27302729
if (tx_pending) {
27312730
serdev_device_wait_until_sent(hu->serdev,
2732-
msecs_to_jiffies(CMD_TRANS_TIMEOUT_MS));
2731+
CMD_TRANS_TIMEOUT);
27332732
serial_clock_vote(HCI_IBS_TX_VOTE_CLOCK_OFF, hu);
27342733
}
27352734

@@ -2738,7 +2737,7 @@ static int __maybe_unused qca_suspend(struct device *dev)
27382737
*/
27392738
ret = wait_event_interruptible_timeout(qca->suspend_wait_q,
27402739
qca->rx_ibs_state == HCI_IBS_RX_ASLEEP,
2741-
msecs_to_jiffies(IBS_BTSOC_TX_IDLE_TIMEOUT_MS));
2740+
IBS_BTSOC_TX_IDLE_TIMEOUT);
27422741
if (ret == 0) {
27432742
ret = -ETIMEDOUT;
27442743
goto error;

0 commit comments

Comments
 (0)