Skip to content

Commit 84edc94

Browse files
drvgithubuserzhenyw
authored andcommitted
drm/i915/gvt: Avoid full proxy f_ops for debugfs attributes
Using DEFINE_SIMPLE_ATTRIBUTE macro with the debugfs_create_file() function adds the overhead of introducing a proxy file operation functions to wrap the original read/write inside file removal protection functions. This adds significant overhead in terms of introducing and managing the proxy factory file operations structure and function wrapping at runtime. As a replacement, a combination of DEFINE_DEBUGFS_ATTRIBUTE macro paired with debugfs_create_file_unsafe() is suggested to be used instead. The DEFINE_DEBUGFS_ATTRIBUTE utilises debugfs_file_get() and debugfs_file_put() wrappers to protect the original read and write function calls for the debug attributes. There is no need for any runtime proxy file operations to be managed by the debugfs core. Following coccicheck make command helped identify this change: make coccicheck M=drivers/gpu/drm/i915/ MODE=patch COCCI=./scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci Signed-off-by: Deepak R Varma <[email protected]> Reviewed-by: Rodrigo Vivi <[email protected]> Acked-by: Zhenyu Wang <[email protected]> Signed-off-by: Zhenyu Wang <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 8038510 commit 84edc94

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/gpu/drm/i915/gvt/debugfs.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ vgpu_scan_nonprivbb_set(void *data, u64 val)
147147
return 0;
148148
}
149149

150-
DEFINE_SIMPLE_ATTRIBUTE(vgpu_scan_nonprivbb_fops,
151-
vgpu_scan_nonprivbb_get, vgpu_scan_nonprivbb_set,
152-
"0x%llx\n");
150+
DEFINE_DEBUGFS_ATTRIBUTE(vgpu_scan_nonprivbb_fops,
151+
vgpu_scan_nonprivbb_get, vgpu_scan_nonprivbb_set,
152+
"0x%llx\n");
153153

154154
static int vgpu_status_get(void *data, u64 *val)
155155
{
@@ -165,7 +165,7 @@ static int vgpu_status_get(void *data, u64 *val)
165165
return 0;
166166
}
167167

168-
DEFINE_SIMPLE_ATTRIBUTE(vgpu_status_fops, vgpu_status_get, NULL, "0x%llx\n");
168+
DEFINE_DEBUGFS_ATTRIBUTE(vgpu_status_fops, vgpu_status_get, NULL, "0x%llx\n");
169169

170170
/**
171171
* intel_gvt_debugfs_add_vgpu - register debugfs entries for a vGPU
@@ -180,10 +180,10 @@ void intel_gvt_debugfs_add_vgpu(struct intel_vgpu *vgpu)
180180

181181
debugfs_create_file("mmio_diff", 0444, vgpu->debugfs, vgpu,
182182
&vgpu_mmio_diff_fops);
183-
debugfs_create_file("scan_nonprivbb", 0644, vgpu->debugfs, vgpu,
184-
&vgpu_scan_nonprivbb_fops);
185-
debugfs_create_file("status", 0644, vgpu->debugfs, vgpu,
186-
&vgpu_status_fops);
183+
debugfs_create_file_unsafe("scan_nonprivbb", 0644, vgpu->debugfs, vgpu,
184+
&vgpu_scan_nonprivbb_fops);
185+
debugfs_create_file_unsafe("status", 0644, vgpu->debugfs, vgpu,
186+
&vgpu_status_fops);
187187
}
188188

189189
/**

0 commit comments

Comments
 (0)