Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4408298ybx; Mon, 4 Nov 2019 12:53:31 -0800 (PST) X-Google-Smtp-Source: APXvYqx8yRIj61eWXQiqTz5oLj6/EdVUe2QJxU+Dxu5scXFUDDYI7kjhe0bc3GW/AEF0GbW8yh+l X-Received: by 2002:a17:906:400f:: with SMTP id v15mr7852902ejj.126.1572900811135; Mon, 04 Nov 2019 12:53:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572900811; cv=none; d=google.com; s=arc-20160816; b=OZNrosu5nGm8GGnqKScRc7osCZ/CAaCifZtNmYBYYFMxlU+iOigPbAA2jPDACkYwFP 8SHljhIFcwOziapYDibKKTj2N2W5w/AJB1DjCGqoPO+en1ZooVNdp8TP42e7LjlSWFJr hSIX9ffGYCOAma4D/TJSd+O2ArtwEPZqK9yIPmA07IOQ69KG5R9v6QTcedo+1k4M0VpJ 1+0qBfgodW+OZrIvhOmjqbSDgmBCfFMhS8A0fJM46ryX8zJuJB/tejT/G9TNyRwV3pPj ZyCOgb80Hzg4hV+Hy4SnGXQOoWwty75sdfKtn+c7yYgnW/aYCJXeKqiM3b5oXQGCqry/ 1gqQ== 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; bh=s2ZNXUR34u/osod04+/K/nglQRXLaZQJIkwz5eSid6U=; b=MGqBAlmNopGJKi5jKxAeyEdIlvZQJTHrECxU/oBrdd9U3Ttkyq1M/+XrcCp4dUXWBc 9wxrXjcMd48Tb/OqSs43ukUGMxntTJ42UzCROTw/FREhHW8UDVhYyeDYFAmNS2B4u3v0 oIryoejH2rplYZKy/46p6Oi2pSGuOM2Ezn6XL+didYgh9HomLLvqab8LZUgQlaOqnyjk OkEAKWNI6kfQEaLr2m2KOxJRUmH1pfd5O1VJsJlMfAUUtmKODHk+S3b3wVEbZptu9634 zM17TWYoPyiGHJzNwqfl8ZIpXPQrwdj6KIQ39B7+It8YfrDN6dcqtdzRysUsEVAUcgel 7Rig== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g21si8462638ejs.171.2019.11.04.12.53.08; Mon, 04 Nov 2019 12:53:31 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729905AbfKDUuU (ORCPT + 99 others); Mon, 4 Nov 2019 15:50:20 -0500 Received: from mga17.intel.com ([192.55.52.151]:52436 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729074AbfKDUuU (ORCPT ); Mon, 4 Nov 2019 15:50:20 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Nov 2019 12:50:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,268,1569308400"; d="scan'208";a="219571189" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by FMSMGA003.fm.intel.com with SMTP; 04 Nov 2019 12:50:11 -0800 Received: by stinkbox (sSMTP sendmail emulation); Mon, 04 Nov 2019 22:50:10 +0200 Date: Mon, 4 Nov 2019 22:50:10 +0200 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: Rob Clark Cc: Rob Clark , dri-devel , David Airlie , open list , Sean Paul , Sean Paul Subject: Re: [PATCH 2/2] drm/atomic: clear new_state pointers at hw_done Message-ID: <20191104205010.GM1208@intel.com> References: <20191101180713.5470-1-robdclark@gmail.com> <20191101180713.5470-2-robdclark@gmail.com> <20191101192458.GI1208@intel.com> <20191101214431.GJ1208@intel.com> <20191104184156.GL1208@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.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 04, 2019 at 11:13:59AM -0800, Rob Clark wrote: > On Mon, Nov 4, 2019 at 10:42 AM Ville Syrj?l? > wrote: > > > > On Fri, Nov 01, 2019 at 03:14:09PM -0700, Rob Clark wrote: > > > On Fri, Nov 1, 2019 at 2:44 PM Ville Syrj?l? > > > wrote: > > > > > > > > On Fri, Nov 01, 2019 at 12:49:02PM -0700, Rob Clark wrote: > > > > > On Fri, Nov 1, 2019 at 12:25 PM Ville Syrj?l? > > > > > wrote: > > > > > > > > > > > > On Fri, Nov 01, 2019 at 11:07:13AM -0700, Rob Clark wrote: > > > > > > > From: Rob Clark > > > > > > > > > > > > > > The new state should not be accessed after this point. Clear the > > > > > > > pointers to make that explicit. > > > > > > > > > > > > > > This makes the error corrected in the previous patch more obvious. > > > > > > > > > > > > > > Signed-off-by: Rob Clark > > > > > > > --- > > > > > > > drivers/gpu/drm/drm_atomic_helper.c | 29 +++++++++++++++++++++++++++++ > > > > > > > 1 file changed, 29 insertions(+) > > > > > > > > > > > > > > diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c > > > > > > > index 732bd0ce9241..176831df8163 100644 > > > > > > > --- a/drivers/gpu/drm/drm_atomic_helper.c > > > > > > > +++ b/drivers/gpu/drm/drm_atomic_helper.c > > > > > > > @@ -2234,13 +2234,42 @@ EXPORT_SYMBOL(drm_atomic_helper_fake_vblank); > > > > > > > */ > > > > > > > void drm_atomic_helper_commit_hw_done(struct drm_atomic_state *old_state) > > > > > > > { > > > > > > > + struct drm_connector *connector; > > > > > > > + struct drm_connector_state *old_conn_state, *new_conn_state; > > > > > > > struct drm_crtc *crtc; > > > > > > > struct drm_crtc_state *old_crtc_state, *new_crtc_state; > > > > > > > + struct drm_plane *plane; > > > > > > > + struct drm_plane_state *old_plane_state, *new_plane_state; > > > > > > > struct drm_crtc_commit *commit; > > > > > > > + struct drm_private_obj *obj; > > > > > > > + struct drm_private_state *old_obj_state, *new_obj_state; > > > > > > > int i; > > > > > > > > > > > > > > + /* > > > > > > > + * After this point, drivers should not access the permanent modeset > > > > > > > + * state, so we also clear the new_state pointers to make this > > > > > > > + * restriction explicit. > > > > > > > + * > > > > > > > + * For the CRTC state, we do this in the same loop where we signal > > > > > > > + * hw_done, since we still need to new_crtc_state to fish out the > > > > > > > + * commit. > > > > > > > + */ > > > > > > > + > > > > > > > + for_each_oldnew_connector_in_state(old_state, connector, old_conn_state, new_conn_state, i) { > > > > > > > + old_state->connectors[i].new_state = NULL; > > > > > > > + } > > > > > > > + > > > > > > > + for_each_oldnew_plane_in_state(old_state, plane, old_plane_state, new_plane_state, i) { > > > > > > > + old_state->planes[i].new_state = NULL; > > > > > > > + } > > > > > > > + > > > > > > > + for_each_oldnew_private_obj_in_state(old_state, obj, old_obj_state, new_obj_state, i) { > > > > > > > + old_state->private_objs[i].new_state = NULL; > > > > > > > + } > > > > > > > + > > > > > > > for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) { > > > > > > > old_state->crtcs[i].new_self_refresh_active = new_crtc_state->self_refresh_active; > > > > > > > + old_state->crtcs[i].new_state = NULL; > > > > > > > > > > > > That's going to be a real PITA when doing programming after the fact from > > > > > > a vblank worker. It's already a pain that the new_crtc_state->state is > > > > > > getting NULLed somewhere. > > > > > > > > > > > > > > > > I think you already have that problem, this just makes it explicit. > > > > > > > > I don't yet. Except on a branch where I have my vblank workers. > > > > And I think the only problem is having the helpers/core clobber > > > > the pointers when it should not. I don't see why it can't just > > > > leave them be and let me use them. > > > > > > > > > > I guess it comes down to what assumptions you can make in driver > > > backend. But if you can, for example, move planes between crtcs, I > > > think you can't make assumptions about the order in which things > > > complete even if you don't have commits overtaking each other on a > > > single crtc.. > > > > IMO this whole notion of accessing new_crtc_state & co. being unsafe > > for some reason is wrong. I think as long as I have the drm_atomic_state > > I should be able to look at the new/old states within. > > > > accessing new state only works if you can guarantee the order in which > commits complete, which I don't think you can do in the general sense. Doesn't feel like it should take a lot of rocket science to guarantee the states get freed in the right order. -- Ville Syrj?l? Intel