Show a patch.

GET /api/patches/21565/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 21565,
    "url": "https://patchwork.libcamera.org/api/patches/21565/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/21565/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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": "<20241009172108.2058320-3-mzamazal@redhat.com>",
    "date": "2024-10-09T17:21:08",
    "name": "[v3,2/2] libcamera: software_isp: Clean up pending requests on stop",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "5637542fa4133126d998039453fadd4b166784f5",
    "submitter": {
        "id": 177,
        "url": "https://patchwork.libcamera.org/api/people/177/?format=api",
        "name": "Milan Zamazal",
        "email": "mzamazal@redhat.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/21565/mbox/",
    "series": [
        {
            "id": 4675,
            "url": "https://patchwork.libcamera.org/api/series/4675/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4675",
            "date": "2024-10-09T17:21:06",
            "name": "Clean up pending requests on stop in software ISP",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/4675/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/21565/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/21565/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 08B60C32DE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  9 Oct 2024 17:21:29 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BAB826536C;\n\tWed,  9 Oct 2024 19:21:28 +0200 (CEST)",
            "from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AE22A63527\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  9 Oct 2024 19:21:23 +0200 (CEST)",
            "from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com\n\t(ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63])\n\tby relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n\tcipher=TLS_AES_256_GCM_SHA384) id us-mta-575--e8JjZO3PcqovBkS94_L8w-1;\n\tWed, 09 Oct 2024 13:21:19 -0400",
            "from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com\n\t(mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com\n\t[10.30.177.15])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (2048 bits)\n\tserver-digest SHA256) (No client certificate requested)\n\tby mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS id 8E07719560AF; Wed,  9 Oct 2024 17:21:18 +0000 (UTC)",
            "from nuthatch.redhat.com (unknown [10.45.224.78])\n\tby mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id CA6A5195607C; Wed,  9 Oct 2024 17:21:16 +0000 (UTC)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"E9cW5//a\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1728494482;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=812ruoLKpxT3+QEGPORyZO2YnCfLt+3fxr0fgL0W9qg=;\n\tb=E9cW5//a2wUufvcU65l/UBMAo1zu/DnGSHWDjeVNbkkH9yeuZhLa3JVTHwTShibMitUm+a\n\tHB5GwS9wfbX7ujQZnhU8eNK/JPuZcbK3+B1wGsBd6Goc4MqSSBrpFF4PHRARRfccKGF2c5\n\tPM65wi1M0WGScCZCRUKSLt9icqcm7VQ=",
        "X-MC-Unique": "-e8JjZO3PcqovBkS94_L8w-1",
        "From": "Milan Zamazal <mzamazal@redhat.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Milan Zamazal <mzamazal@redhat.com>, robert.mader@posteo.de,\n\tkieran.bingham@ideasonboard.com, laurent.pinchart@ideasonboard.com",
        "Subject": "[PATCH v3 2/2] libcamera: software_isp: Clean up pending requests on\n\tstop",
        "Date": "Wed,  9 Oct 2024 19:21:08 +0200",
        "Message-ID": "<20241009172108.2058320-3-mzamazal@redhat.com>",
        "In-Reply-To": "<20241009172108.2058320-1-mzamazal@redhat.com>",
        "References": "<20241009172108.2058320-1-mzamazal@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 3.0 on 10.30.177.15",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-Originator": "redhat.com",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain; charset=\"US-ASCII\"; x-default=true",
        "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": "PipelineHandler::stop() calls stopDevice() method to perform pipeline\nspecific cleanup and then completes waiting requests.  If any queued\nrequests remain, an assertion error is raised.\n\nSoftware ISP stores request buffers in\nSimpleCameraData::conversionQueue_ and queues them as V4L2 signals\nbufferReady.  stopDevice() cleanup forgets to clean up the buffers and\ntheir requests from conversionQueue_, possibly resulting in the\nassertion error.  This patch fixes the omission.\n\nThe problem wasn't very visible when\nSimplePipelineHandler::kNumInternalBuffers (the number of buffers\nallocated in V4L2) was equal to the number of buffers exported from\nsoftware ISP.  But when the number of the exported buffers was increased\nby one in commit abe2ec64f9e4e97bbdfe3a50372611bd7b5315c2, the assertion\nerror started pop up in some environments.  Increasing the number of the\nbuffers much more, e.g. to 9, makes the problem very reproducible.\n\nEach pipeline uses its own mechanism to track the requests to clean up\nand it can't be excluded that similar omissions are present in other\nplaces.  But there is no obvious way to make a common cleanup for all\nthe pipelines (except for doing it instead of raising the assertion\nerror, which is probably undesirable, in order not to hide incomplete\npipeline specific cleanups).\n\nBug: https://bugs.libcamera.org/show_bug.cgi?id=234\nSigned-off-by: Milan Zamazal <mzamazal@redhat.com>\n---\n src/libcamera/pipeline/simple/simple.cpp | 15 +++++++++++++++\n 1 file changed, 15 insertions(+)",
    "diff": "diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\nindex 3ddce71d3..ff3859f18 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -284,6 +284,7 @@ public:\n \tstd::vector<std::unique_ptr<FrameBuffer>> conversionBuffers_;\n \tstd::queue<std::map<const Stream *, FrameBuffer *>> conversionQueue_;\n \tbool useConversion_;\n+\tvoid clearIncompleteRequests();\n \n \tstd::unique_ptr<Converter> converter_;\n \tstd::unique_ptr<SoftwareIsp> swIsp_;\n@@ -897,6 +898,19 @@ void SimpleCameraData::conversionOutputDone(FrameBuffer *buffer)\n \t\tpipe->completeRequest(request);\n }\n \n+void SimpleCameraData::clearIncompleteRequests()\n+{\n+\twhile (!conversionQueue_.empty()) {\n+\t\tfor (auto &item : conversionQueue_.front()) {\n+\t\t\tFrameBuffer *outputBuffer = item.second;\n+\t\t\tRequest *request = outputBuffer->request();\n+\t\t\tif (request->status() == Request::RequestPending)\n+\t\t\t\tpipe()->cancelRequest(request);\n+\t\t}\n+\t\tconversionQueue_.pop();\n+\t}\n+}\n+\n void SimpleCameraData::ispStatsReady(uint32_t frame, uint32_t bufferId)\n {\n \tswIsp_->processStats(frame, bufferId,\n@@ -1406,6 +1420,7 @@ void SimplePipelineHandler::stopDevice(Camera *camera)\n \n \tvideo->bufferReady.disconnect(data, &SimpleCameraData::bufferReady);\n \n+\tdata->clearIncompleteRequests();\n \tdata->conversionBuffers_.clear();\n \n \treleasePipeline(data);\n",
    "prefixes": [
        "v3",
        "2/2"
    ]
}