diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2016-06-01 18:06:32 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2016-06-02 11:20:03 -0400 |
commit | 63e83c1dba5490de84c2d558a2425730db7fb134 (patch) | |
tree | 7e982556c4196a16b80b6f9290ccc06f02df334f | |
parent | 2f196b7c4b82eeff3574eb2999e78add33ef4361 (diff) |
drm: Consolidate connector arrays in drm_atomic_state
It's kinda pointless to have 2 separate mallocs for these. And when we
add more per-connector state in the future it's even more pointless.
Right now there's no such thing planned, but both Gustavo's per-crtc
fence patches, and some nonblocking commit helpers I'm playing around
with will add more per-crtc stuff. It makes sense to also consolidate
connectors, just for consistency.
In the future we can use this to store a pointer to the preceeding
state, making an atomic update entirely free-standing. This will be
needed to be able to queue them up with a depth > 1.
Cc: Gustavo Padovan <gustavo@padovan.org>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1464818821-5736-10-git-send-email-daniel.vetter@ffwll.ch
-rw-r--r-- | drivers/gpu/drm/drm_atomic.c | 27 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_atomic_helper.c | 2 | ||||
-rw-r--r-- | include/drm/drm_atomic.h | 10 | ||||
-rw-r--r-- | include/drm/drm_crtc.h | 11 |
4 files changed, 22 insertions, 28 deletions
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 3ff1ed7b33db..a6395e9654af 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c | |||
@@ -44,7 +44,6 @@ | |||
44 | void drm_atomic_state_default_release(struct drm_atomic_state *state) | 44 | void drm_atomic_state_default_release(struct drm_atomic_state *state) |
45 | { | 45 | { |
46 | kfree(state->connectors); | 46 | kfree(state->connectors); |
47 | kfree(state->connector_states); | ||
48 | kfree(state->crtcs); | 47 | kfree(state->crtcs); |
49 | kfree(state->crtc_states); | 48 | kfree(state->crtc_states); |
50 | kfree(state->planes); | 49 | kfree(state->planes); |
@@ -139,15 +138,15 @@ void drm_atomic_state_default_clear(struct drm_atomic_state *state) | |||
139 | DRM_DEBUG_ATOMIC("Clearing atomic state %p\n", state); | 138 | DRM_DEBUG_ATOMIC("Clearing atomic state %p\n", state); |
140 | 139 | ||
141 | for (i = 0; i < state->num_connector; i++) { | 140 | for (i = 0; i < state->num_connector; i++) { |
142 | struct drm_connector *connector = state->connectors[i]; | 141 | struct drm_connector *connector = state->connectors[i].ptr; |
143 | 142 | ||
144 | if (!connector) | 143 | if (!connector) |
145 | continue; | 144 | continue; |
146 | 145 | ||
147 | connector->funcs->atomic_destroy_state(connector, | 146 | connector->funcs->atomic_destroy_state(connector, |
148 | state->connector_states[i]); | 147 | state->connectors[i].state); |
149 | state->connectors[i] = NULL; | 148 | state->connectors[i].ptr = NULL; |
150 | state->connector_states[i] = NULL; | 149 | state->connectors[i].state = NULL; |
151 | drm_connector_unreference(connector); | 150 | drm_connector_unreference(connector); |
152 | } | 151 | } |
153 | 152 | ||
@@ -896,8 +895,7 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state, | |||
896 | index = drm_connector_index(connector); | 895 | index = drm_connector_index(connector); |
897 | 896 | ||
898 | if (index >= state->num_connector) { | 897 | if (index >= state->num_connector) { |
899 | struct drm_connector **c; | 898 | struct __drm_connnectors_state *c; |
900 | struct drm_connector_state **cs; | ||
901 | int alloc = max(index + 1, config->num_connector); | 899 | int alloc = max(index + 1, config->num_connector); |
902 | 900 | ||
903 | c = krealloc(state->connectors, alloc * sizeof(*state->connectors), GFP_KERNEL); | 901 | c = krealloc(state->connectors, alloc * sizeof(*state->connectors), GFP_KERNEL); |
@@ -908,26 +906,19 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state, | |||
908 | memset(&state->connectors[state->num_connector], 0, | 906 | memset(&state->connectors[state->num_connector], 0, |
909 | sizeof(*state->connectors) * (alloc - state->num_connector)); | 907 | sizeof(*state->connectors) * (alloc - state->num_connector)); |
910 | 908 | ||
911 | cs = krealloc(state->connector_states, alloc * sizeof(*state->connector_states), GFP_KERNEL); | ||
912 | if (!cs) | ||
913 | return ERR_PTR(-ENOMEM); | ||
914 | |||
915 | state->connector_states = cs; | ||
916 | memset(&state->connector_states[state->num_connector], 0, | ||
917 | sizeof(*state->connector_states) * (alloc - state->num_connector)); | ||
918 | state->num_connector = alloc; | 909 | state->num_connector = alloc; |
919 | } | 910 | } |
920 | 911 | ||
921 | if (state->connector_states[index]) | 912 | if (state->connectors[index].state) |
922 | return state->connector_states[index]; | 913 | return state->connectors[index].state; |
923 | 914 | ||
924 | connector_state = connector->funcs->atomic_duplicate_state(connector); | 915 | connector_state = connector->funcs->atomic_duplicate_state(connector); |
925 | if (!connector_state) | 916 | if (!connector_state) |
926 | return ERR_PTR(-ENOMEM); | 917 | return ERR_PTR(-ENOMEM); |
927 | 918 | ||
928 | drm_connector_reference(connector); | 919 | drm_connector_reference(connector); |
929 | state->connector_states[index] = connector_state; | 920 | state->connectors[index].state = connector_state; |
930 | state->connectors[index] = connector; | 921 | state->connectors[index].ptr = connector; |
931 | connector_state->state = state; | 922 | connector_state->state = state; |
932 | 923 | ||
933 | DRM_DEBUG_ATOMIC("Added [CONNECTOR:%d] %p state to %p\n", | 924 | DRM_DEBUG_ATOMIC("Added [CONNECTOR:%d] %p state to %p\n", |
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index a1d9c24c9428..b4e2e988132f 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c | |||
@@ -1572,7 +1572,7 @@ void drm_atomic_helper_swap_state(struct drm_device *dev, | |||
1572 | 1572 | ||
1573 | for_each_connector_in_state(state, connector, conn_state, i) { | 1573 | for_each_connector_in_state(state, connector, conn_state, i) { |
1574 | connector->state->state = state; | 1574 | connector->state->state = state; |
1575 | swap(state->connector_states[i], connector->state); | 1575 | swap(state->connectors[i].state, connector->state); |
1576 | connector->state->state = NULL; | 1576 | connector->state->state = NULL; |
1577 | } | 1577 | } |
1578 | 1578 | ||
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h index 4e97186293be..37478adb6a16 100644 --- a/include/drm/drm_atomic.h +++ b/include/drm/drm_atomic.h | |||
@@ -106,7 +106,7 @@ drm_atomic_get_existing_connector_state(struct drm_atomic_state *state, | |||
106 | if (index >= state->num_connector) | 106 | if (index >= state->num_connector) |
107 | return NULL; | 107 | return NULL; |
108 | 108 | ||
109 | return state->connector_states[index]; | 109 | return state->connectors[index].state; |
110 | } | 110 | } |
111 | 111 | ||
112 | /** | 112 | /** |
@@ -175,11 +175,11 @@ int __must_check drm_atomic_check_only(struct drm_atomic_state *state); | |||
175 | int __must_check drm_atomic_commit(struct drm_atomic_state *state); | 175 | int __must_check drm_atomic_commit(struct drm_atomic_state *state); |
176 | int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state); | 176 | int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state); |
177 | 177 | ||
178 | #define for_each_connector_in_state(state, connector, connector_state, __i) \ | 178 | #define for_each_connector_in_state(__state, connector, connector_state, __i) \ |
179 | for ((__i) = 0; \ | 179 | for ((__i) = 0; \ |
180 | (__i) < (state)->num_connector && \ | 180 | (__i) < (__state)->num_connector && \ |
181 | ((connector) = (state)->connectors[__i], \ | 181 | ((connector) = (__state)->connectors[__i].ptr, \ |
182 | (connector_state) = (state)->connector_states[__i], 1); \ | 182 | (connector_state) = (__state)->connectors[__i].state, 1); \ |
183 | (__i)++) \ | 183 | (__i)++) \ |
184 | for_each_if (connector) | 184 | for_each_if (connector) |
185 | 185 | ||
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index d1559cd04e3d..751990a3bc7a 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h | |||
@@ -1693,6 +1693,11 @@ struct drm_bridge { | |||
1693 | void *driver_private; | 1693 | void *driver_private; |
1694 | }; | 1694 | }; |
1695 | 1695 | ||
1696 | struct __drm_connnectors_state { | ||
1697 | struct drm_connector *ptr; | ||
1698 | struct drm_connector_state *state; | ||
1699 | }; | ||
1700 | |||
1696 | /** | 1701 | /** |
1697 | * struct drm_atomic_state - the global state object for atomic updates | 1702 | * struct drm_atomic_state - the global state object for atomic updates |
1698 | * @dev: parent DRM device | 1703 | * @dev: parent DRM device |
@@ -1704,8 +1709,7 @@ struct drm_bridge { | |||
1704 | * @crtcs: pointer to array of CRTC pointers | 1709 | * @crtcs: pointer to array of CRTC pointers |
1705 | * @crtc_states: pointer to array of CRTC states pointers | 1710 | * @crtc_states: pointer to array of CRTC states pointers |
1706 | * @num_connector: size of the @connectors and @connector_states arrays | 1711 | * @num_connector: size of the @connectors and @connector_states arrays |
1707 | * @connectors: pointer to array of connector pointers | 1712 | * @connectors: pointer to array of structures with per-connector data |
1708 | * @connector_states: pointer to array of connector states pointers | ||
1709 | * @acquire_ctx: acquire context for this atomic modeset state update | 1713 | * @acquire_ctx: acquire context for this atomic modeset state update |
1710 | */ | 1714 | */ |
1711 | struct drm_atomic_state { | 1715 | struct drm_atomic_state { |
@@ -1718,8 +1722,7 @@ struct drm_atomic_state { | |||
1718 | struct drm_crtc **crtcs; | 1722 | struct drm_crtc **crtcs; |
1719 | struct drm_crtc_state **crtc_states; | 1723 | struct drm_crtc_state **crtc_states; |
1720 | int num_connector; | 1724 | int num_connector; |
1721 | struct drm_connector **connectors; | 1725 | struct __drm_connnectors_state *connectors; |
1722 | struct drm_connector_state **connector_states; | ||
1723 | 1726 | ||
1724 | struct drm_modeset_acquire_ctx *acquire_ctx; | 1727 | struct drm_modeset_acquire_ctx *acquire_ctx; |
1725 | }; | 1728 | }; |