All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
To: dri-devel@lists.freedesktop.org
Cc: oded.gabbay@gmail.com, quic_jhugo@quicinc.com,
	maciej.falkowski@linux.intel.com,
	Andrzej Kacprowski <Andrzej.Kacprowski@intel.com>,
	Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
Subject: [PATCH 1/6] accel/ivpu: Add missing locks around mmu queues
Date: Tue,  4 Feb 2025 09:46:17 +0100	[thread overview]
Message-ID: <20250204084622.2422544-2-jacek.lawrynowicz@linux.intel.com> (raw)
In-Reply-To: <20250204084622.2422544-1-jacek.lawrynowicz@linux.intel.com>

From: Andrzej Kacprowski <Andrzej.Kacprowski@intel.com>

Multiple threads were accessing mmu cmd queue simultaneously
causing sporadic failures in ivpu_mmu_cmdq_sync() function.
Protect critical code with mmu mutex.

Reviewed-by: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
Signed-off-by: Andrzej Kacprowski <Andrzej.Kacprowski@intel.com>
Signed-off-by: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
---
 drivers/accel/ivpu/ivpu_mmu.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/accel/ivpu/ivpu_mmu.c b/drivers/accel/ivpu/ivpu_mmu.c
index b80bdded9fd79..5ea010568faa4 100644
--- a/drivers/accel/ivpu/ivpu_mmu.c
+++ b/drivers/accel/ivpu/ivpu_mmu.c
@@ -895,6 +895,9 @@ static int ivpu_mmu_evtq_disable(struct ivpu_device *vdev)
 
 void ivpu_mmu_discard_events(struct ivpu_device *vdev)
 {
+	struct ivpu_mmu_info *mmu = vdev->mmu;
+
+	mutex_lock(&mmu->lock);
 	/*
 	 * Disable event queue (stop MMU from updating the producer)
 	 * to allow synchronization of consumer and producer indexes
@@ -908,6 +911,8 @@ void ivpu_mmu_discard_events(struct ivpu_device *vdev)
 	ivpu_mmu_evtq_enable(vdev);
 
 	drm_WARN_ON_ONCE(&vdev->drm, vdev->mmu->evtq.cons != vdev->mmu->evtq.prod);
+
+	mutex_unlock(&mmu->lock);
 }
 
 int ivpu_mmu_disable_ssid_events(struct ivpu_device *vdev, u32 ssid)
@@ -920,6 +925,8 @@ int ivpu_mmu_disable_ssid_events(struct ivpu_device *vdev, u32 ssid)
 	if (ssid > IVPU_MMU_CDTAB_ENT_COUNT)
 		return -EINVAL;
 
+	mutex_lock(&mmu->lock);
+
 	entry = cdtab->base + (ssid * IVPU_MMU_CDTAB_ENT_SIZE);
 
 	val = READ_ONCE(entry[0]);
@@ -932,6 +939,8 @@ int ivpu_mmu_disable_ssid_events(struct ivpu_device *vdev, u32 ssid)
 	ivpu_mmu_cmdq_write_cfgi_all(vdev);
 	ivpu_mmu_cmdq_sync(vdev);
 
+	mutex_unlock(&mmu->lock);
+
 	return 0;
 }
 
-- 
2.45.1


  reply	other threads:[~2025-02-04  8:46 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-04  8:46 [PATCH 0/6] accel/ivpu: Changes for 6.15 2025-02-04 Jacek Lawrynowicz
2025-02-04  8:46 ` Jacek Lawrynowicz [this message]
2025-02-14 16:41   ` [PATCH 1/6] accel/ivpu: Add missing locks around mmu queues Jeffrey Hugo
2025-02-17 15:26     ` Jacek Lawrynowicz
2025-02-18 15:52       ` Jeffrey Hugo
2025-02-04  8:46 ` [PATCH 2/6] accel/ivpu: Prevent runtime suspend during context abort work Jacek Lawrynowicz
2025-02-14 16:49   ` Jeffrey Hugo
2025-02-17 15:33     ` Jacek Lawrynowicz
2025-02-18 15:48       ` Jeffrey Hugo
2025-02-04  8:46 ` [PATCH 3/6] accel/ivpu: Add debugfs interface for setting HWS priority bands Jacek Lawrynowicz
2025-02-14 16:51   ` Jeffrey Hugo
2025-02-04  8:46 ` [PATCH 4/6] accel/ivpu: Allow to import single buffer into multiple contexts Jacek Lawrynowicz
2025-02-14 16:53   ` Jeffrey Hugo
2025-02-04  8:46 ` [PATCH 5/6] accel/ivpu: Add test modes to toggle clock relinquish disable Jacek Lawrynowicz
2025-02-14 16:59   ` Jeffrey Hugo
2025-02-04  8:46 ` [PATCH 6/6] accel/ivpu: Implement D0i2 disable test mode Jacek Lawrynowicz
2025-02-14 17:04   ` Jeffrey Hugo
2025-02-17 15:35     ` Jacek Lawrynowicz
2025-02-10  9:48 ` [PATCH 0/6] accel/ivpu: Changes for 6.15 2025-02-04 Jacek Lawrynowicz
2025-02-12 10:20 ` Thomas Zimmermann
2025-02-12 12:59   ` Maxime Ripard
2025-02-12 13:27   ` Jacek Lawrynowicz
2025-02-12 15:52     ` Jeffrey Hugo
2025-02-13 14:17       ` Thomas Zimmermann
2025-02-14 15:47         ` Jeffrey Hugo
2025-02-17 16:53           ` Simona Vetter
2025-02-13 14:06     ` Thomas Zimmermann

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=20250204084622.2422544-2-jacek.lawrynowicz@linux.intel.com \
    --to=jacek.lawrynowicz@linux.intel.com \
    --cc=Andrzej.Kacprowski@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=maciej.falkowski@linux.intel.com \
    --cc=oded.gabbay@gmail.com \
    --cc=quic_jhugo@quicinc.com \
    /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.