libcamera: base: event_dispatcher_poll: Dispatch POLLPRI first

When `poll()` returns multiple events for a given file descriptor, while there
is no general rule that requires it, for the use cases of libcamera, it is
better to service priority events first. So dispatch those first, and not last.

For example, a V4L2 capture device might be a source of V4L2 events (e.g. frame
start) as well as a source of dequeue-able buffers. In such cases, given the
appropriate scheduling, it is possible with the current event dispatch order
that dequeueing the buffer happens before processing the corresponding frame
start event. Such occurrence will most likely trip up any internal state machine.

The above is suspected to contribute to [0], however, that is not confirmed.

[0]: https://gitlab.freedesktop.org/camera/libcamera/-/issues/267

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
This commit is contained in:
Barnabás Pőcze
2026-01-06 13:11:57 +01:00
parent 993496ba35
commit fa22b4ffef

View File

@@ -244,9 +244,9 @@ void EventDispatcherPoll::processNotifiers(const std::vector<struct pollfd> &pol
EventNotifier::Type type;
short events;
} events[] = {
{ EventNotifier::Exception, POLLPRI },
{ EventNotifier::Read, POLLIN },
{ EventNotifier::Write, POLLOUT },
{ EventNotifier::Exception, POLLPRI },
};
processingEvents_ = true;