Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

media: bcm2835-unicam: Correctly handle error states on stream on/off #3984

Merged
merged 2 commits into from
Dec 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions drivers/media/platform/bcm2835/bcm2835-unicam.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,8 @@ struct unicam_device {
struct clk *clock;
/* vpu clock handle */
struct clk *vpu_clock;
/* clock status for error handling */
bool clocks_enabled;
/* V4l2 device */
struct v4l2_device v4l2_dev;
struct media_device mdev;
Expand Down Expand Up @@ -1724,14 +1726,14 @@ static int unicam_start_streaming(struct vb2_queue *vq, unsigned int count)
goto err_disable_unicam;
}

dev->clocks_enabled = true;
return 0;

err_disable_unicam:
unicam_disable(dev);
clk_disable_unprepare(dev->clock);
err_vpu_clock:
ret = clk_set_min_rate(dev->vpu_clock, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ouch - that's subtle!
Good spot ;-)

if (ret)
if (clk_set_min_rate(dev->vpu_clock, 0))
unicam_err(dev, "failed to reset the VPU clock\n");
clk_disable_unprepare(dev->vpu_clock);
err_pm_put:
Expand All @@ -1751,8 +1753,6 @@ static void unicam_stop_streaming(struct vb2_queue *vq)
node->streaming = false;

if (node->pad_id == IMAGE_PAD) {
int ret;

/*
* Stop streaming the sensor and disable the peripheral.
* We cannot continue streaming embedded data with the
Expand All @@ -1763,12 +1763,13 @@ static void unicam_stop_streaming(struct vb2_queue *vq)

unicam_disable(dev);

ret = clk_set_min_rate(dev->vpu_clock, 0);
if (ret)
unicam_err(dev, "failed to reset the min VPU clock\n");
if (dev->clocks_enabled) {
if (clk_set_min_rate(dev->vpu_clock, 0))
unicam_err(dev, "failed to reset the min VPU clock\n");

clk_disable_unprepare(dev->vpu_clock);
clk_disable_unprepare(dev->clock);
clk_disable_unprepare(dev->vpu_clock);
clk_disable_unprepare(dev->clock);
}
unicam_runtime_put(dev);

} else if (node->pad_id == METADATA_PAD) {
Expand Down