From patchwork Tue Nov 24 10:54:27 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 29078 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 DE7F8BDE17 for ; Tue, 24 Nov 2026 10:54:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 00D866A9B9; Tue, 24 Nov 2026 11:54:45 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Ddhss1KI"; dkim-atps=neutral Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CB84A6A8C7 for ; Tue, 24 Nov 2026 11:54:44 +0100 (CET) Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-48df160bb9cso204721f8f.1 for ; Tue, 24 Nov 2026 02:54:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1795517684; x=1796122484; 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=DRP3JfKSFJ+HI3JgXul4gBeAdbZD3IbJfRnwEqChYrk=; b=Ddhss1KIXp2coE5KgjpBVNVmneL1ygBNPzt/1chHiC11DMSha9+ZrHEM3RLNcgi/LB nQfC46kBpN2OnfecMng7C2jlUjfTE9IJm9tuChSXxEz2f3j25HlNjpxH2xTGv/CyO4HT KflV1AClDb6+N8yJkBlzArhEEE6AcXcTVasSoJJ/byfAWN0u9VC1AtY3XgCKAnOIyFUp Yfrmbe796VdPHXo3p8tFJDLRGslaBc75/wkUfUWc7DtAbYtEF/r4vKDC0yo/O5XeSeqb OzkNhMhu5B/kb1KEwuJHNxkSEaK5rZUATYLerDV6KeAIMgF1jCAwzrqNGR2NrGRBW68Z cCQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795517684; x=1796122484; 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=DRP3JfKSFJ+HI3JgXul4gBeAdbZD3IbJfRnwEqChYrk=; b=1RHugh1E3OcLMCilLRnfnNxgAIBDwawo0CTxrWyaFdMptOMwEH1P/fz2uJ4dQRznfl fmEXLvCgdzCIc7W7fKyjtPt5gIXmTQg8C19q1uzuxYfnNgXmltJIGMJ0jbmqM8GZD0Jh BY6MIKNxlD7n32cZUJjVH8URoceQYlRAXsfQEoU98xfUtog+1yXmfUrNFzYbUbedFL2T 3aHaLvNnbfsQf+CPZsVO552++cTOobTNM+cTL0flOXa4Q3t3glJExSCDRm8W8wQiWJbs a9pNSoRF64igmeEAP8JTD9yDKd5riOxFTeKtIJ5ZhUf9SFL6NVIjuM8cmG0y6B5JtNhs v9rA== X-Gm-Message-State: APuU4Z80k9Yz5JrvhaZaF0d9Qvows6mCMhacmbmfHljjf/RaMaoLKLyt P5DAY2CG/mLAyZlCTT1FU3le0yOU6k7DxEcqknPHII6BBc2vGvzeR9xryKgjMMMHoo72/0O9lRC wzr7cWC8= X-Gm-Gg: AZFdTZeXT0Qxt93xvgwhr8XMKzSPdtyoyUgmsnKjI8bhPEMx/wfCG9Hw/Kt9S4decHk 9ES37LEGC/yUUiJuS2DmAU7nBHoXCvDETzQv+UYWKfBd/D5sksDlONLfbRLq4UIhnrWEOxGFgTm nE4g/fbyeUjpchLc7B41M+/aBoetCZH5XYLYpGF0wWEIhoycu4tKN/fgv9hgVbwy1QlRnfETvZw 9EajjZJGEgxmfvbt3NnfGH0Wh08v5DG7CbthBqUxKbJKX8n28UPN0KW6PM6fi0FcwFbbVgfbtDk rJZJ7MZWOAzo/pX695YfGXt8s3vRXqHSX9Y4wWzGS433JqSnzejd6l+xbBZbLidh1UMrrVNV1ie Sfp+Kn0OelQWLH8YxTe3oxvoztnCssVD4QEO9MEl82cb4eKwd9XUYXrfeZC+fO2Zf0I8MuEkF0s yk2BFqNZEFNkT3Lk4gG/+8MMammjEcBgNDeDr1bDDL0u9w+GsBBOdrktc3RT+un7L14AdNkwafh rSBTohILnHVwzUCWOKstLyqUhU7ttPgKqbs2A3wfv9U08/ItuCQ0irJEf75TbXJ1liwbJA+7+l8 WsqMGTZXJMXmnqkqlQPXcKSI3bYCS7ZpvcIKtOjAvidlOt/DoC61aZ7xg8bf9mBjRGl1a7W+NkE H5CdBlZvnGUknzTrSQLnC/HC0n9ohf2dGGcBLP7DN98D25b5zH/qVGQysxT5UqJ8bporoY0DgfF 2kxFT/vdqIwokN4xruBj6vHolYgyeagQRhwQ10mbrjamV6kKaNHHCcYZqHPr8= X-Received: by 2002:a05:6000:4308:b0:48e:6651:d82b with SMTP id ffacd0b85a97d-4abae12d0acmr31907760f8f.2.1795517684202; Tue, 24 Nov 2026 02:54:44 -0800 (PST) Received: from naush-dell.pitowers.org ([88.97.53.79]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6c4353d6sm26356817f8f.56.2026.11.24.02.54.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Nov 2026 02:54:43 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: solomai , Naushir Patuck Subject: [PATCH] pipeline: rpi: pisp: Check the oldest CFE job in tryRunPipeline() Date: Tue, 24 Nov 2026 10:54:27 +0000 Message-ID: <20261124105441.2393422-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 Sender: "libcamera-devel" 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 opened, and a complete job that could not run yet is left waiting for 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: solomai Signed-off-by: Naushir Patuck --- 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();