Patch Detail
Show a patch.
GET /api/1.1/patches/23627/?format=api
{ "id": 23627, "url": "https://patchwork.libcamera.org/api/1.1/patches/23627/?format=api", "web_url": "https://patchwork.libcamera.org/patch/23627/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20250623163414.3936727-1-kieran.bingham@ideasonboard.com>", "date": "2025-06-23T16:34:14", "name": "libcamera: pipeline_handler: cancel waiting requests first", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "f34cf483ff860ba4aedf904cf1dab76cd6d80991", "submitter": { "id": 4, "url": "https://patchwork.libcamera.org/api/1.1/people/4/?format=api", "name": "Kieran Bingham", "email": "kieran.bingham@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/23627/mbox/", "series": [ { "id": 5241, "url": "https://patchwork.libcamera.org/api/1.1/series/5241/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5241", "date": "2025-06-23T16:34:14", "name": "libcamera: pipeline_handler: cancel waiting requests first", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5241/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/23627/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/23627/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 493A8BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 23 Jun 2025 16:34:21 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5D5F168DE3;\n\tMon, 23 Jun 2025 18:34:20 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F0E4968DC9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 23 Jun 2025 18:34:18 +0200 (CEST)", "from Monstersaurus.hippo-penny.ts.net\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EAFC410D4;\n\tMon, 23 Jun 2025 18:34:01 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"bq9SEaIl\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1750696442;\n\tbh=J3ay8Bis3+vdhIozP2Ro1shCrOX1tSkT8hcJMeO1NLc=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=bq9SEaIlPyUgdV2naVRm3aEyH44Fi2mIsPvO9SjrRmyM0o+nUYzKvdhUgd4Y+StuR\n\tTV6bjWqThYRFMsNW1qhUqfuBGEzQbNmdIrJWBE68veRp6PpR1sxILh8A8j1gz8mAsi\n\tOnLb3iwSJArP/VUVefHng6xM7FOFRGwx+6X4J33w=", "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>", "To": "libcamera devel <libcamera-devel@lists.libcamera.org>,\n\tstefan.klug@ideasonboard.com", "Cc": "Kieran Bingham <kieran.bingham@ideasonboard.com>", "Subject": "[PATCH] libcamera: pipeline_handler: cancel waiting requests first", "Date": "Mon, 23 Jun 2025 17:34:14 +0100", "Message-ID": "<20250623163414.3936727-1-kieran.bingham@ideasonboard.com>", "X-Mailer": "git-send-email 2.49.0", "In-Reply-To": "<20250526214224.13631-1-stefan.klug@ideasonboard.com>", "References": "<20250526214224.13631-1-stefan.klug@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "When stopping a camera, we may now find that there are requests\nqueued to the camera but not yet available in the pipeline handler.\n\nThese are \"waitingReqeusts\" which are not yet queued to the device.\n\nWhile stopping a camera, we ask the pipeline to stop with stopDevice()\nand then cancel any waiting requests after.\n\nThis however can lead to a race where having stopped the camera and\ncompleted the requests, the pipeline may try to further consume requests\nfrom the waiting lists.\n\nWhen we call PipelineHandler::stop() we know that we can not process any\nof the requests which are sat in the waiting queue, therefore cancel\nthose first before asking the pipeline handler to complete or cancel and\nrequests that it has ownership of.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n\nHi Stefan,\n\nTesting your series I discovered this shutdown race.\n\nWithout this I get:\n\n\n\n[1:48:10.770431125] [2675] FATAL default 6490.777390] audit: type=1701 audit(1741278393.952:115): auid=4294967295 uid=0 gid=0 ses=4294967295 pid=2674 comm=\"cam\" exe=\"/usr/bin/cam\" sig=6 res=1\n;34mrkisp1_ipa_proxy.cpp:467 assertion \"state_ == ProxyRunning\" failed in queueRequestThread()\nBacktrace:\n/lib/libcamera.so.0.5(_ZN9libcamera3ipa6rkisp114IPAProxyRkISP118queueRequestThreadEjRKNS_11ControlListE+0x94) [0xffffb32d[ 6490.810893] audit: type=1334 audit(1741278393.984:116): prog-id=51 op=LOAD\n7f8c]\n/lib/libcamera.so.0.5(_ZN9[ 6490.819683] audit: type=1334 audit(1741278393.996:117): prog-id=52 op=LOAD\nlibcamera3ipa6rkisp114IPAProxyRkI[ 6490.820111] audit: type=1334 audit(1741278393.996:118): prog-id=53 op=LOAD\nSP112queueRequestEjRKNS_11ControlListE+0x28) [0xffffb32d8048]\n/lib/libcamera.so.0.5(_ZN9libcamera21PipelineHandlerRkISP118queueRequestDeviceEPNS_6CameraEPNS_7RequestE+0x50) [0xffffb3360b14]\n\n\nThis patch ensures that requests which are in the waitingRequests queue\nare cancelled first to ensure they don't get processed by the pipeline\nafter it has completed it's stop().\n\n\n src/libcamera/pipeline_handler.cpp | 7 ++++---\n 1 file changed, 4 insertions(+), 3 deletions(-)", "diff": "diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex 0389f34486ab..9cd3504dc9db 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -360,9 +360,6 @@ void PipelineHandler::unlockMediaDevices()\n */\n void PipelineHandler::stop(Camera *camera)\n {\n-\t/* Stop the pipeline handler and let the queued requests complete. */\n-\tstopDevice(camera);\n-\n \tCamera::Private *data = camera->_d();\n \n \t/* Cancel and signal as complete all waiting requests. */\n@@ -372,8 +369,12 @@ void PipelineHandler::stop(Camera *camera)\n \t\tcancelRequest(request);\n \t}\n \n+\t/* Stop the pipeline handler and let the queued requests complete. */\n+\tstopDevice(camera);\n+\n \t/* Make sure no requests are pending. */\n \tASSERT(data->queuedRequests_.empty());\n+\tASSERT(data->waitingRequests_.empty());\n \n \tdata->requestSequence_ = 0;\n }\n", "prefixes": [] }