Skip to content

Commit 8b3b77e

Browse files
author
Frank Duerr
committed
drivers: ethernet: fixed calling mutex from ISR
The NXP ENET driver used a mutex inside an ISR. Since mutexes are not allowed in ISR, an assertion had been triggered. The mutex is not required since a semaphore ensures sequential writing (in ISR) and subsequent reading (after eth_wait_for_ptp_ts()). Fixed by removing calls to mutex. Signed-off-by: Frank Duerr <frank.duerr@ipvs.uni-stuttgart.de>
1 parent 021d90b commit 8b3b77e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/ethernet/eth_nxp_enet.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,16 @@ static inline void ts_register_tx_event(const struct device *dev,
164164

165165
if (pkt && atomic_get(&pkt->atomic_ref) > 0) {
166166
if (eth_get_ptp_data(net_pkt_iface(pkt), pkt) && frameinfo->isTsAvail) {
167-
k_mutex_lock(data->ptp.ptp_mutex, K_FOREVER);
168-
167+
/* Timestamp is written to packet in ISR.
168+
* Semaphore ensures sequential execution of writing
169+
* the timestamp here and subsequently reading the timestamp
170+
* after waiting for the semaphore in eth_wait_for_ptp_ts().
171+
*/
169172
pkt->timestamp.nanosecond = frameinfo->timeStamp.nanosecond;
170173
pkt->timestamp.second = frameinfo->timeStamp.second;
171174

172175
net_if_add_tx_timestamp(pkt);
173176
k_sem_give(&data->ptp.ptp_ts_sem);
174-
175-
k_mutex_unlock(data->ptp.ptp_mutex);
176177
}
177178
net_pkt_unref(pkt);
178179
}

0 commit comments

Comments
 (0)