From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: Matt Roper <matthew.d.roper@intel.com>, intel-xe@lists.freedesktop.org
Subject: Re: [Intel-xe] [PATCH 11/17] drm/xe: Introduce xe_reg_t
Date: Wed, 19 Apr 2023 15:30:17 -0400 [thread overview]
Message-ID: <ZEBBSS8d4uoW5KfS@intel.com> (raw)
In-Reply-To: <stwod2pi444nbt4isgkexorrgvtd6tixn62xezymbydjwdpd6b@z2obzqwxeh2x>
On Wed, Apr 19, 2023 at 11:49:56AM -0700, Lucas De Marchi wrote:
> On Wed, Apr 19, 2023 at 10:33:45AM -0700, Matt Roper wrote:
> > On Wed, Apr 19, 2023 at 12:44:34AM -0700, Lucas De Marchi wrote:
> > > Stop using i915 types for register our own xe_reg_t. Differently from
> > > i915, this will keep under this will keep under the register definition
> > > the knowledge for the different types of registers. For now, the "flags"
> > > are mcr and masked, although only the former is being used.
> > >
> > > Most of the driver is agnostic to the register differences. Convert the
> > > few places that care about that, namely xe_gt_mcr.c, to take the generic
> > > type and warn if the wrong register is used.
> >
> > The disadvantage of this approach is that we don't get the nice
> > type-checking that we have in i915 to catch register misuse at build
> > time. Instead we wind up with a bunch of run-time checks that only tell
> > you that you used the wrong register semantics after the fact. Wouldn't
> > it be better to keep the strict types and let the compiler find mistakes
> > for us at build time?
> >
> > The only real problem with using strict types is that there are a few
> > places where the driver is just trying to refer to registers/offsets
> > without actually accessing them (e.g., whitelists, OA register groups,
>
> that is not true.
>
> > etc.) and the strict typing makes it harder to provide a heterogeneous
> > list of those registers. But I still feel the benefits of compile-time
> > checking outweighs the extra complexity we wind up with in a handful of
> > places.
>
> I disagree here because the strict type checking is only checking for
> "regular vs mcr". Add "masked" in the mix (that has been a huge source
> of mistakes in i915) and you already have 4 types(?) to deal with.
>
> There are also places in the code where we want that "this is an
> mcr/regular/masked register" info to be used later. See how the reg-sr is
> handling that.
>
> In the end I believe having this info encoded in the regs/*.h is
> sufficient to avoid the mistakes we had in the past.
>
> Any change in the code triggering these warnings has a very easy an
> actionable fix.
>
> If for some reason we want to only differentiate mcr/normal as strict
> type checks, then I think we need to provide a better struct for the
> places that don't care about that. Something like below maybe
>
> typedef {
> xe_reg_t reg;
> } xe_reg_mcr_t;
>
> but reg.mcr still being there. Or going the other way around:
>
> typedef union {
> xe_reg_normal_t normal;
> xe_reg_mcr_t mcr;
> } xe_reg_t;
>
> but xe_reg_normal_t and xe_reg_mcr_t actually having the same defintion.
>
> Lucas De Marchi
I honestly liked the approach you took on this patch here. Getting rid of
the i915_mcr is already a win by itself.
One case that came to my mind though is some time sensitive mmio operations
like display inside vblank areas. any runtime check could potentially
increase latency, no?! If that's irrelevant time, than let's move with this
but if it is really a problem, then explore your latest suggestion here
with the compiler doing the checks for us seems a good alternative.
next prev parent reply other threads:[~2023-04-19 19:30 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-19 7:44 [Intel-xe] [PATCH 00/17] Cleanup registers and introduce xe_reg_t Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 01/17] drm/xe: Cleanup page-related defines Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 02/17] fixup! drm/i915/display: Remaining changes to make xe compile Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 03/17] fixup! drm/i915/display: Allow fbdev to allocate stolen memory Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 04/17] drm/xe: Rename RC0/RC6 macros Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 05/17] drm/xe: Rename instruction field to avoid confusion Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 06/17] drm/xe/guc: Rename GEN11_SOFT_SCRATCH for clarity Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 07/17] drm/xe/guc: Move GuC registers to regs/ Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 08/17] drm/xe/guc: Convert GuC registers to REG_FIELD/REG_BIT Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 09/17] drm/xe: Drop gen prefixes and suffixes from registers Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 10/17] drm/xe: Use REG_FIELD/REG_BIT for all regs/*.h Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 11/17] drm/xe: Introduce xe_reg_t Lucas De Marchi
2023-04-19 16:06 ` Jani Nikula
2023-04-19 17:17 ` Lucas De Marchi
2023-04-19 19:39 ` Jani Nikula
2023-04-19 20:30 ` Lucas De Marchi
2023-04-19 17:33 ` Matt Roper
2023-04-19 18:49 ` Lucas De Marchi
2023-04-19 19:30 ` Rodrigo Vivi [this message]
2023-04-19 20:19 ` Lucas De Marchi
2023-04-19 20:24 ` Matt Roper
2023-04-19 21:09 ` Lucas De Marchi
2023-04-19 23:14 ` Matt Roper
2023-04-19 23:38 ` Lucas De Marchi
2023-04-19 19:49 ` Jani Nikula
2023-04-19 20:13 ` Lucas De Marchi
2023-04-19 20:13 ` Matt Roper
2023-04-19 21:24 ` Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 12/17] drm/xe: Clarify register types on PAT programming Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 13/17] drm/xe/rtp: Improve magic macros for RTP tables Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 14/17] drm/xe: Add XE_REG/XE_REG_MCR Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 15/17] drm/xe: Annotate masked registers used by RTP Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 16/17] drm/xe: Plumb xe_reg_t into WAs, rtp, etc Lucas De Marchi
2023-04-19 16:15 ` Jani Nikula
2023-04-19 7:44 ` [Intel-xe] [PATCH 17/17] drm/xe: Move helper macros to separate header Lucas De Marchi
2023-04-19 16:17 ` Jani Nikula
2023-04-19 17:06 ` Lucas De Marchi
2023-04-19 7:47 ` [Intel-xe] ✓ CI.Patch_applied: success for Cleanup registers and introduce xe_reg_t Patchwork
2023-04-19 7:48 ` [Intel-xe] ✓ CI.KUnit: " Patchwork
2023-04-19 7:52 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-04-19 8:12 ` [Intel-xe] ○ CI.BAT: info " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZEBBSS8d4uoW5KfS@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=lucas.demarchi@intel.com \
--cc=matthew.d.roper@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox