[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250314132709.16a38692@booty>
Date: Fri, 14 Mar 2025 13:27:09 +0100
From: Luca Ceresoli <luca.ceresoli@...tlin.com>
To: Anusha Srivatsa <asrivats@...hat.com>
Cc: Neil Armstrong <neil.armstrong@...aro.org>, Jessica Zhang
<quic_jesszhan@...cinc.com>, Maarten Lankhorst
<maarten.lankhorst@...ux.intel.com>, Maxime Ripard <mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>, David Airlie <airlied@...il.com>,
Simona Vetter <simona@...ll.ch>, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH RFC 1/2] drm/panel: Add new helpers for refcounted panel
allocatons
Hello Anusha,
On Thu, 13 Mar 2025 16:34:45 -0400
Anusha Srivatsa <asrivats@...hat.com> wrote:
> > > +void *__devm_drm_panel_alloc(struct device *dev, size_t size, size_t
> > offset,
> > > + const struct drm_panel_funcs *funcs)
> > > +{
> > > + void *container;
> > > + struct drm_panel *panel;
> > > + int err;
> > > +
> > > + if (!funcs) {
> > > + dev_warn(dev, "Missing funcs pointer\n");
> > > + return ERR_PTR(-EINVAL);
> > > + }
> > > +
> > > + container = kzalloc(size, GFP_KERNEL);
> > > + if (!container)
> > > + return ERR_PTR(-ENOMEM);
> > > +
> > > + panel = container + offset;
> > > + panel->container_offset = offset;
> > > + panel->funcs = funcs;
> > > + kref_init(&panel->refcount);
> > > +
> > > + err = devm_add_action_or_reset(dev, drm_panel_put_void, panel);
> > > + if (err)
> > > + return ERR_PTR(err);
> > > +
> > > + drm_panel_init(panel, dev, funcs, panel->connector_type);
> >
> > panel->connector_type here is uninitialized. You are passing
> > panel->connector_type to drm_panel_init(), which will then copy it into
> > panel->connector_type itself.
> >
> > So you mean I pass connector_type from the driver calling the helper, so
> there is access to the connector type here?
I'm not a panel expert, but I think it makes sense that to create the
panel you need to know the connection type, and that is what Maxime
suggested.
> > > + /**
> > > + * @container_offset: Offset of this struct within the container
> > > + * struct embedding it. Used for refcounted panels to free the
> > > + * embeddeing struct when the refcount drops to zero.
> > > + */
> > > + size_t container_offset;
> >
> > While storing the offset obviously works, and that's what I had
> > implemented in my latest bridge refcounting series, after some
> > discussion with Maxime we agreed storing a container pointer instead of
> > the offset is cleaner. I think it would be good here as well.
> >
> > See:
> > https://lore.kernel.org/lkml/20250227-macho-convivial-tody-cea7dc@houat/
> >
>
> so just void *container instead of size_t container_offset.
Exactly. You can have a look at the patch I sent earlier today:
https://lore.kernel.org/lkml/20250314-drm-bridge-refcount-v7-2-152571f8c694@bootlin.com/
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Powered by blists - more mailing lists