From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D59B1DE3B3 for ; Thu, 16 Jan 2025 11:27:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737026863; cv=none; b=RXk0PH61eTXWQ128C1dd8CKb1U/n6GuXjW25vht47jZ02JMl+S2qZ3vt1x+yDIxQj/rsrmuIzX/rwlVkadbF1llqhy+5l5j3dgJXtmzN9kXVyyNInu181TvEmqVpPWwNICE1lxJzZ+Zg26iyKBRu7YsgndFCA+lw91YOGpt5s4Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737026863; c=relaxed/simple; bh=QWyNiP689EamKpiI0Yz4WmMq8bVwXcL/yvIYIHC2mYc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Cbw9RuWADcHSg40N0ECAKn+ndLIC7S0zzrpsIR+G0KwvNMnHMxwghoiM6mONxMD2WEC9dLuOEsGJ/uMKkh4tkzX8ppIf+gT2N1sfXVECBfKsxb95plWDui1NMheX0NodQUwtBHU7TbderXvDE3V02Qb5pe4rc+0wq65O+CXnaO0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch; spf=none smtp.mailfrom=ffwll.ch; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b=U6Ys5Qgl; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ffwll.ch Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="U6Ys5Qgl" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4361e89b6daso4649505e9.3 for ; Thu, 16 Jan 2025 03:27:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; t=1737026860; x=1737631660; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=a0nKJjtH2ApPSyDxi76icAcEp1aOGZMrOf/6aGFgnYQ=; b=U6Ys5Qgl0F0eMVpMBqWG5zD36afs53Z5yDsJ96gvZjApHdk9Wm8OM8Anp5cJNVb5tA 9QzIKx8S2xqAMFfpN2lDucVHu+Phcx94ovYlKnMcM6K4VYcudyoLZ9bjb62/jMULFTHN Xe1nte0L+3SzCFYxgZ+8dzaaD2aQRQXYKOK7A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737026860; x=1737631660; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=a0nKJjtH2ApPSyDxi76icAcEp1aOGZMrOf/6aGFgnYQ=; b=J34fdWLaClq5MF8mpvhWLJur0dkKhF6PhfW0DiOgXgrBAxdieJ1en4owYNmul5lJTe PGbpRbS71+/xLEBZNdo2o8P7upVfP2ZYwmXWwY//NOEL+sjBDC+FTgnBEEtLAPLEya58 IiNBUB7ot86Tf0XoaJZiCCsBCVPi/gTL8thsQfJHHPS6D/8OxOfZP6hP0W+aziRBHc6t BER7tolmcY3mh3nT/+EzQdJ9HSYY9Ekj+cF69zhb19+DrghcDg+hoEZaHBhO3lXT3Ntm trF5zEt0reoZWxHJh3PIYSW1cTJuNjs6ofQaBqvt5W71LhjXOcLUBCSUk0BYmP0E/40s RarQ== X-Forwarded-Encrypted: i=1; AJvYcCVTX10p/WWCxt+ePpk2fOILN9pvnpaYbVJZX++a5ydNJrCYGtVuQI7cUf/7wE99gn6867i4toMLyHoIbW0=@vger.kernel.org X-Gm-Message-State: AOJu0YzNaKRpN/YjFnFxnCalmB7n9S8uXzrc02j3JPyOHnnaMA9UtbMU PVIAmaCuevsDDHDSBzkdadqG0hT1FzecVnPYoAC2594u2IPGiJjW3pQ73SnQQCY= X-Gm-Gg: ASbGncs9JXhgF6jD33qyfoROVnfrzgKMtetN+fMXbBQ3uegmvAjHK5jBtPNBkFdpgL9 HALUVsFxDo/v/9u54S2Hug4howAsKOP/gM+MlPCalhOw9KkZPQc2bfkQ53tDxzxakttUOZm/cBo mnK0/48ClJvW/hPm77hgk6oOK44BCD05LLuY3i1KQgqQVGj+BAHo2D0y/ZJP7W74X0XDgs2AuRJ 13dmnJ1vnY6Nf8W9/ki9eSe2EneYu8Vu/ACTKjrJYZJ2rQebLiCKx5JNegFFFz5kTHv X-Google-Smtp-Source: AGHT+IEn6TJVuC3++aW+1bE9Q5vRJBPt+NtT9C6gLCW54SZ0vlfPrBVTCB3tNcIpK4+Qdu8I/gfALg== X-Received: by 2002:a05:600c:3b94:b0:434:e2ea:fc94 with SMTP id 5b1f17b1804b1-436e2696cb8mr337102945e9.11.1737026859642; Thu, 16 Jan 2025 03:27:39 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:5485:d4b2:c087:b497]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-437c74c65b7sm57007715e9.23.2025.01.16.03.27.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2025 03:27:39 -0800 (PST) Date: Thu, 16 Jan 2025 12:27:36 +0100 From: Simona Vetter To: Dmitry Baryshkov Cc: Maxime Ripard , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Simona Vetter , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Douglas Anderson , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 01/29] drm/atomic-helper: Fix commit_tail state variable name Message-ID: Mail-Followup-To: Dmitry Baryshkov , Maxime Ripard , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Simona Vetter , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Douglas Anderson , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20250115-bridge-connector-v1-0-9a2fecd886a6@kernel.org> <20250115-bridge-connector-v1-1-9a2fecd886a6@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: Linux phenom 6.12.3-amd64 On Thu, Jan 16, 2025 at 03:36:12AM +0200, Dmitry Baryshkov wrote: > On Wed, Jan 15, 2025 at 10:05:08PM +0100, Maxime Ripard wrote: > > Even though the commit_tail () drm_atomic_state parameter is called > > old_state, it's actually the state being committed which is confusing. > > > > It's even more confusing since the atomic_commit_tail hook being called > > by commit_tail() parameter is called state. > > Do you have any kind of history and/or explanation, why it's called > old_state all over the place? > > I think that the renaming is correct, but I'd like to understand the > reason behind it. So originally drm_atomic_state only had a single set of state pointers, so was truly just a state collection and not a state transition/commit like it is now. During atomic check it contained the new states, and the old ones you could get by looking at obj->state pointers. After drm_atomic_helper_swap_state it contained the old states, and the new ones could be found by looking at obj->state. This caused endless amounts of confusions, and eventually we settled on a new design: - Ville added both old and new state pointers to drm_atomic_state, so now it's not just a state collection, but really a state transition/commit. We did discuss whether we should also rename it, but for lack of time and good name this hasn't happened yet. - Instead of trying to pass the individual states to callbacks we've moved over to just passing drm_atomic_state, and let the callbacks grab whatever they need. That's also not yet done everywhere yet, but I think we're pretty close. But one of the interim attempts at reducing the confusion was to rename the drm_atomic_state argument to old_state anywhere after we've called swap_states(). Didn't really help, and not it's just adding to the confusion. If we haven't yet I guess we should document the above two design principles in the drm_atomic_state kerneldoc. Cheers, Sima > > > Let's rename the variable from old_state to state to make it less > > confusing. > > > > Signed-off-by: Maxime Ripard > > --- > > drivers/gpu/drm/drm_atomic_helper.c | 20 ++++++++++---------- > > 1 file changed, 10 insertions(+), 10 deletions(-) > > > > diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c > > index 40e4e1b6c9110677c1c4981eeb15dc93966f4cf6..913d94d664d885323ad7e41a6424633c28c787e1 100644 > > --- a/drivers/gpu/drm/drm_atomic_helper.c > > +++ b/drivers/gpu/drm/drm_atomic_helper.c > > @@ -1818,13 +1818,13 @@ void drm_atomic_helper_commit_tail_rpm(struct drm_atomic_state *old_state) > > > > drm_atomic_helper_cleanup_planes(dev, old_state); > > } > > EXPORT_SYMBOL(drm_atomic_helper_commit_tail_rpm); > > > > -static void commit_tail(struct drm_atomic_state *old_state) > > +static void commit_tail(struct drm_atomic_state *state) > > { > > - struct drm_device *dev = old_state->dev; > > + struct drm_device *dev = state->dev; > > const struct drm_mode_config_helper_funcs *funcs; > > struct drm_crtc_state *new_crtc_state; > > struct drm_crtc *crtc; > > ktime_t start; > > s64 commit_time_ms; > > @@ -1842,37 +1842,37 @@ static void commit_tail(struct drm_atomic_state *old_state) > > * These times will be averaged out in the self refresh helpers to avoid > > * overreacting over one outlier frame > > */ > > start = ktime_get(); > > > > - drm_atomic_helper_wait_for_fences(dev, old_state, false); > > + drm_atomic_helper_wait_for_fences(dev, state, false); > > > > - drm_atomic_helper_wait_for_dependencies(old_state); > > + drm_atomic_helper_wait_for_dependencies(state); > > > > /* > > * We cannot safely access new_crtc_state after > > * drm_atomic_helper_commit_hw_done() so figure out which crtc's have > > * self-refresh active beforehand: > > */ > > - for_each_new_crtc_in_state(old_state, crtc, new_crtc_state, i) > > + for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) > > if (new_crtc_state->self_refresh_active) > > new_self_refresh_mask |= BIT(i); > > > > if (funcs && funcs->atomic_commit_tail) > > - funcs->atomic_commit_tail(old_state); > > + funcs->atomic_commit_tail(state); > > else > > - drm_atomic_helper_commit_tail(old_state); > > + drm_atomic_helper_commit_tail(state); > > > > commit_time_ms = ktime_ms_delta(ktime_get(), start); > > if (commit_time_ms > 0) > > - drm_self_refresh_helper_update_avg_times(old_state, > > + drm_self_refresh_helper_update_avg_times(state, > > (unsigned long)commit_time_ms, > > new_self_refresh_mask); > > > > - drm_atomic_helper_commit_cleanup_done(old_state); > > + drm_atomic_helper_commit_cleanup_done(state); > > > > - drm_atomic_state_put(old_state); > > + drm_atomic_state_put(state); > > } > > > > static void commit_work(struct work_struct *work) > > { > > struct drm_atomic_state *state = container_of(work, > > > > -- > > 2.47.1 > > > > -- > With best wishes > Dmitry -- Simona Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch