From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E7801D711C3 for ; Thu, 18 Dec 2025 21:11:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A667610E2E4; Thu, 18 Dec 2025 21:11:00 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="jC4Iyotu"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7455310E2E4 for ; Thu, 18 Dec 2025 21:10:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1766092259; x=1797628259; h=date:message-id:from:to:cc:subject:in-reply-to: references:mime-version; bh=GB902RBn6/w4f3BbMuV2UddXtZYqh62ujHhgXkvdr5A=; b=jC4IyotuLU3A6CAnwheSVODXPKwH6p42SXiV9hcq6VU/9AbH5TKoNIzd 0sKnScKFymBDg0JYQtNJY8ZWH6QCnrLQaJ29BXq7juw60TRE2wmY6n9X5 ohIvhY4g32RTmSNMFk5ivthJ5HueibNMCxmbOegk9Ecc0wl8JokHWYUqI kKqS3JU+mf/Fgk+zmJS38JwwCPjOzSoozsEjMZpXWLCuo5qBBb0Ao6bwr O1+tkDZg4flvFCHJVag4n4YOVKUAqbJ/1I1Objjz+Nq2G5z2RCexnzcDO z+hJZCOhbjoA+eBHrLNccwz4d1SVnKu0gzXvFZd+rd7jRrf1uh4sAxl4U Q==; X-CSE-ConnectionGUID: 7CIO2xafQEWXFohEp8TBGw== X-CSE-MsgGUID: mWdRhMXxRI67yvchAPGpGg== X-IronPort-AV: E=McAfee;i="6800,10657,11646"; a="71688002" X-IronPort-AV: E=Sophos;i="6.21,159,1763452800"; d="scan'208";a="71688002" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Dec 2025 13:10:59 -0800 X-CSE-ConnectionGUID: auNYsikuSTaWgTTdN+kyxQ== X-CSE-MsgGUID: teMFfM8uRKy6MD/YiQCIWw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,159,1763452800"; d="scan'208";a="198281461" Received: from unknown (HELO adixit-MOBL3.intel.com) ([10.57.131.238]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Dec 2025 13:10:58 -0800 Date: Thu, 18 Dec 2025 13:10:57 -0800 Message-ID: <871pkr338e.wl-ashutosh.dixit@intel.com> From: "Dixit, Ashutosh" To: "Cavitt, Jonathan" Cc: "intel-xe@lists.freedesktop.org" , "Gupta,\ Saurabhg" , "Zuo, Alex" , "Brost, Matthew" , "Ceraolo Spurio, Daniele" , "Vivi, Rodrigo" , "Wajdeczko, Michal" Subject: Re: [PATCH 6/6] drm/xe/xe_guc_ct: Justify WRITE_ONCE/READ_ONCE usage In-Reply-To: References: <20251218153527.6436-8-jonathan.cavitt@intel.com> <20251218153527.6436-14-jonathan.cavitt@intel.com> <874ipn33oo.wl-ashutosh.dixit@intel.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" On Thu, 18 Dec 2025 13:03:45 -0800, Cavitt, Jonathan wrote: > > -----Original Message----- > From: Dixit, Ashutosh > Sent: Thursday, December 18, 2025 1:01 PM > To: Cavitt, Jonathan > Cc: intel-xe@lists.freedesktop.org; Gupta, Saurabhg ; Zuo, Alex ; Brost, Matthew ; Ceraolo Spurio, Daniele ; Vivi, Rodrigo ; Wajdeczko, Michal > Subject: Re: [PATCH 6/6] drm/xe/xe_guc_ct: Justify WRITE_ONCE/READ_ONCE usage > > > > On Thu, 18 Dec 2025 07:35:34 -0800, Jonathan Cavitt wrote: > > > > > > Usage of READ_ONCE and WRITE_ONCE requires comments justifying it. > > > Some recently added uses had cross-dependencies with each other, but > > > needed to be added separately, so introduce the justifications now when > > > it makes more sense to. > > > > What is the reason for doing this in a separate patch? Afais, these > > comments should be added in the same patches where the code was changed. So > > people can see it in a single patch... > > Because the comment "WRITE_ONCE pairs with READ_ONCEs in xe_guc_ct_initialized > and xe_guc_ct_enabled" doesn't make sense when those functions don't have > READ_ONCEs yet. As Stuart mentioned the WRITE and READ should be in a single patch anyway. Together with the comments. > > > > > > > > > Suggested-by: Matthew Brost > > > Suggested-by: Rodrigo Vivi > > > Signed-off-by: Jonathan Cavitt > > > --- > > > drivers/gpu/drm/xe/xe_guc_ct.c | 5 +++++ > > > drivers/gpu/drm/xe/xe_guc_ct.h | 2 ++ > > > 2 files changed, 7 insertions(+) > > > > > > diff --git a/drivers/gpu/drm/xe/xe_guc_ct.c b/drivers/gpu/drm/xe/xe_guc_ct.c > > > index 20ac0438ffb6..24857c2c8cb5 100644 > > > --- a/drivers/gpu/drm/xe/xe_guc_ct.c > > > +++ b/drivers/gpu/drm/xe/xe_guc_ct.c > > > @@ -529,6 +529,11 @@ static void guc_ct_change_state(struct xe_guc_ct *ct, > > > if (ct->g2h_outstanding) > > > xe_pm_runtime_put(ct_to_xe(ct)); > > > ct->g2h_outstanding = 0; > > > + > > > + /* > > > + * WRITE_ONCE pairs with READ_ONCEs in xe_guc_ct_initialized and > > > + * xe_guc_ct_enabled. > > > + */ > > > WRITE_ONCE(ct->state, state); > > > > > > xe_gt_dbg(gt, "GuC CT communication channel %s\n", > > > diff --git a/drivers/gpu/drm/xe/xe_guc_ct.h b/drivers/gpu/drm/xe/xe_guc_ct.h > > > index cb1335f1d66f..8d318b094f33 100644 > > > --- a/drivers/gpu/drm/xe/xe_guc_ct.h > > > +++ b/drivers/gpu/drm/xe/xe_guc_ct.h > > > @@ -30,11 +30,13 @@ void xe_guc_ct_print(struct xe_guc_ct *ct, struct drm_printer *p, bool want_ctb) > > > > > > static inline bool xe_guc_ct_initialized(struct xe_guc_ct *ct) > > > { > > > + /* READ_ONCE pairs with WRITE_ONCE in guc_ct_change_state */ > > > return READ_ONCE(ct->state) != XE_GUC_CT_STATE_NOT_INITIALIZED; > > > } > > > > > > static inline bool xe_guc_ct_enabled(struct xe_guc_ct *ct) > > > { > > > + /* READ_ONCE pairs with WRITE_ONCE in guc_ct_change_state */ > > > return READ_ONCE(ct->state) == XE_GUC_CT_STATE_ENABLED; > > > } > > > > > > -- > > > 2.43.0 > > > > >