Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
- index 264176a01e16..601f4ad844cb 100644
- --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
- +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
- @@ -823,7 +823,12 @@ struct amdgpu_device {
- bool accel_working;
- struct notifier_block acpi_nb;
- struct amdgpu_i2c_chan *i2c_bus[AMDGPU_MAX_I2C_BUS];
- - struct debugfs_blob_wrapper debugfs_vbios_blob;
- + struct amdgpu_debugfs debugfs[AMDGPU_DEBUGFS_MAX_COMPONENTS];
- + 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_atcs atcs;
- struct mutex srbm_mutex;
- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
- index bcaf271b39bf..43059ead733b 100644
- --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
- +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
- @@ -28,6 +28,7 @@
- #include <linux/uaccess.h>
- #include <linux/pm_runtime.h>
- #include <linux/poll.h>
- +#include <drm/drm_debugfs.h>
- #include "amdgpu.h"
- #include "amdgpu_pm.h"
- @@ -37,6 +38,45 @@
- #include "amdgpu_securedisplay.h"
- #include "amdgpu_fw_attestation.h"
- +/**
- + * amdgpu_debugfs_add_files - Add simple debugfs entries
- + *
- + * @adev: Device to attach debugfs entries to
- + * @files: Array of function callbacks that respond to reads
- + * @nfiles: Number of callbacks to register
- + *
- + */
- +int amdgpu_debugfs_add_files(struct amdgpu_device *adev,
- + const struct drm_info_list *files,
- + unsigned nfiles)
- +{
- + unsigned i;
- +
- + for (i = 0; i < adev->debugfs_count; i++) {
- + if (adev->debugfs[i].files == files) {
- + /* Already registered */
- + return 0;
- + }
- + }
- +
- + i = adev->debugfs_count + 1;
- + if (i > AMDGPU_DEBUGFS_MAX_COMPONENTS) {
- + DRM_ERROR("Reached maximum number of debugfs components.\n");
- + DRM_ERROR("Report so we increase "
- + "AMDGPU_DEBUGFS_MAX_COMPONENTS.\n");
- + return -EINVAL;
- + }
- + adev->debugfs[adev->debugfs_count].files = files;
- + adev->debugfs[adev->debugfs_count].num_files = nfiles;
- + adev->debugfs_count = i;
- +#if defined(CONFIG_DEBUG_FS)
- + drm_debugfs_create_files(files, nfiles,
- + adev_to_drm(adev)->primary->debugfs_root,
- + adev_to_drm(adev)->primary);
- +#endif
- + return 0;
- +}
- +
- int amdgpu_debugfs_wait_dump(struct amdgpu_device *adev)
- {
- #if defined(CONFIG_DEBUG_FS)
- @@ -1188,20 +1228,22 @@ int amdgpu_debugfs_regs_init(struct amdgpu_device *adev)
- adev, debugfs_regs[i]);
- if (!i && !IS_ERR_OR_NULL(ent))
- i_size_write(ent->d_inode, adev->rmmio_size);
- + adev->debugfs_regs[i] = ent;
- }
- return 0;
- }
- -static int amdgpu_debugfs_test_ib_show(struct seq_file *m, void *unused)
- +static int amdgpu_debugfs_test_ib(struct seq_file *m, void *data)
- {
- - struct amdgpu_device *adev = (struct amdgpu_device *)m->private;
- - struct drm_device *dev = adev_to_drm(adev);
- + struct drm_info_node *node = (struct drm_info_node *) m->private;
- + struct drm_device *dev = node->minor->dev;
- + struct amdgpu_device *adev = drm_to_adev(dev);
- int r = 0, i;
- r = pm_runtime_get_sync(dev->dev);
- if (r < 0) {
- - pm_runtime_put_autosuspend(dev->dev);
- + pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
- return r;
- }
- @@ -1243,19 +1285,30 @@ static int amdgpu_debugfs_test_ib_show(struct seq_file *m, void *unused)
- return 0;
- }
- -static int amdgpu_debugfs_evict_vram(void *data, u64 *val)
- +static int amdgpu_debugfs_get_vbios_dump(struct seq_file *m, void *data)
- {
- - struct amdgpu_device *adev = (struct amdgpu_device *)data;
- - struct drm_device *dev = adev_to_drm(adev);
- + struct drm_info_node *node = (struct drm_info_node *) m->private;
- + struct drm_device *dev = node->minor->dev;
- + struct amdgpu_device *adev = drm_to_adev(dev);
- +
- + seq_write(m, adev->bios, adev->bios_size);
- + return 0;
- +}
- +
- +static int amdgpu_debugfs_evict_vram(struct seq_file *m, void *data)
- +{
- + struct drm_info_node *node = (struct drm_info_node *)m->private;
- + struct drm_device *dev = node->minor->dev;
- + struct amdgpu_device *adev = drm_to_adev(dev);
- int r;
- r = pm_runtime_get_sync(dev->dev);
- if (r < 0) {
- - pm_runtime_put_autosuspend(dev->dev);
- + pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
- return r;
- }
- - *val = amdgpu_bo_evict_vram(adev);
- + seq_printf(m, "(%d)\n", amdgpu_bo_evict_vram(adev));
- pm_runtime_mark_last_busy(dev->dev);
- pm_runtime_put_autosuspend(dev->dev);
- @@ -1263,11 +1316,11 @@ static int amdgpu_debugfs_evict_vram(void *data, u64 *val)
- return 0;
- }
- -
- -static int amdgpu_debugfs_evict_gtt(void *data, u64 *val)
- +static int amdgpu_debugfs_evict_gtt(struct seq_file *m, void *data)
- {
- - struct amdgpu_device *adev = (struct amdgpu_device *)data;
- - struct drm_device *dev = adev_to_drm(adev);
- + struct drm_info_node *node = (struct drm_info_node *)m->private;
- + struct drm_device *dev = node->minor->dev;
- + struct amdgpu_device *adev = drm_to_adev(dev);
- struct ttm_resource_manager *man;
- int r;
- @@ -1278,7 +1331,8 @@ static int amdgpu_debugfs_evict_gtt(void *data, u64 *val)
- }
- man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT);
- - *val = ttm_resource_manager_evict_all(&adev->mman.bdev, man);
- + r = ttm_resource_manager_evict_all(&adev->mman.bdev, man);
- + seq_printf(m, "(%d)\n", r);
- pm_runtime_mark_last_busy(dev->dev);
- pm_runtime_put_autosuspend(dev->dev);
- @@ -1286,11 +1340,10 @@ static int amdgpu_debugfs_evict_gtt(void *data, u64 *val)
- return 0;
- }
- -
- -static int amdgpu_debugfs_vm_info_show(struct seq_file *m, void *unused)
- +static int amdgpu_debugfs_vm_info(struct seq_file *m, void *data)
- {
- - struct amdgpu_device *adev = (struct amdgpu_device *)m->private;
- - struct drm_device *dev = adev_to_drm(adev);
- + struct drm_info_node *node = (struct drm_info_node *)m->private;
- + struct drm_device *dev = node->minor->dev;
- struct drm_file *file;
- int r;
- @@ -1316,12 +1369,13 @@ static int amdgpu_debugfs_vm_info_show(struct seq_file *m, void *unused)
- return r;
- }
- -DEFINE_SHOW_ATTRIBUTE(amdgpu_debugfs_test_ib);
- -DEFINE_SHOW_ATTRIBUTE(amdgpu_debugfs_vm_info);
- -DEFINE_DEBUGFS_ATTRIBUTE(amdgpu_evict_vram_fops, amdgpu_debugfs_evict_vram,
- - NULL, "%lld\n");
- -DEFINE_DEBUGFS_ATTRIBUTE(amdgpu_evict_gtt_fops, amdgpu_debugfs_evict_gtt,
- - NULL, "%lld\n");
- +static const struct drm_info_list amdgpu_debugfs_list[] = {
- + {"amdgpu_vbios", amdgpu_debugfs_get_vbios_dump},
- + {"amdgpu_test_ib", &amdgpu_debugfs_test_ib},
- + {"amdgpu_evict_vram", &amdgpu_debugfs_evict_vram},
- + {"amdgpu_evict_gtt", &amdgpu_debugfs_evict_gtt},
- + {"amdgpu_vm_info", &amdgpu_debugfs_vm_info},
- +};
- static void amdgpu_ib_preempt_fences_swap(struct amdgpu_ring *ring,
- struct dma_fence **fences)
- @@ -1532,50 +1586,71 @@ static int amdgpu_debugfs_sclk_set(void *data, u64 val)
- return 0;
- }
- -DEFINE_DEBUGFS_ATTRIBUTE(fops_ib_preempt, NULL,
- +DEFINE_SIMPLE_ATTRIBUTE(fops_ib_preempt, NULL,
- amdgpu_debugfs_ib_preempt, "%llu\n");
- -DEFINE_DEBUGFS_ATTRIBUTE(fops_sclk_set, NULL,
- +DEFINE_SIMPLE_ATTRIBUTE(fops_sclk_set, NULL,
- amdgpu_debugfs_sclk_set, "%llu\n");
- int amdgpu_debugfs_init(struct amdgpu_device *adev)
- {
- - struct dentry *root = adev_to_drm(adev)->primary->debugfs_root;
- - struct dentry *ent;
- int r, i;
- -
- -
- - ent = debugfs_create_file("amdgpu_preempt_ib", 0600, root, adev,
- - &fops_ib_preempt);
- - if (!ent) {
- + adev->debugfs_preempt =
- + debugfs_create_file("amdgpu_preempt_ib", 0600,
- + adev_to_drm(adev)->primary->debugfs_root, adev,
- + &fops_ib_preempt);
- + if (!(adev->debugfs_preempt)) {
- DRM_ERROR("unable to create amdgpu_preempt_ib debugsfs file\n");
- return -EIO;
- }
- - ent = debugfs_create_file("amdgpu_force_sclk", 0200, root, adev,
- - &fops_sclk_set);
- - if (!ent) {
- + adev->smu.debugfs_sclk =
- + debugfs_create_file("amdgpu_force_sclk", 0200,
- + adev_to_drm(adev)->primary->debugfs_root, adev,
- + &fops_sclk_set);
- + if (!(adev->smu.debugfs_sclk)) {
- DRM_ERROR("unable to create amdgpu_set_sclk debugsfs file\n");
- return -EIO;
- }
- /* Register debugfs entries for amdgpu_ttm */
- - amdgpu_ttm_debugfs_init(adev);
- - amdgpu_debugfs_pm_init(adev);
- - amdgpu_debugfs_sa_init(adev);
- - amdgpu_debugfs_fence_init(adev);
- - amdgpu_debugfs_gem_init(adev);
- + r = amdgpu_ttm_debugfs_init(adev);
- + if (r) {
- + DRM_ERROR("Failed to init debugfs\n");
- + return r;
- + }
- +
- + r = amdgpu_debugfs_pm_init(adev);
- + if (r) {
- + DRM_ERROR("Failed to register debugfs file for dpm!\n");
- + return r;
- + }
- +
- + if (amdgpu_debugfs_sa_init(adev)) {
- + dev_err(adev->dev, "failed to register debugfs file for SA\n");
- + }
- +
- + if (amdgpu_debugfs_fence_init(adev))
- + dev_err(adev->dev, "fence debugfs file creation failed\n");
- +
- + r = amdgpu_debugfs_gem_init(adev);
- + if (r)
- + DRM_ERROR("registering gem debugfs failed (%d).\n", r);
- r = amdgpu_debugfs_regs_init(adev);
- if (r)
- DRM_ERROR("registering register debugfs failed (%d).\n", r);
- - amdgpu_debugfs_firmware_init(adev);
- + r = amdgpu_debugfs_firmware_init(adev);
- + if (r)
- + DRM_ERROR("registering firmware debugfs failed (%d).\n", r);
- #if defined(CONFIG_DRM_AMD_DC)
- - if (amdgpu_device_has_dc_support(adev))
- - dtn_debugfs_init(adev);
- + if (amdgpu_device_has_dc_support(adev)) {
- + if (dtn_debugfs_init(adev))
- + DRM_ERROR("amdgpu: failed initialize dtn debugfs support.\n");
- + }
- #endif
- for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
- @@ -1590,26 +1665,17 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)
- }
- amdgpu_ras_debugfs_create_all(adev);
- +
- amdgpu_debugfs_autodump_init(adev);
- +
- amdgpu_rap_debugfs_init(adev);
- - amdgpu_securedisplay_debugfs_init(adev);
- - amdgpu_fw_attestation_debugfs_init(adev);
- - debugfs_create_file("amdgpu_evict_vram", 0444, root, adev,
- - &amdgpu_evict_vram_fops);
- - debugfs_create_file("amdgpu_evict_gtt", 0444, root, adev,
- - &amdgpu_evict_gtt_fops);
- - debugfs_create_file("amdgpu_test_ib", 0444, root, adev,
- - &amdgpu_debugfs_test_ib_fops);
- - debugfs_create_file("amdgpu_vm_info", 0444, root, adev,
- - &amdgpu_debugfs_vm_info_fops);
- + amdgpu_securedisplay_debugfs_init(adev);
- - adev->debugfs_vbios_blob.data = adev->bios;
- - adev->debugfs_vbios_blob.size = adev->bios_size;
- - debugfs_create_blob("amdgpu_vbios", 0444, root,
- - &adev->debugfs_vbios_blob);
- + amdgpu_fw_attestation_debugfs_init(adev);
- - return 0;
- + return amdgpu_debugfs_add_files(adev, amdgpu_debugfs_list,
- + ARRAY_SIZE(amdgpu_debugfs_list));
- }
- #else
- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.h
- index 141a8474e24f..2803884d338d 100644
- --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.h
- +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.h
- @@ -26,6 +26,11 @@
- /*
- * Debugfs
- */
- +struct amdgpu_debugfs {
- + const struct drm_info_list *files;
- + unsigned num_files;
- +};
- +
- struct amdgpu_autodump {
- struct completion dumping;
- struct wait_queue_head gpu_hang;
- @@ -34,7 +39,10 @@ struct amdgpu_autodump {
- int amdgpu_debugfs_regs_init(struct amdgpu_device *adev);
- int amdgpu_debugfs_init(struct amdgpu_device *adev);
- void amdgpu_debugfs_fini(struct amdgpu_device *adev);
- -void amdgpu_debugfs_fence_init(struct amdgpu_device *adev);
- -void amdgpu_debugfs_firmware_init(struct amdgpu_device *adev);
- -void amdgpu_debugfs_gem_init(struct amdgpu_device *adev);
- +int amdgpu_debugfs_add_files(struct amdgpu_device *adev,
- + const struct drm_info_list *files,
- + unsigned nfiles);
- +int amdgpu_debugfs_fence_init(struct amdgpu_device *adev);
- +int amdgpu_debugfs_firmware_init(struct amdgpu_device *adev);
- +int amdgpu_debugfs_gem_init(struct amdgpu_device *adev);
- int amdgpu_debugfs_wait_dump(struct amdgpu_device *adev);
- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
- index 47ea46859618..669cc67409d2 100644
- --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
- +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
- @@ -36,6 +36,8 @@
- #include <linux/firmware.h>
- #include <linux/pm_runtime.h>
- +#include <drm/drm_debugfs.h>
- +
- #include "amdgpu.h"
- #include "amdgpu_trace.h"
- @@ -698,9 +700,11 @@ static const struct dma_fence_ops amdgpu_fence_ops = {
- * Fence debugfs
- */
- #if defined(CONFIG_DEBUG_FS)
- -static int amdgpu_debugfs_fence_info_show(struct seq_file *m, void *unused)
- +static int amdgpu_debugfs_fence_info(struct seq_file *m, void *data)
- {
- - struct amdgpu_device *adev = (struct amdgpu_device *)m->private;
- + struct drm_info_node *node = (struct drm_info_node *)m->private;
- + struct drm_device *dev = node->minor->dev;
- + struct amdgpu_device *adev = drm_to_adev(dev);
- int i;
- for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
- @@ -745,10 +749,11 @@ static int amdgpu_debugfs_fence_info_show(struct seq_file *m, void *unused)
- *
- * Manually trigger a gpu reset at the next fence wait.
- */
- -static int gpu_recover_get(void *data, u64 *val)
- +static int amdgpu_debugfs_gpu_recover(struct seq_file *m, void *data)
- {
- - struct amdgpu_device *adev = (struct amdgpu_device *)data;
- - struct drm_device *dev = adev_to_drm(adev);
- + struct drm_info_node *node = (struct drm_info_node *) m->private;
- + struct drm_device *dev = node->minor->dev;
- + struct amdgpu_device *adev = drm_to_adev(dev);
- int r;
- r = pm_runtime_get_sync(dev->dev);
- @@ -757,7 +762,8 @@ static int gpu_recover_get(void *data, u64 *val)
- return 0;
- }
- - *val = amdgpu_device_gpu_recover(adev, NULL);
- + seq_printf(m, "gpu recover\n");
- + amdgpu_device_gpu_recover(adev, NULL);
- pm_runtime_mark_last_busy(dev->dev);
- pm_runtime_put_autosuspend(dev->dev);
- @@ -765,24 +771,26 @@ static int gpu_recover_get(void *data, u64 *val)
- return 0;
- }
- -DEFINE_SHOW_ATTRIBUTE(amdgpu_debugfs_fence_info);
- -DEFINE_DEBUGFS_ATTRIBUTE(amdgpu_debugfs_gpu_recover_fops, gpu_recover_get, NULL,
- - "%lld\n");
- +static const struct drm_info_list amdgpu_debugfs_fence_list[] = {
- + {"amdgpu_fence_info", &amdgpu_debugfs_fence_info, 0, NULL},
- + {"amdgpu_gpu_recover", &amdgpu_debugfs_gpu_recover, 0, NULL}
- +};
- +static const struct drm_info_list amdgpu_debugfs_fence_list_sriov[] = {
- + {"amdgpu_fence_info", &amdgpu_debugfs_fence_info, 0, NULL},
- +};
- #endif
- -void amdgpu_debugfs_fence_init(struct amdgpu_device *adev)
- +int amdgpu_debugfs_fence_init(struct amdgpu_device *adev)
- {
- #if defined(CONFIG_DEBUG_FS)
- - struct drm_minor *minor = adev_to_drm(adev)->primary;
- - struct dentry *root = minor->debugfs_root;
- -
- - debugfs_create_file("amdgpu_fence_info", 0444, root, adev,
- - &amdgpu_debugfs_fence_info_fops);
- -
- - if (!amdgpu_sriov_vf(adev))
- - debugfs_create_file("amdgpu_gpu_recover", 0444, root, adev,
- - &amdgpu_debugfs_gpu_recover_fops);
- + if (amdgpu_sriov_vf(adev))
- + return amdgpu_debugfs_add_files(adev, amdgpu_debugfs_fence_list_sriov,
- + ARRAY_SIZE(amdgpu_debugfs_fence_list_sriov));
- + return amdgpu_debugfs_add_files(adev, amdgpu_debugfs_fence_list,
- + ARRAY_SIZE(amdgpu_debugfs_fence_list));
- +#else
- + return 0;
- #endif
- }
- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
- index 311bcdc59eda..d3269b143ce1 100644
- --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
- +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
- @@ -32,6 +32,7 @@
- #include <linux/dma-buf.h>
- #include <drm/amdgpu_drm.h>
- +#include <drm/drm_debugfs.h>
- #include <drm/drm_gem_ttm_helper.h>
- #include "amdgpu.h"
- @@ -858,10 +859,10 @@ int amdgpu_mode_dumb_create(struct drm_file *file_priv,
- }
- #if defined(CONFIG_DEBUG_FS)
- -static int amdgpu_debugfs_gem_info_show(struct seq_file *m, void *unused)
- +static int amdgpu_debugfs_gem_info(struct seq_file *m, void *data)
- {
- - struct amdgpu_device *adev = (struct amdgpu_device *)m->private;
- - struct drm_device *dev = adev_to_drm(adev);
- + struct drm_info_node *node = (struct drm_info_node *)m->private;
- + struct drm_device *dev = node->minor->dev;
- struct drm_file *file;
- int r;
- @@ -899,17 +900,16 @@ static int amdgpu_debugfs_gem_info_show(struct seq_file *m, void *unused)
- return 0;
- }
- -DEFINE_SHOW_ATTRIBUTE(amdgpu_debugfs_gem_info);
- -
- +static const struct drm_info_list amdgpu_debugfs_gem_list[] = {
- + {"amdgpu_gem_info", &amdgpu_debugfs_gem_info, 0, NULL},
- +};
- #endif
- -void amdgpu_debugfs_gem_init(struct amdgpu_device *adev)
- +int amdgpu_debugfs_gem_init(struct amdgpu_device *adev)
- {
- #if defined(CONFIG_DEBUG_FS)
- - struct drm_minor *minor = adev_to_drm(adev)->primary;
- - struct dentry *root = minor->debugfs_root;
- -
- - debugfs_create_file("amdgpu_gem_info", 0444, root, adev,
- - &amdgpu_debugfs_gem_info_fops);
- + return amdgpu_debugfs_add_files(adev, amdgpu_debugfs_gem_list,
- + ARRAY_SIZE(amdgpu_debugfs_gem_list));
- #endif
- + return 0;
- }
- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
- index 98906a43fda3..7892958d5f59 100644
- --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
- +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
- @@ -30,6 +30,7 @@
- #include <linux/slab.h>
- #include <drm/amdgpu_drm.h>
- +#include <drm/drm_debugfs.h>
- #include "amdgpu.h"
- #include "atom.h"
- @@ -445,9 +446,11 @@ int amdgpu_ib_ring_tests(struct amdgpu_device *adev)
- */
- #if defined(CONFIG_DEBUG_FS)
- -static int amdgpu_debugfs_sa_info_show(struct seq_file *m, void *unused)
- +static int amdgpu_debugfs_sa_info(struct seq_file *m, void *data)
- {
- - struct amdgpu_device *adev = (struct amdgpu_device *)m->private;
- + struct drm_info_node *node = (struct drm_info_node *) m->private;
- + struct drm_device *dev = node->minor->dev;
- + struct amdgpu_device *adev = drm_to_adev(dev);
- seq_printf(m, "--------------------- DELAYED --------------------- \n");
- amdgpu_sa_bo_dump_debug_info(&adev->ib_pools[AMDGPU_IB_POOL_DELAYED],
- @@ -461,18 +464,18 @@ static int amdgpu_debugfs_sa_info_show(struct seq_file *m, void *unused)
- return 0;
- }
- -DEFINE_SHOW_ATTRIBUTE(amdgpu_debugfs_sa_info);
- +static const struct drm_info_list amdgpu_debugfs_sa_list[] = {
- + {"amdgpu_sa_info", &amdgpu_debugfs_sa_info, 0, NULL},
- +};
- #endif
- -void amdgpu_debugfs_sa_init(struct amdgpu_device *adev)
- +int amdgpu_debugfs_sa_init(struct amdgpu_device *adev)
- {
- #if defined(CONFIG_DEBUG_FS)
- - struct drm_minor *minor = adev_to_drm(adev)->primary;
- - struct dentry *root = minor->debugfs_root;
- -
- - debugfs_create_file("amdgpu_sa_info", 0444, root, adev,
- - &amdgpu_debugfs_sa_info_fops);
- -
- + return amdgpu_debugfs_add_files(adev, amdgpu_debugfs_sa_list,
- + ARRAY_SIZE(amdgpu_debugfs_sa_list));
- +#else
- + return 0;
- #endif
- }
- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
- index 39ee88d29cca..09fc4244976e 100644
- --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
- +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
- @@ -27,6 +27,7 @@
- */
- #include "amdgpu.h"
- +#include <drm/drm_debugfs.h>
- #include <drm/amdgpu_drm.h>
- #include "amdgpu_uvd.h"
- #include "amdgpu_vce.h"
- @@ -1330,9 +1331,11 @@ void amdgpu_disable_vblank_kms(struct drm_crtc *crtc)
- */
- #if defined(CONFIG_DEBUG_FS)
- -static int amdgpu_debugfs_firmware_info_show(struct seq_file *m, void *unused)
- +static int amdgpu_debugfs_firmware_info(struct seq_file *m, void *data)
- {
- - struct amdgpu_device *adev = (struct amdgpu_device *)m->private;
- + struct drm_info_node *node = (struct drm_info_node *) m->private;
- + struct drm_device *dev = node->minor->dev;
- + struct amdgpu_device *adev = drm_to_adev(dev);
- struct drm_amdgpu_info_firmware fw_info;
- struct drm_amdgpu_query_fw query_fw;
- struct atom_context *ctx = adev->mode_info.atom_context;
- @@ -1532,18 +1535,17 @@ static int amdgpu_debugfs_firmware_info_show(struct seq_file *m, void *unused)
- return 0;
- }
- -DEFINE_SHOW_ATTRIBUTE(amdgpu_debugfs_firmware_info);
- -
- +static const struct drm_info_list amdgpu_firmware_info_list[] = {
- + {"amdgpu_firmware_info", amdgpu_debugfs_firmware_info, 0, NULL},
- +};
- #endif
- -void amdgpu_debugfs_firmware_init(struct amdgpu_device *adev)
- +int amdgpu_debugfs_firmware_init(struct amdgpu_device *adev)
- {
- #if defined(CONFIG_DEBUG_FS)
- - struct drm_minor *minor = adev_to_drm(adev)->primary;
- - struct dentry *root = minor->debugfs_root;
- -
- - debugfs_create_file("amdgpu_firmware_info", 0444, root,
- - adev, &amdgpu_debugfs_firmware_info_fops);
- -
- + return amdgpu_debugfs_add_files(adev, amdgpu_firmware_info_list,
- + ARRAY_SIZE(amdgpu_firmware_info_list));
- +#else
- + return 0;
- #endif
- }
- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
- index 2d1fefbe1e99..68083e6fcc3e 100644
- --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
- +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
- @@ -337,7 +337,7 @@ void amdgpu_sa_bo_dump_debug_info(struct amdgpu_sa_manager *sa_manager,
- struct seq_file *m);
- u64 amdgpu_bo_print_info(int id, struct amdgpu_bo *bo, struct seq_file *m);
- #endif
- -void amdgpu_debugfs_sa_init(struct amdgpu_device *adev);
- +int amdgpu_debugfs_sa_init(struct amdgpu_device *adev);
- bool amdgpu_bo_support_uswc(u64 bo_flags);
- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
- index b0d2fc9454ca..f1a7166823bc 100644
- --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
- +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
- @@ -1262,19 +1262,16 @@ static int amdgpu_ras_sysfs_remove_all(struct amdgpu_device *adev)
- *
- */
- /* debugfs begin */
- -static struct dentry *amdgpu_ras_debugfs_create_ctrl_node(struct amdgpu_device *adev)
- +static void amdgpu_ras_debugfs_create_ctrl_node(struct amdgpu_device *adev)
- {
- struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
- - struct dentry *dir;
- struct drm_minor *minor = adev_to_drm(adev)->primary;
- - dir = debugfs_create_dir(RAS_FS_NAME, minor->debugfs_root);
- - debugfs_create_file("ras_ctrl", S_IWUGO | S_IRUGO, dir, adev,
- - &amdgpu_ras_debugfs_ctrl_ops);
- - debugfs_create_file("ras_eeprom_reset", S_IWUGO | S_IRUGO, dir, adev,
- - &amdgpu_ras_debugfs_eeprom_ops);
- - debugfs_create_u32("bad_page_cnt_threshold", 0444, dir,
- - &con->bad_page_cnt_threshold);
- + con->dir = debugfs_create_dir(RAS_FS_NAME, minor->debugfs_root);
- + debugfs_create_file("ras_ctrl", S_IWUGO | S_IRUGO, con->dir,
- + adev, &amdgpu_ras_debugfs_ctrl_ops);
- + debugfs_create_file("ras_eeprom_reset", S_IWUGO | S_IRUGO, con->dir,
- + adev, &amdgpu_ras_debugfs_eeprom_ops);
- /*
- * After one uncorrectable error happens, usually GPU recovery will
- @@ -1284,24 +1283,24 @@ static struct dentry *amdgpu_ras_debugfs_create_ctrl_node(struct amdgpu_device *
- * ERREVENT_ATHUB_INTERRUPT generated. Normal GPU recovery routine
- * will never be called.
- */
- - debugfs_create_bool("auto_reboot", S_IWUGO | S_IRUGO, dir, &con->reboot);
- + debugfs_create_bool("auto_reboot", S_IWUGO | S_IRUGO, con->dir,
- + &con->reboot);
- /*
- * User could set this not to clean up hardware's error count register
- * of RAS IPs during ras recovery.
- */
- - debugfs_create_bool("disable_ras_err_cnt_harvest", 0644, dir,
- - &con->disable_ras_err_cnt_harvest);
- - return dir;
- + debugfs_create_bool("disable_ras_err_cnt_harvest", 0644,
- + con->dir, &con->disable_ras_err_cnt_harvest);
- }
- static void amdgpu_ras_debugfs_create(struct amdgpu_device *adev,
- - struct ras_fs_if *head,
- - struct dentry *dir)
- + struct ras_fs_if *head)
- {
- + struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
- struct ras_manager *obj = amdgpu_ras_find_obj(adev, &head->head);
- - if (!obj || !dir)
- + if (!obj || obj->ent)
- return;
- get_obj(obj);
- @@ -1310,14 +1309,14 @@ static void amdgpu_ras_debugfs_create(struct amdgpu_device *adev,
- head->debugfs_name,
- sizeof(obj->fs_data.debugfs_name));
- - debugfs_create_file(obj->fs_data.debugfs_name, S_IWUGO | S_IRUGO, dir,
- - obj, &amdgpu_ras_debugfs_ops);
- + obj->ent = debugfs_create_file(obj->fs_data.debugfs_name,
- + S_IWUGO | S_IRUGO, con->dir, obj,
- + &amdgpu_ras_debugfs_ops);
- }
- void amdgpu_ras_debugfs_create_all(struct amdgpu_device *adev)
- {
- struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
- - struct dentry *dir;
- struct ras_manager *obj;
- struct ras_fs_if fs_info;
- @@ -1328,7 +1327,7 @@ void amdgpu_ras_debugfs_create_all(struct amdgpu_device *adev)
- if (!IS_ENABLED(CONFIG_DEBUG_FS) || !con)
- return;
- - dir = amdgpu_ras_debugfs_create_ctrl_node(adev);
- + amdgpu_ras_debugfs_create_ctrl_node(adev);
- list_for_each_entry(obj, &con->head, node) {
- if (amdgpu_ras_is_supported(adev, obj->head.block) &&
- @@ -1336,11 +1335,34 @@ void amdgpu_ras_debugfs_create_all(struct amdgpu_device *adev)
- sprintf(fs_info.debugfs_name, "%s_err_inject",
- ras_block_str(obj->head.block));
- fs_info.head = obj->head;
- - amdgpu_ras_debugfs_create(adev, &fs_info, dir);
- + amdgpu_ras_debugfs_create(adev, &fs_info);
- }
- }
- }
- +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 */
- /* ras fs */
- @@ -1387,17 +1409,8 @@ static int amdgpu_ras_fs_init(struct amdgpu_device *adev)
- static int amdgpu_ras_fs_fini(struct amdgpu_device *adev)
- {
- - struct amdgpu_ras *con = amdgpu_ras_get_context(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);
- - }
- - }
- -
- + if (IS_ENABLED(CONFIG_DEBUG_FS))
- + amdgpu_ras_debugfs_remove_all(adev);
- amdgpu_ras_sysfs_remove_all(adev);
- return 0;
- }
- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h
- index 60df268a0c66..436b7b77fcb7 100644
- --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h
- +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h
- @@ -318,6 +318,8 @@ struct amdgpu_ras {
- uint32_t supported;
- uint32_t features;
- struct list_head head;
- + /* debugfs */
- + struct dentry *dir;
- /* sysfs */
- struct device_attribute features_attr;
- struct bin_attribute badpages_attr;
- @@ -393,6 +395,8 @@ struct ras_manager {
- struct list_head node;
- /* the device */
- struct amdgpu_device *adev;
- + /* debugfs */
- + struct dentry *ent;
- /* sysfs */
- struct device_attribute sysfs_attr;
- int attr_inuse;
- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
- index d5cbc51c5eaa..5245a7f565cd 100644
- --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
- +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
- @@ -47,6 +47,7 @@
- #include <drm/ttm/ttm_bo_driver.h>
- #include <drm/ttm/ttm_placement.h>
- +#include <drm/drm_debugfs.h>
- #include <drm/amdgpu_drm.h>
- #include "amdgpu.h"
- @@ -1615,7 +1616,7 @@ static void amdgpu_ttm_training_data_block_init(struct amdgpu_device *adev)
- (adev->gmc.mc_vram_size - GDDR6_MEM_TRAINING_OFFSET);
- ctx->train_data_size =
- GDDR6_MEM_TRAINING_DATA_SIZE_IN_BYTES;
- -
- +
- DRM_DEBUG("train_data_size:%llx,p2c_train_data_offset:%llx,c2p_train_data_offset:%llx.\n",
- ctx->train_data_size,
- ctx->p2c_train_data_offset,
- @@ -2105,74 +2106,36 @@ int amdgpu_fill_buffer(struct amdgpu_bo *bo,
- #if defined(CONFIG_DEBUG_FS)
- -static int amdgpu_mm_vram_table_show(struct seq_file *m, void *unused)
- +static int amdgpu_mm_dump_table(struct seq_file *m, void *data)
- {
- - struct amdgpu_device *adev = (struct amdgpu_device *)m->private;
- - struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev,
- - TTM_PL_VRAM);
- + struct drm_info_node *node = (struct drm_info_node *)m->private;
- + unsigned ttm_pl = (uintptr_t)node->info_ent->data;
- + struct drm_device *dev = node->minor->dev;
- + struct amdgpu_device *adev = drm_to_adev(dev);
- + struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, ttm_pl);
- struct drm_printer p = drm_seq_file_printer(m);
- man->func->debug(man, &p);
- return 0;
- }
- -static int amdgpu_ttm_page_pool_show(struct seq_file *m, void *unused)
- +static int amdgpu_ttm_pool_debugfs(struct seq_file *m, void *data)
- {
- - struct amdgpu_device *adev = (struct amdgpu_device *)m->private;
- + struct drm_info_node *node = (struct drm_info_node *)m->private;
- + struct drm_device *dev = node->minor->dev;
- + struct amdgpu_device *adev = drm_to_adev(dev);
- return ttm_pool_debugfs(&adev->mman.bdev.pool, m);
- }
- -static int amdgpu_mm_tt_table_show(struct seq_file *m, void *unused)
- -{
- - struct amdgpu_device *adev = (struct amdgpu_device *)m->private;
- - struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev,
- - TTM_PL_TT);
- - struct drm_printer p = drm_seq_file_printer(m);
- -
- - man->func->debug(man, &p);
- - return 0;
- -}
- -
- -static int amdgpu_mm_gds_table_show(struct seq_file *m, void *unused)
- -{
- - struct amdgpu_device *adev = (struct amdgpu_device *)m->private;
- - struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev,
- - AMDGPU_PL_GDS);
- - struct drm_printer p = drm_seq_file_printer(m);
- -
- - man->func->debug(man, &p);
- - return 0;
- -}
- -
- -static int amdgpu_mm_gws_table_show(struct seq_file *m, void *unused)
- -{
- - struct amdgpu_device *adev = (struct amdgpu_device *)m->private;
- - struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev,
- - AMDGPU_PL_GWS);
- - struct drm_printer p = drm_seq_file_printer(m);
- -
- - man->func->debug(man, &p);
- - return 0;
- -}
- -
- -static int amdgpu_mm_oa_table_show(struct seq_file *m, void *unused)
- -{
- - struct amdgpu_device *adev = (struct amdgpu_device *)m->private;
- - struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev,
- - AMDGPU_PL_OA);
- - struct drm_printer p = drm_seq_file_printer(m);
- -
- - man->func->debug(man, &p);
- - return 0;
- -}
- -
- -DEFINE_SHOW_ATTRIBUTE(amdgpu_mm_vram_table);
- -DEFINE_SHOW_ATTRIBUTE(amdgpu_mm_tt_table);
- -DEFINE_SHOW_ATTRIBUTE(amdgpu_mm_gds_table);
- -DEFINE_SHOW_ATTRIBUTE(amdgpu_mm_gws_table);
- -DEFINE_SHOW_ATTRIBUTE(amdgpu_mm_oa_table);
- -DEFINE_SHOW_ATTRIBUTE(amdgpu_ttm_page_pool);
- +static const struct drm_info_list amdgpu_ttm_debugfs_list[] = {
- + {"amdgpu_vram_mm", amdgpu_mm_dump_table, 0, (void *)TTM_PL_VRAM},
- + {"amdgpu_gtt_mm", amdgpu_mm_dump_table, 0, (void *)TTM_PL_TT},
- + {"amdgpu_gds_mm", amdgpu_mm_dump_table, 0, (void *)AMDGPU_PL_GDS},
- + {"amdgpu_gws_mm", amdgpu_mm_dump_table, 0, (void *)AMDGPU_PL_GWS},
- + {"amdgpu_oa_mm", amdgpu_mm_dump_table, 0, (void *)AMDGPU_PL_OA},
- + {"ttm_page_pool", amdgpu_ttm_pool_debugfs, 0, NULL},
- +};
- /*
- * amdgpu_ttm_vram_read - Linear read access to VRAM
- @@ -2374,29 +2337,46 @@ static const struct file_operations amdgpu_ttm_iomem_fops = {
- .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
- -void amdgpu_ttm_debugfs_init(struct amdgpu_device *adev)
- +int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev)
- {
- #if defined(CONFIG_DEBUG_FS)
- + unsigned count;
- +
- struct drm_minor *minor = adev_to_drm(adev)->primary;
- - struct dentry *root = minor->debugfs_root;
- -
- - debugfs_create_file_size("amdgpu_vram", 0444, root, adev,
- - &amdgpu_ttm_vram_fops, adev->gmc.mc_vram_size);
- - debugfs_create_file("amdgpu_iomem", 0444, root, adev,
- - &amdgpu_ttm_iomem_fops);
- - debugfs_create_file("amdgpu_vram_mm", 0444, root, adev,
- - &amdgpu_mm_vram_table_fops);
- - debugfs_create_file("amdgpu_gtt_mm", 0444, root, adev,
- - &amdgpu_mm_tt_table_fops);
- - debugfs_create_file("amdgpu_gds_mm", 0444, root, adev,
- - &amdgpu_mm_gds_table_fops);
- - debugfs_create_file("amdgpu_gws_mm", 0444, root, adev,
- - &amdgpu_mm_gws_table_fops);
- - debugfs_create_file("amdgpu_oa_mm", 0444, root, adev,
- - &amdgpu_mm_oa_table_fops);
- - debugfs_create_file("ttm_page_pool", 0444, root, adev,
- - &amdgpu_ttm_page_pool_fops);
- + struct dentry *ent, *root = minor->debugfs_root;
- +
- + for (count = 0; count < ARRAY_SIZE(ttm_debugfs_entries); count++) {
- + ent = debugfs_create_file(
- + ttm_debugfs_entries[count].name,
- + S_IFREG | S_IRUGO, root,
- + adev,
- + 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->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;
- + }
- +
- + count = ARRAY_SIZE(amdgpu_ttm_debugfs_list);
- + return amdgpu_debugfs_add_files(adev, amdgpu_ttm_debugfs_list, count);
- +#else
- + return 0;
- #endif
- }
- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
- index 9e38475e0f8d..af94527d0e9b 100644
- --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
- +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
- @@ -64,6 +64,10 @@ struct amdgpu_mman {
- bool initialized;
- void __iomem *aper_base_kaddr;
- +#if defined(CONFIG_DEBUG_FS)
- + struct dentry *debugfs_entries[8];
- +#endif
- +
- /* buffer handling */
- const struct amdgpu_buffer_funcs *buffer_funcs;
- struct amdgpu_ring *buffer_funcs_ring;
- @@ -182,6 +186,6 @@ uint64_t amdgpu_ttm_tt_pde_flags(struct ttm_tt *ttm, struct ttm_resource *mem);
- uint64_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct ttm_tt *ttm,
- struct ttm_resource *mem);
- -void amdgpu_ttm_debugfs_init(struct amdgpu_device *adev);
- +int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev);
- #endif
- diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
- index 1b6b15708b96..c6e5f8d0308c 100644
- --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
- +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
- @@ -25,6 +25,8 @@
- #include <linux/uaccess.h>
- +#include <drm/drm_debugfs.h>
- +
- #include "dc.h"
- #include "amdgpu.h"
- #include "amdgpu_dm.h"
- @@ -2925,9 +2927,11 @@ static ssize_t dtn_log_write(
- * As written to display, taking ABM and backlight lut into account.
- * Ranges from 0x0 to 0x10000 (= 100% PWM)
- */
- -static int current_backlight_show(struct seq_file *m, void *unused)
- +static int current_backlight_read(struct seq_file *m, void *data)
- {
- - struct amdgpu_device *adev = (struct amdgpu_device *)m->private;
- + struct drm_info_node *node = (struct drm_info_node *)m->private;
- + struct drm_device *dev = node->minor->dev;
- + struct amdgpu_device *adev = drm_to_adev(dev);
- struct amdgpu_display_manager *dm = &adev->dm;
- unsigned int backlight = dc_link_get_backlight_level(dm->backlight_link);
- @@ -2941,9 +2945,11 @@ static int current_backlight_show(struct seq_file *m, void *unused)
- * As written to display, taking ABM and backlight lut into account.
- * Ranges from 0x0 to 0x10000 (= 100% PWM)
- */
- -static int target_backlight_show(struct seq_file *m, void *unused)
- +static int target_backlight_read(struct seq_file *m, void *data)
- {
- - struct amdgpu_device *adev = (struct amdgpu_device *)m->private;
- + struct drm_info_node *node = (struct drm_info_node *)m->private;
- + struct drm_device *dev = node->minor->dev;
- + struct amdgpu_device *adev = drm_to_adev(dev);
- struct amdgpu_display_manager *dm = &adev->dm;
- unsigned int backlight = dc_link_get_target_backlight_pwm(dm->backlight_link);
- @@ -2952,10 +2958,10 @@ static int target_backlight_show(struct seq_file *m, void *unused)
- return 0;
- }
- -static int mst_topo_show(struct seq_file *m, void *unused)
- +static int mst_topo(struct seq_file *m, void *unused)
- {
- - struct amdgpu_device *adev = (struct amdgpu_device *)m->private;
- - struct drm_device *dev = adev_to_drm(adev);
- + struct drm_info_node *node = (struct drm_info_node *)m->private;
- + struct drm_device *dev = node->minor->dev;
- struct drm_connector *connector;
- struct drm_connector_list_iter conn_iter;
- struct amdgpu_dm_connector *aconnector;
- @@ -2979,6 +2985,12 @@ static int mst_topo_show(struct seq_file *m, void *unused)
- return 0;
- }
- +static const struct drm_info_list amdgpu_dm_debugfs_list[] = {
- + {"amdgpu_current_backlight_pwm", ¤t_backlight_read},
- + {"amdgpu_target_backlight_pwm", &target_backlight_read},
- + {"amdgpu_mst_topology", &mst_topo},
- +};
- +
- /*
- * Sets trigger hpd for MST topologies.
- * All connected connectors will be rediscovered and re started as needed if val of 1 is sent.
- @@ -3134,9 +3146,6 @@ static int visual_confirm_get(void *data, u64 *val)
- return 0;
- }
- -DEFINE_SHOW_ATTRIBUTE(current_backlight);
- -DEFINE_SHOW_ATTRIBUTE(target_backlight);
- -DEFINE_SHOW_ATTRIBUTE(mst_topo);
- DEFINE_DEBUGFS_ATTRIBUTE(visual_confirm_fops, visual_confirm_get,
- visual_confirm_set, "%llu\n");
- @@ -3198,7 +3207,7 @@ static int visual_confirm_get(void *data, u64 *val)
- return result;
- }
- -void dtn_debugfs_init(struct amdgpu_device *adev)
- +int dtn_debugfs_init(struct amdgpu_device *adev)
- {
- static const struct file_operations dtn_log_fops = {
- .owner = THIS_MODULE,
- @@ -3214,13 +3223,13 @@ void dtn_debugfs_init(struct amdgpu_device *adev)
- struct drm_minor *minor = adev_to_drm(adev)->primary;
- struct dentry *root = minor->debugfs_root;
- + int ret;
- +
- + ret = amdgpu_debugfs_add_files(adev, amdgpu_dm_debugfs_list,
- + ARRAY_SIZE(amdgpu_dm_debugfs_list));
- + if (ret)
- + return ret;
- - debugfs_create_file("amdgpu_current_backlight_pwm", 0444,
- - root, adev, ¤t_backlight_fops);
- - debugfs_create_file("amdgpu_target_backlight_pwm", 0444,
- - root, adev, &target_backlight_fops);
- - debugfs_create_file("amdgpu_mst_topology", 0444, root,
- - adev, &mst_topo_fops);
- debugfs_create_file("amdgpu_dm_dtn_log", 0644, root, adev,
- &dtn_log_fops);
- @@ -3236,16 +3245,8 @@ void dtn_debugfs_init(struct amdgpu_device *adev)
- debugfs_create_file_unsafe("amdgpu_dm_force_timing_sync", 0644, root,
- adev, &force_timing_sync_ops);
- - debugfs_create_file_unsafe("amdgpu_dm_dmcub_trace_event_en", 0644, root,
- - adev, &dmcub_trace_event_state_fops);
- -
- - debugfs_create_file_unsafe("amdgpu_dm_trigger_hpd_mst", 0644, root,
- - adev, &trigger_hpd_mst_ops);
- -
- debugfs_create_file_unsafe("amdgpu_dm_dcc_en", 0644, root, adev,
- &dcc_en_bits_fops);
- - debugfs_create_file_unsafe("amdgpu_dm_disable_hpd", 0644, root, adev,
- - &disable_hpd_ops);
- -
- + return 0;
- }
- diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.h
- index 3366cb644053..cfe8aa2db5cc 100644
- --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.h
- +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.h
- @@ -30,9 +30,9 @@
- #include "amdgpu_dm.h"
- void connector_debugfs_init(struct amdgpu_dm_connector *connector);
- -void dtn_debugfs_init(struct amdgpu_device *adev);
- #if defined(CONFIG_DRM_AMD_SECURE_DISPLAY)
- void crtc_debugfs_init(struct drm_crtc *crtc);
- #endif
- +int dtn_debugfs_init(struct amdgpu_device *adev);
- #endif
- diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
- index 9a54066ec0af..f1a691b659f4 100644
- --- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
- +++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
- @@ -23,6 +23,8 @@
- * Alex Deucher <[email protected]>
- */
- +#include <drm/drm_debugfs.h>
- +
- #include "amdgpu.h"
- #include "amdgpu_drv.h"
- #include "amdgpu_pm.h"
- @@ -3479,10 +3481,11 @@ static void amdgpu_parse_cg_state(struct seq_file *m, u32 flags)
- (flags & clocks[i].flag) ? "On" : "Off");
- }
- -static int amdgpu_debugfs_pm_info_show(struct seq_file *m, void *unused)
- +static int amdgpu_debugfs_pm_info(struct seq_file *m, void *data)
- {
- - struct amdgpu_device *adev = (struct amdgpu_device *)m->private;
- - struct drm_device *dev = adev_to_drm(adev);
- + struct drm_info_node *node = (struct drm_info_node *) m->private;
- + struct drm_device *dev = node->minor->dev;
- + struct amdgpu_device *adev = drm_to_adev(dev);
- u32 flags = 0;
- int r;
- @@ -3532,18 +3535,16 @@ static int amdgpu_debugfs_pm_info_show(struct seq_file *m, void *unused)
- return r;
- }
- -DEFINE_SHOW_ATTRIBUTE(amdgpu_debugfs_pm_info);
- -
- +static const struct drm_info_list amdgpu_pm_info_list[] = {
- + {"amdgpu_pm_info", amdgpu_debugfs_pm_info, 0, NULL},
- +};
- #endif
- -void amdgpu_debugfs_pm_init(struct amdgpu_device *adev)
- +int amdgpu_debugfs_pm_init(struct amdgpu_device *adev)
- {
- #if defined(CONFIG_DEBUG_FS)
- - struct drm_minor *minor = adev_to_drm(adev)->primary;
- - struct dentry *root = minor->debugfs_root;
- -
- - debugfs_create_file("amdgpu_pm_info", 0444, root, adev,
- - &amdgpu_debugfs_pm_info_fops);
- -
- + return amdgpu_debugfs_add_files(adev, amdgpu_pm_info_list, ARRAY_SIZE(amdgpu_pm_info_list));
- +#else
- + return 0;
- #endif
- }
- diff --git a/drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h b/drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h
- index a920515e2274..45a22e101d15 100644
- --- a/drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h
- +++ b/drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h
- @@ -84,6 +84,6 @@ int amdgpu_pm_virt_sysfs_init(struct amdgpu_device *adev);
- void amdgpu_pm_sysfs_fini(struct amdgpu_device *adev);
- void amdgpu_pm_virt_sysfs_fini(struct amdgpu_device *adev);
- -void amdgpu_debugfs_pm_init(struct amdgpu_device *adev);
- +int amdgpu_debugfs_pm_init(struct amdgpu_device *adev);
- #endif
- diff --git a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
- index 8bb224f6c762..c7b5578072fc 100644
- --- a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
- +++ b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
- @@ -444,6 +444,9 @@ struct smu_context
- struct smu_baco_context smu_baco;
- struct smu_temperature_range thermal_range;
- void *od_settings;
- +#if defined(CONFIG_DEBUG_FS)
- + struct dentry *debugfs_sclk;
- +#endif
- struct smu_umd_pstate_table pstate_table;
- uint32_t pstate_sclk;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement