[Intel-xe] [PATCH v2 08/17] drm/xe/guc: Convert GuC registers to REG_FIELD/REG_BIT
Lucas De Marchi
lucas.demarchi at intel.com
Thu Apr 27 14:07:49 UTC 2023
On Wed, Apr 26, 2023 at 02:32:33PM -0700, Lucas De Marchi wrote:
>Cleanup GuC register declarations by converting them to use REG_FIELD,
>REG_BIT and REG_GENMASK. While converting, also reorder the bitfields
>so they follow the convention of declaring the higher bits first.
>
>v2:
> - Drop unused HUC_LOADING_AGENT_VCR and DMA_ADDRESS_SPACE_GTT (Matt Roper)
> - Simplify HUC_LOADING_AGENT_GUC define (Matt Roper)
First 7 patches pushed. For this one, it may be hard to review. So to
double check I didn't screw up the defines I created a test.c that
prints all the defines in regs/xe_guc_regs.h
sed -ne 's/#define\s\+\([_()[:alnum:]]\{1,\}\).*/\1/p' drivers/gpu/drm/xe/regs/xe_guc_regs.h | sed 's/([[:alnum:]]\+)/(0)/' > /tmp/a_defines.txt
<apply patch>
sed -ne 's/#define\s\+\([_()[:alnum:]]\{1,\}\).*/\1/p' drivers/gpu/drm/xe/regs/xe_guc_regs.h | sed 's/([[:alnum:]]\+)/(0)/' > /tmp/b_defines.txt
test.c
------
#include <stdio.h>
#include <linux/limits.h>
#include <linux/types.h>
#include <regs/xe_guc_regs.h>
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#define ENTRY(x) { #x, x }
#undef _MMIO
#define _MMIO(x) x
struct map {
const char *s;
u32 val;
};
#if ARRAY_PRINT == 0
static const struct map define_map_guc_old[] = {
/* Add a_defines.txt here */
};
#endif
#if ARRAY_PRINT == 1
static const struct map define_map_guc_new[] = {
/* Add b_defines.txt here */
};
#endif
int main(void)
{
#if ARRAY_PRINT == 0
for (int i = 0; i < ARRAY_SIZE(define_map_guc_old); i++)
printf("%s %u\n", define_map_guc_old[i].s, define_map_guc_old[i].val);
#endif
#if ARRAY_PRINT == 1
for (int i = 0; i < ARRAY_SIZE(define_map_guc_new); i++)
printf("%s %u\n", define_map_guc_new[i].s, define_map_guc_new[i].val);
#endif
return 0;
}
After building with -DARRAY_PRINT=1 and -DARRAY_PRINT=0, running this
through sort -u produces the diff:
diff --git a/tmp/a.txt b/tmp/b.txt
index 38f397c7a10c..3e613d584e62 100644
--- a/tmp/a.txt
+++ b/tmp/b.txt
@@ -1,21 +1,19 @@
-DE_GUCRMR 278612
DMA_ADDR_0_HIGH 49924
DMA_ADDR_0_LOW 49920
DMA_ADDR_1_HIGH 49932
DMA_ADDR_1_LOW 49928
-DMA_ADDRESS_SPACE_GTT 524288
DMA_ADDRESS_SPACE_WOPCM 458752
+DMA_ADDR_SPACE_MASK 2031616
DMA_COPY_SIZE 49936
DMA_CTRL 49940
DMA_GUC_WOPCM_OFFSET 49984
GEN11_GUC_HOST_INTERRUPT 1638896
GEN11_HUC_KERNEL_LOAD_INFO 49628
GEN12_DIST_DBS_POPULATED 3336
-GEN12_DOORBELLS_PER_SQIDI 255
-GEN12_DOORBELLS_PER_SQIDI_SHIFT 16
+GEN12_DOORBELLS_PER_SQIDI_MASK 16711680
GEN12_GUC_TLB_INV_CR 52968
GEN12_GUC_TLB_INV_CR_INVALIDATE 1
-GEN12_SQIDIS_DOORBELL_EXIST 65535
+GEN12_SQIDIS_DOORBELL_EXIST_MASK 65535
GEN8_DRBREGL(0) 4096
GEN8_DRBREGU(0) 4100
GEN8_DRB_VALID 1
@@ -27,20 +25,15 @@ GEN9LP_GT_PM_CONFIG 1278272
GS_AUTH_STATUS_BAD 1073741824
GS_AUTH_STATUS_GOOD 2147483648
GS_AUTH_STATUS_MASK 3221225472
-GS_AUTH_STATUS_SHIFT 30
GS_BOOTROM_JUMP_PASSED 236
GS_BOOTROM_MASK 254
GS_BOOTROM_RSA_FAILED 160
-GS_BOOTROM_SHIFT 1
GS_MIA_CORE_STATE 65536
GS_MIA_HALT_REQUESTED 131072
GS_MIA_IN_RESET 1
GS_MIA_ISR_ENTRY 262144
GS_MIA_MASK 458752
-GS_MIA_SHIFT 16
-GS_RESET_SHIFT 0
GS_UKERNEL_MASK 65280
-GS_UKERNEL_SHIFT 8
GT_DOORBELL_ENABLE 1
GUC_ARAT_C6DIS 41336
GUC_BCS_RCS_IER 50512
@@ -85,10 +78,8 @@ GUC_WOPCM_OFFSET_VALID 1
GUC_WOPCM_SIZE 49232
GUC_WOPCM_SIZE_LOCKED 1
GUC_WOPCM_SIZE_MASK 4294963200
-GUC_WOPCM_SIZE_SHIFT 12
HUC_FW_VERIFIED 128
HUC_LOADING_AGENT_GUC 2
-HUC_LOADING_AGENT_VCR 0
HUC_LOAD_SUCCESSFUL 1
HUC_STATUS2 54192
HUC_UKERNEL 512
@@ -96,7 +87,7 @@ MED_VF_SW_FLAG(0) 1639184
MED_VF_SW_FLAG_COUNT 4
PVC_GUC_MOCS_INDEX(0) 0
PVC_GUC_MOCS_INDEX_MASK 50331648
-PVC_MOCS_UC_INDEX 1
+PVC_GUC_MOCS_UC_INDEX 1
SOFT_SCRATCH(0) 49536
SOFT_SCRATCH_COUNT 16
START_DMA 1
Which was indeed intended. I hope that helps the review.
Lucas De Marchi
More information about the Intel-xe
mailing list