Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.0/patches/2198193/?format=api
{ "id": 2198193, "url": "http://patchwork.ozlabs.org/api/1.0/patches/2198193/?format=api", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/1.0/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20260219143332.3316679-3-ruslichenko.r@gmail.com>", "date": "2026-02-19T14:33:01", "name": "[v2,02/33] system/device_tree: add few parsing and traversal helpers", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "bfca13b9e334d7672d2d523e1f6c7add95c835a4", "submitter": { "id": 92275, "url": "http://patchwork.ozlabs.org/api/1.0/people/92275/?format=api", "name": "Ruslan Ruslichenko", "email": "ruslichenko.r@gmail.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260219143332.3316679-3-ruslichenko.r@gmail.com/mbox/", "series": [ { "id": 492690, "url": "http://patchwork.ozlabs.org/api/1.0/series/492690/?format=api", "date": "2026-02-19T14:33:04", "name": "hw/arm: Introduce generic FDT-driven machine", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/492690/mbox/" } ], "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2198193/checks/", "tags": {}, "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20230601 header.b=EN2JNFGW;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)" ], "Received": [ "from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fGwsN5rb0z1xxQ\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 20 Feb 2026 01:35:36 +1100 (AEDT)", "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1vt576-0008Sl-Q9; Thu, 19 Feb 2026 09:34:44 -0500", "from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <ruslichenko.r@gmail.com>)\n id 1vt575-0008Rc-FN\n for qemu-devel@nongnu.org; Thu, 19 Feb 2026 09:34:43 -0500", "from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <ruslichenko.r@gmail.com>)\n id 1vt573-0002uf-Fc\n for qemu-devel@nongnu.org; Thu, 19 Feb 2026 09:34:43 -0500", "by mail-wr1-x42b.google.com with SMTP id\n ffacd0b85a97d-43945763558so631832f8f.3\n for <qemu-devel@nongnu.org>; Thu, 19 Feb 2026 06:34:41 -0800 (PST)", "from thinkpad-t470s.. (93-143-129-182.adsl.net.t-com.hr.\n [93.143.129.182]) by smtp.googlemail.com with ESMTPSA id\n ffacd0b85a97d-43796abd259sm52022770f8f.24.2026.02.19.06.34.38\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 19 Feb 2026 06:34:39 -0800 (PST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20230601; t=1771511680; x=1772116480; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=EInj+fhc6M2pb85jhJLuLr62nyN+XzT/wpGcmMowrRw=;\n b=EN2JNFGW8WWQam9yEepLvVWDalY2tGR7A1uzQNYo9kUbUUdg8Z4cte8/ryXNrR0uCo\n KN3qeyfX1UQCy7v3cvOqxAOQtHuJsGE+y+6VLi6RfGTIBPcc3jhsVm2WBM780MY900hM\n yYGL3ZJXvkTPsEghlbkuwANzmsOVF3xiHEgTSVlliiopg0BHABvpnnedEsN/bGcmi2yD\n +FJXmFJ/pLUsVkIgRU4iljgK4DW0vh2+zLlL0QIHne7NyR8ooKhwnO9+alp8xG4sAj5S\n jDO6tMcB72J9HEMZva/iSUjg8aRY3tWT0N+gXBXRF5raacl4f9ZKVvquDtLh5vfNsamC\n +SLA==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1771511680; x=1772116480;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=EInj+fhc6M2pb85jhJLuLr62nyN+XzT/wpGcmMowrRw=;\n b=ZoijrrIU7/anJ4ma+2xklTTWnTiIgeHwcc+zo9yp8JhUreat1Lo95eqXJWCzaFC/ve\n Wea6TGiKQaT3YIF0CnHe3Jp6COgeo9L0uXdFWIzH3HygX8fy8df7shRh3B7rKcjjeVkC\n Gx+93jYZm970WZ1C2P9BtnAqZ5oBpjrrCDxfl37Z5+jHcb1mZxAJwmOUY710Y+gGAZXV\n 1NluT/IA8LS+fjBsoy5E3WNva+OGiLM04MVy9NNrPy+xL9gi6B1Rzuyz+Um8JGp3sgUX\n +qGqmASAnD98nSra9+zfo1zA+iHVGYRiZlAizspgTeueZdg3uJt3JaxUCV/1FjAALoNj\n t9yA==", "X-Gm-Message-State": "AOJu0YxSTExdBIl8+GyU3wpGYI+wbyh/5tee6U5sZaZ/7ntfX1apyJP5\n /L2zdYC7gCT8iKRCzAEdm+RhNpZAgGMeGG7qU4I+Kzy+c9LoPo0Gbb4z6KPI0RgN", "X-Gm-Gg": "AZuq6aIGXTus5126d6ac+2r3uApsIYPmGru6PJ2ZStxJjJhjRgo2ChisD8ms6miJMjc\n TMKIrYQbPYQUWdO2QIKkQM7Ax3iDtXC2PsC9slGtHj8tnBsgKrb7KANxs4mfrWwbRjLFLB+aMr5\n tDsYe505G4Ru30ypFj4cT0mwnS2WPk0jlA2KgXfLBwZ72CxcmXIphgIda6mEffIEtaHamcN1CAa\n IsqU9cfM5DY6yJpfQ79fPZqIVKkX21PzMl0WeB5E0kcDDgrNKyrVfYNbU137WGAVM/gzukbtxhc\n 1c3AHovsheEUIHQ/FZG563Dc4leEhwe+u0yl6erjYm+Ho81HbglyNjMUYT3WFsCXyJWAfksLEhR\n DavpK9PRDmune76L4xuGmPFMiyDJtE+6rpQhPojVidgb4jn/RjMkdNRHH5VNhpcn4aFQK1ypyWv\n Wo7L2eDJRRDwyop8t3ZPv6OfzKDr/pBH6Ki8Cz3+fwCAzPB7XcTtkWFioz1V5LqPnZieK6", "X-Received": "by 2002:a05:6000:2dc9:b0:435:960c:5286 with SMTP id\n ffacd0b85a97d-43796b0539emr38003517f8f.58.1771511679534;\n Thu, 19 Feb 2026 06:34:39 -0800 (PST)", "From": "Ruslan Ruslichenko <ruslichenko.r@gmail.com>", "To": "qemu-devel@nongnu.org", "Cc": "qemu-arm@nongnu.org, alex.bennee@linaro.org, peter.maydell@linaro.org,\n artem_mygaiev@epam.com, volodymyr_babchuk@epam.com,\n takahiro.nakata.wr@renesas.com,\n \"Edgar E . Iglesias\" <edgar.iglesias@gmail.com>,\n Ruslan_Ruslichenko@epam.com, balaton@eik.bme.hu,\n Alistair Francis <alistair.francis@wdc.com>,\n David Gibson <david@gibson.dropbear.id.au>", "Subject": "[PATCH v2 02/33] system/device_tree: add few parsing and traversal\n helpers", "Date": "Thu, 19 Feb 2026 15:33:01 +0100", "Message-ID": "<20260219143332.3316679-3-ruslichenko.r@gmail.com>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20260219143332.3316679-1-ruslichenko.r@gmail.com>", "References": "<20260219143332.3316679-1-ruslichenko.r@gmail.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Received-SPF": "pass client-ip=2a00:1450:4864:20::42b;\n envelope-from=ruslichenko.r@gmail.com; helo=mail-wr1-x42b.google.com", "X-Spam_score_int": "-20", "X-Spam_score": "-2.1", "X-Spam_bar": "--", "X-Spam_report": "(-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,\n RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,\n SPF_PASS=-0.001 autolearn=ham autolearn_force=no", "X-Spam_action": "no action", "X-BeenThere": "qemu-devel@nongnu.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "qemu development <qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<https://lists.nongnu.org/archive/html/qemu-devel>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org" }, "content": "From: Ruslan Ruslichenko <Ruslan_Ruslichenko@epam.com>\n\nThe patch adds few utility functions for parsing FDT nodes.\nThe helpers are required for upcoming Hardware device tree\nfeature.\n\nSigned-off-by: Ruslan Ruslichenko <Ruslan_Ruslichenko@epam.com>\n---\n include/system/device_tree.h | 30 +++++\n system/device_tree.c | 221 +++++++++++++++++++++++++++++++++++\n 2 files changed, 251 insertions(+)", "diff": "diff --git a/include/system/device_tree.h b/include/system/device_tree.h\nindex 5667ff9538..9d6b570bdb 100644\n--- a/include/system/device_tree.h\n+++ b/include/system/device_tree.h\n@@ -116,6 +116,11 @@ const void *qemu_fdt_getprop(void *fdt, const char *node_path,\n uint32_t qemu_fdt_getprop_cell(void *fdt, const char *node_path,\n const char *property, int cell_id,\n Error **errp);\n+\n+const void *qemu_fdt_getprop_inherited(void *fdt, const char *node_path,\n+ const char *property, int *lenp, Error **errp);\n+uint32_t qemu_fdt_getprop_cell_inherited(void *fdt, const char *node_path,\n+ const char *property, int cell_id, Error **errp);\n uint32_t qemu_fdt_get_phandle(void *fdt, const char *path);\n uint32_t qemu_fdt_alloc_phandle(void *fdt);\n int qemu_fdt_nop_node(void *fdt, const char *node_path);\n@@ -191,6 +196,31 @@ int qemu_fdt_setprop_sized_cells_from_array(void *fdt,\n qdt_tmp); \\\n })\n \n+typedef struct QEMUDevtreeProp {\n+ const char *name;\n+ int len;\n+ const void *value;\n+} QEMUDevtreeProp;\n+\n+/* node queries */\n+\n+int qemu_devtree_get_num_children(void *fdt, const char *node_path);\n+int qemu_devtree_get_children(void *fdt, const char *node_path,\n+ int max_paths, char **returned_paths);\n+int qemu_devtree_num_props(void *fdt, const char *node_path);\n+QEMUDevtreeProp *qemu_devtree_get_props(void *fdt, const char *node_path);\n+\n+/* node getters */\n+\n+int qemu_devtree_get_node_by_phandle(void *fdt, char *node_path, int phandle);\n+int qemu_devtree_getparent(void *fdt, char *node_path,\n+ const char *current);\n+\n+/* misc */\n+\n+int devtree_get_num_nodes(void *fdt);\n+\n+#define DT_PATH_LENGTH 1024\n \n /**\n * qemu_fdt_randomize_seeds:\ndiff --git a/system/device_tree.c b/system/device_tree.c\nindex d2db7bd355..fc34c660db 100644\n--- a/system/device_tree.c\n+++ b/system/device_tree.c\n@@ -464,6 +464,103 @@ uint32_t qemu_fdt_getprop_cell(void *fdt, const char *node_path,\n return be32_to_cpu(p[cell_id]);\n }\n \n+const void *qemu_fdt_getprop_inherited(void *fdt, const char *node_path,\n+ const char *property, int *lenp, Error **errp)\n+{\n+ const void *found_val = NULL;\n+ int found_len = 0;\n+ int curr_offset = 0;\n+ int temp_len;\n+ char **tokens;\n+ char **iter;\n+\n+ found_val = fdt_getprop(fdt, 0, property, &found_len);\n+\n+ tokens = g_strsplit(node_path + 1, \"/\", -1);\n+\n+ for (iter = tokens; *iter != NULL; iter++) {\n+ if (**iter == '\\0') {\n+ continue;\n+ }\n+\n+ curr_offset = fdt_subnode_offset(fdt, curr_offset, *iter);\n+ if (curr_offset < 0) {\n+ error_setg(errp, \"%s: Path '%s' not found\",\n+ __func__, *iter);\n+ g_strfreev(tokens);\n+ return NULL;\n+ }\n+\n+ const void *val = fdt_getprop(fdt, curr_offset, property, &temp_len);\n+ if (val) {\n+ found_val = val;\n+ found_len = temp_len;\n+ }\n+ }\n+ g_strfreev(tokens);\n+\n+ if (!found_val) {\n+ error_setg(errp, \"%s: Property '%s' not found\",\n+ __func__, property);\n+ return NULL;\n+ }\n+\n+ if (lenp) {\n+ *lenp = found_len;\n+ }\n+\n+ return found_val;\n+}\n+\n+uint32_t qemu_fdt_getprop_cell_inherited(void *fdt, const char *node_path,\n+ const char *property, int cell_id, Error **errp)\n+{\n+ int len;\n+ const uint32_t *p;\n+\n+ p = qemu_fdt_getprop_inherited(fdt, node_path, property, &len, errp);\n+ if (!p) {\n+ return 0;\n+ }\n+ if (len < (cell_id + 1) * 4) {\n+ error_setg(errp,\n+ \"%s: %s/%s is too short, need %d bytes for cell ind %d\",\n+ __func__, node_path, property, (cell_id + 1) * 4, cell_id);\n+ return 0;\n+ }\n+ return be32_to_cpu(p[cell_id]);\n+}\n+\n+int qemu_devtree_getparent(void *fdt, char *node_path, const char *current)\n+{\n+ const char *sep;\n+ int len;\n+\n+ if (!current || !node_path) {\n+ return -FDT_ERR_NOTFOUND;\n+ }\n+\n+ if (current[0] == '/' && current[1] == 0) {\n+ return -FDT_ERR_NOTFOUND;\n+ }\n+\n+ sep = strrchr(current, '/');\n+ if (!sep) {\n+ return -FDT_ERR_BADPATH;\n+ }\n+\n+ if (sep == current) {\n+ len = 1;\n+ } else {\n+ len = sep - current;\n+ }\n+\n+ memcpy(node_path, current, len);\n+ node_path[len] = '\\0';\n+\n+ return 0;\n+}\n+\n uint32_t qemu_fdt_get_phandle(void *fdt, const char *path)\n {\n uint32_t r;\n@@ -631,6 +728,130 @@ out:\n return ret;\n }\n \n+int qemu_devtree_num_props(void *fdt, const char *node_path)\n+{\n+ int offset = fdt_path_offset(fdt, node_path);\n+ int ret = 0;\n+\n+ for (offset = fdt_first_property_offset(fdt, offset);\n+ offset != -FDT_ERR_NOTFOUND;\n+ offset = fdt_next_property_offset(fdt, offset)) {\n+ ret++;\n+ }\n+ return ret;\n+}\n+\n+QEMUDevtreeProp *qemu_devtree_get_props(void *fdt, const char *node_path)\n+{\n+ QEMUDevtreeProp *ret = g_new0(QEMUDevtreeProp,\n+ qemu_devtree_num_props(fdt, node_path) + 1);\n+ int offset = fdt_path_offset(fdt, node_path);\n+ int i = 0;\n+\n+ for (offset = fdt_first_property_offset(fdt, offset);\n+ offset != -FDT_ERR_NOTFOUND;\n+ offset = fdt_next_property_offset(fdt, offset)) {\n+ const char *propname;\n+ const void *val = fdt_getprop_by_offset(fdt, offset, &propname,\n+ &ret[i].len);\n+\n+ ret[i].name = propname;\n+ ret[i].value = val;\n+ i++;\n+ }\n+ return ret;\n+}\n+\n+int qemu_devtree_get_children(void *fdt, const char *node_path,\n+ int max_paths, char **returned_paths) {\n+ int count = 0;\n+ int subnode;\n+ const char *name;\n+ int offset = fdt_path_offset(fdt, node_path);\n+\n+ if (offset < 0) {\n+ return offset;\n+ }\n+\n+ bool is_root = (strcmp(node_path, \"/\") == 0);\n+\n+ fdt_for_each_subnode(subnode, fdt, offset) {\n+ if (count >= max_paths) {\n+ break;\n+ }\n+ name = fdt_get_name(fdt, subnode, NULL);\n+ if (returned_paths) {\n+ returned_paths[count] = g_strdup_printf(\"%s/%s\",\n+ is_root ? \"\" : node_path, name);\n+ }\n+\n+ ++count;\n+ }\n+\n+ return count;\n+}\n+\n+int qemu_devtree_get_num_children(void *fdt, const char *node_path)\n+{\n+ int count = 0;\n+ int subnode;\n+ int offset = fdt_path_offset(fdt, node_path);\n+\n+ if (offset < 0) {\n+ return offset;\n+ }\n+\n+ fdt_for_each_subnode(subnode, fdt, offset) {\n+ ++count;\n+ }\n+\n+ return count;\n+}\n+\n+int qemu_devtree_get_node_by_phandle(void *fdt, char *node_path, int phandle)\n+{\n+ int offset = 0, cur_depth = 0;\n+ int path_lens[64] = { 0 };\n+\n+ for (offset = 0; offset >= 0; offset = fdt_next_node(fdt, offset,\n+ &cur_depth)) {\n+ if (cur_depth > 64) {\n+ break;\n+ }\n+ const char *name = fdt_get_name(fdt, offset, NULL);\n+\n+ int parent_len = (cur_depth > 0) ? path_lens[cur_depth - 1] : 0;\n+ int len = snprintf(node_path + parent_len,\n+ DT_PATH_LENGTH - parent_len,\n+ \"%s%s\",\n+ (parent_len > 1) ? \"/\" : \"\",\n+ (cur_depth == 0) ? \"/\" : name);\n+\n+ path_lens[cur_depth] = parent_len + len;\n+\n+ if (fdt_get_phandle(fdt, offset) == phandle) {\n+ return 0;\n+ }\n+ }\n+\n+ return -FDT_ERR_NOTFOUND;\n+}\n+\n+int devtree_get_num_nodes(void *fdt)\n+{\n+ int num_nodes = 0;\n+ int depth = 0, offset = 0;\n+\n+ for (;;) {\n+ offset = fdt_next_node(fdt, offset, &depth);\n+ num_nodes++;\n+ if (offset <= 0 || depth <= 0) {\n+ break;\n+ }\n+ }\n+ return num_nodes;\n+}\n+\n void qmp_dumpdtb(const char *filename, Error **errp)\n {\n ERRP_GUARD();\n", "prefixes": [ "v2", "02/33" ] }