aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2016-10-27 22:24:14 -0400
committerDave Airlie <airlied@redhat.com>2016-10-27 22:24:14 -0400
commitaa72c26c2b7aec5f60d9f2bf55e2f00632899ed7 (patch)
tree6ba1c8129beff272d08e6aab1c16367aeca02de5
parent07d9a380680d1c0eb51ef87ff2eab5c994949e69 (diff)
parent4da5caa6a6f82cda3193bca855235b87debf78bd (diff)
Merge tag 'drm-misc-fixes-2016-10-27' of git://anongit.freedesktop.org/git/drm-misc into drm-fixes
Set of drm core fixes. Hopefully fixes a bug in MST unplugs in fbdev. * tag 'drm-misc-fixes-2016-10-27' of git://anongit.freedesktop.org/git/drm-misc: drm/dp/mst: Check peer device type before attempting EDID read drm/dp/mst: Clear port->pdt when tearing down the i2c adapter drm/fb-helper: Keep references for the current set of used connectors drm: Don't force all planes to be added to the state due to zpos drm/fb-helper: Fix connector ref leak on error drm/fb-helper: Don't call dirty callback for untouched clips drm: Release reference from blob lookup after replacing property
-rw-r--r--drivers/gpu/drm/drm_atomic.c9
-rw-r--r--drivers/gpu/drm/drm_atomic_helper.c4
-rw-r--r--drivers/gpu/drm/drm_dp_mst_topology.c6
-rw-r--r--drivers/gpu/drm/drm_fb_helper.c68
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_drv.c20
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_drv.h1
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fb.c2
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_du_kms.c12
-rw-r--r--drivers/gpu/drm/sti/sti_drv.c22
-rw-r--r--include/drm/drm_plane.h8
10 files changed, 113 insertions, 39 deletions
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 23739609427d..e6862a744210 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -420,18 +420,21 @@ drm_atomic_replace_property_blob_from_id(struct drm_crtc *crtc,
420 ssize_t expected_size, 420 ssize_t expected_size,
421 bool *replaced) 421 bool *replaced)
422{ 422{
423 struct drm_device *dev = crtc->dev;
424 struct drm_property_blob *new_blob = NULL; 423 struct drm_property_blob *new_blob = NULL;
425 424
426 if (blob_id != 0) { 425 if (blob_id != 0) {
427 new_blob = drm_property_lookup_blob(dev, blob_id); 426 new_blob = drm_property_lookup_blob(crtc->dev, blob_id);
428 if (new_blob == NULL) 427 if (new_blob == NULL)
429 return -EINVAL; 428 return -EINVAL;
430 if (expected_size > 0 && expected_size != new_blob->length) 429
430 if (expected_size > 0 && expected_size != new_blob->length) {
431 drm_property_unreference_blob(new_blob);
431 return -EINVAL; 432 return -EINVAL;
433 }
432 } 434 }
433 435
434 drm_atomic_replace_property_blob(blob, new_blob, replaced); 436 drm_atomic_replace_property_blob(blob, new_blob, replaced);
437 drm_property_unreference_blob(new_blob);
435 438
436 return 0; 439 return 0;
437} 440}
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index c3f83476f996..21f992605541 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -594,10 +594,6 @@ drm_atomic_helper_check_planes(struct drm_device *dev,
594 struct drm_plane_state *plane_state; 594 struct drm_plane_state *plane_state;
595 int i, ret = 0; 595 int i, ret = 0;
596 596
597 ret = drm_atomic_normalize_zpos(dev, state);
598 if (ret)
599 return ret;
600
601 for_each_plane_in_state(state, plane, plane_state, i) { 597 for_each_plane_in_state(state, plane, plane_state, i) {
602 const struct drm_plane_helper_funcs *funcs; 598 const struct drm_plane_helper_funcs *funcs;
603 599
diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index 04e457117980..aa644487749c 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -914,6 +914,7 @@ static void drm_dp_destroy_port(struct kref *kref)
914 /* no need to clean up vcpi 914 /* no need to clean up vcpi
915 * as if we have no connector we never setup a vcpi */ 915 * as if we have no connector we never setup a vcpi */
916 drm_dp_port_teardown_pdt(port, port->pdt); 916 drm_dp_port_teardown_pdt(port, port->pdt);
917 port->pdt = DP_PEER_DEVICE_NONE;
917 } 918 }
918 kfree(port); 919 kfree(port);
919} 920}
@@ -1159,7 +1160,9 @@ static void drm_dp_add_port(struct drm_dp_mst_branch *mstb,
1159 drm_dp_put_port(port); 1160 drm_dp_put_port(port);
1160 goto out; 1161 goto out;
1161 } 1162 }
1162 if (port->port_num >= DP_MST_LOGICAL_PORT_0) { 1163 if ((port->pdt == DP_PEER_DEVICE_DP_LEGACY_CONV ||
1164 port->pdt == DP_PEER_DEVICE_SST_SINK) &&
1165 port->port_num >= DP_MST_LOGICAL_PORT_0) {
1163 port->cached_edid = drm_get_edid(port->connector, &port->aux.ddc); 1166 port->cached_edid = drm_get_edid(port->connector, &port->aux.ddc);
1164 drm_mode_connector_set_tile_property(port->connector); 1167 drm_mode_connector_set_tile_property(port->connector);
1165 } 1168 }
@@ -2919,6 +2922,7 @@ static void drm_dp_destroy_connector_work(struct work_struct *work)
2919 mgr->cbs->destroy_connector(mgr, port->connector); 2922 mgr->cbs->destroy_connector(mgr, port->connector);
2920 2923
2921 drm_dp_port_teardown_pdt(port, port->pdt); 2924 drm_dp_port_teardown_pdt(port, port->pdt);
2925 port->pdt = DP_PEER_DEVICE_NONE;
2922 2926
2923 if (!port->input && port->vcpi.vcpi > 0) { 2927 if (!port->input && port->vcpi.vcpi > 0) {
2924 drm_dp_mst_reset_vcpi_slots(mgr, port); 2928 drm_dp_mst_reset_vcpi_slots(mgr, port);
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 03414bde1f15..6c75e62c0b22 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -131,7 +131,12 @@ int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper)
131 return 0; 131 return 0;
132fail: 132fail:
133 for (i = 0; i < fb_helper->connector_count; i++) { 133 for (i = 0; i < fb_helper->connector_count; i++) {
134 kfree(fb_helper->connector_info[i]); 134 struct drm_fb_helper_connector *fb_helper_connector =
135 fb_helper->connector_info[i];
136
137 drm_connector_unreference(fb_helper_connector->connector);
138
139 kfree(fb_helper_connector);
135 fb_helper->connector_info[i] = NULL; 140 fb_helper->connector_info[i] = NULL;
136 } 141 }
137 fb_helper->connector_count = 0; 142 fb_helper->connector_count = 0;
@@ -603,6 +608,24 @@ int drm_fb_helper_blank(int blank, struct fb_info *info)
603} 608}
604EXPORT_SYMBOL(drm_fb_helper_blank); 609EXPORT_SYMBOL(drm_fb_helper_blank);
605 610
611static void drm_fb_helper_modeset_release(struct drm_fb_helper *helper,
612 struct drm_mode_set *modeset)
613{
614 int i;
615
616 for (i = 0; i < modeset->num_connectors; i++) {
617 drm_connector_unreference(modeset->connectors[i]);
618 modeset->connectors[i] = NULL;
619 }
620 modeset->num_connectors = 0;
621
622 drm_mode_destroy(helper->dev, modeset->mode);
623 modeset->mode = NULL;
624
625 /* FIXME should hold a ref? */
626 modeset->fb = NULL;
627}
628
606static void drm_fb_helper_crtc_free(struct drm_fb_helper *helper) 629static void drm_fb_helper_crtc_free(struct drm_fb_helper *helper)
607{ 630{
608 int i; 631 int i;
@@ -612,10 +635,12 @@ static void drm_fb_helper_crtc_free(struct drm_fb_helper *helper)
612 kfree(helper->connector_info[i]); 635 kfree(helper->connector_info[i]);
613 } 636 }
614 kfree(helper->connector_info); 637 kfree(helper->connector_info);
638
615 for (i = 0; i < helper->crtc_count; i++) { 639 for (i = 0; i < helper->crtc_count; i++) {
616 kfree(helper->crtc_info[i].mode_set.connectors); 640 struct drm_mode_set *modeset = &helper->crtc_info[i].mode_set;
617 if (helper->crtc_info[i].mode_set.mode) 641
618 drm_mode_destroy(helper->dev, helper->crtc_info[i].mode_set.mode); 642 drm_fb_helper_modeset_release(helper, modeset);
643 kfree(modeset->connectors);
619 } 644 }
620 kfree(helper->crtc_info); 645 kfree(helper->crtc_info);
621} 646}
@@ -644,7 +669,9 @@ static void drm_fb_helper_dirty_work(struct work_struct *work)
644 clip->x2 = clip->y2 = 0; 669 clip->x2 = clip->y2 = 0;
645 spin_unlock_irqrestore(&helper->dirty_lock, flags); 670 spin_unlock_irqrestore(&helper->dirty_lock, flags);
646 671
647 helper->fb->funcs->dirty(helper->fb, NULL, 0, 0, &clip_copy, 1); 672 /* call dirty callback only when it has been really touched */
673 if (clip_copy.x1 < clip_copy.x2 && clip_copy.y1 < clip_copy.y2)
674 helper->fb->funcs->dirty(helper->fb, NULL, 0, 0, &clip_copy, 1);
648} 675}
649 676
650/** 677/**
@@ -2088,7 +2115,6 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper)
2088 struct drm_fb_helper_crtc **crtcs; 2115 struct drm_fb_helper_crtc **crtcs;
2089 struct drm_display_mode **modes; 2116 struct drm_display_mode **modes;
2090 struct drm_fb_offset *offsets; 2117 struct drm_fb_offset *offsets;
2091 struct drm_mode_set *modeset;
2092 bool *enabled; 2118 bool *enabled;
2093 int width, height; 2119 int width, height;
2094 int i; 2120 int i;
@@ -2136,45 +2162,35 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper)
2136 2162
2137 /* need to set the modesets up here for use later */ 2163 /* need to set the modesets up here for use later */
2138 /* fill out the connector<->crtc mappings into the modesets */ 2164 /* fill out the connector<->crtc mappings into the modesets */
2139 for (i = 0; i < fb_helper->crtc_count; i++) { 2165 for (i = 0; i < fb_helper->crtc_count; i++)
2140 modeset = &fb_helper->crtc_info[i].mode_set; 2166 drm_fb_helper_modeset_release(fb_helper,
2141 modeset->num_connectors = 0; 2167 &fb_helper->crtc_info[i].mode_set);
2142 modeset->fb = NULL;
2143 }
2144 2168
2145 for (i = 0; i < fb_helper->connector_count; i++) { 2169 for (i = 0; i < fb_helper->connector_count; i++) {
2146 struct drm_display_mode *mode = modes[i]; 2170 struct drm_display_mode *mode = modes[i];
2147 struct drm_fb_helper_crtc *fb_crtc = crtcs[i]; 2171 struct drm_fb_helper_crtc *fb_crtc = crtcs[i];
2148 struct drm_fb_offset *offset = &offsets[i]; 2172 struct drm_fb_offset *offset = &offsets[i];
2149 modeset = &fb_crtc->mode_set; 2173 struct drm_mode_set *modeset = &fb_crtc->mode_set;
2150 2174
2151 if (mode && fb_crtc) { 2175 if (mode && fb_crtc) {
2176 struct drm_connector *connector =
2177 fb_helper->connector_info[i]->connector;
2178
2152 DRM_DEBUG_KMS("desired mode %s set on crtc %d (%d,%d)\n", 2179 DRM_DEBUG_KMS("desired mode %s set on crtc %d (%d,%d)\n",
2153 mode->name, fb_crtc->mode_set.crtc->base.id, offset->x, offset->y); 2180 mode->name, fb_crtc->mode_set.crtc->base.id, offset->x, offset->y);
2181
2154 fb_crtc->desired_mode = mode; 2182 fb_crtc->desired_mode = mode;
2155 fb_crtc->x = offset->x; 2183 fb_crtc->x = offset->x;
2156 fb_crtc->y = offset->y; 2184 fb_crtc->y = offset->y;
2157 if (modeset->mode)
2158 drm_mode_destroy(dev, modeset->mode);
2159 modeset->mode = drm_mode_duplicate(dev, 2185 modeset->mode = drm_mode_duplicate(dev,
2160 fb_crtc->desired_mode); 2186 fb_crtc->desired_mode);
2161 modeset->connectors[modeset->num_connectors++] = fb_helper->connector_info[i]->connector; 2187 drm_connector_reference(connector);
2188 modeset->connectors[modeset->num_connectors++] = connector;
2162 modeset->fb = fb_helper->fb; 2189 modeset->fb = fb_helper->fb;
2163 modeset->x = offset->x; 2190 modeset->x = offset->x;
2164 modeset->y = offset->y; 2191 modeset->y = offset->y;
2165 } 2192 }
2166 } 2193 }
2167
2168 /* Clear out any old modes if there are no more connected outputs. */
2169 for (i = 0; i < fb_helper->crtc_count; i++) {
2170 modeset = &fb_helper->crtc_info[i].mode_set;
2171 if (modeset->num_connectors == 0) {
2172 BUG_ON(modeset->fb);
2173 if (modeset->mode)
2174 drm_mode_destroy(dev, modeset->mode);
2175 modeset->mode = NULL;
2176 }
2177 }
2178out: 2194out:
2179 kfree(crtcs); 2195 kfree(crtcs);
2180 kfree(modes); 2196 kfree(modes);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index def78c8c1780..f86e7c846678 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -262,6 +262,26 @@ int exynos_atomic_commit(struct drm_device *dev, struct drm_atomic_state *state,
262 return 0; 262 return 0;
263} 263}
264 264
265int exynos_atomic_check(struct drm_device *dev,
266 struct drm_atomic_state *state)
267{
268 int ret;
269
270 ret = drm_atomic_helper_check_modeset(dev, state);
271 if (ret)
272 return ret;
273
274 ret = drm_atomic_normalize_zpos(dev, state);
275 if (ret)
276 return ret;
277
278 ret = drm_atomic_helper_check_planes(dev, state);
279 if (ret)
280 return ret;
281
282 return ret;
283}
284
265static int exynos_drm_open(struct drm_device *dev, struct drm_file *file) 285static int exynos_drm_open(struct drm_device *dev, struct drm_file *file)
266{ 286{
267 struct drm_exynos_file_private *file_priv; 287 struct drm_exynos_file_private *file_priv;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index d215149e737b..80c4d5b81689 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -301,6 +301,7 @@ static inline int exynos_dpi_bind(struct drm_device *dev,
301 301
302int exynos_atomic_commit(struct drm_device *dev, struct drm_atomic_state *state, 302int exynos_atomic_commit(struct drm_device *dev, struct drm_atomic_state *state,
303 bool nonblock); 303 bool nonblock);
304int exynos_atomic_check(struct drm_device *dev, struct drm_atomic_state *state);
304 305
305 306
306extern struct platform_driver fimd_driver; 307extern struct platform_driver fimd_driver;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fb.c b/drivers/gpu/drm/exynos/exynos_drm_fb.c
index 40ce841eb952..23cce0a3f5fc 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fb.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fb.c
@@ -190,7 +190,7 @@ dma_addr_t exynos_drm_fb_dma_addr(struct drm_framebuffer *fb, int index)
190static const struct drm_mode_config_funcs exynos_drm_mode_config_funcs = { 190static const struct drm_mode_config_funcs exynos_drm_mode_config_funcs = {
191 .fb_create = exynos_user_fb_create, 191 .fb_create = exynos_user_fb_create,
192 .output_poll_changed = exynos_drm_output_poll_changed, 192 .output_poll_changed = exynos_drm_output_poll_changed,
193 .atomic_check = drm_atomic_helper_check, 193 .atomic_check = exynos_atomic_check,
194 .atomic_commit = exynos_atomic_commit, 194 .atomic_commit = exynos_atomic_commit,
195}; 195};
196 196
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index bd9c3bb9252c..392c7e6de042 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -231,8 +231,16 @@ static int rcar_du_atomic_check(struct drm_device *dev,
231 struct rcar_du_device *rcdu = dev->dev_private; 231 struct rcar_du_device *rcdu = dev->dev_private;
232 int ret; 232 int ret;
233 233
234 ret = drm_atomic_helper_check(dev, state); 234 ret = drm_atomic_helper_check_modeset(dev, state);
235 if (ret < 0) 235 if (ret)
236 return ret;
237
238 ret = drm_atomic_normalize_zpos(dev, state);
239 if (ret)
240 return ret;
241
242 ret = drm_atomic_helper_check_planes(dev, state);
243 if (ret)
236 return ret; 244 return ret;
237 245
238 if (rcar_du_has(rcdu, RCAR_DU_FEATURE_VSP1_SOURCE)) 246 if (rcar_du_has(rcdu, RCAR_DU_FEATURE_VSP1_SOURCE))
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
index 2784919a7366..9df308565f6c 100644
--- a/drivers/gpu/drm/sti/sti_drv.c
+++ b/drivers/gpu/drm/sti/sti_drv.c
@@ -195,6 +195,26 @@ static void sti_atomic_work(struct work_struct *work)
195 sti_atomic_complete(private, private->commit.state); 195 sti_atomic_complete(private, private->commit.state);
196} 196}
197 197
198static int sti_atomic_check(struct drm_device *dev,
199 struct drm_atomic_state *state)
200{
201 int ret;
202
203 ret = drm_atomic_helper_check_modeset(dev, state);
204 if (ret)
205 return ret;
206
207 ret = drm_atomic_normalize_zpos(dev, state);
208 if (ret)
209 return ret;
210
211 ret = drm_atomic_helper_check_planes(dev, state);
212 if (ret)
213 return ret;
214
215 return ret;
216}
217
198static int sti_atomic_commit(struct drm_device *drm, 218static int sti_atomic_commit(struct drm_device *drm,
199 struct drm_atomic_state *state, bool nonblock) 219 struct drm_atomic_state *state, bool nonblock)
200{ 220{
@@ -248,7 +268,7 @@ static void sti_output_poll_changed(struct drm_device *ddev)
248static const struct drm_mode_config_funcs sti_mode_config_funcs = { 268static const struct drm_mode_config_funcs sti_mode_config_funcs = {
249 .fb_create = drm_fb_cma_create, 269 .fb_create = drm_fb_cma_create,
250 .output_poll_changed = sti_output_poll_changed, 270 .output_poll_changed = sti_output_poll_changed,
251 .atomic_check = drm_atomic_helper_check, 271 .atomic_check = sti_atomic_check,
252 .atomic_commit = sti_atomic_commit, 272 .atomic_commit = sti_atomic_commit,
253}; 273};
254 274
diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
index 43cf193e54d6..8b4dc62470ff 100644
--- a/include/drm/drm_plane.h
+++ b/include/drm/drm_plane.h
@@ -47,8 +47,14 @@ struct drm_crtc;
47 * @src_h: height of visible portion of plane (in 16.16) 47 * @src_h: height of visible portion of plane (in 16.16)
48 * @rotation: rotation of the plane 48 * @rotation: rotation of the plane
49 * @zpos: priority of the given plane on crtc (optional) 49 * @zpos: priority of the given plane on crtc (optional)
50 * Note that multiple active planes on the same crtc can have an identical
51 * zpos value. The rule to solving the conflict is to compare the plane
52 * object IDs; the plane with a higher ID must be stacked on top of a
53 * plane with a lower ID.
50 * @normalized_zpos: normalized value of zpos: unique, range from 0 to N-1 54 * @normalized_zpos: normalized value of zpos: unique, range from 0 to N-1
51 * where N is the number of active planes for given crtc 55 * where N is the number of active planes for given crtc. Note that
56 * the driver must call drm_atomic_normalize_zpos() to update this before
57 * it can be trusted.
52 * @src: clipped source coordinates of the plane (in 16.16) 58 * @src: clipped source coordinates of the plane (in 16.16)
53 * @dst: clipped destination coordinates of the plane 59 * @dst: clipped destination coordinates of the plane
54 * @visible: visibility of the plane 60 * @visible: visibility of the plane