From nobody Tue Feb 10 04:02:55 2026 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 E520A33CEB1 for ; Thu, 6 Nov 2025 14:32:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762439571; cv=none; b=QtKNbRT7opVtneAvDvY9MktsFHyMqWxm/STQqlGZhr1BYCxHeiBEDRUvAl2zI7O8EfbF+tdn6O22ugv68i1bdMsC5O3ixz4hKEavxXEKTQ7vZeMPQA6ooUioCiIiaN7z6E0jVEXjN2TpdZHdArVj9wQ+/k9vTepY4UrJYRdVoRk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762439571; c=relaxed/simple; bh=ogys2EZhfFSnh9TKbDolepyjerxXO8VxWq72k0lyQGE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rclHoqSOL2qXLy5WcLBK37SuH8iQncNXEiEdKosXXKyDRtX4unAS2fZpYfMGeBGmJToXl/QkX3Gppx+/F8Ql17t1bVPYZV3cHqCEGrmQNgNUOuni0CO1ba2049hhyKdEJ2FTvAj6NLP64jRNFrB1Byy9H6/W0+crTudj9UUkqRY= 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=03BxHOI3; arc=none smtp.client-ip=209.85.128.47 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="03BxHOI3" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-47114a40161so10527865e9.3 for ; Thu, 06 Nov 2025 06:32:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1762439568; x=1763044368; 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=ImGcemsFvXDjNWCPFtBPW0d7o3wRSDm6gKdcQwQP5/M=; b=03BxHOI3BN60VwT45As+Ah6FpKi5H0t+nNRc7l0t5f3gd9aY0gcFnYCqsUPn8EPxMo RoYHrPyKerdN4Y/SXelrAVVVkBQUbqEqdmIOipjak9171/AoSF3M5sXK1eR+AgOHcteg nwE837ty/C1DdT88WilHyC+bsl652QEHEpAihnwkjQyoAQ1OgF2Jeq9ofrNYbXpGm5ui 2VFGnKrLne+C63jG3n7WBsjR04/TyyP46Q68VYhKMqioJz6y+kosflnRO+TQdSysrZgT HKhE0hfc059pa2o3mLC8gkx9oPm+deEGNcDfhIgOhNMXaIF96duUvg/UHrHiEJaam8ED Hyjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762439568; x=1763044368; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ImGcemsFvXDjNWCPFtBPW0d7o3wRSDm6gKdcQwQP5/M=; b=V0GeN/slqQbHRPncLEg7mi76Xl2VpHRJF0d/r/VTSsv7UW7+WoFu2/FIrNQplhhaG1 ZfKKzrlvRQ9CzeR7i+3IgoMHv+4g8vJzbJ5IEO1KG9jdh15sBgk5skgO2NhNiNIl1wx/ MQmv8mJcw3XoBlKV1d1/dDzlThAxVIF8Re/jo5XkUrMcbUSXWM+Rt1kX+o+8wuh1YFql B01FBqPFBJ+kxBflclLQm3+ruXWY8keFUKzwwZow7EOAGF7n7veo5F+I8ho53hyudRO3 0VuPGo/fhFStxYRSOE6PbUJW1QM+OWiJxF34XWuUmNSISBocbKd7W1KX60D7B54CyYNY n3Pw== X-Forwarded-Encrypted: i=1; AJvYcCVTvaltcYGgQnudLxX5o9EC4uphpfrY1dz3aG25voQQ8Q3Uvdr7TsN1khMjGhkfn+ZYzIWxkAbq1kyw8tA=@vger.kernel.org X-Gm-Message-State: AOJu0YwEEbp9hrS3t3MoLkEk0qDVrE++kI+VzFZfRYhOuEyCFDcgJYvJ DlzIiYsj7pm34fGoWcnc1u4SnEZmWqfH9dW3yku+bdpy9KaSsc040T7ug6eFCUOIgqo= X-Gm-Gg: ASbGncvvOs/pXllLHHyxggj3CmVN8mmoP5zwbmiPIL68CLPUsBWVudecyNxePlxlF+k WX8w0oenNvz2esXjBXTxuQGEmWjtKpF+B1GX1mpKo58oqgUTCAonqGqTRWekI8vB79ys9DehSL/ NNTACFxgfcRxnNpRKzYKERK/QC1st/taiPDj+CITwLGwp/puajCtwGuOHo7PBY8xGizr6TEUy2c WeXb9ijki6Yyg2UM847oI8ca4rM5fsC1esovNYWjiK6XyVXC29UsIpmNqhxeGXRRFQ7j0cPsh4+ +MM4i4LONJ/Xi5aMUTZ1QdDduN4YuMwpLN2CrpZwKJY9X3TahvldtMyUhOnurewMRBYqE9MW3dp Sb6+L8tCKFk+xR+5kxbacSufj66tuhDR54vmZ71NL6rYdHsLiaJVNnqIIpbEKIYOHKi2zgopX9D 7xR0g= X-Google-Smtp-Source: AGHT+IFCdm6f1PqAwQZCefwuN5Ba+GuMsPPYnzn4FUIGeoArk2eJIorYQiEN4nUrGo8VvRcbFXORbg== X-Received: by 2002:a05:600c:8216:b0:477:3e07:217a with SMTP id 5b1f17b1804b1-4775ce211b8mr75203125e9.36.1762439568104; Thu, 06 Nov 2025 06:32:48 -0800 (PST) Received: from [127.0.1.1] ([2a01:cb1d:dc:7e00:d9de:4038:a78:acab]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47763de4fb5sm18871515e9.2.2025.11.06.06.32.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Nov 2025 06:32:47 -0800 (PST) From: Bartosz Golaszewski Date: Thu, 06 Nov 2025 15:32:32 +0100 Subject: [PATCH v6 3/8] 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: <20251106-reset-gpios-swnodes-v6-3-69aa852de9e4@linaro.org> References: <20251106-reset-gpios-swnodes-v6-0-69aa852de9e4@linaro.org> In-Reply-To: <20251106-reset-gpios-swnodes-v6-0-69aa852de9e4@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 Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Bartosz Golaszewski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3881; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=HpU6/kofClihOZLaRH1MDHt2R8t6/Ip5QySfB23CsUM=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBpDLGHwEikvsoeb9jagwVVc9pM4AhbQuq+ekwJc haYtxnuhxaJAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCaQyxhwAKCRARpy6gFHHX ckRJEADFED31WNfI5lyOtIRU/+69mQA47s6BhhAoyJT3rgmTi+xR6J6SYX7UEPKClkl8QBKySuK EzoTSSub4t5nIioNOq6/Eh3lPQerwcYNkG3Ss4cHUEKqyO3YdIN6RHqBXghJLWFali1D3JzD1D3 YhE6mrggGCJePbPB1bLl3MLwnooDoEXPE0WsJ/uLWvaAZ/UoYIWnEYdOpmAVKZU8onnHuYfQOJa J2pxr3aUbl0Cb4kD1w8T7O8sBZFKyRHGWIzceIiRRU1NhPWjuZUaz392xhkUqteLwvTezt4tHqS 7eAyFyUGMJCT4F2sbHgP5Am/WIcN7gqb8Mw9LaR19Ssv7H09Rut6QDn3X5cGCC2vKZOX10lRDCb YUpWmoAHT9PxtLKy4N+MRvvi/cU4XOJYe+tRBRWTNJYBBaCbfPwG5YVih93FlkVvtCAge9kWPm6 /lVoVBLt02Po759Tx1LicpW04gw0rDNi03FKxAm0uC4xcmePmOs8WtYnPhwCY5qylyvHUSP1PIS YRHGG4yF5MrnkE4rcMuB0KjsNSvuc6mEONM99XUC6/VtRGRf9UeDEoNArl3pgzk57EISMEW2PXL XmKyv5Qgg3ihungUakZh84sp+SO9WXOhIaplRudJNf1EsiCeAEsSalA3S87+JG23LnrCjdbCJIB cXdPC8E+824DlXQ== 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 Signed-off-by: Bartosz Golaszewski --- 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