[PATCH v3 2/2] drm/msm/dsi: implement opp table based check for dsi_mgr_bridge_mode_valid()

Dmitry Baryshkov dmitry.baryshkov at linaro.org
Tue Jan 24 20:11:16 UTC 2023


On 12/01/2023 02:16, Abhinav Kumar wrote:
> Currently there is no protection against a user trying to set
> an unsupported mode on DSI. Implement a check based on the opp
> table whether the byte clock for the mode can be supported by
> validating whether an opp table entry exists.
> 
> For devices which have not added opp table support yet, skip
> this check otherwise it will break bootup on those devices.
> 
> changes in v3:
> 	- make the comment shorter
> 	- handle all errors except ENODEV
> 
> Closes: https://gitlab.freedesktop.org/drm/msm/-/issues/15
> Reported-by: Rob Clark <robdclark at gmail.com>
> Signed-off-by: Abhinav Kumar <quic_abhinavk at quicinc.com>

I finally acquired the db410c again. And... this patch breaks support 
for the board. We were wrong on the assumption that the code will return 
-ENODEV when there is no opp table, my bad. devm_pm_opp_set_clkname(), 
called from msm_dsi_host_init(), allocates an empty table if one doesn't 
exist in DT.

> ---
>   drivers/gpu/drm/msm/dsi/dsi_manager.c | 19 +++++++++++++++++++
>   1 file changed, 19 insertions(+)
> 
> diff --git a/drivers/gpu/drm/msm/dsi/dsi_manager.c b/drivers/gpu/drm/msm/dsi/dsi_manager.c
> index 3a1417397283..b20fddb534a7 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_manager.c
> +++ b/drivers/gpu/drm/msm/dsi/dsi_manager.c
> @@ -450,6 +450,25 @@ static enum drm_mode_status dsi_mgr_bridge_mode_valid(struct drm_bridge *bridge,
>   	int id = dsi_mgr_bridge_get_id(bridge);
>   	struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id);
>   	struct mipi_dsi_host *host = msm_dsi->host;
> +	struct platform_device *pdev = msm_dsi->pdev;
> +	struct dev_pm_opp *opp;
> +	unsigned long byte_clk_rate;
> +
> +	byte_clk_rate = dsi_byte_clk_get_rate(host, IS_BONDED_DSI(), mode);
> +
> +	/*
> +	 * fail all errors except -ENODEV as that could mean that opp
> +	 * table is not yet implemented
> +	 */
> +	opp = dev_pm_opp_find_freq_ceil(&pdev->dev, &byte_clk_rate);
> +	if (IS_ERR(opp)) {
> +		if (PTR_ERR(opp) == -ERANGE)
> +			return MODE_CLOCK_RANGE;
> +		else if (PTR_ERR(opp) != -ENODEV)
> +			return MODE_ERROR;
> +	} else {
> +		dev_pm_opp_put(opp);
> +	}
>   
>   	return msm_dsi_host_check_dsc(host, mode);
>   }

-- 
With best wishes
Dmitry



More information about the dri-devel mailing list