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

drm/vc4: Remove request for min clocks when hdmi output is disabled #6416

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

popcornmix
Copy link
Collaborator

Currently, booting with no hdmi connected has:
pi@pi4:~ $ vcgencmd measure_clock hdmi pixel
frequency(9)=120010256
frequency(29)=74988280

After connecting hdmi we get:
pi@pi4:~ $ vcgencmd measure_clock hdmi pixel
frequency(9)=300005856
frequency(29)=149989744

and that persists after disconnecting hdmi

I can measure this on a power supply as [email protected] (52mW).

We should always remove clk_set_min_rate requests
when we no longer need them.

@6by9
Copy link
Contributor

6by9 commented Oct 14, 2024

We do call clk_disable_unprepare for pixel_bvb_clock in vc4_hdmi_encoder_post_crtc_powerdown, and for hsm_clock in vc4_hdmi_runtime_suspend.

I would have expected the clock framework to ignore any min clock request for a disabled consumer. That may be a false expectation, but feels worth checking out.
(I have a slight niggle in my mind that setting up clocks typically sets the rate and then prepares/enables the clock, but that the caller often wants to validate the new rate before enabling. That can't happen if a disabled clock is ignored)

@popcornmix
Copy link
Collaborator Author

I put some logging in, and I don't believe vc4_hdmi_encoder_post_crtc_powerdown is called when unplugging.
I only saw the log for vc4_hdmi_encoder_post_crtc_disable.

@popcornmix
Copy link
Collaborator Author

I put some logging in, and I don't believe vc4_hdmi_encoder_post_crtc_powerdown is called when unplugging. I only saw the log for vc4_hdmi_encoder_post_crtc_disable.

Ah - printk without a \n means I was seeing the first message (disable) but not the second (powerdown).

Calling clk_set_min_rate with 0 just before the corresponding clk_disable_unprepare in powerdown also works.
Removing the clk_set_min_rate calls does not lower the clocks.

So, clk_disable_unprepare doesn't implicitly remove the min rate request.

@popcornmix
Copy link
Collaborator Author

@mripard is it required for clients to call clk_set_min_rate(clk, 0) before calling clk_disable_unprepare() or should the clock framework do that itself?

@mripard
Copy link
Contributor

mripard commented Oct 15, 2024

Yeah, there's no link between a rate boundary and a whether the clock is enabled or not. Both can happen independently. So you need to explicitly call clk_set_min_rate here indeed.

@popcornmix
Copy link
Collaborator Author

popcornmix commented Oct 15, 2024

It looks like vc4_hvs and vc4_v3d also have clocks that are left with uncleared min clock requests, so added those.

rpivid_video, bcm2835-unicam also use clk_set_min_rate, but appear to cleat the request correctly anyway.

(make this draft until I've done more testing on additional changes)

@6by9
Copy link
Contributor

6by9 commented Oct 15, 2024

Typo in the comments of we not longer have a requirement, but otherwise looks good to me.

@popcornmix popcornmix marked this pull request as ready for review October 15, 2024 16:09
@popcornmix
Copy link
Collaborator Author

Updated comments, and tested on Pi3, Pi4 and Pi5 (with a range of hdmi hotplug/removes and v3d use).

clk_disable_unprepare(vc4_hdmi->pixel_bvb_clock);
clk_set_min_rate(vc4_hdmi->hsm_clock, 0);
Copy link
Contributor

@pelwell pelwell Oct 15, 2024

Choose a reason for hiding this comment

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

Can you explain why the pairing of this line with the following line (which reference hsm_clock and pixel_clock) doesn't match other clk_set_min_rate and clk_disable_unprepare pairs - or at least say that it is expected and correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point. vc4_hdmi->hsm_clock and vc4_hdmi->pixel_bvb_clock are the clocks that previously were used with clk_set_min_rate, so the lines added are as intended.

But, when I moved them from disable to destroy I assumed they lined up with the clocks being disabled, but as you say that is not quite matching. Let me have a closer look.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks - I can believe that does what you want.

Currently, booting with no hdmi connected has:
pi@pi4:~ $ vcgencmd measure_clock hdmi pixel
frequency(9)=120010256
frequency(29)=74988280

After connecting hdmi we get:
pi@pi4:~ $ vcgencmd measure_clock hdmi pixel
frequency(9)=300005856
frequency(29)=149989744

and that persists after disconnecting hdmi

I can measure this on a power supply as [email protected] (52mW).

We should always remove clk_set_min_rate requests
when we no longer need them.

Signed-off-by: Dom Cobley <[email protected]>
@popcornmix
Copy link
Collaborator Author

I've moved the clearing of hsm_clock to vc4_hdmi_runtime_suspend where its clock was unprepared.
Still seems to work the same.

@pelwell pelwell merged commit 18d1851 into raspberrypi:rpi-6.6.y Oct 15, 2024
12 checks passed
@popcornmix popcornmix deleted the no_min_clks branch October 15, 2024 19:00
popcornmix added a commit to raspberrypi/firmware that referenced this pull request Oct 16, 2024
See: raspberrypi/linux#6412

kernel: dtoverlays: Fix up imx500 overlays to have unique clock nodes
See: raspberrypi/linux#6415

kernel: configs: Enable HOTPLUG_CPU
See: raspberrypi/linux#6409

kernel: dtoverlays: Add an overlay for Waveshare's 800x480 4.3" DSI screen
See: raspberrypi/linux#6417

kernel: drm/vc4: Remove request for min clocks when hdmi output is disabled
See: raspberrypi/linux#6416
popcornmix added a commit to raspberrypi/rpi-firmware that referenced this pull request Oct 16, 2024
See: raspberrypi/linux#6412

kernel: dtoverlays: Fix up imx500 overlays to have unique clock nodes
See: raspberrypi/linux#6415

kernel: configs: Enable HOTPLUG_CPU
See: raspberrypi/linux#6409

kernel: dtoverlays: Add an overlay for Waveshare's 800x480 4.3" DSI screen
See: raspberrypi/linux#6417

kernel: drm/vc4: Remove request for min clocks when hdmi output is disabled
See: raspberrypi/linux#6416
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants