public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Luca Ceresoli <luca.ceresoli@bootlin.com>
To: Anusha Srivatsa <asrivats@redhat.com>
Cc: Neil Armstrong <neil.armstrong@linaro.org>,
	Jessica Zhang <quic_jesszhan@quicinc.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC 1/2] drm/panel: Add new helpers for refcounted panel allocatons
Date: Fri, 14 Mar 2025 13:27:09 +0100	[thread overview]
Message-ID: <20250314132709.16a38692@booty> (raw)
In-Reply-To: <CAN9Xe3TeKTZtcMPtae7h33H=B-veGW93z8nMpHK+pEuNdh4=2A@mail.gmail.com>

Hello Anusha,

On Thu, 13 Mar 2025 16:34:45 -0400
Anusha Srivatsa <asrivats@redhat.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

  parent reply	other threads:[~2025-03-14 12:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-13  0:54 [PATCH RFC 0/2] drm/panel: Refcounted panel allocation Anusha Srivatsa
2025-03-13  0:54 ` [PATCH RFC 1/2] drm/panel: Add new helpers for refcounted panel allocatons Anusha Srivatsa
2025-03-13 10:09   ` Luca Ceresoli
2025-03-13 14:34     ` Maxime Ripard
     [not found]     ` <CAN9Xe3TeKTZtcMPtae7h33H=B-veGW93z8nMpHK+pEuNdh4=2A@mail.gmail.com>
2025-03-14 12:27       ` Luca Ceresoli [this message]
2025-03-13 14:42   ` Maxime Ripard
2025-03-13  0:54 ` [PATCH RFC 2/2] drm/panel/panel-simple: Use the new allocation in place of devm_kzalloc() Anusha Srivatsa
2025-03-17 10:12   ` Neil Armstrong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250314132709.16a38692@booty \
    --to=luca.ceresoli@bootlin.com \
    --cc=airlied@gmail.com \
    --cc=asrivats@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=quic_jesszhan@quicinc.com \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox