Hi Simon,

On 05.08.22 18:48, Simon Glass wrote:
Hi Stefan,

On Fri, 5 Aug 2022 at 08:26, Stefan Roese <s...@denx.de> wrote:

Add the basic infrastructure to periodically execute code, e.g. all
100ms. Examples for such functions might be LED blinking etc. The
functions that are hooked into this cyclic list should be small timewise
as otherwise the execution of the other code that relies on a high
frequent polling (e.g. UART rx char ready check) might be delayed too
much. This patch also adds the Kconfig option
CONFIG_CYCLIC_MAX_CPU_TIME_US, which configures the max allowed time
for such a cyclic function. If it's execution time exceeds this time,
this cyclic function will get removed from the cyclic list.

How is this cyclic functionality executed?
The following patch integrates the main function responsible for
calling all registered cyclic functions cyclic_run() into the
common WATCHDOG_RESET macro. This guarantees that cyclic_run() is
executed very often, which is necessary for the cyclic functions to
get scheduled and executed at their configured periods.

This cyclic infrastructure will be used by a board specific function on
the NIC23 MIPS Octeon board, which needs to check periodically, if a
PCIe FLR has occurred.

Signed-off-by: Stefan Roese <s...@denx.de>
---
v3:
- No change
v2:
- Also add cyclic_register() and cyclic_unregister() as empty functions
   when CONFIG_CYCLIC is not defined
- Misc minor changes

  MAINTAINERS      |   6 +++
  common/Kconfig   |  20 +++++++++
  common/Makefile  |   1 +
  common/cyclic.c  | 112 +++++++++++++++++++++++++++++++++++++++++++++++
  include/cyclic.h |  97 ++++++++++++++++++++++++++++++++++++++++
  5 files changed, 236 insertions(+)
  create mode 100644 common/cyclic.c
  create mode 100644 include/cyclic.h

Reviewed-by: Simon Glass <s...@chromium.org>

Can you document cyclic_struct - and perhaps 'struct cyclic_info' for
'struct cyclic' would be better so we don't have 'struct' in a struct?

Agreed. My word choice was definitely not optimal. Will change in the
next version.

Thanks,
Stefan

Reply via email to