Skip to contentSkip to conversation

lan966x pci device: Add support for SFPs, simple-bus part

PATCH Superseded Herve Codina 2 participants 8 messages Nov 9 – Nov 19

Subsystems (2)

v9 of 14 Superseded Latest is v14 →

lore
Share & tools
lore
#0 lore raw

v9 cover lan966x pci device: Add support for SFPs, simple-bus part

Hi,

Previously, I sent a big picture series adding support for SFP ports available on the LAN966x PCI device [0].

In this series patches touch several parts and sub-system in the kernel. Reviews have be done and it makes sense to split the series and send parts separately.

This current series is the extraction of patches related to the simple-bus driver. It has to be seen as a continuation of the big picture series but related to this specific simple-bus part.

Patch 1 fixes an already existing issue reported by Sashiko. Patch 2 removes the no more useful remove() function.

Patch 3 depopulates devices populated at probe() when the driver is unbound.

Patch 4 makes the simple-bus driver compatible with fw_devlink expectation consisting in creating its child devices at probe.

[0] https://lore.kernel.org/all/[email protected]/

Best regards,
Hervé

Changes:

v8 -> v9
v8: https://lore.kernel.org/all/[email protected]/

Rebase on top of v7.4-rc1

- Patch 1 (new patch in v9)
Fix an issue reported by Sashiko related to possible inconsistencies between operations done at probe() and the ones done at remove().

- Patch 2 (new patch in v9)
Fully remove the remove() function.

- Patch 3
Changed the way depopulate is performed and use devres feature. Took into account a pm_runtime possible issue (reported by Sashiko) related to async pm_request_idle() triggered when all child devices are removed from the bus.

- Patch 4
Use devres feature.

v7 -> v8
v7: https://lore.kernel.org/all/[email protected]/

Rebase on top of v7.2-rc1
No nother changes

v6 -> v7

Rebase on top of v7.1-rc1

- Patch 1
No changes

- Patch 2
Fix conflict due to device_has_driver_override() introduction.

Older iterations:
Patches 4 and 5 in the big picture series
https://lore.kernel.org/all/[email protected]/

Herve Codina (4):
bus: simple-pm-bus: Avoid inconsistencies between probe() and remove()
bus: simple-pm-bus: Remove the remove() function
bus: simple-pm-bus: Remove child devices when the bus is unbound
bus: simple-pm-bus: Populate child nodes at probe

 drivers/bus/simple-pm-bus.c | 90 +++++++++++++++++++++++++++----------
 1 file changed, 67 insertions(+), 23 deletions(-)
Signature · 1 line
2.56.0
#1 lore raw

PATCH v9 1/4 bus: simple-pm-bus: Avoid inconsistencies between probe() and remove()

At probe(), operations done depends on device_has_driver_override().

At remove() a call to device_has_driver_override() is also present to identify operations that need to be done in order to revert operations previously done at probe().

Nothing prevents device_has_driver_override() to return a different value when called at probe() and when called at remove(). Indeed, a user can set driver_override (or clear it) after the probe() call and before the remove() call.

In that case, inconsistencies are present between pm_runtime_enable() called at probe() and pm_runtime_disable() called at remove().

In order to ensure that pm_runtime_disable() is called only if pm_runtime_enable() has been called at probe(), use the devres version of pm_runtime_enable().

Fixes 98e96cf80045 ("drivers: bus: simple-pm-bus: Add support for probing simple bus only devices")
---
 drivers/bus/simple-pm-bus.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/bus/simple-pm-bus.c +4 -8
index c920bd6fbaaf..4322a778e801 100644
@@ -29,6 +29,7 @@ static int simple_pm_bus_probe(struct platform_device *pdev)
 	struct device_node *np = dev->of_node;
 	const struct of_device_id *match;
 	struct simple_pm_bus *bus;
+	int ret;
 
 	/*
 	 * Allow user to use driver_override to bind this driver to a
@@ -66,7 +67,9 @@ static int simple_pm_bus_probe(struct platform_device *pdev)
 
 	dev_dbg(&pdev->dev, "%s\n", __func__);
 
-	pm_runtime_enable(&pdev->dev);
+	ret = devm_pm_runtime_enable(&pdev->dev);
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret, "failed enable pm_runtime\n");
 
 	if (np)
 		of_platform_populate(np, NULL, lookup, &pdev->dev);
@@ -76,14 +79,7 @@ static int simple_pm_bus_probe(struct platform_device *pdev)
 
 static void simple_pm_bus_remove(struct platform_device *pdev)
 {
-	const void *data = of_device_get_match_data(&pdev->dev);
-
-	if (device_has_driver_override(&pdev->dev) || data)
-		return;
-
 	dev_dbg(&pdev->dev, "%s\n", __func__);
-
-	pm_runtime_disable(&pdev->dev);
 }
 
 static int simple_pm_bus_runtime_suspend(struct device *dev)
Signature · 1 line
2.56.0
#2 lore raw

PATCH v9 2/4 bus: simple-pm-bus: Remove the remove() function

In reply to Herve Codina

Due to recent modification, the driver remove() function is almost empty. It only performs a dev_dbg() call.

Having this remove() function is no more needed. Remove it.

---
 drivers/bus/simple-pm-bus.c | 6 ------
 1 file changed, 6 deletions(-)
drivers/bus/simple-pm-bus.c +0 -6
index 4322a778e801..e45700156732 100644
@@ -77,11 +77,6 @@ static int simple_pm_bus_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static void simple_pm_bus_remove(struct platform_device *pdev)
-{
-	dev_dbg(&pdev->dev, "%s\n", __func__);
-}
-
 static int simple_pm_bus_runtime_suspend(struct device *dev)
 {
 	struct simple_pm_bus *bus = dev_get_drvdata(dev);
@@ -150,7 +145,6 @@ MODULE_DEVICE_TABLE(of, simple_pm_bus_of_match);
 
 static struct platform_driver simple_pm_bus_driver = {
 	.probe = simple_pm_bus_probe,
-	.remove = simple_pm_bus_remove,
 	.driver = {
 		.name = "simple-pm-bus",
 		.of_match_table = simple_pm_bus_of_match,
Signature · 1 line
2.56.0
#3 lore raw

PATCH v9 3/4 bus: simple-pm-bus: Remove child devices when the bus is unbound

In reply to Herve Codina

During its probe, the simple-pm-bus driver (simple-pm-bus compatible variant) populates its child devices but it doesn't touch them during its removal.

This leads to bus child devices present and bound to drivers whereas the bus itself is unbound.

Be consistent and remove child devices when the bus itself is unbound.

---
 drivers/bus/simple-pm-bus.c | 45 +++++++++++++++++++++++++++++++++++--
 1 file changed, 43 insertions(+), 2 deletions(-)
drivers/bus/simple-pm-bus.c +43 -2
index e45700156732..23ac18551fd9 100644
@@ -22,6 +22,46 @@ struct simple_pm_bus {
 	int num_clks;
 };
 
+static void simple_pm_bus_depopulate(void *data)
+{
+	struct device *dev = data;
+
+	/*
+	 * Bus stays on for children
+	 * This ensure that the bus will not be put in idle asynchronously when
+	 * all its children are removed.
+	 */
+	pm_runtime_get_sync(dev);
+
+	/* Let remove children */
+	of_platform_depopulate(dev);
+
+	/*
+	 * Lets runtime_suspend() calls simple_pm_bus_runtime_suspend() in a
+	 * synchronous way before disabling runtime pm.
+	 *
+	 * This guarantee that clocks are disabled and unprepared before the
+	 * bus is removed in all cases.
+	 */
+	pm_runtime_put_sync(dev);
+}
+
+static int simple_pm_bus_populate(struct device *dev,
+				  const struct of_dev_auxdata *lookup)
+{
+	struct device_node *np = dev->of_node;
+	int ret;
+
+	if (!np)
+		return 0;
+
+	ret = of_platform_populate(np, NULL, lookup, dev);
+	if (ret)
+		return ret;
+
+	return devm_add_action_or_reset(dev, simple_pm_bus_depopulate, dev);
+}
+
 static int simple_pm_bus_probe(struct platform_device *pdev)
 {
 	const struct device *dev = &pdev->dev;
@@ -71,8 +111,9 @@ static int simple_pm_bus_probe(struct platform_device *pdev)
 	if (ret)
 		return dev_err_probe(&pdev->dev, ret, "failed enable pm_runtime\n");
 
-	if (np)
-		of_platform_populate(np, NULL, lookup, &pdev->dev);
+	ret = simple_pm_bus_populate(&pdev->dev, lookup);
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret, "failed to populate\n");
 
 	return 0;
 }
Signature · 1 line
2.56.0
#4 lore raw

