mirror of
https://github.com/torvalds/linux.git
synced 2026-05-28 09:04:39 +02:00
drm/amd/pm: Add debugfs info for STB
Add debugfs hook. Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com> Reviewed-by: Lijo Lazar <lijo.lazar@amd.com> Reviewed-by: Luben Tuikov <luben.tuikov@amd.com> Acked-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
db5b5c679e
commit
1f5fc7a509
|
|
@ -3759,5 +3759,7 @@ void amdgpu_debugfs_pm_init(struct amdgpu_device *adev)
|
|||
adev,
|
||||
&amdgpu_debugfs_pm_prv_buffer_fops,
|
||||
adev->pm.smu_prv_buffer_size);
|
||||
|
||||
amdgpu_smu_stb_debug_fs_init(adev);
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1420,6 +1420,7 @@ int smu_wait_for_event(struct amdgpu_device *adev, enum smu_event_type event,
|
|||
uint64_t event_arg);
|
||||
int smu_get_ecc_info(struct smu_context *smu, void *umc_ecc);
|
||||
int smu_stb_collect_info(struct smu_context *smu, void *buff, uint32_t size);
|
||||
void amdgpu_smu_stb_debug_fs_init(struct amdgpu_device *adev);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3193,3 +3193,89 @@ int smu_stb_collect_info(struct smu_context *smu, void *buf, uint32_t size)
|
|||
*/
|
||||
return smu->ppt_funcs->stb_collect_info(smu, buf, size);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_DEBUG_FS)
|
||||
|
||||
static int smu_stb_debugfs_open(struct inode *inode, struct file *filp)
|
||||
{
|
||||
struct amdgpu_device *adev = filp->f_inode->i_private;
|
||||
struct smu_context *smu = &adev->smu;
|
||||
unsigned char *buf;
|
||||
int r;
|
||||
|
||||
buf = kvmalloc_array(smu->stb_context.stb_buf_size, sizeof(*buf), GFP_KERNEL);
|
||||
if (!buf)
|
||||
return -ENOMEM;
|
||||
|
||||
r = smu_stb_collect_info(smu, buf, smu->stb_context.stb_buf_size);
|
||||
if (r)
|
||||
goto out;
|
||||
|
||||
filp->private_data = buf;
|
||||
|
||||
return 0;
|
||||
|
||||
out:
|
||||
kvfree(buf);
|
||||
return r;
|
||||
}
|
||||
|
||||
static ssize_t smu_stb_debugfs_read(struct file *filp, char __user *buf, size_t size,
|
||||
loff_t *pos)
|
||||
{
|
||||
struct amdgpu_device *adev = filp->f_inode->i_private;
|
||||
struct smu_context *smu = &adev->smu;
|
||||
|
||||
|
||||
if (!filp->private_data)
|
||||
return -EINVAL;
|
||||
|
||||
return simple_read_from_buffer(buf,
|
||||
size,
|
||||
pos, filp->private_data,
|
||||
smu->stb_context.stb_buf_size);
|
||||
}
|
||||
|
||||
static int smu_stb_debugfs_release(struct inode *inode, struct file *filp)
|
||||
{
|
||||
kvfree(filp->private_data);
|
||||
filp->private_data = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* We have to define not only read method but also
|
||||
* open and release because .read takes up to PAGE_SIZE
|
||||
* data each time so and so is invoked multiple times.
|
||||
* We allocate the STB buffer in .open and release it
|
||||
* in .release
|
||||
*/
|
||||
static const struct file_operations smu_stb_debugfs_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = smu_stb_debugfs_open,
|
||||
.read = smu_stb_debugfs_read,
|
||||
.release = smu_stb_debugfs_release,
|
||||
.llseek = default_llseek,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
void amdgpu_smu_stb_debug_fs_init(struct amdgpu_device *adev)
|
||||
{
|
||||
#if defined(CONFIG_DEBUG_FS)
|
||||
|
||||
struct smu_context *smu = &adev->smu;
|
||||
|
||||
if (!smu->stb_context.stb_buf_size)
|
||||
return;
|
||||
|
||||
debugfs_create_file_size("amdgpu_smu_stb_dump",
|
||||
S_IRUSR,
|
||||
adev_to_drm(adev)->primary->debugfs_root,
|
||||
adev,
|
||||
&smu_stb_debugfs_fops,
|
||||
smu->stb_context.stb_buf_size);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user