From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796380654; b=B8VBZxnz2gDerLQ+aO6SdNzowf7BhNhFbaHarGbSAuNjz+rNDIqWkMNN3EFiYfonkt3G EclDyLI6QDe9ZgpmfsM555W5F0jsvH4iC8KtsLuGCYascdprAr/HRIiN2rz2O7Z+TSXAv OzYYQHyYMCPKdF3VMNQfdFA4f5ITOEOSqqqwZYJm8hkoFkAmP+6wrjZ0PRO8/demI/wsQ 8A/HGkYOwF5IBA4cZZzMlFuleKJcLGKxWlmDA82lZkPfputdtbfsPV7Ovjt2uJ9KoeIv1 wCp/kcDNwDazt9h3Zu8SGZlrCHLev2gkxz5BPaPI8piFe8v0/1RLQHPIOm87LkAstTQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380654; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=qGBKI4qRwVYF6Pj3eRIgN1Kk2MiY1xtpraV2TpcSYNQ=; b=F33TXH9cdTc91g1q+NVwa2GSdO4R4kPVE/p/HqCtYi0VkYZ6zfGAxzewtharlmdVGLiE JqL9BgfaewNnNwheddwUA/3B7r7/9K5YY8mdfFByuNBDOVCOGopxZg3yC9n5leYJ9jpNa Dl3XeYPoYWpNP0qyekZZcBs4flykQy35lWNAQAOLfm9DZexqH+sA+OhJZiaxjbl1zMOoV 487Zf1B55D7PGntvD7JaDW9miqHWy7uZy2YnXT/tJgGi5sayQqHn8kkzCyjQTsIbwX1nX 6FuX+5WNBUhr5g34MY23nGdHSzcbaiEyY4twL4r0pbQLpgjFWpku/NiG3ir7ic5VwTA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b="OI/HK0jA"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B59AA606A681; Fri, 4 Dec 2026 10:37:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=OI/HK0jA Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F15E1F000C2; Fri, 4 Dec 2026 10:37:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380654; bh=qGBKI4qRwVYF6Pj3eRIgN1Kk2MiY1xtpraV2TpcSYNQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OI/HK0jAZIuPKcmbTgdxTJ5D4KeqsTDn3m/vmZSvisZSmYM968fBNlByFKQpBA9Y+ juISKVXbh9ocUKzColrm2OQwH7dW3edYgdkOGMn/A0wSfz4cQqB4U1/aLpcZy+Ybnj vVn63qJcUtv4Pzb6SYQIIyRPVlijkqBZrNuqw6uY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, David Rosca , =?UTF-8?q?Timur=20Krist=C3=B3f?= , Alex Deucher Subject: [PATCH 7.3 369/742] drm/amdgpu/vce1: Fix checking whether VCE1 is idle Date: Fri, 4 Dec 2026 19:03:53 +0900 Message-ID: <20261204100644.890391295@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Timur Kristóf commit 4807d0757c1e8ef8aff6d0e65d99f3820fea9833 upstream. It turns out that the VCE_STATUS register bits that we used to check whether VCE1 is idle are actually not useful: VCE_STATUS.JOB_BUSY doesn't exist until VCE3 VCE_STATUS.UENC_BUSY seems to be stuck high on Cape Verde Instead, do the following: Check that the read and write pointer matches for each ring. Check VCE_STATUS.VCPU_REPORT bits to check busy status. Finally, also check SRBM_STATUS2.VCE_BUSY just in case, although this one seems bogus on VCE1. Fixes: d4a640d4b9f3 ("drm/amdgpu/vce1: Implement VCE1 IP block (v2)") Acked-by: David Rosca Signed-off-by: Timur Kristóf Signed-off-by: David Rosca Signed-off-by: Alex Deucher (cherry picked from commit 0db6125a171f81422736850e3a7fefdf23380073) Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/amdgpu/vce_v1_0.c | 25 +++++++++---- drivers/gpu/drm/amd/include/asic_reg/vce/vce_1_0_sh_mask.h | 2 - 2 files changed, 19 insertions(+), 8 deletions(-) --- a/drivers/gpu/drm/amd/amdgpu/vce_v1_0.c +++ b/drivers/gpu/drm/amd/amdgpu/vce_v1_0.c @@ -47,6 +47,9 @@ #define VCE_V1_0_STACK_SIZE (64 * 1024) #define VCE_V1_0_DATA_SIZE (ALIGN(7808 * (AMDGPU_MAX_VCE_HANDLES + 1), VCE_V1_0_ALIGNMENT)) #define VCE_STATUS_VCPU_REPORT_FW_LOADED_MASK 0x02 +#define VCE_STATUS_VCPU_REPORT_AUTO_BUSY_MASK 0x08 +#define VCE_STATUS_VCPU_REPORT_RB0_BUSY_MASK 0x10 +#define VCE_STATUS_VCPU_REPORT_RB1_BUSY_MASK 0x20 static void vce_v1_0_set_ring_funcs(struct amdgpu_device *adev); static void vce_v1_0_set_irq_funcs(struct amdgpu_device *adev); @@ -349,19 +352,29 @@ static int vce_v1_0_mc_resume(struct amd * * @ip_block: amdgpu_ip_block pointer * - * Check whether VCE is busy according to VCE_STATUS. + * Check whether VCE is busy according to VCE_STATUS + * and whether the ring pointers match. + * * Also check whether the SRBM thinks VCE is busy, although - * SRBM_STATUS.VCE_BUSY seems to be bogus because it + * SRBM_STATUS2.VCE_BUSY seems to be bogus because it * appears to mirror the VCE_STATUS.VCPU_REPORT_FW_LOADED bit. */ static bool vce_v1_0_is_idle(struct amdgpu_ip_block *ip_block) { struct amdgpu_device *adev = ip_block->adev; - bool busy = - (RREG32(mmVCE_STATUS) & (VCE_STATUS__JOB_BUSY_MASK | VCE_STATUS__UENC_BUSY_MASK)) || - (RREG32(mmSRBM_STATUS2) & SRBM_STATUS2__VCE_BUSY_MASK); - return !busy; + /* Check whether the rings are busy. */ + if (RREG32(mmVCE_RB_RPTR) != RREG32(mmVCE_RB_WPTR) || + RREG32(mmVCE_RB_RPTR2) != RREG32(mmVCE_RB_WPTR2)) + return false; + + /* Check whether the VCPU is busy. */ + if (RREG32(mmVCE_STATUS) & (VCE_STATUS_VCPU_REPORT_AUTO_BUSY_MASK | + VCE_STATUS_VCPU_REPORT_RB0_BUSY_MASK | + VCE_STATUS_VCPU_REPORT_RB1_BUSY_MASK)) + return false; + + return !(RREG32(mmSRBM_STATUS2) & SRBM_STATUS2__VCE_BUSY_MASK); } static int vce_v1_0_wait_for_idle(struct amdgpu_ip_block *ip_block) --- a/drivers/gpu/drm/amd/include/asic_reg/vce/vce_1_0_sh_mask.h +++ b/drivers/gpu/drm/amd/include/asic_reg/vce/vce_1_0_sh_mask.h @@ -63,8 +63,6 @@ #define VCE_SOFT_RESET__ECPU_SOFT_RESET__SHIFT 0x00000000 #define VCE_SOFT_RESET__FME_SOFT_RESET_MASK 0x00000004L #define VCE_SOFT_RESET__FME_SOFT_RESET__SHIFT 0x00000002 -#define VCE_STATUS__JOB_BUSY_MASK 0x00000001L -#define VCE_STATUS__JOB_BUSY__SHIFT 0x00000000 #define VCE_STATUS__UENC_BUSY_MASK 0x00000100L #define VCE_STATUS__UENC_BUSY__SHIFT 0x00000008 #define VCE_STATUS__VCPU_REPORT_MASK 0x000000feL