Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2236989pxb; Sat, 2 Oct 2021 10:30:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxE6Iwq0VYZcT1Fjs8D+PZqEQnsQ7A99igu6f0rfRrRlKoFFpGFgQqDOwBQW3fpDZ4/S4ah X-Received: by 2002:a05:6402:21ef:: with SMTP id ce15mr5232271edb.19.1633195804016; Sat, 02 Oct 2021 10:30:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633195804; cv=none; d=google.com; s=arc-20160816; b=E7AhuBCmDPZbchB545jTGLMluu5Pnfwtj+qEJ9+mvIA9NKbzy7FCpfJDb6QWGt124T PL9ghaXgJt3t5mSUFsovhppi90TQulmikvYdp9pIB3VPMWipO4OJ45OVENUBuy4a0o87 KD2UzBVcOoQShed+usU4341aX9WZCfyFBnWdd3cPl7S6iDnv0lAYb7718rAy7l81kHWA 6PvlyvqdfmRZYAk1hsfXwsLXVAgk2Ww1cSdLG+09MLeBcraRT2nGkBL46A2U2U6IFyrN 1h7l/siELTXprrZWkGCBjGdQcwZ0xWUDPqej7LiGXAxOnGybEzBVvvygezYuyN+grVA5 fEVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature; bh=NdG2AiDGU0yyjfZEfSHSA1eX2my+Y7Dhy95tEwsxOEE=; b=BuGIjjjlA6Y9yVEGAPzuANZd3wj+488bmMt0p5bAwcCDsxRibd/ZmuqdotzoAM48Yw DAHB/bj0fU/Z7oic8W+OHB4ePTa9qs6ukx4/TjDaq36POEr7cqjKU2VR1uSq6dOLX4i1 XA5S92S41L22JH2BRRPin7hVF8zmcAe84C6o+kNjj2GNiuNsLJrsHrBx7RjTABj2nlD6 reIQJIWziJp1/NN2EDIwcsFrFvQ4Iz98NAjFKE8RP5gAflkvKiPblmQHl68yJnAF+SHV pL4b9up4Bdaep+PWUJJ/DcxORE+2JGGKSq8deJxIrbZZx5q/07rK7ZtZRxQfky9ApLgw HgTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@u92.eu header.s=fm3 header.b=EHf38XIx; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=RrpcoIkl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f12si10506880edy.16.2021.10.02.10.29.40; Sat, 02 Oct 2021 10:30:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@u92.eu header.s=fm3 header.b=EHf38XIx; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=RrpcoIkl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233725AbhJBR36 (ORCPT + 99 others); Sat, 2 Oct 2021 13:29:58 -0400 Received: from new3-smtp.messagingengine.com ([66.111.4.229]:45069 "EHLO new3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233451AbhJBR3z (ORCPT ); Sat, 2 Oct 2021 13:29:55 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.nyi.internal (Postfix) with ESMTP id 647E45804E9; Sat, 2 Oct 2021 13:28:08 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Sat, 02 Oct 2021 13:28:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=u92.eu; h=date :from:to:cc:subject:message-id:references:mime-version :content-type:content-transfer-encoding:in-reply-to; s=fm3; bh=N dG2AiDGU0yyjfZEfSHSA1eX2my+Y7Dhy95tEwsxOEE=; b=EHf38XIxyX3AijX2q ngopIdoNyr1T5LjiY1RSy1XuPrV8q1XjL/4tLTYscB1g0B6chFWCuxlMe9QImHiV kUpLrMS9xdGbUshDw+eXNLhDLdgo8zVWBjqftwU0nnAVlbE+KFdfEpgLiDq38IZ4 AXamJNqMxQXQUKYBEugY/tcVm7z5aaZeWfLZgKrJsiQgRlW4aMI9ca3HhZF090fF TY/u7r/lXgDW9S5blz3NC7PUxKj/TR7c8R646Q4AK7Nu9uCUNIXZXuEROSZtl92o GYGRgcLS1zLTnpzVv/HMzNgUtzsoU8rYdAmiUHJVjxtvP/c6HfwAnyamZYrldcuB 93tzw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=NdG2AiDGU0yyjfZEfSHSA1eX2my+Y7Dhy95tEwsxO EE=; b=RrpcoIklxRRr1rba6cZd76mHODb8D+vtPu79QI+bAxxAMeXKLCDgaupqC JBUzgot1VDDL+3oxEW+xFShKnLUv8F/9i97SMqx++QNxoq3x/LVndAw7I3HX3kdJ /pJ7/W1ykkpDt+vPELlhrLDli4MI+GxLfSzApQw9pc2geW6yCJYw2aH9HHHcrcva uSwZzMvBtjl2+H0v6OiyBRIYP9LmVlltLFMa267Jd579CWYYxFkJfi1BpSL9PqFK aQfe+VLf7jqJ3oShgh3viO7+9jjJLuPfbRhF0qyGiIjt8ilL+WrvObsImLgTXnTr M+oDUovLY3IvonoBXHDIz77IcXOLQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudekkedgudduvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkfhggtggugfgjsehtkeertddttdejnecuhfhrohhmpefhvghr nhgrnhguohcutfgrmhhoshcuoehgrhgvvghnfhhoohesuhelvddrvghuqeenucggtffrrg htthgvrhhnpeeghfffgedufeeuheevtddukedtteeikefgiefhudfhfeffjeetvedtgfff keejudenucffohhmrghinhepfhhrvggvuggvshhkthhophdrohhrghdpmhhuthgvgidrsh honecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepghhr vggvnhhfohhosehuledvrdgvuh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 2 Oct 2021 13:28:04 -0400 (EDT) Date: Sat, 2 Oct 2021 19:28:02 +0200 From: Fernando Ramos To: Ville =?utf-8?B?U3lyasOkbMOk?= Cc: Sean Paul , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, amd-gfx@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-renesas-soc@vger.kernel.org, linux-tegra@vger.kernel.org Subject: Re: [Intel-gfx] [PATCH v2 00/17] drm: cleanup: Use DRM_MODESET_LOCK_ALL_* helpers where possible Message-ID: References: <20210924064324.229457-1-greenfoo@u92.eu> <20211001183655.GW2515@art_vandelay> <20211001204815.GA2515@art_vandelay> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21/10/02 09:13AM, Fernando Ramos wrote: > On 21/10/02 05:30AM, Ville Syrjälä wrote: > > On Sat, Oct 02, 2021 at 01:05:47AM +0300, Ville Syrjälä wrote: > > > On Fri, Oct 01, 2021 at 04:48:15PM -0400, Sean Paul wrote: > > > > On Fri, Oct 01, 2021 at 10:00:50PM +0300, Ville Syrjälä wrote: > > > > > On Fri, Oct 01, 2021 at 02:36:55PM -0400, Sean Paul wrote: > > > > > > > > > > > > Thank you for revising, Fernando! I've pushed the set to drm-misc-next (along > > > > > > with the necessary drm-tip conflict resolutions). > > > > > > > > > > Ugh. Did anyone actually review the locking changes this does? > > > > > I shot the previous i915 stuff down because the commit messages > > > > > did not address any of it. > > > > > > > > I reviewed the set on 9/17, I didn't see your feedback on that thread. > > > > > > It was much earlir than that. > > > https://lists.freedesktop.org/archives/dri-devel/2021-June/313193.html Sorry, I'm new to this and it did not occur to me to search for similar patches in the mailing list archives in case there were additional comments that applied to my change set. In case I had done that I would have found that, as you mentioned, you had already raised two issues back in June: On Tue, Jun 29, 2021, Ville Syrjälä wrote: > > That looks wrong. You're using a private ctx here, but still > passing dev->mode_config.acquire_ctx to the lower level stuff. > > Also DRM_MODESET_LOCK_ALL_{BEGIN,END}() do not seem to be > equivalent to drm_modeset_{lock,unlock}_all() when it comes to > mode_config.mutex. So would need a proper review whether we > actually need that lock or not. The first one was pointing out the same error I would later repeat in my patch series (ups). After further inspection of the code it looks to me that changing this: intel_modeset_setup_hw_state(dev, dev->mode_config.acquire_ctx); ...into this: intel_modeset_setup_hw_state(dev, &ctx); ...would be enough. Why? The only difference between the old drm_modeset_{lock,unlock}_all() functions and the new DRM_MODESET_LOCK_ALL_{BEGIN,END}() macros is that the former use a global context stored in dev->mode_config.acquire_ctx while the latter depend on a user provided one (typically in the stack). In the old (working) code the global context structure is freed in drm_modeset_unlock_all() thus we are sure no one is holding a reference to it at that point. This means that as long as no one accesses the global dev->mode_config.acquire_ctx context in the block that runs between lock/BEGIN and unlock/END, the code should be equivalent before and after my changes. In fact, now that my patch series removes the drm_modeset_{lock,unlock}_all() functions, the acquire_ctx field of the drm_mode_config structure should be deleted: /** * @acquire_ctx: * * Global implicit acquire context used by atomic drivers for legacy * IOCTLs. Deprecated, since implicit locking contexts make it * impossible to use driver-private &struct drm_modeset_lock. Users of * this must hold @mutex. */ struct drm_modeset_acquire_ctx *acquire_ctx; If I had done that (ie. removing this field) I would have detected the problem when compiling. There is another place (in the amdgpu driver) where this field is still being referenced, but before I investigate that I would like to know if you agree that this is a good path to follow. Regarding the second issue you raised... > Also DRM_MODESET_LOCK_ALL_{BEGIN,END}() do not seem to be > equivalent to drm_modeset_{lock,unlock}_all() when it comes to > mode_config.mutex. So would need a proper review whether we > actually need that lock or not. ...the only difference regarding mode_config.mutex I see is that in the new macros the mutex is locked only under this condition: if (!drm_drv_uses_atomic_modeset(dev)) ...which seems reasonable, right? Is this what you were referring to or is it something else? Please let me know what you think. Thanks!