Show a patch.

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

{
    "id": 21825,
    "url": "https://patchwork.libcamera.org/api/patches/21825/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/21825/",
    "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": "<20241106201721.1624461-4-mzamazal@redhat.com>",
    "date": "2024-11-06T20:17:21",
    "name": "[v6,3/3] libcamera: software_isp: Clean up pending requests on stop",
    "commit_ref": "2cbf863f3f38f22e5e81dd35a77f1cee84f74d0a",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "a0433f3d2ad3fc3ff1d048126e0ef63320aca9f2",
    "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/21825/mbox/",
    "series": [
        {
            "id": 4774,
            "url": "https://patchwork.libcamera.org/api/series/4774/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4774",
            "date": "2024-11-06T20:17:18",
            "name": "Clean up pending requests on stop in software ISP",
            "version": 6,
            "mbox": "https://patchwork.libcamera.org/series/4774/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/21825/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/21825/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 8AF6DBDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  6 Nov 2024 20:17:47 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 38AB165467;\n\tWed,  6 Nov 2024 21:17:47 +0100 (CET)",
            "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 34B836545A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  6 Nov 2024 21:17:46 +0100 (CET)",
            "from mx-prod-mc-03.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-445-aDKZP5YuM0W5-GWF_CW4pg-1;\n\tWed, 06 Nov 2024 15:17:40 -0500",
            "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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS id 0DE5019560BD; Wed,  6 Nov 2024 20:17:39 +0000 (UTC)",
            "from nuthatch.redhat.com (unknown [10.45.224.4])\n\tby mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id 0FAED1956088; Wed,  6 Nov 2024 20:17:35 +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=\"guDCJqyU\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1730924265;\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=dw1rSXsZj0CiLBB+4rarMmUmuy8CjjFtsacMneVOvUo=;\n\tb=guDCJqyUg7RzG2vueHRawsS5GKpc5ZV2MYtLaJktKLI+YkHcE0Bo5o2L++lewxqskiMxlc\n\tTLGSVJW6YhQEsquJQ0q08ev6nTz+l8zK8HtgYSSeoCPOq4PryKFEf8mlJfVpX9RI8qMk8V\n\tRZA6FiVfF4PXpIfoDseQogGMxa1MZqk=",
        "X-MC-Unique": "aDKZP5YuM0W5-GWF_CW4pg-1",
        "X-Mimecast-MFC-AGG-ID": "aDKZP5YuM0W5-GWF_CW4pg",
        "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,\n\thdegoede@redhat.com,\n\tStanislaw Gruszka <stanislaw.gruszka@linux.intel.com>",
        "Subject": "[PATCH v6 3/3] libcamera: software_isp: Clean up pending requests on\n\tstop",
        "Date": "Wed,  6 Nov 2024 21:17:21 +0100",
        "Message-ID": "<20241106201721.1624461-4-mzamazal@redhat.com>",
        "In-Reply-To": "<20241106201721.1624461-1-mzamazal@redhat.com>",
        "References": "<20241106201721.1624461-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-MFC-PROC-ID": "b006d7PVPI579MdHh1AVMhxbusOLwQIU2yKBAVIXBNA_1730924259",
        "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>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Hans de Goede <hdegoede@redhat.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nTested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nTested-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>\n---\n src/libcamera/pipeline/simple/simple.cpp | 10 ++++++++++\n 1 file changed, 10 insertions(+)",
    "diff": "diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\nindex 13c0a1891..b425bc0de 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -226,6 +226,7 @@ public:\n \t\t\t V4L2Subdevice::Whence whence,\n \t\t\t Transform transform = Transform::Identity);\n \tvoid bufferReady(FrameBuffer *buffer);\n+\tvoid clearIncompleteRequests();\n \n \tunsigned int streamIndex(const Stream *stream) const\n \t{\n@@ -876,6 +877,14 @@ void SimpleCameraData::bufferReady(FrameBuffer *buffer)\n \tpipe->completeRequest(request);\n }\n \n+void SimpleCameraData::clearIncompleteRequests()\n+{\n+\twhile (!conversionQueue_.empty()) {\n+\t\tpipe()->cancelRequest(conversionQueue_.front().request);\n+\t\tconversionQueue_.pop();\n+\t}\n+}\n+\n void SimpleCameraData::conversionInputDone(FrameBuffer *buffer)\n {\n \t/* Queue the input buffer back for capture. */\n@@ -1401,6 +1410,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": [
        "v6",
        "3/3"
    ]
}