forked from Minki/linux
drm/amd/amdgpu: Fold TTM debugfs entries into array (v2)
Signed-off-by: Tom St Denis <tom.stdenis@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (v2): add domains and avoid strcmp
This commit is contained in:
parent
0b693f0b56
commit
a40cfa0bef
@ -1809,6 +1809,19 @@ static const struct file_operations amdgpu_ttm_gtt_fops = {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev)
|
static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev)
|
||||||
@ -1819,22 +1832,21 @@ static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev)
|
|||||||
struct drm_minor *minor = adev->ddev->primary;
|
struct drm_minor *minor = adev->ddev->primary;
|
||||||
struct dentry *ent, *root = minor->debugfs_root;
|
struct dentry *ent, *root = minor->debugfs_root;
|
||||||
|
|
||||||
ent = debugfs_create_file("amdgpu_vram", S_IFREG | S_IRUGO, root,
|
for (count = 0; count < ARRAY_SIZE(ttm_debugfs_entries); count++) {
|
||||||
adev, &amdgpu_ttm_vram_fops);
|
ent = debugfs_create_file(
|
||||||
if (IS_ERR(ent))
|
ttm_debugfs_entries[count].name,
|
||||||
return PTR_ERR(ent);
|
S_IFREG | S_IRUGO, root,
|
||||||
i_size_write(ent->d_inode, adev->mc.mc_vram_size);
|
adev,
|
||||||
adev->mman.vram = ent;
|
ttm_debugfs_entries[count].fops);
|
||||||
|
if (IS_ERR(ent))
|
||||||
|
return PTR_ERR(ent);
|
||||||
|
if (ttm_debugfs_entries[count].domain == TTM_PL_VRAM)
|
||||||
|
i_size_write(ent->d_inode, adev->mc.mc_vram_size);
|
||||||
|
else if (ttm_debugfs_entries[count].domain == TTM_PL_TT)
|
||||||
|
i_size_write(ent->d_inode, adev->mc.gart_size);
|
||||||
|
adev->mman.debugfs_entries[count] = ent;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS
|
|
||||||
ent = debugfs_create_file("amdgpu_gtt", S_IFREG | S_IRUGO, root,
|
|
||||||
adev, &amdgpu_ttm_gtt_fops);
|
|
||||||
if (IS_ERR(ent))
|
|
||||||
return PTR_ERR(ent);
|
|
||||||
i_size_write(ent->d_inode, adev->mc.gart_size);
|
|
||||||
adev->mman.gtt = ent;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
count = ARRAY_SIZE(amdgpu_ttm_debugfs_list);
|
count = ARRAY_SIZE(amdgpu_ttm_debugfs_list);
|
||||||
|
|
||||||
#ifdef CONFIG_SWIOTLB
|
#ifdef CONFIG_SWIOTLB
|
||||||
@ -1844,7 +1856,6 @@ static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev)
|
|||||||
|
|
||||||
return amdgpu_debugfs_add_files(adev, amdgpu_ttm_debugfs_list, count);
|
return amdgpu_debugfs_add_files(adev, amdgpu_ttm_debugfs_list, count);
|
||||||
#else
|
#else
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -1852,14 +1863,9 @@ static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev)
|
|||||||
static void amdgpu_ttm_debugfs_fini(struct amdgpu_device *adev)
|
static void amdgpu_ttm_debugfs_fini(struct amdgpu_device *adev)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_DEBUG_FS)
|
#if defined(CONFIG_DEBUG_FS)
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
debugfs_remove(adev->mman.vram);
|
for (i = 0; i < ARRAY_SIZE(ttm_debugfs_entries); i++)
|
||||||
adev->mman.vram = NULL;
|
debugfs_remove(adev->mman.debugfs_entries[i]);
|
||||||
|
|
||||||
#ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS
|
|
||||||
debugfs_remove(adev->mman.gtt);
|
|
||||||
adev->mman.gtt = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#ifndef __AMDGPU_TTM_H__
|
#ifndef __AMDGPU_TTM_H__
|
||||||
#define __AMDGPU_TTM_H__
|
#define __AMDGPU_TTM_H__
|
||||||
|
|
||||||
|
#include "amdgpu.h"
|
||||||
#include "gpu_scheduler.h"
|
#include "gpu_scheduler.h"
|
||||||
|
|
||||||
#define AMDGPU_PL_GDS (TTM_PL_PRIV + 0)
|
#define AMDGPU_PL_GDS (TTM_PL_PRIV + 0)
|
||||||
@ -45,8 +46,7 @@ struct amdgpu_mman {
|
|||||||
bool initialized;
|
bool initialized;
|
||||||
|
|
||||||
#if defined(CONFIG_DEBUG_FS)
|
#if defined(CONFIG_DEBUG_FS)
|
||||||
struct dentry *vram;
|
struct dentry *debugfs_entries[8];
|
||||||
struct dentry *gtt;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* buffer handling */
|
/* buffer handling */
|
||||||
|
Loading…
Reference in New Issue
Block a user