diff mbox

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

Message ID 1355933323-2473-1-git-send-email-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson Dec. 19, 2012, 4:08 p.m. UTC
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/intel_display.c |   56 +++++++++++++++++-----------------
 drivers/gpu/drm/i915/intel_dp.c      |    7 ++---
 drivers/gpu/drm/i915/intel_drv.h     |    6 ++--
 drivers/gpu/drm/i915/intel_hdmi.c    |    7 ++---
 drivers/gpu/drm/i915/intel_lvds.c    |    3 +-
 drivers/gpu/drm/i915/intel_sdvo.c    |    7 ++---
 drivers/gpu/drm/i915/intel_tv.c      |    3 +-
 7 files changed, 40 insertions(+), 49 deletions(-)

Comments

Rodrigo Vivi Dec. 20, 2012, 5:46 p.m. UTC | #1
I'm just not sure if "restore" is a good name for the new function
calling intel_set_mode
but I don't have a better suggestion so feel free to use:

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@gmail.com>


On Wed, Dec 19, 2012 at 2:08 PM, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/intel_display.c |   56 +++++++++++++++++-----------------
>  drivers/gpu/drm/i915/intel_dp.c      |    7 ++---
>  drivers/gpu/drm/i915/intel_drv.h     |    6 ++--
>  drivers/gpu/drm/i915/intel_hdmi.c    |    7 ++---
>  drivers/gpu/drm/i915/intel_lvds.c    |    3 +-
>  drivers/gpu/drm/i915/intel_sdvo.c    |    7 ++---
>  drivers/gpu/drm/i915/intel_tv.c      |    3 +-
>  7 files changed, 40 insertions(+), 49 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 7d168e8..8986172 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -6393,7 +6393,7 @@ bool intel_get_load_detect_pipe(struct drm_connector *connector,
>                 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");
>                 if (old->release_fb)
>                         old->release_fb->funcs->destroy(old->release_fb);
> @@ -7573,22 +7573,20 @@ intel_modeset_check_state(struct drm_device *dev)
>         }
>  }
>
> -bool intel_set_mode(struct drm_crtc *crtc,
> -                   struct drm_display_mode *mode,
> -                   int x, int y, struct drm_framebuffer *fb)
> +int intel_set_mode(struct drm_crtc *crtc,
> +                  struct drm_display_mode *mode,
> +                  int x, int y, struct drm_framebuffer *fb)
>  {
>         struct drm_device *dev = crtc->dev;
>         drm_i915_private_t *dev_priv = dev->dev_private;
>         struct drm_display_mode *adjusted_mode, *saved_mode, *saved_hwmode;
>         struct intel_crtc *intel_crtc;
>         unsigned disable_pipes, prepare_pipes, modeset_pipes;
> -       bool ret = true;
> +       int ret = 0;
>
>         saved_mode = kmalloc(2 * sizeof(*saved_mode), GFP_KERNEL);
> -       if (!saved_mode) {
> -               DRM_ERROR("i915: Could not allocate saved display mode.\n");
> -               return false;
> -       }
> +       if (!saved_mode)
> +               return -ENOMEM;
>         saved_hwmode = saved_mode + 1;
>
>         intel_modeset_affected_pipes(crtc, &modeset_pipes,
> @@ -7612,7 +7610,7 @@ bool intel_set_mode(struct drm_crtc *crtc,
>         if (modeset_pipes) {
>                 adjusted_mode = intel_modeset_adjusted_mode(crtc, mode);
>                 if (IS_ERR(adjusted_mode)) {
> -                       ret = false;
> +                       ret = PTR_ERR(adjusted_mode);
>                         goto out;
>                 }
>         }
> @@ -7639,11 +7637,11 @@ bool intel_set_mode(struct drm_crtc *crtc,
>          * on the DPLL.
>          */
>         for_each_intel_crtc_masked(dev, modeset_pipes, intel_crtc) {
> -               ret = !intel_crtc_mode_set(&intel_crtc->base,
> -                                          mode, adjusted_mode,
> -                                          x, y, fb);
> -               if (!ret)
> -                   goto done;
> +               ret = intel_crtc_mode_set(&intel_crtc->base,
> +                                         mode, adjusted_mode,
> +                                         x, y, fb);
> +               if (ret)
> +                       goto done;
>         }
>
>         /* Now enable the clocks, plane, pipe, and connectors that we set up. */
> @@ -7664,7 +7662,7 @@ bool intel_set_mode(struct drm_crtc *crtc,
>         /* FIXME: add subpixel order */
>  done:
>         drm_mode_destroy(dev, adjusted_mode);
> -       if (!ret && crtc->enabled) {
> +       if (ret && crtc->enabled) {
>                 crtc->hwmode = *saved_hwmode;
>                 crtc->mode = *saved_mode;
>         } else {
> @@ -7676,6 +7674,11 @@ out:
>         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
>
>  static void intel_set_config_free(struct intel_set_config *config)
> @@ -7945,11 +7948,11 @@ static int intel_crtc_set_config(struct drm_mode_set *set)
>                         drm_mode_debug_printmodeline(set->mode);
>                 }
>
> -               if (!intel_set_mode(set->crtc, set->mode,
> -                                   set->x, set->y, set->fb)) {
> -                       DRM_ERROR("failed to set mode on [CRTC:%d]\n",
> -                                 set->crtc->base.id);
> -                       ret = -EINVAL;
> +               ret = intel_set_mode(set->crtc, set->mode,
> +                                    set->x, set->y, set->fb);
> +               if (ret) {
> +                       DRM_ERROR("failed to set mode on [CRTC:%d], err = %d\n",
> +                                 set->crtc->base.id, ret);
>                         goto fail;
>                 }
>         } else if (config->fb_changed) {
> @@ -7966,8 +7969,8 @@ fail:
>
>         /* Try to restore the config */
>         if (config->mode_changed &&
> -           !intel_set_mode(save_set.crtc, save_set.mode,
> -                           save_set.x, save_set.y, save_set.fb))
> +           intel_set_mode(save_set.crtc, save_set.mode,
> +                          save_set.x, save_set.y, save_set.fb))
>                 DRM_ERROR("failed to restore config after modeset failure\n");
>
>  out_config:
> @@ -8977,11 +8980,8 @@ void intel_modeset_setup_hw_state(struct drm_device *dev,
>                 intel_sanitize_crtc(__intel_get_crtc_for_pipe(dev_priv, pipe));
>
>         if (force_restore) {
> -               for_each_pipe(pipe) {
> -                       crtc = to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]);
> -                       intel_set_mode(&crtc->base, &crtc->base.mode,
> -                                      crtc->base.x, crtc->base.y, crtc->base.fb);
> -               }
> +               for_each_pipe(pipe)
> +                       intel_crtc_restore_mode(dev_priv->pipe_to_crtc_mapping[pipe]);
>         } else {
>                 intel_modeset_update_staged_output_state(dev);
>         }
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index a3dab91..b8c6fcb 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -2508,11 +2508,8 @@ intel_dp_set_property(struct drm_connector *connector,
>         return -EINVAL;
>
>  done:
> -       if (intel_encoder->base.crtc) {
> -               struct drm_crtc *crtc = intel_encoder->base.crtc;
> -               intel_set_mode(crtc, &crtc->mode,
> -                              crtc->x, crtc->y, crtc->fb);
> -       }
> +       if (intel_encoder->base.crtc)
> +               intel_crtc_restore_mode(intel_encoder->base.crtc);
>
>         return 0;
>  }
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index f280291..a40ebce 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -542,9 +542,11 @@ struct intel_set_config {
>         bool mode_changed;
>  };
>
> -extern bool intel_set_mode(struct drm_crtc *crtc, struct drm_display_mode *mode,
> -                          int x, int y, struct drm_framebuffer *old_fb);
> +extern int intel_set_mode(struct drm_crtc *crtc,
> +                         struct drm_display_mode *mode,
> +                         int x, int y, struct drm_framebuffer *fb);
>  extern void intel_modeset_disable(struct drm_device *dev);
> +extern void intel_crtc_restore_mode(struct drm_crtc *crtc);
>  extern void intel_crtc_queue_unpin(struct intel_crtc *crtc,
>                                    struct drm_i915_gem_object *obj);
>  extern void intel_crtc_load_lut(struct drm_crtc *crtc);
> diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
> index 3a3d058..0f3b797 100644
> --- a/drivers/gpu/drm/i915/intel_hdmi.c
> +++ b/drivers/gpu/drm/i915/intel_hdmi.c
> @@ -933,11 +933,8 @@ intel_hdmi_set_property(struct drm_connector *connector,
>         return -EINVAL;
>
>  done:
> -       if (intel_dig_port->base.base.crtc) {
> -               struct drm_crtc *crtc = intel_dig_port->base.base.crtc;
> -               intel_set_mode(crtc, &crtc->mode,
> -                              crtc->x, crtc->y, crtc->fb);
> -       }
> +       if (intel_dig_port->base.base.crtc)
> +               intel_crtc_restore_mode(intel_dig_port->base.base.crtc);
>
>         return 0;
>  }
> diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
> index 38af1f2..e1c6145 100644
> --- a/drivers/gpu/drm/i915/intel_lvds.c
> +++ b/drivers/gpu/drm/i915/intel_lvds.c
> @@ -666,8 +666,7 @@ static int intel_lvds_set_property(struct drm_connector *connector,
>                          * If the CRTC is enabled, the display will be changed
>                          * according to the new panel fitting mode.
>                          */
> -                       intel_set_mode(crtc, &crtc->mode,
> -                                      crtc->x, crtc->y, crtc->fb);
> +                       intel_crtc_restore_mode(crtc);
>                 }
>         }
>
> diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
> index 229285b..7fcdf4f 100644
> --- a/drivers/gpu/drm/i915/intel_sdvo.c
> +++ b/drivers/gpu/drm/i915/intel_sdvo.c
> @@ -2018,11 +2018,8 @@ set_value:
>
>
>  done:
> -       if (intel_sdvo->base.base.crtc) {
> -               struct drm_crtc *crtc = intel_sdvo->base.base.crtc;
> -               intel_set_mode(crtc, &crtc->mode,
> -                              crtc->x, crtc->y, crtc->fb);
> -       }
> +       if (intel_sdvo->base.base.crtc)
> +               intel_crtc_restore_mode(intel_sdvo->base.base.crtc);
>
>         return 0;
>  #undef CHECK_PROPERTY
> diff --git a/drivers/gpu/drm/i915/intel_tv.c b/drivers/gpu/drm/i915/intel_tv.c
> index ea93520..984a113 100644
> --- a/drivers/gpu/drm/i915/intel_tv.c
> +++ b/drivers/gpu/drm/i915/intel_tv.c
> @@ -1479,8 +1479,7 @@ intel_tv_set_property(struct drm_connector *connector, struct drm_property *prop
>         }
>
>         if (changed && crtc)
> -               intel_set_mode(crtc, &crtc->mode,
> -                              crtc->x, crtc->y, crtc->fb);
> +               intel_crtc_restore_mode(crtc);
>  out:
>         return ret;
>  }
> --
> 1.7.10.4
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Daniel Vetter Dec. 20, 2012, 8:15 p.m. UTC | #2
On Thu, Dec 20, 2012 at 03:46:06PM -0200, Rodrigo Vivi wrote:
> I'm just not sure if "restore" is a good name for the new function
> calling intel_set_mode
> but I don't have a better suggestion so feel free to use:
> 
> Reviewed-by: Rodrigo Vivi <rodrigo.vivi@gmail.com>
Queued for -next, with a note added mentioning the new helper. Imo the
commit message really should waste a few words on such slightly related
changes ...

-Daniel
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 7d168e8..8986172 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -6393,7 +6393,7 @@  bool intel_get_load_detect_pipe(struct drm_connector *connector,
 		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");
 		if (old->release_fb)
 			old->release_fb->funcs->destroy(old->release_fb);
@@ -7573,22 +7573,20 @@  intel_modeset_check_state(struct drm_device *dev)
 	}
 }
 
-bool intel_set_mode(struct drm_crtc *crtc,
-		    struct drm_display_mode *mode,
-		    int x, int y, struct drm_framebuffer *fb)
+int intel_set_mode(struct drm_crtc *crtc,
+		   struct drm_display_mode *mode,
+		   int x, int y, struct drm_framebuffer *fb)
 {
 	struct drm_device *dev = crtc->dev;
 	drm_i915_private_t *dev_priv = dev->dev_private;
 	struct drm_display_mode *adjusted_mode, *saved_mode, *saved_hwmode;
 	struct intel_crtc *intel_crtc;
 	unsigned disable_pipes, prepare_pipes, modeset_pipes;
-	bool ret = true;
+	int ret = 0;
 
 	saved_mode = kmalloc(2 * sizeof(*saved_mode), GFP_KERNEL);
-	if (!saved_mode) {
-		DRM_ERROR("i915: Could not allocate saved display mode.\n");
-		return false;
-	}
+	if (!saved_mode)
+		return -ENOMEM;
 	saved_hwmode = saved_mode + 1;
 
 	intel_modeset_affected_pipes(crtc, &modeset_pipes,
@@ -7612,7 +7610,7 @@  bool intel_set_mode(struct drm_crtc *crtc,
 	if (modeset_pipes) {
 		adjusted_mode = intel_modeset_adjusted_mode(crtc, mode);
 		if (IS_ERR(adjusted_mode)) {
-			ret = false;
+			ret = PTR_ERR(adjusted_mode);
 			goto out;
 		}
 	}
@@ -7639,11 +7637,11 @@  bool intel_set_mode(struct drm_crtc *crtc,
 	 * on the DPLL.
 	 */
 	for_each_intel_crtc_masked(dev, modeset_pipes, intel_crtc) {
-		ret = !intel_crtc_mode_set(&intel_crtc->base,
-					   mode, adjusted_mode,
-					   x, y, fb);
-		if (!ret)
-		    goto done;
+		ret = intel_crtc_mode_set(&intel_crtc->base,
+					  mode, adjusted_mode,
+					  x, y, fb);
+		if (ret)
+			goto done;
 	}
 
 	/* Now enable the clocks, plane, pipe, and connectors that we set up. */
@@ -7664,7 +7662,7 @@  bool intel_set_mode(struct drm_crtc *crtc,
 	/* FIXME: add subpixel order */
 done:
 	drm_mode_destroy(dev, adjusted_mode);
-	if (!ret && crtc->enabled) {
+	if (ret && crtc->enabled) {
 		crtc->hwmode = *saved_hwmode;
 		crtc->mode = *saved_mode;
 	} else {
@@ -7676,6 +7674,11 @@  out:
 	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
 
 static void intel_set_config_free(struct intel_set_config *config)
@@ -7945,11 +7948,11 @@  static int intel_crtc_set_config(struct drm_mode_set *set)
 			drm_mode_debug_printmodeline(set->mode);
 		}
 
-		if (!intel_set_mode(set->crtc, set->mode,
-				    set->x, set->y, set->fb)) {
-			DRM_ERROR("failed to set mode on [CRTC:%d]\n",
-				  set->crtc->base.id);
-			ret = -EINVAL;
+		ret = intel_set_mode(set->crtc, set->mode,
+				     set->x, set->y, set->fb);
+		if (ret) {
+			DRM_ERROR("failed to set mode on [CRTC:%d], err = %d\n",
+				  set->crtc->base.id, ret);
 			goto fail;
 		}
 	} else if (config->fb_changed) {
@@ -7966,8 +7969,8 @@  fail:
 
 	/* Try to restore the config */
 	if (config->mode_changed &&
-	    !intel_set_mode(save_set.crtc, save_set.mode,
-			    save_set.x, save_set.y, save_set.fb))
+	    intel_set_mode(save_set.crtc, save_set.mode,
+			   save_set.x, save_set.y, save_set.fb))
 		DRM_ERROR("failed to restore config after modeset failure\n");
 
 out_config:
@@ -8977,11 +8980,8 @@  void intel_modeset_setup_hw_state(struct drm_device *dev,
 		intel_sanitize_crtc(__intel_get_crtc_for_pipe(dev_priv, pipe));
 
 	if (force_restore) {
-		for_each_pipe(pipe) {
-			crtc = to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]);
-			intel_set_mode(&crtc->base, &crtc->base.mode,
-				       crtc->base.x, crtc->base.y, crtc->base.fb);
-		}
+		for_each_pipe(pipe)
+			intel_crtc_restore_mode(dev_priv->pipe_to_crtc_mapping[pipe]);
 	} else {
 		intel_modeset_update_staged_output_state(dev);
 	}
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index a3dab91..b8c6fcb 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -2508,11 +2508,8 @@  intel_dp_set_property(struct drm_connector *connector,
 	return -EINVAL;
 
 done:
-	if (intel_encoder->base.crtc) {
-		struct drm_crtc *crtc = intel_encoder->base.crtc;
-		intel_set_mode(crtc, &crtc->mode,
-			       crtc->x, crtc->y, crtc->fb);
-	}
+	if (intel_encoder->base.crtc)
+		intel_crtc_restore_mode(intel_encoder->base.crtc);
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index f280291..a40ebce 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -542,9 +542,11 @@  struct intel_set_config {
 	bool mode_changed;
 };
 
-extern bool intel_set_mode(struct drm_crtc *crtc, struct drm_display_mode *mode,
-			   int x, int y, struct drm_framebuffer *old_fb);
+extern int intel_set_mode(struct drm_crtc *crtc,
+			  struct drm_display_mode *mode,
+			  int x, int y, struct drm_framebuffer *fb);
 extern void intel_modeset_disable(struct drm_device *dev);
+extern void intel_crtc_restore_mode(struct drm_crtc *crtc);
 extern void intel_crtc_queue_unpin(struct intel_crtc *crtc,
 				   struct drm_i915_gem_object *obj);
 extern void intel_crtc_load_lut(struct drm_crtc *crtc);
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
index 3a3d058..0f3b797 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -933,11 +933,8 @@  intel_hdmi_set_property(struct drm_connector *connector,
 	return -EINVAL;
 
 done:
-	if (intel_dig_port->base.base.crtc) {
-		struct drm_crtc *crtc = intel_dig_port->base.base.crtc;
-		intel_set_mode(crtc, &crtc->mode,
-			       crtc->x, crtc->y, crtc->fb);
-	}
+	if (intel_dig_port->base.base.crtc)
+		intel_crtc_restore_mode(intel_dig_port->base.base.crtc);
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index 38af1f2..e1c6145 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -666,8 +666,7 @@  static int intel_lvds_set_property(struct drm_connector *connector,
 			 * If the CRTC is enabled, the display will be changed
 			 * according to the new panel fitting mode.
 			 */
-			intel_set_mode(crtc, &crtc->mode,
-				       crtc->x, crtc->y, crtc->fb);
+			intel_crtc_restore_mode(crtc);
 		}
 	}
 
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index 229285b..7fcdf4f 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -2018,11 +2018,8 @@  set_value:
 
 
 done:
-	if (intel_sdvo->base.base.crtc) {
-		struct drm_crtc *crtc = intel_sdvo->base.base.crtc;
-		intel_set_mode(crtc, &crtc->mode,
-			       crtc->x, crtc->y, crtc->fb);
-	}
+	if (intel_sdvo->base.base.crtc)
+		intel_crtc_restore_mode(intel_sdvo->base.base.crtc);
 
 	return 0;
 #undef CHECK_PROPERTY
diff --git a/drivers/gpu/drm/i915/intel_tv.c b/drivers/gpu/drm/i915/intel_tv.c
index ea93520..984a113 100644
--- a/drivers/gpu/drm/i915/intel_tv.c
+++ b/drivers/gpu/drm/i915/intel_tv.c
@@ -1479,8 +1479,7 @@  intel_tv_set_property(struct drm_connector *connector, struct drm_property *prop
 	}
 
 	if (changed && crtc)
-		intel_set_mode(crtc, &crtc->mode,
-			       crtc->x, crtc->y, crtc->fb);
+		intel_crtc_restore_mode(crtc);
 out:
 	return ret;
 }