Commit e850b89f authored by Oded Gabbay's avatar Oded Gabbay
Browse files

habanalabs: prevent CPU soft lockup on Palladium



Unmapping ptes in the device MMU on Palladium can take a long time, which
can cause a kernel BUG of CPU soft lockup.

This patch minimize the chances for this bug by sleeping a little between
unmapping ptes.

Signed-off-by: default avatarOded Gabbay <oded.gabbay@gmail.com>
parent 9336c021
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -1046,11 +1046,18 @@ static int unmap_device_va(struct hl_ctx *ctx, u64 vaddr)

	mutex_lock(&ctx->mmu_lock);

	for (i = 0 ; i < phys_pg_pack->npages ; i++, next_vaddr += page_size)
	for (i = 0 ; i < phys_pg_pack->npages ; i++, next_vaddr += page_size) {
		if (hl_mmu_unmap(ctx, next_vaddr, page_size))
			dev_warn_ratelimited(hdev->dev,
			"unmap failed for vaddr: 0x%llx\n", next_vaddr);

		/* unmapping on Palladium can be really long, so avoid a CPU
		 * soft lockup bug by sleeping a little between unmapping pages
		 */
		if (hdev->pldm)
			usleep_range(500, 1000);
	}

	hdev->asic_funcs->mmu_invalidate_cache(hdev, true);

	mutex_unlock(&ctx->mmu_lock);