Show a patch.

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

{
    "id": 24168,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/24168/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/24168/",
    "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": "<20250820132316.1033443-4-dan.scally@ideasonboard.com>",
    "date": "2025-08-20T13:23:16",
    "name": "[3/3] libcamera: device_enumerator_udev: Defer invalid media devices",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "abec5fd58d196f89e9e11ff6da589e30d08c8bf5",
    "submitter": {
        "id": 156,
        "url": "https://patchwork.libcamera.org/api/1.1/people/156/?format=api",
        "name": "Dan Scally",
        "email": "dan.scally@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/24168/mbox/",
    "series": [
        {
            "id": 5396,
            "url": "https://patchwork.libcamera.org/api/1.1/series/5396/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5396",
            "date": "2025-08-20T13:23:13",
            "name": "Fix fast-booting device enumeration problems",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/5396/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/24168/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/24168/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 DFBDEBD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 20 Aug 2025 13:23:46 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1B35C692DD;\n\tWed, 20 Aug 2025 15:23:44 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5EEDD6925D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 Aug 2025 15:23:37 +0200 (CEST)",
            "from mail.ideasonboard.com\n\t(cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BF45D6AF;\n\tWed, 20 Aug 2025 15:22:38 +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=\"aTrKZx6i\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1755696158;\n\tbh=SfG9M9QxXbOfLKLfb9ULC3+cwJExQNZdq4HRuBotRFI=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=aTrKZx6iCy7WBAHZVkECWZbFblFYYsord2Po9iQ3v7DWqcgSaue28D6IyUOSnmEk9\n\tduBXF2jXMe7+CPe//jtOe7LtPM8tlnEjjlcEvf8Oo3XxZ3651T/J/9vzIBLtTvdbr2\n\tU+7C15Z1LQkp14NtuEGpA2JkyG6prrLgWM3zQfeA=",
        "From": "Daniel Scally <dan.scally@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "dan.scally@ideasonboard.com",
        "Subject": "[PATCH 3/3] libcamera: device_enumerator_udev: Defer invalid media\n\tdevices",
        "Date": "Wed, 20 Aug 2025 14:23:16 +0100",
        "Message-ID": "<20250820132316.1033443-4-dan.scally@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.43.0",
        "In-Reply-To": "<20250820132316.1033443-1-dan.scally@ideasonboard.com>",
        "References": "<20250820132316.1033443-1-dan.scally@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": "A MediaDevice created by DeviceEnumeratorUdev may have an invalid\ntopology if the device nodes for some of its entities have not yet\nbeen created. If that's the case, defer initialisation of the\nMediaDevice. Re-try all deferred media devices whenever a new device\nis added to see if they're ready to be initialised yet.\n\nSigned-off-by: Daniel Scally <dan.scally@ideasonboard.com>\n---\n .../internal/device_enumerator_udev.h         |  2 +\n src/libcamera/device_enumerator.cpp           |  2 +-\n src/libcamera/device_enumerator_udev.cpp      | 37 +++++++++++++++++++\n 3 files changed, 40 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/include/libcamera/internal/device_enumerator_udev.h b/include/libcamera/internal/device_enumerator_udev.h\nindex a5e5e6efe..b76315c63 100644\n--- a/include/libcamera/internal/device_enumerator_udev.h\n+++ b/include/libcamera/internal/device_enumerator_udev.h\n@@ -13,6 +13,7 @@\n #include <set>\n #include <string>\n #include <sys/types.h>\n+#include <vector>\n \n #include \"libcamera/internal/device_enumerator.h\"\n \n@@ -67,6 +68,7 @@ private:\n \tEventNotifier *notifier_;\n \n \tstd::set<dev_t> orphans_;\n+\tstd::vector<std::unique_ptr<MediaDevice>> topologyPending_;\n \tstd::list<MediaDeviceDeps> pending_;\n \tstd::map<dev_t, MediaDeviceDeps *> devMap_;\n };\ndiff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp\nindex ae17862f6..ab7bceec4 100644\n--- a/src/libcamera/device_enumerator.cpp\n+++ b/src/libcamera/device_enumerator.cpp\n@@ -220,7 +220,7 @@ std::unique_ptr<MediaDevice> DeviceEnumerator::createDevice(const std::string &d\n \tstd::unique_ptr<MediaDevice> media = std::make_unique<MediaDevice>(deviceNode);\n \n \tint ret = media->populate();\n-\tif (ret < 0) {\n+\tif (ret < 0 && ret != -EAGAIN) {\n \t\tLOG(DeviceEnumerator, Info)\n \t\t\t<< \"Unable to populate media device \" << deviceNode\n \t\t\t<< \" (\" << strerror(-ret) << \"), skipping\";\ndiff --git a/src/libcamera/device_enumerator_udev.cpp b/src/libcamera/device_enumerator_udev.cpp\nindex 53b4fac80..631e583e7 100644\n--- a/src/libcamera/device_enumerator_udev.cpp\n+++ b/src/libcamera/device_enumerator_udev.cpp\n@@ -82,6 +82,14 @@ int DeviceEnumeratorUdev::addUdevDevice(struct udev_device *dev)\n \t\tif (!media)\n \t\t\treturn -ENODEV;\n \n+\t\tif (!media->isValid()) {\n+\t\t\tLOG(DeviceEnumerator, Debug)\n+\t\t\t\t<< \"Defer media device \" << media->deviceNode()\n+\t\t\t\t<< \" due to an invalid topology\";\n+\t\t\ttopologyPending_.emplace_back(std::move(media));\n+\t\t\treturn 0;\n+\t\t}\n+\n \t\treturn initMediaDevice(std::move(media));\n \t}\n \n@@ -353,6 +361,35 @@ void DeviceEnumeratorUdev::udevNotify()\n \t\t<< action << \" device \" << deviceNode;\n \n \tif (action == \"add\") {\n+\t\t/*\n+\t\t* The addition of a new device may signal that a previously\n+\t\t* deferred media device has had its topology updated to the\n+\t\t* extent that it's now valid - retry devices deferred due to\n+\t\t* invalid topology to see if they're now ready.\n+\t\t*/\n+\n+\t\tLOG(DeviceEnumerator, Debug)\n+\t\t\t<< \"Re-evaluating \" << topologyPending_.size()\n+\t\t\t<< \" deferred media devices\";\n+\n+\t\tfor (auto media = topologyPending_.begin();\n+\t\t     media != topologyPending_.end(); ++media) {\n+\t\t\tLOG(DeviceEnumerator, Debug)\n+\t\t\t\t<< \"Evaluating media device \" << (*media)->deviceNode()\n+\t\t\t\t<< \" again...\";\n+\n+\t\t\tint ret = (*media)->populate();\n+\t\t\tif (ret == -EAGAIN) {\n+\t\t\t\tLOG(DeviceEnumerator, Debug)\n+\t\t\t\t\t<< \"Media device \" << (*media)->deviceNode()\n+\t\t\t\t\t<< \" still has invalid topology\";\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\n+\t\t\tinitMediaDevice(std::move(*media));\n+\t\t\ttopologyPending_.erase(media);\n+\t\t}\n+\n \t\taddUdevDevice(dev);\n \t} else if (action == \"remove\") {\n \t\tconst char *subsystem = udev_device_get_subsystem(dev);\n",
    "prefixes": [
        "3/3"
    ]
}