Commit c0c36b94 authored by Chris Wilson's avatar Chris Wilson Committed by Daniel Vetter

drm/i915: Return the real error code from intel_set_mode()

Note: This patch also adds a little helper intel_crtc_restore_mode for
the common case where we do a full modeset but with the same
parameters, e.g. to undo bios damage or update a property.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarRodrigo Vivi <rodrigo.vivi@gmail.com>
[danvet: Added note.]
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 1c45140d
...@@ -6313,7 +6313,7 @@ bool intel_get_load_detect_pipe(struct drm_connector *connector, ...@@ -6313,7 +6313,7 @@ bool intel_get_load_detect_pipe(struct drm_connector *connector,
return false; return false;
} }
if (!intel_set_mode(crtc, mode, 0, 0, fb)) { if (intel_set_mode(crtc, mode, 0, 0, fb)) {
DRM_DEBUG_KMS("failed to set mode on load-detect pipe\n"); DRM_DEBUG_KMS("failed to set mode on load-detect pipe\n");
if (old->release_fb) if (old->release_fb)
old->release_fb->funcs->destroy(old->release_fb); old->release_fb->funcs->destroy(old->release_fb);
...@@ -7426,7 +7426,7 @@ intel_modeset_check_state(struct drm_device *dev) ...@@ -7426,7 +7426,7 @@ intel_modeset_check_state(struct drm_device *dev)
} }
} }
bool intel_set_mode(struct drm_crtc *crtc, int intel_set_mode(struct drm_crtc *crtc,
struct drm_display_mode *mode, struct drm_display_mode *mode,
int x, int y, struct drm_framebuffer *fb) int x, int y, struct drm_framebuffer *fb)
{ {
...@@ -7435,13 +7435,11 @@ bool intel_set_mode(struct drm_crtc *crtc, ...@@ -7435,13 +7435,11 @@ bool intel_set_mode(struct drm_crtc *crtc,
struct drm_display_mode *adjusted_mode, *saved_mode, *saved_hwmode; struct drm_display_mode *adjusted_mode, *saved_mode, *saved_hwmode;
struct intel_crtc *intel_crtc; struct intel_crtc *intel_crtc;
unsigned disable_pipes, prepare_pipes, modeset_pipes; unsigned disable_pipes, prepare_pipes, modeset_pipes;
bool ret = true; int ret = 0;
saved_mode = kmalloc(2 * sizeof(*saved_mode), GFP_KERNEL); saved_mode = kmalloc(2 * sizeof(*saved_mode), GFP_KERNEL);
if (!saved_mode) { if (!saved_mode)
DRM_ERROR("i915: Could not allocate saved display mode.\n"); return -ENOMEM;
return false;
}
saved_hwmode = saved_mode + 1; saved_hwmode = saved_mode + 1;
intel_modeset_affected_pipes(crtc, &modeset_pipes, intel_modeset_affected_pipes(crtc, &modeset_pipes,
...@@ -7465,7 +7463,7 @@ bool intel_set_mode(struct drm_crtc *crtc, ...@@ -7465,7 +7463,7 @@ bool intel_set_mode(struct drm_crtc *crtc,
if (modeset_pipes) { if (modeset_pipes) {
adjusted_mode = intel_modeset_adjusted_mode(crtc, mode); adjusted_mode = intel_modeset_adjusted_mode(crtc, mode);
if (IS_ERR(adjusted_mode)) { if (IS_ERR(adjusted_mode)) {
ret = false; ret = PTR_ERR(adjusted_mode);
goto out; goto out;
} }
} }
...@@ -7492,10 +7490,10 @@ bool intel_set_mode(struct drm_crtc *crtc, ...@@ -7492,10 +7490,10 @@ bool intel_set_mode(struct drm_crtc *crtc,
* on the DPLL. * on the DPLL.
*/ */
for_each_intel_crtc_masked(dev, modeset_pipes, intel_crtc) { for_each_intel_crtc_masked(dev, modeset_pipes, intel_crtc) {
ret = !intel_crtc_mode_set(&intel_crtc->base, ret = intel_crtc_mode_set(&intel_crtc->base,
mode, adjusted_mode, mode, adjusted_mode,
x, y, fb); x, y, fb);
if (!ret) if (ret)
goto done; goto done;
} }
...@@ -7517,7 +7515,7 @@ bool intel_set_mode(struct drm_crtc *crtc, ...@@ -7517,7 +7515,7 @@ bool intel_set_mode(struct drm_crtc *crtc,
/* FIXME: add subpixel order */ /* FIXME: add subpixel order */
done: done:
drm_mode_destroy(dev, adjusted_mode); drm_mode_destroy(dev, adjusted_mode);
if (!ret && crtc->enabled) { if (ret && crtc->enabled) {
crtc->hwmode = *saved_hwmode; crtc->hwmode = *saved_hwmode;
crtc->mode = *saved_mode; crtc->mode = *saved_mode;
} else { } else {
...@@ -7529,6 +7527,11 @@ bool intel_set_mode(struct drm_crtc *crtc, ...@@ -7529,6 +7527,11 @@ bool intel_set_mode(struct drm_crtc *crtc,
return ret; return ret;
} }
void intel_crtc_restore_mode(struct drm_crtc *crtc)
{
intel_set_mode(crtc, &crtc->mode, crtc->x, crtc->y, crtc->fb);
}
#undef for_each_intel_crtc_masked #undef for_each_intel_crtc_masked
static void intel_set_config_free(struct intel_set_config *config) static void intel_set_config_free(struct intel_set_config *config)
...@@ -7798,11 +7801,11 @@ static int intel_crtc_set_config(struct drm_mode_set *set) ...@@ -7798,11 +7801,11 @@ static int intel_crtc_set_config(struct drm_mode_set *set)
drm_mode_debug_printmodeline(set->mode); drm_mode_debug_printmodeline(set->mode);
} }
if (!intel_set_mode(set->crtc, set->mode, ret = intel_set_mode(set->crtc, set->mode,
set->x, set->y, set->fb)) { set->x, set->y, set->fb);
DRM_ERROR("failed to set mode on [CRTC:%d]\n", if (ret) {
set->crtc->base.id); DRM_ERROR("failed to set mode on [CRTC:%d], err = %d\n",
ret = -EINVAL; set->crtc->base.id, ret);
goto fail; goto fail;
} }
} else if (config->fb_changed) { } else if (config->fb_changed) {
...@@ -7819,7 +7822,7 @@ static int intel_crtc_set_config(struct drm_mode_set *set) ...@@ -7819,7 +7822,7 @@ static int intel_crtc_set_config(struct drm_mode_set *set)
/* Try to restore the config */ /* Try to restore the config */
if (config->mode_changed && if (config->mode_changed &&
!intel_set_mode(save_set.crtc, save_set.mode, intel_set_mode(save_set.crtc, save_set.mode,
save_set.x, save_set.y, save_set.fb)) save_set.x, save_set.y, save_set.fb))
DRM_ERROR("failed to restore config after modeset failure\n"); DRM_ERROR("failed to restore config after modeset failure\n");
...@@ -8804,11 +8807,8 @@ void intel_modeset_setup_hw_state(struct drm_device *dev, ...@@ -8804,11 +8807,8 @@ void intel_modeset_setup_hw_state(struct drm_device *dev,
} }
if (force_restore) { if (force_restore) {
for_each_pipe(pipe) { for_each_pipe(pipe)
crtc = to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]); intel_crtc_restore_mode(dev_priv->pipe_to_crtc_mapping[pipe]);
intel_set_mode(&crtc->base, &crtc->base.mode,
crtc->base.x, crtc->base.y, crtc->base.fb);
}
} else { } else {
intel_modeset_update_staged_output_state(dev); intel_modeset_update_staged_output_state(dev);
} }
......
...@@ -2483,11 +2483,8 @@ intel_dp_set_property(struct drm_connector *connector, ...@@ -2483,11 +2483,8 @@ intel_dp_set_property(struct drm_connector *connector,
return -EINVAL; return -EINVAL;
done: done:
if (intel_encoder->base.crtc) { if (intel_encoder->base.crtc)
struct drm_crtc *crtc = intel_encoder->base.crtc; intel_crtc_restore_mode(intel_encoder->base.crtc);
intel_set_mode(crtc, &crtc->mode,
crtc->x, crtc->y, crtc->fb);
}
return 0; return 0;
} }
......
...@@ -501,9 +501,10 @@ struct intel_set_config { ...@@ -501,9 +501,10 @@ struct intel_set_config {
bool mode_changed; bool mode_changed;
}; };
extern bool intel_set_mode(struct drm_crtc *crtc, struct drm_display_mode *mode, extern int intel_set_mode(struct drm_crtc *crtc, struct drm_display_mode *mode,
int x, int y, struct drm_framebuffer *old_fb); int x, int y, struct drm_framebuffer *old_fb);
extern void intel_modeset_disable(struct drm_device *dev); extern void intel_modeset_disable(struct drm_device *dev);
extern void intel_crtc_restore_mode(struct drm_crtc *crtc);
extern void intel_crtc_load_lut(struct drm_crtc *crtc); extern void intel_crtc_load_lut(struct drm_crtc *crtc);
extern void intel_crtc_update_dpms(struct drm_crtc *crtc); extern void intel_crtc_update_dpms(struct drm_crtc *crtc);
extern void intel_encoder_noop(struct drm_encoder *encoder); extern void intel_encoder_noop(struct drm_encoder *encoder);
......
...@@ -917,11 +917,8 @@ intel_hdmi_set_property(struct drm_connector *connector, ...@@ -917,11 +917,8 @@ intel_hdmi_set_property(struct drm_connector *connector,
return -EINVAL; return -EINVAL;
done: done:
if (intel_dig_port->base.base.crtc) { if (intel_dig_port->base.base.crtc)
struct drm_crtc *crtc = intel_dig_port->base.base.crtc; intel_crtc_restore_mode(intel_dig_port->base.base.crtc);
intel_set_mode(crtc, &crtc->mode,
crtc->x, crtc->y, crtc->fb);
}
return 0; return 0;
} }
......
...@@ -646,8 +646,7 @@ static int intel_lvds_set_property(struct drm_connector *connector, ...@@ -646,8 +646,7 @@ static int intel_lvds_set_property(struct drm_connector *connector,
* If the CRTC is enabled, the display will be changed * If the CRTC is enabled, the display will be changed
* according to the new panel fitting mode. * according to the new panel fitting mode.
*/ */
intel_set_mode(crtc, &crtc->mode, intel_crtc_restore_mode(crtc);
crtc->x, crtc->y, crtc->fb);
} }
} }
......
...@@ -1997,11 +1997,8 @@ intel_sdvo_set_property(struct drm_connector *connector, ...@@ -1997,11 +1997,8 @@ intel_sdvo_set_property(struct drm_connector *connector,
done: done:
if (intel_sdvo->base.base.crtc) { if (intel_sdvo->base.base.crtc)
struct drm_crtc *crtc = intel_sdvo->base.base.crtc; intel_crtc_restore_mode(intel_sdvo->base.base.crtc);
intel_set_mode(crtc, &crtc->mode,
crtc->x, crtc->y, crtc->fb);
}
return 0; return 0;
#undef CHECK_PROPERTY #undef CHECK_PROPERTY
......
...@@ -1479,8 +1479,7 @@ intel_tv_set_property(struct drm_connector *connector, struct drm_property *prop ...@@ -1479,8 +1479,7 @@ intel_tv_set_property(struct drm_connector *connector, struct drm_property *prop
} }
if (changed && crtc) if (changed && crtc)
intel_set_mode(crtc, &crtc->mode, intel_crtc_restore_mode(crtc);
crtc->x, crtc->y, crtc->fb);
out: out:
return ret; return ret;
} }
......
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