[Patch v1 3/5] drm/amdkfd: Introduce debugfs option to disable baco
Rajneesh Bhardwaj
rajneesh.bhardwaj at amd.com
Tue Jan 28 01:29:21 UTC 2020
When BACO is enabled by default, sometimes it can cause additional
trouble to debug KFD issues. This debugfs override allows to temporarily
disable BACO for debug purpose without having to reboot the machine.
However, in some cases one suspend-resume cycle might be needed if
the device is already runtime suspended.
e.g
sudo rtcwake -m < mem or freeze > -s 15
or
by triggering autosuspend event from user space, by doing something
like:
echo 6000 > /sys/bus/pci/devices/0000\:03\:00.0/power/autosuspend_delay_ms
Usage:
echo 0 > /sys/kernel/debug/kfd/enable_baco and run
cat /sys/kernel/debug/kfd/baco_status to verify whether BACO is
enabled or disabled by kfd driver.
It should be noted that while enabling baco again via kfd override, we
must do the following steps:
1. echo 0 > /sys/kernel/debug/kfd/enable_baco
2. sudo rtcwake -m < mem > -s 15
In this case, we need GPU to be fully reset which is done by BIOS. This
is not possible in case of S2idle i.e. freeze so we must use mem for
sleep.
Signed-off-by: Rajneesh Bhardwaj <rajneesh.bhardwaj at amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 1 +
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++
drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c | 27 ++++++++++++++++++++++
3 files changed, 31 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
index 47b0f2957d1f..0fa898d30207 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
@@ -34,6 +34,7 @@
#include "amdgpu_vm.h"
extern uint64_t amdgpu_amdkfd_total_mem_size;
+extern bool kfd_enable_baco;
struct amdgpu_device;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 2c64d2a83d61..d9e5eac182d3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3259,6 +3259,9 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)
return -ENODEV;
}
+ if (!kfd_enable_baco)
+ return -EBUSY;
+
adev = dev->dev_private;
if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c b/drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c
index 511712c2e382..c6f6ff2ff603 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c
@@ -26,6 +26,7 @@
#include "kfd_priv.h"
static struct dentry *debugfs_root;
+bool kfd_enable_baco = true;
static int kfd_debugfs_open(struct inode *inode, struct file *file)
{
@@ -83,6 +84,28 @@ static const struct file_operations kfd_debugfs_hang_hws_fops = {
.release = single_release,
};
+static int baco_sts_set(void *data, u64 val)
+{
+ if (!val)
+ kfd_enable_baco = false;
+ else
+ kfd_enable_baco = true;
+
+ return 0;
+}
+DEFINE_SIMPLE_ATTRIBUTE(fops_baco_enable, NULL, baco_sts_set, "%lld\n");
+
+static int baco_sts_show(struct seq_file *s, void *unused)
+{
+ if (kfd_enable_baco)
+ seq_puts(s, "Baco is Enabled\n");
+ else
+ seq_puts(s, "Baco is Disabled\n");
+
+ return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(baco_sts);
+
void kfd_debugfs_init(void)
{
debugfs_root = debugfs_create_dir("kfd", NULL);
@@ -95,6 +118,10 @@ void kfd_debugfs_init(void)
kfd_debugfs_rls_by_device, &kfd_debugfs_fops);
debugfs_create_file("hang_hws", S_IFREG | 0200, debugfs_root,
NULL, &kfd_debugfs_hang_hws_fops);
+ debugfs_create_file("enable_baco", 0644, debugfs_root, NULL,
+ &fops_baco_enable);
+ debugfs_create_file("baco_status", 0444, debugfs_root, NULL,
+ &baco_sts_fops);
}
void kfd_debugfs_fini(void)
--
2.17.1
More information about the amd-gfx
mailing list