Commit a4eff9aa authored by Daniel Vetter's avatar Daniel Vetter

drm: Add acquire ctx parameter to ->set_config

Surprisingly a lot of legacy drivers roll their own, for
runtime pm and because vmwgfx.

Also make nouveau's set_config static while at it.

Cc: Sinclair Yeh <syeh@vmware.com>
Cc: Thomas Hellstrom <thellstrom@vmware.com>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Reviewed-by: default avatarHarry Wentland <harry.wentland@amd.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20170322215058.8671-19-daniel.vetter@ffwll.ch
parent 2ceb585a
...@@ -333,7 +333,8 @@ int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc, ...@@ -333,7 +333,8 @@ int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc,
return 0; return 0;
} }
int amdgpu_crtc_set_config(struct drm_mode_set *set) int amdgpu_crtc_set_config(struct drm_mode_set *set,
struct drm_modeset_acquire_ctx *ctx)
{ {
struct drm_device *dev; struct drm_device *dev;
struct amdgpu_device *adev; struct amdgpu_device *adev;
...@@ -350,7 +351,7 @@ int amdgpu_crtc_set_config(struct drm_mode_set *set) ...@@ -350,7 +351,7 @@ int amdgpu_crtc_set_config(struct drm_mode_set *set)
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = drm_crtc_helper_set_config(set); ret = drm_crtc_helper_set_config(set, ctx);
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
if (crtc->enabled) if (crtc->enabled)
......
...@@ -590,7 +590,8 @@ int amdgpu_align_pitch(struct amdgpu_device *adev, int width, int bpp, bool tile ...@@ -590,7 +590,8 @@ int amdgpu_align_pitch(struct amdgpu_device *adev, int width, int bpp, bool tile
/* amdgpu_display.c */ /* amdgpu_display.c */
void amdgpu_print_display_setup(struct drm_device *dev); void amdgpu_print_display_setup(struct drm_device *dev);
int amdgpu_modeset_create_props(struct amdgpu_device *adev); int amdgpu_modeset_create_props(struct amdgpu_device *adev);
int amdgpu_crtc_set_config(struct drm_mode_set *set); int amdgpu_crtc_set_config(struct drm_mode_set *set,
struct drm_modeset_acquire_ctx *ctx);
int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc, int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc,
struct drm_framebuffer *fb, struct drm_framebuffer *fb,
struct drm_pending_vblank_event *event, struct drm_pending_vblank_event *event,
......
...@@ -2265,6 +2265,7 @@ static int update_output_state(struct drm_atomic_state *state, ...@@ -2265,6 +2265,7 @@ static int update_output_state(struct drm_atomic_state *state,
/** /**
* drm_atomic_helper_set_config - set a new config from userspace * drm_atomic_helper_set_config - set a new config from userspace
* @set: mode set configuration * @set: mode set configuration
* @ctx: lock acquisition context
* *
* Provides a default crtc set_config handler using the atomic driver interface. * Provides a default crtc set_config handler using the atomic driver interface.
* *
...@@ -2277,7 +2278,8 @@ static int update_output_state(struct drm_atomic_state *state, ...@@ -2277,7 +2278,8 @@ static int update_output_state(struct drm_atomic_state *state,
* Returns: * Returns:
* Returns 0 on success, negative errno numbers on failure. * Returns 0 on success, negative errno numbers on failure.
*/ */
int drm_atomic_helper_set_config(struct drm_mode_set *set) int drm_atomic_helper_set_config(struct drm_mode_set *set,
struct drm_modeset_acquire_ctx *ctx)
{ {
struct drm_atomic_state *state; struct drm_atomic_state *state;
struct drm_crtc *crtc = set->crtc; struct drm_crtc *crtc = set->crtc;
......
...@@ -465,7 +465,7 @@ static int __drm_mode_set_config_internal(struct drm_mode_set *set, ...@@ -465,7 +465,7 @@ static int __drm_mode_set_config_internal(struct drm_mode_set *set,
fb = set->fb; fb = set->fb;
ret = crtc->funcs->set_config(set); ret = crtc->funcs->set_config(set, ctx);
if (ret == 0) { if (ret == 0) {
crtc->primary->crtc = crtc; crtc->primary->crtc = crtc;
crtc->primary->fb = fb; crtc->primary->fb = fb;
......
...@@ -476,6 +476,7 @@ drm_crtc_helper_disable(struct drm_crtc *crtc) ...@@ -476,6 +476,7 @@ drm_crtc_helper_disable(struct drm_crtc *crtc)
/** /**
* drm_crtc_helper_set_config - set a new config from userspace * drm_crtc_helper_set_config - set a new config from userspace
* @set: mode set configuration * @set: mode set configuration
* @ctx: lock acquire context, not used here
* *
* The drm_crtc_helper_set_config() helper function implements the of * The drm_crtc_helper_set_config() helper function implements the of
* &drm_crtc_funcs.set_config callback for drivers using the legacy CRTC * &drm_crtc_funcs.set_config callback for drivers using the legacy CRTC
...@@ -510,7 +511,8 @@ drm_crtc_helper_disable(struct drm_crtc *crtc) ...@@ -510,7 +511,8 @@ drm_crtc_helper_disable(struct drm_crtc *crtc)
* Returns: * Returns:
* Returns 0 on success, negative errno numbers on failure. * Returns 0 on success, negative errno numbers on failure.
*/ */
int drm_crtc_helper_set_config(struct drm_mode_set *set) int drm_crtc_helper_set_config(struct drm_mode_set *set,
struct drm_modeset_acquire_ctx *ctx)
{ {
struct drm_device *dev; struct drm_device *dev;
struct drm_crtc **save_encoder_crtcs, *new_crtc; struct drm_crtc **save_encoder_crtcs, *new_crtc;
......
...@@ -371,7 +371,7 @@ int drm_primary_helper_update(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -371,7 +371,7 @@ int drm_primary_helper_update(struct drm_plane *plane, struct drm_crtc *crtc,
* drm_mode_setplane() already handles the basic refcounting for the * drm_mode_setplane() already handles the basic refcounting for the
* framebuffers involved in this operation. * framebuffers involved in this operation.
*/ */
ret = crtc->funcs->set_config(&set); ret = crtc->funcs->set_config(&set, ctx);
kfree(connector_list); kfree(connector_list);
return ret; return ret;
......
...@@ -514,17 +514,18 @@ void gma_crtc_destroy(struct drm_crtc *crtc) ...@@ -514,17 +514,18 @@ void gma_crtc_destroy(struct drm_crtc *crtc)
kfree(gma_crtc); kfree(gma_crtc);
} }
int gma_crtc_set_config(struct drm_mode_set *set) int gma_crtc_set_config(struct drm_mode_set *set,
struct drm_modeset_acquire_ctx *ctx)
{ {
struct drm_device *dev = set->crtc->dev; struct drm_device *dev = set->crtc->dev;
struct drm_psb_private *dev_priv = dev->dev_private; struct drm_psb_private *dev_priv = dev->dev_private;
int ret; int ret;
if (!dev_priv->rpm_enabled) if (!dev_priv->rpm_enabled)
return drm_crtc_helper_set_config(set); return drm_crtc_helper_set_config(set, ctx);
pm_runtime_forbid(&dev->pdev->dev); pm_runtime_forbid(&dev->pdev->dev);
ret = drm_crtc_helper_set_config(set); ret = drm_crtc_helper_set_config(set, ctx);
pm_runtime_allow(&dev->pdev->dev); pm_runtime_allow(&dev->pdev->dev);
return ret; return ret;
......
...@@ -79,7 +79,8 @@ extern void gma_crtc_prepare(struct drm_crtc *crtc); ...@@ -79,7 +79,8 @@ extern void gma_crtc_prepare(struct drm_crtc *crtc);
extern void gma_crtc_commit(struct drm_crtc *crtc); extern void gma_crtc_commit(struct drm_crtc *crtc);
extern void gma_crtc_disable(struct drm_crtc *crtc); extern void gma_crtc_disable(struct drm_crtc *crtc);
extern void gma_crtc_destroy(struct drm_crtc *crtc); extern void gma_crtc_destroy(struct drm_crtc *crtc);
extern int gma_crtc_set_config(struct drm_mode_set *set); extern int gma_crtc_set_config(struct drm_mode_set *set,
struct drm_modeset_acquire_ctx *ctx);
extern void gma_crtc_save(struct drm_crtc *crtc); extern void gma_crtc_save(struct drm_crtc *crtc);
extern void gma_crtc_restore(struct drm_crtc *crtc); extern void gma_crtc_restore(struct drm_crtc *crtc);
......
...@@ -1031,8 +1031,9 @@ nv04_crtc_cursor_move(struct drm_crtc *crtc, int x, int y) ...@@ -1031,8 +1031,9 @@ nv04_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
return 0; return 0;
} }
int static int
nouveau_crtc_set_config(struct drm_mode_set *set) nouveau_crtc_set_config(struct drm_mode_set *set,
struct drm_modeset_acquire_ctx *ctx)
{ {
struct drm_device *dev; struct drm_device *dev;
struct nouveau_drm *drm; struct nouveau_drm *drm;
...@@ -1049,7 +1050,7 @@ nouveau_crtc_set_config(struct drm_mode_set *set) ...@@ -1049,7 +1050,7 @@ nouveau_crtc_set_config(struct drm_mode_set *set)
if (ret < 0 && ret != -EACCES) if (ret < 0 && ret != -EACCES)
return ret; return ret;
ret = drm_crtc_helper_set_config(set); ret = drm_crtc_helper_set_config(set, ctx);
drm = nouveau_drm(dev); drm = nouveau_drm(dev);
......
...@@ -88,7 +88,6 @@ int nouveau_display_dumb_map_offset(struct drm_file *, struct drm_device *, ...@@ -88,7 +88,6 @@ int nouveau_display_dumb_map_offset(struct drm_file *, struct drm_device *,
void nouveau_hdmi_mode_set(struct drm_encoder *, struct drm_display_mode *); void nouveau_hdmi_mode_set(struct drm_encoder *, struct drm_display_mode *);
int nouveau_crtc_set_config(struct drm_mode_set *set);
#ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT #ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT
extern int nouveau_backlight_init(struct drm_device *); extern int nouveau_backlight_init(struct drm_device *);
extern void nouveau_backlight_exit(struct drm_device *); extern void nouveau_backlight_exit(struct drm_device *);
......
...@@ -624,7 +624,8 @@ static int radeon_crtc_page_flip_target(struct drm_crtc *crtc, ...@@ -624,7 +624,8 @@ static int radeon_crtc_page_flip_target(struct drm_crtc *crtc,
} }
static int static int
radeon_crtc_set_config(struct drm_mode_set *set) radeon_crtc_set_config(struct drm_mode_set *set,
struct drm_modeset_acquire_ctx *ctx)
{ {
struct drm_device *dev; struct drm_device *dev;
struct radeon_device *rdev; struct radeon_device *rdev;
...@@ -641,7 +642,7 @@ radeon_crtc_set_config(struct drm_mode_set *set) ...@@ -641,7 +642,7 @@ radeon_crtc_set_config(struct drm_mode_set *set)
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = drm_crtc_helper_set_config(set); ret = drm_crtc_helper_set_config(set, ctx);
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
if (crtc->enabled) if (crtc->enabled)
......
...@@ -208,7 +208,8 @@ static int vmw_ldu_add_active(struct vmw_private *vmw_priv, ...@@ -208,7 +208,8 @@ static int vmw_ldu_add_active(struct vmw_private *vmw_priv,
return 0; return 0;
} }
static int vmw_ldu_crtc_set_config(struct drm_mode_set *set) static int vmw_ldu_crtc_set_config(struct drm_mode_set *set,
struct drm_modeset_acquire_ctx *ctx)
{ {
struct vmw_private *dev_priv; struct vmw_private *dev_priv;
struct vmw_legacy_display_unit *ldu; struct vmw_legacy_display_unit *ldu;
......
...@@ -248,7 +248,8 @@ static int vmw_sou_backing_alloc(struct vmw_private *dev_priv, ...@@ -248,7 +248,8 @@ static int vmw_sou_backing_alloc(struct vmw_private *dev_priv,
return ret; return ret;
} }
static int vmw_sou_crtc_set_config(struct drm_mode_set *set) static int vmw_sou_crtc_set_config(struct drm_mode_set *set,
struct drm_modeset_acquire_ctx *ctx)
{ {
struct vmw_private *dev_priv; struct vmw_private *dev_priv;
struct vmw_screen_object_unit *sou; struct vmw_screen_object_unit *sou;
......
...@@ -509,7 +509,8 @@ static int vmw_stdu_bind_fb(struct vmw_private *dev_priv, ...@@ -509,7 +509,8 @@ static int vmw_stdu_bind_fb(struct vmw_private *dev_priv,
* RETURNS: * RETURNS:
* 0 on success, error code otherwise * 0 on success, error code otherwise
*/ */
static int vmw_stdu_crtc_set_config(struct drm_mode_set *set) static int vmw_stdu_crtc_set_config(struct drm_mode_set *set,
struct drm_modeset_acquire_ctx *ctx)
{ {
struct vmw_private *dev_priv; struct vmw_private *dev_priv;
struct vmw_framebuffer *vfb; struct vmw_framebuffer *vfb;
......
...@@ -100,7 +100,8 @@ int drm_atomic_helper_disable_plane(struct drm_plane *plane, ...@@ -100,7 +100,8 @@ int drm_atomic_helper_disable_plane(struct drm_plane *plane,
struct drm_modeset_acquire_ctx *ctx); struct drm_modeset_acquire_ctx *ctx);
int __drm_atomic_helper_disable_plane(struct drm_plane *plane, int __drm_atomic_helper_disable_plane(struct drm_plane *plane,
struct drm_plane_state *plane_state); struct drm_plane_state *plane_state);
int drm_atomic_helper_set_config(struct drm_mode_set *set); int drm_atomic_helper_set_config(struct drm_mode_set *set,
struct drm_modeset_acquire_ctx *ctx);
int __drm_atomic_helper_set_config(struct drm_mode_set *set, int __drm_atomic_helper_set_config(struct drm_mode_set *set,
struct drm_atomic_state *state); struct drm_atomic_state *state);
......
...@@ -347,7 +347,8 @@ struct drm_crtc_funcs { ...@@ -347,7 +347,8 @@ struct drm_crtc_funcs {
* *
* 0 on success or a negative error code on failure. * 0 on success or a negative error code on failure.
*/ */
int (*set_config)(struct drm_mode_set *set); int (*set_config)(struct drm_mode_set *set,
struct drm_modeset_acquire_ctx *ctx);
/** /**
* @page_flip: * @page_flip:
......
...@@ -44,7 +44,8 @@ ...@@ -44,7 +44,8 @@
#include <drm/drm_modeset_helper.h> #include <drm/drm_modeset_helper.h>
void drm_helper_disable_unused_functions(struct drm_device *dev); void drm_helper_disable_unused_functions(struct drm_device *dev);
int drm_crtc_helper_set_config(struct drm_mode_set *set); int drm_crtc_helper_set_config(struct drm_mode_set *set,
struct drm_modeset_acquire_ctx *ctx);
bool drm_crtc_helper_set_mode(struct drm_crtc *crtc, bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
struct drm_display_mode *mode, struct drm_display_mode *mode,
int x, int y, int x, int y,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment