Commit 77ef3857 authored by Daniel Vetter's avatar Daniel Vetter Committed by Alex Deucher
Browse files

drm/modeset-lock: Take the modeset BKL for legacy drivers

This fell off in the conversion in

commit 9bcaa3fe
Author: Michal Orzel <michalorzel.eng@gmail.com>
Date:   Tue Apr 28 19:10:04 2020 +0200

    drm: Replace drm_modeset_lock/unlock_all with DRM_MODESET_LOCK_ALL_* helpers

but it's caught by the drm_warn_on_modeset_not_all_locked() that the
legacy modeset code uses. Since this is the bkl and it's unclear
what's all protected, play it safe and grab it again for legacy
drivers.

Unfortunately this means we need to sprinkle a few more #includes
around.

Also we need to add the drm_device as a parameter to the _END macro.

Finally remove the mute_lock() from setcrtc, since that's now done by
the macro.

Cc: Alex Deucher <alexdeucher@gmail.com>
References: https://gitlab.freedesktop.org/drm/amd/-/issues/1224


Fixes: 9bcaa3fe ("drm: Replace drm_modeset_lock/unlock_all with DRM_MODESET_LOCK_ALL_* helpers")
Cc: Michal Orzel <michalorzel.eng@gmail.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v5.8+
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200814093842.3048472-1-daniel.vetter@ffwll.ch
parent 88fee1c9
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
#include <drm/drm_bridge.h>
#include <drm/drm_damage_helper.h>
#include <drm/drm_device.h>
#include <drm/drm_drv.h>
#include <drm/drm_plane_helper.h>
#include <drm/drm_print.h>
#include <drm/drm_self_refresh_helper.h>
@@ -3105,7 +3106,7 @@ void drm_atomic_helper_shutdown(struct drm_device *dev)
	if (ret)
		DRM_ERROR("Disabling all crtc's during unload failed with %i\n", ret);

	DRM_MODESET_LOCK_ALL_END(ctx, ret);
	DRM_MODESET_LOCK_ALL_END(dev, ctx, ret);
}
EXPORT_SYMBOL(drm_atomic_helper_shutdown);

@@ -3245,7 +3246,7 @@ struct drm_atomic_state *drm_atomic_helper_suspend(struct drm_device *dev)
	}

unlock:
	DRM_MODESET_LOCK_ALL_END(ctx, err);
	DRM_MODESET_LOCK_ALL_END(dev, ctx, err);
	if (err)
		return ERR_PTR(err);

@@ -3326,7 +3327,7 @@ int drm_atomic_helper_resume(struct drm_device *dev,

	err = drm_atomic_helper_commit_duplicated_state(state, &ctx);

	DRM_MODESET_LOCK_ALL_END(ctx, err);
	DRM_MODESET_LOCK_ALL_END(dev, ctx, err);
	drm_atomic_state_put(state);

	return err;
+1 −1
Original line number Diff line number Diff line
@@ -294,7 +294,7 @@ int drm_mode_gamma_set_ioctl(struct drm_device *dev,
				     crtc->gamma_size, &ctx);

out:
	DRM_MODESET_LOCK_ALL_END(ctx, ret);
	DRM_MODESET_LOCK_ALL_END(dev, ctx, ret);
	return ret;

}
+1 −3
Original line number Diff line number Diff line
@@ -561,7 +561,6 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
	if (crtc_req->mode_valid && !drm_lease_held(file_priv, plane->base.id))
		return -EACCES;

	mutex_lock(&crtc->dev->mode_config.mutex);
	DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx,
				   DRM_MODESET_ACQUIRE_INTERRUPTIBLE, ret);

@@ -728,8 +727,7 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
	fb = NULL;
	mode = NULL;

	DRM_MODESET_LOCK_ALL_END(ctx, ret);
	mutex_unlock(&crtc->dev->mode_config.mutex);
	DRM_MODESET_LOCK_ALL_END(dev, ctx, ret);

	return ret;
}
+2 −2
Original line number Diff line number Diff line
@@ -428,7 +428,7 @@ int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data,
out_unref:
	drm_mode_object_put(obj);
out:
	DRM_MODESET_LOCK_ALL_END(ctx, ret);
	DRM_MODESET_LOCK_ALL_END(dev, ctx, ret);
	return ret;
}

@@ -470,7 +470,7 @@ static int set_property_legacy(struct drm_mode_object *obj,
		break;
	}
	drm_property_change_valid_put(prop, ref);
	DRM_MODESET_LOCK_ALL_END(ctx, ret);
	DRM_MODESET_LOCK_ALL_END(dev, ctx, ret);

	return ret;
}
+1 −1
Original line number Diff line number Diff line
@@ -791,7 +791,7 @@ static int setplane_internal(struct drm_plane *plane,
					  crtc_x, crtc_y, crtc_w, crtc_h,
					  src_x, src_y, src_w, src_h, &ctx);

	DRM_MODESET_LOCK_ALL_END(ctx, ret);
	DRM_MODESET_LOCK_ALL_END(plane->dev, ctx, ret);

	return ret;
}
Loading