From patchwork Mon Nov 30 15:47:04 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 29111 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 02CF4C3300 for ; Mon, 30 Nov 2026 15:47:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0C4F46AA67; Mon, 30 Nov 2026 16:47:19 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="InW/C8hN"; dkim-atps=neutral Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D176A6AA45 for ; Mon, 30 Nov 2026 16:47:17 +0100 (CET) Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-4a35df85cc8so968044f8f.0 for ; Mon, 30 Nov 2026 07:47:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1796053637; x=1796658437; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=fHZ6zC/OJD4PS2dGwlUdRY5k1SZMmHqdWpwjLcc2/HY=; b=InW/C8hNBIFdvcmKjhT00j7ymL9CjUfEWdSiaDEOZ/qlOW/AiIBgrZqOtVp348OcDS j53StzbQYgdhj5T6+KG25vXBpLg7GZQlVil3CRZ1EwooxUDLGNQz+f3g1zQtlo4tsLs5 WY9PA3uAnktUAWj/l6MbepovCBr94vEDFS3ejI6DaPmCxL11rm0kWfFNELFfewb3zOUl INgjA6hretcr9lNQ6QUmeftt7sKgwPQq6wSBZGcgbQvjkl2msO2I/y+TmSEx5rz36oWC hBkOaNW1oAW9JeriA+tX9EDwUMl0fo2tiPQmCAFbjzTFFW5SgrtY3Gb+xLHbd/Q1fP2B SA2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796053637; x=1796658437; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=fHZ6zC/OJD4PS2dGwlUdRY5k1SZMmHqdWpwjLcc2/HY=; b=RJ1e2IO6adtcmuQEamGFyRQ/v5vO1C+o5AXrJO2SiiHqTUlovoDJAtnQDgarSB4Ett b8JKw8RPgszmw7DYUVBs3gVnSjUQxWdpFxwNt8zCU0r09pdQFt+kI+WOfXzHTbZrZZP9 YZmu1If2Zm4ZGncoBCRZM6gQCt+K2w7T4ccxNiyG5OwwVu9Rdj03VSUxdkWHUyQJdvMU 1Z1/Bz7QoN7Qr6hDUaNchuMm5k+O3olddX8ZKilqilW27JBRaZkRTlX/dEkuXEK8viqY vtpko1zPCqCQmr1JYPhQ8g7XkOHbB2AmR5Do3uSj4+pmtJmfhpwc/bHS4n6b8jsyED2g NGNQ== X-Gm-Message-State: APuU4Z/Xq0Q9WAbDQIYuoTux3eq8QBZ1EOYutnVzFgCq8nb9B6OBH7Mw c3yHU0H7x2Kksjvv5ISeyAVRNK2zrk3OsqvptXklEgxSHFhbI3tbzBgeekKZ8n9x9UpYmS81rE0 QrskoHCQ= X-Gm-Gg: AZFdTZfTdK2lnAF8be2U3/UJdiZU7XwOP9lY9VoWa72ZAaJIP2RDsGZNMmDSUnc/9QF G7VBBQDTHirxryKH21jnXzaRwmhtxx6+TwKLkQeJNRsaGNNh8fbMQh2R/a37m/+b/gfd0iyR1JQ FLRNzSmqPInRruVFdeGxHroMaUm3jGYZBm8nxcFrSsM2Mjov56dMJuj3GGa817OGHSU1s2g8fbr WQmP5lt29vatCu4SRuzM8m805w9WDRSAcE319oL0SVfpVVNvAHA8j2ROhALqFFWqL1DXOBPblxS 5eb5c5Nag4IqCW4WM9i7+UwetHuo9y2cKfFwq5jYQlnodmqSTdbDwh/Mgta89usNUjmVT7lBnUy TxyHL1pHTzhZk75GQKuwuAotgqVpEck9QSnx6i5pwLOBSUo1tDIpWiBMBjnw8NbhHvLqa6U0FSc TAc7jW6az0FpGBRWk4gWWcUL/Y9T5A1jIqw76PpDinKVbBqIXO4+/N5UP72Fqr+t7iIAD4fzyNX VqVGS+XkFbi/5odX4kzRebZa++hi4RdRbji1X88HDGTYivbF1SdD/0UAkvkk3toePvLYwQptrP1 p2H+/6zL2i2mz9lWrIo9HcAQ49uVxwxQ2JmZTy7YKQUixJ3eiyaS4PTOoKNfZ9EbXeC9ck3vj38 FNFuYjgpGTjvkYkJalNiEQeqYsZffPiamTd2mmJDz66c0nuKYZjz3PU3jfmx+2aDZHW+nLwaa+R Djpm0CdyxaDX1AEPlYT08fARk+GABejAAyLiXzhV+ChNlFqJlHwSBegYOwQKI8HmAKCqznLYyiH XIXZH9fMNSOFRpNg+vH X-Received: by 2002:a5d:5888:0:b0:49d:2e96:4d55 with SMTP id ffacd0b85a97d-4abb46bc931mr62003395f8f.6.1796053636510; Mon, 30 Nov 2026 07:47:16 -0800 (PST) Received: from naush-dell.patuck.org ([88.97.53.79]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4b8e564e39asm29532477f8f.57.2026.11.30.07.47.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 07:47:15 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: solomai , Naushir Patuck Subject: [PATCH v2] pipeline: rpi: pisp: Check the oldest CFE job in tryRunPipeline() Date: Mon, 30 Nov 2026 15:47:04 +0000 Message-ID: <20261130154713.55915-1-naush@raspberrypi.com> X-Mailer: git-send-email 2.53.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 From: solomai tryRunPipeline() runs the oldest job in cfeJobQueue_, but checks the newest one with cfeJobComplete(). If a CFE config buffer is dequeued after its image and stats buffers, a new empty job is pushed to the back of the queue. In turn, the now ready job is left waiting instead of being sent to the IPA and Backend until the next frame. Once every CFE image buffer is held by a waiting job, the CFE stalls and the camera stops silently. Fix this by passing the job to test into cfeJobComplete() so that tryRunPipeline() checks the oldest job and cfeBufferDequeue() the newest. Link: https://github.com/raspberrypi/libcamera/issues/369 Signed-off-by: Andrii Solomai Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- src/libcamera/pipeline/rpi/pisp/pisp.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/libcamera/pipeline/rpi/pisp/pisp.cpp b/src/libcamera/pipeline/rpi/pisp/pisp.cpp index 159c6b05ee7b..ee61992d3f8c 100644 --- a/src/libcamera/pipeline/rpi/pisp/pisp.cpp +++ b/src/libcamera/pipeline/rpi/pisp/pisp.cpp @@ -834,12 +834,8 @@ private: std::queue cfeJobQueue_; - bool cfeJobComplete() const + bool cfeJobComplete(const CfeJob &job) const { - if (cfeJobQueue_.empty()) - return false; - - const CfeJob &job = cfeJobQueue_.back(); return job.buffers.count(&cfe_[Cfe::Output0]) && job.buffers.count(&cfe_[Cfe::Stats]) && (!sensorMetadata_ || @@ -1733,7 +1729,7 @@ void PiSPCameraData::cfeBufferDequeue(FrameBuffer *buffer) } /* If the last CFE job has completed, we need a new job entry in the queue. */ - if (cfeJobQueue_.empty() || cfeJobComplete()) + if (cfeJobQueue_.empty() || cfeJobComplete(cfeJobQueue_.back())) cfeJobQueue_.push({}); CfeJob &job = cfeJobQueue_.back(); @@ -2337,8 +2333,16 @@ void PiSPCameraData::prepareBe(uint32_t bufferId, bool stitchSwapBuffers) void PiSPCameraData::tryRunPipeline() { - /* If any of our request or buffer queues are empty, we cannot proceed. */ - if (state_ != State::Idle || requestQueue_.empty() || !cfeJobComplete()) + /* + * If any of our request or buffer queues are empty, we cannot proceed. + * + * The job that gets run is the oldest one in the queue. The newest job + * may be incomplete (for example, holding only a config buffer that was + * dequeued after the image and stats buffers of its frame) while older + * jobs are ready to run. + */ + if (state_ != State::Idle || requestQueue_.empty() || + cfeJobQueue_.empty() || !cfeJobComplete(cfeJobQueue_.front())) return; CfeJob &job = cfeJobQueue_.front();