All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dawid Osuchowski <dawid.osuchowski@linux.intel.com>
To: dri-devel@lists.freedesktop.org
Cc: oded.gabbay@gmail.com, jeff.hugo@oss.qualcomm.com,
	karol.wachowski@linux.intel.com, lizhi.hou@amd.com,
	andrzej.kacprowski@linux.intel.com,
	dawid.osuchowski@linux.intel.com,
	Jozef Wludzik <jozef.wludzik@linux.intel.com>
Subject: [PATCH 1/3] accel/ivpu: Avoid taking the context lock when unmapping pages
Date: Tue,  1 Dec 2026 16:01:48 +0100	[thread overview]
Message-ID: <20261201150150.653061-2-dawid.osuchowski@linux.intel.com> (raw)
In-Reply-To: <20261201150150.653061-1-dawid.osuchowski@linux.intel.com>

From: Jozef Wludzik <jozef.wludzik@linux.intel.com>

Unmapping a BO only invalidates leaf PTEs in its reserved VA range. The
caller serializes access to that range and keeps the context and VA node
alive until unmapping completes. Intermediate page tables remain
allocated until context teardown.

Remove the context mutex from scatter-gather unmapping and use
WRITE_ONCE() for leaf PTE invalidation. Keep the write barrier and TLB
invalidation, as well as the existing locking for mapping, page-table
allocation and drm_mm updates.

Signed-off-by: Jozef Wludzik <jozef.wludzik@linux.intel.com>
Signed-off-by: Dawid Osuchowski <dawid.osuchowski@linux.intel.com>
---
 drivers/accel/ivpu/ivpu_mmu_context.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/accel/ivpu/ivpu_mmu_context.c b/drivers/accel/ivpu/ivpu_mmu_context.c
index bb3ca81838e3..6429cddf968f 100644
--- a/drivers/accel/ivpu/ivpu_mmu_context.c
+++ b/drivers/accel/ivpu/ivpu_mmu_context.c
@@ -303,7 +303,8 @@ static void ivpu_mmu_context_unmap_page(struct ivpu_mmu_context *ctx, u64 vpu_ad
 	int pte_idx = FIELD_GET(IVPU_MMU_PTE_INDEX_MASK, vpu_addr);
 
 	/* Update PTE with dummy physical address and clear flags */
-	ctx->pgtable.pte_ptrs[pgd_idx][pud_idx][pmd_idx][pte_idx] = IVPU_MMU_ENTRY_INVALID;
+	WRITE_ONCE(ctx->pgtable.pte_ptrs[pgd_idx][pud_idx][pmd_idx][pte_idx],
+		   IVPU_MMU_ENTRY_INVALID);
 }
 
 static int
@@ -523,8 +524,6 @@ ivpu_mmu_context_unmap_sgt(struct ivpu_device *vdev, struct ivpu_mmu_context *ct
 	if (drm_WARN_ON(&vdev->drm, !ctx))
 		return;
 
-	mutex_lock(&ctx->lock);
-
 	for_each_sgtable_dma_sg(sgt, sg, i) {
 		dma_addr_t dma_addr = sg_dma_address(sg) - sg->offset;
 		size_t size = sg_dma_len(sg) + sg->offset;
@@ -539,8 +538,6 @@ ivpu_mmu_context_unmap_sgt(struct ivpu_device *vdev, struct ivpu_mmu_context *ct
 	/* Ensure page table modifications are flushed from wc buffers to memory */
 	wmb();
 
-	mutex_unlock(&ctx->lock);
-
 	ret = ivpu_mmu_invalidate_tlb(vdev, ctx->id);
 	if (ret)
 		ivpu_warn_ratelimited(vdev, "Failed to invalidate TLB for ctx %u: %d\n",
-- 
2.43.0


  reply	other threads:[~2026-12-01 15:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 15:01 [PATCH 0/3] accel/ivpu: Remove ctx->lock on MMU context unmap Dawid Osuchowski
2026-12-01 15:01 ` Dawid Osuchowski [this message]
2026-12-02 13:42   ` [PATCH 1/3] accel/ivpu: Avoid taking the context lock when unmapping pages Andrzej Kacprowski
2026-12-01 15:01 ` [PATCH 2/3] accel/ivpu: Separate VA allocator locking from page-table locking Dawid Osuchowski
2026-12-02 13:43   ` Andrzej Kacprowski
2026-12-01 15:01 ` [PATCH 3/3] accel/ivpu: Shorten bo_list_lock hold time in BO free Dawid Osuchowski
2026-12-02 13:44   ` Andrzej Kacprowski

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=20261201150150.653061-2-dawid.osuchowski@linux.intel.com \
    --to=dawid.osuchowski@linux.intel.com \
    --cc=andrzej.kacprowski@linux.intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jeff.hugo@oss.qualcomm.com \
    --cc=jozef.wludzik@linux.intel.com \
    --cc=karol.wachowski@linux.intel.com \
    --cc=lizhi.hou@amd.com \
    --cc=oded.gabbay@gmail.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.