lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20180306074055.GU22212@phenom.ffwll.local>
Date:   Tue, 6 Mar 2018 08:40:55 +0100
From:   Daniel Vetter <daniel@...ll.ch>
To:     Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>
Cc:     Rob Clark <robdclark@...il.com>, dri-devel@...ts.freedesktop.org,
        Archit Taneja <architt@...eaurora.org>,
        linux-arm-msm@...r.kernel.org,
        Gustavo Padovan <gustavo@...ovan.org>,
        Sean Paul <seanpaul@...omium.org>,
        David Airlie <airlied@...ux.ie>, linux-kernel@...r.kernel.org,
        Daniel Vetter <daniel@...ll.ch>
Subject: Re: [PATCH 1/4] drm/atomic: integrate modeset lock with private
 objects

On Tue, Mar 06, 2018 at 08:29:20AM +0100, Daniel Vetter wrote:
> On Wed, Feb 21, 2018 at 04:19:40PM +0100, Maarten Lankhorst wrote:
> > Hey,
> > 
> > Op 21-02-18 om 15:37 schreef Rob Clark:
> > > Follow the same pattern of locking as with other state objects.  This
> > > avoids boilerplate in the driver.
> > I'm afraid this will prohibit any uses of this on i915, since it still uses legacy lock_all().
> > 
> > Oh well, afaict nothing in i915 uses private objects, so I don't think it's harmful. :)
> 
> We do use private objects, as part of dp mst helpers. But I also thought
> that the only users left of lock_all are in the debugfs code, where this
> really doesn't matter all that much.

Correction, we use it in other places than debugfs. But thanks to Ville's
private state obj refactoring we now have drm_atomic_private_obj_init(),
so it's easy to add all the private state objects to a new list in
drm_dev->mode_config.private_states or so, and use that list in
drm_modeset_lock_all_ctx to also take driver private locks.

I think that would actually be useful in other places, just in case.
-Daniel

> 
> > Could you cc intel-gfx just in case?
> 
> Yeah, best to double-check with CI.
> 
> > > Signed-off-by: Rob Clark <robdclark@...il.com>
> > > ---
> > >  drivers/gpu/drm/drm_atomic.c | 9 ++++++++-
> > >  include/drm/drm_atomic.h     | 5 +++++
> > >  2 files changed, 13 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> > > index fc8c4da409ff..004e621ab307 100644
> > > --- a/drivers/gpu/drm/drm_atomic.c
> > > +++ b/drivers/gpu/drm/drm_atomic.c
> > > @@ -1078,6 +1078,8 @@ drm_atomic_private_obj_init(struct drm_private_obj *obj,
> > >  {
> > >  	memset(obj, 0, sizeof(*obj));
> > >  
> > > +	drm_modeset_lock_init(&obj->lock);
> > > +
> > >  	obj->state = state;
> > >  	obj->funcs = funcs;
> > >  }
> > > @@ -1093,6 +1095,7 @@ void
> > >  drm_atomic_private_obj_fini(struct drm_private_obj *obj)
> > >  {
> > >  	obj->funcs->atomic_destroy_state(obj, obj->state);
> > > +	drm_modeset_lock_fini(&obj->lock);
> > >  }
> > >  EXPORT_SYMBOL(drm_atomic_private_obj_fini);
> > >  
> > > @@ -1113,7 +1116,7 @@ struct drm_private_state *
> > >  drm_atomic_get_private_obj_state(struct drm_atomic_state *state,
> > >  				 struct drm_private_obj *obj)
> > >  {
> > > -	int index, num_objs, i;
> > > +	int index, num_objs, i, ret;
> > >  	size_t size;
> > >  	struct __drm_private_objs_state *arr;
> > >  	struct drm_private_state *obj_state;
> > > @@ -1122,6 +1125,10 @@ drm_atomic_get_private_obj_state(struct drm_atomic_state *state,
> > >  		if (obj == state->private_objs[i].ptr)
> > >  			return state->private_objs[i].state;
> > >  
> > > +	ret = drm_modeset_lock(&obj->lock, state->acquire_ctx);
> > > +	if (ret)
> > > +		return ERR_PTR(ret);
> > > +
> > >  	num_objs = state->num_private_objs + 1;
> > >  	size = sizeof(*state->private_objs) * num_objs;
> > >  	arr = krealloc(state->private_objs, size, GFP_KERNEL);
> > > diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
> > > index 09076a625637..9ae53b73c9d2 100644
> > > --- a/include/drm/drm_atomic.h
> > > +++ b/include/drm/drm_atomic.h
> > > @@ -218,6 +218,11 @@ struct drm_private_state_funcs {
> > >   * &drm_modeset_lock is required to duplicate and update this object's state.
> > >   */
> > >  struct drm_private_obj {
> > > +	/**
> > > +	 * @lock: Modeset lock to protect the state object.
> > > +	 */
> > > +	struct drm_modeset_lock lock;
> > > +
> > >  	/**
> > >  	 * @state: Current atomic state for this driver private object.
> > >  	 */
> > 
> > 
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