linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Clark <robdclark@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: Daniel Vetter <daniel@ffwll.ch>,
	Rob Clark <robdclark@chromium.org>,
	Jordan Crouse <jcrouse@codeaurora.org>,
	Rob Clark <robdclark@gmail.com>, Sean Paul <sean@poorly.run>,
	David Airlie <airlied@linux.ie>, Eric Anholt <eric@anholt.net>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	AngeloGioacchino Del Regno <kholk11@gmail.com>,
	Emil Velikov <emil.velikov@collabora.com>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Jonathan Marek <jonathan@marek.ca>,
	Akhil P Oommen <akhilpo@codeaurora.org>,
	Sharat Masetty <smasetty@codeaurora.org>,
	linux-arm-msm@vger.kernel.org (open list:DRM DRIVER FOR MSM
	ADRENO GPU),
	freedreno@lists.freedesktop.org (open list:DRM DRIVER FOR MSM
	ADRENO GPU), linux-kernel@vger.kernel.org (open list)
Subject: [PATCH v3 14/23] drm/msm: Document and rename preempt_lock
Date: Mon, 19 Oct 2020 13:46:15 -0700	[thread overview]
Message-ID: <20201019204636.139997-15-robdclark@gmail.com> (raw)
In-Reply-To: <20201019204636.139997-1-robdclark@gmail.com>

From: Rob Clark <robdclark@chromium.org>

Before adding another lock, give ring->lock a more descriptive name.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Jordan Crouse <jcrouse@codeaurora.org>
---
 drivers/gpu/drm/msm/adreno/a5xx_gpu.c     |  4 ++--
 drivers/gpu/drm/msm/adreno/a5xx_preempt.c | 12 ++++++------
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c     |  4 ++--
 drivers/gpu/drm/msm/msm_ringbuffer.c      |  2 +-
 drivers/gpu/drm/msm/msm_ringbuffer.h      |  7 ++++++-
 5 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
index b2593c6bd2ac..2befaf304f04 100644
--- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
@@ -36,7 +36,7 @@ void a5xx_flush(struct msm_gpu *gpu, struct msm_ringbuffer *ring,
 		OUT_RING(ring, upper_32_bits(shadowptr(a5xx_gpu, ring)));
 	}
 
-	spin_lock_irqsave(&ring->lock, flags);
+	spin_lock_irqsave(&ring->preempt_lock, flags);
 
 	/* Copy the shadow to the actual register */
 	ring->cur = ring->next;
@@ -44,7 +44,7 @@ void a5xx_flush(struct msm_gpu *gpu, struct msm_ringbuffer *ring,
 	/* Make sure to wrap wptr if we need to */
 	wptr = get_wptr(ring);
 
-	spin_unlock_irqrestore(&ring->lock, flags);
+	spin_unlock_irqrestore(&ring->preempt_lock, flags);
 
 	/* Make sure everything is posted before making a decision */
 	mb();
diff --git a/drivers/gpu/drm/msm/adreno/a5xx_preempt.c b/drivers/gpu/drm/msm/adreno/a5xx_preempt.c
index 7e04509c4e1f..183de1139eeb 100644
--- a/drivers/gpu/drm/msm/adreno/a5xx_preempt.c
+++ b/drivers/gpu/drm/msm/adreno/a5xx_preempt.c
@@ -45,9 +45,9 @@ static inline void update_wptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring)
 	if (!ring)
 		return;
 
-	spin_lock_irqsave(&ring->lock, flags);
+	spin_lock_irqsave(&ring->preempt_lock, flags);
 	wptr = get_wptr(ring);
-	spin_unlock_irqrestore(&ring->lock, flags);
+	spin_unlock_irqrestore(&ring->preempt_lock, flags);
 
 	gpu_write(gpu, REG_A5XX_CP_RB_WPTR, wptr);
 }
@@ -62,9 +62,9 @@ static struct msm_ringbuffer *get_next_ring(struct msm_gpu *gpu)
 		bool empty;
 		struct msm_ringbuffer *ring = gpu->rb[i];
 
-		spin_lock_irqsave(&ring->lock, flags);
+		spin_lock_irqsave(&ring->preempt_lock, flags);
 		empty = (get_wptr(ring) == ring->memptrs->rptr);
-		spin_unlock_irqrestore(&ring->lock, flags);
+		spin_unlock_irqrestore(&ring->preempt_lock, flags);
 
 		if (!empty)
 			return ring;
@@ -132,9 +132,9 @@ void a5xx_preempt_trigger(struct msm_gpu *gpu)
 	}
 
 	/* Make sure the wptr doesn't update while we're in motion */
-	spin_lock_irqsave(&ring->lock, flags);
+	spin_lock_irqsave(&ring->preempt_lock, flags);
 	a5xx_gpu->preempt[ring->id]->wptr = get_wptr(ring);
-	spin_unlock_irqrestore(&ring->lock, flags);
+	spin_unlock_irqrestore(&ring->preempt_lock, flags);
 
 	/* Set the address of the incoming preemption record */
 	gpu_write64(gpu, REG_A5XX_CP_CONTEXT_SWITCH_RESTORE_ADDR_LO,
diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index 0894703a742e..5dddb9163bd3 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -65,7 +65,7 @@ static void a6xx_flush(struct msm_gpu *gpu, struct msm_ringbuffer *ring)
 		OUT_RING(ring, upper_32_bits(shadowptr(a6xx_gpu, ring)));
 	}
 
-	spin_lock_irqsave(&ring->lock, flags);
+	spin_lock_irqsave(&ring->preempt_lock, flags);
 
 	/* Copy the shadow to the actual register */
 	ring->cur = ring->next;
@@ -73,7 +73,7 @@ static void a6xx_flush(struct msm_gpu *gpu, struct msm_ringbuffer *ring)
 	/* Make sure to wrap wptr if we need to */
 	wptr = get_wptr(ring);
 
-	spin_unlock_irqrestore(&ring->lock, flags);
+	spin_unlock_irqrestore(&ring->preempt_lock, flags);
 
 	/* Make sure everything is posted before making a decision */
 	mb();
diff --git a/drivers/gpu/drm/msm/msm_ringbuffer.c b/drivers/gpu/drm/msm/msm_ringbuffer.c
index 935bf9b1d941..1b6958e908dc 100644
--- a/drivers/gpu/drm/msm/msm_ringbuffer.c
+++ b/drivers/gpu/drm/msm/msm_ringbuffer.c
@@ -46,7 +46,7 @@ struct msm_ringbuffer *msm_ringbuffer_new(struct msm_gpu *gpu, int id,
 	ring->memptrs_iova = memptrs_iova;
 
 	INIT_LIST_HEAD(&ring->submits);
-	spin_lock_init(&ring->lock);
+	spin_lock_init(&ring->preempt_lock);
 
 	snprintf(name, sizeof(name), "gpu-ring-%d", ring->id);
 
diff --git a/drivers/gpu/drm/msm/msm_ringbuffer.h b/drivers/gpu/drm/msm/msm_ringbuffer.h
index 0987d6bf848c..4956d1bc5d0e 100644
--- a/drivers/gpu/drm/msm/msm_ringbuffer.h
+++ b/drivers/gpu/drm/msm/msm_ringbuffer.h
@@ -46,7 +46,12 @@ struct msm_ringbuffer {
 	struct msm_rbmemptrs *memptrs;
 	uint64_t memptrs_iova;
 	struct msm_fence_context *fctx;
-	spinlock_t lock;
+
+	/*
+	 * preempt_lock protects preemption and serializes wptr updates against
+	 * preemption.  Can be aquired from irq context.
+	 */
+	spinlock_t preempt_lock;
 };
 
 struct msm_ringbuffer *msm_ringbuffer_new(struct msm_gpu *gpu, int id,
-- 
2.26.2


  parent reply	other threads:[~2020-10-19 20:46 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-19 20:46 [PATCH v3 00/23] drm/msm: de-struct_mutex-ification Rob Clark
2020-10-19 20:46 ` [PATCH v3 01/23] drm/msm: Fix a couple incorrect usages of get_vaddr_active() Rob Clark
2020-10-19 20:46 ` [PATCH v3 02/23] drm/msm/gem: Add obj->lock wrappers Rob Clark
2020-10-19 20:46 ` [PATCH v3 03/23] drm/msm/gem: Rename internal get_iova_locked helper Rob Clark
2020-10-19 20:46 ` [PATCH v3 04/23] drm/msm/gem: Move prototypes to msm_gem.h Rob Clark
2020-10-19 20:46 ` [PATCH v3 05/23] drm/msm/gem: Add some _locked() helpers Rob Clark
2020-10-19 20:46 ` [PATCH v3 06/23] drm/msm/gem: Move locking in shrinker path Rob Clark
2020-10-23  8:55   ` [Freedreno] " Kristian Høgsberg
2020-10-23 14:46     ` Rob Clark
2020-10-19 20:46 ` [PATCH v3 07/23] drm/msm/submit: Move copy_from_user ahead of locking bos Rob Clark
2020-10-23  9:08   ` [Freedreno] " Kristian Høgsberg
2020-10-19 20:46 ` [PATCH v3 08/23] drm/msm: Do rpm get sooner in the submit path Rob Clark
2020-10-19 20:46 ` [PATCH v3 09/23] drm/msm/gem: Switch over to obj->resv for locking Rob Clark
2020-10-19 20:46 ` [PATCH v3 10/23] drm/msm: Use correct drm_gem_object_put() in fail case Rob Clark
2020-10-19 20:46 ` [PATCH v3 11/23] drm/msm: Drop chatty trace Rob Clark
2020-10-19 20:46 ` [PATCH v3 12/23] drm/msm: Move update_fences() Rob Clark
2020-10-19 20:46 ` [PATCH v3 13/23] drm/msm: Add priv->mm_lock to protect active/inactive lists Rob Clark
2020-10-19 20:46 ` Rob Clark [this message]
2020-10-19 20:46 ` [PATCH v3 15/23] drm/msm: Protect ring->submits with it's own lock Rob Clark
2020-10-19 20:46 ` [PATCH v3 16/23] drm/msm: Refcount submits Rob Clark
2020-10-19 20:46 ` [PATCH v3 17/23] drm/msm: Remove obj->gpu Rob Clark
2020-10-19 20:46 ` [PATCH v3 18/23] drm/msm: Drop struct_mutex from the retire path Rob Clark
2020-10-19 20:46 ` [PATCH v3 19/23] drm/msm: Drop struct_mutex in free_object() path Rob Clark
2020-10-19 20:46 ` [PATCH v3 20/23] drm/msm: Remove msm_gem_free_work Rob Clark
2020-10-19 20:46 ` [PATCH v3 21/23] drm/msm: Drop struct_mutex in madvise path Rob Clark
2020-10-19 20:46 ` [PATCH v3 22/23] drm/msm: Drop struct_mutex in shrinker path Rob Clark
2020-10-19 20:46 ` [PATCH v3 23/23] drm/msm: Don't implicit-sync if only a single ring Rob Clark
2020-10-23 10:58 ` [Freedreno] [PATCH v3 00/23] drm/msm: de-struct_mutex-ification Kristian Høgsberg

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=20201019204636.139997-15-robdclark@gmail.com \
    --to=robdclark@gmail.com \
    --cc=airlied@linux.ie \
    --cc=akhilpo@codeaurora.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emil.velikov@collabora.com \
    --cc=eric@anholt.net \
    --cc=freedreno@lists.freedesktop.org \
    --cc=gustavoars@kernel.org \
    --cc=jcrouse@codeaurora.org \
    --cc=jonathan@marek.ca \
    --cc=kholk11@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robdclark@chromium.org \
    --cc=sean@poorly.run \
    --cc=smasetty@codeaurora.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;
as well as URLs for NNTP newsgroup(s).