The PR which solved the interaction between main thread and error generation: https://github.com/apache/nuttx/pull/8060
This affects the stm32 CAN driver, actually. I mentioned s32x_error() because we have ported the error generation code to the s32k1xx CAN driver, because we needed that. The drivers are quite similar, so error generation (which is only present in base stm32 drivers) can be ported quickly to stm32h7 and s32k1xx. We have done both. But this problem is present on the base stm32 CAN driver. Mateusz (raiden00pl) you might want to have a look. Thanks, Carlos On Wed, Jan 4, 2023 at 2:56 PM Carlos Sanchez <carlossanc...@geotab.com> wrote: > Hi Peter, > > >> It seems that calling can_input directly from IRQ got broken since the >> IOB rewrite. >> Before can_input only used dev->d_appdata, but now can_input overwrites >> the dev->d_buf pointer as well. >> >> https://github.com/apache/nuttx/blob/779a610ca3ba495640b49d6c36bce89784955e0d/net/can/can_input.c#L231 >> dev- >> <https://github.com/apache/nuttx/blob/779a610ca3ba495640b49d6c36bce89784955e0d/net/can/can_input.c#L231dev->>d_len >> always has been fixed to sizeof(struct can_frame) or sizeof(struct >> canfd_frame) depending on kconfig setting. >> > > Please note dev->d_len might change depending on the timestamping setting > for each socket. > > Short term you could either go back to an older version of NuttX, or try >> to schedule the workqueue for can_input and see if you can enough >> throughput. >> > > I have added net_lock()/net_unlock() around s32k1xx_error() call and this > solves the interaction between the application thread and CANWORK thread > for error frame injection. Other _work handlers do lock the network, so I > think this just slipped by and it should have been there since the > beginning. I have found a couple of other problems in the driver, I > will create a PR with all this. > > The interactions with interrupts are a little bit more problematic, though. > > Best regards, > > Carlos > > -- > > Carlos Sanchez (he, him, his) > Geotab > > Embedded Systems Developer Team Lead | Europe > > Visit > > www.geotab.com > > Twitter <https://twitter.com/geotab> | Facebook > <https://www.facebook.com/Geotab> | YouTube > <https://www.youtube.com/user/MyGeotab> | LinkedIn > <https://www.linkedin.com/company/geotab/> > -- Carlos Sanchez (he, him, his) Geotab Embedded Systems Developer Team Lead | Europe Visit www.geotab.com Twitter <https://twitter.com/geotab> | Facebook <https://www.facebook.com/Geotab> | YouTube <https://www.youtube.com/user/MyGeotab> | LinkedIn <https://www.linkedin.com/company/geotab/>