Lin Huang posted comments on CHROMIUM: drm/rockchip: Toggle devfreq on/off.
Patch Set 27: (1 comment)
File drivers/gpu/drm/rockchip/rockchip_drm_fb.c:
Patch Set #27, Line 271: rockchip_drm_disable_dmc(priv);
i cherry-pick this patch, and found even i connect a dp monitor, the num_active_crtcs still 1, so use this flow, can not check wether we connect two monitor or not.
To view, visit this change. To unsubscribe, visit settings.
智情 姚 posted comments on CHROMIUM: drm/rockchip: Toggle devfreq on/off.
Patch Set 27: (1 comment)
File drivers/gpu/drm/rockchip/rockchip_drm_fb.c:
for_each_crtc_in_state(state, crtc, crtc_state, i) { if (crtc_state->active) num_active_crtcs++; if (crtc_state->active_changed) active_changed = true; }
if only one crtc status change, use for_each_crtc_in_state only can found one crtc state. rockchip_atomic_commit_complete is after drm_atomic_helper_swap_state, so crtc->state is new state. So I think we can change like that: drm_for_each_crtc(crtc,dev) { if (crtc->state->active) num_active_crtcs++; if (crtc->state->active_changed) active_changed = true; }
Stéphane Marchesin posted comments on CHROMIUM: drm/rockchip: Toggle devfreq on/off.
Patch Set 27: (1 comment)
File drivers/gpu/drm/rockchip/rockchip_drm_fb.c:
same comment as before you should inline this to make locking simpler to understand.
Lin Huang posted comments on CHROMIUM: drm/rockchip: Toggle devfreq on/off.
Patch Set 27: (1 comment)
for_each_crtc_in_state(state, crtc, crtc_state, i) { if (crtc_state->active) num_active_crtcs++; if (crtc_state->active_changed) active_changed = true; }
if only one crtc status change, use for_each_crtc_in_state only can found o
maybe we should use: drm_for_each_crtc(crtc,dev) { if (crtc->state->active) num_active_crtcs++; if (crtc->state->active_changed) active_changed = true; }
Lin Huang uploaded patch set #28 to CHROMIUM: drm/rockchip: Toggle devfreq on/off.
CHROMIUM: drm/rockchip: Toggle devfreq on/off This patch adds devfreq to the rockchip drm driver. It will activate when there is one crtc active, and disable if more than one becomes active (to avoid flickering on one of the screens). BUG=chrome-os-partner:54651 TEST=kevin compiles/boots Signed-off-by: Sean Paul <sean...@chromium.org> Change-Id: I690ae1c0d2436b957fc823585c1a32b48cfcf3fd --- M drivers/gpu/drm/rockchip/rockchip_drm_drv.c M drivers/gpu/drm/rockchip/rockchip_drm_drv.h M drivers/gpu/drm/rockchip/rockchip_drm_fb.c 3 files changed, 138 insertions(+), 0 deletions(-)
To view, visit this change. To unsubscribe, visit settings.
Stéphane Marchesin posted comments on CHROMIUM: drm/rockchip: Toggle devfreq on/off.
Patch Set 28: Code-Review-2 instead of repeating my comment I'm going to mark -2...
To view, visit this change. To unsubscribe, visit settings.
Lin Huang uploaded patch set #29 to CHROMIUM: drm/rockchip: Toggle devfreq on/off.
CHROMIUM: drm/rockchip: Toggle devfreq on/off This patch adds devfreq to the rockchip drm driver. It will activate when there is one crtc active, and disable if more than one becomes active (to avoid flickering on one of the screens). BUG=chrome-os-partner:54651 TEST=kevin compiles/boots Change-Id: I690ae1c0d2436b957fc823585c1a32b48cfcf3fd Signed-off-by: Sean Paul <sean...@chromium.org> Signed-off-by: Lin Huang <h...@rock-chips.com> --- M drivers/gpu/drm/rockchip/rockchip_drm_drv.c M drivers/gpu/drm/rockchip/rockchip_drm_drv.h M drivers/gpu/drm/rockchip/rockchip_drm_fb.c 3 files changed, 142 insertions(+), 0 deletions(-)
To view, visit this change. To unsubscribe, visit settings.
Lin Huang posted comments on CHROMIUM: drm/rockchip: Toggle devfreq on/off.
Patch Set 27: (1 comment)
same comment as before you should inline this to make locking simpler to un
sorry miss your comment before, in your before comment, you said "why not simply put all this in the caller?", i am sorry not got what you mean, can you explain in detail?
To view, visit this change. To unsubscribe, visit settings.
Derek Basehore posted comments on CHROMIUM: drm/rockchip: Toggle devfreq on/off.
File drivers/gpu/drm/rockchip/rockchip_drm_fb.c:
Patch Set #25, Line 239: mutex_lock(&priv->dmc_mutex);
why not simply put all this in the caller? It would be simpler than having
Sean wrote this code, but it seems we need to hold the mutex while checking the condition !priv->dmc_in_progress. wait_event just requires this as a wrapper so it will lock the mutex whenever it checks the condition.
To view, visit this change. To unsubscribe, visit settings.
Stéphane Marchesin posted comments on CHROMIUM: drm/rockchip: Toggle devfreq on/off.
sorry miss your comment before,
Put all this code in the only caller. That way, the locking/unlocking happens in the same function which is much easier to read/understand.
To view, visit this change. To unsubscribe, visit settings.
Lin Huang posted comments on CHROMIUM: drm/rockchip: Toggle devfreq on/off.
Put all this code in the only caller. That way, the locking/unlocking happe
but the caller is a wait_event condition check, and we need to check the lock, it seem hard to put then into the caller.
Derek Basehore posted comments on CHROMIUM: drm/rockchip: Toggle devfreq on/off.
but the caller is a wait_event condition check, and we need to check the lo
You can technically do this with a code block, but that's a non-standard C extension. The other option is to rewrite the code to something like it was in the earlier versions.
Lin Huang posted comments on CHROMIUM: drm/rockchip: Toggle devfreq on/off.
You can technically do this with a code block, but that's a non-standard C
it very early versions, and Sean have refactor it, it hard to go back now.
Derek Basehore posted comments on CHROMIUM: drm/rockchip: Toggle devfreq on/off.
You can technically do this with a code block, but that's a non-standard C
I think we could just switch to a mutex/semaphore by itself.
Derek Basehore uploaded patch set #31 to this change.
CHROMIUM: drm/rockchip: Toggle devfreq on/off This patch adds devfreq to the rockchip drm driver. It will activate when there is one crtc active, and disable if more than one becomes active (to avoid flickering on one of the screens). BUG=chrome-os-partner:54651 TEST=kevin compiles/boots Change-Id: I690ae1c0d2436b957fc823585c1a32b48cfcf3fd Signed-off-by: Sean Paul <sean...@chromium.org> Signed-off-by: Lin Huang <h...@rock-chips.com
> --- M drivers/gpu/drm/rockchip/rockchip_drm_drv.c M drivers/gpu/drm/rockchip/rockchip_drm_drv.h M drivers/gpu/drm/rockchip/rockchip_drm_fb.c 3 files changed, 117 insertions(+), 0 deletions(-)
To view, visit this change. To unsubscribe, visit settings.
Derek Basehore posted comments on this change.
I think we could just switch to a mutex/semaphore by itself.
Okay, I did what I suggested. This might cause a race condition later on, but that will have to be fixed separately. See other comment about race condition.
File drivers/gpu/drm/rockchip/rockchip_drm_fb.c:
Patch Set #31, Line 298: priv->dmc_disable_flag = true;
I'm not sure if these have race conditions. Is this function protected by a mutex (or something) that will prevent multiple threads from accessing these values?
To view, visit this change. To unsubscribe, visit settings.
Lin Huang posted comments on this change.
Patch Set #31, Line 298: priv->dmc_disable_flag = true;
I'm not sure if these have race conditions. Is this function protected by a
i think this function will protect by the commit->lock
Lin Huang uploaded patch set #33 to this change.
CHROMIUM: drm/rockchip: Toggle devfreq on/off This patch adds devfreq to the rockchip drm driver. It will activate when there is one crtc active, and disable if more than one becomes active (to avoid flickering on one of the screens). BUG=chrome-os-partner:54651 TEST=kevin compiles/boots Change-Id: I690ae1c0d2436b957fc823585c1a32b48cfcf3fd Signed-off-by: Sean Paul <sean...@chromium.org> Signed-off-by: Lin Huang <h...@rock-chips.com> --- M drivers/gpu/drm/rockchip/rockchip_drm_drv.c M drivers/gpu/drm/rockchip/rockchip_drm_drv.h M drivers/gpu/drm/rockchip/rockchip_drm_fb.c 3 files changed, 117 insertions(+), 0 deletions(-)
To view, visit this change. To unsubscribe, visit settings.
Derek Basehore posted comments on this change.
Patch Set #31, Line 298: priv->dmc_disable_flag = true;
i think this function will protect by the commit->lock
Is that lock shared by all of the displays? Also, is priv shared by all of the displays?
To view, visit this change. To unsubscribe, visit settings.
Stéphane Marchesin posted comments on this change.
File drivers/gpu/drm/rockchip/rockchip_drm_fb.c:
Patch Set #33, Line 295: priv->dmc_disable_flag = false;
if we have only one display but that's an external (say hdmi) display, should we enable dmc? I thought we didn't necessarily have the time to do reclocking during the vblanks then.
To view, visit this change. To unsubscribe, visit settings.
Lin Huang posted comments on this change.
Patch Set #31, Line 298: priv->dmc_disable_flag = true;
Is that lock shared by all of the displays? Also, is priv shared by all of
i think so.
File drivers/gpu/drm/rockchip/rockchip_drm_fb.c:
Patch Set #33, Line 295: priv->dmc_disable_flag = false;
if we have only one display but that's an external (say hdmi) display, shou
we need to enable dmc when we have one display(even it is external), the enable/disable dmc only happen the display 2->1 or 1->2.
To view, visit this change. To unsubscribe, visit settings.
Derek Basehore posted comments on this change.
Patch Set #33, Line 295: priv->dmc_disable_flag = false;
if we have only one display but that's an external (say hdmi) display, shou
We should check the vblank time against a set value. 300us is a large enough limit with plenty of room. It takes around 200us to change the rate. It doesn't have much variance either.
To view, visit this change. To unsubscribe, visit settings.
Lin Huang posted comments on this change.
Patch Set #33, Line 295: priv->dmc_disable_flag = false;
We should check the vblank time against a set value. 300us is a large enoug
i have measure the change rate time(use gpio), and we only care the time between idele_port and deidle_port(the flow in the M0 code), since when in this time we can not access the ddr, it take 90us now.
To view, visit this change. To unsubscribe, visit settings.
Derek Basehore posted comments on this change.
We can probably get rid of the mutex altogether and just rely on the devfreq function calls to act as synchronization barriers.
Patch Set #33, Line 295: priv->dmc_disable_flag = false;
i have measure the change rate time(use gpio), and we only care the time be
Stephane, are there any displays that would have trouble with that?
To view, visit this change. To unsubscribe, visit settings.
Stéphane Marchesin posted comments on this change.
Patch Set #33, Line 295: priv->dmc_disable_flag = false;
Stephane, are there any displays that would have trouble with that?
display timings are flexible, so you cannot guarantee anything (the display brings its own timing through EDID). So you have to compare the display timing to the timing you need to figure out it if will fit.
To view, visit this change. To unsubscribe, visit settings.
Derek Basehore posted comments on this change.
Patch Set #33, Line 295: priv->dmc_disable_flag = false;
display timings are flexible, so you cannot guarantee anything (the display
Yes, I think we just need to calculate the vblank time in crtc_enable in rockchip_drm_vop.c. That seems to have all of the information needed to calculate vblank time.
To view, visit this change. To unsubscribe, visit settings.
Patch Set #33, Line 295: priv->dmc_disable_flag = false;
Yes, I think we just need to calculate the vblank time in crtc_enable in ro
Okay, I think that everything is addressed in the latest patch.
To view, visit this change. To unsubscribe, visit settings.
Derek Basehore uploaded patch set #34 to this change.
CHROMIUM: drm/rockchip: Toggle devfreq on/off This patch adds devfreq to the rockchip drm driver. It will activate when there is one crtc active, and disable if more than one becomes active (to avoid flickering on one of the screens). BUG=chrome-os-partner:54651 TEST=kevin compiles/boots Change-Id: I690ae1c0d2436b957fc823585c1a32b48cfcf3fd Signed-off-by: Sean Paul <sean...@chromium.org> Signed-off-by: Lin Huang <h...@rock-chips.com
> --- M drivers/gpu/drm/rockchip/rockchip_drm_drv.c M drivers/gpu/drm/rockchip/rockchip_drm_drv.h M drivers/gpu/drm/rockchip/rockchip_drm_fb.c 3 files changed, 136 insertions(+), 0 deletions(-)
To view, visit this change. To unsubscribe, visit settings.
Derek Basehore uploaded patch set #35 to this change.
CHROMIUM: drm/rockchip: Toggle devfreq on/off This patch adds devfreq to the rockchip drm driver. It will activate when there is one crtc active, and disable if more than one becomes active (to avoid flickering on one of the screens). BUG=chrome-os-partner:54651 TEST=kevin compiles/boots Change-Id: I690ae1c0d2436b957fc823585c1a32b48cfcf3fd Signed-off-by: Sean Paul <sean...@chromium.org> Signed-off-by: Lin Huang <h...@rock-chips.com
> --- M drivers/gpu/drm/rockchip/rockchip_drm_drv.c M drivers/gpu/drm/rockchip/rockchip_drm_drv.h M drivers/gpu/drm/rockchip/rockchip_drm_fb.c M include/soc/rockchip/rk3399_dmc.h 4 files changed, 137 insertions(+), 0 deletions(-)
To view, visit this change. To unsubscribe, visit settings.
Derek Basehore uploaded patch set #36 to this change.
CHROMIUM: drm/rockchip: Toggle devfreq on/off This patch adds devfreq to the rockchip drm driver. It will activate when there is one crtc active, and disable if more than one becomes active (to avoid flickering on one of the screens). BUG=chrome-os-partner:54651 TEST=kevin compiles/boots Change-Id: I690ae1c0d2436b957fc823585c1a32b48cfcf3fd Signed-off-by: Sean Paul <sean...@chromium.org> Signed-off-by: Lin Huang <h...@rock-chips.com
> --- M drivers/gpu/drm/rockchip/rockchip_drm_drv.c M drivers/gpu/drm/rockchip/rockchip_drm_drv.h M drivers/gpu/drm/rockchip/rockchip_drm_fb.c M include/soc/rockchip/rk3399_dmc.h 4 files changed, 140 insertions(+), 0 deletions(-)
To view, visit this change. To unsubscribe, visit settings.
Stéphane Marchesin posted comments on this change.
Patch Set 36:
(2 comments)
File drivers/gpu/drm/rockchip/rockchip_drm_fb.c:
Patch Set #36, Line 258: drm_for_each_crtc(crtc, dev) {
if you're operating on crtcs, you need to own modeset locks I think
Patch Set #36, Line 281: mutex_lock(&priv->dmc_mutex);
why do you lock this mutex even for cases where you don't need it (for example if the vblank is too short)?
To view, visit this change. To unsubscribe, visit settings.
Derek Basehore posted comments on this change.
Patch Set #36, Line 258: drm_for_each_crtc(crtc, dev) {
if you're operating on crtcs, you need to own modeset locks I think
Okay, I'll fix this tomorrow. I'll be locking the drm_crtc:mutex (which is a struct drm_modeset_lock). If that's the wrong lock, please say so.
Patch Set #36, Line 281: mutex_lock(&priv->dmc_mutex);
why do you lock this mutex even for cases where you don't need it (for exam
We might not need to lock the mutex at all, either. I need to think about it. Disabling dmc should force us into the suspend frequency (the higher frequency). At this point, it's either fine for the dmc to change frequency, or we won't be changing frequency at all until another display state change happens.
To view, visit this change. To unsubscribe, visit settings.
(1 comment)
Patch Set #36, Line 258: drm_for_each_crtc(crtc, dev) {
Okay, I'll fix this tomorrow. I'll be locking the drm_crtc:mutex (which is
If I hold all of the modeset locks via drm_modeset_lock_all, it seems to deadlock reliably on boot. I'm not sure, but is there an existing order between those locks and the commit lock which is held when this function is called?
To view, visit this change. To unsubscribe, visit settings.
File drivers/gpu/drm/rockchip/rockchip_drm_fb.c:
Patch Set #36, Line 281: mutex_lock(&priv->dmc_mutex);
We might not need to lock the mutex at all, either. I need to think about i
Done
To view, visit this change. To unsubscribe, visit settings.
Derek Basehore uploaded patch set #37 to this change.
CHROMIUM: drm/rockchip: Toggle devfreq on/off This patch adds devfreq to the rockchip drm driver. It will activate when there is one crtc active, and disable if more than one becomes active (to avoid flickering on one of the screens). BUG=chrome-os-partner:54651 TEST=kevin compiles/boots Change-Id: I690ae1c0d2436b957fc823585c1a32b48cfcf3fd Signed-off-by: Sean Paul <sean...@chromium.org> Signed-off-by: Lin Huang <h...@rock-chips.com
> --- M drivers/gpu/drm/rockchip/rockchip_drm_drv.c M drivers/gpu/drm/rockchip/rockchip_drm_drv.h M drivers/gpu/drm/rockchip/rockchip_drm_fb.c M include/soc/rockchip/rk3399_dmc.h 4 files changed, 116 insertions(+), 0 deletions(-)
To view, visit this change. To unsubscribe, visit settings.
File drivers/gpu/drm/rockchip/rockchip_drm_fb.c:
Patch Set #36, Line 258: drm_for_each_crtc(crtc, dev) {
If I hold all of the modeset locks via drm_modeset_lock_all, it seems to de
The drm_atomic_commit function make have the modeset locks acquired. We could make it such that the async functionality will have the modeset locks, though.
To view, visit this change. To unsubscribe, visit settings.
Patch Set #36, Line 258: drm_for_each_crtc(crtc, dev) {
The drm_atomic_commit function make have the modeset locks acquired. We cou
Are the crtcs going to be changed outside of this function?
To view, visit this change. To unsubscribe, visit settings.
Derek Basehore uploaded patch set #38 to this change.
CHROMIUM: drm/rockchip: Toggle devfreq on/off This patch adds devfreq to the rockchip drm driver. It will activate when there is one crtc active, and disable if more than one becomes active (to avoid flickering on one of the screens). BUG=chrome-os-partner:54651 TEST=kevin compiles/boots Change-Id: I690ae1c0d2436b957fc823585c1a32b48cfcf3fd Signed-off-by: Sean Paul <sean...@chromium.org> Signed-off-by: Lin Huang <h...@rock-chips.com
> Signed-off-by: Derek Basehore <dbas...@chromium.org> --- M drivers/gpu/drm/rockchip/rockchip_drm_drv.c M drivers/gpu/drm/rockchip/rockchip_drm_drv.h M drivers/gpu/drm/rockchip/rockchip_drm_fb.c M include/soc/rockchip/rk3399_dmc.h 4 files changed, 120 insertions(+), 0 deletions(-)
To view, visit this change. To unsubscribe, visit settings.
Derek Basehore posted comments on this change.
Patch Set 38:
(1 comment)
Patch Set #36, Line 258: drm_for_each_crtc(crtc, dev) {
Are the crtcs going to be changed outside of this function?
Done
To view, visit this change. To unsubscribe, visit settings.
Stéphane Marchesin posted comments on this change.
File drivers/gpu/drm/rockchip/rockchip_drm_fb.c:
what about the following scenario:
To view, visit this change. To unsubscribe, visit settings.
Derek Basehore posted comments on this change.
what about the following scenario:
I guess we should get rid of active_changed.
To view, visit this change. To unsubscribe, visit settings.
Stéphane Marchesin posted comments on this change.
I guess we should get rid of active_changed.
as long as you keep dmc out of the fast path (where there are no mode changes)
To view, visit this change. To unsubscribe, visit settings.
Derek Basehore uploaded patch set #39 to this change.
CHROMIUM: drm/rockchip: Toggle devfreq on/off This patch adds devfreq to the rockchip drm driver. It will activate when there is one crtc active, and disable if more than one becomes active (to avoid flickering on one of the screens). BUG=chrome-os-partner:54651 TEST=kevin compiles/boots Change-Id: I690ae1c0d2436b957fc823585c1a32b48cfcf3fd Signed-off-by: Sean Paul <sean...@chromium.org> Signed-off-by: Lin Huang <h...@rock-chips.com> Signed-off-by: Derek Basehore <dbas...@chromium.org
> --- M drivers/gpu/drm/rockchip/rockchip_drm_drv.c M drivers/gpu/drm/rockchip/rockchip_drm_drv.h M drivers/gpu/drm/rockchip/rockchip_drm_fb.c M include/soc/rockchip/rk3399_dmc.h 4 files changed, 104 insertions(+), 0 deletions(-)
To view, visit this change. To unsubscribe, visit settings.
Stéphane Marchesin posted comments on this change.
Patch Set 39: Code-Review+2
To view, visit this change. To unsubscribe, visit settings.
Derek Basehore uploaded patch set #40 to this change.
CHROMIUM: drm/rockchip: Toggle devfreq on/off This patch adds devfreq to the rockchip drm driver. It will activate when there is one crtc active, and disable if more than one becomes active (to avoid flickering on one of the screens). BUG=chrome-os-partner:54651 TEST=kevin compiles/boots Change-Id: I690ae1c0d2436b957fc823585c1a32b48cfcf3fd Signed-off-by: Sean Paul <sean...@chromium.org> Signed-off-by: Lin Huang <h...@rock-chips.com> Signed-off-by: Derek Basehore <dbas...@chromium.org> --- M drivers/gpu/drm/rockchip/rockchip_drm_drv.c M drivers/gpu/drm/rockchip/rockchip_drm_drv.h M drivers/gpu/drm/rockchip/rockchip_drm_fb.c M include/soc/rockchip/rk3399_dmc.h 4 files changed, 104 insertions(+), 0 deletions(-)
To view, visit this change. To unsubscribe, visit settings.
Derek Basehore posted comments on this change.
Patch Set 40: Verified+1 Code-Review+2 Commit-Queue+1 Trybot-Ready+1
Just differences from rebasing. Carrying forward the +2 from Stephane.
To view, visit this change. To unsubscribe, visit settings.
ChromeOS Commit Bot uploaded patch set #41 to this change.
CHROMIUM: drm/rockchip: Toggle devfreq on/off This patch adds devfreq to the rockchip drm driver. It will activate when there is one crtc active, and disable if more than one becomes active (to avoid flickering on one of the screens). BUG=chrome-os-partner:54651 TEST=kevin compiles/boots Change-Id: I690ae1c0d2436b957fc823585c1a32b48cfcf3fd Signed-off-by: Sean Paul <sean...@chromium.org> Signed-off-by: Lin Huang <h...@rock-chips.com> Signed-off-by: Derek Basehore <dbas...@chromium.org
> Reviewed-on: https://chromium-review.googlesource.com/362907
--- M drivers/gpu/drm/rockchip/rockchip_drm_drv.c M drivers/gpu/drm/rockchip/rockchip_drm_drv.h M drivers/gpu/drm/rockchip/rockchip_drm_fb.c M include/soc/rockchip/rk3399_dmc.h 4 files changed, 104 insertions(+), 0 deletions(-)
To view, visit this change. To unsubscribe, visit settings.
ChromeOS Commit Bot merged this change.
CHROMIUM: drm/rockchip: Toggle devfreq on/off This patch adds devfreq to the rockchip drm driver. It will activate when there is one crtc active, and disable if more than one becomes active (to avoid flickering on one of the screens). BUG=chrome-os-partner:54651 TEST=kevin compiles/boots Change-Id: I690ae1c0d2436b957fc823585c1a32b48cfcf3fd Signed-off-by: Sean Paul <sean...@chromium.org> Signed-off-by: Lin Huang <h...@rock-chips.com> Signed-off-by: Derek Basehore <dbas...@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/362907 --- M drivers/gpu/drm/rockchip/rockchip_drm_drv.c M drivers/gpu/drm/rockchip/rockchip_drm_drv.h M drivers/gpu/drm/rockchip/rockchip_drm_fb.c M include/soc/rockchip/rk3399_dmc.h 4 files changed, 104 insertions(+), 0 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c index 5ca782d..4d90111 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c @@ -17,6 +17,8 @@ #include <drm/drmP.h> #include <drm/drm_crtc_helper.h> #include <drm/drm_fb_helper.h> +#include <linux/devfreq.h> +#include <linux/devfreq-event.h> #include <linux/dma-mapping.h> #include <linux/dma-iommu.h> #include <linux/pm_runtime.h> @@ -74,6 +76,56 @@ return; iommu_detach_device(domain, dev); +} + +void rockchip_drm_enable_dmc(struct rockchip_drm_private *priv) +{ + if (priv->devfreq_event_dev) + devfreq_event_enable_edev(priv->devfreq_event_dev); + if (priv->devfreq) + devfreq_resume_device(priv->devfreq); +} +EXPORT_SYMBOL(rockchip_drm_enable_dmc); + +void rockchip_drm_disable_dmc(struct rockchip_drm_private *priv) +{ + if (priv->devfreq_event_dev) + devfreq_event_disable_edev(priv->devfreq_event_dev); + if (priv->devfreq) + devfreq_suspend_device(priv->devfreq); +} +EXPORT_SYMBOL(rockchip_drm_disable_dmc); + +static int rockchip_initialize_devfreq(struct device *dev, + struct rockchip_drm_private *priv) +{ + struct devfreq *devfreq; + struct devfreq_event_dev *edev; + int ret; + + devfreq = devfreq_get_devfreq_by_phandle(dev, 0); + if (IS_ERR(devfreq)) { + ret = PTR_ERR(devfreq); + if (ret == -ENODEV) { + DRM_DEV_INFO(dev, "devfreq missing, skip\n"); + return 0; + } + return ret; + } + + edev = devfreq_event_get_edev_by_phandle(devfreq->dev.parent, 0); + if (IS_ERR(edev)) { + ret = PTR_ERR(edev); + if (ret == -ENODEV) { + DRM_DEV_INFO(dev, "devfreq edev missing, skip\n"); + return 0; + } + return ret; + } + + priv->devfreq = devfreq; + priv->devfreq_event_dev = edev; + return 0; } int rockchip_register_crtc_funcs(struct drm_crtc *crtc, @@ -200,6 +252,10 @@ if (!private) return -ENOMEM; + ret = rockchip_initialize_devfreq(dev, private); + if (ret) + return ret; + ret = rockchip_initialize_kthread(&private->commit); if (ret) goto err_config_cleanup; diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h index a88fe8a..ba0ff0c 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h @@ -85,6 +85,9 @@ struct list_head psr_list; struct mutex psr_list_lock; + struct devfreq *devfreq; + struct devfreq_event_dev *devfreq_event_dev; + bool dmc_disable_flag; struct drm_atomic_state *state; }; @@ -99,4 +102,7 @@ int rockchip_drm_wait_line_flag(struct drm_crtc *crtc, unsigned int line_num, unsigned int mstimeout); +void rockchip_drm_enable_dmc(struct rockchip_drm_private *priv); +void rockchip_drm_disable_dmc(struct rockchip_drm_private *priv); + #endif /* _ROCKCHIP_DRM_DRV_H_ */ diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c index 1fecaa3..0b3febe 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c @@ -19,6 +19,7 @@ #include <drm/drm_atomic.h> #include <drm/drm_fb_helper.h> #include <drm/drm_crtc_helper.h> +#include <soc/rockchip/rk3399_dmc.h> #include "rockchip_drm_drv.h" #include "rockchip_drm_gem.h" @@ -233,13 +234,43 @@ } } +static uint32_t get_vblank_time_us(struct drm_display_mode *mode) +{ + uint64_t vblank_time = mode->vtotal - mode->vdisplay; + + vblank_time *= (uint64_t)USEC_PER_SEC * mode->htotal; + do_div(vblank_time, mode->clock * 1000); + + return vblank_time; +} + static void rockchip_atomic_commit_complete(struct rockchip_atomic_commit *commit) { struct drm_atomic_state *state = commit->state; struct drm_device *dev = commit->dev; + struct rockchip_drm_private *priv = dev->dev_private; + struct drm_crtc *crtc; + int num_active_crtcs = 0; + bool force_dmc_off = false; + + drm_for_each_crtc(crtc, dev) { + if (crtc->state->active) { + num_active_crtcs++; + if (get_vblank_time_us(&crtc->state->adjusted_mode) < + ROCKCHIP_DMC_MIN_VBLANK_US) + force_dmc_off = true; + } + } wait_for_fences(dev, state); + + /* If disabling dmc, disable it before committing mode set changes. */ + if ((force_dmc_off || num_active_crtcs > 1) && + !priv->dmc_disable_flag) { + rockchip_drm_disable_dmc(priv); + priv->dmc_disable_flag = true; + } /* * Rockchip crtc support runtime PM, can't update display planes @@ -271,6 +302,11 @@ drm_atomic_helper_cleanup_planes(dev, state); + if (!force_dmc_off && num_active_crtcs <= 1 && priv->dmc_disable_flag) { + rockchip_drm_enable_dmc(priv); + priv->dmc_disable_flag = false; + } + drm_atomic_state_free(state); } @@ -279,7 +315,11 @@ struct rockchip_atomic_commit *commit = container_of(work, struct rockchip_atomic_commit, work); + drm_modeset_lock_all(commit->dev); + mutex_lock(&commit->lock); rockchip_atomic_commit_complete(commit); + mutex_unlock(&commit->lock); + drm_modeset_unlock_all(commit->dev); } int rockchip_drm_atomic_commit(struct drm_device *dev, diff --git a/include/soc/rockchip/rk3399_dmc.h b/include/soc/rockchip/rk3399_dmc.h index f0b6b41..4c0574f 100644 --- a/include/soc/rockchip/rk3399_dmc.h +++ b/include/soc/rockchip/rk3399_dmc.h @@ -17,6 +17,8 @@ #include <linux/devfreq.h> +#define ROCKCHIP_DMC_MIN_VBLANK_US 300 + struct rk3399_dmcfreq { struct device *dev; struct devfreq *devfreq;
To view, visit this change. To unsubscribe, visit settings.