From nobody Sat Jul 25 03:12:44 2026 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 551D93B4EAA for ; Mon, 20 Jul 2026 07:03:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784531001; cv=none; b=OitdUR+v7H08hN1JH7Y23Dxr8MQMjDjXA2z5I6DwLFJbXf3zSbQs8WW+95R4LuWYSgpIrv+5FZJbaiXHzyXR8uAvsTL0W18X/G7DcyTX3Qae0kLkzsXcMrYfxUIk0LgIcM6lXoFIKPfcFYyPBuD4nhtiNTFMp1uc/leczT5o6+4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784531001; c=relaxed/simple; bh=AXh/+BVSNBJekVgTzZxSzokTgbsSUiKAaKcyY0FFV2I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CMUv3jpiSOuJxf5YiVvcDhiPBYpcBSrA28B5Ik7Rnc0DKXFf3DUCiYHvyuwtQu7F2Mhxtc6fmClR10ts3HIcIU5jIruk5vqeNEXiRjkOhE8zQUeWXiru9e9lYoEvcJNWaWhUrs1Gdfk6ZF43NZkmeTjSgVsE6KtO8wDILZxJqyI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nexthop.ai; spf=pass smtp.mailfrom=nexthop.ai; dkim=pass (2048-bit key) header.d=nexthop.ai header.i=@nexthop.ai header.b=SzeLJDUs; arc=none smtp.client-ip=209.85.216.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nexthop.ai Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nexthop.ai Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nexthop.ai header.i=@nexthop.ai header.b="SzeLJDUs" Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-38e3617ba36so4142133a91.3 for ; Mon, 20 Jul 2026 00:03:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nexthop.ai; s=google; t=1784530999; x=1785135799; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ZKwZA/kKgqjbce/z+Ie0wgEXyyQ4XQnnJsQw4aZLb2o=; b=SzeLJDUsItrr6L7SVRkymOTUMyOfWXpHXD/eBzyUwKCj+lnLObz2gy3Okv/cu+c1X+ dSt8s3XH5fuSJRWwVEjIzzAvCJbAQmzIILWyCRb+uX816WzgIEjFpMZ+1RXS51lmtYlI l8aEji5VJ9r3A23Tr1ENOBv1sLx3ySGafbdQ8aSc784tqmsL+/v1l4wgTEqcZ7iQ/mu0 5Egj1QzFdwaMGT/yNkUxjq4+FlQn2hvScroWSLlog4kjZPe2kEjDUMwP5ppZueBr3SBV KPO58pjFRiQxIjw7cP59J0lLtHgIAHSlIDv8T8gjncrWm2Bbcxg2f8lF2PbIsW0deBHL /GWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784530999; x=1785135799; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ZKwZA/kKgqjbce/z+Ie0wgEXyyQ4XQnnJsQw4aZLb2o=; b=RdDQTGZ7275fYhBL/nRPIqLuYH/56+j+gV4JAD+O4CAEV74793oQ0g2k5rjkwAath2 aYk2DwiKJ+D+jk5H0ktENxN4UesSLlc0RqgzWIxBFbxhNwswYGEKuCRvf25D87+EbDmf gdDgJYcTXjUfUvcTJGfRSBlaxgRXbvQ1m0XCnSdFg17tbSy36+bLfP/Nb1/fFv7q449t zEvo0JoUgGCWKo637/FQ+dVEgTX3EY1OhV5Lz6haSmw+XoGOf1vp3U1fjY4o1mpkuTCE W5P3+7ztz5oo/tCzs10087njlEzw6RN3xeCIrFuM/mu5GBAikq8zvBReRB14zFb1EFKG SH/g== X-Forwarded-Encrypted: i=1; AHgh+Rq4W8FEp8dn+qRpIjq5DTyBFy2SeGgFUkMHR/gkgOdI/3S1zof/cJT6nXoY27/NqyAwpdkAuR99FyRGzw8=@vger.kernel.org X-Gm-Message-State: AOJu0YxmdK4FZh10gISflOaIGXc3Q3d0xAmdNxhvcadYXW65wKEsSjse MRXK7Yan3Di6Dd+JIMkp+4kl6tBRRD78fQ7+jc+E+ZBuAmMD5fGPECz6OU3u6BHKuRI= X-Gm-Gg: AfdE7clwonXQ7ow43zQjMsGwXbNrb/gqNR1A4lv5VECE5JZ8wbsIWTmLiuHUDwAuYqL HG6EmxItftjFPJqhvugUXrJpKo4siV2eNFeKB/H0H3TRPQ0YTKyT39CaZ40l5XdhVe4O7f+kIVK iV56q3qcdNRntEmggNYWH1Zry0T47eZo4AgqSfiza6sZFKqBIlxx8eUWimkh9/xmTsTBiYMQFLn pSJyGuHCsrhxTlmzq6XzgPtTUO5ydJqDXjUNjKK2gYY+pDhomVSYynPCbmdOiKfqJ1nqHPBDa5U coQWJgKV7gM4tG7O3rGpapjRPrKOmLYZ9mIx3QMfd1n7PWfsHJcJnJK+IEvlZUjC3T5y7VSfbON 9I2g/s1Yx2M42RNhN/GKtc90ezx60c0mvjDtMlwlWaQIAKXN4z35yvchnh0aWoH/+0rnQQPxGjv sgY68q X-Received: by 2002:a17:90b:2692:b0:380:a568:cc4e with SMTP id 98e67ed59e1d1-38e4b3e11c8mr13395985a91.9.1784530999256; Mon, 20 Jul 2026 00:03:19 -0700 (PDT) Received: from [127.0.0.2] ([50.145.100.174]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-38e60cc2ad5sm463052a91.4.2026.07.20.00.03.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 00:03:18 -0700 (PDT) From: Abdurrahman Hussain Date: Mon, 20 Jul 2026 00:02:50 -0700 Subject: [PATCH RFC 1/4] of: incrementally update /aliases lookup on reconfig notifications Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260720-nh-of-alias-overlay-v1-1-f1e5d9889b30@nexthop.ai> References: <20260720-nh-of-alias-overlay-v1-0-f1e5d9889b30@nexthop.ai> In-Reply-To: <20260720-nh-of-alias-overlay-v1-0-f1e5d9889b30@nexthop.ai> To: Rob Herring , Saravana Kannan Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Abdurrahman Hussain X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784530997; l=10139; i=abdurrahman@nexthop.ai; s=20260510; h=from:subject:message-id; bh=AXh/+BVSNBJekVgTzZxSzokTgbsSUiKAaKcyY0FFV2I=; b=Y92NlrUJulTwPHL0XGt/BnMV1CEpavP0tnNyNXOtf62TQWqSacepXMfBtlfu5e4TbKGunIbsl QBOcg0kQhHSB/rDWVCwSgs6OTt7aXggZII5mEZSA+65aSnBVic+XNyw X-Developer-Key: i=abdurrahman@nexthop.ai; a=ed25519; pk=omTm9cCAbO0ZhS32aKfJDKue0W3sQGpG9ub5eYHif8I= /aliases entries added by a device-tree overlay are stored in the live tree but never enter the global aliases_lookup list that of_alias_scan() builds at boot. As a result, of_alias_get_id() returns -ENODEV for aliases declared inside overlays, and any driver that relies on alias-based numbering (i2c-xiic, spi, tty, mmc, ...) silently loses its pinned id and falls back to auto-assignment. Fix by registering an internal OF reconfig notifier from of_core_init() that mirrors /aliases property changes into aliases_lookup: OF_RECONFIG_ADD_PROPERTY -> of_alias_create(pp, kzalloc, owned=3Dtrue) OF_RECONFIG_REMOVE_PROPERTY -> of_alias_destroy(name) OF_RECONFIG_UPDATE_PROPERTY -> destroy + create The reconfig notifier chain fires from both direct changesets and overlay apply/revert, so the same code path covers runtime dt modifications and overlay-declared aliases without any overlay- specific hook in drivers/of/overlay.c. Grant Likely suggested this shape on Geert Uytterhoeven's 2015 RFC [1]; Geert's original hook was in dynamic.c directly. Match the /aliases target node structurally (name =3D=3D "aliases" and parent =3D=3D root) rather than by pointer against the of_aliases global. A system with no boot-time /aliases has of_aliases =3D=3D NULL, so an overlay that creates /aliases from scratch would otherwise be missed from the first ATTACH_NODE onward. The ATTACH/DETACH_NODE cases also update of_aliases lazily so subsequent consumers see it. Factor the per-property loop body of of_alias_scan() into of_alias_create() so the boot-time scan and the runtime notifier share one code path. Add a one-bit @owned flag to struct alias_prop tracking whether the entry was kmalloc'd (overlay-time) or came from the boot- time memblock allocator via of_alias_scan(). of_alias_destroy() skips non-owned entries, so an overlay-driven UPDATE_PROPERTY against a boot-time alias can't kfree() memblock storage =E2=80=94 addressing the allocator-mismatch worry Grant flagged on the 2015 series [2]. An @owned entry also holds an of_node_get() reference to its target, released by of_alias_destroy(); this fixes a smaller leak Geert's original of_alias_create() would have introduced for overlay targets. Naming builds on Geert's original series: - "of: Extract of_alias_create()" [3] - "of: Add of_alias_destroy()" [4] - "of/dynamic: Update list of aliases on aliases changes" [5] Link: https://lore.kernel.org/lkml/1435675876-2159-1-git-send-email-geert+r= enesas@glider.be/ [1] Link: https://lore.kernel.org/lkml/20150630172131.D4E6CC4041A@trevor.secret= lab.ca/ [2] Link: https://lore.kernel.org/lkml/1435675876-2159-2-git-send-email-geert+r= enesas@glider.be/ [3] Link: https://lore.kernel.org/lkml/1435675876-2159-3-git-send-email-geert+r= enesas@glider.be/ [4] Link: https://lore.kernel.org/lkml/1435675876-2159-4-git-send-email-geert+r= enesas@glider.be/ [5] Signed-off-by: Abdurrahman Hussain --- drivers/of/base.c | 184 ++++++++++++++++++++++++++++++++++++++------= ---- drivers/of/of_private.h | 7 ++ 2 files changed, 155 insertions(+), 36 deletions(-) diff --git a/drivers/of/base.c b/drivers/of/base.c index 6e7a42dedad3..d516523a71d5 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -1915,6 +1915,152 @@ static void of_alias_add(struct alias_prop *ap, str= uct device_node *np, ap->alias, ap->stem, ap->id, np); } =20 +/* + * Build an alias_prop for @pp using @dt_alloc as the storage allocator + * and add it to aliases_lookup. @owned is stored on the entry so the + * matching destroy path knows whether the alias_prop is a kmalloc'd + * struct that must be kfree()d (with a paired of_node_put on the + * target) or a memblock/dt_alloc'd struct that must be left alone. + * + * Pseudo-properties (name, phandle, ...) and alias names not ending in + * a numeric id are silently skipped. + */ +static void of_alias_create(const struct property *pp, + void *(*dt_alloc)(u64 size, u64 align), + bool owned) +{ + const char *start =3D pp->name; + const char *end =3D start + strlen(start); + struct device_node *np; + struct alias_prop *ap; + int id, len; + + if (is_pseudo_property(pp->name)) + return; + + np =3D of_find_node_by_path(pp->value); + if (!np) + return; + + while (isdigit(*(end - 1)) && end > start) + end--; + len =3D end - start; + + if (kstrtoint(end, 10, &id) < 0) + goto out_put; + + ap =3D dt_alloc(sizeof(*ap) + len + 1, __alignof__(*ap)); + if (!ap) + goto out_put; + memset(ap, 0, sizeof(*ap) + len + 1); + ap->alias =3D start; + ap->owned =3D owned; + of_alias_add(ap, np, id, start, len); + return; + +out_put: + /* + * Boot-time entries reach here on parse failure; leaking the + * of_node_get() from of_find_node_by_path() is fine because the + * boot tree is never freed. Overlay-time entries need the put so + * the target node's refcount tracks the failed-parse case + * symmetrically with success. + */ + if (owned) + of_node_put(np); +} + +/* + * Reverse of of_alias_create(): find the owned alias_prop whose name + * matches @name, unlink it, and release everything it owns. Non-owned + * (boot-time) entries are skipped so an overlay-driven UPDATE against + * a boot-time alias can't kfree() memblock storage. That does mean an + * overlay updating a boot-time alias leaves two entries in + * aliases_lookup =E2=80=94 deferred as a separate cleanup. + */ +static void of_alias_destroy(const char *name) +{ + struct alias_prop *ap, *tmp; + + list_for_each_entry_safe(ap, tmp, &aliases_lookup, link) { + if (!ap->owned || strcmp(ap->alias, name) !=3D 0) + continue; + list_del(&ap->link); + of_node_put(ap->np); + kfree(ap); + return; + } +} + +static void *alias_alloc(u64 size, u64 align) +{ + return kzalloc(size, GFP_KERNEL); +} + +/* + * OF reconfig notifier that mirrors /aliases property changes into + * aliases_lookup. Fires on both direct changesets and overlay + * apply/revert, so of_alias_get_id() returns the right id for aliases + * declared inside an overlay. + */ +static int of_aliases_reconfig_notifier(struct notifier_block *nb, + unsigned long action, void *arg) +{ + struct of_reconfig_data *rd =3D arg; + + /* + * Match /aliases structurally (name + root-parent) rather than by + * pointer against the of_aliases global =E2=80=94 a system with no + * boot-time /aliases (of_aliases =3D=3D NULL) can still acquire one + * from an overlay, and we must track its properties from the + * first ATTACH_NODE onward. + */ + if (!rd->dn || !rd->dn->parent || + !of_node_is_root(rd->dn->parent) || + !of_node_name_eq(rd->dn, "aliases")) + return NOTIFY_DONE; + + switch (action) { + case OF_RECONFIG_ATTACH_NODE: + if (!of_aliases) + of_aliases =3D rd->dn; + break; + case OF_RECONFIG_DETACH_NODE: + if (of_aliases =3D=3D rd->dn) + of_aliases =3D NULL; + break; + case OF_RECONFIG_ADD_PROPERTY: + of_alias_create(rd->prop, alias_alloc, true); + break; + case OF_RECONFIG_REMOVE_PROPERTY: + of_alias_destroy(rd->prop->name); + break; + case OF_RECONFIG_UPDATE_PROPERTY: + of_alias_destroy(rd->old_prop->name); + of_alias_create(rd->prop, alias_alloc, true); + break; + default: + break; + } + return NOTIFY_OK; +} + +static struct notifier_block of_aliases_nb =3D { + .notifier_call =3D of_aliases_reconfig_notifier, +}; + +static int __init of_aliases_reconfig_init(void) +{ + return of_reconfig_notifier_register(&of_aliases_nb); +} + +/* + * of_alias_scan() runs from of_core_init() (core_initcall), so hook the + * reconfig notifier one initcall level later to guarantee the initial + * static scan is complete before any dynamic tracking begins. + */ +core_initcall_sync(of_aliases_reconfig_init); + /** * of_alias_scan - Scan all properties of the 'aliases' node * @dt_alloc: An allocator that provides a virtual address to memory @@ -1950,42 +2096,8 @@ void of_alias_scan(void * (*dt_alloc)(u64 size, u64 = align)) if (!of_aliases) return; =20 - for_each_property_of_node(of_aliases, pp) { - const char *start =3D pp->name; - const char *end =3D start + strlen(start); - struct device_node *np; - struct alias_prop *ap; - int id, len; - - /* Skip those we do not want to proceed */ - if (is_pseudo_property(pp->name)) - continue; - - np =3D of_find_node_by_path(pp->value); - if (!np) - continue; - - /* walk the alias backwards to extract the id and work out - * the 'stem' string */ - while (isdigit(*(end-1)) && end > start) - end--; - len =3D end - start; - - if (kstrtoint(end, 10, &id) < 0) { - of_node_put(np); - continue; - } - - /* Allocate an alias_prop with enough space for the stem */ - ap =3D dt_alloc(sizeof(*ap) + len + 1, __alignof__(*ap)); - if (!ap) { - of_node_put(np); - continue; - } - memset(ap, 0, sizeof(*ap) + len + 1); - ap->alias =3D start; - of_alias_add(ap, np, id, start, len); - } + for_each_property_of_node(of_aliases, pp) + of_alias_create(pp, dt_alloc, false); } =20 /** diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h index 0ae16da066e2..9d16765ae2c3 100644 --- a/drivers/of/of_private.h +++ b/drivers/of/of_private.h @@ -17,6 +17,12 @@ * @alias: Alias property name * @np: Pointer to device_node that the alias stands for * @id: Index value from end of alias name + * @owned: True if @alias was kstrdup'd and @np was of_node_get'd on + * insertion (overlay-time entries). False for entries built + * by of_alias_scan() at boot, where @alias points into the + * FDT and @np is an unreferenced pointer. The removal path + * uses this flag to decide whether it must kfree(@alias), + * of_node_put(@np), and kfree(the struct itself). * @stem: Alias string without the index * * The structure represents one alias property of 'aliases' node as @@ -27,6 +33,7 @@ struct alias_prop { const char *alias; struct device_node *np; int id; + bool owned; char stem[]; }; =20 --=20 2.54.0 From nobody Sat Jul 25 03:12:44 2026 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DEBE53B6341 for ; Mon, 20 Jul 2026 07:03:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784531002; cv=none; b=eclmdRWAy4Q4rAPWQAonkNRqp/y9F+ywMJ6bb1uf02O2mIOGCoHz2lHnz1xYWIxge1scklE7LZkdjBur/nOGehYSlwANqALhMUlzZGMGw2xwigL43Paz0b1SQUsx6vCMLK4lQict6imt6bCNl+Glwn0uF1EGfaJtpUGrQ2ERK10= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784531002; c=relaxed/simple; bh=R6tBpLfkSYlFbeXQtoe6ybjEQWYkSemCib35gwY2h1U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PVrT9xaW3N/V/UYXoiiTwhQFEufpd/fpx5HmpWe29WREQQow7jIDSSl6ffIws3YCvYb9A3nwIKFEsA8Gceac2nG0EsS3o2mhzqJxhP0x0oZB9iJVWYl1vsl0FfBUVyys67+MtopclXa6oLUiBP0PjGwCbKyvs3V17KtthW3LjQ8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nexthop.ai; spf=pass smtp.mailfrom=nexthop.ai; dkim=pass (2048-bit key) header.d=nexthop.ai header.i=@nexthop.ai header.b=clzU1yRn; arc=none smtp.client-ip=209.85.216.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nexthop.ai Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nexthop.ai Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nexthop.ai header.i=@nexthop.ai header.b="clzU1yRn" Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-383b4a3755fso6101149a91.3 for ; Mon, 20 Jul 2026 00:03:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nexthop.ai; s=google; t=1784531000; x=1785135800; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Jb3SzunVzCrAW1kpVHD7vkFwItBmsZgciNXBopwYDGc=; b=clzU1yRniYhUJ6RtlG4JaeeE5wD57r6dTaYJZHMmZyUmdijQtdxQ1FFPglYfEb7pKn UeUe1MeIuAxoquYQdcM+GkfzCvMU5nWl3RkzrSdhTau+S+T5aHz/O+Xj/ueXkv9VB8r4 1JAaZjJ6RIcKD581p+z6IsBWNpv2rsly8NaSCbYXDWU4mSsh0NVuB16Yd/mWEeQk0EV7 +uysH5kOTcvFUgsOjI+4Oh8oDFgqXe3pZSi5i8GHtx+VIWyrMGDEpXVwQlu3zpVRXu/d pLcNv3qMomgyfYn9/8XC39PMzn3ZFjxEWwHvehpzavtwzxobt6k1qnfKGOe/fZzIrs3H YrTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784531000; x=1785135800; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Jb3SzunVzCrAW1kpVHD7vkFwItBmsZgciNXBopwYDGc=; b=nm3xzUDY+QCu7PNh0yoaP78z6WjRXkGusrxNLa+AfGgZ9ZR2knMFN9Qi/WOZjUxXZO VqSGCA0otphurQ5hvm2ykGr/8KZBmugMonadHmdGBDHmPBmkYQz56+Ave0zYXdOLpNbA BMnpSxWHjwMxScFaZgdhPNO09RXKFu42bRb7ilf6muhbmZxQ6rWrY2x6dPUUG5u7TuOX AIFlZQx8yAVVL9+x2srccvpLJmMVUapksWXGeVEUrKjaZlOSzjm0fUxdZzQD/vy9Oua4 4NcbC+fnuAaKVMmdptPrp4guNna3DTGsVDmRd6LuElmlVUidmVvHIrQ4L8enrT9qm5sj Ysnw== X-Forwarded-Encrypted: i=1; AHgh+RqmBBikATStz82L5TeKB5s7aOhe17x1PR8NaAsUXSW555kajFgnEv5/3wWDDMO8ZJtT4XB+Zk5mUjnIxSc=@vger.kernel.org X-Gm-Message-State: AOJu0YwzpSLSAOo8OlYIKGdmV3SiUc61U/GgcSW2IypjNO7zXyIQ9FXl gKk5rn9P8dN321vtIPkpwuGUf/uEv5isH5qmTIIp74i8WmYWICWM9JOTP0mV9OWj/qE= X-Gm-Gg: AR+sD11XVUwcZi+HwyHWNh8+P8zh3e8B8mqSEX62hZl2UO1zEl7FCgs8OEaTDk8jrTF KiAn/cmgjw1fDlIpaRGn2aW8enAGGSXBa133OPjnxbElIBzzYO2Cn+MlIIqWhwf3uy8WjBup/Hc LWGou9bze2EpTht9RBz8x89Z1dOLq1+hIpnc4a1/ZPx/5OVPCO3BIOJcqCWguZhpECbgde6ea2k oXo/ej4G2tSNsY1XxizRUurfNRnuK+FDHWUzUWr1y7OzoqqUjQMosSmHhtNcQGBX2iwAitq/3aZ wctawJHrKGkOh0ZZmzRHhzUW6+YC3gVhM5LV9Y08MiP6/VY8t2UMlkIFtDgK/r82R0pUYz7oQtF +x7KIFbO7fERnNCY9qBITKXub3Vx5v0GlI9G8aq/bnirqRNAIJ53EfQ2PXKRcf2GB0N+9B43ImL XFKZQ41w7e2Lajo2o= X-Received: by 2002:a17:90b:442e:b0:38e:5701:644a with SMTP id 98e67ed59e1d1-38e570170d9mr7802747a91.27.1784531000271; Mon, 20 Jul 2026 00:03:20 -0700 (PDT) Received: from [127.0.0.2] ([50.145.100.174]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-38e60cc2ad5sm463052a91.4.2026.07.20.00.03.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 00:03:19 -0700 (PDT) From: Abdurrahman Hussain Date: Mon, 20 Jul 2026 00:02:51 -0700 Subject: [PATCH RFC 2/4] of/overlay: look up absolute target-paths absolutely Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260720-nh-of-alias-overlay-v1-2-f1e5d9889b30@nexthop.ai> References: <20260720-nh-of-alias-overlay-v1-0-f1e5d9889b30@nexthop.ai> In-Reply-To: <20260720-nh-of-alias-overlay-v1-0-f1e5d9889b30@nexthop.ai> To: Rob Herring , Saravana Kannan Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Abdurrahman Hussain X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784530997; l=3039; i=abdurrahman@nexthop.ai; s=20260510; h=from:subject:message-id; bh=R6tBpLfkSYlFbeXQtoe6ybjEQWYkSemCib35gwY2h1U=; b=TXgPnutlRoNe0Wge8odd/KK0fuVD2uAR0WfDoS6ArpQ035gAW51sflvkhAFsNWcKhhMyL6i8n 0ZwMaNU6wZfCYJLakp7ZO/1psakX+WO2MNId8kmjZxsuiURfTE1nDKN X-Developer-Key: i=abdurrahman@nexthop.ai; a=ed25519; pk=omTm9cCAbO0ZhS32aKfJDKue0W3sQGpG9ub5eYHif8I= When of_overlay_fdt_apply() is called with a non-NULL target base, find_target() currently concatenates the base's full path with every fragment's target-path via "%pOF%s" =E2=80=94 so target-path=3D"" resolves = to the base itself (the intended common case), but target-path=3D"/foo" resolves to "/foo" (never the DT root) and target-path=3D"/" to "/" (never a valid node at all). That makes it impossible for a two-fragment overlay to modify one subtree under the base and one node at the DT root =E2=80=94 a shape that arises naturally when a PCI-attached device wants to declare its peripherals under dev_of_node(&pdev->dev) AND add /aliases entries so alias-aware drivers (i2c-xiic, spi, tty, ...) can pin bus numbers. Treat target-path as absolute whenever it is non-empty. An empty target-path continues to mean "the target base itself", preserving the existing shape used by drivers/misc/lan966x_pci.c and its dtso (the only in-tree of_overlay_fdt_apply() caller today that passes a non-NULL base). Signed-off-by: Abdurrahman Hussain --- drivers/of/overlay.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index 08d5351746be..654a70d5cb07 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -693,7 +693,6 @@ static struct device_node *find_target(const struct dev= ice_node *info_node, const struct device_node *target_base) { struct device_node *node; - char *target_path; const char *path; u32 val; int ret; @@ -709,23 +708,22 @@ static struct device_node *find_target(const struct d= evice_node *info_node, =20 ret =3D of_property_read_string(info_node, "target-path", &path); if (!ret) { - if (target_base) { - target_path =3D kasprintf(GFP_KERNEL, "%pOF%s", target_base, path); - if (!target_path) - return NULL; - node =3D of_find_node_by_path(target_path); - if (!node) { - pr_err("find target, node: %pOF, path '%s' not found\n", - info_node, target_path); - } - kfree(target_path); - } else { - node =3D of_find_node_by_path(path); - if (!node) { - pr_err("find target, node: %pOF, path '%s' not found\n", - info_node, path); - } - } + /* + * With a non-NULL @target_base, an empty target-path means + * "the target base itself" =E2=80=94 this is the common + * of_overlay_fdt_apply(..., base) form used by e.g. the + * LAN966x PCI overlay. Any other target-path is looked up + * absolutely, so overlays that also need to reach the DT + * root (e.g. to add /aliases entries alongside a base- + * relative fragment) can do so with target-path=3D"/aliases". + */ + if (target_base && path[0] =3D=3D '\0') + return of_node_get((struct device_node *)target_base); + + node =3D of_find_node_by_path(path); + if (!node) + pr_err("find target, node: %pOF, path '%s' not found\n", + info_node, path); return node; } =20 --=20 2.54.0 From nobody Sat Jul 25 03:12:44 2026 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFB613B6C01 for ; Mon, 20 Jul 2026 07:03:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784531003; cv=none; b=NCK9eFVzICcG8WrI1/aBcyp+BW2R+tQjr/bWmb14o0yR+6AsJDFc9CGZuSuwlVASFWUFRURMSy+D8p0xngY+nrBzfuzh4O+jxt0iYmJa+VLNALqq+2nzYJ7GK7KAhBXA4VDDOZoZJgZ9ltXUPnqUo0OhTQHE7/mbVaxm2V2k3vA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784531003; c=relaxed/simple; bh=ukiUyExq0XnTaCqoO00vJRBVYD+CBNPsreTEPosjgA8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Yn6aG7Vw2JAuA4miAGqblkW5mspp2PP51wuA5cyrC5bdNPqdVFHdeajHuzbmkxZT7UmOwZ6QXslU2ODMBfIFmH1yWvL+C7FxZIYqhCN7wyS7KNMJFCh1Wx0g0Sv1ksTuYiXpwcy81gf9BTFz2ekYDl3Td4fxpBgVyQDxA9Yj2uI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nexthop.ai; spf=pass smtp.mailfrom=nexthop.ai; dkim=pass (2048-bit key) header.d=nexthop.ai header.i=@nexthop.ai header.b=FrzAGAu9; arc=none smtp.client-ip=209.85.216.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nexthop.ai Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nexthop.ai Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nexthop.ai header.i=@nexthop.ai header.b="FrzAGAu9" Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-38759bcd877so8406490a91.2 for ; Mon, 20 Jul 2026 00:03:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nexthop.ai; s=google; t=1784531001; x=1785135801; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=l3pCI8QzdNtZEY1wJy1ziEltENbQOXThfdEHc5FunM0=; b=FrzAGAu9NqVdnNmW6KufJQcoeElVkzTz0lxV4TySd7Chccu7zufDtq+bmIUwYTD17y s7okRgJspqtJDMMlsWrx1lOreGLYU6uiI3aDstcqCLqDiJxNCAe5Z12rhnYdPbHCrQEf l9R2NHg6VHDuVc5qfTFFqZg1WsVF4oPrWWGHJo5UlA3Wbd2dvNOBtaAj5OBAsf+OrXKn 1MyHAti6k8bX5z5VeU8eUb5rXbUK4C2aU6cOM+IAmUxV+UTpCVvpGhykOS5KQH9qxBnt zMtbUqltwBWQ6xeFzevsijUgVtKmVUyQb9inE+VqoOXw43FuG8GKy/5AJf80gjiBZlza qHuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784531001; x=1785135801; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=l3pCI8QzdNtZEY1wJy1ziEltENbQOXThfdEHc5FunM0=; b=pKiLenDtO7aEBzU8GgQ2fYFZ3ebFgxliEfEmhlLwL83fSjF2GPc6P2zJwXzm014R/0 3+jnrzvZ9E2NTFr09wO7tC1XdS9keWDSe5CDNKF1n/AZdBWl1V3K3rOyywHPzxVrl9wT CAbpk+PvZwGmK3CMvCE+ROKr9lIymKRcVIcO4LXhkybFjuTpa2a794uaGUH19C2h6jGg NN3bDeRSbp06GmX6X/2aTwFlc3oKW4Gpfw38Xzf7XAAPKK+lV+GyGJ4Pki8v/eTFlWy4 hbcDJyfu5qOExSiweyobsoFKGllLQvc8T+wrUeaBnAbfkngq8A+Hu/tLjTLhkhBApEaC mIbw== X-Forwarded-Encrypted: i=1; AHgh+RodWJkZE5aWTQIOAxlDyWdPayZQo/AO4EyY8J+w6qwC81eo2pw9K3Q+Sbgi3nPt28BL8NtIh3kfZWVbVn8=@vger.kernel.org X-Gm-Message-State: AOJu0YwPdREOhc1ckP2i7XLVxWP0SWVdS2tP4TUdjk+tQSLKU9FQPvsS jN9i13VBXL6vsRNMmW4IT393JUbpScesQbhE6owmtlQGX8Kijp93C24xoC6mJjTcUiU= X-Gm-Gg: AR+sD10BjSZtDxlPgNnq/ZFGqIMR1kGQSh3FDk8/AOVEyggmOsh8pKooXf/jkYuy8cK 0OmoqlZ8IiS4TDNAyt8huwziPVzbCG0q5mxfwVSdI4BA5qQz4VP/sRumj+LdWBTjWgE+8m74Kyz Gx4MK9slN9Dk2oBfFBs6U7dxp3iB/f9aq2VlZl51M7S5o88unXqLm6tf31uByDjWpJnmXqUKFcA mTso3KAnMBFBx9z/yHHmDFoTIHfQF1LUQPfrB8V5a2+MW9irUn1pmiIqS/euITB7qWcifVeeVLq U6vjytUMXKc5HzwMAD5Fk9zaWKPBwXqRobf52/QQVNGURmFmCD5ObxSzzJGnRaEMkY6PYQ920em Cg2qCZIEC+saD3lLX5zOasjrFrs2bPTFB8Q2NRaaSEse6WS9e5unJQ2y26AvQM3UPh+0QJdp6Q6 ysCPrw8stjqIIwycs= X-Received: by 2002:a17:90b:3942:b0:387:e0bb:57ff with SMTP id 98e67ed59e1d1-38e4b5d99a6mr13188088a91.38.1784531001215; Mon, 20 Jul 2026 00:03:21 -0700 (PDT) Received: from [127.0.0.2] ([50.145.100.174]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-38e60cc2ad5sm463052a91.4.2026.07.20.00.03.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 00:03:20 -0700 (PDT) From: Abdurrahman Hussain Date: Mon, 20 Jul 2026 00:02:52 -0700 Subject: [PATCH RFC 3/4] of/overlay: rewrite /aliases path values to live-tree paths Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260720-nh-of-alias-overlay-v1-3-f1e5d9889b30@nexthop.ai> References: <20260720-nh-of-alias-overlay-v1-0-f1e5d9889b30@nexthop.ai> In-Reply-To: <20260720-nh-of-alias-overlay-v1-0-f1e5d9889b30@nexthop.ai> To: Rob Herring , Saravana Kannan Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Abdurrahman Hussain X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784530997; l=2365; i=abdurrahman@nexthop.ai; s=20260510; h=from:subject:message-id; bh=ukiUyExq0XnTaCqoO00vJRBVYD+CBNPsreTEPosjgA8=; b=Lx6z57+d2jdA1VGsy6etjNt16LDdRIrsalsiQOtAlkxNeFaVYZaPIxW2DlipW0MzzQCf8kQ37 zUQKvREMdxtBD7Qs5Xw5MnulyxyWljFwOplN9J+oc9cWto6Gj+T2EIq X-Developer-Key: i=abdurrahman@nexthop.ai; a=ed25519; pk=omTm9cCAbO0ZhS32aKfJDKue0W3sQGpG9ub5eYHif8I= /aliases entries added by an overlay reference labeled nodes inside the overlay via '&label' in the .dtso. dtc renders those references as string paths at compile time, but the paths encode the overlay's internal fragment layout (e.g. "/fragment@1/__overlay__/fpga@0/i2c@40000") rather than the location where the node will live after apply. Currently only /__symbols__ has its property values rewritten from overlay-internal paths to live-tree paths by dup_and_fixup_symbol_prop(). /aliases values fall through the plain __of_prop_dup() path and are copied byte-for-byte, so of_find_node_by_path() on such a value returns NULL, of_alias_get_id() reports -ENODEV =E2=80=94 and the reconfig notifier added earlier in this series sees uninterpretable paths and can't populate aliases_lookup for overlay-declared aliases. The values in /aliases follow the same textual convention as /__symbols__, so we can reuse the existing rewriter. Detect the /aliases target node and route its properties through dup_and_fixup_symbol_prop() as well. Fall back to a raw dup when the value is not a rewritable fragment path (legacy string aliases like "ttyS0" that some out-of-tree code writes verbatim). Signed-off-by: Abdurrahman Hussain --- drivers/of/overlay.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index 654a70d5cb07..338786cef17a 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -350,6 +350,19 @@ static int add_changeset_property(struct overlay_chang= eset *ovcs, if (prop) return -EINVAL; new_prop =3D dup_and_fixup_symbol_prop(ovcs, overlay_prop); + } else if (target->np->parent && + of_node_is_root(target->np->parent) && + of_node_name_eq(target->np, "aliases")) { + /* + * /aliases property values are string paths in the same + * "/fragment@N/__overlay__/..." form as /__symbols__. + * Rewrite them to live-tree paths so of_alias_get_id() can + * resolve them; fall back to a raw dup for non-fragment + * values (e.g. legacy string aliases like "ttyS0"). + */ + new_prop =3D dup_and_fixup_symbol_prop(ovcs, overlay_prop); + if (!new_prop) + new_prop =3D __of_prop_dup(overlay_prop, GFP_KERNEL); } else { new_prop =3D __of_prop_dup(overlay_prop, GFP_KERNEL); } --=20 2.54.0 From nobody Sat Jul 25 03:12:44 2026 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E7E6B3B6370 for ; Mon, 20 Jul 2026 07:03:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784531006; cv=none; b=AYkmj+4Bod/uLjW/FQEVXuGvljQ5+8xwuKrJ3AelULXMWXoLfpEGMxELRkleWFnw17xDLKk70qVGdDEATx6XXHBqTUM5gkzfokgtCXyXGdGqsCn20QoU9pdhDNnYge5QmFWH+4E8OAlFXVrjhpdNEWay4GiAvPDlu1n9lgeuttc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784531006; c=relaxed/simple; bh=MDFjA3RgAEvCtdRyXnAbVMy3S7sJXL7lribMJJ6+tBE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GeRjVll2m2NoJT/oDfovJ2gos2VkBqhsHsVH+i2DE+4RNthmcabBB2V7wKU/CD/IQvgvtJ4HacenF7sbAoMCbyA9Su7Xm0R/Pm8CE2vH3r4BV6VQJIMtqO06wBhjFm18KH/7gaSkVF6q3whGUyOT16aau+pHuUUmF0hXHAH7LRg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nexthop.ai; spf=pass smtp.mailfrom=nexthop.ai; dkim=pass (2048-bit key) header.d=nexthop.ai header.i=@nexthop.ai header.b=aKwr+pic; arc=none smtp.client-ip=209.85.216.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nexthop.ai Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nexthop.ai Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nexthop.ai header.i=@nexthop.ai header.b="aKwr+pic" Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-38511175ad3so8023605a91.2 for ; Mon, 20 Jul 2026 00:03:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nexthop.ai; s=google; t=1784531002; x=1785135802; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=pX5vXL9Rltp502Am/rntkBhNRyHxfpxR6XXxdG/Nl84=; b=aKwr+picSxIJU1ehb88vHUxFKJRjm4pw/9A/Zf20fbskTTWukPZKul9wUwZzg+qu9w bHG058XnDm6tS8e6NnEEDtHLZx55bp0nOOC0YmHSkbcKpYzwom5/wh2DShmhnRKNgt6m Vx8h5IC66Q0pAYTBSlLo8YlfDkApmNc4CzXhblTD4SiEFS7UvpEfsWDHFkSX63SkX0lH HMUrQ4u/iqiBEtcvkHHpMaH59nfI0JGKTJ08tzCJv8toAUkoEkKqXgqoLd+3HP+irAnc cT5dlT+w8A7UaIuFJUQRCbrZIJMTvjOYIwA78Yi70LGBMzPEtgyHXbh4fj2P1rkRX3yn BOpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784531002; x=1785135802; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=pX5vXL9Rltp502Am/rntkBhNRyHxfpxR6XXxdG/Nl84=; b=IXSXqylrlZonfh8ULDDGHllUL7ptmKSDNLj8xGfJLXJvnWP3TikavniS6chbiH7Tfj Q8hAP8pqXbT+SVbJJLkJC5aB+lNXZUqaOTNsoe6iHzLYEW8YcmmKiXl5G/iT19st3nhK K5n2emD2Xy4feLX8lQZEdLpOJsCkaG/jd5LzYrOhPyfM7po5vrLN/ejYdaZ1WUHxl/l7 Hfu4K3KD2kfk+5mgbRe2eklkb2LydCJsLgYO3PR9XzU8108bYwcGn0dMkMRyAvd+SkBA 4yh///0tYVlLAnRpItMb9IXA+ej3V1h2aGNauyoweCqapwYdXrzxDJgx/HJe3bWgdqYR 6D8w== X-Forwarded-Encrypted: i=1; AHgh+Robti/w0E3ddU85AP+E8bUboCSct8ZNufEehfPFVWJqj9ziJVXH9jjKDx4hlyKzE+f9rAgI8/dPf7U8tAw=@vger.kernel.org X-Gm-Message-State: AOJu0YylKuF5jpZEpktCshwXlEUiDdEPYV7lv990lB5C9yiSZjOdYcRW 9tJRmzN81g1BZH4n5i+hbufnb5wXZVdntdlcXOrkg8v6bG29aRuWtqYlKffsU48vVPM= X-Gm-Gg: AfdE7cnYumj3D7M3M64JEuwl0GUg7mOvdugBSrTShiRYDqfDmx0wedTH1wgMkf7JAec xn8A7njwJXilx9wgq21k4zbpTB4ehVRHaYi/pU+WIN36JbEQmnr72/iSvz+ab29yIGIiWZQ+x5b Ijfe5kTrfNLcL15lnXRlPEUv3gPImigrNA0CqSkcVenPOI64y6DEd7zGPD653gVvdQ5BF73ujlZ TUtuA/97fZo+ZD2bP4wca/ZXekfIljTQ3Wo7lkHLYCo909H8wR2Zymhj5l+SmDSPW7DmTvQ6M62 bqBamQMpQw1EakBpl70N+BgSFNZNb4EGL8IC1GbDnvD/dTAqz+HKnQksgMPU95XG+jojKeOn7bu V92+LaRPC8s7heon64KxK8J9TbKjW4l2pCXWSWZ3JlaWnNdgrOC80Ukz+xXOVQW2CtyqUdhwG31 pr1MB2 X-Received: by 2002:a17:90b:4a08:b0:380:9157:d6c with SMTP id 98e67ed59e1d1-38e4b41043cmr14246640a91.10.1784531002261; Mon, 20 Jul 2026 00:03:22 -0700 (PDT) Received: from [127.0.0.2] ([50.145.100.174]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-38e60cc2ad5sm463052a91.4.2026.07.20.00.03.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 00:03:21 -0700 (PDT) From: Abdurrahman Hussain Date: Mon, 20 Jul 2026 00:02:53 -0700 Subject: [PATCH RFC 4/4] of: unittest: cover /aliases updates from overlay apply/revert Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260720-nh-of-alias-overlay-v1-4-f1e5d9889b30@nexthop.ai> References: <20260720-nh-of-alias-overlay-v1-0-f1e5d9889b30@nexthop.ai> In-Reply-To: <20260720-nh-of-alias-overlay-v1-0-f1e5d9889b30@nexthop.ai> To: Rob Herring , Saravana Kannan Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Abdurrahman Hussain X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784530997; l=4807; i=abdurrahman@nexthop.ai; s=20260510; h=from:subject:message-id; bh=MDFjA3RgAEvCtdRyXnAbVMy3S7sJXL7lribMJJ6+tBE=; b=1uRt+NYgSdsZklwmrfdumPXYE/QBEyqERaPzRKFHEZQtMC3xI1dM47vV3H8GishS+GzYzTxCP qF4b4W4H8RbAl930bpY2FBF9kQzZ3pdQJHlygIXRSBygbhdgVFkhAfA X-Developer-Key: i=abdurrahman@nexthop.ai; a=ed25519; pk=omTm9cCAbO0ZhS32aKfJDKue0W3sQGpG9ub5eYHif8I= Add overlay_alias.dtso, which declares `testcase-alias99 =3D ...` under /aliases via the &{/aliases} shorthand, and an of_unittest_overlay_alias() runner that: 1. asserts of_alias_get_id(target, "testcase-alias") is -ENODEV before the overlay is applied, 2. applies the overlay and asserts the same call now returns 99, 3. removes the overlay and asserts we're back to -ENODEV. Exercises all three functional patches earlier in this series together: patch 1's reconfig notifier is what mutates aliases_lookup on apply/revert, patch 2 is what lets target-path=3D"/aliases" resolve to the DT root when target_base is non-NULL, and patch 3 is what rewrites the fragment-internal path in the alias value so of_find_node_by_path() finds the live-tree target. Any one of the three missing turns the middle assertion (get_id -> 99) into -ENODEV. Signed-off-by: Abdurrahman Hussain --- drivers/of/unittest-data/Makefile | 2 ++ drivers/of/unittest-data/overlay_alias.dtso | 9 +++++ drivers/of/unittest.c | 51 +++++++++++++++++++++++++= ++++ 3 files changed, 62 insertions(+) diff --git a/drivers/of/unittest-data/Makefile b/drivers/of/unittest-data/M= akefile index 01a966e39f23..0a8bd9a74283 100644 --- a/drivers/of/unittest-data/Makefile +++ b/drivers/of/unittest-data/Makefile @@ -22,6 +22,7 @@ obj-$(CONFIG_OF_OVERLAY) +=3D overlay.dtbo.o \ overlay_18.dtbo.o \ overlay_19.dtbo.o \ overlay_20.dtbo.o \ + overlay_alias.dtbo.o \ overlay_bad_add_dup_node.dtbo.o \ overlay_bad_add_dup_prop.dtbo.o \ overlay_bad_phandle.dtbo.o \ @@ -87,6 +88,7 @@ apply_static_overlay_1 :=3D overlay_0.dtbo \ overlay_18.dtbo \ overlay_19.dtbo \ overlay_20.dtbo \ + overlay_alias.dtbo \ overlay_gpio_01.dtbo \ overlay_gpio_02a.dtbo \ overlay_gpio_02b.dtbo \ diff --git a/drivers/of/unittest-data/overlay_alias.dtso b/drivers/of/unitt= est-data/overlay_alias.dtso new file mode 100644 index 000000000000..32532c80505a --- /dev/null +++ b/drivers/of/unittest-data/overlay_alias.dtso @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; +/plugin/; + +/* overlay_alias - declare an alias inside an overlay */ + +&{/aliases} { + testcase-alias99 =3D "/testcase-data/overlay-node/test-bus/test-unittest1= 00"; +}; diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index e255f54f4d76..a9f4a0bb3087 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -3475,6 +3475,53 @@ static struct notifier_block of_nb =3D { .notifier_call =3D of_notify, }; =20 +static void __init of_unittest_overlay_alias(void) +{ + const char *path =3D "/testcase-data/overlay-node/test-bus/test-unittest1= 00"; + struct device_node *np; + int ovcs_id =3D 0; + int id, ret; + + np =3D of_find_node_by_path(path); + if (!np) { + unittest(0, "could not find %s for alias test\n", path); + return; + } + + id =3D of_alias_get_id(np, "testcase-alias"); + if (id !=3D -ENODEV) { + unittest(0, + "of_alias_get_id() =3D %d before overlay, expected -ENODEV\n", + id); + goto out; + } + + ret =3D overlay_data_apply("overlay_alias", &ovcs_id); + if (!ret) { + unittest(0, "overlay_alias apply failed\n"); + goto out; + } + + id =3D of_alias_get_id(np, "testcase-alias"); + unittest(id =3D=3D 99, + "of_alias_get_id() =3D %d after overlay apply, expected 99\n", id); + + ret =3D of_overlay_remove(&ovcs_id); + if (ret) { + unittest(0, "overlay_alias remove failed, ret =3D %d\n", ret); + goto out; + } + + id =3D of_alias_get_id(np, "testcase-alias"); + unittest(id =3D=3D -ENODEV, + "of_alias_get_id() =3D %d after overlay remove, expected -ENODEV\n", + id); + + unittest(1, "overlay alias test passed\n"); +out: + of_node_put(np); +} + static void __init of_unittest_overlay_notify(void) { int ovcs_id; @@ -3649,6 +3696,8 @@ static void __init of_unittest_overlay(void) =20 of_unittest_overlay_gpio(); =20 + of_unittest_overlay_alias(); + of_unittest_remove_tracked_overlays(); =20 of_unittest_overlay_notify(); @@ -3848,6 +3897,7 @@ OVERLAY_INFO_EXTERN(overlay_17); OVERLAY_INFO_EXTERN(overlay_18); OVERLAY_INFO_EXTERN(overlay_19); OVERLAY_INFO_EXTERN(overlay_20); +OVERLAY_INFO_EXTERN(overlay_alias); OVERLAY_INFO_EXTERN(overlay_gpio_01); OVERLAY_INFO_EXTERN(overlay_gpio_02a); OVERLAY_INFO_EXTERN(overlay_gpio_02b); @@ -3885,6 +3935,7 @@ static struct overlay_info overlays[] =3D { OVERLAY_INFO(overlay_18, 0, 0), OVERLAY_INFO(overlay_19, 0, 0), OVERLAY_INFO(overlay_20, 0, 0), + OVERLAY_INFO(overlay_alias, 0, 0), OVERLAY_INFO(overlay_gpio_01, 0, 0), OVERLAY_INFO(overlay_gpio_02a, 0, 0), OVERLAY_INFO(overlay_gpio_02b, 0, 0), --=20 2.54.0