Skip to content

i3c: stm32: Prevent mutex deadlock on DAA failure #93233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions drivers/i3c/i3c_stm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,7 @@ static int i3c_stm32_do_daa(const struct device *dev)
const struct i3c_stm32_config *config = dev->config;
struct i3c_stm32_data *data = dev->data;
I3C_TypeDef *i3c = config->i3c;
int ret = 0;

k_mutex_lock(&data->bus_mutex, K_FOREVER);

Expand All @@ -1068,20 +1069,23 @@ static int i3c_stm32_do_daa(const struct device *dev)

/* Wait for DAA to finish */
if (k_sem_take(&data->device_sync_sem, STM32_I3C_TRANSFER_TIMEOUT) != 0) {
return -ETIMEDOUT;
ret = -ETIMEDOUT;
goto i3c_stm32_do_daa_ending;
}

if (data->msg_state == STM32_I3C_MSG_ERR) {
i3c_stm32_clear_err(dev, false);
/* Enable TXFNF interrupt in case an error occurred before it was enabled by RXFNE
*/
LL_I3C_EnableIT_TXFNF(i3c);
return -EIO;
ret = -EIO;
goto i3c_stm32_do_daa_ending;
}

i3c_stm32_do_daa_ending:
k_mutex_unlock(&data->bus_mutex);

return 0;
return ret;
}

#ifdef CONFIG_I3C_STM32_DMA
Expand Down