drivers: NXP ENET: fix for issue mutex called from ISR #89443
+5
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #89442
The NXP ENET driver uses a mutex inside an ISR.
Function ts_register_tx_event() (source file zephyr/drivers/ethernet/eth_nxp_enet.c) is invoked from the ISR when a TX packet timestamp is available. Before the timestamp is copied to the packet, a mutex is locked, most likely to protect the timestamp from concurrent read/write operations. Since mutexes are not allowed in ISR, the following assertion is triggered (when compiled with assertions):
The problem can be fixed by simply removing the calls to the mutex in ts_register_tx_event() since the timestamp is also protected from concurrent read operations using a semaphore (ptp_ts_sem), which is only released after copying the timestamp to the packet. This semaphore ptp_ts_sem ensures sequential execution of writing the timestamp in ts_register_tx_event() (inside the ISR) and subsequently reading the timestamp after waiting for the semaphore ptp_ts_sem in eth_wait_for_ptp_ts().