All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] drm: return int error code from mode_fixup
@ 2021-07-13 17:13 ` Grace An
  0 siblings, 0 replies; 7+ messages in thread
From: Grace An @ 2021-07-13 17:13 UTC (permalink / raw)
  To: dri-devel
  Cc: Grace An, linux-arm-msm, freedreno, robdclark, seanpaul, swboyd,
	nganji, aravindh, khsieh, pdhaval, abhinavk, dmitry.baryshkov,
	daniel

When CONFIG_PROVE_LOCKING is defined, the kernel randomly injects
-EDEADLK errors for all the ww_mutex. This results in
drm_atomic_get_private_obj_state randomly returning -EDEADLK.
However, the mode_fixup functions do not propagate these error
codes and return false, causing the atomic commit to fail with
-EINVAL instead of retrying.

Change encoder, crtc, and bridge mode_fixup functions to return
an int instead of a boolean to indicate success or failure. If
any of these functions fail, the mode_fixup function now returns
the provided integer error code instead of -EINVAL.

This change needs modifications across drivers, but before submitting
the entire change, we want to get feedback on this RFC.

Signed-off-by: Grace An <gracan@codeaurora.org>
---
 drivers/gpu/drm/drm_atomic_helper.c      | 8 ++++----
 drivers/gpu/drm/drm_bridge.c             | 4 ++--
 include/drm/drm_bridge.h                 | 2 +-
 include/drm/drm_modeset_helper_vtables.h | 4 ++--
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index f2b3e28..d75f09a 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -457,10 +457,10 @@ mode_fixup(struct drm_atomic_state *state)
 		} else if (funcs && funcs->mode_fixup) {
 			ret = funcs->mode_fixup(encoder, &new_crtc_state->mode,
 						&new_crtc_state->adjusted_mode);
-			if (!ret) {
+			if (ret) {
 				DRM_DEBUG_ATOMIC("[ENCODER:%d:%s] fixup failed\n",
 						 encoder->base.id, encoder->name);
-				return -EINVAL;
+				return ret;
 			}
 		}
 	}
@@ -481,10 +481,10 @@ mode_fixup(struct drm_atomic_state *state)
 
 		ret = funcs->mode_fixup(crtc, &new_crtc_state->mode,
 					&new_crtc_state->adjusted_mode);
-		if (!ret) {
+		if (ret) {
 			DRM_DEBUG_ATOMIC("[CRTC:%d:%s] fixup failed\n",
 					 crtc->base.id, crtc->name);
-			return -EINVAL;
+			return ret;
 		}
 	}
 
diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index 64f0eff..3ad16b5 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -736,9 +736,9 @@ static int drm_atomic_bridge_check(struct drm_bridge *bridge,
 		if (ret)
 			return ret;
 	} else if (bridge->funcs->mode_fixup) {
-		if (!bridge->funcs->mode_fixup(bridge, &crtc_state->mode,
+		if (bridge->funcs->mode_fixup(bridge, &crtc_state->mode,
 					       &crtc_state->adjusted_mode))
-			return -EINVAL;
+			return ret;
 	}
 
 	return 0;
diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
index 2195daa..5d02dfc 100644
--- a/include/drm/drm_bridge.h
+++ b/include/drm/drm_bridge.h
@@ -153,7 +153,7 @@ struct drm_bridge_funcs {
 	 * True if an acceptable configuration is possible, false if the modeset
 	 * operation should be rejected.
 	 */
-	bool (*mode_fixup)(struct drm_bridge *bridge,
+	int (*mode_fixup)(struct drm_bridge *bridge,
 			   const struct drm_display_mode *mode,
 			   struct drm_display_mode *adjusted_mode);
 	/**
diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h
index f3a4b47..e305c97 100644
--- a/include/drm/drm_modeset_helper_vtables.h
+++ b/include/drm/drm_modeset_helper_vtables.h
@@ -184,7 +184,7 @@ struct drm_crtc_helper_funcs {
 	 * True if an acceptable configuration is possible, false if the modeset
 	 * operation should be rejected.
 	 */
-	bool (*mode_fixup)(struct drm_crtc *crtc,
+	int (*mode_fixup)(struct drm_crtc *crtc,
 			   const struct drm_display_mode *mode,
 			   struct drm_display_mode *adjusted_mode);
 
@@ -599,7 +599,7 @@ struct drm_encoder_helper_funcs {
 	 * True if an acceptable configuration is possible, false if the modeset
 	 * operation should be rejected.
 	 */
-	bool (*mode_fixup)(struct drm_encoder *encoder,
+	int (*mode_fixup)(struct drm_encoder *encoder,
 			   const struct drm_display_mode *mode,
 			   struct drm_display_mode *adjusted_mode);
 
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [RFC] drm: return int error code from mode_fixup
@ 2021-07-13 17:13 ` Grace An
  0 siblings, 0 replies; 7+ messages in thread
From: Grace An @ 2021-07-13 17:13 UTC (permalink / raw)
  To: dri-devel
  Cc: Grace An, linux-arm-msm, pdhaval, abhinavk, swboyd, khsieh,
	seanpaul, dmitry.baryshkov, aravindh, freedreno

When CONFIG_PROVE_LOCKING is defined, the kernel randomly injects
-EDEADLK errors for all the ww_mutex. This results in
drm_atomic_get_private_obj_state randomly returning -EDEADLK.
However, the mode_fixup functions do not propagate these error
codes and return false, causing the atomic commit to fail with
-EINVAL instead of retrying.

Change encoder, crtc, and bridge mode_fixup functions to return
an int instead of a boolean to indicate success or failure. If
any of these functions fail, the mode_fixup function now returns
the provided integer error code instead of -EINVAL.

This change needs modifications across drivers, but before submitting
the entire change, we want to get feedback on this RFC.

Signed-off-by: Grace An <gracan@codeaurora.org>
---
 drivers/gpu/drm/drm_atomic_helper.c      | 8 ++++----
 drivers/gpu/drm/drm_bridge.c             | 4 ++--
 include/drm/drm_bridge.h                 | 2 +-
 include/drm/drm_modeset_helper_vtables.h | 4 ++--
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index f2b3e28..d75f09a 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -457,10 +457,10 @@ mode_fixup(struct drm_atomic_state *state)
 		} else if (funcs && funcs->mode_fixup) {
 			ret = funcs->mode_fixup(encoder, &new_crtc_state->mode,
 						&new_crtc_state->adjusted_mode);
-			if (!ret) {
+			if (ret) {
 				DRM_DEBUG_ATOMIC("[ENCODER:%d:%s] fixup failed\n",
 						 encoder->base.id, encoder->name);
-				return -EINVAL;
+				return ret;
 			}
 		}
 	}
@@ -481,10 +481,10 @@ mode_fixup(struct drm_atomic_state *state)
 
 		ret = funcs->mode_fixup(crtc, &new_crtc_state->mode,
 					&new_crtc_state->adjusted_mode);
-		if (!ret) {
+		if (ret) {
 			DRM_DEBUG_ATOMIC("[CRTC:%d:%s] fixup failed\n",
 					 crtc->base.id, crtc->name);
-			return -EINVAL;
+			return ret;
 		}
 	}
 
diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index 64f0eff..3ad16b5 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -736,9 +736,9 @@ static int drm_atomic_bridge_check(struct drm_bridge *bridge,
 		if (ret)
 			return ret;
 	} else if (bridge->funcs->mode_fixup) {
-		if (!bridge->funcs->mode_fixup(bridge, &crtc_state->mode,
+		if (bridge->funcs->mode_fixup(bridge, &crtc_state->mode,
 					       &crtc_state->adjusted_mode))
-			return -EINVAL;
+			return ret;
 	}
 
 	return 0;
diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
index 2195daa..5d02dfc 100644
--- a/include/drm/drm_bridge.h
+++ b/include/drm/drm_bridge.h
@@ -153,7 +153,7 @@ struct drm_bridge_funcs {
 	 * True if an acceptable configuration is possible, false if the modeset
 	 * operation should be rejected.
 	 */
-	bool (*mode_fixup)(struct drm_bridge *bridge,
+	int (*mode_fixup)(struct drm_bridge *bridge,
 			   const struct drm_display_mode *mode,
 			   struct drm_display_mode *adjusted_mode);
 	/**
diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h
index f3a4b47..e305c97 100644
--- a/include/drm/drm_modeset_helper_vtables.h
+++ b/include/drm/drm_modeset_helper_vtables.h
@@ -184,7 +184,7 @@ struct drm_crtc_helper_funcs {
 	 * True if an acceptable configuration is possible, false if the modeset
 	 * operation should be rejected.
 	 */
-	bool (*mode_fixup)(struct drm_crtc *crtc,
+	int (*mode_fixup)(struct drm_crtc *crtc,
 			   const struct drm_display_mode *mode,
 			   struct drm_display_mode *adjusted_mode);
 
@@ -599,7 +599,7 @@ struct drm_encoder_helper_funcs {
 	 * True if an acceptable configuration is possible, false if the modeset
 	 * operation should be rejected.
 	 */
-	bool (*mode_fixup)(struct drm_encoder *encoder,
+	int (*mode_fixup)(struct drm_encoder *encoder,
 			   const struct drm_display_mode *mode,
 			   struct drm_display_mode *adjusted_mode);
 
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [RFC] drm: return int error code from mode_fixup
  2021-07-13 17:13 ` Grace An
@ 2021-07-13 17:44   ` Daniel Vetter
  -1 siblings, 0 replies; 7+ messages in thread
From: Daniel Vetter @ 2021-07-13 17:44 UTC (permalink / raw)
  To: Grace An
  Cc: dri-devel, linux-arm-msm, freedreno, Clark, Rob, Sean Paul,
	Stephen Boyd, nganji, aravindh, Kuogee Hsieh, pdhaval,
	Abhinav Kumar, Dmitry Baryshkov

On Tue, Jul 13, 2021 at 7:14 PM Grace An <gracan@codeaurora.org> wrote:
> When CONFIG_PROVE_LOCKING is defined, the kernel randomly injects
> -EDEADLK errors for all the ww_mutex. This results in
> drm_atomic_get_private_obj_state randomly returning -EDEADLK.
> However, the mode_fixup functions do not propagate these error
> codes and return false, causing the atomic commit to fail with
> -EINVAL instead of retrying.
>
> Change encoder, crtc, and bridge mode_fixup functions to return
> an int instead of a boolean to indicate success or failure. If
> any of these functions fail, the mode_fixup function now returns
> the provided integer error code instead of -EINVAL.
>
> This change needs modifications across drivers, but before submitting
> the entire change, we want to get feedback on this RFC.
>
> Signed-off-by: Grace An <gracan@codeaurora.org>

Why don't you just use the various atomic_check hooks we have for
this? There you get passed the state and everything, have a full int
return value, and things actually work.

->mode_fixup is for compatibility with legacy crtc modeset helpers
from the pre-atomic times. If the kerneldoc isn't clear yet, please do
a patch to fix that up so that @mode_fixup points at the relevant
@atomic_check as the recommended function.
-Daniel

> ---
>  drivers/gpu/drm/drm_atomic_helper.c      | 8 ++++----
>  drivers/gpu/drm/drm_bridge.c             | 4 ++--
>  include/drm/drm_bridge.h                 | 2 +-
>  include/drm/drm_modeset_helper_vtables.h | 4 ++--
>  4 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index f2b3e28..d75f09a 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -457,10 +457,10 @@ mode_fixup(struct drm_atomic_state *state)
>                 } else if (funcs && funcs->mode_fixup) {
>                         ret = funcs->mode_fixup(encoder, &new_crtc_state->mode,
>                                                 &new_crtc_state->adjusted_mode);
> -                       if (!ret) {
> +                       if (ret) {
>                                 DRM_DEBUG_ATOMIC("[ENCODER:%d:%s] fixup failed\n",
>                                                  encoder->base.id, encoder->name);
> -                               return -EINVAL;
> +                               return ret;
>                         }
>                 }
>         }
> @@ -481,10 +481,10 @@ mode_fixup(struct drm_atomic_state *state)
>
>                 ret = funcs->mode_fixup(crtc, &new_crtc_state->mode,
>                                         &new_crtc_state->adjusted_mode);
> -               if (!ret) {
> +               if (ret) {
>                         DRM_DEBUG_ATOMIC("[CRTC:%d:%s] fixup failed\n",
>                                          crtc->base.id, crtc->name);
> -                       return -EINVAL;
> +                       return ret;
>                 }
>         }
>
> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
> index 64f0eff..3ad16b5 100644
> --- a/drivers/gpu/drm/drm_bridge.c
> +++ b/drivers/gpu/drm/drm_bridge.c
> @@ -736,9 +736,9 @@ static int drm_atomic_bridge_check(struct drm_bridge *bridge,
>                 if (ret)
>                         return ret;
>         } else if (bridge->funcs->mode_fixup) {
> -               if (!bridge->funcs->mode_fixup(bridge, &crtc_state->mode,
> +               if (bridge->funcs->mode_fixup(bridge, &crtc_state->mode,
>                                                &crtc_state->adjusted_mode))
> -                       return -EINVAL;
> +                       return ret;
>         }
>
>         return 0;
> diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
> index 2195daa..5d02dfc 100644
> --- a/include/drm/drm_bridge.h
> +++ b/include/drm/drm_bridge.h
> @@ -153,7 +153,7 @@ struct drm_bridge_funcs {
>          * True if an acceptable configuration is possible, false if the modeset
>          * operation should be rejected.
>          */
> -       bool (*mode_fixup)(struct drm_bridge *bridge,
> +       int (*mode_fixup)(struct drm_bridge *bridge,
>                            const struct drm_display_mode *mode,
>                            struct drm_display_mode *adjusted_mode);
>         /**
> diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h
> index f3a4b47..e305c97 100644
> --- a/include/drm/drm_modeset_helper_vtables.h
> +++ b/include/drm/drm_modeset_helper_vtables.h
> @@ -184,7 +184,7 @@ struct drm_crtc_helper_funcs {
>          * True if an acceptable configuration is possible, false if the modeset
>          * operation should be rejected.
>          */
> -       bool (*mode_fixup)(struct drm_crtc *crtc,
> +       int (*mode_fixup)(struct drm_crtc *crtc,
>                            const struct drm_display_mode *mode,
>                            struct drm_display_mode *adjusted_mode);
>
> @@ -599,7 +599,7 @@ struct drm_encoder_helper_funcs {
>          * True if an acceptable configuration is possible, false if the modeset
>          * operation should be rejected.
>          */
> -       bool (*mode_fixup)(struct drm_encoder *encoder,
> +       int (*mode_fixup)(struct drm_encoder *encoder,
>                            const struct drm_display_mode *mode,
>                            struct drm_display_mode *adjusted_mode);
>
> --
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
>


-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC] drm: return int error code from mode_fixup
@ 2021-07-13 17:44   ` Daniel Vetter
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Vetter @ 2021-07-13 17:44 UTC (permalink / raw)
  To: Grace An
  Cc: linux-arm-msm, pdhaval, dri-devel, Stephen Boyd, Kuogee Hsieh,
	Sean Paul, Abhinav Kumar, Dmitry Baryshkov, aravindh, freedreno

On Tue, Jul 13, 2021 at 7:14 PM Grace An <gracan@codeaurora.org> wrote:
> When CONFIG_PROVE_LOCKING is defined, the kernel randomly injects
> -EDEADLK errors for all the ww_mutex. This results in
> drm_atomic_get_private_obj_state randomly returning -EDEADLK.
> However, the mode_fixup functions do not propagate these error
> codes and return false, causing the atomic commit to fail with
> -EINVAL instead of retrying.
>
> Change encoder, crtc, and bridge mode_fixup functions to return
> an int instead of a boolean to indicate success or failure. If
> any of these functions fail, the mode_fixup function now returns
> the provided integer error code instead of -EINVAL.
>
> This change needs modifications across drivers, but before submitting
> the entire change, we want to get feedback on this RFC.
>
> Signed-off-by: Grace An <gracan@codeaurora.org>

Why don't you just use the various atomic_check hooks we have for
this? There you get passed the state and everything, have a full int
return value, and things actually work.

->mode_fixup is for compatibility with legacy crtc modeset helpers
from the pre-atomic times. If the kerneldoc isn't clear yet, please do
a patch to fix that up so that @mode_fixup points at the relevant
@atomic_check as the recommended function.
-Daniel

> ---
>  drivers/gpu/drm/drm_atomic_helper.c      | 8 ++++----
>  drivers/gpu/drm/drm_bridge.c             | 4 ++--
>  include/drm/drm_bridge.h                 | 2 +-
>  include/drm/drm_modeset_helper_vtables.h | 4 ++--
>  4 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index f2b3e28..d75f09a 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -457,10 +457,10 @@ mode_fixup(struct drm_atomic_state *state)
>                 } else if (funcs && funcs->mode_fixup) {
>                         ret = funcs->mode_fixup(encoder, &new_crtc_state->mode,
>                                                 &new_crtc_state->adjusted_mode);
> -                       if (!ret) {
> +                       if (ret) {
>                                 DRM_DEBUG_ATOMIC("[ENCODER:%d:%s] fixup failed\n",
>                                                  encoder->base.id, encoder->name);
> -                               return -EINVAL;
> +                               return ret;
>                         }
>                 }
>         }
> @@ -481,10 +481,10 @@ mode_fixup(struct drm_atomic_state *state)
>
>                 ret = funcs->mode_fixup(crtc, &new_crtc_state->mode,
>                                         &new_crtc_state->adjusted_mode);
> -               if (!ret) {
> +               if (ret) {
>                         DRM_DEBUG_ATOMIC("[CRTC:%d:%s] fixup failed\n",
>                                          crtc->base.id, crtc->name);
> -                       return -EINVAL;
> +                       return ret;
>                 }
>         }
>
> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
> index 64f0eff..3ad16b5 100644
> --- a/drivers/gpu/drm/drm_bridge.c
> +++ b/drivers/gpu/drm/drm_bridge.c
> @@ -736,9 +736,9 @@ static int drm_atomic_bridge_check(struct drm_bridge *bridge,
>                 if (ret)
>                         return ret;
>         } else if (bridge->funcs->mode_fixup) {
> -               if (!bridge->funcs->mode_fixup(bridge, &crtc_state->mode,
> +               if (bridge->funcs->mode_fixup(bridge, &crtc_state->mode,
>                                                &crtc_state->adjusted_mode))
> -                       return -EINVAL;
> +                       return ret;
>         }
>
>         return 0;
> diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
> index 2195daa..5d02dfc 100644
> --- a/include/drm/drm_bridge.h
> +++ b/include/drm/drm_bridge.h
> @@ -153,7 +153,7 @@ struct drm_bridge_funcs {
>          * True if an acceptable configuration is possible, false if the modeset
>          * operation should be rejected.
>          */
> -       bool (*mode_fixup)(struct drm_bridge *bridge,
> +       int (*mode_fixup)(struct drm_bridge *bridge,
>                            const struct drm_display_mode *mode,
>                            struct drm_display_mode *adjusted_mode);
>         /**
> diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h
> index f3a4b47..e305c97 100644
> --- a/include/drm/drm_modeset_helper_vtables.h
> +++ b/include/drm/drm_modeset_helper_vtables.h
> @@ -184,7 +184,7 @@ struct drm_crtc_helper_funcs {
>          * True if an acceptable configuration is possible, false if the modeset
>          * operation should be rejected.
>          */
> -       bool (*mode_fixup)(struct drm_crtc *crtc,
> +       int (*mode_fixup)(struct drm_crtc *crtc,
>                            const struct drm_display_mode *mode,
>                            struct drm_display_mode *adjusted_mode);
>
> @@ -599,7 +599,7 @@ struct drm_encoder_helper_funcs {
>          * True if an acceptable configuration is possible, false if the modeset
>          * operation should be rejected.
>          */
> -       bool (*mode_fixup)(struct drm_encoder *encoder,
> +       int (*mode_fixup)(struct drm_encoder *encoder,
>                            const struct drm_display_mode *mode,
>                            struct drm_display_mode *adjusted_mode);
>
> --
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
>


-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC] drm: return int error code from mode_fixup
  2021-07-13 17:44   ` Daniel Vetter
  (?)
@ 2021-07-13 19:34   ` Sam Ravnborg
  -1 siblings, 0 replies; 7+ messages in thread
From: Sam Ravnborg @ 2021-07-13 19:34 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Grace An, linux-arm-msm, dri-devel, Stephen Boyd, Kuogee Hsieh,
	pdhaval, Sean Paul, Abhinav Kumar, Dmitry Baryshkov, aravindh,
	freedreno

On Tue, Jul 13, 2021 at 07:44:12PM +0200, Daniel Vetter wrote:
> On Tue, Jul 13, 2021 at 7:14 PM Grace An <gracan@codeaurora.org> wrote:
> > When CONFIG_PROVE_LOCKING is defined, the kernel randomly injects
> > -EDEADLK errors for all the ww_mutex. This results in
> > drm_atomic_get_private_obj_state randomly returning -EDEADLK.
> > However, the mode_fixup functions do not propagate these error
> > codes and return false, causing the atomic commit to fail with
> > -EINVAL instead of retrying.
> >
> > Change encoder, crtc, and bridge mode_fixup functions to return
> > an int instead of a boolean to indicate success or failure. If
> > any of these functions fail, the mode_fixup function now returns
> > the provided integer error code instead of -EINVAL.
> >
> > This change needs modifications across drivers, but before submitting
> > the entire change, we want to get feedback on this RFC.
> >
> > Signed-off-by: Grace An <gracan@codeaurora.org>
> 
> Why don't you just use the various atomic_check hooks we have for
> this? There you get passed the state and everything, have a full int
> return value, and things actually work.
> 
> ->mode_fixup is for compatibility with legacy crtc modeset helpers
> from the pre-atomic times. If the kerneldoc isn't clear yet, please do
> a patch to fix that up so that @mode_fixup points at the relevant
> @atomic_check as the recommended function.
Agreed, and we need to document this better.

I have posted the following patch to make it more obvious that
mode_fixup is deprecated.
https://lore.kernel.org/dri-devel/20210713193257.958852-1-sam@ravnborg.org/T/#u

	Sam

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC] drm: return int error code from mode_fixup
  2021-07-13 17:13 ` Grace An
  (?)
  (?)
@ 2021-07-14  9:40 ` kernel test robot
  -1 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2021-07-14  9:40 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 12828 bytes --]

Hi Grace,

[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on drm-intel/for-linux-next]
[also build test ERROR on drm-tip/drm-tip drm-exynos/exynos-drm-next tegra-drm/drm/tegra/for-next linus/master v5.14-rc1 next-20210714]
[cannot apply to drm/drm-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Grace-An/drm-return-int-error-code-from-mode_fixup/20210714-154532
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: h8300-randconfig-r023-20210713 (attached as .config)
compiler: h8300-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/2f5324deb5c8ffa632b47e073c8f7c27046d79a9
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Grace-An/drm-return-int-error-code-from-mode_fixup/20210714-154532
        git checkout 2f5324deb5c8ffa632b47e073c8f7c27046d79a9
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross O=build_dir ARCH=h8300 SHELL=/bin/bash drivers/gpu/drm/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from include/linux/err.h:5,
                    from drivers/gpu/drm/drm_bridge.c:24:
   include/linux/scatterlist.h: In function 'sg_set_buf':
   include/asm-generic/page.h:89:50: warning: ordered comparison of pointer with null pointer [-Wextra]
      89 | #define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
         |                                                  ^~
   include/linux/compiler.h:78:42: note: in definition of macro 'unlikely'
      78 | # define unlikely(x) __builtin_expect(!!(x), 0)
         |                                          ^
   include/linux/scatterlist.h:137:2: note: in expansion of macro 'BUG_ON'
     137 |  BUG_ON(!virt_addr_valid(buf));
         |  ^~~~~~
   include/linux/scatterlist.h:137:10: note: in expansion of macro 'virt_addr_valid'
     137 |  BUG_ON(!virt_addr_valid(buf));
         |          ^~~~~~~~~~~~~~~
   drivers/gpu/drm/drm_bridge.c: In function 'drm_atomic_bridge_check':
>> drivers/gpu/drm/drm_bridge.c:744:11: error: 'ret' undeclared (first use in this function); did you mean 'net'?
     744 |    return ret;
         |           ^~~
         |           net
   drivers/gpu/drm/drm_bridge.c:744:11: note: each undeclared identifier is reported only once for each function it appears in
--
   In file included from include/linux/err.h:5,
                    from include/linux/clk.h:12,
                    from drivers/gpu/drm/rcar-du/rcar_lvds.c:10:
   include/linux/scatterlist.h: In function 'sg_set_buf':
   include/asm-generic/page.h:89:50: warning: ordered comparison of pointer with null pointer [-Wextra]
      89 | #define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
         |                                                  ^~
   include/linux/compiler.h:78:42: note: in definition of macro 'unlikely'
      78 | # define unlikely(x) __builtin_expect(!!(x), 0)
         |                                          ^
   include/linux/scatterlist.h:137:2: note: in expansion of macro 'BUG_ON'
     137 |  BUG_ON(!virt_addr_valid(buf));
         |  ^~~~~~
   include/linux/scatterlist.h:137:10: note: in expansion of macro 'virt_addr_valid'
     137 |  BUG_ON(!virt_addr_valid(buf));
         |          ^~~~~~~~~~~~~~~
   drivers/gpu/drm/rcar-du/rcar_lvds.c: At top level:
>> drivers/gpu/drm/rcar-du/rcar_lvds.c:695:16: error: initialization of 'int (*)(struct drm_bridge *, const struct drm_display_mode *, struct drm_display_mode *)' from incompatible pointer type 'bool (*)(struct drm_bridge *, const struct drm_display_mode *, struct drm_display_mode *)' {aka '_Bool (*)(struct drm_bridge *, const struct drm_display_mode *, struct drm_display_mode *)'} [-Werror=incompatible-pointer-types]
     695 |  .mode_fixup = rcar_lvds_mode_fixup,
         |                ^~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/rcar-du/rcar_lvds.c:695:16: note: (near initialization for 'rcar_lvds_bridge_ops.mode_fixup')
   cc1: some warnings being treated as errors
--
   In file included from include/linux/kernel.h:11,
                    from include/linux/unaligned/packed_struct.h:4,
                    from include/asm-generic/unaligned.h:9,
                    from ./arch/h8300/include/generated/asm/unaligned.h:1,
                    from drivers/gpu/drm/bridge/sil-sii8620.c:9:
   include/linux/scatterlist.h: In function 'sg_set_buf':
   include/asm-generic/page.h:89:50: warning: ordered comparison of pointer with null pointer [-Wextra]
      89 | #define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
         |                                                  ^~
   include/linux/compiler.h:78:42: note: in definition of macro 'unlikely'
      78 | # define unlikely(x) __builtin_expect(!!(x), 0)
         |                                          ^
   include/linux/scatterlist.h:137:2: note: in expansion of macro 'BUG_ON'
     137 |  BUG_ON(!virt_addr_valid(buf));
         |  ^~~~~~
   include/linux/scatterlist.h:137:10: note: in expansion of macro 'virt_addr_valid'
     137 |  BUG_ON(!virt_addr_valid(buf));
         |          ^~~~~~~~~~~~~~~
   drivers/gpu/drm/bridge/sil-sii8620.c: At top level:
>> drivers/gpu/drm/bridge/sil-sii8620.c:2283:16: error: initialization of 'int (*)(struct drm_bridge *, const struct drm_display_mode *, struct drm_display_mode *)' from incompatible pointer type 'bool (*)(struct drm_bridge *, const struct drm_display_mode *, struct drm_display_mode *)' {aka '_Bool (*)(struct drm_bridge *, const struct drm_display_mode *, struct drm_display_mode *)'} [-Werror=incompatible-pointer-types]
    2283 |  .mode_fixup = sii8620_mode_fixup,
         |                ^~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/bridge/sil-sii8620.c:2283:16: note: (near initialization for 'sii8620_bridge_funcs.mode_fixup')
   cc1: some warnings being treated as errors
--
   In file included from include/linux/build_bug.h:5,
                    from include/linux/bits.h:22,
                    from drivers/gpu/drm/bridge/ti-sn65dsi83.c:28:
   include/linux/scatterlist.h: In function 'sg_set_buf':
   include/asm-generic/page.h:89:50: warning: ordered comparison of pointer with null pointer [-Wextra]
      89 | #define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
         |                                                  ^~
   include/linux/compiler.h:78:42: note: in definition of macro 'unlikely'
      78 | # define unlikely(x) __builtin_expect(!!(x), 0)
         |                                          ^
   include/linux/scatterlist.h:137:2: note: in expansion of macro 'BUG_ON'
     137 |  BUG_ON(!virt_addr_valid(buf));
         |  ^~~~~~
   include/linux/scatterlist.h:137:10: note: in expansion of macro 'virt_addr_valid'
     137 |  BUG_ON(!virt_addr_valid(buf));
         |          ^~~~~~~~~~~~~~~
   drivers/gpu/drm/bridge/ti-sn65dsi83.c: At top level:
>> drivers/gpu/drm/bridge/ti-sn65dsi83.c:569:16: error: initialization of 'int (*)(struct drm_bridge *, const struct drm_display_mode *, struct drm_display_mode *)' from incompatible pointer type 'bool (*)(struct drm_bridge *, const struct drm_display_mode *, struct drm_display_mode *)' {aka '_Bool (*)(struct drm_bridge *, const struct drm_display_mode *, struct drm_display_mode *)'} [-Werror=incompatible-pointer-types]
     569 |  .mode_fixup = sn65dsi83_mode_fixup,
         |                ^~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/bridge/ti-sn65dsi83.c:569:16: note: (near initialization for 'sn65dsi83_funcs.mode_fixup')
   cc1: some warnings being treated as errors
--
   In file included from include/linux/err.h:5,
                    from include/linux/clk.h:12,
                    from drivers/gpu/drm/arm/display/komeda/komeda_crtc.c:7:
   include/linux/scatterlist.h: In function 'sg_set_buf':
   include/asm-generic/page.h:89:50: warning: ordered comparison of pointer with null pointer [-Wextra]
      89 | #define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
         |                                                  ^~
   include/linux/compiler.h:78:42: note: in definition of macro 'unlikely'
      78 | # define unlikely(x) __builtin_expect(!!(x), 0)
         |                                          ^
   include/linux/scatterlist.h:137:2: note: in expansion of macro 'BUG_ON'
     137 |  BUG_ON(!virt_addr_valid(buf));
         |  ^~~~~~
   include/linux/scatterlist.h:137:10: note: in expansion of macro 'virt_addr_valid'
     137 |  BUG_ON(!virt_addr_valid(buf));
         |          ^~~~~~~~~~~~~~~
   drivers/gpu/drm/arm/display/komeda/komeda_crtc.c: At top level:
>> drivers/gpu/drm/arm/display/komeda/komeda_crtc.c:491:16: error: initialization of 'int (*)(struct drm_crtc *, const struct drm_display_mode *, struct drm_display_mode *)' from incompatible pointer type 'bool (*)(struct drm_crtc *, const struct drm_display_mode *, struct drm_display_mode *)' {aka '_Bool (*)(struct drm_crtc *, const struct drm_display_mode *, struct drm_display_mode *)'} [-Werror=incompatible-pointer-types]
     491 |  .mode_fixup = komeda_crtc_mode_fixup,
         |                ^~~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/arm/display/komeda/komeda_crtc.c:491:16: note: (near initialization for 'komeda_crtc_helper_funcs.mode_fixup')
   cc1: some warnings being treated as errors
--
   In file included from include/linux/gcd.h:5,
                    from drivers/gpu/drm/bridge/analogix/anx7625.c:6:
   include/linux/scatterlist.h: In function 'sg_set_buf':
   include/asm-generic/page.h:89:50: warning: ordered comparison of pointer with null pointer [-Wextra]
      89 | #define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
         |                                                  ^~
   include/linux/compiler.h:78:42: note: in definition of macro 'unlikely'
      78 | # define unlikely(x) __builtin_expect(!!(x), 0)
         |                                          ^
   include/linux/scatterlist.h:137:2: note: in expansion of macro 'BUG_ON'
     137 |  BUG_ON(!virt_addr_valid(buf));
         |  ^~~~~~
   include/linux/scatterlist.h:137:10: note: in expansion of macro 'virt_addr_valid'
     137 |  BUG_ON(!virt_addr_valid(buf));
         |          ^~~~~~~~~~~~~~~
   drivers/gpu/drm/bridge/analogix/anx7625.c: At top level:
>> drivers/gpu/drm/bridge/analogix/anx7625.c:1607:16: error: initialization of 'int (*)(struct drm_bridge *, const struct drm_display_mode *, struct drm_display_mode *)' from incompatible pointer type 'bool (*)(struct drm_bridge *, const struct drm_display_mode *, struct drm_display_mode *)' {aka '_Bool (*)(struct drm_bridge *, const struct drm_display_mode *, struct drm_display_mode *)'} [-Werror=incompatible-pointer-types]
    1607 |  .mode_fixup = anx7625_bridge_mode_fixup,
         |                ^~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/bridge/analogix/anx7625.c:1607:16: note: (near initialization for 'anx7625_bridge_funcs.mode_fixup')
   cc1: some warnings being treated as errors


vim +744 drivers/gpu/drm/drm_bridge.c

   723	
   724	static int drm_atomic_bridge_check(struct drm_bridge *bridge,
   725					   struct drm_crtc_state *crtc_state,
   726					   struct drm_connector_state *conn_state)
   727	{
   728		if (bridge->funcs->atomic_check) {
   729			struct drm_bridge_state *bridge_state;
   730			int ret;
   731	
   732			bridge_state = drm_atomic_get_new_bridge_state(crtc_state->state,
   733								       bridge);
   734			if (WARN_ON(!bridge_state))
   735				return -EINVAL;
   736	
   737			ret = bridge->funcs->atomic_check(bridge, bridge_state,
   738							  crtc_state, conn_state);
   739			if (ret)
   740				return ret;
   741		} else if (bridge->funcs->mode_fixup) {
   742			if (bridge->funcs->mode_fixup(bridge, &crtc_state->mode,
   743						       &crtc_state->adjusted_mode))
 > 744				return ret;
   745		}
   746	
   747		return 0;
   748	}
   749	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 26007 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC] drm: return int error code from mode_fixup
  2021-07-13 17:13 ` Grace An
                   ` (2 preceding siblings ...)
  (?)
@ 2021-07-14 10:07 ` kernel test robot
  -1 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2021-07-14 10:07 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 4935 bytes --]

Hi Grace,

[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on drm-intel/for-linux-next]
[also build test ERROR on drm-tip/drm-tip drm-exynos/exynos-drm-next tegra-drm/drm/tegra/for-next linus/master v5.14-rc1 next-20210714]
[cannot apply to drm/drm-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Grace-An/drm-return-int-error-code-from-mode_fixup/20210714-154532
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: xtensa-randconfig-s031-20210713 (attached as .config)
compiler: xtensa-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.3-341-g8af24329-dirty
        # https://github.com/0day-ci/linux/commit/2f5324deb5c8ffa632b47e073c8f7c27046d79a9
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Grace-An/drm-return-int-error-code-from-mode_fixup/20210714-154532
        git checkout 2f5324deb5c8ffa632b47e073c8f7c27046d79a9
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=xtensa 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/gpu/drm/exynos/exynos_drm_crtc.c:112:16: error: initialization of 'int (*)(struct drm_crtc *, const struct drm_display_mode *, struct drm_display_mode *)' from incompatible pointer type 'bool (*)(struct drm_crtc *, const struct drm_display_mode *, struct drm_display_mode *)' {aka '_Bool (*)(struct drm_crtc *, const struct drm_display_mode *, struct drm_display_mode *)'} [-Werror=incompatible-pointer-types]
     112 |  .mode_fixup = exynos_crtc_mode_fixup,
         |                ^~~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/exynos/exynos_drm_crtc.c:112:16: note: (near initialization for 'exynos_crtc_helper_funcs.mode_fixup')
   cc1: some warnings being treated as errors
--
>> drivers/gpu/drm/vc4/vc4_dsi.c:1324:16: error: initialization of 'int (*)(struct drm_encoder *, const struct drm_display_mode *, struct drm_display_mode *)' from incompatible pointer type 'bool (*)(struct drm_encoder *, const struct drm_display_mode *, struct drm_display_mode *)' {aka '_Bool (*)(struct drm_encoder *, const struct drm_display_mode *, struct drm_display_mode *)'} [-Werror=incompatible-pointer-types]
    1324 |  .mode_fixup = vc4_dsi_encoder_mode_fixup,
         |                ^~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/vc4/vc4_dsi.c:1324:16: note: (near initialization for 'vc4_dsi_encoder_helper_funcs.mode_fixup')
   cc1: some warnings being treated as errors
--
>> drivers/gpu/drm/vc4/vc4_vec.c:501:16: error: initialization of 'int (*)(struct drm_encoder *, const struct drm_display_mode *, struct drm_display_mode *)' from incompatible pointer type 'bool (*)(struct drm_encoder *, const struct drm_display_mode *, struct drm_display_mode *)' {aka '_Bool (*)(struct drm_encoder *, const struct drm_display_mode *, struct drm_display_mode *)'} [-Werror=incompatible-pointer-types]
     501 |  .mode_fixup = vc4_vec_encoder_mode_fixup,
         |                ^~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/vc4/vc4_vec.c:501:16: note: (near initialization for 'vc4_vec_encoder_helper_funcs.mode_fixup')
   cc1: some warnings being treated as errors


vim +112 drivers/gpu/drm/exynos/exynos_drm_crtc.c

2466db97e39d54 Andrzej Hajda    2017-09-29  108  
2466db97e39d54 Andrzej Hajda    2017-09-29  109  
a392276d1dec63 Andrzej Hajda    2017-03-14  110  static const struct drm_crtc_helper_funcs exynos_crtc_helper_funcs = {
c3653fede57f30 Andrzej Hajda    2017-08-24  111  	.mode_valid	= exynos_crtc_mode_valid,
2466db97e39d54 Andrzej Hajda    2017-09-29 @112  	.mode_fixup	= exynos_crtc_mode_fixup,
a392276d1dec63 Andrzej Hajda    2017-03-14  113  	.atomic_check	= exynos_crtc_atomic_check,
a392276d1dec63 Andrzej Hajda    2017-03-14  114  	.atomic_begin	= exynos_crtc_atomic_begin,
a392276d1dec63 Andrzej Hajda    2017-03-14  115  	.atomic_flush	= exynos_crtc_atomic_flush,
0b20a0f8c3cb6f Laurent Pinchart 2017-06-30  116  	.atomic_enable	= exynos_drm_crtc_atomic_enable,
64581714b58bc3 Laurent Pinchart 2017-06-30  117  	.atomic_disable	= exynos_drm_crtc_atomic_disable,
a392276d1dec63 Andrzej Hajda    2017-03-14  118  };
a392276d1dec63 Andrzej Hajda    2017-03-14  119  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 37464 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-07-14 10:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-13 17:13 [RFC] drm: return int error code from mode_fixup Grace An
2021-07-13 17:13 ` Grace An
2021-07-13 17:44 ` Daniel Vetter
2021-07-13 17:44   ` Daniel Vetter
2021-07-13 19:34   ` Sam Ravnborg
2021-07-14  9:40 ` kernel test robot
2021-07-14 10:07 ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.