AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Pixel Ding <Pixel.Ding-5C7GfCeVMHo@public.gmane.org>
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: pding <Pixel.Ding-5C7GfCeVMHo@public.gmane.org>
Subject: [PATCH 2/2] drm/amdgpu: use irq-safe lock for adev->ring_lru_list_lock
Date: Tue, 7 Nov 2017 15:26:48 +0800	[thread overview]
Message-ID: <1510039608-15811-2-git-send-email-Pixel.Ding@amd.com> (raw)
In-Reply-To: <1510039608-15811-1-git-send-email-Pixel.Ding-5C7GfCeVMHo@public.gmane.org>

From: pding <Pixel.Ding@amd.com>

This lock is used during register accessing in SRIOV guest
since KIQ uses general ring submission (amdgpu_ring_commit).
The register accessing could happen both in irq enabled and
irq disabled cases. Always use irq-safe lock.

Signed-off-by: pding <Pixel.Ding@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
index e5ece1f..d7997b5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
@@ -401,11 +401,12 @@ int amdgpu_ring_lru_get(struct amdgpu_device *adev, int type,
 			bool lru_pipe_order, struct amdgpu_ring **ring)
 {
 	struct amdgpu_ring *entry;
+	unsigned long flags;
 
 	/* List is sorted in LRU order, find first entry corresponding
 	 * to the desired HW IP */
 	*ring = NULL;
-	spin_lock(&adev->ring_lru_list_lock);
+	spin_lock_irqsave(&adev->ring_lru_list_lock, flags);
 	list_for_each_entry(entry, &adev->ring_lru_list, lru_list) {
 		if (entry->funcs->type != type)
 			continue;
@@ -430,7 +431,7 @@ int amdgpu_ring_lru_get(struct amdgpu_device *adev, int type,
 	if (*ring)
 		amdgpu_ring_lru_touch_locked(adev, *ring);
 
-	spin_unlock(&adev->ring_lru_list_lock);
+	spin_unlock_irqrestore(&adev->ring_lru_list_lock, flags);
 
 	if (!*ring) {
 		DRM_ERROR("Ring LRU contains no entries for ring type:%d\n", type);
@@ -450,9 +451,11 @@ int amdgpu_ring_lru_get(struct amdgpu_device *adev, int type,
  */
 void amdgpu_ring_lru_touch(struct amdgpu_device *adev, struct amdgpu_ring *ring)
 {
-	spin_lock(&adev->ring_lru_list_lock);
+	unsigned long flags;
+
+	spin_lock_irqsave(&adev->ring_lru_list_lock, flags);
 	amdgpu_ring_lru_touch_locked(adev, ring);
-	spin_unlock(&adev->ring_lru_list_lock);
+	spin_unlock_irqrestore(&adev->ring_lru_list_lock, flags);
 }
 
 /*
-- 
2.9.5

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

  parent reply	other threads:[~2017-11-07  7:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-07  7:26 [PATCH 1/2] drm/amdgpu: use irq-safe lock for kiq->ring_lock Pixel Ding
     [not found] ` <1510039608-15811-1-git-send-email-Pixel.Ding-5C7GfCeVMHo@public.gmane.org>
2017-11-07  7:26   ` Pixel Ding [this message]
     [not found]     ` <1510039608-15811-2-git-send-email-Pixel.Ding-5C7GfCeVMHo@public.gmane.org>
2017-11-07 10:36       ` [PATCH 2/2] drm/amdgpu: use irq-safe lock for adev->ring_lru_list_lock Christian König
2017-11-07 10:36   ` [PATCH 1/2] drm/amdgpu: use irq-safe lock for kiq->ring_lock Christian König
2017-11-07 12:09   ` Grazvydas Ignotas

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=1510039608-15811-2-git-send-email-Pixel.Ding@amd.com \
    --to=pixel.ding-5c7gfcevmho@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox