Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: pisp_be: Fix pm_runtime underrun in probe

During the probe() routine, the PiSP BE driver needs to power up the
interface in order to identify and initialize the hardware.

The driver 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 and use the pm_runtime framework
in the probe() error path. While at it, remove manual suspend of the
interface in the remove() function. The driver cannot be unloaded if in
use, so simply disable runtime pm.

To simplify the implementation, make the driver depend on PM as the
RPI5 platform where the ISP is integrated in uses the PM framework by
default.

Fixes: 12187bd5d4f8 ("media: raspberrypi: Add support for PiSP BE")
Cc: stable@vger.kernel.org
Tested-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>

authored by

Jacopo Mondi and committed by
Hans Verkuil
e9bb2eac 972eed08

+3 -3
+1
drivers/media/platform/raspberrypi/pisp_be/Kconfig
··· 3 3 depends on V4L_PLATFORM_DRIVERS 4 4 depends on VIDEO_DEV 5 5 depends on ARCH_BCM2835 || COMPILE_TEST 6 + depends on PM 6 7 select VIDEO_V4L2_SUBDEV_API 7 8 select MEDIA_CONTROLLER 8 9 select VIDEOBUF2_DMA_CONTIG
+2 -3
drivers/media/platform/raspberrypi/pisp_be/pisp_be.c
··· 1725 1725 pm_runtime_use_autosuspend(pispbe->dev); 1726 1726 pm_runtime_enable(pispbe->dev); 1727 1727 1728 - ret = pispbe_runtime_resume(pispbe->dev); 1728 + ret = pm_runtime_resume_and_get(pispbe->dev); 1729 1729 if (ret) 1730 1730 goto pm_runtime_disable_err; 1731 1731 ··· 1747 1747 disable_devs_err: 1748 1748 pispbe_destroy_devices(pispbe); 1749 1749 pm_runtime_suspend_err: 1750 - pispbe_runtime_suspend(pispbe->dev); 1750 + pm_runtime_put(pispbe->dev); 1751 1751 pm_runtime_disable_err: 1752 1752 pm_runtime_dont_use_autosuspend(pispbe->dev); 1753 1753 pm_runtime_disable(pispbe->dev); ··· 1761 1761 1762 1762 pispbe_destroy_devices(pispbe); 1763 1763 1764 - pispbe_runtime_suspend(pispbe->dev); 1765 1764 pm_runtime_dont_use_autosuspend(pispbe->dev); 1766 1765 pm_runtime_disable(pispbe->dev); 1767 1766 }