Skip to content

Commit 78df43b

Browse files
sberbzAndi Shyti
authored andcommitted
drm/i915/gt: use designated initializers for intel_gt_debugfs_file
CONFIG_RANDSTRUCT may reorder structure fields, which makes positional initializers unsafe. The i915 GT debugfs tables were using positional initializers for `struct intel_gt_debugfs_file`, and on configs where the layout differs (e.g., presence/absence of the `.eval` callback), this can lead to fields being initialized incorrectly and trigger randstruct warnings such as: ``` drivers/gpu/drm/i915/gt/intel_gt_debugfs.c:75:51: note: randstruct: casting between randomized structure pointer types (constructor) ``` Switch all the GT debugfs file arrays to designated initializers. This binds each value to the intended member regardless of structure reordering or optional members and removes the warning while preserving the intended initialization. Also drops the '&' from intel_eval_slpc_support so .eval receives the function pointer directly. No functional change, only initialization style is updated. Signed-off-by: Sebastian Brzezinka <sebastian.brzezinka@intel.com> Reviewed-by: Krzysztof Karas <krzysztof.karas@intel.com> Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com> Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com> Link: https://lore.kernel.org/r/bae491e8098705a87304a7c94573b377e8c8fa37.1765897826.git.sebastian.brzezinka@intel.com
1 parent 08889b7 commit 78df43b

9 files changed

Lines changed: 27 additions & 25 deletions

drivers/gpu/drm/i915/gt/intel_gt_debugfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE(steering);
7373
static void gt_debugfs_register(struct intel_gt *gt, struct dentry *root)
7474
{
7575
static const struct intel_gt_debugfs_file files[] = {
76-
{ "reset", &reset_fops, NULL },
77-
{ "steering", &steering_fops },
76+
{ .name = "reset", .fops = &reset_fops },
77+
{ .name = "steering", .fops = &steering_fops },
7878
};
7979

8080
intel_gt_debugfs_register_files(root, files, ARRAY_SIZE(files), gt);

drivers/gpu/drm/i915/gt/intel_gt_engines_debugfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE(engines);
2929
void intel_gt_engines_debugfs_register(struct intel_gt *gt, struct dentry *root)
3030
{
3131
static const struct intel_gt_debugfs_file files[] = {
32-
{ "engines", &engines_fops },
32+
{ .name = "engines", .fops = &engines_fops },
3333
};
3434

3535
intel_gt_debugfs_register_files(root, files, ARRAY_SIZE(files), gt);

drivers/gpu/drm/i915/gt/intel_gt_pm_debugfs.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -586,13 +586,14 @@ DEFINE_SIMPLE_ATTRIBUTE(perf_limit_reasons_fops, perf_limit_reasons_get,
586586
void intel_gt_pm_debugfs_register(struct intel_gt *gt, struct dentry *root)
587587
{
588588
static const struct intel_gt_debugfs_file files[] = {
589-
{ "drpc", &drpc_fops, NULL },
590-
{ "frequency", &frequency_fops, NULL },
591-
{ "forcewake", &fw_domains_fops, NULL },
592-
{ "forcewake_user", &forcewake_user_fops, NULL},
593-
{ "llc", &llc_fops, llc_eval },
594-
{ "rps_boost", &rps_boost_fops, rps_eval },
595-
{ "perf_limit_reasons", &perf_limit_reasons_fops, perf_limit_reasons_eval },
589+
{ .name = "drpc", .fops = &drpc_fops },
590+
{ .name = "frequency", .fops = &frequency_fops },
591+
{ .name = "forcewake", .fops = &fw_domains_fops },
592+
{ .name = "forcewake_user", .fops = &forcewake_user_fops},
593+
{ .name = "llc", .fops = &llc_fops, .eval = llc_eval },
594+
{ .name = "rps_boost", .fops = &rps_boost_fops, .eval = rps_eval },
595+
{ .name = "perf_limit_reasons", .fops = &perf_limit_reasons_fops,
596+
.eval = perf_limit_reasons_eval },
596597
};
597598

598599
intel_gt_debugfs_register_files(root, files, ARRAY_SIZE(files), gt);

drivers/gpu/drm/i915/gt/intel_sseu_debugfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE(sseu_topology);
291291
void intel_sseu_debugfs_register(struct intel_gt *gt, struct dentry *root)
292292
{
293293
static const struct intel_gt_debugfs_file files[] = {
294-
{ "sseu_status", &sseu_status_fops, NULL },
295-
{ "sseu_topology", &sseu_topology_fops, NULL },
294+
{ .name = "sseu_status", .fops = &sseu_status_fops },
295+
{ .name = "sseu_topology", .fops = &sseu_topology_fops },
296296
};
297297

298298
intel_gt_debugfs_register_files(root, files, ARRAY_SIZE(files), gt);

drivers/gpu/drm/i915/gt/uc/intel_gsc_uc_debugfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE(gsc_info);
2929
void intel_gsc_uc_debugfs_register(struct intel_gsc_uc *gsc_uc, struct dentry *root)
3030
{
3131
static const struct intel_gt_debugfs_file files[] = {
32-
{ "gsc_info", &gsc_info_fops, NULL },
32+
{ .name = "gsc_info", .fops = &gsc_info_fops },
3333
};
3434

3535
if (!intel_gsc_uc_is_supported(gsc_uc))

drivers/gpu/drm/i915/gt/uc/intel_guc_debugfs.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,13 @@ DEFINE_SIMPLE_ATTRIBUTE(guc_sched_disable_gucid_threshold_fops,
132132
void intel_guc_debugfs_register(struct intel_guc *guc, struct dentry *root)
133133
{
134134
static const struct intel_gt_debugfs_file files[] = {
135-
{ "guc_info", &guc_info_fops, NULL },
136-
{ "guc_registered_contexts", &guc_registered_contexts_fops, NULL },
137-
{ "guc_slpc_info", &guc_slpc_info_fops, &intel_eval_slpc_support},
138-
{ "guc_sched_disable_delay_ms", &guc_sched_disable_delay_ms_fops, NULL },
139-
{ "guc_sched_disable_gucid_threshold", &guc_sched_disable_gucid_threshold_fops,
140-
NULL },
135+
{ .name = "guc_info", .fops = &guc_info_fops },
136+
{ .name = "guc_registered_contexts", .fops = &guc_registered_contexts_fops },
137+
{ .name = "guc_slpc_info", .fops = &guc_slpc_info_fops,
138+
.eval = intel_eval_slpc_support },
139+
{ .name = "guc_sched_disable_delay_ms", .fops = &guc_sched_disable_delay_ms_fops },
140+
{ .name = "guc_sched_disable_gucid_threshold",
141+
.fops = &guc_sched_disable_gucid_threshold_fops },
141142
};
142143

143144
if (!intel_guc_is_supported(guc))

drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,10 @@ void intel_guc_log_debugfs_register(struct intel_guc_log *log,
162162
struct dentry *root)
163163
{
164164
static const struct intel_gt_debugfs_file files[] = {
165-
{ "guc_log_dump", &guc_log_dump_fops, NULL },
166-
{ "guc_load_err_log_dump", &guc_load_err_log_dump_fops, NULL },
167-
{ "guc_log_level", &guc_log_level_fops, NULL },
168-
{ "guc_log_relay", &guc_log_relay_fops, NULL },
165+
{ .name = "guc_log_dump", .fops = &guc_log_dump_fops },
166+
{ .name = "guc_load_err_log_dump", .fops = &guc_load_err_log_dump_fops},
167+
{ .name = "guc_log_level", .fops = &guc_log_level_fops },
168+
{ .name = "guc_log_relay", .fops = &guc_log_relay_fops },
169169
};
170170

171171
if (!intel_guc_is_supported(log_to_guc(log)))

drivers/gpu/drm/i915/gt/uc/intel_huc_debugfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE(huc_info);
2626
void intel_huc_debugfs_register(struct intel_huc *huc, struct dentry *root)
2727
{
2828
static const struct intel_gt_debugfs_file files[] = {
29-
{ "huc_info", &huc_info_fops, NULL },
29+
{ .name = "huc_info", .fops = &huc_info_fops },
3030
};
3131

3232
if (!intel_huc_is_supported(huc))

drivers/gpu/drm/i915/gt/uc/intel_uc_debugfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE(uc_usage);
4040
void intel_uc_debugfs_register(struct intel_uc *uc, struct dentry *gt_root)
4141
{
4242
static const struct intel_gt_debugfs_file files[] = {
43-
{ "usage", &uc_usage_fops, NULL },
43+
{ .name = "usage", .fops = &uc_usage_fops },
4444
};
4545
struct dentry *root;
4646

0 commit comments

Comments
 (0)