From nobody Tue Dec 2 02:29:42 2025 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 3C60632F76C for ; Thu, 20 Nov 2025 13:24:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763645061; cv=none; b=nQVA4vYQ4OWeZWS6XvOM8NhLihaz/Tj5g2byzQIujRPOUD/3dBiQflWss993CZMmvbp4RSeU2T9f1hqM5ysldd8pfbQKNuEymQq4nr3FnYymI5ZjVs18GGQV9c52xWLqxqDv9vfyBEqW54c7nglvNYaPcE77CuRQrGwB2nHsP1A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763645061; c=relaxed/simple; bh=oHRVYdIjd/Yd3H6psQO5ORnSPlcaHmVdQ/RqmmG7LOc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HxRoNqCjigt3z3J0uBPWVOEIiQ+sLeBFZ6UFHwd+OwU4+1B4hIXy0b6MaByVMxVCrtUUm2PLRS/2aKyA4n5fnO6SYtBhPFRJAbjbMMgfe7ph4aUlAdBHmaHW8A3xHm6DK66yVZk545Eb8R1cDbKI/AnEhGx9gMO4P//8A5FROM4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=bPFO+MtV; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="bPFO+MtV" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4775ae77516so9794595e9.1 for ; Thu, 20 Nov 2025 05:24:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1763645052; x=1764249852; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=MRaQQoBUjPToTmVTOLCnaE+FSHPEdMRVOEcLCHXxxj4=; b=bPFO+MtVHT3k7aKlTyTpiBEylJlA21SVZMYH9YVtroTjV0wEESBYXA1usedq0ydrn0 HklIaqmTcI/cUZxirvQ2nYi0qSUu+1PqU7SsW45dyruFMiEF0+VKzb6ZhnWPd+iTHXHB VRUz3nMG+MPDIS0ngWXBLPLDfJbQC2E5+Ch85VqalsTLsv5OwOLVK7C/tlN4C0Wn0i0x IppdBfPL0/Z9gt4i6yPCU2iFX5GzJHss8e5PV7+gskfAimkkCc/uauiB9d6BAKuSScRt y+Rb/vYrHu0cq5bNNPhw29KifMoKeyKnQ3dSMliTLmp2mIB4p1P+Ts3vWZhJSQRq3gmw VU+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763645052; x=1764249852; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=MRaQQoBUjPToTmVTOLCnaE+FSHPEdMRVOEcLCHXxxj4=; b=iKu0EOdH+2MGXaBBMMDJYhOWH9ksZZeDTUG3hi/CTTxxwX0BaN6TqRNCWa454qydmN tNSIu5jzZNsF4rLp9Pj0rX2F/hgKTHZYsTZ6PVC5RyzcONTMTACPmIapXA20EFtNw1uk FaSeVBjFhqM0oUcNYyLVxMlM/wn99thjBGWKzenUj0G/sC5VD5JRrDJA9LEkUmw96Sz3 0pPntHjCI3sHpzTxbdjsa2Ot5WlehBShPzVMlU1R066jTffPLxy6OEJLZQRwvup202u/ X1fcpHZA+GoDvB75h26zHUo0OGXei+gmfOg1PGehaYjSzxz2uCwUw+FtmqQ7Um4dB25V Q2dw== X-Forwarded-Encrypted: i=1; AJvYcCXrTg1W6Duj90FFCFg61jNrZhZBWrZipeZ7zj99K3mEonFDCa47cpPbEtXSMnijvTgTYheDVm7KIO+973I=@vger.kernel.org X-Gm-Message-State: AOJu0YxExa+zUpI2FL2egm4LM2CR+WlaWfC1sJTJtME/OGJEwX6zFO2y qPvAf5K6pExDMexXFb56Mj5HwyoAJIVfmVA9XPae/QCzyFGZf+SgUMsmRynVRqBpoT8= X-Gm-Gg: ASbGncvSiCGUZ5/qx8MVRzFCT9ku6JqhwQ9PDnYeGpgM9A3lkflwdOluDYGGfW1s1kV 6IzZtgm73f4SaE/5f9j3AGe7TtJ12lWn7CGGidKInDuIURgsM+YPT0C1GC0kUQreZ9DUK8M3/o+ /Uy/un8hhMnNeUkjZ3GfXu3lswnStDcN5Me2QRyv9ETd5qwN2FHRG7JZalAesHtKEbSSRzh28tA wX8/zSnlUK5XAjFVXhhpH4o2AMyPtGxhun2AI3e6yJT66BJV/DkImJ19beZxV01sZeN95djGo7W QP9ABQ8fc5vH+aJP1OfEl3YZ9gFgjuq4Hg9s94Q3aZZJmOR683kdMdKXnT8xgqhbAj5MThaA8Zn gBiZaDw8YDszYjLAX2oH7qeaqZAisGZqKuJznU5oLibDLgOXMAeI3od2FjG+Cy+r0Gxsh7ih+mM ptybfTkd9g1jc3Ng== X-Google-Smtp-Source: AGHT+IH3hYAe2O/tKOuUpAJ7i/RcaZOaAn9ArFPrD5AK9VGJHEneDKjfYXeaAppiEZHUy4nrflG5lA== X-Received: by 2002:a05:600c:3ba1:b0:477:c37:2ea7 with SMTP id 5b1f17b1804b1-477b8a84841mr2670455e9.21.1763645052351; Thu, 20 Nov 2025 05:24:12 -0800 (PST) Received: from [127.0.1.1] ([2a01:cb1d:dc:7e00:37af:6c1f:28a:47d2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-477b82cc72dsm46762935e9.1.2025.11.20.05.24.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Nov 2025 05:24:11 -0800 (PST) From: Bartosz Golaszewski Date: Thu, 20 Nov 2025 14:23:58 +0100 Subject: [PATCH v7 3/9] software node: allow referencing firmware nodes 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: <20251120-reset-gpios-swnodes-v7-3-a100493a0f4b@linaro.org> References: <20251120-reset-gpios-swnodes-v7-0-a100493a0f4b@linaro.org> In-Reply-To: <20251120-reset-gpios-swnodes-v7-0-a100493a0f4b@linaro.org> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Philipp Zabel , Krzysztof Kozlowski , David Rhodes , Richard Fitzgerald , Mark Brown , Maciej Strozek , Charles Keepax , Andy Shevchenko , Bartosz Golaszewski Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-sound@vger.kernel.org, patches@opensource.cirrus.com, linux-spi@vger.kernel.org, Bartosz Golaszewski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3940; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=jEg7ScMzld+wLGiHDAncvLuj6Q+b2Nv5Y09GFyLpduI=; b=owEBbQKS/ZANAwAKAQWdLsv/NoTDAcsmYgBpHxZyYB3Pcu0cgiUmoHlajxQL2+zrp5X3CpVHY lBTQ1ay3vmJAjMEAAEKAB0WIQSR5RMt5bVGHXuiZfwFnS7L/zaEwwUCaR8WcgAKCRAFnS7L/zaE w28TD/4lXRUCRC+Pme/fHRFXDEnjAj6FiVe+JDQdH1IPiDeM56/qwpqkZ82DWBdobLTUvtx60FE xGzbd/A3USw5o607LH0g2clGxtTUUPH4iQspgkeJpdWStEnmxDDUhljg5gmxpCJb9ybB/rJV9jO Ft9X6GPHwCFz7GSUkQsWfBCEP8VnYgEUoLRmwrHdNO/ShEEwE8fsNuM0K/lqIdNArEhsGViLJrJ /wH+ajrOqreC41hSJ9QrjXj3ItlYRyl40gnwFFOwS1FdetroL73JTU8u657ZBaCWL9NoAqjpnQt uE8vxzSE0gp0tyo9aH5NaWsFrE+DZuqhb/4znM76VhN0zrfxKpniM230qLAbEkjSJGIYoQ1Gd7C 0Lc+lkkQPEEeoPS584I7yvNZt4lVDtG3i7KO8D7w0Gs0UA85fP5XpsAq9eIMx68qalwLRESBlND FucPzSS+JIFDu8fX07MD3Qsw2fWqjFSm+45x8cMR1onVW/vtJV944OvC/Cl8kryEL9GI0EQCIBM ZuPKvhTH/G2EAu9IwSAS+nXRKVn9LR9ELm7UcyxHIkZ8V/TvPHKmNpyCdYyQ1eHcdNqlnluN8j/ dnwLWN3lCCXG7o1+gdPOJ8/VbKnOzKnVVic9FNSD3HwHEJo7bnb0X1715D1QXqjSHRhKiacmeAV ANetY0o+KvwXmxA== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 From: Bartosz Golaszewski At the moment software nodes can only reference other software nodes. This is a limitation for devices created, for instance, on the auxiliary bus with a dynamic software node attached which cannot reference devices the firmware node of which is "real" (as an OF node or otherwise). Make it possible for a software node to reference all firmware nodes in addition to static software nodes. To that end: add a second pointer to struct software_node_ref_args of type struct fwnode_handle. The core swnode code will first check the swnode pointer and if it's NULL, it will assume the fwnode pointer should be set. Software node graphs remain the same, as in: the remote endpoints still have to be software nodes. Acked-by: Linus Walleij Reviewed-by: Sakari Ailus Reviewed-by: Andy Shevchenko Acked-by: Greg Kroah-Hartman Signed-off-by: Bartosz Golaszewski Reviewed-by: Charles Keepax Tested-by: Charles Keepax --- drivers/base/swnode.c | 24 ++++++++++++++++++++++-- include/linux/property.h | 13 ++++++++++--- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c index 6b1ee75a908fbf272f29dbe65529ce69ce03a021..16a8301c25d6390ba304c66411d= 1a261345184f3 100644 --- a/drivers/base/swnode.c +++ b/drivers/base/swnode.c @@ -535,7 +535,24 @@ software_node_get_reference_args(const struct fwnode_h= andle *fwnode, ref_array =3D prop->pointer; ref =3D &ref_array[index]; =20 - refnode =3D software_node_fwnode(ref->node); + /* + * A software node can reference other software nodes or firmware + * nodes (which are the abstraction layer sitting on top of them). + * This is done to ensure we can create references to static software + * nodes before they're registered with the firmware node framework. + * At the time the reference is being resolved, we expect the swnodes + * in question to already have been registered and to be backed by + * a firmware node. This is why we use the fwnode API below to read the + * relevant properties and bump the reference count. + */ + + if (ref->swnode) + refnode =3D software_node_fwnode(ref->swnode); + else if (ref->fwnode) + refnode =3D ref->fwnode; + else + return -EINVAL; + if (!refnode) return -ENOENT; =20 @@ -633,7 +650,10 @@ software_node_graph_get_remote_endpoint(const struct f= wnode_handle *fwnode) =20 ref =3D prop->pointer; =20 - return software_node_get(software_node_fwnode(ref[0].node)); + if (!ref->swnode) + return NULL; + + return software_node_get(software_node_fwnode(ref->swnode)); } =20 static struct fwnode_handle * diff --git a/include/linux/property.h b/include/linux/property.h index 50b26589dd70d1756f3b8644255c24a011e2617c..272bfbdea7bf4ab1143159fa49f= c29dcdde0ef9d 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -355,19 +355,26 @@ struct software_node; =20 /** * struct software_node_ref_args - Reference property with additional argu= ments - * @node: Reference to a software node + * @swnode: Reference to a software node + * @fwnode: Alternative reference to a firmware node handle * @nargs: Number of elements in @args array * @args: Integer arguments */ struct software_node_ref_args { - const struct software_node *node; + const struct software_node *swnode; + struct fwnode_handle *fwnode; unsigned int nargs; u64 args[NR_FWNODE_REFERENCE_ARGS]; }; =20 #define SOFTWARE_NODE_REFERENCE(_ref_, ...) \ (const struct software_node_ref_args) { \ - .node =3D _ref_, \ + .swnode =3D _Generic(_ref_, \ + const struct software_node *: _ref_, \ + default: NULL), \ + .fwnode =3D _Generic(_ref_, \ + struct fwnode_handle *: _ref_, \ + default: NULL), \ .nargs =3D COUNT_ARGS(__VA_ARGS__), \ .args =3D { __VA_ARGS__ }, \ } --=20 2.51.0