diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2016-06-01 18:06:34 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2016-06-02 11:20:32 -0400 |
commit | 5d943aa6c0d424f4d4a1c96fb2fa2a81e55e1e85 (patch) | |
tree | 775a58cf68b7d87a5d394575d2ecee6c1f9d4e9a | |
parent | b8b5342b699b9b3d1b3455861a68b96424146959 (diff) |
drm: Consolidate crtc arrays in drm_atomic_state
It's silly to have 2 mallocs when we could tie these two together.
Also, Gustavo adds another one in his per-crtc out-fence patches. And
I want to add more stuff here for nonblocking commit helpers.
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-12-git-send-email-daniel.vetter@ffwll.ch
-rw-r--r-- | drivers/gpu/drm/drm_atomic.c | 17 | ||||
-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 | 8 |
4 files changed, 18 insertions, 19 deletions
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 68fd99d2fd01..674b2e490aa9 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c | |||
@@ -45,7 +45,6 @@ void drm_atomic_state_default_release(struct drm_atomic_state *state) | |||
45 | { | 45 | { |
46 | kfree(state->connectors); | 46 | kfree(state->connectors); |
47 | kfree(state->crtcs); | 47 | kfree(state->crtcs); |
48 | kfree(state->crtc_states); | ||
49 | kfree(state->planes); | 48 | kfree(state->planes); |
50 | } | 49 | } |
51 | EXPORT_SYMBOL(drm_atomic_state_default_release); | 50 | EXPORT_SYMBOL(drm_atomic_state_default_release); |
@@ -70,10 +69,6 @@ drm_atomic_state_init(struct drm_device *dev, struct drm_atomic_state *state) | |||
70 | sizeof(*state->crtcs), GFP_KERNEL); | 69 | sizeof(*state->crtcs), GFP_KERNEL); |
71 | if (!state->crtcs) | 70 | if (!state->crtcs) |
72 | goto fail; | 71 | goto fail; |
73 | state->crtc_states = kcalloc(dev->mode_config.num_crtc, | ||
74 | sizeof(*state->crtc_states), GFP_KERNEL); | ||
75 | if (!state->crtc_states) | ||
76 | goto fail; | ||
77 | state->planes = kcalloc(dev->mode_config.num_total_plane, | 72 | state->planes = kcalloc(dev->mode_config.num_total_plane, |
78 | sizeof(*state->planes), GFP_KERNEL); | 73 | sizeof(*state->planes), GFP_KERNEL); |
79 | if (!state->planes) | 74 | if (!state->planes) |
@@ -146,15 +141,15 @@ void drm_atomic_state_default_clear(struct drm_atomic_state *state) | |||
146 | } | 141 | } |
147 | 142 | ||
148 | for (i = 0; i < config->num_crtc; i++) { | 143 | for (i = 0; i < config->num_crtc; i++) { |
149 | struct drm_crtc *crtc = state->crtcs[i]; | 144 | struct drm_crtc *crtc = state->crtcs[i].ptr; |
150 | 145 | ||
151 | if (!crtc) | 146 | if (!crtc) |
152 | continue; | 147 | continue; |
153 | 148 | ||
154 | crtc->funcs->atomic_destroy_state(crtc, | 149 | crtc->funcs->atomic_destroy_state(crtc, |
155 | state->crtc_states[i]); | 150 | state->crtcs[i].state); |
156 | state->crtcs[i] = NULL; | 151 | state->crtcs[i].ptr = NULL; |
157 | state->crtc_states[i] = NULL; | 152 | state->crtcs[i].state = NULL; |
158 | } | 153 | } |
159 | 154 | ||
160 | for (i = 0; i < config->num_total_plane; i++) { | 155 | for (i = 0; i < config->num_total_plane; i++) { |
@@ -264,8 +259,8 @@ drm_atomic_get_crtc_state(struct drm_atomic_state *state, | |||
264 | if (!crtc_state) | 259 | if (!crtc_state) |
265 | return ERR_PTR(-ENOMEM); | 260 | return ERR_PTR(-ENOMEM); |
266 | 261 | ||
267 | state->crtc_states[index] = crtc_state; | 262 | state->crtcs[index].state = crtc_state; |
268 | state->crtcs[index] = crtc; | 263 | state->crtcs[index].ptr = crtc; |
269 | crtc_state->state = state; | 264 | crtc_state->state = state; |
270 | 265 | ||
271 | DRM_DEBUG_ATOMIC("Added [CRTC:%d:%s] %p state to %p\n", | 266 | DRM_DEBUG_ATOMIC("Added [CRTC:%d:%s] %p state to %p\n", |
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index c2ef42c8a947..94509453b3f9 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c | |||
@@ -1578,7 +1578,7 @@ void drm_atomic_helper_swap_state(struct drm_device *dev, | |||
1578 | 1578 | ||
1579 | for_each_crtc_in_state(state, crtc, crtc_state, i) { | 1579 | for_each_crtc_in_state(state, crtc, crtc_state, i) { |
1580 | crtc->state->state = state; | 1580 | crtc->state->state = state; |
1581 | swap(state->crtc_states[i], crtc->state); | 1581 | swap(state->crtcs[i].state, crtc->state); |
1582 | crtc->state->state = NULL; | 1582 | crtc->state->state = NULL; |
1583 | } | 1583 | } |
1584 | 1584 | ||
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h index 8e616d39353b..d9504dfcd1cc 100644 --- a/include/drm/drm_atomic.h +++ b/include/drm/drm_atomic.h | |||
@@ -71,7 +71,7 @@ static inline struct drm_crtc_state * | |||
71 | drm_atomic_get_existing_crtc_state(struct drm_atomic_state *state, | 71 | drm_atomic_get_existing_crtc_state(struct drm_atomic_state *state, |
72 | struct drm_crtc *crtc) | 72 | struct drm_crtc *crtc) |
73 | { | 73 | { |
74 | return state->crtc_states[drm_crtc_index(crtc)]; | 74 | return state->crtcs[drm_crtc_index(crtc)].state; |
75 | } | 75 | } |
76 | 76 | ||
77 | /** | 77 | /** |
@@ -183,11 +183,11 @@ int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state); | |||
183 | (__i)++) \ | 183 | (__i)++) \ |
184 | for_each_if (connector) | 184 | for_each_if (connector) |
185 | 185 | ||
186 | #define for_each_crtc_in_state(state, crtc, crtc_state, __i) \ | 186 | #define for_each_crtc_in_state(__state, crtc, crtc_state, __i) \ |
187 | for ((__i) = 0; \ | 187 | for ((__i) = 0; \ |
188 | (__i) < (state)->dev->mode_config.num_crtc && \ | 188 | (__i) < (__state)->dev->mode_config.num_crtc && \ |
189 | ((crtc) = (state)->crtcs[__i], \ | 189 | ((crtc) = (__state)->crtcs[__i].ptr, \ |
190 | (crtc_state) = (state)->crtc_states[__i], 1); \ | 190 | (crtc_state) = (__state)->crtcs[__i].state, 1); \ |
191 | (__i)++) \ | 191 | (__i)++) \ |
192 | for_each_if (crtc_state) | 192 | for_each_if (crtc_state) |
193 | 193 | ||
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 821398ce52d0..07a410144b07 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h | |||
@@ -1698,6 +1698,11 @@ struct __drm_planes_state { | |||
1698 | struct drm_plane_state *state; | 1698 | struct drm_plane_state *state; |
1699 | }; | 1699 | }; |
1700 | 1700 | ||
1701 | struct __drm_crtcs_state { | ||
1702 | struct drm_crtc *ptr; | ||
1703 | struct drm_crtc_state *state; | ||
1704 | }; | ||
1705 | |||
1701 | struct __drm_connnectors_state { | 1706 | struct __drm_connnectors_state { |
1702 | struct drm_connector *ptr; | 1707 | struct drm_connector *ptr; |
1703 | struct drm_connector_state *state; | 1708 | struct drm_connector_state *state; |
@@ -1722,8 +1727,7 @@ struct drm_atomic_state { | |||
1722 | bool legacy_cursor_update : 1; | 1727 | bool legacy_cursor_update : 1; |
1723 | bool legacy_set_config : 1; | 1728 | bool legacy_set_config : 1; |
1724 | struct __drm_planes_state *planes; | 1729 | struct __drm_planes_state *planes; |
1725 | struct drm_crtc **crtcs; | 1730 | struct __drm_crtcs_state *crtcs; |
1726 | struct drm_crtc_state **crtc_states; | ||
1727 | int num_connector; | 1731 | int num_connector; |
1728 | struct __drm_connnectors_state *connectors; | 1732 | struct __drm_connnectors_state *connectors; |
1729 | 1733 | ||