Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915/perf: Register sysctl path globally

We do not require to register the sysctl paths per instance,
so making registration global.

v2: make sysctl path register and unregister function driver
specific (Tvrtko and Lucas).

Cc: Sudeep Dutt <sudeep.dutt@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Venkata Sandeep Dhanalakota <venkata.s.dhanalakota@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20191213155152.69182-1-venkata.s.dhanalakota@intel.com

authored by

Venkata Sandeep Dhanalakota and committed by
Chris Wilson
3dc716fd b69fa361

+23 -6
+8 -1
drivers/gpu/drm/i915/i915_pci.c
··· 30 30 #include "display/intel_fbdev.h" 31 31 32 32 #include "i915_drv.h" 33 + #include "i915_perf.h" 33 34 #include "i915_globals.h" 34 35 #include "i915_selftest.h" 35 36 ··· 1054 1053 return 0; 1055 1054 } 1056 1055 1057 - return pci_register_driver(&i915_pci_driver); 1056 + err = pci_register_driver(&i915_pci_driver); 1057 + if (err) 1058 + return err; 1059 + 1060 + i915_perf_sysctl_register(); 1061 + return 0; 1058 1062 } 1059 1063 1060 1064 static void __exit i915_exit(void) ··· 1067 1061 if (!i915_pci_driver.driver.owner) 1068 1062 return; 1069 1063 1064 + i915_perf_sysctl_unregister(); 1070 1065 pci_unregister_driver(&i915_pci_driver); 1071 1066 i915_globals_exit(); 1072 1067 }
+13 -4
drivers/gpu/drm/i915/i915_perf.c
··· 387 387 struct i915_vma *vma; 388 388 }; 389 389 390 + static struct ctl_table_header *sysctl_header; 391 + 390 392 static enum hrtimer_restart oa_poll_check_timer_cb(struct hrtimer *hrtimer); 391 393 392 394 void i915_oa_config_release(struct kref *ref) ··· 4230 4228 }; 4231 4229 4232 4230 /** 4233 - * i915_perf_init - initialize i915-perf state on module load 4231 + * i915_perf_init - initialize i915-perf state on module bind 4234 4232 * @i915: i915 device instance 4235 4233 * 4236 4234 * Initializes i915-perf state without exposing anything to userspace. ··· 4347 4345 4348 4346 oa_sample_rate_hard_limit = 1000 * 4349 4347 (RUNTIME_INFO(i915)->cs_timestamp_frequency_khz / 2); 4350 - perf->sysctl_header = register_sysctl_table(dev_root); 4351 4348 4352 4349 mutex_init(&perf->metrics_lock); 4353 4350 idr_init(&perf->metrics_idr); ··· 4382 4381 return 0; 4383 4382 } 4384 4383 4384 + void i915_perf_sysctl_register(void) 4385 + { 4386 + sysctl_header = register_sysctl_table(dev_root); 4387 + } 4388 + 4389 + void i915_perf_sysctl_unregister(void) 4390 + { 4391 + unregister_sysctl_table(sysctl_header); 4392 + } 4393 + 4385 4394 /** 4386 4395 * i915_perf_fini - Counter part to i915_perf_init() 4387 4396 * @i915: i915 device instance ··· 4405 4394 4406 4395 idr_for_each(&perf->metrics_idr, destroy_config, perf); 4407 4396 idr_destroy(&perf->metrics_idr); 4408 - 4409 - unregister_sysctl_table(perf->sysctl_header); 4410 4397 4411 4398 memset(&perf->ops, 0, sizeof(perf->ops)); 4412 4399 perf->i915 = NULL;
+2
drivers/gpu/drm/i915/i915_perf.h
··· 23 23 void i915_perf_register(struct drm_i915_private *i915); 24 24 void i915_perf_unregister(struct drm_i915_private *i915); 25 25 int i915_perf_ioctl_version(void); 26 + void i915_perf_sysctl_register(void); 27 + void i915_perf_sysctl_unregister(void); 26 28 27 29 int i915_perf_open_ioctl(struct drm_device *dev, void *data, 28 30 struct drm_file *file);
-1
drivers/gpu/drm/i915/i915_perf_types.h
··· 380 380 struct drm_i915_private *i915; 381 381 382 382 struct kobject *metrics_kobj; 383 - struct ctl_table_header *sysctl_header; 384 383 385 384 /* 386 385 * Lock associated with adding/modifying/removing OA configs