NET: mcan: Move runtime PM enable/disable to m_can_platform
Subsystems (2)
v2 cover NET: mcan: Move runtime PM enable/disable to m_can_platform
Hi,This is a preparatory patch for modifying PM enabling due to PCI based M_CAN devices. As the functionality is right now, adding a PCI based M_CAN driver causes the core PCI functionality to call pm_runtime_enable() from pci_pm_init() when the PCI device is added. When the device is added, it is registered with m_can_class_register(), which ends up calling pm_runtime_enable() once more and causes the kernel to log an angry 'Unbalanced pm_runtime_enable!' message, as dev->power.disable_depth has gone down to zero.
To resolve this situation, I have added a patch that moves runtime PM enabling from m_can.c to the m_can_platform.c driver, which currently is the only driver that ends up enabling runtime PM.
Thanks,
Patrik
Patrik Flykt (1):
NET: mcan: Move runtime PM enable/disable to m_can_platform
drivers/net/can/m_can/m_can.c | 9 ++------- drivers/net/can/m_can/m_can_platform.c | 7 ++++++- 2 files changed, 8 insertions(+), 8 deletions(-)
Signature · 1 line
2.28.0
PATCH v2 1/1 NET: mcan: Move runtime PM enable/disable to m_can_platform
This is a preparatory patch for upcoming PCI based M_CAN devices. The current PM implementation would cause PCI based drivers to enable PM twice, once when the PCI device is added and a second time in m_can_class_register(). This will cause 'Unbalanced pm_runtime_enable!' to be logged, and is a situation that should be avoided.
Therefore, in anticipation of PCI devices, move PM enabling out from M_CAN class registration to its only user, the m_can_platform driver.
---
v2: Rebased on mkl/linux-can.git 9146843b11b6
drivers/net/can/m_can/m_can.c | 9 ++------- drivers/net/can/m_can/m_can_platform.c | 7 ++++++- 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/net/can/m_can/m_can.c +2 -7
@@ -1803,10 +1803,9 @@ int m_can_class_register(struct m_can_classdev *m_can_dev)int ret;if (m_can_dev->pm_clock_support) { -pm_runtime_enable (m_can_dev->dev); ret =m_can_clk_start (m_can_dev);if (ret) - goto pm_runtime_fail; + goto clk_fail; } ret =m_can_dev_setup (m_can_dev);
@@ -1832,12 +1831,8 @@ int m_can_class_register(struct m_can_classdev *m_can_dev)*/ clk_disable:m_can_clk_stop (m_can_dev); -pm_runtime_fail: -if (ret) { -if (m_can_dev->pm_clock_support) -pm_runtime_disable (m_can_dev->dev); - } +clk_fail:return ret; }EXPORT_SYMBOL_GPL (m_can_class_register);
drivers/net/can/m_can/m_can_platform.c +6 -1
@@ -134,7 +134,12 @@ static int m_can_plat_probe(struct platform_device *pdev)m_can_init_ram (mcan_class); -return m_can_class_register (mcan_class); +pm_runtime_enable (mcan_class->dev); + ret =m_can_class_register (mcan_class); +if (ret) +pm_runtime_disable (mcan_class->dev); + +return ret; probe_fail:m_can_class_free_dev (mcan_class->net);
Signature · 1 line
2.28.0
Quoted 7 lines · Patrik Flykt
This is a preparatory patch for upcoming PCI based
M_CANdevices. The current PM implementation would cause PCI based drivers to enable PM twice, once when the PCI device is added and a second time inm_can_class_register(). This will cause 'Unbalancedpm_runtime_enable!' to be logged, and is a situation that should be avoided.
Quoted 7 lines
Therefore, in anticipation of PCI devices, move PM enabling out from
M_CANclass registration to its only user, them_can_platformdriver.Signed-off-by Patrik Flykt <[email protected]>---
v2: Rebased on mkl/linux-can.git9146843b11b6
Ping ping?
Patrik
Marc Kleine-Budde
maintainerQuoted 12 lines · Patrik Flykt
Quoted 11 lines · Patrik Flykt
This is a preparatory patch for upcoming PCI based
M_CANdevices. The current PM implementation would cause PCI based drivers to enable PM twice, once when the PCI device is added and a second time inm_can_class_register(). This will cause 'Unbalancedpm_runtime_enable!' to be logged, and is a situation that should be avoided.Therefore, in anticipation of PCI devices, move PM enabling out from
M_CANclass registration to its only user, them_can_platformdriver.
Quoted 5 lines
Quoted 3 lines
Signed-off-by Patrik Flykt <[email protected]>---
v2: Rebased on mkl/linux-can.git9146843b11b6Ping ping?
Applied to linux-can/testing.
Thanks,
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |