[PATCH v2 05/13] event: Add basic support for events

Simon Glass sjg at chromium.org
Tue Mar 8 17:05:33 CET 2022


Hi Takahiro,

On Sun, 6 Mar 2022 at 21:26, AKASHI Takahiro <takahiro.akashi at linaro.org> wrote:
>
> Hi Simon,
>
> On Fri, Mar 04, 2022 at 08:43:00AM -0700, Simon Glass wrote:
> > Add a way to create and dispatch events without needing to allocate
> > memory. Also add a way to 'spy' on events, thus allowing 'hooks' to be
> > created.
> >
> > Use a linker list for static events, which we can use to replace functions
> > like arch_cpu_init_f(). Allow an EVENT_DEBUG option which makes it
> > easier to see what is going on at runtime, but uses more code space.
> >
> > Dynamic events allow the creation of a spy at runtime. This is not always
> > necessary, but can be enabled with EVENT_DYNAMIC if needed.
> >
> > A 'test' event is the only option for now.
> >
> > Signed-off-by: Simon Glass <sjg at chromium.org>
> > ---
> >
> > Changes in v2:
> > - Add a 'used' attribute to avoid LTO dropping the code
> >
> >  MAINTAINERS                       |   6 +
> >  common/Kconfig                    |  31 +++++
> >  common/Makefile                   |   2 +
> >  common/board_r.c                  |   1 +
> >  common/event.c                    | 186 +++++++++++++++++++++++++++++
> >  common/log.c                      |   1 +
> >  include/asm-generic/global_data.h |  13 +++
> >  include/event.h                   | 188 ++++++++++++++++++++++++++++++
> >  include/event_internal.h          |  35 ++++++
> >  include/log.h                     |   2 +
> >  10 files changed, 465 insertions(+)
> >  create mode 100644 common/event.c
> >  create mode 100644 include/event.h
> >  create mode 100644 include/event_internal.h
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index fb171e0c68..b534ad66b9 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -809,6 +809,12 @@ S:       Maintained
> >  F:   doc/usage/environment.rst
> >  F:   scripts/env2string.awk
> >
> > +EVENTS
> > +M:   Simon Glass <sjg at chromium.org>
> > +S:   Maintained
> > +F:   common/event.c
> > +F:   include/event.h
> > +
> >  FASTBOOT
> >  S:   Orphaned
> >  F:   cmd/fastboot.c
> > diff --git a/common/Kconfig b/common/Kconfig
> > index 82cd864baf..76c04b2001 100644
> > --- a/common/Kconfig
> > +++ b/common/Kconfig
> > @@ -492,6 +492,37 @@ config DISPLAY_BOARDINFO_LATE
> >
> >  menu "Start-up hooks"
> >
> > +config EVENT
> > +     bool "General-purpose event-handling mechanism"
>
> I don't think that this config option needs to be visible (or user-selectable).
> Instead, any subsystem that needs it should explicitly select it.
> I prefer that subsystem can add "select EVENT or DM_EVENT" rather than
> "imply" or "depends on".

But events can be added for other reasons. For example a board may
want to detect that a USB controller is about to be probed and enable
power to devices on that USB bus so that the devices are enumerated.
This series is partly about replacing all the various hooks we
currently have but goes further than that.

[..]

Regards,
Simon


More information about the U-Boot mailing list