Commit 4d8bf9ae authored by Christian König's avatar Christian König Committed by Dave Airlie

drm/radeon: fix debugfs handling v3

Having registered debugfs files globally causes
the files to not show up on the second, third
etc.. card in the system.

v2: fix crash on module unloading
v3: fix space indentation
Signed-off-by: default avatarChristian König <deathsimple@vodafone.de>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Reviewed-by: default avatarJerome Glisse <jglisse@redhat.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent e2e022ec
...@@ -873,6 +873,11 @@ void radeon_test_moves(struct radeon_device *rdev); ...@@ -873,6 +873,11 @@ void radeon_test_moves(struct radeon_device *rdev);
/* /*
* Debugfs * Debugfs
*/ */
struct radeon_debugfs {
struct drm_info_list *files;
unsigned num_files;
};
int radeon_debugfs_add_files(struct radeon_device *rdev, int radeon_debugfs_add_files(struct radeon_device *rdev,
struct drm_info_list *files, struct drm_info_list *files,
unsigned nfiles); unsigned nfiles);
...@@ -1278,6 +1283,9 @@ struct radeon_device { ...@@ -1278,6 +1283,9 @@ struct radeon_device {
struct drm_file *cmask_filp; struct drm_file *cmask_filp;
/* i2c buses */ /* i2c buses */
struct radeon_i2c_chan *i2c_bus[RADEON_MAX_I2C_BUS]; struct radeon_i2c_chan *i2c_bus[RADEON_MAX_I2C_BUS];
/* debugfs */
struct radeon_debugfs debugfs[RADEON_DEBUGFS_MAX_COMPONENTS];
unsigned debugfs_count;
}; };
int radeon_device_init(struct radeon_device *rdev, int radeon_device_init(struct radeon_device *rdev,
......
...@@ -829,6 +829,8 @@ int radeon_device_init(struct radeon_device *rdev, ...@@ -829,6 +829,8 @@ int radeon_device_init(struct radeon_device *rdev,
return 0; return 0;
} }
static void radeon_debugfs_remove_files(struct radeon_device *rdev);
void radeon_device_fini(struct radeon_device *rdev) void radeon_device_fini(struct radeon_device *rdev)
{ {
DRM_INFO("radeon: finishing device.\n"); DRM_INFO("radeon: finishing device.\n");
...@@ -843,6 +845,7 @@ void radeon_device_fini(struct radeon_device *rdev) ...@@ -843,6 +845,7 @@ void radeon_device_fini(struct radeon_device *rdev)
rdev->rio_mem = NULL; rdev->rio_mem = NULL;
iounmap(rdev->rmmio); iounmap(rdev->rmmio);
rdev->rmmio = NULL; rdev->rmmio = NULL;
radeon_debugfs_remove_files(rdev);
} }
...@@ -992,36 +995,29 @@ int radeon_gpu_reset(struct radeon_device *rdev) ...@@ -992,36 +995,29 @@ int radeon_gpu_reset(struct radeon_device *rdev)
/* /*
* Debugfs * Debugfs
*/ */
struct radeon_debugfs {
struct drm_info_list *files;
unsigned num_files;
};
static struct radeon_debugfs _radeon_debugfs[RADEON_DEBUGFS_MAX_COMPONENTS];
static unsigned _radeon_debugfs_count = 0;
int radeon_debugfs_add_files(struct radeon_device *rdev, int radeon_debugfs_add_files(struct radeon_device *rdev,
struct drm_info_list *files, struct drm_info_list *files,
unsigned nfiles) unsigned nfiles)
{ {
unsigned i; unsigned i;
for (i = 0; i < _radeon_debugfs_count; i++) { for (i = 0; i < rdev->debugfs_count; i++) {
if (_radeon_debugfs[i].files == files) { if (rdev->debugfs[i].files == files) {
/* Already registered */ /* Already registered */
return 0; return 0;
} }
} }
i = _radeon_debugfs_count + 1; i = rdev->debugfs_count + 1;
if (i > RADEON_DEBUGFS_MAX_COMPONENTS) { if (i > RADEON_DEBUGFS_MAX_COMPONENTS) {
DRM_ERROR("Reached maximum number of debugfs components.\n"); DRM_ERROR("Reached maximum number of debugfs components.\n");
DRM_ERROR("Report so we increase " DRM_ERROR("Report so we increase "
"RADEON_DEBUGFS_MAX_COMPONENTS.\n"); "RADEON_DEBUGFS_MAX_COMPONENTS.\n");
return -EINVAL; return -EINVAL;
} }
_radeon_debugfs[_radeon_debugfs_count].files = files; rdev->debugfs[rdev->debugfs_count].files = files;
_radeon_debugfs[_radeon_debugfs_count].num_files = nfiles; rdev->debugfs[rdev->debugfs_count].num_files = nfiles;
_radeon_debugfs_count = i; rdev->debugfs_count = i;
#if defined(CONFIG_DEBUG_FS) #if defined(CONFIG_DEBUG_FS)
drm_debugfs_create_files(files, nfiles, drm_debugfs_create_files(files, nfiles,
rdev->ddev->control->debugfs_root, rdev->ddev->control->debugfs_root,
...@@ -1033,6 +1029,22 @@ int radeon_debugfs_add_files(struct radeon_device *rdev, ...@@ -1033,6 +1029,22 @@ int radeon_debugfs_add_files(struct radeon_device *rdev,
return 0; return 0;
} }
static void radeon_debugfs_remove_files(struct radeon_device *rdev)
{
#if defined(CONFIG_DEBUG_FS)
unsigned i;
for (i = 0; i < rdev->debugfs_count; i++) {
drm_debugfs_remove_files(rdev->debugfs[i].files,
rdev->debugfs[i].num_files,
rdev->ddev->control);
drm_debugfs_remove_files(rdev->debugfs[i].files,
rdev->debugfs[i].num_files,
rdev->ddev->primary);
}
#endif
}
#if defined(CONFIG_DEBUG_FS) #if defined(CONFIG_DEBUG_FS)
int radeon_debugfs_init(struct drm_minor *minor) int radeon_debugfs_init(struct drm_minor *minor)
{ {
...@@ -1041,11 +1053,5 @@ int radeon_debugfs_init(struct drm_minor *minor) ...@@ -1041,11 +1053,5 @@ int radeon_debugfs_init(struct drm_minor *minor)
void radeon_debugfs_cleanup(struct drm_minor *minor) void radeon_debugfs_cleanup(struct drm_minor *minor)
{ {
unsigned i;
for (i = 0; i < _radeon_debugfs_count; i++) {
drm_debugfs_remove_files(_radeon_debugfs[i].files,
_radeon_debugfs[i].num_files, minor);
}
} }
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment