Show a patch.

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

{
    "id": 19666,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/19666/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/19666/",
    "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": "<20240311141524.27192-4-hdegoede@redhat.com>",
    "date": "2024-03-11T14:15:07",
    "name": "[v5,03/18] libcamera: dma_heaps: extend DmaHeap class to support system heap",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "82eb22482f8a0aa8bf2aa6582b56117d6c6552ab",
    "submitter": {
        "id": 102,
        "url": "https://patchwork.libcamera.org/api/1.1/people/102/?format=api",
        "name": "Hans de Goede",
        "email": "hdegoede@redhat.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/19666/mbox/",
    "series": [
        {
            "id": 4214,
            "url": "https://patchwork.libcamera.org/api/1.1/series/4214/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4214",
            "date": "2024-03-11T14:15:04",
            "name": "libcamera: introduce Software ISP and Software IPA",
            "version": 5,
            "mbox": "https://patchwork.libcamera.org/series/4214/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/19666/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/19666/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 10A1FC32A3\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 11 Mar 2024 14:15:39 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BE8BB62868;\n\tMon, 11 Mar 2024 15:15:38 +0100 (CET)",
            "from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AA5E762C88\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 11 Mar 2024 15:15:36 +0100 (CET)",
            "from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73])\n\tby relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n\tcipher=TLS_AES_256_GCM_SHA384) id us-mta-132-txudEXaxPhGqDHbK0ucCLg-1;\n\tMon, 11 Mar 2024 10:15:32 -0400",
            "from smtp.corp.redhat.com\n\t(int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7])\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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id E69B83C0CEF5;\n\tMon, 11 Mar 2024 14:15:31 +0000 (UTC)",
            "from x1.localdomain.com (unknown [10.39.195.37])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 488871C060CE;\n\tMon, 11 Mar 2024 14:15:30 +0000 (UTC)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"U8LjPgjr\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1710166535;\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=xB1JKMgKcvPP6XGmxDbDJKnN0KwKX7Op7EzdPDGztco=;\n\tb=U8LjPgjrft9c50BoKlbRMkfbR69DMTLFYnSkqELgdYEFjIFByDWcgxp7/GY7HUlnFUX/si\n\t4r+Ss5gmvCmkYS1ZNuzvVGtCJhKDnhBB2hTHxQcojVRddRh72mkmitAMGsrQwNsnTGjieB\n\tFzhTWLYrWfQjsxro2r6Tz9DmVu1cTTg=",
        "X-MC-Unique": "txudEXaxPhGqDHbK0ucCLg-1",
        "From": "Hans de Goede <hdegoede@redhat.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Subject": "[PATCH v5 03/18] libcamera: dma_heaps: extend DmaHeap class to\n\tsupport system heap",
        "Date": "Mon, 11 Mar 2024 15:15:07 +0100",
        "Message-ID": "<20240311141524.27192-4-hdegoede@redhat.com>",
        "In-Reply-To": "<20240311141524.27192-1-hdegoede@redhat.com>",
        "References": "<20240311141524.27192-1-hdegoede@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 3.4.1 on 10.11.54.7",
        "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>",
        "Cc": "Maxime Ripard <mripard@redhat.com>, Pavel Machek <pavel@ucw.cz>,\n\tBryan O'Donoghue <bryan.odonoghue@linaro.org>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "From: Andrey Konovalov <andrey.konovalov@linaro.org>\n\nAdd an argument to the constructor to specify dma heaps type(s)\nto use. Can be DmaHeapFlag::Cma and/or DmaHeapFlag::System.\nBy default DmaHeapFlag::Cma is used. If both DmaHeapFlag::Cma and\nDmaHeapFlag::System are set, CMA heap is tried first.\n\nTested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # sc8280xp Lenovo x13s\nTested-by: Pavel Machek <pavel@ucw.cz>\nReviewed-by: Milan Zamazal <mzamazal@redhat.com>\nReviewed-by: Pavel Machek <pavel@ucw.cz>\nSigned-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>\nSigned-off-by: Hans de Goede <hdegoede@redhat.com>\n---\n include/libcamera/internal/dma_heaps.h | 12 ++++-\n src/libcamera/dma_heaps.cpp            | 67 ++++++++++++++++++++------\n 2 files changed, 63 insertions(+), 16 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/dma_heaps.h b/include/libcamera/internal/dma_heaps.h\nindex cff8f140..80bf29e7 100644\n--- a/include/libcamera/internal/dma_heaps.h\n+++ b/include/libcamera/internal/dma_heaps.h\n@@ -9,6 +9,7 @@\n \n #include <stddef.h>\n \n+#include <libcamera/base/flags.h>\n #include <libcamera/base/unique_fd.h>\n \n namespace libcamera {\n@@ -16,7 +17,14 @@ namespace libcamera {\n class DmaHeap\n {\n public:\n-\tDmaHeap();\n+\tenum class DmaHeapFlag {\n+\t\tCma = 1 << 0,\n+\t\tSystem = 1 << 1,\n+\t};\n+\n+\tusing DmaHeapFlags = Flags<DmaHeapFlag>;\n+\n+\tDmaHeap(DmaHeapFlags flags = DmaHeapFlag::Cma);\n \t~DmaHeap();\n \tbool isValid() const { return dmaHeapHandle_.isValid(); }\n \tUniqueFD alloc(const char *name, std::size_t size);\n@@ -25,4 +33,6 @@ private:\n \tUniqueFD dmaHeapHandle_;\n };\n \n+LIBCAMERA_FLAGS_ENABLE_OPERATORS(DmaHeap::DmaHeapFlag)\n+\n } /* namespace libcamera */\ndiff --git a/src/libcamera/dma_heaps.cpp b/src/libcamera/dma_heaps.cpp\nindex 38ef175a..d0e33ce6 100644\n--- a/src/libcamera/dma_heaps.cpp\n+++ b/src/libcamera/dma_heaps.cpp\n@@ -19,9 +19,11 @@\n \n /**\n  * \\file dma_heaps.cpp\n- * \\brief CMA dma-heap allocator\n+ * \\brief dma-heap allocator\n  */\n \n+namespace libcamera {\n+\n /*\n  * /dev/dma_heap/linux,cma is the dma-heap allocator, which allows dmaheap-cma\n  * to only have to worry about importing.\n@@ -29,42 +31,77 @@\n  * Annoyingly, should the cma heap size be specified on the kernel command line\n  * instead of DT, the heap gets named \"reserved\" instead.\n  */\n-static constexpr std::array<const char *, 2> heapNames = {\n-\t\"/dev/dma_heap/linux,cma\",\n-\t\"/dev/dma_heap/reserved\"\n+\n+/**\n+ * \\struct DmaHeapInfo\n+ * \\brief Tells what type of dma-heap the dma-heap represented by the device node name is\n+ * \\var DmaHeapInfo::flag\n+ * \\brief The type of the dma-heap\n+ * \\var DmaHeapInfo::name\n+ * \\brief The dma-heap's device node name\n+ */\n+struct DmaHeapInfo {\n+\tDmaHeap::DmaHeapFlag flag;\n+\tconst char *name;\n };\n \n-namespace libcamera {\n+static constexpr std::array<DmaHeapInfo, 3> heapInfos = {\n+\t{ /* CMA heap names first */\n+\t  { DmaHeap::DmaHeapFlag::Cma, \"/dev/dma_heap/linux,cma\" },\n+\t  { DmaHeap::DmaHeapFlag::Cma, \"/dev/dma_heap/reserved\" },\n+\t  { DmaHeap::DmaHeapFlag::System, \"/dev/dma_heap/system\" } }\n+};\n \n LOG_DEFINE_CATEGORY(DmaHeap)\n \n /**\n  * \\class DmaHeap\n- * \\brief Helper class for CMA dma-heap allocations\n+ * \\brief Helper class for dma-heap allocations\n  */\n \n /**\n- * \\brief Construct a DmaHeap that owns a CMA dma-heap file descriptor\n+ * \\enum DmaHeap::DmaHeapFlag\n+ * \\brief Type of the dma-heap\n+ * \\var DmaHeap::Cma\n+ * \\brief Allocate from a CMA dma-heap\n+ * \\var DmaHeap::System\n+ * \\brief Allocate from the system dma-heap\n+ */\n+\n+/**\n+ * \\typedef DmaHeap::DmaHeapFlags\n+ * \\brief A bitwise combination of DmaHeap::DmaHeapFlag values\n+ */\n+\n+/**\n+ * \\brief Construct a DmaHeap that owns a CMA or system dma-heap file descriptor\n+ * \\param [in] flags The type(s) of the dma-heap(s) to allocate from\n  *\n- * Goes through the internal list of possible names of the CMA dma-heap devices\n- * until a CMA dma-heap device is successfully opened. If it fails to open any\n- * dma-heap device, an invalid DmaHeap object is constructed. A valid DmaHeap\n- * object owns a wrapped dma-heap file descriptor.\n+ * By default \\a flags are set to DmaHeap::DmaHeapFlag::Cma. The constructor goes\n+ * through the internal list of possible names of the CMA and system dma-heap devices\n+ * until the dma-heap device of the requested type is successfully opened. If more\n+ * than one dma-heap type is specified in flags the CMA heap is tried first. If it\n+ * fails to open any dma-heap device an invalid DmaHeap object is constructed.\n+ * A valid DmaHeap object owns a wrapped dma-heap file descriptor.\n  *\n  * Please check the new DmaHeap object with \\ref DmaHeap::isValid before using it.\n  */\n-DmaHeap::DmaHeap()\n+DmaHeap::DmaHeap(DmaHeapFlags flags)\n {\n-\tfor (const char *name : heapNames) {\n-\t\tint ret = ::open(name, O_RDWR | O_CLOEXEC, 0);\n+\tfor (const auto &info : heapInfos) {\n+\t\tif (!(flags & info.flag))\n+\t\t\tcontinue;\n+\n+\t\tint ret = ::open(info.name, O_RDWR | O_CLOEXEC, 0);\n \t\tif (ret < 0) {\n \t\t\tret = errno;\n \t\t\tLOG(DmaHeap, Debug)\n-\t\t\t\t<< \"Failed to open \" << name << \": \"\n+\t\t\t\t<< \"Failed to open \" << info.name << \": \"\n \t\t\t\t<< strerror(ret);\n \t\t\tcontinue;\n \t\t}\n \n+\t\tLOG(DmaHeap, Debug) << \"Using \" << info.name;\n \t\tdmaHeapHandle_ = UniqueFD(ret);\n \t\tbreak;\n \t}\n",
    "prefixes": [
        "v5",
        "03/18"
    ]
}