dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Maxime Ripard <mripard@kernel.org>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	dri-devel@lists.freedesktop.org, Imre Deak <imre.deak@intel.com>
Subject: Re: [PATCH 05/16] drm/dp_mst: Switch private_obj initialization to reset
Date: Wed, 8 Oct 2025 19:12:28 +0300	[thread overview]
Message-ID: <aOaNbCo8a-DDlDAc@intel.com> (raw)
In-Reply-To: <20251008-phenomenal-industrious-elk-eaa232@houat>

On Wed, Oct 08, 2025 at 04:53:20PM +0200, Maxime Ripard wrote:
> On Wed, Oct 08, 2025 at 05:06:43PM +0300, Ville Syrjälä wrote:
> > On Wed, Oct 08, 2025 at 02:04:03PM +0200, Maxime Ripard wrote:
> > > The DP MST implementation relies on a drm_private_obj, that is
> > > initialized by allocating and initializing a state, and then passing it
> > > to drm_private_obj_init.
> > > 
> > > Since we're gradually moving away from that pattern to the more
> > > established one relying on a reset implementation, let's migrate this
> > > instance to the new pattern.
> > > 
> > > Signed-off-by: Maxime Ripard <mripard@kernel.org>
> > > ---
> > >  drivers/gpu/drm/display/drm_dp_mst_topology.c | 39 ++++++++++++++++++---------
> > >  1 file changed, 26 insertions(+), 13 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/display/drm_dp_mst_topology.c b/drivers/gpu/drm/display/drm_dp_mst_topology.c
> > > index 64e5c176d5cce9df9314f77a0b4c97662c30c070..255fbdcea9f0b6376d15439e3da1dc02be472a20 100644
> > > --- a/drivers/gpu/drm/display/drm_dp_mst_topology.c
> > > +++ b/drivers/gpu/drm/display/drm_dp_mst_topology.c
> > > @@ -5181,10 +5181,34 @@ static void drm_dp_mst_destroy_state(struct drm_private_obj *obj,
> > >  
> > >  	kfree(mst_state->commit_deps);
> > >  	kfree(mst_state);
> > >  }
> > >  
> > > +static void drm_dp_mst_reset(struct drm_private_obj *obj)
> > > +{
> > > +	struct drm_dp_mst_topology_mgr *mgr =
> > > +		to_dp_mst_topology_mgr(obj);
> > > +	struct drm_dp_mst_topology_state *mst_state;
> > > +
> > > +	if (obj->state) {
> > > +		drm_dp_mst_destroy_state(obj, obj->state);
> > > +		obj->state = NULL;
> > 
> > I'm not a big fan of this "free+reallocate without any way to handle
> > failures" pattern.
> > 
> > Currently i915 does not do any of this, and so there are no unhandled
> > points of failure. But the mst and tunneling changes here force it on
> > i915 as well.
> 
> A very theoretical point of failure. If I'm counting right,
> drm_dp_mst_topology_state takes 72 bytes. Any GFP_KERNEL allocation
> of less than 8 pages cannot fail.

Until you start to inject failures, or you blow up the size of the
state. You wouldn't think to check for potential NULL pointer
dereferences before doing that, nor should you have to.

I'd rather not leave potential footguns lying around intentionally.

> So, sure, it's less satisfying to look at, but that's about it. It's
> just as safe and reliable.
> 
> > I think for the common things it would be nicer to just implement
> > the reset as just that "a reset of the current state", and leave
> > the "let's play fast and loose with kmalloc() failures" to the
> > drivers that want it.
> 
> I'm sorry, but I have no idea what you mean by that. It's using the
> exact same pattern we've been using since forever for every driver
> (except, apparently, i915).

The reset() stuff was added specifically to deal with drivers
that didn't have readout. i915 has always had full readout and
never needed it.

> What would you like to change to that pattern to accomodate i915
> requirements?

I think the reset should be ideally done without reallocation,
or perhaps just don't implement reset for the things that don't
need it (mst and tunneling in this case).

-- 
Ville Syrjälä
Intel

  reply	other threads:[~2025-10-08 16:12 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-08 12:03 [PATCH 00/16] drm/atomic: Switch drm_private_obj to reset Maxime Ripard
2025-10-08 12:03 ` [PATCH 01/16] drm/atomic: Add dev pointer to drm_private_obj Maxime Ripard
2025-10-08 13:21   ` Tomi Valkeinen
2025-10-08 15:48   ` Dmitry Baryshkov
2025-10-08 12:04 ` [PATCH 02/16] drm/atomic: Add reset " Maxime Ripard
2025-10-08 13:24   ` Tomi Valkeinen
2025-10-08 12:04 ` [PATCH 03/16] drm/atomic-helper: Add private_obj reset helper Maxime Ripard
2025-10-08 13:27   ` Tomi Valkeinen
2025-10-08 18:35   ` Dmitry Baryshkov
2025-10-08 12:04 ` [PATCH 04/16] drm/bridge: Switch private_obj initialization to reset Maxime Ripard
2025-10-08 18:40   ` Dmitry Baryshkov
2025-10-10  9:47   ` kernel test robot
2025-10-08 12:04 ` [PATCH 05/16] drm/dp_mst: " Maxime Ripard
2025-10-08 14:06   ` Ville Syrjälä
2025-10-08 14:53     ` Maxime Ripard
2025-10-08 16:12       ` Ville Syrjälä [this message]
2025-10-09 14:42         ` Maxime Ripard
2025-10-09 16:03           ` Ville Syrjälä
2025-10-08 16:24     ` Imre Deak
2025-10-14 22:35       ` Dmitry Baryshkov
2025-10-16  6:36         ` Imre Deak
2025-10-08 12:04 ` [PATCH 06/16] drm/dp_tunnel: " Maxime Ripard
2025-10-08 12:04 ` [PATCH 07/16] drm/amdgpu: " Maxime Ripard
2025-10-08 12:04 ` [PATCH 08/16] drm/arm: komeda: " Maxime Ripard
2025-10-08 12:04 ` [PATCH 09/16] drm/ingenic: " Maxime Ripard
2025-10-08 12:04 ` [PATCH 10/16] drm/msm: mdp5: " Maxime Ripard
2025-10-08 18:48   ` Dmitry Baryshkov
2025-10-08 12:04 ` [PATCH 11/16] drm/msm: dpu1: " Maxime Ripard
2025-10-08 18:47   ` Dmitry Baryshkov
2025-10-08 12:04 ` [PATCH 12/16] drm/omapdrm: " Maxime Ripard
2025-10-08 13:29   ` Tomi Valkeinen
2025-10-08 12:04 ` [PATCH 13/16] drm/tegra: " Maxime Ripard
2025-10-08 12:04 ` [PATCH 14/16] drm/vc4: " Maxime Ripard
2025-10-08 12:04 ` [PATCH 15/16] drm/atomic: Remove state argument to drm_atomic_private_obj_init Maxime Ripard
2025-10-08 13:30   ` Tomi Valkeinen
2025-10-08 18:50   ` Dmitry Baryshkov
2025-10-08 12:04 ` [PATCH 16/16] drm/mode_config: Call private obj reset with the other objects Maxime Ripard
2025-10-08 18:52   ` Dmitry Baryshkov

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=aOaNbCo8a-DDlDAc@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=imre.deak@intel.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).