drm/simple-helpers: Always add planes to the state update
Subsystems (2)
PATCH 1/1 drm/simple-helpers: Always add planes to the state update
Our update function is hooked to the single plane, which might not get called for crtc-only updates. Which is surprising, so fix this by always adding the plane.
While at it document how&when the event should be sent out better in the kerneldoc.
---
I'm not entirely sure we really want to put the responsibility for this onto driver. Plan B) would be to remove the kerneldoc I added here and call the right function from drm_simple_kms_plane_atomic_update. That way simple drivers don't need to deal with that detail, and in general those drivers don't care that much about the miniscule possible race a generic implementation would cause. What do you suggest as the best approach?
-Daniel
--- drivers/gpu/drm/drm_simple_kms_helper.c | 7 +++++++ include/drm/drm_simple_kms_helper.h | 6 ++++++ 2 files changed, 13 insertions(+)
drivers/gpu/drm/drm_simple_kms_helper.c +7 -0
@@ -34,6 +34,12 @@ static const struct drm_encoder_funcs drm_simple_kms_encoder_funcs = { .destroy = drm_encoder_cleanup, }; +static int drm_simple_kms_crtc_check (struct drm_crtc *crtc, +struct drm_crtc_state *state) +{ +return drm_atomic_add_affected_planes (state->state, crtc); +} +static void drm_simple_kms_crtc_enable (struct drm_crtc *crtc) {struct drm_simple_display_pipe *pipe;
@@ -57,6 +63,7 @@ static void drm_simple_kms_crtc_disable(struct drm_crtc *crtc) }static const struct drm_crtc_helper_funcs drm_simple_kms_crtc_helper_funcs = { + .atomic_check = drm_simple_kms_crtc_check, .disable = drm_simple_kms_crtc_disable, .enable = drm_simple_kms_crtc_enable, };
include/drm/drm_simple_kms_helper.h +6 -0
@@ -60,6 +60,12 @@ struct drm_simple_display_pipe_funcs {* * This function is called when the underlying plane state is updated. * This hook is optional. +* +* This is the function drivers should submit the +* &drm_pending_vblank_event from. Using either +* drm_crtc_arm_vblank_event(), when the driver supports vblank +* interrupt handling, or drm_crtc_send_vblank_event() directly in case +* the hardware lacks vblank support entirely. */ void (*update)(struct drm_simple_display_pipe *pipe,struct drm_plane_state *plane_state);
Signature · 6 lines
2.8.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Den 23.08.2016 08:25, skrev Daniel Vetter:
Quoted 11 lines
Our update function is hooked to the single plane, which might not get called for crtc-only updates. Which is surprising, so fix this by always adding the plane.
While at it document how&when the event should be sent out better in the kerneldoc.
Cc Noralf Trønnes <[email protected]>Tested-and-Reported-by [email protected]Signed-off-by Daniel Vetter <[email protected]>
Quoted 8 lines
---
I'm not entirely sure we really want to put the responsibility for this onto driver. Plan B) would be to remove the kerneldoc I added here and call the right function fromdrm_simple_kms_plane_atomic_update. That way simple drivers don't need to deal with that detail, and in general those drivers don't care that much about the miniscule possible race a generic implementation would cause. What do you suggest as the best approach?
If the driver is responsible, a helper like this would be nice:
void drm_simple_display_pipe_handle_vblank_event(struct drm_simple_display_pipe *pipe)
{
struct drm_crtc *crtc = &pipe->crtc;
if (crtc->state && crtc->state->event) {
spin_lock_irq(&crtc->dev->event_lock);
drm_crtc_send_vblank_event(crtc, crtc->state->event);
spin_unlock_irq(&crtc->dev->event_lock);
crtc->state->event = NULL;
}
}Then if the update() callback is not set, drm_simple_kms_plane_atomic_update calls this, and if it is set, then the driver has to do it or something similar.
It is difficult to predict what future drivers will need. Unless there are drivers on the horizon that will need to handle the event themselves, I suggest that we follow your plan B. If the need arises, we just add a one-liner to all drivers that has the update() callback set.
Noralf.
Sidenote:
When I converted simpledrm I had problems with flip_done timeouts. In the end I had to check for the event in disable/enable/update. Trying it again now, it's enough to do it in update(). Not sure what has changed.
Quoted 38 lines
(quoted diff) +0
-2-Daniel --- drivers/gpu/drm/drm_simple_kms_helper.c | 7 +++++++ include/drm/drm_simple_kms_helper.h | 6 ++++++ 2 files changed, 13 insertions(+)drivers/gpu/drm/drm_simple_kms_helper.c +7
-0@@ -34,6 +34,12 @@ static const struct drm_encoder_funcs drm_simple_kms_encoder_funcs = { .destroy = drm_encoder_cleanup, }; +static int drm_simple_kms_crtc_check (struct drm_crtc *crtc, +struct drm_crtc_state *state) +{ +return drm_atomic_add_affected_planes (state->state, crtc); +} +static void drm_simple_kms_crtc_enable (struct drm_crtc *crtc) {struct drm_simple_display_pipe *pipe;@@ -57,6 +63,7 @@ static void drm_simple_kms_crtc_disable(struct drm_crtc *crtc) }static const struct drm_crtc_helper_funcs drm_simple_kms_crtc_helper_funcs = { + .atomic_check = drm_simple_kms_crtc_check, .disable = drm_simple_kms_crtc_disable, .enable = drm_simple_kms_crtc_enable, };include/drm/drm_simple_kms_helper.h +0
-0@@ -60,6 +60,12 @@ struct drm_simple_display_pipe_funcs {* * This function is called when the underlying plane state is updated.
include/drm/drm_simple_kms_helper.h struct drm_simple_display_pipe_funcs { · line 71
Quoted 10 lines
include/drm/drm_simple_kms_helper.h +6
-0* This hook is optional. +* +* This is the function drivers should submit the +* &drm_pending_vblank_event from. Using either +* drm_crtc_arm_vblank_event(), when the driver supports vblank +* interrupt handling, or drm_crtc_send_vblank_event() directly in case +* the hardware lacks vblank support entirely. */ void (*update)(struct drm_simple_display_pipe *pipe,struct drm_plane_state *plane_state);
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 26 lines · Noralf Trønnes
Den 23.08.2016 08:25, skrev Daniel Vetter:
Quoted 11 lines
Our update function is hooked to the single plane, which might not get called for crtc-only updates. Which is surprising, so fix this by always adding the plane.
While at it document how&when the event should be sent out better in the kerneldoc.
Cc Noralf Trønnes <[email protected]>Tested-and-Reported-by [email protected]Signed-off-by Daniel Vetter <[email protected]>Quoted 8 lines
---
I'm not entirely sure we really want to put the responsibility for this onto driver. Plan B) would be to remove the kerneldoc I added here and call the right function fromdrm_simple_kms_plane_atomic_update. That way simple drivers don't need to deal with that detail, and in general those drivers don't care that much about the miniscule possible race a generic implementation would cause. What do you suggest as the best approach?If the driver is responsible, a helper like this would be nice:
void
drm_simple_display_pipe_handle_vblank_event(struct drm_simple_display_pipe *pipe)
Quoted 8 lines
{
struct drm_crtc *crtc = &pipe->crtc;
if (crtc->state && crtc->state->event) {
spin_lock_irq(&crtc->dev->event_lock);
drm_crtc_send_vblank_event(crtc, crtc->state->event);
spin_unlock_irq(&crtc->dev->event_lock);
crtc->state->event = NULL;For a generic version we probably want to automatically switch to drm_crtc_arm_vblank_event, if vblank support is available. That can be checked by looking at drm_device->num_crtcs.
Quoted 11 lines
} }Then if the
update()callback is not set,drm_simple_kms_plane_atomic_updatecalls this, and if it is set, then the driver has to do it or something similar.It is difficult to predict what future drivers will need. Unless there are drivers on the horizon that will need to handle the event themselves, I suggest that we follow your plan B. If the need arises, we just add a one-liner to all drivers that has the
update()callback set.
Hm yeah. What about merging this patch here for now (would need your formal reviewed-by), and then later on when we have 2-3 simple drivers using this we can reconsider? Since I dont have hw for any of them I can't do this myself.
Quoted 7 lines
Noralf.
Sidenote:
When I converted simpledrm I had problems withflip_donetimeouts. In the end I had to check for the event in disable/enable/update. Trying it again now, it's enough to do it inupdate(). Not sure what has changed.
Trying again with this patch, or without? Since this patch here is meant to exactly the problem that you need to handle the event in too many places. If it's fixed with just latest drm-misc, that would be surprising
...
-Daniel
Quoted 48 lines
Quoted 47 lines
(quoted diff) +0
-2-Daniel --- drivers/gpu/drm/drm_simple_kms_helper.c | 7 +++++++ include/drm/drm_simple_kms_helper.h | 6 ++++++ 2 files changed, 13 insertions(+)drivers/gpu/drm/drm_simple_kms_helper.c +7
-0@@ -34,6 +34,12 @@ static const struct drm_encoder_funcs drm_simple_kms_encoder_funcs = { .destroy = drm_encoder_cleanup, }; +static int drm_simple_kms_crtc_check (struct drm_crtc *crtc, +struct drm_crtc_state *state) +{ +return drm_atomic_add_affected_planes (state->state, crtc); +} +static void drm_simple_kms_crtc_enable (struct drm_crtc *crtc) {struct drm_simple_display_pipe *pipe;@@ -57,6 +63,7 @@ static void drm_simple_kms_crtc_disable(struct drm_crtc *crtc) }static const struct drm_crtc_helper_funcs drm_simple_kms_crtc_helper_funcs = { + .atomic_check = drm_simple_kms_crtc_check, .disable = drm_simple_kms_crtc_disable, .enable = drm_simple_kms_crtc_enable, };include/drm/drm_simple_kms_helper.h +6
-0@@ -60,6 +60,12 @@ struct drm_simple_display_pipe_funcs {* * This function is called when the underlying plane state is updated. * This hook is optional. +* +* This is the function drivers should submit the +* &drm_pending_vblank_event from. Using either +* drm_crtc_arm_vblank_event(), when the driver supports vblank +* interrupt handling, or drm_crtc_send_vblank_event() directly in case +* the hardware lacks vblank support entirely. */ void (*update)(struct drm_simple_display_pipe *pipe,struct drm_plane_state *plane_state);
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
Noralf Trønnes
Reviewed-byDen 25.08.2016 08:30, skrev Daniel Vetter:
Quoted 60 lines · Noralf Trønnes
Quoted 24 lines
Den 23.08.2016 08:25, skrev Daniel Vetter:
Quoted 11 lines
Our update function is hooked to the single plane, which might not get called for crtc-only updates. Which is surprising, so fix this by always adding the plane.
While at it document how&when the event should be sent out better in the kerneldoc.
Cc Noralf Trønnes <[email protected]>Tested-and-Reported-by [email protected]Signed-off-by Daniel Vetter <[email protected]>Quoted 8 lines
---
I'm not entirely sure we really want to put the responsibility for this onto driver. Plan B) would be to remove the kerneldoc I added here and call the right function fromdrm_simple_kms_plane_atomic_update. That way simple drivers don't need to deal with that detail, and in general those drivers don't care that much about the miniscule possible race a generic implementation would cause. What do you suggest as the best approach?If the driver is responsible, a helper like this would be nice:
void
drm_simple_display_pipe_handle_vblank_event(struct drm_simple_display_pipe *pipe)Quoted 8 lines
{ struct drm_crtc *crtc = &pipe->crtc; if (crtc->state && crtc->state->event) { spin_lock_irq(&crtc->dev->event_lock); drm_crtc_send_vblank_event(crtc, crtc->state->event); spin_unlock_irq(&crtc->dev->event_lock); crtc->state->event = NULL;For a generic version we probably want to automatically switch to
drm_crtc_arm_vblank_event, if vblank support is available. That can be checked by looking atdrm_device->num_crtcs.Quoted 11 lines
} }Then if the
update()callback is not set,drm_simple_kms_plane_atomic_updatecalls this, and if it is set, then the driver has to do it or something similar.It is difficult to predict what future drivers will need. Unless there are drivers on the horizon that will need to handle the event themselves, I suggest that we follow your plan B. If the need arises, we just add a one-liner to all drivers that has the
update()callback set.Hm yeah. What about merging this patch here for now (would need your formal reviewed-by), and then later on when we have 2-3 simple drivers using this we can reconsider? Since I dont have hw for any of them I can't do this myself.
Quoted 7 lines
Noralf.
Sidenote:
When I converted simpledrm I had problems withflip_donetimeouts. In the end I had to check for the event in disable/enable/update. Trying it again now, it's enough to do it inupdate(). Not sure what has changed.
Quoted 4 lines
Trying again with this patch, or without? Since this patch here is meant to exactly the problem that you need to handle the event in too many places. If it's fixed with just latest drm-misc, that would be surprising
...
I have updated Raspian so I could use xorg to test with, and indeed without this patch and without sending vblank event in disable and enable, the flip_done timeout showed up. modetest -v didn't trigger it. With this patch I only have to send the vblank event in update().
Quoted 40 lines
-Daniel
Quoted 38 lines
Quoted 38 lines
(quoted diff) +0
-2-Daniel --- drivers/gpu/drm/drm_simple_kms_helper.c | 7 +++++++ include/drm/drm_simple_kms_helper.h | 6 ++++++ 2 files changed, 13 insertions(+)drivers/gpu/drm/drm_simple_kms_helper.c +7
-0@@ -34,6 +34,12 @@ static const struct drm_encoder_funcs drm_simple_kms_encoder_funcs = { .destroy = drm_encoder_cleanup, }; +static int drm_simple_kms_crtc_check (struct drm_crtc *crtc, +struct drm_crtc_state *state) +{ +return drm_atomic_add_affected_planes (state->state, crtc); +} +static void drm_simple_kms_crtc_enable (struct drm_crtc *crtc) {struct drm_simple_display_pipe *pipe;@@ -57,6 +63,7 @@ static void drm_simple_kms_crtc_disable(struct drm_crtc *crtc) }static const struct drm_crtc_helper_funcs drm_simple_kms_crtc_helper_funcs = { + .atomic_check = drm_simple_kms_crtc_check, .disable = drm_simple_kms_crtc_disable, .enable = drm_simple_kms_crtc_enable, };include/drm/drm_simple_kms_helper.h +1
-0@@ -60,6 +60,12 @@ struct drm_simple_display_pipe_funcs {* * This function is called when the underlying plane state is updated. * This hook is optional. +*
Quoted 8 lines
Quoted 8 lines
include/drm/drm_simple_kms_helper.h struct drm_simple_display_pipe_funcs { · line 71
Quoted 8 lines
include/drm/drm_simple_kms_helper.h +5
-0+* This is the function drivers should submit the +* &drm_pending_vblank_event from. Using either +* drm_crtc_arm_vblank_event(), when the driver supports vblank +* interrupt handling, or drm_crtc_send_vblank_event() directly in case +* the hardware lacks vblank support entirely. */ void (*update)(struct drm_simple_display_pipe *pipe,struct drm_plane_state *plane_state);
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 67 lines · Noralf Trønnes
Den 25.08.2016 08:30, skrev Daniel Vetter:
Quoted 60 lines · Noralf Trønnes
Quoted 24 lines
Den 23.08.2016 08:25, skrev Daniel Vetter:
Quoted 11 lines
Our update function is hooked to the single plane, which might not get called for crtc-only updates. Which is surprising, so fix this by always adding the plane.
While at it document how&when the event should be sent out better in the kerneldoc.
Cc Noralf Trønnes <[email protected]>Tested-and-Reported-by [email protected]Signed-off-by Daniel Vetter <[email protected]>Quoted 8 lines
---
I'm not entirely sure we really want to put the responsibility for this onto driver. Plan B) would be to remove the kerneldoc I added here and call the right function fromdrm_simple_kms_plane_atomic_update. That way simple drivers don't need to deal with that detail, and in general those drivers don't care that much about the miniscule possible race a generic implementation would cause. What do you suggest as the best approach?If the driver is responsible, a helper like this would be nice:
void
drm_simple_display_pipe_handle_vblank_event(struct drm_simple_display_pipe *pipe)Quoted 8 lines
{ struct drm_crtc *crtc = &pipe->crtc; if (crtc->state && crtc->state->event) { spin_lock_irq(&crtc->dev->event_lock); drm_crtc_send_vblank_event(crtc, crtc->state->event); spin_unlock_irq(&crtc->dev->event_lock); crtc->state->event = NULL;For a generic version we probably want to automatically switch to
drm_crtc_arm_vblank_event, if vblank support is available. That can be checked by looking atdrm_device->num_crtcs.Quoted 11 lines
} }Then if the
update()callback is not set,drm_simple_kms_plane_atomic_updatecalls this, and if it is set, then the driver has to do it or something similar.It is difficult to predict what future drivers will need. Unless there are drivers on the horizon that will need to handle the event themselves, I suggest that we follow your plan B. If the need arises, we just add a one-liner to all drivers that has the
update()callback set.Hm yeah. What about merging this patch here for now (would need your formal reviewed-by), and then later on when we have 2-3 simple drivers using this we can reconsider? Since I dont have hw for any of them I can't do this myself.
Quoted 7 lines
Noralf.
Sidenote:
When I converted simpledrm I had problems withflip_donetimeouts. In the end I had to check for the event in disable/enable/update. Trying it again now, it's enough to do it inupdate(). Not sure what has changed.Quoted 4 lines
Trying again with this patch, or without? Since this patch here is meant to exactly the problem that you need to handle the event in too many places. If it's fixed with just latest drm-misc, that would be surprising
...
Quoted 6 lines
I have updated Raspian so I could use xorg to test with, and indeed without this patch and without sending vblank event in disable and enable, the
flip_donetimeout showed up. modetest -v didn't trigger it. With this patch I only have to send the vblank event inupdate().Reviewed-by Noralf Trønnes <[email protected]>
Thanks for the review, pushed onto -misc.
-Daniel
Quoted 50 lines
Quoted 49 lines
-Daniel
Quoted 46 lines
Quoted 46 lines
(quoted diff) +0
-2-Daniel --- drivers/gpu/drm/drm_simple_kms_helper.c | 7 +++++++ include/drm/drm_simple_kms_helper.h | 6 ++++++ 2 files changed, 13 insertions(+)drivers/gpu/drm/drm_simple_kms_helper.c +7
-0@@ -34,6 +34,12 @@ static const struct drm_encoder_funcs drm_simple_kms_encoder_funcs = { .destroy = drm_encoder_cleanup, }; +static int drm_simple_kms_crtc_check (struct drm_crtc *crtc, +struct drm_crtc_state *state) +{ +return drm_atomic_add_affected_planes (state->state, crtc); +} +static void drm_simple_kms_crtc_enable (struct drm_crtc *crtc) {struct drm_simple_display_pipe *pipe;@@ -57,6 +63,7 @@ static void drm_simple_kms_crtc_disable(struct drm_crtc *crtc) }static const struct drm_crtc_helper_funcs drm_simple_kms_crtc_helper_funcs = { + .atomic_check = drm_simple_kms_crtc_check, .disable = drm_simple_kms_crtc_disable, .enable = drm_simple_kms_crtc_enable, };include/drm/drm_simple_kms_helper.h +6
-0@@ -60,6 +60,12 @@ struct drm_simple_display_pipe_funcs {* * This function is called when the underlying plane state is updated. * This hook is optional. +* +* This is the function drivers should submit the +* &drm_pending_vblank_event from. Using either +* drm_crtc_arm_vblank_event(), when the driver supports vblank +* interrupt handling, or drm_crtc_send_vblank_event() directly in case +* the hardware lacks vblank support entirely. */ void (*update)(struct drm_simple_display_pipe *pipe,struct drm_plane_state *plane_state);
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