Commit 88293c03 authored by Nirmoy Das's avatar Nirmoy Das Committed by Alex Deucher

drm/amdgpu: do not keep debugfs dentry

Cleanup unnecessary debugfs dentries and surrounding functions.

v3: remove return value check for debugfs_create_file()
v2: remove ttm_debugfs_entries array.
    do not init variables.
Signed-off-by: default avatarNirmoy Das <nirmoy.das@amd.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 6e80fb8a
...@@ -793,10 +793,6 @@ struct amdgpu_device { ...@@ -793,10 +793,6 @@ struct amdgpu_device {
struct amdgpu_i2c_chan *i2c_bus[AMDGPU_MAX_I2C_BUS]; struct amdgpu_i2c_chan *i2c_bus[AMDGPU_MAX_I2C_BUS];
struct amdgpu_debugfs debugfs[AMDGPU_DEBUGFS_MAX_COMPONENTS]; struct amdgpu_debugfs debugfs[AMDGPU_DEBUGFS_MAX_COMPONENTS];
unsigned debugfs_count; unsigned debugfs_count;
#if defined(CONFIG_DEBUG_FS)
struct dentry *debugfs_preempt;
struct dentry *debugfs_regs[AMDGPU_DEBUGFS_MAX_COMPONENTS];
#endif
struct amdgpu_atif *atif; struct amdgpu_atif *atif;
struct amdgpu_atcs atcs; struct amdgpu_atcs atcs;
struct mutex srbm_mutex; struct mutex srbm_mutex;
......
...@@ -1228,7 +1228,6 @@ int amdgpu_debugfs_regs_init(struct amdgpu_device *adev) ...@@ -1228,7 +1228,6 @@ int amdgpu_debugfs_regs_init(struct amdgpu_device *adev)
adev, debugfs_regs[i]); adev, debugfs_regs[i]);
if (!i && !IS_ERR_OR_NULL(ent)) if (!i && !IS_ERR_OR_NULL(ent))
i_size_write(ent->d_inode, adev->rmmio_size); i_size_write(ent->d_inode, adev->rmmio_size);
adev->debugfs_regs[i] = ent;
} }
return 0; return 0;
...@@ -1594,22 +1593,21 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_sclk_set, NULL, ...@@ -1594,22 +1593,21 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_sclk_set, NULL,
int amdgpu_debugfs_init(struct amdgpu_device *adev) int amdgpu_debugfs_init(struct amdgpu_device *adev)
{ {
struct dentry *ent;
int r, i; int r, i;
adev->debugfs_preempt = ent = debugfs_create_file("amdgpu_preempt_ib", 0600,
debugfs_create_file("amdgpu_preempt_ib", 0600, adev_to_drm(adev)->primary->debugfs_root, adev,
adev_to_drm(adev)->primary->debugfs_root, adev, &fops_ib_preempt);
&fops_ib_preempt); if (!ent) {
if (!(adev->debugfs_preempt)) {
DRM_ERROR("unable to create amdgpu_preempt_ib debugsfs file\n"); DRM_ERROR("unable to create amdgpu_preempt_ib debugsfs file\n");
return -EIO; return -EIO;
} }
adev->smu.debugfs_sclk = ent = debugfs_create_file("amdgpu_force_sclk", 0200,
debugfs_create_file("amdgpu_force_sclk", 0200, adev_to_drm(adev)->primary->debugfs_root, adev,
adev_to_drm(adev)->primary->debugfs_root, adev, &fops_sclk_set);
&fops_sclk_set); if (!ent) {
if (!(adev->smu.debugfs_sclk)) {
DRM_ERROR("unable to create amdgpu_set_sclk debugsfs file\n"); DRM_ERROR("unable to create amdgpu_set_sclk debugsfs file\n");
return -EIO; return -EIO;
} }
......
...@@ -1137,16 +1137,17 @@ static int amdgpu_ras_sysfs_remove_all(struct amdgpu_device *adev) ...@@ -1137,16 +1137,17 @@ static int amdgpu_ras_sysfs_remove_all(struct amdgpu_device *adev)
* *
*/ */
/* debugfs begin */ /* debugfs begin */
static void amdgpu_ras_debugfs_create_ctrl_node(struct amdgpu_device *adev) struct dentry *amdgpu_ras_debugfs_create_ctrl_node(struct amdgpu_device *adev)
{ {
struct amdgpu_ras *con = amdgpu_ras_get_context(adev); struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
struct dentry *dir;
struct drm_minor *minor = adev_to_drm(adev)->primary; struct drm_minor *minor = adev_to_drm(adev)->primary;
con->dir = debugfs_create_dir(RAS_FS_NAME, minor->debugfs_root); dir = debugfs_create_dir(RAS_FS_NAME, minor->debugfs_root);
debugfs_create_file("ras_ctrl", S_IWUGO | S_IRUGO, con->dir, debugfs_create_file("ras_ctrl", S_IWUGO | S_IRUGO, dir, adev,
adev, &amdgpu_ras_debugfs_ctrl_ops); &amdgpu_ras_debugfs_ctrl_ops);
debugfs_create_file("ras_eeprom_reset", S_IWUGO | S_IRUGO, con->dir, debugfs_create_file("ras_eeprom_reset", S_IWUGO | S_IRUGO, dir, adev,
adev, &amdgpu_ras_debugfs_eeprom_ops); &amdgpu_ras_debugfs_eeprom_ops);
/* /*
* After one uncorrectable error happens, usually GPU recovery will * After one uncorrectable error happens, usually GPU recovery will
...@@ -1156,24 +1157,24 @@ static void amdgpu_ras_debugfs_create_ctrl_node(struct amdgpu_device *adev) ...@@ -1156,24 +1157,24 @@ static void amdgpu_ras_debugfs_create_ctrl_node(struct amdgpu_device *adev)
* ERREVENT_ATHUB_INTERRUPT generated. Normal GPU recovery routine * ERREVENT_ATHUB_INTERRUPT generated. Normal GPU recovery routine
* will never be called. * will never be called.
*/ */
debugfs_create_bool("auto_reboot", S_IWUGO | S_IRUGO, con->dir, debugfs_create_bool("auto_reboot", S_IWUGO | S_IRUGO, dir, &con->reboot);
&con->reboot);
/* /*
* User could set this not to clean up hardware's error count register * User could set this not to clean up hardware's error count register
* of RAS IPs during ras recovery. * of RAS IPs during ras recovery.
*/ */
debugfs_create_bool("disable_ras_err_cnt_harvest", 0644, debugfs_create_bool("disable_ras_err_cnt_harvest", 0644, dir,
con->dir, &con->disable_ras_err_cnt_harvest); &con->disable_ras_err_cnt_harvest);
return dir;
} }
static void amdgpu_ras_debugfs_create(struct amdgpu_device *adev, static void amdgpu_ras_debugfs_create(struct amdgpu_device *adev,
struct ras_fs_if *head) struct ras_fs_if *head,
struct dentry *dir)
{ {
struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
struct ras_manager *obj = amdgpu_ras_find_obj(adev, &head->head); struct ras_manager *obj = amdgpu_ras_find_obj(adev, &head->head);
if (!obj || obj->ent) if (!obj || !dir)
return; return;
get_obj(obj); get_obj(obj);
...@@ -1182,14 +1183,14 @@ static void amdgpu_ras_debugfs_create(struct amdgpu_device *adev, ...@@ -1182,14 +1183,14 @@ static void amdgpu_ras_debugfs_create(struct amdgpu_device *adev,
head->debugfs_name, head->debugfs_name,
sizeof(obj->fs_data.debugfs_name)); sizeof(obj->fs_data.debugfs_name));
obj->ent = debugfs_create_file(obj->fs_data.debugfs_name, debugfs_create_file(obj->fs_data.debugfs_name, S_IWUGO | S_IRUGO, dir,
S_IWUGO | S_IRUGO, con->dir, obj, obj, &amdgpu_ras_debugfs_ops);
&amdgpu_ras_debugfs_ops);
} }
void amdgpu_ras_debugfs_create_all(struct amdgpu_device *adev) void amdgpu_ras_debugfs_create_all(struct amdgpu_device *adev)
{ {
struct amdgpu_ras *con = amdgpu_ras_get_context(adev); struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
struct dentry *dir;
struct ras_manager *obj; struct ras_manager *obj;
struct ras_fs_if fs_info; struct ras_fs_if fs_info;
...@@ -1200,7 +1201,7 @@ void amdgpu_ras_debugfs_create_all(struct amdgpu_device *adev) ...@@ -1200,7 +1201,7 @@ void amdgpu_ras_debugfs_create_all(struct amdgpu_device *adev)
if (!IS_ENABLED(CONFIG_DEBUG_FS) || !con) if (!IS_ENABLED(CONFIG_DEBUG_FS) || !con)
return; return;
amdgpu_ras_debugfs_create_ctrl_node(adev); dir = amdgpu_ras_debugfs_create_ctrl_node(adev);
list_for_each_entry(obj, &con->head, node) { list_for_each_entry(obj, &con->head, node) {
if (amdgpu_ras_is_supported(adev, obj->head.block) && if (amdgpu_ras_is_supported(adev, obj->head.block) &&
...@@ -1208,34 +1209,11 @@ void amdgpu_ras_debugfs_create_all(struct amdgpu_device *adev) ...@@ -1208,34 +1209,11 @@ void amdgpu_ras_debugfs_create_all(struct amdgpu_device *adev)
sprintf(fs_info.debugfs_name, "%s_err_inject", sprintf(fs_info.debugfs_name, "%s_err_inject",
ras_block_str(obj->head.block)); ras_block_str(obj->head.block));
fs_info.head = obj->head; fs_info.head = obj->head;
amdgpu_ras_debugfs_create(adev, &fs_info); amdgpu_ras_debugfs_create(adev, &fs_info, dir);
} }
} }
} }
static void amdgpu_ras_debugfs_remove(struct amdgpu_device *adev,
struct ras_common_if *head)
{
struct ras_manager *obj = amdgpu_ras_find_obj(adev, head);
if (!obj || !obj->ent)
return;
obj->ent = NULL;
put_obj(obj);
}
static void amdgpu_ras_debugfs_remove_all(struct amdgpu_device *adev)
{
struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
struct ras_manager *obj, *tmp;
list_for_each_entry_safe(obj, tmp, &con->head, node) {
amdgpu_ras_debugfs_remove(adev, &obj->head);
}
con->dir = NULL;
}
/* debugfs end */ /* debugfs end */
/* ras fs */ /* ras fs */
...@@ -1282,8 +1260,17 @@ static int amdgpu_ras_fs_init(struct amdgpu_device *adev) ...@@ -1282,8 +1260,17 @@ static int amdgpu_ras_fs_init(struct amdgpu_device *adev)
static int amdgpu_ras_fs_fini(struct amdgpu_device *adev) static int amdgpu_ras_fs_fini(struct amdgpu_device *adev)
{ {
if (IS_ENABLED(CONFIG_DEBUG_FS)) struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
amdgpu_ras_debugfs_remove_all(adev); struct ras_manager *con_obj, *ip_obj, *tmp;
if (IS_ENABLED(CONFIG_DEBUG_FS)) {
list_for_each_entry_safe(con_obj, tmp, &con->head, node) {
ip_obj = amdgpu_ras_find_obj(adev, &con_obj->head);
if (ip_obj)
put_obj(ip_obj);
}
}
amdgpu_ras_sysfs_remove_all(adev); amdgpu_ras_sysfs_remove_all(adev);
return 0; return 0;
} }
......
...@@ -318,8 +318,6 @@ struct amdgpu_ras { ...@@ -318,8 +318,6 @@ struct amdgpu_ras {
uint32_t supported; uint32_t supported;
uint32_t features; uint32_t features;
struct list_head head; struct list_head head;
/* debugfs */
struct dentry *dir;
/* sysfs */ /* sysfs */
struct device_attribute features_attr; struct device_attribute features_attr;
struct bin_attribute badpages_attr; struct bin_attribute badpages_attr;
...@@ -395,8 +393,6 @@ struct ras_manager { ...@@ -395,8 +393,6 @@ struct ras_manager {
struct list_head node; struct list_head node;
/* the device */ /* the device */
struct amdgpu_device *adev; struct amdgpu_device *adev;
/* debugfs */
struct dentry *ent;
/* sysfs */ /* sysfs */
struct device_attribute sysfs_attr; struct device_attribute sysfs_attr;
int attr_inuse; int attr_inuse;
......
...@@ -1696,7 +1696,7 @@ static void amdgpu_ttm_training_data_block_init(struct amdgpu_device *adev) ...@@ -1696,7 +1696,7 @@ static void amdgpu_ttm_training_data_block_init(struct amdgpu_device *adev)
(adev->gmc.mc_vram_size - GDDR6_MEM_TRAINING_OFFSET); (adev->gmc.mc_vram_size - GDDR6_MEM_TRAINING_OFFSET);
ctx->train_data_size = ctx->train_data_size =
GDDR6_MEM_TRAINING_DATA_SIZE_IN_BYTES; GDDR6_MEM_TRAINING_DATA_SIZE_IN_BYTES;
DRM_DEBUG("train_data_size:%llx,p2c_train_data_offset:%llx,c2p_train_data_offset:%llx.\n", DRM_DEBUG("train_data_size:%llx,p2c_train_data_offset:%llx,c2p_train_data_offset:%llx.\n",
ctx->train_data_size, ctx->train_data_size,
ctx->p2c_train_data_offset, ctx->p2c_train_data_offset,
...@@ -2474,18 +2474,6 @@ static const struct file_operations amdgpu_ttm_iomem_fops = { ...@@ -2474,18 +2474,6 @@ static const struct file_operations amdgpu_ttm_iomem_fops = {
.llseek = default_llseek .llseek = default_llseek
}; };
static const struct {
char *name;
const struct file_operations *fops;
int domain;
} ttm_debugfs_entries[] = {
{ "amdgpu_vram", &amdgpu_ttm_vram_fops, TTM_PL_VRAM },
#ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS
{ "amdgpu_gtt", &amdgpu_ttm_gtt_fops, TTM_PL_TT },
#endif
{ "amdgpu_iomem", &amdgpu_ttm_iomem_fops, TTM_PL_SYSTEM },
};
#endif #endif
int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev) int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev)
...@@ -2494,23 +2482,18 @@ int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev) ...@@ -2494,23 +2482,18 @@ int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev)
unsigned count; unsigned count;
struct drm_minor *minor = adev_to_drm(adev)->primary; struct drm_minor *minor = adev_to_drm(adev)->primary;
struct dentry *ent, *root = minor->debugfs_root; umode_t mode = S_IFREG | S_IRUGO;
struct dentry *root = minor->debugfs_root;
for (count = 0; count < ARRAY_SIZE(ttm_debugfs_entries); count++) {
ent = debugfs_create_file( debugfs_create_file_size("amdgpu_vram", mode, root, adev,
ttm_debugfs_entries[count].name, &amdgpu_ttm_vram_fops, adev->gmc.mc_vram_size);
S_IFREG | S_IRUGO, root, #ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS
adev, debugfs_create_file_size("amdgpu_gtt", mode, root, adev,
ttm_debugfs_entries[count].fops); &amdgpu_ttm_gtt_fops, adev->gmc.gart_size);
if (IS_ERR(ent)) #endif
return PTR_ERR(ent);
if (ttm_debugfs_entries[count].domain == TTM_PL_VRAM)
i_size_write(ent->d_inode, adev->gmc.mc_vram_size);
else if (ttm_debugfs_entries[count].domain == TTM_PL_TT)
i_size_write(ent->d_inode, adev->gmc.gart_size);
adev->mman.debugfs_entries[count] = ent;
}
debugfs_create_file("amdgpu_iomem", mode, root, adev,
&amdgpu_ttm_iomem_fops);
count = ARRAY_SIZE(amdgpu_ttm_debugfs_list); count = ARRAY_SIZE(amdgpu_ttm_debugfs_list);
return amdgpu_debugfs_add_files(adev, amdgpu_ttm_debugfs_list, count); return amdgpu_debugfs_add_files(adev, amdgpu_ttm_debugfs_list, count);
#else #else
......
...@@ -64,10 +64,6 @@ struct amdgpu_mman { ...@@ -64,10 +64,6 @@ struct amdgpu_mman {
bool initialized; bool initialized;
void __iomem *aper_base_kaddr; void __iomem *aper_base_kaddr;
#if defined(CONFIG_DEBUG_FS)
struct dentry *debugfs_entries[8];
#endif
/* buffer handling */ /* buffer handling */
const struct amdgpu_buffer_funcs *buffer_funcs; const struct amdgpu_buffer_funcs *buffer_funcs;
struct amdgpu_ring *buffer_funcs_ring; struct amdgpu_ring *buffer_funcs_ring;
......
...@@ -439,9 +439,6 @@ struct smu_context ...@@ -439,9 +439,6 @@ struct smu_context
struct smu_baco_context smu_baco; struct smu_baco_context smu_baco;
struct smu_temperature_range thermal_range; struct smu_temperature_range thermal_range;
void *od_settings; void *od_settings;
#if defined(CONFIG_DEBUG_FS)
struct dentry *debugfs_sclk;
#endif
struct smu_umd_pstate_table pstate_table; struct smu_umd_pstate_table pstate_table;
uint32_t pstate_sclk; uint32_t pstate_sclk;
......
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