lan966x pci device: Add support for SFPs, simple-bus part
Subsystems (5)
v10 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 prepares TI OMAP bus-only devices to be populated by the simple-pm-bus probe().
Patch 5 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:
v9 -> v10
v9: https://lore.kernel.org/all/[email protected]/
- Patches 1..3
No change
- Patch 4 (new patch in v10)
Prepares TI OMAP bus-only devices to be populated by the simple-pm-bus probe(). This fixes an issue reported by Sashiko related auxdata lookup table dropped in simple_pm_bus_probe().
- Patch 5 (patch 4 in v9)
Use of_platform_default_populate() instead of of_platform_populate() for bus-only devices to fix the 'unpopulated grandchildren in simple_pm_bus_populate()' issue reported by Sashiko.
Add Fixes tag.
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 (5):
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
ARM: OMAP2+: pdata-quirks: Pass auxdata for simple-bus devices
bus: simple-pm-bus: Populate child nodes at probe
arch/arm/mach-omap2/pdata-quirks.c | 1 + drivers/bus/simple-pm-bus.c | 92 ++++++++++++++++++++++-------- 2 files changed, 70 insertions(+), 23 deletions(-)
Signature · 1 line
2.56.0
PATCH v10 1/5 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().
--- drivers/bus/simple-pm-bus.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/bus/simple-pm-bus.c +4 -8
@@ -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
PATCH v10 2/5 bus: simple-pm-bus: Remove the remove() function
In reply to Herve CodinaDue 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
@@ -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
PATCH v10 3/5 bus: simple-pm-bus: Remove child devices when the bus is unbound
In reply to Herve CodinaDuring 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
@@ -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
PATCH v10 4/5 ARM: OMAP2+: pdata-quirks: Pass auxdata for simple-bus devices
In reply to Herve CodinaThe simple-pm-bus driver takes the of_dev_auxdata lookup table from the platform data of the bus device, following the convention introduced for "simple-pm-bus" by commit eda080eabf5b ("drivers: bus: simple-pm-bus:
Fix compatibility with simple-bus for auxdata").
omap_auxdata_lookup only has an entry for the "simple-pm-bus" compatible, so a simple-bus node created by of_platform_populate() with this lookup table has no platform data, and the lookup table is not available to the driver for that bus.
As a prerequisite for introducing platform device population for bus-only devices in the simple-pm-bus driver, the lookup table must also be available on simple-bus devices. When the driver populates the children of such a bus from its probe(), it takes the lookup table from the platform data of the bus device; otherwise those children are created without the bus_id and platform_data overrides.
Add the corresponding "simple-bus" entry, mapping it to the same table as the "simple-pm-bus" one.
--- arch/arm/mach-omap2/pdata-quirks.c | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-omap2/pdata-quirks.c +1 -0
@@ -491,6 +491,7 @@ static struct of_dev_auxdata omap_auxdata_lookup[] = {#endif /* Common auxdata */ OF_DEV_AUXDATA ("simple-pm-bus" ,0 ,NULL , omap_auxdata_lookup), +OF_DEV_AUXDATA ("simple-bus" ,0 ,NULL , omap_auxdata_lookup),OF_DEV_AUXDATA ("ti,sysc" ,0 ,NULL , &ti_sysc_pdata),OF_DEV_AUXDATA ("pinctrl-single" ,0 ,NULL , &pcs_pdata), OF_DEV_AUXDATA("ti,omap-prm-inst", 0, NULL, &ti_prm_pdata),
Signature · 1 line
2.56.0
PATCH v10 5/5 bus: simple-pm-bus: Populate child nodes at probe
In reply to Herve CodinaThe 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 | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-)
drivers/bus/simple-pm-bus.c +25 -10
@@ -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
@@ -46,7 +52,7 @@ static void simple_pm_bus_depopulate(void *data)pm_runtime_put_sync (dev); } -static int simple_pm_bus_populate (struct device *dev, +static int simple_pm_bus_populate (struct device *dev,bool default_populate,const struct of_dev_auxdata *lookup) {struct device_node *np = dev->of_node;
@@ -55,7 +61,9 @@ static int simple_pm_bus_populate(struct device *dev,if (!np)return 0 ; - ret =of_platform_populate (np,NULL , lookup, dev); + ret = default_populate ? +of_platform_default_populate (np, lookup, dev) : +of_platform_populate (np,NULL , lookup, dev);if (ret)return ret;
@@ -83,16 +91,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, true, 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 );
@@ -111,7 +126,7 @@ static int simple_pm_bus_probe(struct platform_device *pdev)if (ret)return dev_err_probe (&pdev->dev, ret,"failed enable pm_runtime\n" ); - ret =simple_pm_bus_populate (&pdev->dev, lookup); + ret =simple_pm_bus_populate (&pdev->dev, false, lookup);if (ret)return dev_err_probe (&pdev->dev, ret,"failed to populate\n" );
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH v10 5/5] bus: simple-pm-bus: Populate child nodes at probe
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] bus: simple-pm-bus: invalid Fixes trailer SHA 628b8ca3e915 --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] bus: simple-pm-bus: invalid Fixes trailer SHA 628b8ca3e915 --
commit e4f7a29754a7ea513e3c43d4f852eb4379192762
Author: Herve Codina <[email protected]>
bus: simple-pm-bus: Populate child nodes at probe
This commit updates simple_pm_bus_probe() in drivers/bus/simple-pm-bus.c to populate child devices during probe for transparent bus matches via of_platform_default_populate(), and updates simple_pm_bus_depopulate() to depopulate directly when runtime PM is not enabled.
[Severity: Low]
In the commit message, the Fixes: trailer references commit 628b8ca3e915 ("bus: simple-pm-bus: Remove child devices when the bus is unbound"), which cannot be resolved in the repository and points to an unmerged patch from earlier in the same series rather than a stable upstream commit. Probing transparent bus-only devices in simple_pm_bus_probe() and returning early without populating their child nodes during probe was originally introduced in commit 98e96cf80045 ("drivers: bus:
simple-pm-bus: Add support for probing simple bus only devices").
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
Hi all,
Please ignore the series, I've mentioned a wrong commit in Fixes tag available in patch 5/5.
I fix that and send a new iteration soon.
Sorry about that :(
Best regards,
Hervé
Quoted 49 lines · On Thu, 19 Nov 2026 12:00:06 +0100 Herve Codina <[email protected]>…
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 prepares TI OMAP bus-only devices to be populated by the simple-pm-bus
probe().Patch 5 makes the simple-bus driver compatible with
fw_devlinkexpectation consisting in creating its child devices at probe.[0] https://lore.kernel.org/all/[email protected]/
Best regards,
HervéChanges:
v9 -> v10
v9: https://lore.kernel.org/all/[email protected]/- Patches 1..3
No change- Patch 4 (new patch in v10)
Prepares TI OMAP bus-only devices to be populated by the simple-pm-busprobe(). This fixes an issue reported by Sashiko related auxdata lookup table dropped insimple_pm_bus_probe().- Patch 5 (patch 4 in v9)
Useof_platform_default_populate()instead ofof_platform_populate()for bus-only devices to fix the 'unpopulated grandchildren insimple_pm_bus_populate()' issue reported by Sashiko.
Add Fixes tag.