Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/msm/dsi: properly handle the case of empty OPP table in dsi_mgr_bridge_mode_valid

It was left unnoticed during the review that even if there is no OPP
table in device tree, one will be created by a call to the function
devm_pm_opp_set_clkname(). This leads to dsi_mgr_bridge_mode_valid()
rejecting all modes if DT contains no OPP table for the DSI host.

Rework dsi_mgr_bridge_mode_valid() to handle this case by actually
checking that the table is populated with frequency entries before
returning an error.

Fixes: 8328041b8c82 ("drm/msm/dsi: implement opp table based check for dsi_mgr_bridge_mode_valid()")
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
Patchwork: https://patchwork.freedesktop.org/patch/520076/
Link: https://lore.kernel.org/r/20230124203600.3488766-1-dmitry.baryshkov@linaro.org
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

+11 -10
+11 -10
drivers/gpu/drm/msm/dsi/dsi_manager.c
··· 456 456 457 457 byte_clk_rate = dsi_byte_clk_get_rate(host, IS_BONDED_DSI(), mode); 458 458 459 - /* 460 - * fail all errors except -ENODEV as that could mean that opp 461 - * table is not yet implemented 462 - */ 463 459 opp = dev_pm_opp_find_freq_ceil(&pdev->dev, &byte_clk_rate); 464 - if (IS_ERR(opp)) { 465 - if (PTR_ERR(opp) == -ERANGE) 466 - return MODE_CLOCK_RANGE; 467 - else if (PTR_ERR(opp) != -ENODEV) 468 - return MODE_ERROR; 469 - } else { 460 + if (!IS_ERR(opp)) { 470 461 dev_pm_opp_put(opp); 462 + } else if (PTR_ERR(opp) == -ERANGE) { 463 + /* 464 + * An empty table is created by devm_pm_opp_set_clkname() even 465 + * if there is none. Thus find_freq_ceil will still return 466 + * -ERANGE in such case. 467 + */ 468 + if (dev_pm_opp_get_opp_count(&pdev->dev) != 0) 469 + return MODE_CLOCK_RANGE; 470 + } else { 471 + return MODE_ERROR; 471 472 } 472 473 473 474 return msm_dsi_host_check_dsc(host, mode);