mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 18:09:56 +00:00
media: bcm2835-unicam: Return early from stop_streaming() if stopped
clk_disable_unprepare() is called unconditionally in stop_streaming(). This is incorrect in the cases where start_streaming() fails, and unprepares all clocks as part of the failure cleanup. To avoid this, ensure that clk_disable_unprepare() is only called in stop_streaming() if the clocks are in a prepared state. Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
This commit is contained in:
committed by
Dom Cobley
parent
c8051d40d2
commit
11fb509ec8
@@ -426,6 +426,8 @@ struct unicam_device {
|
|||||||
struct clk *clock;
|
struct clk *clock;
|
||||||
/* vpu clock handle */
|
/* vpu clock handle */
|
||||||
struct clk *vpu_clock;
|
struct clk *vpu_clock;
|
||||||
|
/* clock status for error handling */
|
||||||
|
bool clocks_enabled;
|
||||||
/* V4l2 device */
|
/* V4l2 device */
|
||||||
struct v4l2_device v4l2_dev;
|
struct v4l2_device v4l2_dev;
|
||||||
struct media_device mdev;
|
struct media_device mdev;
|
||||||
@@ -1724,6 +1726,7 @@ static int unicam_start_streaming(struct vb2_queue *vq, unsigned int count)
|
|||||||
goto err_disable_unicam;
|
goto err_disable_unicam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dev->clocks_enabled = true;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_disable_unicam:
|
err_disable_unicam:
|
||||||
@@ -1750,8 +1753,6 @@ static void unicam_stop_streaming(struct vb2_queue *vq)
|
|||||||
node->streaming = false;
|
node->streaming = false;
|
||||||
|
|
||||||
if (node->pad_id == IMAGE_PAD) {
|
if (node->pad_id == IMAGE_PAD) {
|
||||||
int ret;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Stop streaming the sensor and disable the peripheral.
|
* Stop streaming the sensor and disable the peripheral.
|
||||||
* We cannot continue streaming embedded data with the
|
* We cannot continue streaming embedded data with the
|
||||||
@@ -1762,12 +1763,13 @@ static void unicam_stop_streaming(struct vb2_queue *vq)
|
|||||||
|
|
||||||
unicam_disable(dev);
|
unicam_disable(dev);
|
||||||
|
|
||||||
ret = clk_set_min_rate(dev->vpu_clock, 0);
|
if (dev->clocks_enabled) {
|
||||||
if (ret)
|
if (clk_set_min_rate(dev->vpu_clock, 0))
|
||||||
unicam_err(dev, "failed to reset the min VPU clock\n");
|
unicam_err(dev, "failed to reset the min VPU clock\n");
|
||||||
|
|
||||||
clk_disable_unprepare(dev->vpu_clock);
|
clk_disable_unprepare(dev->vpu_clock);
|
||||||
clk_disable_unprepare(dev->clock);
|
clk_disable_unprepare(dev->clock);
|
||||||
|
}
|
||||||
unicam_runtime_put(dev);
|
unicam_runtime_put(dev);
|
||||||
|
|
||||||
} else if (node->pad_id == METADATA_PAD) {
|
} else if (node->pad_id == METADATA_PAD) {
|
||||||
|
|||||||
Reference in New Issue
Block a user