Re: EFI Group Event Callback Order


Laszlo Ersek
 

On 01/17/20 14:24, Li, Walon wrote:
Laszlo,

Yes, we can specific TPL to adjust callback order. But sometimes, an
event has many callbacks like as ReadyToBoot and TPL level may not
satisfy purpose. In UEFI spec CreateEvent chapter, also mentioned
"The functions in these queues are invoked in FIFO order". So, if it
define clearly in UEFI spec, LIFO or FIFO, we may use driver
dependency to decide which driver's event registration priority and
specific callback order indirectly.
The FIFO order refers to something else. Here's a larger citation:

When the event is signaled, firmware changes its state to “signaled”
and, if EVT_NOTIFY_SIGNAL is specified, places a call to its
notification function in a FIFO queue. There is a queue for each of
the “basic” task priority levels defined in Section 7.1
(TPL_CALLBACK, and TPL_NOTIFY). The functions in these queues are
invoked in FIFO order, starting with the highest priority level
queue and proceeding to the lowest priority queue that is unmasked
by the current TPL.

It means that, within a given TPL, the notification function invocation
order will reflect the enqueueing (= signaling) order.

But the spec does not specify the *signaling* order for such events that
belong to the same event group, when one of those events is signaled.
The spec says,

Event groups are collections of events identified by a shared
EFI_GUID where, when one member event is signaled, all other events
are signaled and their individual notification actions are taken (as
described in CreateEvent). All events are guaranteed to be signaled
before the first notification action is taken. All notification
functions will be executed in the order specified by their
NotifyTpl.

So if you have two events, A and B, and they belong to the same event
group G, and NotifyTpl is the same for both, then if you signal either A
or B, then the notification functions may be queued, *and invoked*, in
either (A, B), or (B, A), order. The invocation order will reflect the
queueing order, yes, but the latter is unspecified, when you go through
an event group.

Thanks
Laszlo

Join discuss@edk2.groups.io to automatically receive all group messages.