Re: [PATCH 04/25] drm/display: hdmi-state-helper: Reject connectors lacking HDMI funcs
From: Cristian Ciocaltea
Date: Tue Nov 24 2026 - 14:50:35 EST
Hi Maxime,
Thanks for checking this out!
On 11/23/26 2:57 PM, Maxime Ripard wrote:
> On Sat, Nov 14, 2026 at 08:03:28PM +0200, Cristian Ciocaltea wrote:
>> drm_atomic_helper_connector_hdmi_check() must only be used with
>> connectors set up via drmm_connector_hdmi_init(), which guarantees
>> connector->hdmi.funcs is set.
>
> I don't think that's true or mandated anywhere, and just like any other
> helpers, we'll probably end up with a driver reusing parts of the states
> but reimplementing part of the logic.
Ack, I will drop drm_WARN_ON_ONCE() and move the guard in hdmi_compute_config(),
before accessing connector->hdmi.funcs->max_bpc.
I would simply return -EINVAL with a proper debug message, rather than forcing
max_bpc to 0 and letting hdmi_compute_format_bpc() still be called, which would
generate a bunch of potentially misleading "output format not supported for any
bpc count" messages.
Regards,
Cristian
>
> Maxime
>
>> Other connectors used to fail gracefully: with max_bpc and
>> supported_formats both zero, hdmi_compute_config() found no usable
>> format/bpc combination and returned -EINVAL before
>> hdmi_generate_infoframes() dereferenced hdmi.funcs.
>>
>> As those fields are being replaced by drm_connector_hdmi_funcs
>> counterparts, hdmi_compute_config() would dereference hdmi.funcs right
>> away. To preserve the old behaviour, return an error early for such
>> connectors, and use drm_WARN_ON_ONCE() to flag the driver bug.
>>
>> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@xxxxxxxxxxxxx>
>> ---
>> drivers/gpu/drm/display/drm_hdmi_state_helper.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
>> index c50cedc7fa65..f533d5a7aab9 100644
>> --- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c
>> +++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
>> @@ -912,6 +912,9 @@ int drm_atomic_helper_connector_hdmi_check(struct drm_connector *connector,
>> if (!new_conn_state->crtc || !new_conn_state->best_encoder)
>> return 0;
>>
>> + if (drm_WARN_ON_ONCE(connector->dev, !connector->hdmi.funcs))
>> + return -EINVAL;
>> +
>> ret = hdmi_compute_config(connector, new_conn_state, mode);
>> if (ret)
>> return ret;
>>
>> --
>> 2.56.0
>>