PATCH v9 4/4 bus: simple-pm-bus: Populate child nodes at probe

In reply to Herve Codina

The simple-pm-bus driver handles several simple busses. When it is used with busses other than a compatible "simple-pm-bus", it doesn't populate its child devices during its probe.

This confuses fw_devlink and results in wrong or missing devlinks.

Once a driver is bound to a device and the probe() has been called, device_links_driver_bound() is called.

This function performs operation based on the following assumption:
If a child firmware node of the bound device is not added as a device, it will never be added.

Among operations done on fw_devlinks of those "never be added" devices, device_links_driver_bound() changes their supplier.

With devices attached to a simple-bus compatible device, this change leads to wrong devlinks where supplier of devices points to the device parent (i.e. simple-bus compatible device) instead of the device itself (i.e. simple-bus child).

When the device attached to the simple-bus is removed, because devlinks are not correct, its consumers are not removed first.

In order to have correct devlinks created, make the simple-pm-bus driver compliant with the devlink assumption and create its child devices during its probe.

---
 drivers/bus/simple-pm-bus.c | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)
drivers/bus/simple-pm-bus.c +20 -7
index 23ac18551fd9..569580788575 100644
@@ -26,6 +26,12 @@ static void simple_pm_bus_depopulate(void *data)
 {
 	struct device *dev = data;
 
+	if (!pm_runtime_enabled(dev)) {
+		/* No PM runtime, we can directly depopulate */
+		of_platform_depopulate(dev);
+		return;
+	}
+
 	/*
 	 * Bus stays on for children
 	 * This ensure that the bus will not be put in idle asynchronously when
@@ -83,16 +89,23 @@ static int simple_pm_bus_probe(struct platform_device *pdev)
 	match = of_match_device(dev->driver->of_match_table, dev);
 	/*
 	 * These are transparent bus devices (not simple-pm-bus matches) that
-	 * have their child nodes populated automatically.  So, don't need to
-	 * do anything more. We only match with the device if this driver is
-	 * the most specific match because we don't want to incorrectly bind to
-	 * a device that has a more specific driver.
+	 * need to have their child nodes populated. So, don't need to do
+	 * anything more except populate child nodes during this probe(). We
+	 * only match with the device if this driver is the most specific match
+	 * because we don't want to incorrectly bind to a device that has a more
+	 * specific driver.
 	 */
 	if (match && match->data) {
-		if (of_property_match_string(np, "compatible", match->compatible) == 0)
-			return 0;
-		else
+		if (of_property_match_string(np, "compatible", match->compatible))
 			return -ENODEV;
+
+		dev_dbg(&pdev->dev, "%s: populate only\n", __func__);
+
+		ret = simple_pm_bus_populate(&pdev->dev, lookup);
+		if (ret)
+			return dev_err_probe(&pdev->dev, ret, "failed to populate\n");
+
+		return 0;
 	}
 
 	bus = devm_kzalloc(&pdev->dev, sizeof(*bus), GFP_KERNEL);
Signature · 1 line
2.56.0
#5 lore raw

Re: [PATCH v9 4/4] bus: simple-pm-bus: Populate child nodes at probe

Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [High] bus: simple-pm-bus: unpopulated grandchildren in simple_pm_bus_populate() - [Medium] bus…

Thank you for your contribution! Sashiko AI review found 3 potential issues to consider:
- [High] bus: simple-pm-bus: unpopulated grandchildren in simple_pm_bus_populate()
- [Medium] bus: simple-pm-bus: auxdata lookup table dropped in simple_pm_bus_probe()
- [Low] bus: simple-pm-bus: missing Fixes trailer for commit 98e96cf80045
--

commit 7ba99d9ea04b1e1a29eebc1e1525489b300fe107
Author: Herve Codina <[email protected]>

bus: simple-pm-bus: Populate child nodes at probe

This commit updates simple_pm_bus_probe() to populate child devices for transparent bus matches (such as simple-bus, simple-mfd, isa, and arm,amba-bus) during probe, and skips runtime PM calls in simple_pm_bus_depopulate() when runtime PM is not enabled.

[Severity: Low]
In the commit message, this patch fixes the probe behavior for bus-only devices where returning 0 without populating children caused device_links_driver_bound() to create wrong fw_devlinks. Should the commit message include a Fixes tag for 98e96cf80045 ("drivers: bus: simple-pm-bus:
Add support for probing simple bus only devices")?

[Severity: High]
In drivers/bus/simple-pm-bus.c, simple_pm_bus_probe() at line 104 now calls simple_pm_bus_populate(), which at line 64 calls of_platform_populate() with NULL for the matches table instead of calling of_platform_default_populate(). Does this leave grandchild devices unpopulated when a child node has a device-specific compatible string followed by a fallback bus or MFD compatible string (such as compatible = "vendor,syscon", "syscon", "simple-mfd")?

When an outer of_platform_default_populate() creates an ONLY_BUS device after simple_pm_bus_driver is registered, of_platform_device_create_pdata() synchronously runs simple_pm_bus_probe() before the outer of_platform_bus_create() reaches its child loop. Inside simple_pm_bus_populate(), of_platform_populate(np, NULL, lookup, dev) creates the child platform_device and sets OF_POPULATED on the child node. During device_add(), simple_pm_bus_probe() rejects that child with -ENODEV at line 100 because the generic bus compatible is not first, and of_platform_bus_create() returns 0 at drivers/of/platform.c line 371 without recursing into the child's subnodes because matches is NULL. When control returns to the outer of_platform_default_populate() loop, of_platform_device_create_pdata() sees OF_POPULATED already set on the child and returns NULL, so the outer loop also returns 0 without populating the grandchildren. Calling of_platform_default_populate(np, lookup, dev) in simple_pm_bus_populate() would pass the default match table and avoid skipping those grandchildren.

[Severity: Medium]
In drivers/bus/simple-pm-bus.c, simple_pm_bus_probe() reads lookup from dev_get_platdata(dev) at line 74 and passes it to simple_pm_bus_populate() at line 104. Can this drop the caller's of_dev_auxdata lookup table for devices beneath a simple-bus node?

When a caller such as sysc_probe() in drivers/bus/ti-sysc.c (line 3243) calls of_platform_populate() with a match table that includes simple-bus and a non-NULL auxdata lookup table, of_platform_bus_create() only attaches platform_data to the simple-bus device itself if the auxdata table has an explicit entry matching the simple-bus node. Otherwise dev_get_platdata(dev) on the simple-bus device is NULL, and simple_pm_bus_probe() synchronously populates all child devices of the simple-bus with lookup = NULL (setting OF_POPULATED on each child) before the caller's of_platform_bus_create() loop can recurse with the caller's auxdata table. As a result, child devices under that simple-bus lose their auxdata bus_id and platform_data overrides.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
#6 lore raw

Re: [PATCH v9 4/4] bus: simple-pm-bus: Populate child nodes at probe

Hi,

Quoted 20 lines · On Mon, 09 Nov 2026 14:50:21 +0000 [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 3 potential issues to consider:
- [High] bus: simple-pm-bus: unpopulated grandchildren in simple_pm_bus_populate()
- [Medium] bus: simple-pm-bus: auxdata lookup table dropped in simple_pm_bus_probe()
- [Low] bus: simple-pm-bus: missing Fixes trailer for commit 98e96cf80045
--

commit 7ba99d9ea04b1e1a29eebc1e1525489b300fe107
Author: Herve Codina <[email protected]>

bus: simple-pm-bus: Populate child nodes at probe

This commit updates simple_pm_bus_probe() to populate child devices for transparent bus matches (such as simple-bus, simple-mfd, isa, and arm,amba-bus) during probe, and skips runtime PM calls in simple_pm_bus_depopulate() when runtime PM is not enabled.

Quoted 6 lines

[Severity: Low]
In the commit message, this patch fixes the probe behavior for bus-only devices where returning 0 without populating children caused device_links_driver_bound() to create wrong fw_devlinks. Should the commit message include a Fixes tag for 98e96cf80045 ("drivers: bus: simple-pm-bus:
Add support for probing simple bus only devices")?

The commit 98e96cf80045 didn't introduce the issue nor change the behavior. The problem is there from the beginning. For fw_devlink child devices should be populated by at parent (bus) probe(). bus-only devices such as simple-bus can populate devices recursively skipping the parent bus probe() step. I don't see an obvious commit to point for a Fixes tag and so I don't plan to add a Fixes tag on the next iteration.

Quoted 10 lines

[Severity: High]
In drivers/bus/simple-pm-bus.c, simple_pm_bus_probe() at line 104 now calls simple_pm_bus_populate(), which at line 64 calls of_platform_populate() with NULL for the matches table instead of calling of_platform_default_populate(). Does this leave grandchild devices unpopulated when a child node has a device-specific compatible string followed by a fallback bus or MFD compatible string (such as compatible = "vendor,syscon", "syscon", "simple-mfd")?

Quoted 16 lines

When an outer of_platform_default_populate() creates an ONLY_BUS device after simple_pm_bus_driver is registered, of_platform_device_create_pdata() synchronously runs simple_pm_bus_probe() before the outer of_platform_bus_create() reaches its child loop. Inside simple_pm_bus_populate(), of_platform_populate(np, NULL, lookup, dev) creates the child platform_device and sets OF_POPULATED on the child node. During device_add(), simple_pm_bus_probe() rejects that child with -ENODEV at line 100 because the generic bus compatible is not first, and of_platform_bus_create() returns 0 at drivers/of/platform.c line 371 without recursing into the child's subnodes because matches is NULL. When control returns to the outer of_platform_default_populate() loop, of_platform_device_create_pdata() sees OF_POPULATED already set on the child and returns NULL, so the outer loop also returns 0 without populating the grandchildren. Calling of_platform_default_populate(np, lookup, dev) in simple_pm_bus_populate() would pass the default match table and avoid skipping those grandchildren.

Indeed, will switch to the of_platform_default_populate() call in the next iteration.

Quoted 7 lines

[Severity: Medium]
In drivers/bus/simple-pm-bus.c, simple_pm_bus_probe() reads lookup from dev_get_platdata(dev) at line 74 and passes it to simple_pm_bus_populate() at line 104. Can this drop the caller's of_dev_auxdata lookup table for devices beneath a simple-bus node?

Quoted 11 lines

When a caller such as sysc_probe() in drivers/bus/ti-sysc.c (line 3243) calls of_platform_populate() with a match table that includes simple-bus and a non-NULL auxdata lookup table, of_platform_bus_create() only attaches platform_data to the simple-bus device itself if the auxdata table has an explicit entry matching the simple-bus node. Otherwise dev_get_platdata(dev) on the simple-bus device is NULL, and simple_pm_bus_probe() synchronously populates all child devices of the simple-bus with lookup = NULL (setting OF_POPULATED on each child) before the caller's of_platform_bus_create() loop can recurse with the caller's auxdata table. As a result, child devices under that simple-bus lose their auxdata bus_id and platform_data overrides.

Indeed.

To fix the issue I will add a OF_DEV_AUXDATA() entry for simple-bus in the existing omap_auxdata_lookup table.

A new patch for that specific modification will be added in the next iteration.

Best regards,
Hervé

#7 lore raw

Re: [PATCH v9 4/4] bus: simple-pm-bus: Populate child nodes at probe

Hi,

Quoted 5 lines · On Thu, 19 Nov 2026 09:12:45 +0100 Herve Codina <[email protected]>…

Hi,

On Mon, 09 Nov 2026 14:50:21 +0000
[email protected] wrote:

...

Quoted 17 lines
Quoted 10 lines

commit 7ba99d9ea04b1e1a29eebc1e1525489b300fe107
Author: Herve Codina <[email protected]>

bus: simple-pm-bus: Populate child nodes at probe

This commit updates simple_pm_bus_probe() to populate child devices for transparent bus matches (such as simple-bus, simple-mfd, isa, and arm,amba-bus) during probe, and skips runtime PM calls in simple_pm_bus_depopulate() when runtime PM is not enabled.

Quoted 6 lines

[Severity: Low]
In the commit message, this patch fixes the probe behavior for bus-only devices where returning 0 without populating children caused device_links_driver_bound() to create wrong fw_devlinks. Should the commit message include a Fixes tag for 98e96cf80045 ("drivers: bus: simple-pm-bus:
Add support for probing simple bus only devices")?

Quoted 6 lines

The commit 98e96cf80045 didn't introduce the issue nor change the behavior. The problem is there from the beginning. For fw_devlink child devices should be populated by at parent (bus) probe(). bus-only devices such as simple-bus can populate devices recursively skipping the parent bus probe() step. I don't see an obvious commit to point for a Fixes tag and so I don't plan to add a Fixes tag on the next iteration.

Actually found a commit for Fixes tag:
628b8ca3e915 ("bus: simple-pm-bus: Remove child devices when the bus is unbound")

Will add the Fixes tag with this one in the next iteration.

Best regards,
Hervé