All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tom St Denis <tstdenis82-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: Tom St Denis <tom.stdenis-5C7GfCeVMHo@public.gmane.org>
Subject: [PATCH 02/14] drm/amd/amdgpu: add pm lock to debugfs mmio entry
Date: Thu, 28 Jul 2016 10:19:00 -0400	[thread overview]
Message-ID: <20160728141912.18140-3-tom.stdenis@amd.com> (raw)
In-Reply-To: <20160728141912.18140-1-tom.stdenis-5C7GfCeVMHo@public.gmane.org>

Adds support for PM locks around access to registers that might
have race conditions on PG transistions.

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index eab931a58d06..1fe8ef626407 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2335,22 +2335,26 @@ static ssize_t amdgpu_debugfs_regs_read(struct file *f, char __user *buf,
 	struct amdgpu_device *adev = f->f_inode->i_private;
 	ssize_t result = 0;
 	int r;
-	bool use_bank;
+	bool pm_pg_lock, use_bank;
 	unsigned instance_bank, sh_bank, se_bank;
 
 	if (size & 0x3 || *pos & 0x3)
 		return -EINVAL;
 
+	/* are we reading registers for which a PG lock is necessary? */
+	pm_pg_lock = (*pos >> 23) & 1;
+
 	if (*pos & (1ULL << 62)) {
 		se_bank = (*pos >> 24) & 0x3FF;
 		sh_bank = (*pos >> 34) & 0x3FF;
 		instance_bank = (*pos >> 44) & 0x3FF;
 		use_bank = 1;
-		*pos &= 0xFFFFFF;
 	} else {
 		use_bank = 0;
 	}
 
+	*pos &= 0x3FFFF;
+
 	if (use_bank) {
 		if (sh_bank >= adev->gfx.config.max_sh_per_se ||
 		    se_bank >= adev->gfx.config.max_shader_engines)
@@ -2360,6 +2364,9 @@ static ssize_t amdgpu_debugfs_regs_read(struct file *f, char __user *buf,
 					sh_bank, instance_bank);
 	}
 
+	if (pm_pg_lock)
+		mutex_lock(&adev->pm.mutex);
+
 	while (size) {
 		uint32_t value;
 
@@ -2385,6 +2392,9 @@ end:
 		mutex_unlock(&adev->grbm_idx_mutex);
 	}
 
+	if (pm_pg_lock)
+		mutex_unlock(&adev->pm.mutex);
+
 	return result;
 }
 
-- 
2.9.2

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2016-07-28 14:19 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-28 14:18 GFX/UVD/VCE PG (v3) Tom St Denis
     [not found] ` <20160728141912.18140-1-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
2016-07-28 14:18   ` [PATCH 01/14] drm/amd/amdgpu: add mutex locking for both DPM and PP based powergating for UVD/VCE Tom St Denis
2016-07-28 14:19   ` Tom St Denis [this message]
2016-07-28 14:19   ` [PATCH 03/14] drm/amd/amdgpu: don't set clockgating in uvd_v6_0_start() Tom St Denis
2016-07-28 14:19   ` [PATCH 04/14] drm/amd/amdgpu: don't track state in UVD clockgating Tom St Denis
2016-07-28 14:19   ` [PATCH 05/14] drm/amd/amdgpu: enable PG_EN bit in powergating UVD Tom St Denis
2016-07-28 14:19   ` [PATCH 06/14] drm/amd/amdgpu: Add error messages to UVD PG in DPM Tom St Denis
2016-07-28 14:19   ` [PATCH 07/14] drm/amd/powerplay: remove enable_clock_power_gatings_tasks from initialize and resume events Tom St Denis
     [not found]     ` <20160728141912.18140-8-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
2016-07-28 16:53       ` Zhu, Rex
2016-08-08 20:59       ` Eric Huang
2016-07-28 14:19   ` [PATCH 08/14] drm/amd/powerplay: move clockgating to after ungating power in pp for uvd/vce Tom St Denis
2016-07-28 14:19   ` [PATCH 09/14] drm/amd/amdgpu: Enable carrizo GFX PG Tom St Denis
     [not found]     ` <20160728141912.18140-10-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
2016-08-08 17:57       ` Felix Kuehling
     [not found]         ` <4d311362-aad3-13c2-1385-5d4a886d1b35-5C7GfCeVMHo@public.gmane.org>
2016-08-08 17:59           ` StDenis, Tom
     [not found]             ` <DM5PR12MB1132541F79B3643F3EF5B5ADF71B0-2J9CzHegvk+UzrhdoDeimQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2016-08-08 18:03               ` Deucher, Alexander
     [not found]                 ` <MWHPR12MB1694BEBFF3242EFDEA1133DAF71B0-Gy0DoCVfaSW4WA4dJ5YXGAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2016-08-08 18:13                   ` Kuehling, Felix
2016-07-28 14:19   ` [PATCH 10/14] drm/amd/amdgpu: Enable carrizo UVD PG Tom St Denis
2016-07-28 14:19   ` [PATCH 11/14] drm/amd/amdgpu: Enable carrizo VCE PG Tom St Denis
2016-07-28 14:19   ` [PATCH 12/14] drm/amd/amdgpu: Enable stoney GFX PG Tom St Denis
2016-07-28 14:19   ` [PATCH 13/14] drm/amd/amdgpu: Enable stoney UVD PG Tom St Denis
2016-07-28 14:19   ` [PATCH 14/14] drm/amd/amdgpu: Enable stoney VCE PG Tom St Denis
2016-07-28 18:24   ` GFX/UVD/VCE PG (v3) Alex Deucher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160728141912.18140-3-tom.stdenis@amd.com \
    --to=tstdenis82-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=tom.stdenis-5C7GfCeVMHo@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.