RFC: xe_reg_t
In !303 (merged) I was playing with some possible ways to define registers for xe driver. I ended up defining a xe_rtp_reg_t to be used only there, postponing a possible refactor throughout the driver. Here I'd like to ask 2 questions:
- Would it be good to encode additional details about registers in the register itself? I'm thinking about this:
typedef union {
struct {
u32 reg:30
u32 masked:1
u32 mcr:1
};
u32 raw;
} xe_reg_t;
This way we can pass the register around and have all necessary info about it. Getting just the address is just accessing the .reg field, like we have today.
- Use a file format and move to a auto-generated header. This makes it easier to change the header in future - i915_reg.h has conventions that are hardly followed and the refactor on that header is going as long as I'm involved with the driver. The format I propose is to use an xml, like mesa, which is also loosely what we can get from the HW spec (with edits). The idea is to either integrate the GEN .xml -> .h at build time, or commit both the .h and the .xml.
From https://lore.kernel.org/all/20221012190531.ecmurislebsivjhf@ldmartin-desk2.lan/, it would look something like:
<register name="HIZ_CHICKEN" length="1" num="0x7018">
<field name="HZ Depth Test LE/GE Optimization Disable" start="13" end="13" type="bool"/>
<field name="HZ Depth Test LE/GE Optimization Disable Mask" start="29" end="29" type="bool"/>
</register>
If we decide to do so, then I can start this file with any register used in xe_wa.c and keep extending that until xe driver doesn't need to include i915_reg.h anymore.