]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/gpu/drm/drm_crtc.c
Merge branch 'x86-efi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[karo-tx-linux.git] / drivers / gpu / drm / drm_crtc.c
index 9c797f6fea75118d17104586640754db4f6ce46e..3bdf2a650d9c4c4ec8f65d1c8f0e1ebd3bcc507e 100644 (file)
@@ -68,9 +68,23 @@ void drm_modeset_unlock_all(struct drm_device *dev)
 
        mutex_unlock(&dev->mode_config.mutex);
 }
-
 EXPORT_SYMBOL(drm_modeset_unlock_all);
 
+/**
+ * drm_warn_on_modeset_not_all_locked - check that all modeset locks are locked
+ * @dev: device
+ */
+void drm_warn_on_modeset_not_all_locked(struct drm_device *dev)
+{
+       struct drm_crtc *crtc;
+
+       list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
+               WARN_ON(!mutex_is_locked(&crtc->mutex));
+
+       WARN_ON(!mutex_is_locked(&dev->mode_config.mutex));
+}
+EXPORT_SYMBOL(drm_warn_on_modeset_not_all_locked);
+
 /* Avoid boilerplate.  I'm tired of typing. */
 #define DRM_ENUM_NAME_FN(fnname, list)                         \
        char *fnname(int val)                                   \
@@ -1982,9 +1996,9 @@ int drm_mode_setplane(struct drm_device *dev, void *data,
                                         plane_req->src_w, plane_req->src_h);
        if (!ret) {
                old_fb = plane->fb;
-               fb = NULL;
                plane->crtc = crtc;
                plane->fb = fb;
+               fb = NULL;
        }
        drm_modeset_unlock_all(dev);
 
@@ -2253,7 +2267,7 @@ uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth)
 
        switch (bpp) {
        case 8:
-               fmt = DRM_FORMAT_RGB332;
+               fmt = DRM_FORMAT_C8;
                break;
        case 16:
                if (depth == 15)
@@ -3778,6 +3792,13 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
                /* Keep the old fb, don't unref it. */
                old_fb = NULL;
        } else {
+               /*
+                * Warn if the driver hasn't properly updated the crtc->fb
+                * field to reflect that the new framebuffer is now used.
+                * Failing to do so will screw with the reference counting
+                * on framebuffers.
+                */
+               WARN_ON(crtc->fb != fb);
                /* Unref only the old framebuffer. */
                fb = NULL;
        }
@@ -3856,6 +3877,7 @@ void drm_fb_get_bpp_depth(uint32_t format, unsigned int *depth,
                          int *bpp)
 {
        switch (format) {
+       case DRM_FORMAT_C8:
        case DRM_FORMAT_RGB332:
        case DRM_FORMAT_BGR233:
                *depth = 8;