[Patch v1 3/5] drm/amdkfd: Introduce debugfs option to disable baco

Alex Deucher alexdeucher at gmail.com
Tue Jan 28 20:22:54 UTC 2020


On Mon, Jan 27, 2020 at 8:30 PM Rajneesh Bhardwaj
<rajneesh.bhardwaj at amd.com> wrote:
>
> 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.
>

I think we can drop this patch in favor of just using the standard
runtime pm control.  E.g.,
/sys/class/drm/card0/device/power/control

Also, the underlying mechanism may not always be BACO.  E.g., hybrid
laptops use BOCO (d3cold).  So it would be better to make the naming
more generic (e.g., runpm_enable, runpm_status).  This is also kfd
specific.  If we actually do want something like this, I think it
should be at the device level in amdgpu.

Alex

> 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
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx


More information about the amd-gfx mailing list