From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D73F1E1DEC; Fri, 25 Jul 2025 17:49:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.112 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753465781; cv=pass; b=Y3snqvGaVaINBBGb89p3JVk8jB+sSKaOjfsY5A8HO7HsnBVhPTkVN/Cjgpt7iJdAPHEqtH8EJ26PSwmtDbGEqjTyaaYBGRavsV2fcY5wi92kT7CwH2nLbpN7B/5Cfb/2QDwwo9OiOW1+XQDss6/Dten3+4y6TPulxbOgQx3KPDk= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753465781; c=relaxed/simple; bh=Co6omVD6qq46O47C9a1PV7dali/amXL688ppAOCwZFQ=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=glQUnanHQ+lD+l1qLzQO93wlUVCg5v5IygcR3CV0muDDGqnGRx6g4JT0HgLeUoQ4q3+hCedqJ48K+g5S8Lc8DT6ZZYmAvCbFiheSSnsd2VZ1ntqTn4sW6aeO7o1NcGgfdE4BPTF1A/G2RA1+pyLe+qjUUQVa7cH+jRKaI8x9bJ8= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (1024-bit key) header.d=collabora.com header.i=daniel.almeida@collabora.com header.b=WfkPD5PH; arc=pass smtp.client-ip=136.143.188.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=collabora.com header.i=daniel.almeida@collabora.com header.b="WfkPD5PH" ARC-Seal: i=1; a=rsa-sha256; t=1753465764; cv=none; d=zohomail.com; s=zohoarc; b=kvYg6N2ZoJIXxduKMoPHwdjd1xqRAN62MLvcUVzavG+mvwbt2xGvavJGx0iTsrwpkCHfCvFWeVf7vhlHkF4YOtHWSEhxii67hURhbann3esN40vyQ+As7iLfNpmnz1aFWsG5rt0coLeU98jqdBcVq6Tt0qe0O34O7shrcs6b2H0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753465764; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=2Xwr8x+BKUfSlLKO3O+ng3v4MJ3vSU0Ctp+7wpnQ0qs=; b=k2Z14keX7UvYBb8mwJzAUzxqWE5NHR99CN8NZ44Ut7UuJcVfeWmIIRQODzsVE8qslv3nvWr6BFNeb4+T2VvaJQ+9CZylFM29ngdj3NcPBLFfsZx1Thn6H+AFZFAhINAznfpAJYZePocD7cXnP5DT8BzZwBxaOGpMpij51undEhI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=daniel.almeida@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1753465764; s=zohomail; d=collabora.com; i=daniel.almeida@collabora.com; h=Content-Type:Mime-Version:Subject:Subject:From:From:In-Reply-To:Date:Date:Cc:Cc:Content-Transfer-Encoding:Message-Id:Message-Id:References:To:To:Reply-To; bh=2Xwr8x+BKUfSlLKO3O+ng3v4MJ3vSU0Ctp+7wpnQ0qs=; b=WfkPD5PHmKFfD+wGtklw8Rz+QGPx9vifm3NRfHVBB9cRUwhMSR5MQY8utpSCYXz2 HatZ3AN6Z2/wUdmw6rGz23/MLkVu1KlclPjTlDdToJasGsi+KbgHT0zuZTAG9oRXXpV rHzRCZvvN36hxXB1J3jdnu1vNYPGPwpju6m9x+EQ= Received: by mx.zohomail.com with SMTPS id 1753465762422919.5367130253645; Fri, 25 Jul 2025 10:49:22 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.600.51.1.1\)) Subject: Re: [PATCH v2 11/19] gpu: nova-core: register: improve `Debug` implementation From: Daniel Almeida In-Reply-To: <20250718-nova-regs-v2-11-7b6a762aa1cd@nvidia.com> Date: Fri, 25 Jul 2025 14:49:08 -0300 Cc: Danilo Krummrich , David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Beata Michalska , nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: <4E14EE9C-727F-49D4-AE01-96CB101705C5@collabora.com> References: <20250718-nova-regs-v2-0-7b6a762aa1cd@nvidia.com> <20250718-nova-regs-v2-11-7b6a762aa1cd@nvidia.com> To: Alexandre Courbot X-Mailer: Apple Mail (2.3826.600.51.1.1) X-ZohoMailClient: External > On 18 Jul 2025, at 04:26, Alexandre Courbot = wrote: >=20 > Now that we have an internal rule to dispatch field information where > needed, use it to generate a better `Debug` implementation where the = raw > hexadecimal value of the register is displayed, as well as the `Debug` > values of its individual fields. >=20 > Signed-off-by: Alexandre Courbot > --- > drivers/gpu/nova-core/regs/macros.rs | 25 +++++++++++++++---------- > 1 file changed, 15 insertions(+), 10 deletions(-) >=20 > diff --git a/drivers/gpu/nova-core/regs/macros.rs = b/drivers/gpu/nova-core/regs/macros.rs > index = 8b081242595de620cbf94b405838a2dac67b8e83..485cac806e4a6578059c657f3b31f15e= 361becbd 100644 > --- a/drivers/gpu/nova-core/regs/macros.rs > +++ b/drivers/gpu/nova-core/regs/macros.rs > @@ -122,16 +122,6 @@ macro_rules! register { > #[derive(Clone, Copy, Default)] > pub(crate) struct $name(u32); >=20 > - // TODO[REGA]: display the raw hex value, then the value of = all the fields. This requires > - // matching the fields, which will complexify the syntax = considerably... > - impl ::core::fmt::Debug for $name { > - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> = ::core::fmt::Result { > - f.debug_tuple(stringify!($name)) > - .field(&format_args!("0x{0:x}", &self.0)) > - .finish() > - } > - } > - > impl ::core::ops::BitOr for $name { > type Output =3D Self; >=20 > @@ -171,6 +161,7 @@ fn from(reg: $name) -> u32 { > ; > )* > }); > + register!(@debug $name { $($field;)* }); > }; >=20 > // Defines all the field getter/methods methods for `$name`. > @@ -316,6 +307,20 @@ pub(crate) fn [](mut self, value: = $to_type) -> Self { > ); > }; >=20 > + // Generates the `Debug` implementation for `$name`. > + (@debug $name:ident { $($field:ident;)* }) =3D> { > + impl ::core::fmt::Debug for $name { > + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> = ::core::fmt::Result { > + f.debug_struct(stringify!($name)) > + .field("", &format_args!("{:#x}", &self.0)) > + $( > + .field(stringify!($field), &self.$field()) > + )* > + .finish() > + } > + } > + }; > + > // Generates the IO accessors for a fixed offset register. > (@io $name:ident @ $offset:expr) =3D> { > #[allow(dead_code)] >=20 > --=20 > 2.50.1 >=20 Reviewed-by: Daniel Almeida