From patchwork Wed Jan 7 19:55:37 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 25688 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 3C0E1BE08B for ; Wed, 7 Jan 2026 19:55:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8AEBE61FC1; Wed, 7 Jan 2026 20:55:43 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="tinc+Geq"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8803961F84 for ; Wed, 7 Jan 2026 20:55:41 +0100 (CET) Received: from pb-laptop.local (185.221.143.114.nat.pool.zt.hu [185.221.143.114]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 65591593; Wed, 7 Jan 2026 20:55:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1767815719; bh=yQ1gY7e5zWz5sEJukYfQHDU1ZcmG25A/BwUdzfy2BJU=; h=From:To:Cc:Subject:Date:From; b=tinc+GeqZ06hzbZLChOhngkr06XM2AEX/kEj7U3zKqp3mOiXOeuvFZHYn9FAeAJqc AvSG1rcIRHQ+pa+3xOL1B+kSleY1mJ3gualr6nfX0dxB+4mK2VkVVGP5dOcPGtquWr EDQaDiAYKhS6IA6SMuCVs2WLFp2xn3mTToF/Lz4o= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Cc: Naushir Patuck , David Plowman Subject: [PATCH v1] libcamera: base: event_dispatcher_poll: Dispatch `POLLPRI` first Date: Wed, 7 Jan 2026 20:55:37 +0100 Message-ID: <20260107195537.2180637-1-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.52.0 MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" When `poll()` returns multiple events for a given file descriptor, 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 Reviewed-by: Laurent Pinchart --- src/libcamera/base/event_dispatcher_poll.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/base/event_dispatcher_poll.cpp b/src/libcamera/base/event_dispatcher_poll.cpp index 52bfb34e2..006e223f8 100644 --- a/src/libcamera/base/event_dispatcher_poll.cpp +++ b/src/libcamera/base/event_dispatcher_poll.cpp @@ -244,9 +244,9 @@ void EventDispatcherPoll::processNotifiers(const std::vector &pol EventNotifier::Type type; short events; } events[] = { + { EventNotifier::Exception, POLLPRI }, { EventNotifier::Read, POLLIN }, { EventNotifier::Write, POLLOUT }, - { EventNotifier::Exception, POLLPRI }, }; processingEvents_ = true;