Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE05337F8A0; Thu, 20 Aug 2026 15:15:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787238958; cv=none; b=hIcyVBfqa9heAbtgn6H3NHSGo2HJIz529UCcv4On9aFK53XJEwoZusCLKJbIu92+OWa3OK8CiuOYqhdRItBSonXysAV3rTe3lk1k4JlDrV47AWsrVpe2i38RfOH8J6ujh95MCDqVfEMGjM++vbBJlPejc3nRkOyllahRlkVFjZ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787238958; c=relaxed/simple; bh=PJWINT4PAxmnSAOpTvEY9UU+OuQQNgohL91Kmd/4Sf8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kQOk7JEWCdVWXpY89R3TyGK+CZy57lXUFj4FprictOd9rUAsxjkFLhdJQGVIYXM+uFLc/b9nhGOPFzUeFQD3JiD2E4BeTO1OgjvZq21rgU9LB8AvEZWfIfipJ+fpqITy2oNsHUZPOvdaTlfTSgHqfXYzAd4jFEHX0boTnatBddk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=zBR0aGYm; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="zBR0aGYm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22CDC1F000E9; Thu, 20 Aug 2026 15:15:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1787238957; bh=25DP2CyB6iErauC8CDEU9IG8/X1al8+6fcH9y+TRMn4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=zBR0aGYm2ilomj36538q0wcYWTNiw/ghSvht83Jr8wud2UmSt/0nz/C7qZJx1EGTK GM6daXLRbN3zQV6lOUrevsH5IDrKA9+gyLtz6joDeWG2tNG/iv/gX9wuXVfcp2sjkd eB3BZZ/FDDOBUmQiWsAQRjSIim0DKPL+oQbBA2d4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, David Rosca , Leo Liu , Ruijing Dong , Alex Deucher Subject: [PATCH 6.18 100/217] drm/amdgpu: Fix UVD dpb min size calculation for H264 Date: Thu, 20 Aug 2026 16:54:28 +0200 Message-ID: <20260820145240.751431607@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260820145237.531699751@linuxfoundation.org> References: <20260820145237.531699751@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Rosca commit 21a8084cd76223a13493237e04d45f5226d7cee6 upstream. This should use actual number of references from the decode message, instead of maximum derived from level. Signed-off-by: David Rosca Acked-by: Leo Liu Reviewed-by: Ruijing Dong Signed-off-by: Alex Deucher (cherry picked from commit 64b525edb7e7bdfcdc77883c5e413804e2396856) Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 62 ++------------------------------ 1 file changed, 4 insertions(+), 58 deletions(-) --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c @@ -645,11 +645,9 @@ static int amdgpu_uvd_cs_msg_decode(stru unsigned int height = msg[7]; unsigned int dpb_size = msg[9]; unsigned int pitch = msg[28]; - unsigned int level = msg[57]; unsigned int width_in_mb = width / 16; unsigned int height_in_mb = ALIGN(height / 16, 2); - unsigned int fs_in_mb = width_in_mb * height_in_mb; unsigned int image_size, tmp, min_dpb_size, num_dpb_buffer; unsigned int min_ctx_size = ~0; @@ -668,35 +666,9 @@ static int amdgpu_uvd_cs_msg_decode(stru switch (stream_type) { case 0: /* H264 */ - switch (level) { - case 30: - num_dpb_buffer = 8100 / fs_in_mb; - break; - case 31: - num_dpb_buffer = 18000 / fs_in_mb; - break; - case 32: - num_dpb_buffer = 20480 / fs_in_mb; - break; - case 41: - num_dpb_buffer = 32768 / fs_in_mb; - break; - case 42: - num_dpb_buffer = 34816 / fs_in_mb; - break; - case 50: - num_dpb_buffer = 110400 / fs_in_mb; - break; - case 51: - num_dpb_buffer = 184320 / fs_in_mb; - break; - default: - num_dpb_buffer = 184320 / fs_in_mb; - break; - } - num_dpb_buffer++; + num_dpb_buffer = ((msg[61] >> 16) & 0xff) + 1; if (num_dpb_buffer > 17) - num_dpb_buffer = 17; + return -EINVAL; /* reference picture buffer */ min_dpb_size = image_size * num_dpb_buffer; @@ -746,35 +718,9 @@ static int amdgpu_uvd_cs_msg_decode(stru break; case 7: /* H264 Perf */ - switch (level) { - case 30: - num_dpb_buffer = 8100 / fs_in_mb; - break; - case 31: - num_dpb_buffer = 18000 / fs_in_mb; - break; - case 32: - num_dpb_buffer = 20480 / fs_in_mb; - break; - case 41: - num_dpb_buffer = 32768 / fs_in_mb; - break; - case 42: - num_dpb_buffer = 34816 / fs_in_mb; - break; - case 50: - num_dpb_buffer = 110400 / fs_in_mb; - break; - case 51: - num_dpb_buffer = 184320 / fs_in_mb; - break; - default: - num_dpb_buffer = 184320 / fs_in_mb; - break; - } - num_dpb_buffer++; + num_dpb_buffer = ((msg[61] >> 16) & 0xff) + 1; if (num_dpb_buffer > 17) - num_dpb_buffer = 17; + return -EINVAL; /* reference picture buffer */ min_dpb_size = image_size * num_dpb_buffer;