Skip to content

Commit

Permalink
drm/i915/perf: Register sysctl path globally
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Venkata Sandeep Dhanalakota authored and Chris Wilson committed Dec 13, 2019
1 parent b69fa36 commit 3dc716f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
9 changes: 8 additions & 1 deletion drivers/gpu/drm/i915/i915_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "display/intel_fbdev.h"

#include "i915_drv.h"
#include "i915_perf.h"
#include "i915_globals.h"
#include "i915_selftest.h"

Expand Down Expand Up @@ -1053,14 +1054,20 @@ static int __init i915_init(void)
return 0;
}

return pci_register_driver(&i915_pci_driver);
err = pci_register_driver(&i915_pci_driver);
if (err)
return err;

i915_perf_sysctl_register();
return 0;
}

static void __exit i915_exit(void)
{
if (!i915_pci_driver.driver.owner)
return;

i915_perf_sysctl_unregister();
pci_unregister_driver(&i915_pci_driver);
i915_globals_exit();
}
Expand Down
17 changes: 13 additions & 4 deletions drivers/gpu/drm/i915/i915_perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ struct i915_oa_config_bo {
struct i915_vma *vma;
};

static struct ctl_table_header *sysctl_header;

static enum hrtimer_restart oa_poll_check_timer_cb(struct hrtimer *hrtimer);

void i915_oa_config_release(struct kref *ref)
Expand Down Expand Up @@ -4228,7 +4230,7 @@ static struct ctl_table dev_root[] = {
};

/**
* i915_perf_init - initialize i915-perf state on module load
* i915_perf_init - initialize i915-perf state on module bind
* @i915: i915 device instance
*
* Initializes i915-perf state without exposing anything to userspace.
Expand Down Expand Up @@ -4345,7 +4347,6 @@ void i915_perf_init(struct drm_i915_private *i915)

oa_sample_rate_hard_limit = 1000 *
(RUNTIME_INFO(i915)->cs_timestamp_frequency_khz / 2);
perf->sysctl_header = register_sysctl_table(dev_root);

mutex_init(&perf->metrics_lock);
idr_init(&perf->metrics_idr);
Expand Down Expand Up @@ -4381,6 +4382,16 @@ static int destroy_config(int id, void *p, void *data)
return 0;
}

void i915_perf_sysctl_register(void)
{
sysctl_header = register_sysctl_table(dev_root);
}

void i915_perf_sysctl_unregister(void)
{
unregister_sysctl_table(sysctl_header);
}

/**
* i915_perf_fini - Counter part to i915_perf_init()
* @i915: i915 device instance
Expand All @@ -4395,8 +4406,6 @@ void i915_perf_fini(struct drm_i915_private *i915)
idr_for_each(&perf->metrics_idr, destroy_config, perf);
idr_destroy(&perf->metrics_idr);

unregister_sysctl_table(perf->sysctl_header);

memset(&perf->ops, 0, sizeof(perf->ops));
perf->i915 = NULL;
}
Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/drm/i915/i915_perf.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ void i915_perf_fini(struct drm_i915_private *i915);
void i915_perf_register(struct drm_i915_private *i915);
void i915_perf_unregister(struct drm_i915_private *i915);
int i915_perf_ioctl_version(void);
void i915_perf_sysctl_register(void);
void i915_perf_sysctl_unregister(void);

int i915_perf_open_ioctl(struct drm_device *dev, void *data,
struct drm_file *file);
Expand Down
1 change: 0 additions & 1 deletion drivers/gpu/drm/i915/i915_perf_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,6 @@ struct i915_perf {
struct drm_i915_private *i915;

struct kobject *metrics_kobj;
struct ctl_table_header *sysctl_header;

/*
* Lock associated with adding/modifying/removing OA configs
Expand Down

0 comments on commit 3dc716f

Please sign in to comment.