From 7088b655e8828bb960f528dd33132de27c505b8f Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 3 May 2017 08:40:41 +1000 Subject: [PATCH] radeonsi: constify a bunch of the perfcounter structs. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This moves the structs from the data segment to the rodata segment, which seems like the more correct place for them. Reviewed-by: Nicolai Hähnle Signed-off-by: Dave Airlie --- src/gallium/drivers/radeon/r600_perfcounter.c | 2 +- src/gallium/drivers/radeon/r600_query.h | 4 +- src/gallium/drivers/radeonsi/si_perfcounter.c | 92 +++++++++---------- 3 files changed, 46 insertions(+), 52 deletions(-) diff --git a/src/gallium/drivers/radeon/r600_perfcounter.c b/src/gallium/drivers/radeon/r600_perfcounter.c index 48f609bcb41..d76aa7be277 100644 --- a/src/gallium/drivers/radeon/r600_perfcounter.c +++ b/src/gallium/drivers/radeon/r600_perfcounter.c @@ -603,7 +603,7 @@ void r600_perfcounters_add_block(struct r600_common_screen *rscreen, struct r600_perfcounters *pc, const char *name, unsigned flags, unsigned counters, unsigned selectors, - unsigned instances, void *data) + unsigned instances, const void *data) { struct r600_perfcounter_block *block = &pc->blocks[pc->num_blocks]; diff --git a/src/gallium/drivers/radeon/r600_query.h b/src/gallium/drivers/radeon/r600_query.h index 05aceb72839..834dde1330f 100644 --- a/src/gallium/drivers/radeon/r600_query.h +++ b/src/gallium/drivers/radeon/r600_query.h @@ -243,7 +243,7 @@ struct r600_perfcounter_block { char *selector_names; unsigned selector_name_stride; - void *data; + const void *data; }; struct r600_perfcounters { @@ -301,7 +301,7 @@ void r600_perfcounters_add_block(struct r600_common_screen *, struct r600_perfcounters *, const char *name, unsigned flags, unsigned counters, unsigned selectors, - unsigned instances, void *data); + unsigned instances, const void *data); void r600_perfcounters_do_destroy(struct r600_perfcounters *); void r600_query_hw_reset_buffers(struct r600_common_context *rctx, struct r600_query_hw *query); diff --git a/src/gallium/drivers/radeonsi/si_perfcounter.c b/src/gallium/drivers/radeonsi/si_perfcounter.c index 41dd52edb11..ad7b9b7ae4b 100644 --- a/src/gallium/drivers/radeonsi/si_perfcounter.c +++ b/src/gallium/drivers/radeonsi/si_perfcounter.c @@ -60,22 +60,22 @@ enum si_pc_reg_layout { }; struct si_pc_block_base { - const char *name; + char name[8]; unsigned num_counters; unsigned flags; unsigned select_or; unsigned select0; unsigned counter0_lo; - unsigned *select; - unsigned *counters; + unsigned select[4]; + unsigned counters[4]; unsigned num_multi; unsigned num_prelude; unsigned layout; }; struct si_pc_block { - struct si_pc_block_base *b; + const struct si_pc_block_base *b; unsigned selectors; unsigned instances; }; @@ -98,7 +98,7 @@ static const unsigned si_pc_shader_type_bits[] = { S_036780_CS_EN(1), }; -static struct si_pc_block_base cik_CB = { +static const struct si_pc_block_base cik_CB = { .name = "CB", .num_counters = 4, .flags = R600_PC_BLOCK_SE | R600_PC_BLOCK_INSTANCE_GROUPS, @@ -110,22 +110,19 @@ static struct si_pc_block_base cik_CB = { .layout = SI_PC_MULTI_ALTERNATE, }; -static unsigned cik_CPC_select[] = { - R_036024_CPC_PERFCOUNTER0_SELECT, - R_036010_CPC_PERFCOUNTER0_SELECT1, - R_03600C_CPC_PERFCOUNTER1_SELECT, -}; -static struct si_pc_block_base cik_CPC = { +static const struct si_pc_block_base cik_CPC = { .name = "CPC", .num_counters = 2, - .select = cik_CPC_select, + .select = { R_036024_CPC_PERFCOUNTER0_SELECT, + R_036010_CPC_PERFCOUNTER0_SELECT1, + R_03600C_CPC_PERFCOUNTER1_SELECT }, .counter0_lo = R_034018_CPC_PERFCOUNTER0_LO, .num_multi = 1, .layout = SI_PC_MULTI_CUSTOM | SI_PC_REG_REVERSE, }; -static struct si_pc_block_base cik_CPF = { +static const struct si_pc_block_base cik_CPF = { .name = "CPF", .num_counters = 2, @@ -135,7 +132,7 @@ static struct si_pc_block_base cik_CPF = { .layout = SI_PC_MULTI_ALTERNATE | SI_PC_REG_REVERSE, }; -static struct si_pc_block_base cik_CPG = { +static const struct si_pc_block_base cik_CPG = { .name = "CPG", .num_counters = 2, @@ -145,7 +142,7 @@ static struct si_pc_block_base cik_CPG = { .layout = SI_PC_MULTI_ALTERNATE | SI_PC_REG_REVERSE, }; -static struct si_pc_block_base cik_DB = { +static const struct si_pc_block_base cik_DB = { .name = "DB", .num_counters = 4, .flags = R600_PC_BLOCK_SE | R600_PC_BLOCK_INSTANCE_GROUPS, @@ -156,7 +153,7 @@ static struct si_pc_block_base cik_DB = { .layout = SI_PC_MULTI_ALTERNATE, }; -static struct si_pc_block_base cik_GDS = { +static const struct si_pc_block_base cik_GDS = { .name = "GDS", .num_counters = 4, @@ -166,19 +163,16 @@ static struct si_pc_block_base cik_GDS = { .layout = SI_PC_MULTI_TAIL, }; -static unsigned cik_GRBM_counters[] = { - R_034100_GRBM_PERFCOUNTER0_LO, - R_03410C_GRBM_PERFCOUNTER1_LO, -}; -static struct si_pc_block_base cik_GRBM = { +static const struct si_pc_block_base cik_GRBM = { .name = "GRBM", .num_counters = 2, .select0 = R_036100_GRBM_PERFCOUNTER0_SELECT, - .counters = cik_GRBM_counters, + .counters = { R_034100_GRBM_PERFCOUNTER0_LO, + R_03410C_GRBM_PERFCOUNTER1_LO }, }; -static struct si_pc_block_base cik_GRBMSE = { +static const struct si_pc_block_base cik_GRBMSE = { .name = "GRBMSE", .num_counters = 4, @@ -186,7 +180,7 @@ static struct si_pc_block_base cik_GRBMSE = { .counter0_lo = R_034114_GRBM_SE0_PERFCOUNTER_LO, }; -static struct si_pc_block_base cik_IA = { +static const struct si_pc_block_base cik_IA = { .name = "IA", .num_counters = 4, @@ -196,7 +190,7 @@ static struct si_pc_block_base cik_IA = { .layout = SI_PC_MULTI_TAIL, }; -static struct si_pc_block_base cik_PA_SC = { +static const struct si_pc_block_base cik_PA_SC = { .name = "PA_SC", .num_counters = 8, .flags = R600_PC_BLOCK_SE, @@ -208,7 +202,7 @@ static struct si_pc_block_base cik_PA_SC = { }; /* According to docs, PA_SU counters are only 48 bits wide. */ -static struct si_pc_block_base cik_PA_SU = { +static const struct si_pc_block_base cik_PA_SU = { .name = "PA_SU", .num_counters = 4, .flags = R600_PC_BLOCK_SE, @@ -219,7 +213,7 @@ static struct si_pc_block_base cik_PA_SU = { .layout = SI_PC_MULTI_ALTERNATE, }; -static struct si_pc_block_base cik_SPI = { +static const struct si_pc_block_base cik_SPI = { .name = "SPI", .num_counters = 6, .flags = R600_PC_BLOCK_SE, @@ -230,7 +224,7 @@ static struct si_pc_block_base cik_SPI = { .layout = SI_PC_MULTI_BLOCK, }; -static struct si_pc_block_base cik_SQ = { +static const struct si_pc_block_base cik_SQ = { .name = "SQ", .num_counters = 16, .flags = R600_PC_BLOCK_SE | R600_PC_BLOCK_SHADER, @@ -242,7 +236,7 @@ static struct si_pc_block_base cik_SQ = { .counter0_lo = R_034700_SQ_PERFCOUNTER0_LO, }; -static struct si_pc_block_base cik_SX = { +static const struct si_pc_block_base cik_SX = { .name = "SX", .num_counters = 4, .flags = R600_PC_BLOCK_SE, @@ -253,7 +247,7 @@ static struct si_pc_block_base cik_SX = { .layout = SI_PC_MULTI_TAIL, }; -static struct si_pc_block_base cik_TA = { +static const struct si_pc_block_base cik_TA = { .name = "TA", .num_counters = 2, .flags = R600_PC_BLOCK_SE | R600_PC_BLOCK_INSTANCE_GROUPS | R600_PC_BLOCK_SHADER_WINDOWED, @@ -264,7 +258,7 @@ static struct si_pc_block_base cik_TA = { .layout = SI_PC_MULTI_ALTERNATE, }; -static struct si_pc_block_base cik_TD = { +static const struct si_pc_block_base cik_TD = { .name = "TD", .num_counters = 2, .flags = R600_PC_BLOCK_SE | R600_PC_BLOCK_INSTANCE_GROUPS | R600_PC_BLOCK_SHADER_WINDOWED, @@ -275,7 +269,7 @@ static struct si_pc_block_base cik_TD = { .layout = SI_PC_MULTI_ALTERNATE, }; -static struct si_pc_block_base cik_TCA = { +static const struct si_pc_block_base cik_TCA = { .name = "TCA", .num_counters = 4, .flags = R600_PC_BLOCK_INSTANCE_GROUPS, @@ -286,7 +280,7 @@ static struct si_pc_block_base cik_TCA = { .layout = SI_PC_MULTI_ALTERNATE, }; -static struct si_pc_block_base cik_TCC = { +static const struct si_pc_block_base cik_TCC = { .name = "TCC", .num_counters = 4, .flags = R600_PC_BLOCK_INSTANCE_GROUPS, @@ -297,7 +291,7 @@ static struct si_pc_block_base cik_TCC = { .layout = SI_PC_MULTI_ALTERNATE, }; -static struct si_pc_block_base cik_TCP = { +static const struct si_pc_block_base cik_TCP = { .name = "TCP", .num_counters = 4, .flags = R600_PC_BLOCK_SE | R600_PC_BLOCK_INSTANCE_GROUPS | R600_PC_BLOCK_SHADER_WINDOWED, @@ -308,7 +302,7 @@ static struct si_pc_block_base cik_TCP = { .layout = SI_PC_MULTI_ALTERNATE, }; -static struct si_pc_block_base cik_VGT = { +static const struct si_pc_block_base cik_VGT = (const struct si_pc_block_base) { .name = "VGT", .num_counters = 4, .flags = R600_PC_BLOCK_SE, @@ -319,7 +313,7 @@ static struct si_pc_block_base cik_VGT = { .layout = SI_PC_MULTI_TAIL, }; -static struct si_pc_block_base cik_WD = { +static const struct si_pc_block_base cik_WD = { .name = "WD", .num_counters = 4, @@ -327,14 +321,14 @@ static struct si_pc_block_base cik_WD = { .counter0_lo = R_034200_WD_PERFCOUNTER0_LO, }; -static struct si_pc_block_base cik_MC = { +static const struct si_pc_block_base cik_MC = { .name = "MC", .num_counters = 4, .layout = SI_PC_FAKE, }; -static struct si_pc_block_base cik_SRBM = { +static const struct si_pc_block_base cik_SRBM = { .name = "SRBM", .num_counters = 2, @@ -349,7 +343,7 @@ static struct si_pc_block_base cik_SRBM = { * blindly once it believes it has identified the hardware, so the order of * blocks here matters. */ -static struct si_pc_block groups_CIK[] = { +static const struct si_pc_block groups_CIK[] = { { &cik_CB, 226, 4 }, { &cik_CPF, 17 }, { &cik_DB, 257, 4 }, @@ -376,7 +370,7 @@ static struct si_pc_block groups_CIK[] = { }; -static struct si_pc_block groups_VI[] = { +static const struct si_pc_block groups_VI[] = { { &cik_CB, 396, 4 }, { &cik_CPF, 19 }, { &cik_DB, 257, 4 }, @@ -407,8 +401,8 @@ static void si_pc_get_size(struct r600_perfcounter_block *group, unsigned count, unsigned *selectors, unsigned *num_select_dw, unsigned *num_read_dw) { - struct si_pc_block *sigroup = (struct si_pc_block *)group->data; - struct si_pc_block_base *regs = sigroup->b; + const struct si_pc_block *sigroup = (const struct si_pc_block *)group->data; + const struct si_pc_block_base *regs = sigroup->b; unsigned layout_multi = regs->layout & SI_PC_MULTI_MASK; if (regs->layout & SI_PC_FAKE) { @@ -467,8 +461,8 @@ static void si_pc_emit_select(struct r600_common_context *ctx, struct r600_perfcounter_block *group, unsigned count, unsigned *selectors) { - struct si_pc_block *sigroup = (struct si_pc_block *)group->data; - struct si_pc_block_base *regs = sigroup->b; + const struct si_pc_block *sigroup = (const struct si_pc_block *)group->data; + const struct si_pc_block_base *regs = sigroup->b; struct radeon_winsys_cs *cs = ctx->gfx.cs; unsigned idx; unsigned layout_multi = regs->layout & SI_PC_MULTI_MASK; @@ -521,7 +515,7 @@ static void si_pc_emit_select(struct r600_common_context *ctx, for (idx = 0; idx < select1_count; ++idx) radeon_emit(cs, 0); } else if (layout_multi == SI_PC_MULTI_CUSTOM) { - unsigned *reg = regs->select; + const unsigned *reg = regs->select; for (idx = 0; idx < count; ++idx) { radeon_set_uconfig_reg(cs, *reg++, selectors[idx] | regs->select_or); if (idx < regs->num_multi) @@ -608,8 +602,8 @@ static void si_pc_emit_read(struct r600_common_context *ctx, unsigned count, unsigned *selectors, struct r600_resource *buffer, uint64_t va) { - struct si_pc_block *sigroup = (struct si_pc_block *)group->data; - struct si_pc_block_base *regs = sigroup->b; + const struct si_pc_block *sigroup = (const struct si_pc_block *)group->data; + const struct si_pc_block_base *regs = sigroup->b; struct radeon_winsys_cs *cs = ctx->gfx.cs; unsigned idx; unsigned reg = regs->counter0_lo; @@ -658,7 +652,7 @@ static void si_pc_cleanup(struct r600_common_screen *rscreen) void si_init_perfcounters(struct si_screen *screen) { struct r600_perfcounters *pc; - struct si_pc_block *blocks; + const struct si_pc_block *blocks; unsigned num_blocks; unsigned i; @@ -710,7 +704,7 @@ void si_init_perfcounters(struct si_screen *screen) goto error; for (i = 0; i < num_blocks; ++i) { - struct si_pc_block *block = &blocks[i]; + const struct si_pc_block *block = &blocks[i]; unsigned instances = block->instances; if (!strcmp(block->b->name, "IA")) { -- 2.30.2