drm/hyperv: Replace simple-KMS with regular atomic helpers
Subsystems (5)
PATCH v2 1/1 drm/hyperv: Replace simple-KMS with regular atomic helpers
Drop simple-KMS in favor of regular atomic helpers to make the code more modular. The simple-KMS helper mix up plane and CRTC state, so it is obsolete and should go away [1]. Since it just split the simple-pipe functions into per-plane and per-CRTC, no functional changes is expected.
[1] https://lore.kernel.org/lkml/[email protected]/
---
v2:
- Remove hyperv_crtc_helper_mode_valid
- Remove hyperv_format_mod_supported
- Call helper_add after {plane,crtc}_init
- Move drm_plane_enable_fb_damage_clips to a place close to plane init
- Move hyperv_conn_init() into hyperv_pipe_init
- Remove hyperv_blit_to_vram_fullscreen
- Remove format check
- Replace hyperv_crtc_helper_atomic_check to drm_crtc_helper_atomic_check
v1:
https://lore.kernel.org/all/[email protected]/
drivers/gpu/drm/hyperv/hyperv_drm.h | 4 +- drivers/gpu/drm/hyperv/hyperv_drm_modeset.c | 159 +++++++++++++------- 2 files changed, 107 insertions(+), 56 deletions(-)
drivers/gpu/drm/hyperv/hyperv_drm.h +3 -1
@@ -11,7 +11,9 @@struct hyperv_drm_device {/* drm */ struct drm_device dev; -struct drm_simple_display_pipe pipe; +struct drm_plane plane; +struct drm_crtc crtc; +struct drm_encoder encoder;struct drm_connector connector;/* mode */
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c +104 -55
230 lines not on this page · raw message
base-commit: b60301774a8fe6c30b14a95104ec099290a2e904
Signature · 1 line
2.49.0
Ryosuke Yasuoka <[email protected]> writes:
Hello Ryosuke,
Quoted 15 lines
Drop simple-KMS in favor of regular atomic helpers to make the code more modular. The simple-KMS helper mix up plane and CRTC state, so it is obsolete and should go away [1]. Since it just split the simple-pipe functions into per-plane and per-CRTC, no functional changes is expected.
[1] https://lore.kernel.org/lkml/[email protected]/
Signed-off-by Ryosuke Yasuoka <[email protected]>drivers/gpu/drm/hyperv/hyperv_drm_modeset.c +0
-2-static void hyperv_pipe_enable(struct drm_simple_display_pipe *pipe, - struct drm_crtc_state *crtc_state,
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c static int hyperv_check_size(struct hyperv_drm_device *hv, int w, int h, · line 99
Quoted 10 lines
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c +9
-1- struct drm_plane_state *plane_state) +static const uint32_t hyperv_formats[] = { +DRM_FORMAT_XRGB8888 , +}; + +static const uint64_t hyperv_modifiers[] = { +DRM_FORMAT_MOD_LINEAR , +DRM_FORMAT_MOD_INVALID +}; +
I think the kernel u32 and u64 types are preferred ?
Quoted 15 lines
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c +6
-2+static void hyperv_crtc_helper_atomic_enable (struct drm_crtc *crtc, +struct drm_atomic_state *state) { -struct hyperv_drm_device *hv =to_hv (pipe->crtc.dev); -struct drm_shadow_plane_state *shadow_plane_state =to_drm_shadow_plane_state (plane_state); +struct hyperv_drm_device *hv =to_hv (crtc->dev); +struct drm_plane *plane = &hv->plane; +struct drm_plane_state *plane_state = plane->state; +struct drm_crtc_state *crtc_state = crtc->state;hyperv_hide_hw_ptr (hv->hdev);hyperv_update_situation (hv->hdev,1 , hv->screen_depth, crtc_state->mode.hdisplay, crtc_state->mode.vdisplay, plane_state->fb->pitches[0 ]);
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c static int hyperv_check_size(struct hyperv_drm_device *hv, int w, int h, · line 118
Quoted 10 lines
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c +4
-4-hyperv_blit_to_vram_fullscreen (plane_state->fb, &shadow_plane_state->data[0 ]); } -static int hyperv_pipe_check (struct drm_simple_display_pipe *pipe, -struct drm_plane_state *plane_state, -struct drm_crtc_state *crtc_state) +static void hyperv_crtc_helper_atomic_disable (struct drm_crtc *crtc, +struct drm_atomic_state *state) +{ } +
Why do you need an empty CRTC atomic disable callback? Can you just not set it instead?
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c static int hyperv_pipe_check(struct drm_simple_display_pipe *pipe, · line 171
Quoted 11 lines
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c +5
-4-static void hyperv_pipe_update (struct drm_simple_display_pipe *pipe, -struct drm_plane_state *old_state) +static void hyperv_plane_atomic_update (struct drm_plane *plane, +struct drm_atomic_state *old_state) { -struct hyperv_drm_device *hv =to_hv (pipe->crtc.dev); -struct drm_plane_state *state = pipe->plane.state; +struct drm_plane_state *old_pstate =drm_atomic_get_old_plane_state (old_state, plane); +struct hyperv_drm_device *hv =to_hv (plane->dev); +struct drm_plane_state *state = plane->state;
You should never access the plane->state directly, instead the helper drm_atomic_get_new_plane_state() should be used. You can also rename the old_state paramete to just state, since it will be used to lookup both the old and new atomic states.
More info is in the following email from Ville:
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c static int hyperv_pipe_check(struct drm_simple_display_pipe *pipe, · line 175
Quoted 5 lines
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c +1
-1struct drm_shadow_plane_state *shadow_plane_state =to_drm_shadow_plane_state (state);struct drm_rect rect; -if (drm_atomic_helper_damage_merged (old_state, state, &rect)) { +if (drm_atomic_helper_damage_merged (old_pstate, state, &rect)) {
I know that most of the simple-KMS drivers do this but since this driver enables FB damage clips support, it is better to iterate over the damage areas. For example:
struct drm_atomic_helper_damage_iter iter;
struct drm_rect dst_clip;
struct drm_rect damage;
drm_atomic_helper_damage_iter_init(&iter, old_pstate, state);
drm_atomic_for_each_plane_damage(&iter, &damage) {
dst_clip = state->dst;
if (!drm_rect_intersect(&dst_clip, &damage))
continue;
hyperv_blit_to_vram_rect(state->fb, &shadow_plane_state->data[0], &damage);
hyperv_update_dirt(hv->hdev, &damage);
}Other than these small comments, the patch looks good to me. So if you take into account my suggestions, feel free to add:
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Hi Javier,
Quoted 18 lines · Javier Martinez Canillas
Ryosuke Yasuoka <[email protected]> writes:
Hello Ryosuke,
Quoted 10 lines
Drop simple-KMS in favor of regular atomic helpers to make the code more modular. The simple-KMS helper mix up plane and CRTC state, so it is obsolete and should go away [1]. Since it just split the simple-pipe functions into per-plane and per-CRTC, no functional changes is expected.
[1] https://lore.kernel.org/lkml/[email protected]/
Signed-off-by Ryosuke Yasuoka <[email protected]>
Quoted 14 lines
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c static int hyperv_check_size(struct hyperv_drm_device *hv, int w, int h, · line 99
Quoted 12 lines
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c +9
-3-static void hyperv_pipe_enable (struct drm_simple_display_pipe *pipe, -struct drm_crtc_state *crtc_state, -struct drm_plane_state *plane_state) +static const uint32_t hyperv_formats[] = { +DRM_FORMAT_XRGB8888 , +}; + +static const uint64_t hyperv_modifiers[] = { +DRM_FORMAT_MOD_LINEAR , +DRM_FORMAT_MOD_INVALID +}; +I think the kernel u32 and u64 types are preferred ?
I'm not sure if I should fix this in this patch because I did not add these variables. IMO, we need to split the commit if we fix them.
Quoted 18 lines
Quoted 18 lines
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c +6
-3+static void hyperv_crtc_helper_atomic_enable (struct drm_crtc *crtc, +struct drm_atomic_state *state) { -struct hyperv_drm_device *hv =to_hv (pipe->crtc.dev); -struct drm_shadow_plane_state *shadow_plane_state =to_drm_shadow_plane_state (plane_state); +struct hyperv_drm_device *hv =to_hv (crtc->dev); +struct drm_plane *plane = &hv->plane; +struct drm_plane_state *plane_state = plane->state; +struct drm_crtc_state *crtc_state = crtc->state;hyperv_hide_hw_ptr (hv->hdev);hyperv_update_situation (hv->hdev,1 , hv->screen_depth, crtc_state->mode.hdisplay, crtc_state->mode.vdisplay, plane_state->fb->pitches[0 ]); -hyperv_blit_to_vram_fullscreen (plane_state->fb, &shadow_plane_state->data[0 ]); }
Quoted 10 lines
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c static int hyperv_check_size(struct hyperv_drm_device *hv, int w, int h, · line 118
Quoted 7 lines
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c +4
-3-static int hyperv_pipe_check (struct drm_simple_display_pipe *pipe, -struct drm_plane_state *plane_state, -struct drm_crtc_state *crtc_state) +static void hyperv_crtc_helper_atomic_disable (struct drm_crtc *crtc, +struct drm_atomic_state *state) +{ } +Why do you need an empty CRTC atomic disable callback? Can you just not set it instead?
OK. I'll fix it in my next patch.
Quoted 17 lines
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c static int hyperv_pipe_check(struct drm_simple_display_pipe *pipe, · line 171
Quoted 11 lines
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c +5
-4-static void hyperv_pipe_update (struct drm_simple_display_pipe *pipe, -struct drm_plane_state *old_state) +static void hyperv_plane_atomic_update (struct drm_plane *plane, +struct drm_atomic_state *old_state) { -struct hyperv_drm_device *hv =to_hv (pipe->crtc.dev); -struct drm_plane_state *state = pipe->plane.state; +struct drm_plane_state *old_pstate =drm_atomic_get_old_plane_state (old_state, plane); +struct hyperv_drm_device *hv =to_hv (plane->dev); +struct drm_plane_state *state = plane->state;You should never access the
plane->statedirectly, instead the helperdrm_atomic_get_new_plane_state()should be used. You can also rename theold_stateparamete to just state, since it will be used to lookup both the old and new atomic states.
Quoted 3 lines
More info is in the following email from Ville:
OK. I'll fix it in my next patch. Thank you for sharing the url.
Quoted 10 lines
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c static int hyperv_pipe_check(struct drm_simple_display_pipe *pipe, · line 175
Quoted 5 lines
struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(state); struct drm_rect rect;drivers/gpu/drm/hyperv/hyperv_drm_modeset.c +1
-1-if (drm_atomic_helper_damage_merged (old_state, state, &rect)) { +if (drm_atomic_helper_damage_merged (old_pstate, state, &rect)) {I know that most of the simple-KMS drivers do this but since this driver enables FB damage clips support, it is better to iterate over the damage areas. For example:
Quoted 15 lines
struct drm_atomic_helper_damage_iter iter;
struct drm_rect dst_clip;
struct drm_rect damage;
drm_atomic_helper_damage_iter_init(&iter, old_pstate, state);
drm_atomic_for_each_plane_damage(&iter, &damage) {
dst_clip = state->dst;
if (!drm_rect_intersect(&dst_clip, &damage))
continue;
hyperv_blit_to_vram_rect(state->fb, &shadow_plane_state->data[0], &damage);
hyperv_update_dirt(hv->hdev, &damage);
}OK. As you said, other drivers like mgag200 implement like this. I'll fix them in my next patch.
Quoted 4 lines
Other than these small comments, the patch looks good to me. So if you take into account my suggestions, feel free to add:
Thank you for your review and comment. I'll fix them and add your ack.
Best regards,
Ryosuke
Quoted 7 lines
--
Best regards,Javier Martinez Canillas
Core Platforms
Red Hat
Ryosuke Yasuoka <[email protected]> writes:
Hello Ryosuke,
Quoted 37 lines
Hi Javier,
Quoted 18 lines · Javier Martinez Canillas
Ryosuke Yasuoka <[email protected]> writes:
Hello Ryosuke,
Quoted 10 lines
Drop simple-KMS in favor of regular atomic helpers to make the code more modular. The simple-KMS helper mix up plane and CRTC state, so it is obsolete and should go away [1]. Since it just split the simple-pipe functions into per-plane and per-CRTC, no functional changes is expected.
[1] https://lore.kernel.org/lkml/[email protected]/
Signed-off-by Ryosuke Yasuoka <[email protected]>Quoted 14 lines
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c static int hyperv_check_size(struct hyperv_drm_device *hv, int w, int h, · line 99
Quoted 12 lines
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c +9
-3-static void hyperv_pipe_enable (struct drm_simple_display_pipe *pipe, -struct drm_crtc_state *crtc_state, -struct drm_plane_state *plane_state) +static const uint32_t hyperv_formats[] = { +DRM_FORMAT_XRGB8888 , +}; + +static const uint64_t hyperv_modifiers[] = { +DRM_FORMAT_MOD_LINEAR , +DRM_FORMAT_MOD_INVALID +}; +I think the kernel u32 and u64 types are preferred ?
Quoted 3 lines
I'm not sure if I should fix this in this patch because I did not add these variables. IMO, we need to split the commit if we fix them.
Right, I got confused for how the diff showed the changes. But I agree with you that should be a separate patch since the variables already exist.
[...]
Quoted 5 lines
Quoted 2 lines
Thank you for your review and comment. I'll fix them and add your ack.
Thanks!
Quoted 3 lines
Best regards,
Ryosuke
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat