removal of extra abstraction layers
Subsystems (3)
cover removal of extra abstraction layers
From: Gustavo Padovan <[email protected]>
Hi Inki,
In this series I've removed some level of indirection from the exynos_drm_code. There two moves in these patches, first we remove all exynos_drm_crtc_plane_*() wrappers and call the manager specific functions directly. The other change is the removal of struct exynos_drm_overlay(). In my understanding the overlay struct was just storing plane data in a 1:1 relationship so it made sense to merge its fields in struct exynos_drm_plane and remove another abstraction from the driver.
Next steps:
During our initial investigation on the Exynos DRM driver we've spoted a few abstractions that could be removed to get a more clean and less abstract code.
- struct exynos_drm_manager: this is just a helper of struct exynos_drm_crtc, I suggest we could merge them both.
- struct *_win_data: Most of the share common fields and could be merged int struct exynos_drm_plane.
- some more function wrapper can be removed as well.
After these changes intead of looking to manager and win_data we will look into crtc and planes. The new names give us more clue about what a piece of code is doing since they are already defined and used by the whole DRM ecossytem.
What your thoughts on this? I've seen that you pushed some patches to remove static usage of managers so I would like to check with you which direction are you planning to go with this. I've done some code[0] around this but now it needs a rebase against you exynos-drm-next.
[0] https://git.kernel.org/cgit/linux/kernel/git/padovan/drm-exynos.git/log/?h=cleanup
Gustavo Padovan (4):
drm/exynos: move to_exynos_crtc() macro to main header drm/exynos: expose struct exynos_drm_crtc drm/exynos: remove exynos_drm_crtc_plane_* wrappers drm/exynos: remove struct exynos_drm_overlay
drivers/gpu/drm/exynos/exynos_drm_crtc.c | 66 --------------------- drivers/gpu/drm/exynos/exynos_drm_crtc.h | 2 +- drivers/gpu/drm/exynos/exynos_drm_drv.h | 43 +++++++++++++- drivers/gpu/drm/exynos/exynos_drm_fimd.c | 44 +++++++------- drivers/gpu/drm/exynos/exynos_drm_plane.c | 96 +++++++++++++++---------------- drivers/gpu/drm/exynos/exynos_drm_vidi.c | 38 ++++++------ drivers/gpu/drm/exynos/exynos_mixer.c | 50 ++++++++-------- 7 files changed, 156 insertions(+), 183 deletions(-)
Signature · 6 lines
1.9.3 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/4 drm/exynos: move to_exynos_crtc() macro to main header
From: Gustavo Padovan <[email protected]>
With this change we allow other pieces of the code to use this macro.
--- drivers/gpu/drm/exynos/exynos_drm_crtc.c | 3 --- drivers/gpu/drm/exynos/exynos_drm_drv.h | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_crtc.c +0 -3
@@ -20,9 +20,6 @@#include "exynos_drm_encoder.h" #include "exynos_drm_plane.h" -#define to_exynos_crtc (x) container_of(x, struct exynos_drm_crtc,\ - drm_crtc) -enum exynos_crtc_mode {CRTC_MODE_NORMAL ,/* normal mode */ CRTC_MODE_BLANK ,/* The private plane of crtc is blank */
drivers/gpu/drm/exynos/exynos_drm_drv.h +3 -0
@@ -23,6 +23,9 @@#define MAX_FB_BUFFER 4#define DEFAULT_ZPOS -1 +#define to_exynos_crtc (x) container_of(x, struct exynos_drm_crtc,\ + drm_crtc) +/* This enumerates device type. */ enum exynos_drm_device_type {EXYNOS_DEVICE_TYPE_NONE ,
Signature · 1 line
1.9.3
PATCH 2/4 drm/exynos: expose struct exynos_drm_crtc
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
Let other pieces of the driver access struct exynos_drm_crtc as well.
struct exynos_drm_manager will be merged into struct exynos_drm_crtc, in the sense we will move all its members to exynos_drm_crtc, so to start this conversion exynos_drm_crtc need to be exposed as well.
--- drivers/gpu/drm/exynos/exynos_drm_crtc.c | 30 ------------------------------ drivers/gpu/drm/exynos/exynos_drm_drv.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 30 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_crtc.c +0 -30
@@ -20,36 +20,6 @@#include "exynos_drm_encoder.h" #include "exynos_drm_plane.h" -enum exynos_crtc_mode { -CRTC_MODE_NORMAL ,/* normal mode */ -CRTC_MODE_BLANK ,/* The private plane of crtc is blank */ -}; - -/* -* Exynos specific crtc structure. -* -* @drm_crtc: crtc object. -* @manager: the manager associated with this crtc -* @pipe: a crtc index created at load() with a new crtc object creation -* and the crtc object would be set to private->crtc array -* to get a crtc object corresponding to this pipe from private->crtc -* array when irq interrupt occurred. the reason of using this pipe is that -* drm framework doesn't support multiple irq yet. -* we can refer to the crtc to current hardware interrupt occurred through -* this pipe value. -* @dpms: store the crtc dpms value -* @mode: store the crtc mode value -*/ -struct exynos_drm_crtc { -struct drm_crtc drm_crtc; -struct exynos_drm_manager *manager; -unsigned int pipe; -unsigned int dpms; -enum exynos_crtc_mode mode; -wait_queue_head_t pending_flip_queue; -atomic_t pending_flip; -}; -static void exynos_drm_crtc_dpms (struct drm_crtc *crtc,int mode) {struct exynos_drm_crtc *exynos_crtc =to_exynos_crtc (crtc);
drivers/gpu/drm/exynos/exynos_drm_drv.h +30 -0
@@ -215,6 +215,36 @@ struct exynos_drm_manager {struct exynos_drm_manager_ops *ops; }; +enum exynos_crtc_mode { +CRTC_MODE_NORMAL ,/* normal mode */ +CRTC_MODE_BLANK ,/* The private plane of crtc is blank */ +}; + +/* +* Exynos specific crtc structure. +* +* @drm_crtc: crtc object. +* @manager: the manager associated with this crtc +* @pipe: a crtc index created at load() with a new crtc object creation +* and the crtc object would be set to private->crtc array +* to get a crtc object corresponding to this pipe from private->crtc +* array when irq interrupt occurred. the reason of using this pipe is that +* drm framework doesn't support multiple irq yet. +* we can refer to the crtc to current hardware interrupt occurred through +* this pipe value. +* @dpms: store the crtc dpms value +* @mode: store the crtc mode value +*/ +struct exynos_drm_crtc { +struct drm_crtc drm_crtc; +struct exynos_drm_manager *manager; +unsigned int pipe; +unsigned int dpms; +enum exynos_crtc_mode mode; +wait_queue_head_t pending_flip_queue; +atomic_t pending_flip; +}; +struct exynos_drm_g2d_private {struct device *dev;struct list_head inuse_cmdlist;
Signature · 1 line
1.9.3
PATCH 3/4 drm/exynos: remove exynos_drm_crtc_plane_* wrappers
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
This functions were doing nothing but calling a manager op function, so remove them and call the manager directly.
--- drivers/gpu/drm/exynos/exynos_drm_crtc.c | 33 ------------------------------- drivers/gpu/drm/exynos/exynos_drm_plane.c | 19 ++++++++++++++---- 2 files changed, 15 insertions(+), 37 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_crtc.c +0 -33
@@ -410,39 +410,6 @@ void exynos_drm_crtc_finish_pageflip(struct drm_device *dev, int pipe)spin_unlock_irqrestore (&dev->event_lock, flags); } -void exynos_drm_crtc_plane_mode_set (struct drm_crtc *crtc, -struct exynos_drm_overlay *overlay) -{ -struct exynos_drm_manager *manager =to_exynos_crtc (crtc)->manager; - -if (manager->ops->win_mode_set) - manager->ops->win_mode_set (manager, overlay); -} - -void exynos_drm_crtc_plane_commit (struct drm_crtc *crtc,int zpos) -{ -struct exynos_drm_manager *manager =to_exynos_crtc (crtc)->manager; - -if (manager->ops->win_commit) - manager->ops->win_commit (manager, zpos); -} - -void exynos_drm_crtc_plane_enable (struct drm_crtc *crtc,int zpos) -{ -struct exynos_drm_manager *manager =to_exynos_crtc (crtc)->manager; - -if (manager->ops->win_enable) - manager->ops->win_enable (manager, zpos); -} - -void exynos_drm_crtc_plane_disable (struct drm_crtc *crtc,int zpos) -{ -struct exynos_drm_manager *manager =to_exynos_crtc (crtc)->manager; - -if (manager->ops->win_disable) - manager->ops->win_disable (manager, zpos); -} -void exynos_drm_crtc_complete_scanout (struct drm_framebuffer *fb) {struct exynos_drm_manager *manager;
drivers/gpu/drm/exynos/exynos_drm_plane.c +15 -4
@@ -76,6 +76,7 @@ int exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc, uint32_t src_w, uint32_t src_h) {struct exynos_plane *exynos_plane =to_exynos_plane (plane); +struct exynos_drm_manager *manager =to_exynos_crtc (crtc)->manager;struct exynos_drm_overlay *overlay = &exynos_plane->overlay;unsigned int actual_w;unsigned int actual_h;
@@ -141,7 +142,8 @@ int exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc, plane->crtc = crtc; -exynos_drm_crtc_plane_mode_set (crtc, overlay); +if (manager->ops->win_mode_set) + manager->ops->win_mode_set (manager, overlay);return 0 ; }
@@ -150,26 +152,35 @@ void exynos_plane_commit(struct drm_plane *plane) {struct exynos_plane *exynos_plane =to_exynos_plane (plane);struct exynos_drm_overlay *overlay = &exynos_plane->overlay; +struct exynos_drm_manager *manager =to_exynos_crtc (plane->crtc)->manager; -exynos_drm_crtc_plane_commit (plane->crtc, overlay->zpos); +if (manager->ops->win_commit) + manager->ops->win_commit (manager, overlay->zpos); }void exynos_plane_dpms (struct drm_plane *plane,int mode) {struct exynos_plane *exynos_plane =to_exynos_plane (plane);struct exynos_drm_overlay *overlay = &exynos_plane->overlay; +struct exynos_drm_manager *manager;if (mode ==DRM_MODE_DPMS_ON ) {if (exynos_plane->enabled)return ; -exynos_drm_crtc_plane_enable (plane->crtc, overlay->zpos); + manager =to_exynos_crtc (plane->crtc)->manager; +if (manager->ops->win_enable) + manager->ops->win_enable (manager, overlay->zpos); + exynos_plane->enabled = true; }else {if (!exynos_plane->enabled)return ; -exynos_drm_crtc_plane_disable (plane->crtc, overlay->zpos); + manager =to_exynos_crtc (plane->crtc)->manager; +if (manager->ops->win_disable) + manager->ops->win_disable (manager, overlay->zpos); + exynos_plane->enabled = false; } }
Signature · 6 lines
1.9.3 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/4 drm/exynos: remove struct exynos_drm_overlay
In reply to Gustavo PadovanFrom: Gustavo Padovan <[email protected]>
struct exynos_drm_overlay has no practical advantage nor serves as important piece of the exynos API design. The only place it was used was inside the struct exynos_plane which was just causing a extra access overhead. Users had to access the overlay first and just then get the plane information it contains.
This patch merges struct exynos_drm_overlay into struct exynos_plane. It also renames struct exynos_plane to struct exynos_drm_plane.
The rational is to cut one step to access plane information.
--- drivers/gpu/drm/exynos/exynos_drm_crtc.h | 2 +- drivers/gpu/drm/exynos/exynos_drm_drv.h | 10 +++- drivers/gpu/drm/exynos/exynos_drm_fimd.c | 44 ++++++++-------- drivers/gpu/drm/exynos/exynos_drm_plane.c | 85 ++++++++++++++----------------- drivers/gpu/drm/exynos/exynos_drm_vidi.c | 38 +++++++------- drivers/gpu/drm/exynos/exynos_mixer.c | 50 +++++++++--------- 6 files changed, 112 insertions(+), 117 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_crtc.h +1 -1
@@ -24,7 +24,7 @@ void exynos_drm_crtc_finish_pageflip(struct drm_device *dev, int pipe);void exynos_drm_crtc_complete_scanout (struct drm_framebuffer *fb);void exynos_drm_crtc_plane_mode_set (struct drm_crtc *crtc, -struct exynos_drm_overlay *overlay); +struct exynos_drm_plane *plane);void exynos_drm_crtc_plane_commit (struct drm_crtc *crtc,int zpos);void exynos_drm_crtc_plane_enable (struct drm_crtc *crtc,int zpos);void exynos_drm_crtc_plane_disable (struct drm_crtc *crtc,int zpos);
drivers/gpu/drm/exynos/exynos_drm_drv.h +8 -2
@@ -25,6 +25,7 @@#define to_exynos_crtc (x) container_of(x, struct exynos_drm_crtc,\ drm_crtc) +#define to_exynos_plane (x) container_of(x, struct exynos_drm_plane, base)/* This enumerates device type. */ enum exynos_drm_device_type {
@@ -47,6 +48,7 @@ enum exynos_drm_output_type {/* * Exynos drm common overlay structure. * +* @base: plane object * @fb_x: offset x on a framebuffer to be displayed. * - the unit is screen coordinates. * @fb_y: offset y on a framebuffer to be displayed.
@@ -76,11 +78,14 @@ enum exynos_drm_output_type {* @local_path: in case of lcd type, local path mode on or off. * @transparency: transparency on or off. * @activated: activated or not. +* @enabled: enabled or not. * * this structure is common to exynos SoC and its contents would be copied * to hardware specific overlay info. */ -struct exynos_drm_overlay { + +struct exynos_drm_plane { +struct drm_plane base;unsigned int fb_x;unsigned int fb_y;unsigned int fb_width;
@@ -107,6 +112,7 @@ struct exynos_drm_overlay { bool local_path:1; bool transparency:1; bool activated:1; + bool enabled:1; };/*
@@ -188,7 +194,7 @@ struct exynos_drm_manager_ops {void (*disable_vblank)(struct exynos_drm_manager *mgr);void (*wait_for_vblank)(struct exynos_drm_manager *mgr);void (*win_mode_set)(struct exynos_drm_manager *mgr, -struct exynos_drm_overlay *overlay); +struct exynos_drm_plane *plane);void (*win_commit)(struct exynos_drm_manager *mgr,int zpos);void (*win_enable)(struct exynos_drm_manager *mgr,int zpos);void (*win_disable)(struct exynos_drm_manager *mgr,int zpos);
drivers/gpu/drm/exynos/exynos_drm_fimd.c +22 -22
81 lines not on this page · raw message
drivers/gpu/drm/exynos/exynos_drm_plane.c +37 -48
173 lines not on this page · raw message
drivers/gpu/drm/exynos/exynos_drm_vidi.c +19 -19
@@ -161,43 +161,43 @@ static void vidi_disable_vblank(struct exynos_drm_manager *mgr) }static void vidi_win_mode_set (struct exynos_drm_manager *mgr, -struct exynos_drm_overlay *overlay) +struct exynos_drm_plane *plane) {struct vidi_context *ctx =manager_to_vidi (mgr);struct vidi_win_data *win_data;int win;unsigned long offset; -if (!overlay) { -DRM_ERROR ("overlay is NULL\n" ); +if (!plane) { +DRM_ERROR ("plane is NULL\n" );return ; } - win = overlay->zpos; + win = plane->zpos;if (win ==DEFAULT_ZPOS ) win = ctx->default_win;if (win <0 || win >=WINDOWS_NR )return ; - offset = overlay->fb_x * (overlay->bpp >>3 ); - offset += overlay->fb_y * overlay->pitch; + offset = plane->fb_x * (plane->bpp >>3 ); + offset += plane->fb_y * plane->pitch; -DRM_DEBUG_KMS ("offset = 0x%lx, pitch = %x\n" , offset, overlay->pitch); +DRM_DEBUG_KMS ("offset = 0x%lx, pitch = %x\n" , offset, plane->pitch); win_data = &ctx->win_data[win]; - win_data->offset_x = overlay->crtc_x; - win_data->offset_y = overlay->crtc_y; - win_data->ovl_width = overlay->crtc_width; - win_data->ovl_height = overlay->crtc_height; - win_data->fb_width = overlay->fb_width; - win_data->fb_height = overlay->fb_height; - win_data->dma_addr = overlay->dma_addr[0 ] + offset; - win_data->bpp = overlay->bpp; - win_data->buf_offsize = (overlay->fb_width - overlay->crtc_width) * - (overlay->bpp >>3 ); - win_data->line_size = overlay->crtc_width * (overlay->bpp >>3 ); + win_data->offset_x = plane->crtc_x; + win_data->offset_y = plane->crtc_y; + win_data->ovl_width = plane->crtc_width; + win_data->ovl_height = plane->crtc_height; + win_data->fb_width = plane->fb_width; + win_data->fb_height = plane->fb_height; + win_data->dma_addr = plane->dma_addr[0 ] + offset; + win_data->bpp = plane->bpp; + win_data->buf_offsize = (plane->fb_width - plane->crtc_width) * + (plane->bpp >>3 ); + win_data->line_size = plane->crtc_width * (plane->bpp >>3 );/* * some parts of win_data should be transferred to user side
@@ -210,7 +210,7 @@ static void vidi_win_mode_set(struct exynos_drm_manager *mgr, win_data->ovl_width, win_data->ovl_height);DRM_DEBUG_KMS ("paddr = 0x%lx\n" , (unsigned long )win_data->dma_addr);DRM_DEBUG_KMS ("fb_width = %d, crtc_width = %d\n" , - overlay->fb_width, overlay->crtc_width); + plane->fb_width, plane->crtc_width); }static void vidi_win_commit (struct exynos_drm_manager *mgr,int zpos)
drivers/gpu/drm/exynos/exynos_mixer.c +25 -25
76 lines not on this page · raw message
Signature · 1 line
1.9.3
Hi Inki,
Can you please review this? I also have sent other two patch sets that sits on top of this one. Thanks.
Gustavo
2014-11-24 Gustavo Padovan <[email protected]>:
Quoted 51 lines
From: Gustavo Padovan <[email protected]>
Hi Inki,
In this series I've removed some level of indirection from the
exynos_drm_code. There two moves in these patches, first we remove all exynos_drm_crtc_plane_*() wrappers and call the manager specific functions directly. The other change is the removal of structexynos_drm_overlay(). In my understanding the overlay struct was just storing plane data in a 1:1 relationship so it made sense to merge its fields in structexynos_drm_planeand remove another abstraction from the driver.Next steps:
During our initial investigation on the Exynos DRM driver we've spoted a few abstractions that could be removed to get a more clean and less abstract code.
- structexynos_drm_manager: this is just a helper of structexynos_drm_crtc, I suggest we could merge them both.
- struct*_win_data: Most of the share common fields and could be merged int structexynos_drm_plane.
- some more function wrapper can be removed as well.After these changes intead of looking to manager and
win_datawe will look into crtc and planes. The new names give us more clue about what a piece of code is doing since they are already defined and used by the whole DRM ecossytem.What your thoughts on this? I've seen that you pushed some patches to remove static usage of managers so I would like to check with you which direction are you planning to go with this. I've done some code[0] around this but now it needs a rebase against you exynos-drm-next.
[0] https://git.kernel.org/cgit/linux/kernel/git/padovan/drm-exynos.git/log/?h=cleanup
Gustavo Padovan (4):
drm/exynos: moveto_exynos_crtc()macro to main header drm/exynos: expose structexynos_drm_crtcdrm/exynos: remove exynos_drm_crtc_plane_* wrappers drm/exynos: remove structexynos_drm_overlaydrivers/gpu/drm/exynos/exynos_drm_crtc.c | 66 --------------------- drivers/gpu/drm/exynos/exynos_drm_crtc.h | 2 +- drivers/gpu/drm/exynos/exynos_drm_drv.h | 43 +++++++++++++- drivers/gpu/drm/exynos/exynos_drm_fimd.c | 44 +++++++------- drivers/gpu/drm/exynos/exynos_drm_plane.c | 96 +++++++++++++++---------------- drivers/gpu/drm/exynos/exynos_drm_vidi.c | 38 ++++++------ drivers/gpu/drm/exynos/exynos_mixer.c | 50 ++++++++-------- 7 files changed, 156 insertions(+), 183 deletions(-)Signature · 1 line
1.9.3
Dave Airlie
maintainerQuoted 4 lines · Gustavo Padovan
Hi Inki,
Can you please review this? I also have sent other two patch sets that sits on top of this one. Thanks.
Inki, any plans on when you can get to looking at this?
I think cleaning up exynos so we can get atomic using it is something that will benefit it heavily.
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi Inki,
2014-12-06 Dave Airlie <[email protected]>:
Quoted 10 lines · Gustavo Padovan
Quoted 4 lines
Hi Inki,
Can you please review this? I also have sent other two patch sets that sits on top of this one. Thanks.
Inki, any plans on when you can get to looking at this?
I think cleaning up exynos so we can get atomic using it is something that will benefit it heavily.
Besides these patches I have other two clean up patchsets[0][1] that are very important for atomic support, can you review these two too?
[0] http://www.spinics.net/lists/linux-samsung-soc/msg39614.html
[1] http://www.spinics.net/lists/linux-samsung-soc/msg39632.html
Gustavo
Hi,
Quoted 7 lines · Gustavo Padovan
2014-12-06 Dave Airlie <[email protected]>:
Quoted 1 line
On 2 December 2014 at 22:38, Gustavo Padovan <[email protected]>
Quoted 1 line · wrote:
Quoted 1 line
Can you please review this? I also have sent other two patch sets that
sits on
Quoted 2 lines
Quoted 1 line
top of this one. Thanks.
Quoted 9 lines
Quoted 4 lines
Inki, any plans on when you can get to looking at this?
I think cleaning up exynos so we can get atomic using it is something that will benefit it heavily.
Besides these patches I have other two clean up patchsets[0][1] that are very
important for atomic support, can you review these two too?
It'd be fantastic to get the START == START_S fix merged too:
http://www.spinics.net/lists/linux-samsung-soc/msg40128.html
Cheers,
Daniel
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel