Unverified Commit 78df43b9 authored by Sebastian Brzezinka's avatar Sebastian Brzezinka Committed by Andi Shyti
Browse files

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: default avatarSebastian Brzezinka <sebastian.brzezinka@intel.com>
Reviewed-by: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Reviewed-by: default avatarAndi Shyti <andi.shyti@linux.intel.com>
Signed-off-by: default avatarAndi Shyti <andi.shyti@linux.intel.com>
Link: https://lore.kernel.org/r/bae491e8098705a87304a7c94573b377e8c8fa37.1765897826.git.sebastian.brzezinka@intel.com
parent 08889b70
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -73,8 +73,8 @@ DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE(steering);
static void gt_debugfs_register(struct intel_gt *gt, struct dentry *root)
{
	static const struct intel_gt_debugfs_file files[] = {
		{ "reset", &reset_fops, NULL },
		{ "steering", &steering_fops },
		{ .name = "reset", .fops = &reset_fops },
		{ .name = "steering", .fops = &steering_fops },
	};

	intel_gt_debugfs_register_files(root, files, ARRAY_SIZE(files), gt);
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE(engines);
void intel_gt_engines_debugfs_register(struct intel_gt *gt, struct dentry *root)
{
	static const struct intel_gt_debugfs_file files[] = {
		{ "engines", &engines_fops },
		{ .name = "engines", .fops = &engines_fops },
	};

	intel_gt_debugfs_register_files(root, files, ARRAY_SIZE(files), gt);
+8 −7
Original line number Diff line number Diff line
@@ -586,13 +586,14 @@ DEFINE_SIMPLE_ATTRIBUTE(perf_limit_reasons_fops, perf_limit_reasons_get,
void intel_gt_pm_debugfs_register(struct intel_gt *gt, struct dentry *root)
{
	static const struct intel_gt_debugfs_file files[] = {
		{ "drpc", &drpc_fops, NULL },
		{ "frequency", &frequency_fops, NULL },
		{ "forcewake", &fw_domains_fops, NULL },
		{ "forcewake_user", &forcewake_user_fops, NULL},
		{ "llc", &llc_fops, llc_eval },
		{ "rps_boost", &rps_boost_fops, rps_eval },
		{ "perf_limit_reasons", &perf_limit_reasons_fops, perf_limit_reasons_eval },
		{ .name = "drpc", .fops = &drpc_fops },
		{ .name = "frequency", .fops = &frequency_fops },
		{ .name = "forcewake", .fops = &fw_domains_fops },
		{ .name = "forcewake_user", .fops = &forcewake_user_fops},
		{ .name = "llc", .fops = &llc_fops, .eval = llc_eval },
		{ .name = "rps_boost", .fops = &rps_boost_fops, .eval = rps_eval },
		{ .name = "perf_limit_reasons", .fops = &perf_limit_reasons_fops,
		  .eval = perf_limit_reasons_eval },
	};

	intel_gt_debugfs_register_files(root, files, ARRAY_SIZE(files), gt);
+2 −2
Original line number Diff line number Diff line
@@ -291,8 +291,8 @@ DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE(sseu_topology);
void intel_sseu_debugfs_register(struct intel_gt *gt, struct dentry *root)
{
	static const struct intel_gt_debugfs_file files[] = {
		{ "sseu_status", &sseu_status_fops, NULL },
		{ "sseu_topology", &sseu_topology_fops, NULL },
		{ .name = "sseu_status", .fops = &sseu_status_fops },
		{ .name = "sseu_topology", .fops = &sseu_topology_fops },
	};

	intel_gt_debugfs_register_files(root, files, ARRAY_SIZE(files), gt);
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE(gsc_info);
void intel_gsc_uc_debugfs_register(struct intel_gsc_uc *gsc_uc, struct dentry *root)
{
	static const struct intel_gt_debugfs_file files[] = {
		{ "gsc_info", &gsc_info_fops, NULL },
		{ .name = "gsc_info", .fops = &gsc_info_fops },
	};

	if (!intel_gsc_uc_is_supported(gsc_uc))
Loading