Show a patch.

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

{
    "id": 17723,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/17723/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/17723/",
    "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": "<CAEmqJPqRYY8T6u1vBFv1aXjkaH60fK3WhkMZSEGQEhoiruk0Zw@mail.gmail.com>",
    "date": "2022-10-28T09:42:55",
    "name": "[libcamera-devel] Concurrent camera usage in libcamera",
    "commit_ref": null,
    "pull_url": null,
    "state": "not-applicable",
    "archived": false,
    "hash": "3415db462572b30c3ad85e5cb0d5bf81c8251168",
    "submitter": {
        "id": 34,
        "url": "https://patchwork.libcamera.org/api/1.1/people/34/?format=api",
        "name": "Naushir Patuck",
        "email": "naush@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/17723/mbox/",
    "series": [
        {
            "id": 3584,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3584/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3584",
            "date": "2022-10-28T09:42:55",
            "name": "[libcamera-devel] Concurrent camera usage in libcamera",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3584/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/17723/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/17723/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 4728FBD16B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 28 Oct 2022 09:43:14 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0D67162FC8;\n\tFri, 28 Oct 2022 11:43:14 +0200 (CEST)",
            "from mail-qk1-x734.google.com (mail-qk1-x734.google.com\n\t[IPv6:2607:f8b0:4864:20::734])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 76C6162F41\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 28 Oct 2022 11:43:12 +0200 (CEST)",
            "by mail-qk1-x734.google.com with SMTP id a5so3055452qkl.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 28 Oct 2022 02:43:12 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1666950194;\n\tbh=wO5BlERyLgQTRFmBHLXMmg9G2zPmv9c5ynZsWI94kcM=;\n\th=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=2uprzRMab76iI/FKJtk1C5jnht6y2E0mICEfMCKOzeQMvxUugTGZW/LLdMuzcXSn0\n\tNhQknBAQ46YOZpNO5tYPojTl2u8pIJCZkAE1KGhSYMCwsgURcjjjRAwTZj+sDELc/O\n\talyv+/lQjCGXbUBrvYT04ewb90MRAY5Ni2a6RAKwKAhlnC5sa5DUt9I1eT797Ajv4L\n\tKQ4U4ivYBYd+fgqAELKElQ9lB4sb3ClcgKvNuM1X7g1Cx0PkmUTCKmukoZbT0MJyKJ\n\t2tXn/CCa4Rp3yqRaGimwG+I9CeP1oCayS5lCiJjHo6Y6FEWCnkRBZV6nvB5JBrkieI\n\toIJmDHPbCl1ww==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=to:subject:message-id:date:from:mime-version:from:to:cc:subject\n\t:date:message-id:reply-to;\n\tbh=MD8w3bY6M8ZvGwJqgy10et6Dbi6tuH3rGkEypNntNk4=;\n\tb=Q+c0tMlFJb+N7WWxzMfZgmFCf5Q/zozBGQBeiK0WURMGb2ce4TqDyL4Wwe6PMKgEt6\n\tQ9ME2UiyvWP4w/dueaW/dm5HunKRIZuDvOFf93qpxmh4HnvtPHpkYpWwPYtZ0ytVWHzW\n\tdP6rlwrjDQ9Dss684S5BVtVpAm1jOZQ9infsWsv6CrpDGTdLgzTZUzq6yuMvGB8KthAG\n\tA7R1REekYzj7ypsfnfwbBxDuTsYkrXZDNhGiTfCd/kZhY05TJZPOqAja3/nLrz/VQHIO\n\tVwCqavsOcelXnQ5NN/KyvXXwykfK7ize3G2DMXmhmeCzIrEQ87snhMJqCh3Ui3eLCf0e\n\tMs5g=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"Q+c0tMlF\"; dkim-atps=neutral",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=to:subject:message-id:date:from:mime-version:x-gm-message-state\n\t:from:to:cc:subject:date:message-id:reply-to;\n\tbh=MD8w3bY6M8ZvGwJqgy10et6Dbi6tuH3rGkEypNntNk4=;\n\tb=5X8vkxZiKAXo7l4+dfFfITnRKFt6cP6J8xvUOfCY9BdonuNM3IBxXnSOdJDKVnVGRS\n\tR4LYhkc1Y41774jvOyvpcJqHpvWo/H/kl/oZha+tU3BZocoKFhblhi6UdkjqYgXIonV5\n\tzMZzR968RgNPEVge8/NWvEjNn0x32NYl6Mg9drDSCMdvmkmyDINrn2ZbBVWnlmRktDVg\n\tbnvtone9G0tG1NhQ9l+yJSKNe1Z1/giDiEsj3kSK6+dK0EZ+jTEuxxYXpwz/8RnKMhDf\n\tT5rQqM7kjhCLRjUXQpBJwfnQt09ksjfb2BM+1v826IBBAXfjpyr5gKFyLqaxn3o/PIFU\n\taqaQ==",
        "X-Gm-Message-State": "ACrzQf2d51bx0YXT6qieL1G+G/fVP1s0BCBelGr7NoGunsIoc6pQb/w2\n\t88SN4Y4DScgtiUvI+0sWJKU3rWtaO8ul8aoLwqRMSncKTGEI4w==",
        "X-Google-Smtp-Source": "AMsMyM4ynG0aeZcvSIt4k/Tzh1Sy5gazSPvN2jvkFVVelnXhE9nuHpCbjii+pJZGGicS9NCOyzPjfVuaB4ukdwFhgZw=",
        "X-Received": "by 2002:a37:407:0:b0:6f9:6a80:14b1 with SMTP id\n\t7-20020a370407000000b006f96a8014b1mr8325329qke.198.1666950191032;\n\tFri, 28 Oct 2022 02:43:11 -0700 (PDT)",
        "MIME-Version": "1.0",
        "Date": "Fri, 28 Oct 2022 10:42:55 +0100",
        "Message-ID": "<CAEmqJPqRYY8T6u1vBFv1aXjkaH60fK3WhkMZSEGQEhoiruk0Zw@mail.gmail.com>",
        "To": "libcamera devel <libcamera-devel@lists.libcamera.org>",
        "Content-Type": "multipart/alternative; boundary=\"000000000000fec54205ec15155a\"",
        "Subject": "[libcamera-devel] Concurrent camera usage in libcamera",
        "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>",
        "From": "Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Naushir Patuck <naush@raspberrypi.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Hi all,\n\nI wonder if I could get some thoughts regarding a problem we are seeing\nwith running multiple cameras in separate libcamera processes on Raspberry\nPi (this probably affects any/all platforms though).\n\nIn my scenario, I have libcamera process 1 running \"cam -c 1 -C\" and\nstreaming from imx477 using the Raspberry Pi pipeline handler.  In process\n2, I have \"cam -c 2 -C\" running streaming from a USB camera using the\nuvcvideo pipeline handler.  If I exit process 2, I get the following error\nmessages:\n\n[0:01:33.155169911] [1392] ERROR V4L2 v4l2_videodevice.cpp:1241\n/dev/video2[16:cap]: Unable to request 0 buffers: Device or resource busy\n[0:01:33.155359910] [1392] ERROR V4L2 v4l2_videodevice.cpp:1241\n/dev/video3[17:cap]: Unable to request 0 buffers: Device or resource busy\n[0:01:33.155460595] [1392] ERROR V4L2 v4l2_videodevice.cpp:1241\n/dev/video13[18:out]: Unable to request 0 buffers: Device or resource busy\n[0:01:33.155564354] [1392] ERROR V4L2 v4l2_videodevice.cpp:1241\n/dev/video14[19:cap]: Unable to request 0 buffers: Device or resource busy\n[0:01:33.155664150] [1392] ERROR V4L2 v4l2_videodevice.cpp:1241\n/dev/video15[20:cap]: Unable to request 0 buffers: Device or resource busy\n[0:01:33.155763483] [1392] ERROR V4L2 v4l2_videodevice.cpp:1241\n/dev/video16[21:cap]: Unable to request 0 buffers: Device or resource busy\n\nThese errors come up because the V4L2VideoDevice destructor in process 2 is\nindirectly calling ioctl(REQBUFS, 0) on all the Unicam and ISP device nodes\nwhile the device driver buffer queues are actively owned and used by\nprocess 1. This does not actively interfere with process 1 running, it\ncontinues happily enough.\n\nThe error here stems from the fact that the RPi pipeline handler\nPipelineHandler::match() opens all the device nodes for every Camera object\nregistered through PipelineHandler::registerCamera().  So even if the\nCamera was never used by a process, when terminating the V4L2VideoDevice\ndestructor will call ioctl(REQBUFS, 0) for every single device.  This\nbehavior is exactly the same for the ipu3 and rkisp1 pipeline handlers.\n\nSo the question is how to fix this and avoid the error messages?\n\n1) The V4L2VideoDevice destructor should not call ioctl(REQBUFS, 0) if it\nhas not allocated buffers for the device:\n\nPipelineHandler::match(), and defer this call to when configure() gets\ncalled.\n\nOption 2 is not trivial, as (at least in the RPi pipeline handler) a bunch\nof validation occurs in PipelineHandler::match() that needs the device\nnodes to be open. In my opinion, option 1 seems to be the correct thing to\ndo.\n\nAny other suggestions or thoughts?\n\nRegards,\nNaush",
    "diff": "diff --git a/src/libcamera/v4l2_videodevice.cpp\nb/src/libcamera/v4l2_videodevice.cpp\nindex e30858c9fa02..108e60f035ab 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -758,7 +758,8 @@ void V4L2VideoDevice::close()\n        if (!isOpen())\n                return;\n\n-       releaseBuffers();\n+       if (cache_)\n+               releaseBuffers();\n        delete fdBufferNotifier_;\n\n2) All pipeline handlers need to change and avoid calling device open() in\n",
    "prefixes": [
        "libcamera-devel"
    ]
}