[PATCH v5 5/9] drm/imx: Add support for i.MX94 DCIF

Laurentiu Palcu laurentiu.palcu at oss.nxp.com
Fri Oct 31 05:15:08 PDT 2025


Hi Luca,

On Fri, Oct 31, 2025 at 09:14:45AM +0100, Luca Ceresoli wrote:
> Hello Laurentiu,
> 
> On Thu Sep 11, 2025 at 1:37 PM CEST, Laurentiu Palcu wrote:
> 
> ...
> 
> > +static struct drm_bridge *dcif_crtc_get_bridge(struct drm_crtc *crtc,
> > +					       struct drm_crtc_state *crtc_state)
> > +{
> > +	struct drm_connector_state *conn_state;
> > +	struct drm_encoder *encoder;
> > +	struct drm_connector *conn;
> > +	struct drm_bridge *bridge;
> > +	int i;
> > +
> > +	for_each_new_connector_in_state(crtc_state->state, conn, conn_state, i) {
> > +		if (crtc != conn_state->crtc)
> > +			continue;
> > +
> > +		encoder = conn_state->best_encoder;
> > +
> > +		bridge = drm_bridge_chain_get_first_bridge(encoder);
> 
> The bridge returned by drm_bridge_chain_get_first_bridge() is refcounted
> since v6.18-rc1 [0], so you have to put that reference...
> 
> > +		if (bridge)
> > +			return bridge;
> > +	}
> > +
> > +	return NULL;
> > +}
> > +
> > +static void dcif_crtc_query_output_bus_format(struct drm_crtc *crtc,
> > +					      struct drm_crtc_state *crtc_state)
> > +{
> > +	struct dcif_crtc_state *dcif_state = to_dcif_crtc_state(crtc_state);
> > +	struct drm_bridge_state *bridge_state;
> > +	struct drm_bridge *bridge;
> > +
> > +	dcif_state->bus_format = MEDIA_BUS_FMT_RGB888_1X24;
> > +	dcif_state->bus_flags = 0;
> > +
> > +	bridge = dcif_crtc_get_bridge(crtc, crtc_state);
> > +	if (!bridge)
> > +		return;
> > +
> > +	bridge_state = drm_atomic_get_new_bridge_state(crtc_state->state, bridge);
> > +	if (!bridge_state)
> > +		return;
> > +
> > +	dcif_state->bus_format = bridge_state->input_bus_cfg.format;
> > +	dcif_state->bus_flags = bridge_state->input_bus_cfg.flags;
> 
> ...perhaps here, when both the bridge pointer and the bridge_state pointer
> referencing it go out of scope.
> 
> > +}
> 
> You can just call drm_bridge_put(bridge) there, or (at your option) use a
> cleanup action:
> 
>  static void dcif_crtc_query_output_bus_format(struct drm_crtc *crtc,
>                                                struct drm_crtc_state *crtc_state)
>  {
>          struct dcif_crtc_state *dcif_state = to_dcif_crtc_state(crtc_state);
>          struct drm_bridge_state *bridge_state;
> -        struct drm_bridge *bridge;
> 
>          dcif_state->bus_format = MEDIA_BUS_FMT_RGB888_1X24;
>          dcif_state->bus_flags = 0;
> 
> -        bridge = dcif_crtc_get_bridge(crtc, crtc_state);
> +        struct drm_bridge *bridge __free(drm_bridge_put) = dcif_crtc_get_bridge(crtc, crtc_state);
>          if (!bridge)
>                  return;
> 
>          bridge_state = drm_atomic_get_new_bridge_state(crtc_state->state, bridge);
>          if (!bridge_state)
>                  return;
> 
>          dcif_state->bus_format = bridge_state->input_bus_cfg.format;
>          dcif_state->bus_flags = bridge_state->input_bus_cfg.flags;
>  }
> 
> This would call drm_bridge_put() at end of scope, i.e. end of function.
> 
> You can also have a look at recent commits involving drm_bridge_put (git
> log -p -Gdrm_bridge_put v6.16..origin/master) to see how other parts of the
> kernel have added drm_bridge_put().

Thanks for reviewing and the heads-up on using drm_bridge_put(). I'll
send a v6 next week with the fix.

Thanks,
Laurentiu

> 
> [0] https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/8fa5909400f377351836419223c33f1131f0f7d3
> 
> Best regards,
> Luca
> 
> ---
> Luca Ceresoli, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com



More information about the linux-arm-kernel mailing list