This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push: new f3945560c0 stm32f4/f7/h7_eth: Improvements in Ethernet DMA error handling. f3945560c0 is described below commit f3945560c0f5d6c15a3b86b9ca3278bb09676602 Author: Fotis Panagiotopoulos <f.pa...@amco.gr> AuthorDate: Thu Aug 3 19:05:18 2023 +0300 stm32f4/f7/h7_eth: Improvements in Ethernet DMA error handling. * Error handling for abnormal interrupts and DMA errors is now enabled for all builds, regardless of any DEBUG configuration. * Error handling resets the MAC for the specific errors that may halt the Ethernet operation, instead of everything as it was before. --- arch/arm/src/stm32/stm32_eth.c | 36 ++++++++++++++++++----------------- arch/arm/src/stm32f7/stm32_ethernet.c | 36 ++++++++++++++++++----------------- arch/arm/src/stm32h7/stm32_ethernet.c | 36 ++++++++++++++++++----------------- 3 files changed, 57 insertions(+), 51 deletions(-) diff --git a/arch/arm/src/stm32/stm32_eth.c b/arch/arm/src/stm32/stm32_eth.c index 149dcaf0a6..4acfa0af59 100644 --- a/arch/arm/src/stm32/stm32_eth.c +++ b/arch/arm/src/stm32/stm32_eth.c @@ -587,11 +587,7 @@ #define ETH_DMAINT_XMIT_ENABLE (ETH_DMAINT_NIS | ETH_DMAINT_TI) #define ETH_DMAINT_XMIT_DISABLE (ETH_DMAINT_TI) -#ifdef CONFIG_DEBUG_NET -# define ETH_DMAINT_ERROR_ENABLE (ETH_DMAINT_AIS | ETH_DMAINT_ABNORMAL) -#else -# define ETH_DMAINT_ERROR_ENABLE (0) -#endif +#define ETH_DMAINT_ERROR_ENABLE (ETH_DMAINT_AIS | ETH_DMAINT_ABNORMAL) /* Helpers ******************************************************************/ @@ -2043,21 +2039,27 @@ static void stm32_interrupt_work(void *arg) stm32_putreg(ETH_DMAINT_AIS, STM32_ETH_DMASR); - /* As per the datasheet's recommendation, the MAC - * needs to be reset for all abnormal events. The - * scheduled job will take the interface down and - * up again. - */ + /* In case of any error that stops the DMA, reset the MAC. */ - work_queue(ETHWORK, &priv->irqwork, stm32_txtimeout_work, priv, 0); + if (dmasr & (ETH_DMAINT_FBEI | ETH_DMAINT_RPSI | + ETH_DMAINT_TJTI | ETH_DMAINT_TPSI)) + { + /* As per the datasheet's recommendation, the MAC + * needs to be reset for all fatal errors. The + * scheduled job will take the interface down and + * up again. + */ - /* Interrupts need to remain disabled, no other - * processing will take place. After reset - * everything will be restored. - */ + work_queue(ETHWORK, &priv->irqwork, stm32_txtimeout_work, priv, 0); + + /* Interrupts need to remain disabled, no other + * processing will take place. After reset + * everything will be restored. + */ - net_unlock(); - return; + net_unlock(); + return; + } } net_unlock(); diff --git a/arch/arm/src/stm32f7/stm32_ethernet.c b/arch/arm/src/stm32f7/stm32_ethernet.c index d52ab837c3..5f4902e0ae 100644 --- a/arch/arm/src/stm32f7/stm32_ethernet.c +++ b/arch/arm/src/stm32f7/stm32_ethernet.c @@ -572,11 +572,7 @@ #define ETH_DMAINT_XMIT_ENABLE (ETH_DMAINT_NIS | ETH_DMAINT_TI) #define ETH_DMAINT_XMIT_DISABLE (ETH_DMAINT_TI) -#ifdef CONFIG_DEBUG_NET -# define ETH_DMAINT_ERROR_ENABLE (ETH_DMAINT_AIS | ETH_DMAINT_ABNORMAL) -#else -# define ETH_DMAINT_ERROR_ENABLE (0) -#endif +#define ETH_DMAINT_ERROR_ENABLE (ETH_DMAINT_AIS | ETH_DMAINT_ABNORMAL) /* Helpers ******************************************************************/ @@ -2133,21 +2129,27 @@ static void stm32_interrupt_work(void *arg) stm32_putreg(ETH_DMAINT_AIS, STM32_ETH_DMASR); - /* As per the datasheet's recommendation, the MAC - * needs to be reset for all abnormal events. The - * scheduled job will take the interface down and - * up again. - */ + /* In case of any error that stops the DMA, reset the MAC. */ - work_queue(ETHWORK, &priv->irqwork, stm32_txtimeout_work, priv, 0); + if (dmasr & (ETH_DMAINT_FBEI | ETH_DMAINT_RPSI | + ETH_DMAINT_TJTI | ETH_DMAINT_TPSI)) + { + /* As per the datasheet's recommendation, the MAC + * needs to be reset for all fatal errors. The + * scheduled job will take the interface down and + * up again. + */ - /* Interrupts need to remain disabled, no other - * processing will take place. After reset - * everything will be restored. - */ + work_queue(ETHWORK, &priv->irqwork, stm32_txtimeout_work, priv, 0); + + /* Interrupts need to remain disabled, no other + * processing will take place. After reset + * everything will be restored. + */ - net_unlock(); - return; + net_unlock(); + return; + } } net_unlock(); diff --git a/arch/arm/src/stm32h7/stm32_ethernet.c b/arch/arm/src/stm32h7/stm32_ethernet.c index 728dbacb87..b0d76c38db 100644 --- a/arch/arm/src/stm32h7/stm32_ethernet.c +++ b/arch/arm/src/stm32h7/stm32_ethernet.c @@ -578,11 +578,7 @@ #define ETH_DMAINT_XMIT_ENABLE (ETH_DMACIER_NIE | ETH_DMACIER_TIE) #define ETH_DMAINT_XMIT_DISABLE (ETH_DMACIER_TIE) -#ifdef CONFIG_DEBUG_NET -# define ETH_DMAINT_ERROR_ENABLE (ETH_DMACIER_AIE | ETH_DMAINT_ABNORMAL) -#else -# define ETH_DMAINT_ERROR_ENABLE (0) -#endif +#define ETH_DMAINT_ERROR_ENABLE (ETH_DMACIER_AIE | ETH_DMAINT_ABNORMAL) /* Helpers ******************************************************************/ @@ -2246,21 +2242,27 @@ static void stm32_interrupt_work(void *arg) stm32_putreg(ETH_DMACSR_AIS, STM32_ETH_DMACSR); - /* As per the datasheet's recommendation, the MAC - * needs to be reset for all abnormal events. The - * scheduled job will take the interface down and - * up again. - */ + /* In case of any error that stops the DMA, reset the MAC. */ - work_queue(ETHWORK, &priv->irqwork, stm32_txtimeout_work, priv, 0); + if (dmasr & (ETH_DMACIER_CDEE | ETH_DMACSR_FBE | + ETH_DMACSR_RPS | ETH_DMACSR_TPS)) + { + /* As per the datasheet's recommendation, the MAC + * needs to be reset for all fatal errors. The + * scheduled job will take the interface down and + * up again. + */ - /* Interrupts need to remain disabled, no other - * processing will take place. After reset - * everything will be restored. - */ + work_queue(ETHWORK, &priv->irqwork, stm32_txtimeout_work, priv, 0); + + /* Interrupts need to remain disabled, no other + * processing will take place. After reset + * everything will be restored. + */ - net_unlock(); - return; + net_unlock(); + return; + } } net_unlock();