From nobody Thu Apr 2 23:55:36 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 791BF3F9F4C for ; Wed, 25 Mar 2026 16:35:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774456535; cv=none; b=Vi7Giq64XABo2lDADpzKrxwYYx2QLdSv77kvofkXwBbOR0r5WnpJCqCFTvrHlD8fyS7Jx0cXsa6YO61TgFDDoFaKZ4Y9SQ/foiwEefu2WX92INr37ZwlPgbYD9SlC/ve76yqXq0thhn8GxJkyJKXWASM6PItLYM/pXJ+5bI8G0U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774456535; c=relaxed/simple; bh=SkM04Tuc1oWoCnquGSiDaEayQNN7DyeQkIktNqEIUTQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=Rww0r2uMAFhF27PTtSvKjltOBc5yvv+kHSWRHXzkQn4AcZmaszekGzwEzFuJCmOqZ0zGLs0o+CZhWdez0c+1dAjWySY8wdsvgJMWLTPy9ao+tryJxDPDjAMCrPbU/7QTRI4iL6Hj1iaVFVncm0puctJvx/U7wDJJVkecmzuL04Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=p3yJKLxi; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=OvBtA//2; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="p3yJKLxi"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="OvBtA//2" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62PFH6S93628131 for ; Wed, 25 Mar 2026 16:35:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=qcppdkim1; bh=Xua7y/qVOt6Psq0DlarnsA 3wXTzgqE7tw4Y/8vH23fo=; b=p3yJKLxiA/cSTk6xgKz2MjDQFDlvlCvxJkxKHf /6odZiRqB4vwQE6HlFRaDdGfeBe5aeA4g0kS4MLI2EVd3uY/xpzdbgLxXg8P9haC MAx68OaglNzMxhDDkhH0alwSLYm9MPSjrLyLbpe+BnePMXu5KEDekSTiy2GJg3b1 OzPqeom0ZOBrlaJ47UwyW8lqGdMUaJNOGyYerqxNPjSOT/7hSSq0gZ87IKOQZ0yT 32dx2IpHL8whwQxbFZFSY0Vq1AYmJmPYB54R9SAO7q/qby26fErGhK2+gygfnU2J 4mX++cJDYzq3JGyjT3Dy3uV96M53OPnIpQz1fCQG31XVvq8A== Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4d4dmpseq7-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 25 Mar 2026 16:35:30 +0000 (GMT) Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-82c63f85c84so29913b3a.2 for ; Wed, 25 Mar 2026 09:35:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1774456530; x=1775061330; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=Xua7y/qVOt6Psq0DlarnsA3wXTzgqE7tw4Y/8vH23fo=; b=OvBtA//2eeThU14R7h7Oz/8BJuO2y7gMuV57JFnGz392kEhAJSo6HljHuApfL7giYU puoOiEifZyx7W6JBQcBpkyOPRq485kdu5Yg9I4+zFel2ZnCoudCkadXxPz9WZr77urr6 obkJG3jAwE+6gMbRrnxnvmP91GP1Kx+IF+nDLB+yAhpd6mIuQFyatvgPmkCYblBx9FJY 14I5ZiXmXcd7dz6VtZ5t4kZC3wt5vNmLYc4x5SmHWj9wyW3EYzirzz22qdSaJw8mvlyS vvzaGlShJTMdWxwImx/MolkqEOLb63Mmtaa2VO9Ij9QcSMDuKSageUmYv58fAalFRrlC Ps5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774456530; x=1775061330; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Xua7y/qVOt6Psq0DlarnsA3wXTzgqE7tw4Y/8vH23fo=; b=CN/CKTPnMZFwQKu5SWfFgCNhs/k40A3U5irnCeLKmQELFv8rKu2tjpcnJjay8Y4SXk VcwRY8trmaNjYo+hSA+sIL0o8H8NR7vFtJgpLI6uodxsWSjvLoVlif11UVFR+ZDi+0Zb DJVuSx7O+Igvz1oJ4e7//WqMyqlWzRRLu4pDLASiuX8wl8wgDCKrUnrJ7PlwFzs3GHDm m51X2WRQEzqTulcytMBVBYowdJ5/KhYGvk2OHH/DLmbgbJCWs4QqYWCRByFFjSjJQHLF 4y/BOY61oppUYg8/NURYyZOQPg7gAcp+gFhd19Bxe3FlWHP08+Nc3m6Ob8uDhNzs7rB5 8wlw== X-Forwarded-Encrypted: i=1; AJvYcCXu1BtEbrdms65qY2jHUe3Y3UFVRU+LV9TdM8Tt7nwKmE5yO8LCOVHHLzMnJOAXqKWKKc9sxx5QCHKvxa8=@vger.kernel.org X-Gm-Message-State: AOJu0YzD/rgdbMssEtPaYzrAQnD5kuvTAHvkuo4X1pY4zJYpS5RVy+6m 3+oDhH8LflXAip0Sv+4cZplKIiYl4g4mT40eSoVDxA1RpEEIhkpKLBeIVlR+Fpve04snuTxwySK enTy6Hq9ECqxr+3IjIq1MP9kg3eM/+3PPB31l2xubnN8ALKyTgHrRR9823Eq9Lj/fAPs= X-Gm-Gg: ATEYQzxAdKv84th9UfAnSQQqbPCBJQH/mjyiad51ep3XhnYPO8md5sg3BsqLsWnvLP8 pRL/FaBBP2Zu3J08Devi35ZYboR6BFc+Ci72t14MuC9smHlIcOJzavF4E9IBwvD47shIVKRpzV0 DuqS2CH4YPhT1oTiJnE5D2QraGV7Iy7h5iZqvni9x27te7OAkEIJCJCmf710SBz7KfWN/dWxSWe HdM8Ny3lJ+70lPvYkXNP4lru2yrInI2Hosx+PpW5wkfc67wah1ev1GS77w6RuIyhL87Gs8fhioc o4v+xChXcdca7xH6ZKtdGjLLJuhIQ+uB8/QQ1cQcUpfWGbmQEXCiwEOZnr4FC/LHdQ5TBeyEwVu JkPq1iFDgvbhnPshZlhZYSF5j31+x6no71uNiRDDbvcqvNepAzrODStQ= X-Received: by 2002:a05:6a00:3cc8:b0:824:18cd:f2f6 with SMTP id d2e1a72fcca58-82c6e0d6eb6mr4130684b3a.59.1774456529556; Wed, 25 Mar 2026 09:35:29 -0700 (PDT) X-Received: by 2002:a05:6a00:3cc8:b0:824:18cd:f2f6 with SMTP id d2e1a72fcca58-82c6e0d6eb6mr4130655b3a.59.1774456529023; Wed, 25 Mar 2026 09:35:29 -0700 (PDT) Received: from hu-bvisredd-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82c7d216a0esm207991b3a.17.2026.03.25.09.35.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Mar 2026 09:35:28 -0700 (PDT) From: Vishnu Reddy Date: Wed, 25 Mar 2026 22:05:11 +0530 Subject: [PATCH v4] media: iris: add FPS calculation and VPP FW overhead in frequency formula Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260325-update_fps_calculation-v4-1-13728c0065ff@oss.qualcomm.com> X-B4-Tracking: v=1; b=H4sIAL4OxGkC/4XOTWrDMBAF4KsYraugn5HkZJV7lBJG0qgRJLFj2 aYl+O5VnU0WNd0MvGHm4z1YoSFTYYfmwQaac8ndrQZ4a1g44+2TeI41MyWUFVoAn/qII51SX04 BL2G64Fhf+L4lcskZ4bxk9bkfKOWvFX7/eOaB7lP1x+eSeSzEQ3e95vHQJCMM7V0bJQoAhdH7S NAiRd0G0UKMhDZaYr/WOZexG77XzrNcsf/qzZJLDkQYtNNoBBy7Unb3qZ7UBrs6VnlWr5rZ1FT VSHsTQvBSgd3Q9IumtjVdNa8oWAPJEcQ/tGVZfgCfmKhdqwEAAA== X-Change-ID: 20260304-update_fps_calculation-98ee7f7507b1 To: Vikash Garodia , Dikshita Agarwal , Abhinav Kumar , Bryan O'Donoghue , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Vishnu Reddy X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774456525; l=4990; i=busanna.reddy@oss.qualcomm.com; s=20260216; h=from:subject:message-id; bh=SkM04Tuc1oWoCnquGSiDaEayQNN7DyeQkIktNqEIUTQ=; b=OPenVd7otuxeRKIhxBkKDzulhSJJJRAd+z7/3z22lVIj1YHgff7g4KPL2bRdarnRCjJRVvZ3N j9FQmgGW9yEDmbLr8bSXbWd2OcktuOabtQwRKsEgdZPXHmaNbnnEZxo X-Developer-Key: i=busanna.reddy@oss.qualcomm.com; a=ed25519; pk=9vmy9HahBKVAa+GBFj1yHVbz0ey/ucIs1hrlfx+qtok= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI1MDEyMCBTYWx0ZWRfX6kaAruJGAqsG e97ZRDtryeuSdgqVBEQfheRlNDpINdEX63qIgCUjU5lk1kqYfaYc/whXOh8zJwESihuv1l9dcR7 qrAK9RV2T51E1B08HvNKc9cpis8JZATLqZaukb4ilnSxtxjCb2RVd2VWQcS7Tb8VyslBfwxvoX8 +w3M3gxziqUNFtbYLxo5z7yJgO4+eAJsV4xFW79yDwYW8aklcgQs+o52uVlSqKx8E8Mmkyuu0bB gNdLZQ6a5BIzLp7pJ1PQUIJHizdenFCRvHJ7KbQNxNVG26C7sNsr/g+nKh2qd2roM2YZ34Cg8Dj qPA7fU6lRh8sdgHIw5QwJ7Tb05EGDgbCY3WbWNtoC873L1VGUsE3YaJ8ZhwltC9iIF7GrQqfLo8 2ZL2yslJP7kuZWpo8u8WSrQITwyTe75QIGbsulegnFOzz/dvUOWr2JhV1ViRaCwiheFptVXqOyt /ZXOJ6OT7mXNw+yDAOg== X-Proofpoint-GUID: ys46eXDjl6N0KOlv3MsidEEkbVOHAp2D X-Proofpoint-ORIG-GUID: ys46eXDjl6N0KOlv3MsidEEkbVOHAp2D X-Authority-Analysis: v=2.4 cv=O7w0fR9W c=1 sm=1 tr=0 ts=69c40ed2 cx=c_pps a=mDZGXZTwRPZaeRUbqKGCBw==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=aZFUA4iBNJJznah6NdIA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=zc0IvFSfCIW2DFIPzwfm:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-25_05,2026-03-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 malwarescore=0 priorityscore=1501 impostorscore=0 bulkscore=0 phishscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603250120 The driver was using a fixed default FPS value when calculating the VPU frequency. This caused wrong frequency requests for high=E2=80=91frame=E2= =80=91rate streams, for example 4K at 240 FPS. Because of this, the hardware was running at a lower frequency than needed. Add the FPS measurement based on the decoder input buffer arrival rate. The measured FPS is stored per instance and used in frequency calculation instead of the fixed default FPS. The value is clamped so that it does not exceed platform limits. Add a VPP firmware overhead when running in STAGE_2. Signed-off-by: Vishnu Reddy Reviewed-by: Vikash Garodia --- Changes in v4: - Renamed the variable names (Vikash Garodia) - Updated the fps calculation logic (Vikash Garodia) - Link to v3: https://lore.kernel.org/r/20260325-update_fps_calculation-v3-= 1-b2ec654f7e4d@oss.qualcomm.com Changes in v3: - Updated the frame_count condition check (Vikash Garodia) - Link to v2: https://lore.kernel.org/r/20260305-update_fps_calculation-v2-= 1-e3b5cccb1246@oss.qualcomm.com Changes in v2: - Replaced div_u64 with mult_frac (Konrad Dybcio) - Link to v1: https://lore.kernel.org/r/20260304-update_fps_calculation-v1-= 1-4eeac373a504@oss.qualcomm.com --- drivers/media/platform/qcom/iris/iris_instance.h | 2 ++ drivers/media/platform/qcom/iris/iris_vdec.c | 20 ++++++++++++++++++= ++ drivers/media/platform/qcom/iris/iris_vpu_common.c | 6 +++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/qcom/iris/iris_instance.h b/drivers/med= ia/platform/qcom/iris/iris_instance.h index 16965150f427..a47cd949645f 100644 --- a/drivers/media/platform/qcom/iris/iris_instance.h +++ b/drivers/media/platform/qcom/iris/iris_instance.h @@ -109,6 +109,8 @@ struct iris_inst { u32 metadata_idx; u32 codec; bool last_buffer_dequeued; + u64 last_buf_ns; + u32 frame_counter; u32 frame_rate; u32 operating_rate; u32 hfi_rc_type; diff --git a/drivers/media/platform/qcom/iris/iris_vdec.c b/drivers/media/p= latform/qcom/iris/iris_vdec.c index 719217399a30..7fb45df37db6 100644 --- a/drivers/media/platform/qcom/iris/iris_vdec.c +++ b/drivers/media/platform/qcom/iris/iris_vdec.c @@ -54,6 +54,7 @@ int iris_vdec_inst_init(struct iris_inst *inst) f->fmt.pix_mp.quantization =3D V4L2_QUANTIZATION_DEFAULT; inst->buffers[BUF_OUTPUT].min_count =3D iris_vpu_buf_count(inst, BUF_OUTP= UT); inst->buffers[BUF_OUTPUT].size =3D f->fmt.pix_mp.plane_fmt[0].sizeimage; + inst->frame_rate =3D MAXIMUM_FPS; =20 memcpy(&inst->fw_caps[0], &core->inst_fw_caps_dec[0], INST_FW_CAP_MAX * sizeof(struct platform_inst_fw_cap)); @@ -369,6 +370,8 @@ int iris_vdec_streamon_input(struct iris_inst *inst) if (ret) return ret; =20 + inst->frame_counter =3D 0; + return iris_process_streamon_input(inst); } =20 @@ -411,6 +414,7 @@ int iris_vdec_qbuf(struct iris_inst *inst, struct vb2_v= 4l2_buffer *vbuf) { struct iris_buffer *buf =3D to_iris_buffer(vbuf); struct vb2_buffer *vb2 =3D &vbuf->vb2_buf; + u64 cur_buf_ns, delta_ns; struct vb2_queue *q; int ret; =20 @@ -427,6 +431,22 @@ int iris_vdec_qbuf(struct iris_inst *inst, struct vb2_= v4l2_buffer *vbuf) return 0; } =20 + if (buf->type =3D=3D BUF_INPUT) { + cur_buf_ns =3D ktime_get_ns(); + + if (!inst->frame_counter) + inst->last_buf_ns =3D cur_buf_ns; + + inst->frame_counter++; + delta_ns =3D cur_buf_ns - inst->last_buf_ns; + + if (delta_ns >=3D NSEC_PER_SEC) { + inst->frame_rate =3D clamp_t(u32, inst->frame_counter, DEFAULT_FPS, + MAXIMUM_FPS); + inst->frame_counter =3D 0; + } + } + iris_scale_power(inst); =20 return iris_queue_buffer(inst, buf); diff --git a/drivers/media/platform/qcom/iris/iris_vpu_common.c b/drivers/m= edia/platform/qcom/iris/iris_vpu_common.c index 548e5f1727fd..d621ccffa868 100644 --- a/drivers/media/platform/qcom/iris/iris_vpu_common.c +++ b/drivers/media/platform/qcom/iris/iris_vpu_common.c @@ -416,7 +416,7 @@ u64 iris_vpu3x_vpu4x_calculate_frequency(struct iris_in= st *inst, size_t data_siz u32 height, width, mbs_per_second, mbpf; u64 fw_cycles, fw_vpp_cycles; u64 vsp_cycles, vpp_cycles; - u32 fps =3D DEFAULT_FPS; + u32 fps =3D inst->frame_rate; =20 width =3D max(inp_f->fmt.pix_mp.width, inst->crop.width); height =3D max(inp_f->fmt.pix_mp.height, inst->crop.height); @@ -435,6 +435,10 @@ u64 iris_vpu3x_vpu4x_calculate_frequency(struct iris_i= nst *inst, size_t data_siz if (inst->fw_caps[PIPE].value > 1) vpp_cycles +=3D div_u64(vpp_cycles * 59, 1000); =20 + /* 1.05 is VPP FW overhead */ + if (inst->fw_caps[STAGE].value =3D=3D STAGE_2) + vpp_cycles +=3D mult_frac(vpp_cycles, 5, 100); + vsp_cycles =3D fps * data_size * 8; vsp_cycles =3D div_u64(vsp_cycles, 2); /* VSP FW overhead 1.05 */ --- base-commit: f505e978d1a0442adbbde48aed38c084ddea6d6e change-id: 20260304-update_fps_calculation-98ee7f7507b1 Best regards, --=20 Vishnu Reddy