Skip to content

Commit e6adfc6

Browse files
committed
eth_nxp_enet_qos: Turn on interrupt after init
Don't enable interrupt until after init because there can be a interrupt mistakenly happen during the init process which can cause various problems. Along similar lines, avoid issue for sporadic TX interrupt with no packet in tx done handler. Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
1 parent 1c35874 commit e6adfc6

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

drivers/ethernet/eth_nxp_enet_qos/eth_nxp_enet_qos_mac.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,12 @@ static void tx_dma_done(const struct device *dev)
156156
struct net_pkt *pkt = tx_data->pkt;
157157
struct net_buf *fragment = pkt->frags;
158158

159-
LOG_DBG("TX DMA completed on packet %p", pkt);
159+
if (pkt == NULL) {
160+
LOG_DBG("%s TX DMA done on nonexistent packet?", dev->name);
161+
goto skip;
162+
} else {
163+
LOG_DBG("TX DMA completed on packet %p", pkt);
164+
}
160165

161166
/* Returning the buffers and packet to the pool */
162167
while (fragment != NULL) {
@@ -169,6 +174,7 @@ static void tx_dma_done(const struct device *dev)
169174

170175
eth_stats_update_pkts_tx(data->iface);
171176

177+
skip:
172178
/* Allows another send */
173179
k_sem_give(&data->tx.tx_sem);
174180
LOG_DBG("Gave driver TX sem %p by thread %s", &data->tx.tx_sem,
@@ -794,13 +800,6 @@ static int eth_nxp_enet_qos_mac_init(const struct device *dev)
794800
break;
795801
}
796802

797-
/* This driver cannot work without interrupts. */
798-
if (config->irq_config_func) {
799-
config->irq_config_func();
800-
} else {
801-
return -ENOSYS;
802-
}
803-
804803
/* Effectively reset of the peripheral */
805804
ret = enet_qos_dma_reset(base);
806805
if (ret) {
@@ -849,6 +848,13 @@ static int eth_nxp_enet_qos_mac_init(const struct device *dev)
849848
/* Work upon a reception of a packet to a buffer */
850849
k_work_init(&data->rx.rx_work, eth_nxp_enet_qos_rx);
851850

851+
/* This driver cannot work without interrupts. */
852+
if (config->irq_config_func) {
853+
config->irq_config_func();
854+
} else {
855+
return -ENOSYS;
856+
}
857+
852858
return ret;
853859
}
854860

0 commit comments

Comments
 (0)