Skip to content

Commit

Permalink
drm: return int error code from mode_fixup
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Grace An authored and intel-lab-lkp committed Jul 14, 2021
1 parent d5bfbad commit 2f5324d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions drivers/gpu/drm/drm_atomic_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand All @@ -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;
}
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/drm_bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,9 +739,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;
Expand Down
2 changes: 1 addition & 1 deletion include/drm/drm_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
/**
Expand Down
4 changes: 2 additions & 2 deletions include/drm/drm_modeset_helper_vtables.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 2f5324d

Please sign in to comment.