drm/tidss: dispc: Rewrite naive plane positioning code
Subsystems (3)
PATCH v2 1/1 drm/tidss: dispc: Rewrite naive plane positioning code
The old implementation of placing planes on the CRTC while configuring the planes was naive and relied on the order in which the planes were configured, enabled, and disabled. The situation where a plane's zpos was changed on the fly was completely broken. The usual symptoms of this problem was scrambled display and a flood of sync lost errors, when a plane was active in two layers at the same time, or a missing plane, in case when a layer was accidentally disabled.
The rewrite takes a more straight forward approach when HW is concerned. The plane positioning registers are in the CRTC (actually OVR) register space and it is more natural to configure them in one go while configuring the CRTC. To do this we need to make sure we have all the planes on updated CRTCs in the new atomic state to be committed. This is done by calling drm_atomic_add_affected_planes() in crtc_atomic_check().
--- drivers/gpu/drm/tidss/tidss_crtc.c | 55 ++++++++++++++++++++++++++++- drivers/gpu/drm/tidss/tidss_dispc.c | 55 +++++++++++------------------ drivers/gpu/drm/tidss/tidss_dispc.h | 5 +++ 3 files changed, 79 insertions(+), 36 deletions(-)
drivers/gpu/drm/tidss/tidss_crtc.c +54 -1
@@ -17,6 +17,7 @@#include "tidss_dispc.h" #include "tidss_drv.h" #include "tidss_irq.h" +#include "tidss_plane.h" /* Page flip and frame done IRQs */
@@ -93,6 +94,7 @@ static int tidss_crtc_atomic_check(struct drm_crtc *crtc,u32 hw_videoport = tcrtc->hw_videoport;const struct drm_display_mode *mode;enum drm_mode_status ok; +int ret;dev_dbg (ddev->dev,"%s\n" , __func__);
@@ -108,7 +110,54 @@ static int tidss_crtc_atomic_check(struct drm_crtc *crtc,return -EINVAL ; } -return dispc_vp_bus_check (dispc, hw_videoport, state); + ret =dispc_vp_bus_check (dispc, hw_videoport, state); +if (ret) +return ret; + +/* Add unchanged planes on this crtc to state for zpos update. */ +return drm_atomic_add_affected_planes (state->state, crtc); +} + +static void tidss_crtc_position_planes (struct tidss_device *tidss, +struct drm_crtc *crtc, +struct drm_crtc_state *old_state, +bool newmodeset) +{ +struct drm_atomic_state *ostate = old_state->state; +struct tidss_crtc *tcrtc =to_tidss_crtc (crtc); +struct drm_crtc_state *cstate = crtc->state; +int zpos; + +if (!newmodeset && !cstate->zpos_changed && !cstate->planes_changed) +return ; + +for (zpos =0 ; zpos < tidss->feat->num_planes; zpos++) { +struct drm_plane_state *pstate; +struct drm_plane *plane; +bool zpos_taken = false; +int i; + +for_each_new_plane_in_state (ostate, plane, pstate, i) { +if (pstate->crtc != crtc || !pstate->visible) +continue ; + +if (pstate->normalized_zpos == zpos) { + zpos_taken = true; +break ; + } + } + +if (zpos_taken) { +struct tidss_plane *tplane =to_tidss_plane (plane); + +dispc_ovr_set_plane (tidss->dispc, tplane->hw_plane_id, + tcrtc->hw_videoport, + pstate->crtc_x, pstate->crtc_y, + zpos); + } +dispc_ovr_enable_layer (tidss->dispc, tcrtc->hw_videoport, zpos, + zpos_taken); + } } static void tidss_crtc_atomic_flush(struct drm_crtc *crtc,
@@ -146,6 +195,9 @@ static void tidss_crtc_atomic_flush(struct drm_crtc *crtc,/* Write vp properties to HW if needed. */ dispc_vp_setup (tidss->dispc, tcrtc->hw_videoport, crtc->state, false); +/* Update plane positions if needed. */ +tidss_crtc_position_planes (tidss, crtc, old_crtc_state, false); +WARN_ON (drm_crtc_vblank_get (crtc) !=0 );spin_lock_irqsave (&ddev->event_lock, flags);
@@ -183,6 +235,7 @@ static void tidss_crtc_atomic_enable(struct drm_crtc *crtc,return ;dispc_vp_setup (tidss->dispc, tcrtc->hw_videoport, crtc->state, true); +tidss_crtc_position_planes (tidss, crtc, old_state, true);/* Turn vertical blanking interrupt reporting on. */ drm_crtc_vblank_on (crtc);
drivers/gpu/drm/tidss/tidss_dispc.c +20 -35
121 lines not on this page · raw message
drivers/gpu/drm/tidss/tidss_dispc.h +5 -0
@@ -94,6 +94,11 @@ extern const struct dispc_features dispc_j721e_feats;void dispc_set_irqenable (struct dispc_device *dispc,dispc_irq_t mask);dispc_irq_t dispc_read_and_clear_irqstatus (struct dispc_device *dispc); +void dispc_ovr_set_plane (struct dispc_device *dispc,u32 hw_plane, +u32 hw_videoport,u32 x,u32 y,u32 layer); +void dispc_ovr_enable_layer (struct dispc_device *dispc, +u32 hw_videoport,u32 layer,bool enable); +void dispc_vp_prepare (struct dispc_device *dispc,u32 hw_videoport,const struct drm_crtc_state *state); void dispc_vp_enable(struct dispc_device *dispc, u32 hw_videoport,
Signature · 6 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 27 lines · Jyri Sarha
The old implementation of placing planes on the CRTC while configuring the planes was naive and relied on the order in which the planes were configured, enabled, and disabled. The situation where a plane's zpos was changed on the fly was completely broken. The usual symptoms of this problem was scrambled display and a flood of sync lost errors, when a plane was active in two layers at the same time, or a missing plane, in case when a layer was accidentally disabled.
The rewrite takes a more straight forward approach when HW is concerned. The plane positioning registers are in the CRTC (actually OVR) register space and it is more natural to configure them in one go while configuring the CRTC. To do this we need to make sure we have all the planes on updated CRTCs in the new atomic state to be committed. This is done by calling
drm_atomic_add_affected_planes()incrtc_atomic_check().Signed-off-by Jyri Sarha <[email protected]>--- drivers/gpu/drm/tidss/tidss_crtc.c | 55 ++++++++++++++++++++++++++++- drivers/gpu/drm/tidss/tidss_dispc.c | 55 +++++++++++------------------ drivers/gpu/drm/tidss/tidss_dispc.h | 5 +++ 3 files changed, 79 insertions(+), 36 deletions(-)drivers/gpu/drm/tidss/tidss_crtc.c +0
-0
...
drivers/gpu/drm/tidss/tidss_crtc.c static int tidss_crtc_atomic_check(struct drm_crtc *crtc, · line 118
Quoted 11 lines
drivers/gpu/drm/tidss/tidss_crtc.c +6
-1@@ -108,7 +110,54 @@ static int tidss_crtc_atomic_check(struct drm_crtc *crtc,return -EINVAL ; } -return dispc_vp_bus_check (dispc, hw_videoport, state); + ret =dispc_vp_bus_check (dispc, hw_videoport, state); +if (ret) +return ret; + +/* Add unchanged planes on this crtc to state for zpos update. */ +return drm_atomic_add_affected_planes (state->state, crtc);
Is this a correct way to use drm_atomic_add_affected_planes()?
I saw that some other drivers implement their own mode_config atomic_check() and have this call there in for_each_new_crtc_in_state()-loop, but I thought it should be fine to call it in crtc_atomic_check().
BR,
Jyri
Signature · 6 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 43 lines · Jyri Sarha
Quoted 27 lines · Jyri Sarha
The old implementation of placing planes on the CRTC while configuring the planes was naive and relied on the order in which the planes were configured, enabled, and disabled. The situation where a plane's zpos was changed on the fly was completely broken. The usual symptoms of this problem was scrambled display and a flood of sync lost errors, when a plane was active in two layers at the same time, or a missing plane, in case when a layer was accidentally disabled.
The rewrite takes a more straight forward approach when HW is concerned. The plane positioning registers are in the CRTC (actually OVR) register space and it is more natural to configure them in one go while configuring the CRTC. To do this we need to make sure we have all the planes on updated CRTCs in the new atomic state to be committed. This is done by calling
drm_atomic_add_affected_planes()incrtc_atomic_check().Signed-off-by Jyri Sarha <[email protected]>--- drivers/gpu/drm/tidss/tidss_crtc.c | 55 ++++++++++++++++++++++++++++- drivers/gpu/drm/tidss/tidss_dispc.c | 55 +++++++++++------------------ drivers/gpu/drm/tidss/tidss_dispc.h | 5 +++ 3 files changed, 79 insertions(+), 36 deletions(-)drivers/gpu/drm/tidss/tidss_crtc.c +0
-0...
drivers/gpu/drm/tidss/tidss_crtc.c static int tidss_crtc_atomic_check(struct drm_crtc *crtc, · line 118
Quoted 11 lines
drivers/gpu/drm/tidss/tidss_crtc.c +6
-1@@ -108,7 +110,54 @@ static int tidss_crtc_atomic_check(struct drm_crtc *crtc,return -EINVAL ; } -return dispc_vp_bus_check (dispc, hw_videoport, state); + ret =dispc_vp_bus_check (dispc, hw_videoport, state); +if (ret) +return ret; + +/* Add unchanged planes on this crtc to state for zpos update. */ +return drm_atomic_add_affected_planes (state->state, crtc);Is this a correct way to use
drm_atomic_add_affected_planes()?
Quoted 4 lines
I saw that some other drivers implement their own
mode_configatomic_check()and have this call there in for_each_new_crtc_in_state()-loop, but I thought it should be fine to call it incrtc_atomic_check().
You seem to be using drm_atomic_helper_check_planes(), which means crtc.atomic_check() gets called after plane.atomic_check(). So this might be good or bad depending on whether you'd like the planes you add here to go through their .atomic_check() or not.
Signature · 6 lines
Ville Syrjälä Intel _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 49 lines · Ville Syrjälä
Quoted 43 lines · Jyri Sarha
Quoted 27 lines · Jyri Sarha
The old implementation of placing planes on the CRTC while configuring the planes was naive and relied on the order in which the planes were configured, enabled, and disabled. The situation where a plane's zpos was changed on the fly was completely broken. The usual symptoms of this problem was scrambled display and a flood of sync lost errors, when a plane was active in two layers at the same time, or a missing plane, in case when a layer was accidentally disabled.
The rewrite takes a more straight forward approach when HW is concerned. The plane positioning registers are in the CRTC (actually OVR) register space and it is more natural to configure them in one go while configuring the CRTC. To do this we need to make sure we have all the planes on updated CRTCs in the new atomic state to be committed. This is done by calling
drm_atomic_add_affected_planes()incrtc_atomic_check().Signed-off-by Jyri Sarha <[email protected]>--- drivers/gpu/drm/tidss/tidss_crtc.c | 55 ++++++++++++++++++++++++++++- drivers/gpu/drm/tidss/tidss_dispc.c | 55 +++++++++++------------------ drivers/gpu/drm/tidss/tidss_dispc.h | 5 +++ 3 files changed, 79 insertions(+), 36 deletions(-)drivers/gpu/drm/tidss/tidss_crtc.c +0
-0...
drivers/gpu/drm/tidss/tidss_crtc.c static int tidss_crtc_atomic_check(struct drm_crtc *crtc, · line 118
Quoted 11 lines
drivers/gpu/drm/tidss/tidss_crtc.c +6
-1@@ -108,7 +110,54 @@ static int tidss_crtc_atomic_check(struct drm_crtc *crtc,return -EINVAL ; } -return dispc_vp_bus_check (dispc, hw_videoport, state); + ret =dispc_vp_bus_check (dispc, hw_videoport, state); +if (ret) +return ret; + +/* Add unchanged planes on this crtc to state for zpos update. */ +return drm_atomic_add_affected_planes (state->state, crtc);Is this a correct way to use
drm_atomic_add_affected_planes()?Quoted 4 lines
I saw that some other drivers implement their own
mode_configatomic_check()and have this call there in for_each_new_crtc_in_state()-loop, but I thought it should be fine to call it incrtc_atomic_check().
Quoted 5 lines
You seem to be using
drm_atomic_helper_check_planes(), which meanscrtc.atomic_check()gets called afterplane.atomic_check(). So this might be good or bad depending on whether you'd like the planes you add here to go through their .atomic_check() or not.
Should have thought of that my self. Extra plane.atomic_check() calls do not do any actual harm, but they are potentially expensive. The planes are really only needed there in the commit phase (crtc_enable() or flush()). Well, I'll do my own mode_config.atomic_check() and call drm_atomic_add_affected_planes() in a for_each_new_crtc_in_state()-loop after all the checks.
Thanks,
Jyri
Signature · 6 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 57 lines · Jyri Sarha
Quoted 49 lines · Ville Syrjälä
Quoted 43 lines · Jyri Sarha
Quoted 27 lines · Jyri Sarha
The old implementation of placing planes on the CRTC while configuring the planes was naive and relied on the order in which the planes were configured, enabled, and disabled. The situation where a plane's zpos was changed on the fly was completely broken. The usual symptoms of this problem was scrambled display and a flood of sync lost errors, when a plane was active in two layers at the same time, or a missing plane, in case when a layer was accidentally disabled.
The rewrite takes a more straight forward approach when HW is concerned. The plane positioning registers are in the CRTC (actually OVR) register space and it is more natural to configure them in one go while configuring the CRTC. To do this we need to make sure we have all the planes on updated CRTCs in the new atomic state to be committed. This is done by calling
drm_atomic_add_affected_planes()incrtc_atomic_check().Signed-off-by Jyri Sarha <[email protected]>--- drivers/gpu/drm/tidss/tidss_crtc.c | 55 ++++++++++++++++++++++++++++- drivers/gpu/drm/tidss/tidss_dispc.c | 55 +++++++++++------------------ drivers/gpu/drm/tidss/tidss_dispc.h | 5 +++ 3 files changed, 79 insertions(+), 36 deletions(-)drivers/gpu/drm/tidss/tidss_crtc.c +0
-0...
drivers/gpu/drm/tidss/tidss_crtc.c static int tidss_crtc_atomic_check(struct drm_crtc *crtc, · line 118
Quoted 11 lines
drivers/gpu/drm/tidss/tidss_crtc.c +6
-1@@ -108,7 +110,54 @@ static int tidss_crtc_atomic_check(struct drm_crtc *crtc,return -EINVAL ; } -return dispc_vp_bus_check (dispc, hw_videoport, state); + ret =dispc_vp_bus_check (dispc, hw_videoport, state); +if (ret) +return ret; + +/* Add unchanged planes on this crtc to state for zpos update. */ +return drm_atomic_add_affected_planes (state->state, crtc);Is this a correct way to use
drm_atomic_add_affected_planes()?Quoted 4 lines
I saw that some other drivers implement their own
mode_configatomic_check()and have this call there in for_each_new_crtc_in_state()-loop, but I thought it should be fine to call it incrtc_atomic_check().Quoted 5 lines
You seem to be using
drm_atomic_helper_check_planes(), which meanscrtc.atomic_check()gets called afterplane.atomic_check(). So this might be good or bad depending on whether you'd like the planes you add here to go through their .atomic_check() or not.
Quoted 6 lines
Should have thought of that my self. Extra
plane.atomic_check()calls do not do any actual harm, but they are potentially expensive. The planes are really only needed there in the commit phase (crtc_enable()orflush()). Well, I'll do my ownmode_config.atomic_check()and calldrm_atomic_add_affected_planes()in a for_each_new_crtc_in_state()-loop after all the checks.
Also, if you do use the helpers then this should already have happened for you. Which makes me wonder why all this work, so maybe there's some dependency between all the various check functions you have going on? Might be time to roll your own top-level check function that calls stuff in the order your hw needs things to be checked, so that you don't add new states late and have to run one check phase twice (which is totally fine with the helpers as long as all your check callbacks are idempotent, but often just overkill and confusing). -Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 70 lines · Daniel Vetter
Quoted 57 lines · Jyri Sarha
Quoted 49 lines · Ville Syrjälä
Quoted 43 lines · Jyri Sarha
Quoted 27 lines · Jyri Sarha
The old implementation of placing planes on the CRTC while configuring the planes was naive and relied on the order in which the planes were configured, enabled, and disabled. The situation where a plane's zpos was changed on the fly was completely broken. The usual symptoms of this problem was scrambled display and a flood of sync lost errors, when a plane was active in two layers at the same time, or a missing plane, in case when a layer was accidentally disabled.
The rewrite takes a more straight forward approach when HW is concerned. The plane positioning registers are in the CRTC (actually OVR) register space and it is more natural to configure them in one go while configuring the CRTC. To do this we need to make sure we have all the planes on updated CRTCs in the new atomic state to be committed. This is done by calling
drm_atomic_add_affected_planes()incrtc_atomic_check().Signed-off-by Jyri Sarha <[email protected]>--- drivers/gpu/drm/tidss/tidss_crtc.c | 55 ++++++++++++++++++++++++++++- drivers/gpu/drm/tidss/tidss_dispc.c | 55 +++++++++++------------------ drivers/gpu/drm/tidss/tidss_dispc.h | 5 +++ 3 files changed, 79 insertions(+), 36 deletions(-)drivers/gpu/drm/tidss/tidss_crtc.c +0
-0...
drivers/gpu/drm/tidss/tidss_crtc.c static int tidss_crtc_atomic_check(struct drm_crtc *crtc, · line 118
Quoted 11 lines
drivers/gpu/drm/tidss/tidss_crtc.c +6
-1@@ -108,7 +110,54 @@ static int tidss_crtc_atomic_check(struct drm_crtc *crtc,return -EINVAL ; } -return dispc_vp_bus_check (dispc, hw_videoport, state); + ret =dispc_vp_bus_check (dispc, hw_videoport, state); +if (ret) +return ret; + +/* Add unchanged planes on this crtc to state for zpos update. */ +return drm_atomic_add_affected_planes (state->state, crtc);Is this a correct way to use
drm_atomic_add_affected_planes()?Quoted 4 lines
I saw that some other drivers implement their own
mode_configatomic_check()and have this call there in for_each_new_crtc_in_state()-loop, but I thought it should be fine to call it incrtc_atomic_check().Quoted 5 lines
You seem to be using
drm_atomic_helper_check_planes(), which meanscrtc.atomic_check()gets called afterplane.atomic_check(). So this might be good or bad depending on whether you'd like the planes you add here to go through their .atomic_check() or not.Quoted 6 lines
Should have thought of that my self. Extra
plane.atomic_check()calls do not do any actual harm, but they are potentially expensive. The planes are really only needed there in the commit phase (crtc_enable()orflush()). Well, I'll do my ownmode_config.atomic_check()and calldrm_atomic_add_affected_planes()in a for_each_new_crtc_in_state()-loop after all the checks.Also, if you do use the helpers then this should already have happened for you. Which makes me wonder why all this work, so maybe there's some dependency between all the various check functions you have going on? Might be time to roll your own top-level check function that calls
Quoted 4 lines
stuff in the order your hw needs things to be checked, so that you don't add new states late and have to run one check phase twice (which is totally fine with the helpers as long as all your check callbacks are idempotent, but often just overkill and confusing).
All the driver specific checks are perfectly independent without any cross dependencies. And there is no extra data in the plane- or CRTC-state, nor do the driver specific checks touch the state in any way.
I only want all the planes on a crtc to be there, if any of the planes on the CRTC changes, so that I can write the plane positions from the scratch directly from the atomic state with each commit.
Long explanation (if you are interested):
With the DSS HW the planes are positioned to CRTCs by filling each plane's id and x,y position to correct overlay register according to the plane's zpos (each overlay reg has its own static zpos).
Using the naive implementation, there is a problem if I have plane0 at zpos0 and another commit comes with plane1 at zpos0 and plane0 disabled. If plane1 in the commit is handled first, it overwrites plane0's previous position, and plane0 handled afterwards will disable freshly configured plane1. There is number of other problematic cases.
Ok, I can easily fix this by storing the plane positions (x,y, and z) in the driver's internal state, and rolling the positions out in the crtc_enable() or -flush(). But I have understood the atomic drivers should avoid having any internal state. So the obvious choice would be to roll out the plane positions directly from the atomic state. However, there is a problem with that.
The problem appears when I have more than one plane active on a crtc and I just need to update one of the planes. In the situation nothing changes about the CRTC and the unchanged planes, so it is quite understandable that the helpers do not add the unchanged planes to the atomic state. But if I want to roll out the new plane positions from the scratch with every commit that touches any plane on that CRTC, I need to have the unchanged planes there.
So the drm_atomic_add_affected_planes()-calls are added just to avoid any internal plane position state in the driver.
Best regards,
Jyri
Signature · 6 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 77 lines · Jyri Sarha
Quoted 70 lines · Daniel Vetter
Quoted 57 lines · Jyri Sarha
Quoted 49 lines · Ville Syrjälä
Quoted 43 lines · Jyri Sarha
Quoted 27 lines · Jyri Sarha
The old implementation of placing planes on the CRTC while configuring the planes was naive and relied on the order in which the planes were configured, enabled, and disabled. The situation where a plane's zpos was changed on the fly was completely broken. The usual symptoms of this problem was scrambled display and a flood of sync lost errors, when a plane was active in two layers at the same time, or a missing plane, in case when a layer was accidentally disabled.
The rewrite takes a more straight forward approach when HW is concerned. The plane positioning registers are in the CRTC (actually OVR) register space and it is more natural to configure them in one go while configuring the CRTC. To do this we need to make sure we have all the planes on updated CRTCs in the new atomic state to be committed. This is done by calling
drm_atomic_add_affected_planes()incrtc_atomic_check().Signed-off-by Jyri Sarha <[email protected]>--- drivers/gpu/drm/tidss/tidss_crtc.c | 55 ++++++++++++++++++++++++++++- drivers/gpu/drm/tidss/tidss_dispc.c | 55 +++++++++++------------------ drivers/gpu/drm/tidss/tidss_dispc.h | 5 +++ 3 files changed, 79 insertions(+), 36 deletions(-)drivers/gpu/drm/tidss/tidss_crtc.c +0
-0...
drivers/gpu/drm/tidss/tidss_crtc.c static int tidss_crtc_atomic_check(struct drm_crtc *crtc, · line 118
Quoted 11 lines
drivers/gpu/drm/tidss/tidss_crtc.c +6
-1@@ -108,7 +110,54 @@ static int tidss_crtc_atomic_check(struct drm_crtc *crtc,return -EINVAL ; } -return dispc_vp_bus_check (dispc, hw_videoport, state); + ret =dispc_vp_bus_check (dispc, hw_videoport, state); +if (ret) +return ret; + +/* Add unchanged planes on this crtc to state for zpos update. */ +return drm_atomic_add_affected_planes (state->state, crtc);Is this a correct way to use
drm_atomic_add_affected_planes()?Quoted 4 lines
I saw that some other drivers implement their own
mode_configatomic_check()and have this call there in for_each_new_crtc_in_state()-loop, but I thought it should be fine to call it incrtc_atomic_check().Quoted 5 lines
You seem to be using
drm_atomic_helper_check_planes(), which meanscrtc.atomic_check()gets called afterplane.atomic_check(). So this might be good or bad depending on whether you'd like the planes you add here to go through their .atomic_check() or not.Quoted 6 lines
Should have thought of that my self. Extra
plane.atomic_check()calls do not do any actual harm, but they are potentially expensive. The planes are really only needed there in the commit phase (crtc_enable()orflush()). Well, I'll do my ownmode_config.atomic_check()and calldrm_atomic_add_affected_planes()in a for_each_new_crtc_in_state()-loop after all the checks.Also, if you do use the helpers then this should already have happened for you. Which makes me wonder why all this work, so maybe there's some dependency between all the various check functions you have going on? Might be time to roll your own top-level check function that calls
Quoted 4 lines
stuff in the order your hw needs things to be checked, so that you don't add new states late and have to run one check phase twice (which is totally fine with the helpers as long as all your check callbacks are idempotent, but often just overkill and confusing).
Quoted 7 lines
All the driver specific checks are perfectly independent without any cross dependencies. And there is no extra data in the plane- or CRTC-state, nor do the driver specific checks touch the state in any way.
I only want all the planes on a crtc to be there, if any of the planes on the CRTC changes, so that I can write the plane positions from the scratch directly from the atomic state with each commit.
You /should/ get this already with the atomic helpers, no further action needed. Does it not work?
Quoted 12 lines
Long explanation (if you are interested):
With the DSS HW the planes are positioned to CRTCs by filling each plane's id and x,y position to correct overlay register according to the plane's zpos (each overlay reg has its own static zpos).
Using the naive implementation, there is a problem if I have plane0 at zpos0 and another commit comes with plane1 at zpos0 and plane0 disabled. If plane1 in the commit is handled first, it overwrites plane0's previous position, and plane0 handled afterwards will disable freshly configured plane1. There is number of other problematic cases.
Quoted 6 lines
Ok, I can easily fix this by storing the plane positions (x,y, and z) in the driver's internal state, and rolling the positions out in the
crtc_enable()or -flush(). But I have understood the atomic drivers should avoid having any internal state. So the obvious choice would be to roll out the plane positions directly from the atomic state. However, there is a problem with that.
Hm I'm not entirely following the problem, but if you have some requirements around the order in which your planes need to be committed, then roll your own plane commit code. At least for the parts of the plane state which need to be committed like that. You can then stuff that into one of your crtc commit functions.
And I guess "commit planes in order of zpos" is probably fairly common driver requirement, we might want to have a shared iterator for that.
Aside: Driver private state is totally fine. Just needs to be attached to one of the drm_*_state objects (you can have private state objects too). What's not ok in atomic is stuffing that kind of data into your drm_crtc structure (or somewhere else like that), that's where the problems happen.
Quoted 10 lines
The problem appears when I have more than one plane active on a crtc and I just need to update one of the planes. In the situation nothing changes about the CRTC and the unchanged planes, so it is quite understandable that the helpers do not add the unchanged planes to the atomic state. But if I want to roll out the new plane positions from the scratch with every commit that touches any plane on that CRTC, I need to have the unchanged planes there.
So the drm_atomic_add_affected_planes()-calls are added just to avoid any internal plane position state in the driver.
Again, this should all happen already.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 114 lines · Daniel Vetter
Quoted 77 lines · Jyri Sarha
Quoted 70 lines · Daniel Vetter
Quoted 57 lines · Jyri Sarha
Quoted 49 lines · Ville Syrjälä
Quoted 43 lines · Jyri Sarha
Quoted 27 lines · Jyri Sarha
The old implementation of placing planes on the CRTC while configuring the planes was naive and relied on the order in which the planes were configured, enabled, and disabled. The situation where a plane's zpos was changed on the fly was completely broken. The usual symptoms of this problem was scrambled display and a flood of sync lost errors, when a plane was active in two layers at the same time, or a missing plane, in case when a layer was accidentally disabled.
The rewrite takes a more straight forward approach when HW is concerned. The plane positioning registers are in the CRTC (actually OVR) register space and it is more natural to configure them in one go while configuring the CRTC. To do this we need to make sure we have all the planes on updated CRTCs in the new atomic state to be committed. This is done by calling
drm_atomic_add_affected_planes()incrtc_atomic_check().Signed-off-by Jyri Sarha <[email protected]>--- drivers/gpu/drm/tidss/tidss_crtc.c | 55 ++++++++++++++++++++++++++++- drivers/gpu/drm/tidss/tidss_dispc.c | 55 +++++++++++------------------ drivers/gpu/drm/tidss/tidss_dispc.h | 5 +++ 3 files changed, 79 insertions(+), 36 deletions(-)drivers/gpu/drm/tidss/tidss_crtc.c +0
-0...
drivers/gpu/drm/tidss/tidss_crtc.c static int tidss_crtc_atomic_check(struct drm_crtc *crtc, · line 118
Quoted 11 lines
drivers/gpu/drm/tidss/tidss_crtc.c +6
-1@@ -108,7 +110,54 @@ static int tidss_crtc_atomic_check(struct drm_crtc *crtc,return -EINVAL ; } -return dispc_vp_bus_check (dispc, hw_videoport, state); + ret =dispc_vp_bus_check (dispc, hw_videoport, state); +if (ret) +return ret; + +/* Add unchanged planes on this crtc to state for zpos update. */ +return drm_atomic_add_affected_planes (state->state, crtc);Is this a correct way to use
drm_atomic_add_affected_planes()?Quoted 4 lines
I saw that some other drivers implement their own
mode_configatomic_check()and have this call there in for_each_new_crtc_in_state()-loop, but I thought it should be fine to call it incrtc_atomic_check().Quoted 5 lines
You seem to be using
drm_atomic_helper_check_planes(), which meanscrtc.atomic_check()gets called afterplane.atomic_check(). So this might be good or bad depending on whether you'd like the planes you add here to go through their .atomic_check() or not.Quoted 6 lines
Should have thought of that my self. Extra
plane.atomic_check()calls do not do any actual harm, but they are potentially expensive. The planes are really only needed there in the commit phase (crtc_enable()orflush()). Well, I'll do my ownmode_config.atomic_check()and calldrm_atomic_add_affected_planes()in a for_each_new_crtc_in_state()-loop after all the checks.Also, if you do use the helpers then this should already have happened for you. Which makes me wonder why all this work, so maybe there's some dependency between all the various check functions you have going on? Might be time to roll your own top-level check function that calls
Quoted 4 lines
stuff in the order your hw needs things to be checked, so that you don't add new states late and have to run one check phase twice (which is totally fine with the helpers as long as all your check callbacks are idempotent, but often just overkill and confusing).
Quoted 7 lines
All the driver specific checks are perfectly independent without any cross dependencies. And there is no extra data in the plane- or CRTC-state, nor do the driver specific checks touch the state in any way.
I only want all the planes on a crtc to be there, if any of the planes on the CRTC changes, so that I can write the plane positions from the scratch directly from the atomic state with each commit.
You /should/ get this already with the atomic helpers, no further action needed. Does it not work?
Quoted 12 lines
Long explanation (if you are interested):
With the DSS HW the planes are positioned to CRTCs by filling each plane's id and x,y position to correct overlay register according to the plane's zpos (each overlay reg has its own static zpos).
Using the naive implementation, there is a problem if I have plane0 at zpos0 and another commit comes with plane1 at zpos0 and plane0 disabled. If plane1 in the commit is handled first, it overwrites plane0's previous position, and plane0 handled afterwards will disable freshly configured plane1. There is number of other problematic cases.
Quoted 6 lines
Ok, I can easily fix this by storing the plane positions (x,y, and z) in the driver's internal state, and rolling the positions out in the
crtc_enable()or -flush(). But I have understood the atomic drivers should avoid having any internal state. So the obvious choice would be to roll out the plane positions directly from the atomic state. However, there is a problem with that.Hm I'm not entirely following the problem, but if you have some requirements around the order in which your planes need to be committed, then roll your own plane commit code. At least for the parts of the plane state which need to be committed like that. You can then stuff that into one of your crtc commit functions.
Quoted 9 lines
And I guess "commit planes in order of zpos" is probably fairly common driver requirement, we might want to have a shared iterator for that.
Aside: Driver private state is totally fine. Just needs to be attached to one of the drm_*_state objects (you can have private state objects too). What's not ok in atomic is stuffing that kind of data into your
drm_crtcstructure (or somewhere else like that), that's where the problems happen.
The root cause is the plane position being part of the plane-state, but in fact the positions being programmed into CRTC registers. I can figure out all kind of strategies to deal with situation in plane commit code. However, the simplest solution is to write all plane positions from the scratch with each commit to all CRTCs with changed planes.
Quoted 8 lines
Quoted 8 lines
The problem appears when I have more than one plane active on a crtc and I just need to update one of the planes. In the situation nothing changes about the CRTC and the unchanged planes, so it is quite understandable that the helpers do not add the unchanged planes to the atomic state. But if I want to roll out the new plane positions from the scratch with every commit that touches any plane on that CRTC, I need to have the unchanged planes there.
Quoted 4 lines
Quoted 2 lines
So the drm_atomic_add_affected_planes()-calls are added just to avoid any internal plane position state in the driver.
Again, this should all happen already.
drm_atomic_helper_check() is supposed to add all the planes on the same CRTC in the atomic state, if one plane on that CRTC changes?
If that should be the case, then there is a bug somewhere.
My test changes a property in a single plane, while another plane is active on the same CRTC. When I loop the planes with for_each_new_plane_in_state() in the crtc_flush() I can only find the updated plane.
Best regards,
Jyri
Signature · 6 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 142 lines · Jyri Sarha
Quoted 114 lines · Daniel Vetter
Quoted 77 lines · Jyri Sarha
Quoted 70 lines · Daniel Vetter
Quoted 57 lines · Jyri Sarha
Quoted 49 lines · Ville Syrjälä
Quoted 43 lines · Jyri Sarha
Quoted 27 lines · Jyri Sarha
The old implementation of placing planes on the CRTC while configuring the planes was naive and relied on the order in which the planes were configured, enabled, and disabled. The situation where a plane's zpos was changed on the fly was completely broken. The usual symptoms of this problem was scrambled display and a flood of sync lost errors, when a plane was active in two layers at the same time, or a missing plane, in case when a layer was accidentally disabled.
The rewrite takes a more straight forward approach when HW is concerned. The plane positioning registers are in the CRTC (actually OVR) register space and it is more natural to configure them in one go while configuring the CRTC. To do this we need to make sure we have all the planes on updated CRTCs in the new atomic state to be committed. This is done by calling
drm_atomic_add_affected_planes()incrtc_atomic_check().Signed-off-by Jyri Sarha <[email protected]>--- drivers/gpu/drm/tidss/tidss_crtc.c | 55 ++++++++++++++++++++++++++++- drivers/gpu/drm/tidss/tidss_dispc.c | 55 +++++++++++------------------ drivers/gpu/drm/tidss/tidss_dispc.h | 5 +++ 3 files changed, 79 insertions(+), 36 deletions(-)drivers/gpu/drm/tidss/tidss_crtc.c +0
-0...
drivers/gpu/drm/tidss/tidss_crtc.c static int tidss_crtc_atomic_check(struct drm_crtc *crtc, · line 118
Quoted 11 lines
drivers/gpu/drm/tidss/tidss_crtc.c +6
-1@@ -108,7 +110,54 @@ static int tidss_crtc_atomic_check(struct drm_crtc *crtc,return -EINVAL ; } -return dispc_vp_bus_check (dispc, hw_videoport, state); + ret =dispc_vp_bus_check (dispc, hw_videoport, state); +if (ret) +return ret; + +/* Add unchanged planes on this crtc to state for zpos update. */ +return drm_atomic_add_affected_planes (state->state, crtc);Is this a correct way to use
drm_atomic_add_affected_planes()?Quoted 4 lines
I saw that some other drivers implement their own
mode_configatomic_check()and have this call there in for_each_new_crtc_in_state()-loop, but I thought it should be fine to call it incrtc_atomic_check().Quoted 5 lines
You seem to be using
drm_atomic_helper_check_planes(), which meanscrtc.atomic_check()gets called afterplane.atomic_check(). So this might be good or bad depending on whether you'd like the planes you add here to go through their .atomic_check() or not.Quoted 6 lines
Should have thought of that my self. Extra
plane.atomic_check()calls do not do any actual harm, but they are potentially expensive. The planes are really only needed there in the commit phase (crtc_enable()orflush()). Well, I'll do my ownmode_config.atomic_check()and calldrm_atomic_add_affected_planes()in a for_each_new_crtc_in_state()-loop after all the checks.Also, if you do use the helpers then this should already have happened for you. Which makes me wonder why all this work, so maybe there's some dependency between all the various check functions you have going on? Might be time to roll your own top-level check function that calls
Quoted 4 lines
stuff in the order your hw needs things to be checked, so that you don't add new states late and have to run one check phase twice (which is totally fine with the helpers as long as all your check callbacks are idempotent, but often just overkill and confusing).
Quoted 7 lines
All the driver specific checks are perfectly independent without any cross dependencies. And there is no extra data in the plane- or CRTC-state, nor do the driver specific checks touch the state in any way.
I only want all the planes on a crtc to be there, if any of the planes on the CRTC changes, so that I can write the plane positions from the scratch directly from the atomic state with each commit.
You /should/ get this already with the atomic helpers, no further action needed. Does it not work?
Quoted 12 lines
Long explanation (if you are interested):
With the DSS HW the planes are positioned to CRTCs by filling each plane's id and x,y position to correct overlay register according to the plane's zpos (each overlay reg has its own static zpos).
Using the naive implementation, there is a problem if I have plane0 at zpos0 and another commit comes with plane1 at zpos0 and plane0 disabled. If plane1 in the commit is handled first, it overwrites plane0's previous position, and plane0 handled afterwards will disable freshly configured plane1. There is number of other problematic cases.
Quoted 6 lines
Ok, I can easily fix this by storing the plane positions (x,y, and z) in the driver's internal state, and rolling the positions out in the
crtc_enable()or -flush(). But I have understood the atomic drivers should avoid having any internal state. So the obvious choice would be to roll out the plane positions directly from the atomic state. However, there is a problem with that.Hm I'm not entirely following the problem, but if you have some requirements around the order in which your planes need to be committed, then roll your own plane commit code. At least for the parts of the plane state which need to be committed like that. You can then stuff that into one of your crtc commit functions.
Quoted 9 lines
And I guess "commit planes in order of zpos" is probably fairly common driver requirement, we might want to have a shared iterator for that.
Aside: Driver private state is totally fine. Just needs to be attached to one of the drm_*_state objects (you can have private state objects too). What's not ok in atomic is stuffing that kind of data into your
drm_crtcstructure (or somewhere else like that), that's where the problems happen.The root cause is the plane position being part of the plane-state, but in fact the positions being programmed into CRTC registers. I can figure out all kind of strategies to deal with situation in plane commit code. However, the simplest solution is to write all plane positions from the scratch with each commit to all CRTCs with changed planes.
Quoted 11 lines
Quoted 10 lines
The problem appears when I have more than one plane active on a crtc and I just need to update one of the planes. In the situation nothing changes about the CRTC and the unchanged planes, so it is quite understandable that the helpers do not add the unchanged planes to the atomic state. But if I want to roll out the new plane positions from the scratch with every commit that touches any plane on that CRTC, I need to have the unchanged planes there.
So the drm_atomic_add_affected_planes()-calls are added just to avoid any internal plane position state in the driver.
Quoted 6 lines
Quoted 1 line
Again, this should all happen already.
drm_atomic_helper_check()is supposed to add all the planes on the same CRTC in the atomic state, if one plane on that CRTC changes?If that should be the case, then there is a bug somewhere.
Sry I misread, it only adds it for the case when there's a modeset. If you need it in more cases (like when zpos changes), you indeed have to do that yourself. Apologies for the confusion, Tom helped me clear this up with a quick chat on irc.
Tom said you're working on a patch that calls add_affected_planes at the right spot in atomic_check, and it sounds like that's all you really need. -Daniel
Quoted 11 lines
My test changes a property in a single plane, while another plane is active on the same CRTC. When I loop the planes with
for_each_new_plane_in_state()in thecrtc_flush()I can only find the updated plane.Best regards,
JyriSignature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi Jyri,
Quoted 94 lines · Jyri Sarha
Quoted 68 lines · Daniel Vetter
Quoted 55 lines · Jyri Sarha
Quoted 49 lines · Ville Syrjälä
Quoted 43 lines · Jyri Sarha
Quoted 27 lines · Jyri Sarha
The old implementation of placing planes on the CRTC while configuring the planes was naive and relied on the order in which the planes were configured, enabled, and disabled. The situation where a plane's zpos was changed on the fly was completely broken. The usual symptoms of this problem was scrambled display and a flood of sync lost errors, when a plane was active in two layers at the same time, or a missing plane, in case when a layer was accidentally disabled.
The rewrite takes a more straight forward approach when HW is concerned. The plane positioning registers are in the CRTC (actually OVR) register space and it is more natural to configure them in one go while configuring the CRTC. To do this we need to make sure we have all the planes on updated CRTCs in the new atomic state to be committed. This is done by calling
drm_atomic_add_affected_planes()incrtc_atomic_check().Signed-off-by Jyri Sarha <[email protected]>--- drivers/gpu/drm/tidss/tidss_crtc.c | 55 ++++++++++++++++++++++++++++- drivers/gpu/drm/tidss/tidss_dispc.c | 55 +++++++++++------------------ drivers/gpu/drm/tidss/tidss_dispc.h | 5 +++ 3 files changed, 79 insertions(+), 36 deletions(-)drivers/gpu/drm/tidss/tidss_crtc.c +0
-0...
drivers/gpu/drm/tidss/tidss_crtc.c static int tidss_crtc_atomic_check(struct drm_crtc *crtc, · line 118
Quoted 11 lines
drivers/gpu/drm/tidss/tidss_crtc.c +6
-1@@ -108,7 +110,54 @@ static int tidss_crtc_atomic_check(struct drm_crtc *crtc,return -EINVAL ; } -return dispc_vp_bus_check (dispc, hw_videoport, state); + ret =dispc_vp_bus_check (dispc, hw_videoport, state); +if (ret) +return ret; + +/* Add unchanged planes on this crtc to state for zpos update. */ +return drm_atomic_add_affected_planes (state->state, crtc);Is this a correct way to use
drm_atomic_add_affected_planes()?Quoted 4 lines
I saw that some other drivers implement their own
mode_configatomic_check()and have this call there in for_each_new_crtc_in_state()-loop, but I thought it should be fine to call it incrtc_atomic_check().Quoted 4 lines
You seem to be using
drm_atomic_helper_check_planes(), which meanscrtc.atomic_check()gets called afterplane.atomic_check(). So this might be good or bad depending on whether you'd like the planes you add here to go through their .atomic_check() or not.Quoted 6 lines
Should have thought of that my self. Extra
plane.atomic_check()calls do not do any actual harm, but they are potentially expensive. The planes are really only needed there in the commit phase (crtc_enable()orflush()). Well, I'll do my ownmode_config.atomic_check()and calldrm_atomic_add_affected_planes()in a for_each_new_crtc_in_state()-loop after all the checks.Also, if you do use the helpers then this should already have happened for you. Which makes me wonder why all this work, so maybe there's some dependency between all the various check functions you have going on? Might be time to roll your own top-level check function that calls
Quoted 4 lines
stuff in the order your hw needs things to be checked, so that you don't add new states late and have to run one check phase twice (which is totally fine with the helpers as long as all your check callbacks are idempotent, but often just overkill and confusing).
All the driver specific checks are perfectly independent without any cross dependencies. And there is no extra data in the plane- or CRTC-state, nor do the driver specific checks touch the state in any way.
I only want all the planes on a crtc to be there, if any of the planes on the CRTC changes, so that I can write the plane positions from the scratch directly from the atomic state with each commit.
Long explanation (if you are interested):
With the DSS HW the planes are positioned to CRTCs by filling each plane's id and x,y position to correct overlay register according to the plane's zpos (each overlay reg has its own static zpos).
Using the naive implementation, there is a problem if I have plane0 at zpos0 and another commit comes with plane1 at zpos0 and plane0 disabled. If plane1 in the commit is handled first, it overwrites plane0's previous position, and plane0 handled afterwards will disable freshly configured plane1. There is number of other problematic cases.
Quoted 6 lines
Ok, I can easily fix this by storing the plane positions (x,y, and z) in the driver's internal state, and rolling the positions out in the
crtc_enable()or -flush(). But I have understood the atomic drivers should avoid having any internal state. So the obvious choice would be to roll out the plane positions directly from the atomic state. However, there is a problem with that.
Atomic drivers should not store state in internal structures, but they can subclass the standard state structures and add data there. You could, in your atomic_check implementation, compute the values of the CRTC registers that govern plane positioning, store them in your subsclas of drm_crtc_state, and then just apply them in the CRTC atomic flush.
Quoted 10 lines
The problem appears when I have more than one plane active on a crtc and I just need to update one of the planes. In the situation nothing changes about the CRTC and the unchanged planes, so it is quite understandable that the helpers do not add the unchanged planes to the atomic state. But if I want to roll out the new plane positions from the scratch with every commit that touches any plane on that CRTC, I need to have the unchanged planes there.
So the drm_atomic_add_affected_planes()-calls are added just to avoid any internal plane position state in the driver.
Signature · 7 lines
Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel