From nobody Fri Dec 19 14:22:24 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 639E92E1F08 for ; Wed, 5 Nov 2025 08:48:05 +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=1762332487; cv=none; b=cQErmW0QlMJ3sGIEJ/28JqGzLE7st1l5KdKYK+RiD9lJrV4F3JSJQa7w95nL1Cf7qpLd7wy8EVAN/F80oPdjZodqfylMeMjshjAKmYq0tN5EodnqcoEycM9U4zrjeg2/3fLCTP15zqpZLWFCUyA+hMD1R/sITzRvLXxsYjocAo4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762332487; c=relaxed/simple; bh=ZzrngTy8GvyLzYtwqD4FoT3jMmWGmQZFcpmlX8gaDnY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=k3G0SH3kL5Qjs+csE6rw18tOOqisoA6KCSnaLoOTe4WbdNVApwoui7FGT0FjXPEOztVLyICckd1x9v26Tw5DOz7+i4XXYKSUuQBpePK7bM8zipFPHosFA7Agwsa5Sfvim3sK1UrXRTz21juwRuN/W+uSR998CDDi2YleMZ1iu20= 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=o43YTN0A; 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="o43YTN0A" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4711810948aso45375165e9.2 for ; Wed, 05 Nov 2025 00:48:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1762332483; x=1762937283; 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=8OAyY/i3h/xnNvRM460Hy35E4MkdMx/5c8tuVEvyWsY=; b=o43YTN0AzrHjFLs9lsFByT0SoGKhWKxOdNpfFxSvvbjWTa3uySGDs08TSOWJvcRufU Y+kqP+aNKdR+aCRUmkHTwkIahQqoR4sLhqXS6jOF50iycKlvQPDYP9zJO7F5VGvsKl1K qlJ1grQ1GDfNzDpaz7pAhef/xV1PgGrFTIDS6qEvMZCjlIZkS96CwjejrSlxWwFeXnqQ htZL2zE5O72oA3m5ug7GPbM5eDGSLZqjJoIV5mkatkT8rlJfoaNAuPDmQ3//7J7pqiJs gQqbXU9y/w9PQWNUylh8ybS+qPHBBHI60yuqhjeUkJeU9X5c0H193gHKiWxy33QE9U1p HnrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762332483; x=1762937283; 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=8OAyY/i3h/xnNvRM460Hy35E4MkdMx/5c8tuVEvyWsY=; b=pGOfX/JxaM8nLuJuxux5nAu+70IcdRoIxyzLWW7ql+R6lgtyAv/76HmBgm+K9Qu4EC HcRNsuBK2+i6Uvry/f1lzmSKfN9/8Q8KNZpNqQelzJJgMqrUkKSqSkh/9iZf4Wx1DVhy ptTWcwY6qESELASGwnsB0r5tzXwgwDJWP4VsGIa47VPp82rYrBBzkXkQfz8bvSlMj22k WZdeOLd9QjtZ1vTEZGPW6hh/lCRYItnS55vbOszXj24dbIk7xqhNr9wUmdw7Q1D5W5OS 0x8iFm8E5s4AW1CqSdOH4U2RIVUVkisqKBuJqSZKa9h5TT0FaXB6GWIXzZx/cwGSDSRH cf5g== X-Forwarded-Encrypted: i=1; AJvYcCUcbcRvV0cO+yX1lmnSMTwhe//FvocXLyATomAgVZJdDFB3KhEoZfrvF+sZF/CAihy9LiiZ9Q4kEp11MNM=@vger.kernel.org X-Gm-Message-State: AOJu0YztOFm6tIOy/c/5fc3o1BFXXquWp/+zEL5ZZB6rp7u4/BDR95rQ wgEo7QYBxgk3foufQYAK3EcFHwPwh7TW8Fq1wrYUdZ+wleVapIVLIA24SzTtmXd9at0= X-Gm-Gg: ASbGncuCM5EQP59k+orjOKGql2jniL+Ds6HQd7ONnxyyqSTabF2h7tzHMI1eB9E0Pmt aU/zB199yFO385sKO+sAzql2JOtUia2IwwyWUGkay5B6hkNuYmJXXXLsnSWnBuH2msNKqKvZVg1 re7IWJJlyeJKOkwExfryZt1bFqjrlfco4q4USO89zRi3dRL1HGQuJ6xIX8jCC0LOwV0POdRFMnd yAfC3E6WC36/DW/KXZlB7vuSIfUju456d9ZpJ64tjNqQjhJuBMQu5V0KmVoMjBDgNv0RL25TYVU YK/lmSl5BW4xGZYucseGAsCjJZLxHPZj0ZnqKhVrSVOu8RFIXlHhD3H+Ntyz5vGGLG0iHoAFEkN tfeGE6TGurZXhafJ82t/+ROt3D+qBfx/CP8h9c+CSj/OFV+nmsSLtLO24oae28BOtm9QVOQ== X-Google-Smtp-Source: AGHT+IE2WPCD4GiDlUt+MHh5JCpQNRYBZvuFk64K36d4NGc/YsH+GIeCl/xuZLKboh+Y80dVw4T4ug== X-Received: by 2002:a05:600c:821a:b0:471:1765:839c with SMTP id 5b1f17b1804b1-4775cdf4770mr16644615e9.20.1762332483098; Wed, 05 Nov 2025 00:48:03 -0800 (PST) Received: from [127.0.1.1] ([2a01:cb1d:dc:7e00:4e71:8371:5a52:77e4]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-429dc1f9cdbsm9315936f8f.34.2025.11.05.00.47.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Nov 2025 00:47:58 -0800 (PST) From: Bartosz Golaszewski Date: Wed, 05 Nov 2025 09:47:34 +0100 Subject: [PATCH v5 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: <20251105-reset-gpios-swnodes-v5-3-1f67499a8287@linaro.org> References: <20251105-reset-gpios-swnodes-v5-0-1f67499a8287@linaro.org> In-Reply-To: <20251105-reset-gpios-swnodes-v5-0-1f67499a8287@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=3759; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=wXlmW1dk+PI/4eJ8ubrNkh/VoKzD6+wnAicAUbt2Xl0=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBpCw8x+G6l9pwkekwRY/FEtaPs1gOr5eb2k6K3c JU1HAMzFCKJAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCaQsPMQAKCRARpy6gFHHX ctMwEACfSzKb9DlWHXQfZWFRpCFeH2jLvNwW9DNJfuYb+rf0QlGnT6Jz7YlqOd158PxqgkPr/ex enpcuNGArvItmP1v/6Z0wykrf0piX2jCCzNbLhZTO3DJSFih4T3CtUeUL3proU7k3MWgLpLJO26 Xe+Op1urBq4s9P+nvXF3BKfa7iVg2u4ZdBmBsD7B/JHtI8bE6k/qqRNMW0m5v1TS+Ec8XVDoUV1 ra2xpriDkrkhl3ViTeD+Mp9TJDdUUxgIHs79X9xi2/98m6dVKmbhkUvcKCA9t26G2FPzgBoCiTk wxUa9gVTC3R2oWFD4tvk1I/f7Bv16rEJvu02TMhdXZiR+g8mFBBDA07TziYEFaGHv9e74ZZtPN1 i2q/6OzEVae7f1Rd1HWmLvZSMo+q8omo0kb5J098AG97EtyCgenP4DcxDVUHkXN0SvqppdN1F5C U4aEUAb5P99akn5mA3S1TEdz3VDcx4RlBkR2Y10IFgLH+FrLfmpGnVlEnYO8ZWJF2BDE/zLbrR8 vyZAPuwMpYKEtEByscVLYLEVdksQE5MQDKODWBHiP3dVbeWPUxKn2ldsy3pwMiAfgaVV+w3bUUe jIUoE4Dum8VmIZFSMnT5X/5srL7wihcYsiaY+vEhfoLtJzXDIp2mERaQfVxMBrwdEgQFsKjmIa8 zVy3d5nHN0U7+Yg== 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 Signed-off-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko Reviewed-by: Sakari Ailus --- 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..44710339255ffba1766f5984b28= 98a5fb4436557 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[0].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