[4/4] media: pisp_be: Fix pm_runtime underrun in probe

Message ID 20240826144338.463683-5-jacopo.mondi@ideasonboard.com (mailing list archive)
State Superseded
Headers
Series media: pisp-be: Split jobs creation and scheduling |

Commit Message

Jacopo Mondi Aug. 26, 2024, 2:43 p.m. UTC
  The pisp_be driver uses and depends on runtime_pm.

During the probe() routine, the driver needs to power up the interface
in order to identify and initialize the hardware and it later suspends
it at the end of probe().

The driver erroneously resumes the interface by calling the
pispbe_runtime_resume() function directly, without going
through the pm_runtime helpers, but later suspends it by calling
pm_runtime_put_autosuspend().

This causes a PM usage count imbalance at probe time, notified by the
runtime_pm framework with the below message in the system log:

 pispbe 1000880000.pisp_be: Runtime PM usage count underflow!

Fix this by resuming the interface using the pm runtime helpers instead
of calling the resume function directly.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
 drivers/media/platform/raspberrypi/pisp_be/pisp_be.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

kernel test robot Aug. 27, 2024, 5 a.m. UTC | #1
Hi Jacopo,

kernel test robot noticed the following build warnings:

[auto build test WARNING on media-tree/master]
[also build test WARNING on linus/master v6.11-rc5 next-20240826]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Jacopo-Mondi/media-pisp_be-Drop-reference-to-non-existing-function/20240826-224625
base:   git://linuxtv.org/media_tree.git master
patch link:    https://lore.kernel.org/r/20240826144338.463683-5-jacopo.mondi%40ideasonboard.com
patch subject: [PATCH 4/4] media: pisp_be: Fix pm_runtime underrun in probe
config: m68k-allmodconfig (https://download.01.org/0day-ci/archive/20240827/202408271258.YcqkRjNU-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240827/202408271258.YcqkRjNU-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408271258.YcqkRjNU-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/media/platform/raspberrypi/pisp_be/pisp_be.c:1641:12: warning: 'pispbe_runtime_resume' defined but not used [-Wunused-function]
    1641 | static int pispbe_runtime_resume(struct device *dev)
         |            ^~~~~~~~~~~~~~~~~~~~~


vim +/pispbe_runtime_resume +1641 drivers/media/platform/raspberrypi/pisp_be/pisp_be.c

12187bd5d4f8c1 Naushir Patuck 2024-06-26  1640  
12187bd5d4f8c1 Naushir Patuck 2024-06-26 @1641  static int pispbe_runtime_resume(struct device *dev)
12187bd5d4f8c1 Naushir Patuck 2024-06-26  1642  {
12187bd5d4f8c1 Naushir Patuck 2024-06-26  1643  	struct pispbe_dev *pispbe = dev_get_drvdata(dev);
12187bd5d4f8c1 Naushir Patuck 2024-06-26  1644  	int ret;
12187bd5d4f8c1 Naushir Patuck 2024-06-26  1645  
12187bd5d4f8c1 Naushir Patuck 2024-06-26  1646  	ret = clk_prepare_enable(pispbe->clk);
12187bd5d4f8c1 Naushir Patuck 2024-06-26  1647  	if (ret) {
12187bd5d4f8c1 Naushir Patuck 2024-06-26  1648  		dev_err(dev, "Unable to enable clock\n");
12187bd5d4f8c1 Naushir Patuck 2024-06-26  1649  		return ret;
12187bd5d4f8c1 Naushir Patuck 2024-06-26  1650  	}
12187bd5d4f8c1 Naushir Patuck 2024-06-26  1651  
12187bd5d4f8c1 Naushir Patuck 2024-06-26  1652  	dev_dbg(dev, "%s: Enabled clock, rate=%lu\n",
12187bd5d4f8c1 Naushir Patuck 2024-06-26  1653  		__func__, clk_get_rate(pispbe->clk));
12187bd5d4f8c1 Naushir Patuck 2024-06-26  1654  
12187bd5d4f8c1 Naushir Patuck 2024-06-26  1655  	return 0;
12187bd5d4f8c1 Naushir Patuck 2024-06-26  1656  }
12187bd5d4f8c1 Naushir Patuck 2024-06-26  1657
  

Patch

diff --git a/drivers/media/platform/raspberrypi/pisp_be/pisp_be.c b/drivers/media/platform/raspberrypi/pisp_be/pisp_be.c
index f42541bb4827..fd4fec0f5d99 100644
--- a/drivers/media/platform/raspberrypi/pisp_be/pisp_be.c
+++ b/drivers/media/platform/raspberrypi/pisp_be/pisp_be.c
@@ -1741,7 +1741,7 @@  static int pispbe_probe(struct platform_device *pdev)
 	pm_runtime_use_autosuspend(pispbe->dev);
 	pm_runtime_enable(pispbe->dev);
 
-	ret = pispbe_runtime_resume(pispbe->dev);
+	ret = pm_runtime_resume_and_get(pispbe->dev);
 	if (ret)
 		goto pm_runtime_disable_err;