Skip to content
Snippets Groups Projects
Commit a9e487b7 authored by Kamal Negi's avatar Kamal Negi
Browse files

fm: synchronize dequeue_fm_tx_cmd function

In dequeue_fm_tx_cmd function, there is race condition happened between
command credits decrement and event received for command sent. After
sending command to SoC, event received immediately and processed before
it decrement the command credits, hence command credits become zero and
it stuck in condition wait for command credits and FM failure happens.

Change-Id: Ibb2cf98ade08bbc9b25946d2368b1b7e428397bc
parent 67f115c0
Branches
No related tags found
No related merge requests found
......@@ -138,12 +138,11 @@ static void dequeue_fm_tx_cmd(struct fm_hci_t *hci)
}
pthread_mutex_unlock(&hci->tx_q_lock);
wait_for_cmd_credits:
pthread_mutex_lock(&hci->credit_lock);
wait_for_cmd_credits:
while (hci->command_credits == 0) {
pthread_cond_wait(&hci->cmd_credits_cond, &hci->credit_lock);
}
pthread_mutex_unlock(&hci->credit_lock);
/* Check if we really got the command credits */
if (hci->command_credits) {
......@@ -160,14 +159,18 @@ again:
count = 0;
/* Decrement cmd credits by '1' after sending the cmd*/
pthread_mutex_lock(&hci->credit_lock);
hci->command_credits--;
pthread_mutex_unlock(&hci->credit_lock);
if (temp->hdr)
free(temp->hdr);
free(temp);
} else {
if (!lib_running)
if (!lib_running) {
pthread_mutex_unlock(&hci->credit_lock);
break;
}
goto wait_for_cmd_credits;
}
pthread_mutex_unlock(&hci->credit_lock);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment