Re: [PATCH] drm/msm/dp: Return MODE_BAD instead of -EINVAL from mode_valid callbacks

From: Guodong Xu

Date: Wed Nov 25 2026 - 07:08:48 EST


Hi Ian,

On Thu, 19 Nov 2026 09:10:46 -0800, Ian Rogers wrote:
> msm_dp_display_mode_valid() and msm_edp_bridge_mode_valid() have
> return type enum drm_mode_status, but return -EINVAL (-22) when dp,
> dp->connector, or mode->clock is zero/NULL. If a mode with zero pixel
> clock is validated and pruned, passing -22 to
> drm_get_mode_status_name() computes a negative array index and fires
> WARN_ON().

Thanks for the patch. At this moment, both checks are dead code:
drm_mode_validate_basic() rejects clock == 0 before any bridge
.mode_valid() runs, and dp and dp->connector are set up before a
mode can be validated.

>
> Return MODE_BAD instead of -EINVAL in both callbacks.
>
> Found via Clang -Wassign-enum on an x86_64 allyesconfig build.
> Verified by building drivers/gpu/drm/msm/dp/dp_display.o and dp_drm.o
> with LLVM=1 W=1 (-Werror) and -Wassign-enum; not runtime-tested on
> Qualcomm Snapdragon DP/eDP hardware.
>
> Fixes: c943b4948b58 ("drm/msm/dp: add displayPort driver support")
> Fixes: 05d001352733 ("drm/msm/dp: use the eDP bridge ops to validate eDP modes")
> Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
> ---
> drivers/gpu/drm/msm/dp/dp_display.c | 2 +-
> drivers/gpu/drm/msm/dp/dp_drm.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
> index c0c150e2c575..51649b584573 100644
> --- a/drivers/gpu/drm/msm/dp/dp_display.c
> +++ b/drivers/gpu/drm/msm/dp/dp_display.c
> @@ -759,7 +759,7 @@ enum drm_mode_status msm_dp_display_mode_valid(struct msm_dp *dp,
>
> if (!dp || !mode_pclk_khz || !dp->connector) {

msm_dp_display_mode_valid() is a helper shared across files. None of
the three conditions can be true today, but it may get more callers
in the future, so keeping the check there looks fine to me.

> DRM_ERROR("invalid params\n");
> - return -EINVAL;
> + return MODE_BAD;

Why not MODE_ERROR? It matches "invalid params" better.

> }
>
> msm_dp_display = container_of(dp, struct msm_dp_display_private, msm_dp_display);
> diff --git a/drivers/gpu/drm/msm/dp/dp_drm.c b/drivers/gpu/drm/msm/dp/dp_drm.c
> index c1e4147bfef1..dd4e8426cfe0 100644
> --- a/drivers/gpu/drm/msm/dp/dp_drm.c
> +++ b/drivers/gpu/drm/msm/dp/dp_drm.c
> @@ -251,7 +251,7 @@ static enum drm_mode_status msm_edp_bridge_mode_valid(struct drm_bridge *bridge,

This one is a static bridge callback.

>
> if (!dp || !mode_pclk_khz || !dp->connector) {

As explained above, none of the three conditions can be true here.
It is dead code.

> DRM_ERROR("invalid params\n");
> - return -EINVAL;
> + return MODE_BAD;
> }

My suggestion is to drop the entire if() check block.

BR,
Guodong

>
> if (msm_dp_wide_bus_available(dp))
> --
> 2.56.1.708.g77570a6a1d-goog