From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D85CB484236; Wed, 9 Sep 2026 08:02:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788940960; cv=none; b=CeI4rHfUbRBYbFYGRNpHFh8RcKeMBZrLomMMTZOgP8K7m83Vyl1UpGSXgMAMWSat1DW2fwq/s7rNvLmVFpQVBKJnJVpgbNAXFSHARSsg75Rexwj5fJdvayO4JsUrbCwNLkU0JLVsCWVBU8qEKfJXBwYY72b0c/VUaT+FNqQEUzo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788940960; c=relaxed/simple; bh=4RVhPavqbFdZB9dLlUgTUNkwX9QrrcgqvBFuvF2ryQw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OCV1IKpFYKf4Sk0Mg2k3trBlOkWLBzn7bW0j316BkpYCNLeTFRF5LVETqAEjrsdBVbtLQA2eGl9OaulJ0gFXW/U435wza4TROw109jYp9bGJTqBeNJYqCCY8WnbZMSmEsnFr/RoWzCaaBHbwTRR2nrc6azPnZifbwvfY87A7XjU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=pjnC7K5p; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="pjnC7K5p" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 5EC961A1A77; Wed, 9 Sep 2026 08:02:37 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 2CE0460448; Wed, 9 Sep 2026 08:02:37 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id D710111C7AF5E; Wed, 9 Sep 2026 10:02:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1788940954; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=S9hVX9w2762K2NqjWVW1JueaSmRHavaw67h+zQmQF34=; b=pjnC7K5pQ5BzeWmR3L2BvvYdnOoypY2LEsKre4EEi2Sql8RS1V6pfkZo5M4BK38ayRDMqL YidsM4LucG7w+0HJFFSNNuS9yOYEZ851mUrOH/tjaf4r5Zv4p/TRvI6sI628mI4A5DoLxM cpnNG87ZNq/51EMwI0A1/cbKQnogIUOo7f8YANkqi72Aq32awMp10K4OvklFZ2WUD5jjvm j27UNSD0tzb3NWT0CTGcdMSVxs9yOVPvEGcjitXFOpnFKEX5rY64LVOAbTcI0zsQqC0EC/ yJCWwDN5RsRcabMmiKlic/6o2skkgz+WjytJGxvrnmIx2ILl1F2UGn+Jh1Fjog== From: Herve Codina To: Richard Cheng , Andrew Lunn , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Bjorn Helgaas , Charles Keepax , Richard Fitzgerald , David Rhodes , Linus Walleij , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Bartosz Golaszewski , Len Brown , Davidlohr Bueso , Jonathan Cameron , Dave Jiang , Alison Schofield , Vishal Verma , Dan Williams , Ira Weiny , Li Ming , Herve Codina , Lizhi Hou Cc: driver-core@lists.linux.dev, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-sound@vger.kernel.org, patches@opensource.cirrus.com, linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, linux-cxl@vger.kernel.org, Allan Nielsen , Horatiu Vultur , Daniel Machon , Steen Hegelund , Luca Ceresoli , Thomas Petazzoni , stable@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v11 08/10] PCI: of: Set fwnode device of newly created PCI device nodes Date: Wed, 9 Sep 2026 10:01:07 +0200 Message-ID: <20260909080114.591938-9-herve.codina@bootlin.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260909080114.591938-1-herve.codina@bootlin.com> References: <20260909080114.591938-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 Device-tree node can be created when CONFIG_PCI_DYNAMIC_OF_NODES. Those nodes are created and filled based on PCI core information but the fwnode device field is not set. When later an overlay is applied, this confuses fw_devlink. Indeed, without any device attached to the node, fw_devlink considers that this node will never become a device. When this node is pointed as a supplier, devlink looks at its ancestors in order to find a node with a device that could be used as the supplier. In the PCI use case, this leads to links that wrongly use the PCI root bridge device as the supplier instead of the expected PCI device. Setting the fwnode device to the device of the PCI device allows devlink to use this device as a supplier and so, correct links are created. Fixes: 407d1a51921e ("PCI: Create device tree node for bridge") Cc: stable@vger.kernel.org Signed-off-by: Herve Codina Acked-by: Bjorn Helgaas Reviewed-by: Richard Cheng Acked-by: Manivannan Sadhasivam --- drivers/pci/of.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/pci/of.c b/drivers/pci/of.c index 29b63a9090ae..8914bfa25dc1 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -736,6 +736,7 @@ void of_pci_remove_node(struct pci_dev *pdev) if (!np || !of_node_check_flag(np, OF_DYNAMIC)) return; + fw_devlink_set_device(&np->fwnode, NULL); device_remove_of_node(&pdev->dev); of_changeset_revert(np->data); of_changeset_destroy(np->data); @@ -788,9 +789,16 @@ void of_pci_make_dev_node(struct pci_dev *pdev) if (ret) goto out_free_node; + /* + * Set the fwnode device in order to have fw_devlink creating links + * pointing to this PCI device instead of walking up to the PCI host + * bridge. + */ + fw_devlink_set_device(&np->fwnode, &pdev->dev); + ret = of_changeset_apply(cset); if (ret) - goto out_free_node; + goto out_clear_devlink_dev; np->data = cset; @@ -805,6 +813,8 @@ void of_pci_make_dev_node(struct pci_dev *pdev) out_revert_cset: np->data = NULL; of_changeset_revert(cset); +out_clear_devlink_dev: + fw_devlink_set_device(&np->fwnode, NULL); out_free_node: of_node_put(np); out_destroy_cset: -- 2.55.0