Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8A3B2D12D56 for ; Wed, 3 Dec 2025 12:18:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5005C10E78B; Wed, 3 Dec 2025 12:18:05 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="OyatpmNW"; dkim-atps=neutral Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1A29210E786 for ; Wed, 3 Dec 2025 12:18:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1764764281; bh=NhHuKZoIZXeIxgIqJ4nrsOnQpdUM7PFLVje1MFRfRlw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OyatpmNWpFd74HCV3wdQ825uSiPJlCG3/JsUtNrcJtkpohPzajCwVrnmVWfVy2EOM 4RNalUQWhBuUinihyiRwm8oCCtoC0Mb/siv3zj01Tv8V5LQCc7n8Srrw+4wiqespS7 QTxrfRXcSMdWpcd8BOLiSswZR4oazZOy1EmzWqrH5HD0w/wY9w1q/l+yxxteHPT2iw FDBofTsZIi5LRl/Q1KPePQ+hCDQt3oPCjQBOQxrLoSKfVzKQGszIABu+DR6WLi0WLW K0Km4JdN4VXx1Gr1QwBz/cC9qUOHdWCsMp0APlH9SgJ9ByMFgYLk2CmDBJS08YUP1Q lW1pKP8oXM5uQ== Received: from fedora (unknown [IPv6:2a01:e0a:2c:6930:a2a7:f53:ebb0:945e]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbrezillon) by bali.collaboradmins.com (Postfix) with ESMTPSA id 6038517E13CD; Wed, 3 Dec 2025 13:18:01 +0100 (CET) From: Boris Brezillon To: Boris Brezillon , Steven Price , Liviu Dudau , =?UTF-8?q?Adri=C3=A1n=20Larumbe?= Cc: dri-devel@lists.freedesktop.org, Akash Goel , Chia-I Wu , kernel@collabora.com Subject: [PATCH v3 3/3] drm/panthor: Unlock the locked region before disabling an AS Date: Wed, 3 Dec 2025 13:17:50 +0100 Message-ID: <20251203121750.404340-4-boris.brezillon@collabora.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251203121750.404340-1-boris.brezillon@collabora.com> References: <20251203121750.404340-1-boris.brezillon@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" An AS can be disabled in the middle of a VM operation (VM being evicted from an AS slot, for instance). In that case, we need the locked section to be unlocked before releasing the slot. v2: - Add an lockdep_assert_held() in panthor_mmu_as_disable() - Collect R-bs v3: - Don't reset the locked_region range in the as_disable() path Fixes: 6e2d3b3e8589 ("drm/panthor: Add support for atomic page table updates") Signed-off-by: Boris Brezillon Reviewed-by: Liviu Dudau Reviewed-by: Chia-I Wu --- drivers/gpu/drm/panthor/panthor_mmu.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c index 3644af1a8e56..ca112d874ecb 100644 --- a/drivers/gpu/drm/panthor/panthor_mmu.c +++ b/drivers/gpu/drm/panthor/panthor_mmu.c @@ -588,14 +588,24 @@ static int panthor_mmu_as_enable(struct panthor_device *ptdev, u32 as_nr, static int panthor_mmu_as_disable(struct panthor_device *ptdev, u32 as_nr, bool recycle_slot) { + struct panthor_vm *vm = ptdev->mmu->as.slots[as_nr].vm; int ret; + lockdep_assert_held(&ptdev->mmu->as.slots_lock); + /* Flush+invalidate RW caches, invalidate RO ones. */ ret = panthor_gpu_flush_caches(ptdev, CACHE_CLEAN | CACHE_INV, CACHE_CLEAN | CACHE_INV, CACHE_INV); if (ret) return ret; + if (vm && vm->locked_region.size) { + /* Unlock the region if there's a lock pending. */ + ret = as_send_cmd_and_wait(ptdev, vm->as.id, AS_COMMAND_UNLOCK); + if (ret) + return ret; + } + /* If the slot is going to be used immediately, don't bother changing * the config. */ -- 2.51.1