Received: by 10.223.185.116 with SMTP id b49csp800752wrg; Wed, 21 Feb 2018 07:08:39 -0800 (PST) X-Google-Smtp-Source: AH8x226TW2vvN1aUbMFsDLey5BvBeR7E1ZbncNhUAXUkviI7dY+13jAGVua3VhQgevoDNb4g1LUG X-Received: by 2002:a17:902:34f:: with SMTP id 73-v6mr3342451pld.55.1519225719769; Wed, 21 Feb 2018 07:08:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519225719; cv=none; d=google.com; s=arc-20160816; b=qIyt94LFhzAgTFjjo5CLpqlH58x5+jK0s+ngnF3fMCxS5VIdPpNXZ4UR02KR+o7eZG 9UpAo/x4nur4c0HeRf/PYjHeU69az7RQn99VDnfehSBfIPli8uhC5EgS87JZAs3Rf6wY cO5Wa+AxGFfsZS+glb5A+lziWDGO3xPcm9vBqjFSwoMz6GwR6XvO9cDbVPbOyJnikHVF Vg1UZUegY6Px4MOtnjJEAjt22cWnbEQ7gQc0pfQymn/hGojIuvFHA2rmK4J9+7epSq0x 9OkjmRnI+e75SQTBgPWsEMarnO3QYr3P/C9IUmFGi+psrkfOcaWkfi2YIxu4xmkJIf9F 3wVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=JTDw31VamUnUVfGPdXLCskXi4UGXGND7qzndyhfG3+M=; b=tQAiBq15s3mQ56lyHI8It1eyDlfWi5mKmXADqOOrTLfwQUBE0I3XL0AFlN7zyy1aCR lMojslEFqCwfvOyX8zN/4s06FXvLiwXWgP3YvSlCm1g2WmlTJh//0vAjev9rbQJFToWi oZBxGEb7uRkIILgEn6EQ/KvQJhdO9dXHH7gXQ5VKYyczbv+pEwJRLXG/Ltks6hQDKZrz EcCOW9ftmO4GuMpFpffSV+s3X8A254SIvZwk6XVogvIBOR/TnkNa/2VaJNDpq5eMJCx7 LXZ6BejlWTnC4J2MUMPHIl4PDYoqYhgU1vvr/6WFAU9ZuWU9brqWBUcrMoedfqp22umH fbxA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a14-v6si1731532plt.693.2018.02.21.07.08.24; Wed, 21 Feb 2018 07:08:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965889AbeBUPHc (ORCPT + 99 others); Wed, 21 Feb 2018 10:07:32 -0500 Received: from mga04.intel.com ([192.55.52.120]:5178 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932826AbeBUPHb (ORCPT ); Wed, 21 Feb 2018 10:07:31 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Feb 2018 07:07:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,543,1511856000"; d="scan'208";a="21888900" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by fmsmga002.fm.intel.com with SMTP; 21 Feb 2018 07:07:28 -0800 Received: by stinkbox (sSMTP sendmail emulation); Wed, 21 Feb 2018 17:07:27 +0200 Date: Wed, 21 Feb 2018 17:07:27 +0200 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: Rob Clark Cc: dri-devel , David Airlie , linux-arm-msm , Linux Kernel Mailing List Subject: Re: [PATCH 1/4] drm/atomic: integrate modeset lock with private objects Message-ID: <20180221150727.GO5453@intel.com> References: <20180221143730.30285-1-robdclark@gmail.com> <20180221143730.30285-2-robdclark@gmail.com> <20180221144919.GN5453@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.7.2 (2016-11-26) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 21, 2018 at 09:54:49AM -0500, Rob Clark wrote: > On Wed, Feb 21, 2018 at 9:49 AM, Ville Syrj?l? > wrote: > > On Wed, Feb 21, 2018 at 09:37:21AM -0500, Rob Clark wrote: > >> Follow the same pattern of locking as with other state objects. This > >> avoids boilerplate in the driver. > > > > I'm not sure we really want to do this. What if the driver wants a > > custom locking scheme for this state? > > That seems like something we want to discourage, ie. all the more > reason for this patch. > > There is no reason drivers could not split their global state into > multiple private objs's, each with their own lock, for more fine > grained locking. That is basically the only valid reason I can think > of for "custom locking". In i915 we have at least one case that would want something close to an rwlock. Any crtc lock is enough for read, need all of them for write. Though if we wanted to use private objs for that we might need to actually make the states refcounted as well, otherwise I can imagine we might land in some use-after-free issues once again. Maybe we could duplicate the state into per-crtc and global copies, but then we have to keep all of those in sync somehow which doesn't sound particularly pleasant. > > (And ofc drivers could add there own locks in addition to what is done > by core, but I'd rather look at that on a case by case basis, rather > than it being part of the boilerplate in each driver.) > > BR, > -R > > >> > >> Signed-off-by: Rob Clark > >> --- > >> 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. > >> */ > >> -- > >> 2.14.3 > >> > >> _______________________________________________ > >> dri-devel mailing list > >> dri-devel@lists.freedesktop.org > >> https://lists.freedesktop.org/mailman/listinfo/dri-devel > > > > -- > > Ville Syrj?l? > > Intel OTC -- Ville Syrj?l? Intel OTC