pmdomain: imx: gpc: set fwnode from parent device
Subsystems (2)
PATCH 1/1 pmdomain: imx: gpc: set fwnode from parent device
Before commit 3fb16866b51d ("driver core: fw_devlink: Make cycle detection more robust"), consumer devices without their fwnode set printed errors like the one below:
[ 1.039830] imx-gpc 20dc000.gpc: Failed to create device link (0x180) with 20c8000.anatop:regulator-vddpu
To fix this, set the fwnode so fw_devlink can find and handle it properly.
--- drivers/pmdomain/imx/gpc.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pmdomain/imx/gpc.c +2 -0
@@ -411,6 +411,8 @@ static int imx_gpc_probe(struct platform_device *pdev)void __iomem *base;int ret; +device_set_node (&pdev->dev,dev_fwnode (pdev->dev.parent)); + pgc_node =of_get_child_by_name (pdev->dev.of_node,"pgc" );/* bail out if DT too old and doesn't provide the necessary info */
Signature · 1 line
2.41.0
Quoted 3 lines · Emil Kronborg Andersen
Before commit
3fb16866b51d("driver core:fw_devlink: Make cycle detection more robust"), consumer devices without their fwnode set printed errors like the one below:
The commit message is wrong. Instead of "Before commit...", it should read "After commit...". Do you want me to send a new patch or can you fix it?
Best regards,
Emil
Fabio Estevam
reviewerHi Emil,
Quoted 9 lines · Emil Kronborg Andersen
Quoted 3 lines · Emil Kronborg Andersen
Before commit
3fb16866b51d("driver core:fw_devlink: Make cycle detection more robust"), consumer devices without their fwnode set printed errors like the one below:The commit message is wrong. Instead of "Before commit...", it should read "After commit...". Do you want me to send a new patch or can you fix it?
Please send a new version with the commit message fixed and also with the Fixes tag.
Thanks
Quoted 20 lines · Emil Kronborg Andersen
Before commit
3fb16866b51d("driver core:fw_devlink: Make cycle detection more robust"), consumer devices without their fwnode set printed errors like the one below:[ 1.039830] imx-gpc 20dc000.gpc: Failed to create device link (0x180) with 20c8000.anatop:regulator-vddpuTo fix this, set the fwnode so
fw_devlinkcan find and handle it properly.Signed-off-by Emil Kronborg Andersen <[email protected]>--- drivers/pmdomain/imx/gpc.c | 2 ++ 1 file changed, 2 insertions(+)drivers/pmdomain/imx/gpc.c +0
-0
drivers/pmdomain/imx/gpc.c static int imx_gpc_probe(struct platform_device *pdev) · line 415
Quoted 5 lines
drivers/pmdomain/imx/gpc.c +2
-0@@ -411,6 +411,8 @@ static int imx_gpc_probe(struct platform_device *pdev)void __iomem *base;int ret; +device_set_node (&pdev->dev,dev_fwnode (pdev->dev.parent)); +
Similar question as the other patch. Can we do this at a pmdomain framework level instead of per driver?
-Saravana
Quoted 6 lines
drivers/pmdomain/imx/gpc.c +0
-1pgc_node =of_get_child_by_name (pdev->dev.of_node,"pgc" );/* bail out if DT too old and doesn't provide the necessary info */ --2.41.0
Quoted 25 lines · Saravana Kannan
Quoted 23 lines · Emil Kronborg Andersen
Before commit
3fb16866b51d("driver core:fw_devlink: Make cycle detection more robust"), consumer devices without their fwnode set printed errors like the one below:[ 1.039830] imx-gpc 20dc000.gpc: Failed to create device link (0x180) with 20c8000.anatop:regulator-vddpuTo fix this, set the fwnode so
fw_devlinkcan find and handle it properly.Signed-off-by Emil Kronborg Andersen <[email protected]>--- drivers/pmdomain/imx/gpc.c | 2 ++ 1 file changed, 2 insertions(+)drivers/pmdomain/imx/gpc.c +0
-0@@ -411,6 +411,8 @@ static int imx_gpc_probe(struct platform_device *pdev)void __iomem *base;int ret;
Quoted 5 lines
drivers/pmdomain/imx/gpc.c static int imx_gpc_probe(struct platform_device *pdev) · line 415
Quoted 2 lines
drivers/pmdomain/imx/gpc.c +2
-0+device_set_node (&pdev->dev,dev_fwnode (pdev->dev.parent)); +Similar question as the other patch. Can we do this at a pmdomain framework level instead of per driver?
Unfortunately, it's not that easy. It's not required by pm_genpd_init() (or of_genpd_add_provider_*) to use a struct *device when registering a genpd provider. In fact, that's also the reason why pm_genpd_init() needs to initialize its own struct device.
That said, can you please explain the special condition that caused this thing to be needed in the first place?
[...]
Kind regards
Uffe
Hi Ulf,
Quoted 4 lines · Ulf Hansson
Unfortunately, it's not that easy. It's not required by
pm_genpd_init()(or of_genpd_add_provider_*) to use a struct *device when registering a genpd provider. In fact, that's also the reason whypm_genpd_init()needs to initialize its own struct device.
Do you see any way to do it properly at pmdomain level instead, or is that not feasible? I agree with Saravana that a centralized solution, akin to what was implemented for tty devices in commit 1a5ecc73b2bf ("serdev: Set fwnode for serdev devices"), would be ideal. However, I was not able to find other reports or patches of problems regarding fw_devlink at pmdomain level, so it might not be a general problem here, and fixes per driver might be okay in this case?
Quoted 2 lines
That said, can you please explain the special condition that caused this thing to be needed in the first place?
I noticed this issue when I updated from 5.15.93 to 6.1.37. Except for the commit I bisected, i.e., 3fb16866b51d ("driver core: fw_devlink:
Make cycle detection more robust"), I found that the issue was introduced somewhere between 6.1.16 and 6.1.15. Here, some commits regarding fw_devlink was backported, which might be relevant:
$ git log --oneline v6.1.15..v6.1.16 -- drivers/base/core.c | grep fw_devlink 11d93294b7c3 driver core: fw_devlink: Avoid spurious error message 3dd596616d10 driver core: fw_devlink: Make cycle detection more robust a3c171751512 driver core: fw_devlink: Improve check for fwnode with no device/driver 7a8ce4d2fbbc driver core: fw_devlink: Consolidate device link flag computation 16aa2487cf15 driver core: fw_devlink: Allow marking a fwnode link as being part of a cycle eaf9b5612a47 driver core: fw_devlink: Don't purge child fwnode's consumer links 2455b81afe68 driver core: fw_devlink: Add DL_FLAG_CYCLE support to device links
Best regards,
Emil
Quoted 9 lines · Emil Kronborg Andersen
Hi Ulf,
Quoted 4 lines · Ulf Hansson
Unfortunately, it's not that easy. It's not required by
pm_genpd_init()(or of_genpd_add_provider_*) to use a struct *device when registering a genpd provider. In fact, that's also the reason whypm_genpd_init()needs to initialize its own struct device.
Quoted 7 lines
Do you see any way to do it properly at pmdomain level instead, or is that not feasible? I agree with Saravana that a centralized solution, akin to what was implemented for tty devices in commit
1a5ecc73b2bf("serdev: Set fwnode for serdev devices"), would be ideal. However, I was not able to find other reports or patches of problems regardingfw_devlinkat pmdomain level, so it might not be a general problem here, and fixes per driver might be okay in this case?
Sure, we could fix it though a centralized solution, but it requires us to patch each and every genpd provider driver too. At this point I would therefore say, let's just fix it for those that need it.
Quoted 10 lines
Quoted 3 lines
That said, can you please explain the special condition that caused this thing to be needed in the first place?
I noticed this issue when I updated from 5.15.93 to 6.1.37. Except for the commit I bisected, i.e.,
3fb16866b51d("driver core:fw_devlink:
Make cycle detection more robust"), I found that the issue was introduced somewhere between 6.1.16 and 6.1.15. Here, some commits regardingfw_devlinkwas backported, which might be relevant:
Quoted 8 lines
$ git log --oneline v6.1.15..v6.1.16 -- drivers/base/core.c | grep fw_devlink 11d93294b7c3 driver core: fw_devlink: Avoid spurious error message 3dd596616d10 driver core: fw_devlink: Make cycle detection more robust a3c171751512 driver core: fw_devlink: Improve check for fwnode with no device/driver 7a8ce4d2fbbc driver core: fw_devlink: Consolidate device link flag computation 16aa2487cf15 driver core: fw_devlink: Allow marking a fwnode link as being part of a cycle eaf9b5612a47 driver core: fw_devlink: Don't purge child fwnode's consumer links 2455b81afe68 driver core: fw_devlink: Add DL_FLAG_CYCLE support to device links
Thanks for sharing the commits. I haven't looked much closer to them, but maybe Saravana has some ideas about whether this potentially can be fixed in the fw_devlink parsing instead?
Kind regards
Uffe
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
+ Pengfei Li
Quoted 42 lines · Ulf Hansson
Quoted 9 lines · Emil Kronborg Andersen
Hi Ulf,
Quoted 4 lines · Ulf Hansson
Unfortunately, it's not that easy. It's not required by
pm_genpd_init()(or of_genpd_add_provider_*) to use a struct *device when registering a genpd provider. In fact, that's also the reason whypm_genpd_init()needs to initialize its own struct device.Quoted 7 lines
Do you see any way to do it properly at pmdomain level instead, or is that not feasible? I agree with Saravana that a centralized solution, akin to what was implemented for tty devices in commit
1a5ecc73b2bf("serdev: Set fwnode for serdev devices"), would be ideal. However, I was not able to find other reports or patches of problems regardingfw_devlinkat pmdomain level, so it might not be a general problem here, and fixes per driver might be okay in this case?Sure, we could fix it though a centralized solution, but it requires us to patch each and every genpd provider driver too. At this point I would therefore say, let's just fix it for those that need it.
Quoted 10 lines
Quoted 3 lines
That said, can you please explain the special condition that caused this thing to be needed in the first place?
I noticed this issue when I updated from 5.15.93 to 6.1.37. Except for the commit I bisected, i.e.,
3fb16866b51d("driver core:fw_devlink:
Make cycle detection more robust"), I found that the issue was introduced somewhere between 6.1.16 and 6.1.15. Here, some commits regardingfw_devlinkwas backported, which might be relevant:Quoted 8 lines
$ git log --oneline v6.1.15..v6.1.16 -- drivers/base/core.c | grep fw_devlink 11d93294b7c3 driver core: fw_devlink: Avoid spurious error message 3dd596616d10 driver core: fw_devlink: Make cycle detection more robust a3c171751512 driver core: fw_devlink: Improve check for fwnode with no device/driver 7a8ce4d2fbbc driver core: fw_devlink: Consolidate device link flag computation 16aa2487cf15 driver core: fw_devlink: Allow marking a fwnode link as being part of a cycle eaf9b5612a47 driver core: fw_devlink: Don't purge child fwnode's consumer links 2455b81afe68 driver core: fw_devlink: Add DL_FLAG_CYCLE support to device links
Quoted 3 lines
Thanks for sharing the commits. I haven't looked much closer to them, but maybe Saravana has some ideas about whether this potentially can be fixed in the
fw_devlinkparsing instead?
I had a bit closer look at this. If I understand things correctly, this problem is because the imx_gpc_driver's ->probe() (imx_gpc_probe) is allocating/adding a new platform device, per child-of-node to represent a power-domain.
I suspect in most other cases where a platform device is being allocated per child node, is when the child node has a compatible-string and the parent driver is calling of_platform_populate(), or similar. In those cases, the "dev.fwnode" would be set accordingly, but not in the imx_gpc_driver case as it needs to be set explicitly.
That said, it looks like we should move forward with the $subject patch. However, it looks like the patch [1] from Pengfei Li is more correct than the $subject patch.
Kind regards
Uffe
Quoted 16 lines · Ulf Hansson
I had a bit closer look at this. If I understand things correctly, this problem is because the imx_gpc_driver's ->probe() (
imx_gpc_probe) is allocating/adding a new platform device, per child-of-node to represent a power-domain.I suspect in most other cases where a platform device is being allocated per child node, is when the child node has a compatible-string and the parent driver is calling
of_platform_populate(), or similar. In those cases, the "dev.fwnode" would be set accordingly, but not in theimx_gpc_drivercase as it needs to be set explicitly.That said, it looks like we should move forward with the $subject patch. However, it looks like the patch [1] from Pengfei Li is more correct than the $subject patch.
Quoted 5 lines
Kind regards
Uffe
That is also how I understand it works.
I was unsure if the patch from Pengfei Li [1] solves the same issue as this patch, since there are no errors included in the commit message. However, after testing the patch in [1], I can confirm that it fixes:
[ 1.039830] imx-gpc 20dc000.gpc: Failed to create device link (0x180) with 20c8000.anatop:regulator-vddpu
I based my solution on other patches, where device_set_node() is used. For example, a26cc2934331 ("drm/mipi-dsi: Set the fwnode for mipi_dsi_device") and 6dbe6c07f94f ("gpio: Propagate firmware node from a parent"). I am curious: Why is the approach in [1] considered more correct? It seems logical to set the fwnode as early as possible from the parent its device.
Thanks!
Best regards,
Emil
Quoted 30 lines · Emil Kronborg Andersen
Quoted 16 lines · Ulf Hansson
I had a bit closer look at this. If I understand things correctly, this problem is because the imx_gpc_driver's ->probe() (
imx_gpc_probe) is allocating/adding a new platform device, per child-of-node to represent a power-domain.I suspect in most other cases where a platform device is being allocated per child node, is when the child node has a compatible-string and the parent driver is calling
of_platform_populate(), or similar. In those cases, the "dev.fwnode" would be set accordingly, but not in theimx_gpc_drivercase as it needs to be set explicitly.That said, it looks like we should move forward with the $subject patch. However, it looks like the patch [1] from Pengfei Li is more correct than the $subject patch.
Quoted 5 lines
Kind regards
UffeThat is also how I understand it works.
I was unsure if the patch from Pengfei Li [1] solves the same issue as this patch, since there are no errors included in the commit message. However, after testing the patch in [1], I can confirm that it fixes:
Quoted 8 lines
[ 1.039830] imx-gpc 20dc000.gpc: Failed to create device link (0x180) with 20c8000.anatop:regulator-vddpuI based my solution on other patches, where
device_set_node()is used. For example,a26cc2934331("drm/mipi-dsi: Set the fwnode formipi_dsi_device") and6dbe6c07f94f("gpio: Propagate firmware node from a parent"). I am curious: Why is the approach in [1] considered more correct? It seems logical to set the fwnode as early as possible from the parent its device.
Why do we want to use the parent's node? The devices (platform-device) that we allocate belongs to the corresponding parsed child node, doesn't it?
Kind regards
Uffe
Quoted 44 lines · Ulf Hansson
Quoted 30 lines · Emil Kronborg Andersen
Quoted 16 lines · Ulf Hansson
I had a bit closer look at this. If I understand things correctly, this problem is because the imx_gpc_driver's ->probe() (
imx_gpc_probe) is allocating/adding a new platform device, per child-of-node to represent a power-domain.I suspect in most other cases where a platform device is being allocated per child node, is when the child node has a compatible-string and the parent driver is calling
of_platform_populate(), or similar. In those cases, the "dev.fwnode" would be set accordingly, but not in theimx_gpc_drivercase as it needs to be set explicitly.That said, it looks like we should move forward with the $subject patch. However, it looks like the patch [1] from Pengfei Li is more correct than the $subject patch.
Quoted 5 lines
Kind regards
UffeThat is also how I understand it works.
I was unsure if the patch from Pengfei Li [1] solves the same issue as this patch, since there are no errors included in the commit message. However, after testing the patch in [1], I can confirm that it fixes:
Quoted 8 lines
[ 1.039830] imx-gpc 20dc000.gpc: Failed to create device link (0x180) with 20c8000.anatop:regulator-vddpuI based my solution on other patches, where
device_set_node()is used. For example,a26cc2934331("drm/mipi-dsi: Set the fwnode formipi_dsi_device") and6dbe6c07f94f("gpio: Propagate firmware node from a parent"). I am curious: Why is the approach in [1] considered more correct? It seems logical to set the fwnode as early as possible from the parent its device.Why do we want to use the parent's node? The devices (platform-device) that we allocate belongs to the corresponding parsed child node, doesn't it?
Quoted 7 lines
Kind regards
Uffe_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
I think you are right about that.
In [1], dev.fwnode is set directly, but I think it is more correct to use device_set_node() instead, to ensure that dev.of_node is also set correctly like so:
drivers/pmdomain/imx/gpc.c +1 -1
@@ -497,7 +497,7 @@ static int imx_gpc_probe(struct platform_device *pdev) domain->ipg_rate_mhz = ipg_rate_mhz; pd_pdev->dev.parent = &pdev->dev; - pd_pdev->dev.of_node = np; +device_set_node (&pd_pdev->dev,of_fwnode_handle (np)); ret =platform_device_add (pd_pdev);if (ret) {
[1]
https://lore.kernel.org/all/[email protected]/
Best regards,
Emil