Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp794135ybx; Fri, 1 Nov 2019 11:19:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZj8kiAAvI8p3uO4CzNm3Yr9OyHIJ87t6vipBGC5g/x+1LvAoWA6FESOpD30lHqo/ykTWo X-Received: by 2002:a50:eb8e:: with SMTP id y14mr14459845edr.285.1572632370782; Fri, 01 Nov 2019 11:19:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572632370; cv=none; d=google.com; s=arc-20160816; b=t2dKq4LOIXFN44lXu940/l37COLoOon2YMxq36j+T5xoKWhE+ZkbueZPvvIR5vIlvh QZpy0/jVQuE8EkBEDei0iDYBUSELLqaeXqfy5GCzVvdtUcZjaX+DFIby2rlvC1458jBb jZa6X4sFN2j/fhUBH6N1tW6ILpdXIA59ivskbanlw6ANaHKv5llEwn8/N0r+tLM10xGM hgnutW6/a+GzCgeh9rE/6OgfjYxasLy/n4xtN8VPegaew2p4TPzuJxyHktfflu3hhl0S 9XgnPl8YFu/zlntO3Ex6QTnavHs67XJ+CzuWs1fggiS3MwTLXE0widarFPkhv9++f61m JZLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=D6pp+waK1B6eoQZsfgu20T9S0S5gE50J59ZyY893XeU=; b=x4wJ+hg/kl/lPJZ2iEMPnpYP3gYdLubt7nMCagm2KR3GwmOBd8CCvHCRYtCagFQNV/ /j50GgjrSmRKQV8eKB8z+r9oNsgCkBS7aHtKVCa1c1EECxq1B091PYbeL9TSUqcao0Lu 7mwcWboeqn9vPAm/AH/6l83oZUMsyiJgC32YLPvPYw7J6ieDc6JVSgrzhEkEpLGi8bbq TTCrFr2FPaEZ7bU70HWakyBVy6/Bq9mT+hh7DY+xIc/+v0IaxNKWVzFnNzQkyeJSyogF ZT2ZfK1Y9xs3W1b4P6hI0oXaAj1trK3ttzVYcrkmDq6rQb3R+614NYFxSqbQe+3NcZGR dDXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ctnx2Mq7; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k22si341439eji.282.2019.11.01.11.19.06; Fri, 01 Nov 2019 11:19:30 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ctnx2Mq7; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727350AbfKASLn (ORCPT + 99 others); Fri, 1 Nov 2019 14:11:43 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:34245 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726866AbfKASLn (ORCPT ); Fri, 1 Nov 2019 14:11:43 -0400 Received: by mail-pg1-f195.google.com with SMTP id e4so6975753pgs.1 for ; Fri, 01 Nov 2019 11:11:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=D6pp+waK1B6eoQZsfgu20T9S0S5gE50J59ZyY893XeU=; b=ctnx2Mq7v0ZwoxZpgw8YqdbWutmx0MLZKmxmioikkvICWrTw1w/6AKRvR8X0KBJo1Q H0q5nPYMGRreXVKlEPeoh4VtEN1K97KsqpD13ts5v4lWQFJg4H2P5+JzG7oAlzLrVo1p oI5Os+HHsLwy+OUClFC8ZVGFwLA6KHN6/4DoMryIAOT7NsStmpHqwZFUtokc9oZL/kT+ cGvXVaiQTIs40ctu7V2vStfRIJlOGEpU2g9cmAKmuhy+UxHp9xJWz1vqEaJ+QNmFvjN+ y8MDer/CsYviNag0SnshQ6oPqAx3IpnuaI3HL54iKUW3BxQAZRGqCosbW1KAi6YtEudk jw3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=D6pp+waK1B6eoQZsfgu20T9S0S5gE50J59ZyY893XeU=; b=pK0vGwt+s512Z6aTBFuE6rDJ5mYzl7Jn5wf4J5nrHm8ETDzyUM8HGX0CS5ql+VqfA+ 96usvDdOL+AKbVnFbr0MnLH72HaZEcoCJslPmicIFcwm6bCZwzBkYqOwPdaae6SUKlzz ZHMF4k1fj54ZoOJZeRDF5Hy981FDSvX75pL1U0gInmr1XtsgtIuqU2QnI1P0c7/Bjz5t rqqHa6YzBWKbMXfsCfq2lPwJiq/Vw2FWMZ8YA2SbAAZpjV7b0LQXdqOVhwI+D0yIV7rM /irevEG8tzwPgEQJ94YKj6tB03P0ovJI6lG8qqeZq0YqrbJqe6fyEL0POsWpbkLlC0xg ylIg== X-Gm-Message-State: APjAAAUZXSpl4KvxSCYMehHNlTIYiFI+LA55UFOOVXNkvLaiFx3dn+V6 O+33MJR3Y/dBgxHTQrRLLQo= X-Received: by 2002:a17:90a:8816:: with SMTP id s22mr12344442pjn.31.1572631902246; Fri, 01 Nov 2019 11:11:42 -0700 (PDT) Received: from localhost ([100.118.89.209]) by smtp.gmail.com with ESMTPSA id h5sm11525487pjc.9.2019.11.01.11.11.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2019 11:11:41 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: Sean Paul , Maarten Lankhorst , Rob Clark , Maxime Ripard , Sean Paul , David Airlie , Daniel Vetter , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 2/2] drm/atomic: clear new_state pointers at hw_done Date: Fri, 1 Nov 2019 11:07:13 -0700 Message-Id: <20191101180713.5470-2-robdclark@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191101180713.5470-1-robdclark@gmail.com> References: <20191101180713.5470-1-robdclark@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; commit = new_crtc_state->commit; if (!commit) -- 2.21.0