From nobody Wed Apr 1 09:46:28 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 ACD2F3E6DD3 for ; Tue, 31 Mar 2026 15:01:35 +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=1774969297; cv=none; b=T+KzxnioGS6wAMTG08ZcXI0DVoeF2XFbH5qV26UEA+cuA37EttGR9SoCVoX4ySnTLW7SgSg3AX2UiW/ugi5Hee1HA5g2aU4PbW9rzgMijjDpdTuZAvZaf/nwb+9821cIAI40WhQwoabpS0mpqZzWkpoXnphBwxP/Xwbrl7yy+jY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774969297; c=relaxed/simple; bh=PlaYA7y1JMu2F/o4KAogbQ82mxmDcO9REeDJEqBJ60o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=ek1e2e+VikFSNZCLPw+Iwj2D4XLX0vEXXBuq6X5G1YpTlKVCZ/jCOeLOv3I33+ePwJx1qUZj28Eq/MAu+WiTEDvcjVrryyQ5kBe6gf58xMiSbOQHAHcTXfRLhyfIDp4fSaJ8IA2KTSRbKh/cgg04DeoR1bRO4v02PdMz+icDSXg= 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=YTzWHCJA; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=TP76M/ic; 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="YTzWHCJA"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="TP76M/ic" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62VE2D4v2761385 for ; Tue, 31 Mar 2026 15:01:35 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=YaIebiXxL5AXXySdpawh0R o3xuctHFlJdv+NGpCFUpI=; b=YTzWHCJAfTNNaqEXqR7chz+A+GJtypT9WXG95z XvmS5jRCbHLgnNiG8kLTZKya3EUE+Fn2Hg8A3hqbteQQvy4TzDnEvDdPF7LrMLB7 v/ZDS4rQca+PVCY1vQRe0fVeZQfLG9t4Hn8NSTMyKEHtXZp4rZpYHBtPL9u8mV9/ mV0LoNZ6z33I8DX+Re+u32BqupaD5r1ZwMJPRXbzps2ZpzUn4moATxZ4A8AvUxtT RMLisNWyVNK6ndLbEPHZliFX7Smvl4oym1X2pIGgt4IjkbkZYDQJ3sMvCAXpGC7q m7CL6aBAcn53X/Nl8U45i66aTsvam+rZts7lPgKMFiXQKKLA== Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4d8b931m6c-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 31 Mar 2026 15:01:33 +0000 (GMT) Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-c76b06f37a7so500596a12.0 for ; Tue, 31 Mar 2026 08:01:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1774969292; x=1775574092; 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=YaIebiXxL5AXXySdpawh0Ro3xuctHFlJdv+NGpCFUpI=; b=TP76M/ic0bsiG6j4+IcCODbWXlF8+HL49cIyDAi+znhpdA6UIkin6clTAgAvRA7gZf 3n1xhYMkSQgzImBOTuNrhWQCDRnI5uw5LWCZUACVrdD/df8hqtAY8h4FX1JvTpphDbWd LwKu3t6Zb3dm+zkITTRUI2zpRbYimRNvjQfwkeCO8z2lL86SS6at/uaqFnUiDI7d/bun 3E6hjo9FRc9u935q5J/5WQdHS5Eddc8RzAkmK1xvUbpS0PONcozaPWi9v4gIfucSINyW 8rM+evTsd4n/m0gL9gBukMFBBOJgxNDv1Z0y0SmLlDVdMQDPDOwvhAO00TK3hu8pESx8 J+cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774969292; x=1775574092; 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=YaIebiXxL5AXXySdpawh0Ro3xuctHFlJdv+NGpCFUpI=; b=kdgNINdeg9J7Fv9bWP5bDP9FoeC1j8DVmXve7CooKq4ugHJDAeP3Jdw4iDeUunrWp0 jNN7CMHTByV+kDaWftHsjWjlaSJYphW78S39815EIeKYgi7avMzqMwlRYzUhxuYStkgj GPKA6sXTSQx/5dscbPHE1hf6ZNy6uZ+gux0T7rBkLTh9LLAeCGAtqpUWxN3YFRlJ5kag TiO/XjLQHegQR4Xz9XsHrvUtY6ZOhVkDE7bcKP9V8S9t7pFLl9KX8lth+x+JcRvEWcOv v6wHEDd9CIzMxuIhXi3TOIrnv4FPWk0b1RcWjdLDUanC+ZXtQob+E/kUKpEkztYzd4SY 9XRQ== X-Forwarded-Encrypted: i=1; AJvYcCU5vMjYkIZ+pQu3KgNkSQTVvGSl5d4SV8xsyPGmW61cu+wncoe8z87JPsjrz2Mw/sVD0FNl5RpelSph8zk=@vger.kernel.org X-Gm-Message-State: AOJu0Yz7rBMlBD9ty9BYWHjyysiwSLaF0kLZOMozl4qoc8WVArfNRK9g 8t4mV8KVhWQYKCRp419W2mNha+6IQ7BN8LwArNMknxQQ8yguOmSz2iATzQAfFlKILwmfiggadIy uDswifToGAP4pG7/4xiXNg0HfOSVd9NCTrszhalAh9Hu04kER86gmKJ2xFN4tbo+2Yc4= X-Gm-Gg: ATEYQzzA3/g+RPwwKAZBFvNjv6xz++/72/2YMYrAjABzVWKRo7SqUWjvG8yzuSBPQU/ LwNnFSvLfFGVLAbeaTBcm7BAfPeaRKI1jBqbn0Bskzqh9K8e1nDMFuLuc6kXc9DKP5Sl0AXntbO HlzvJTlu6zu15LnbJBg7xEyLn/epA6VGsbyjUpsu9hOQI+spOJCRVu5fmAlpNCT7Sm4u/PhcS5/ Xh8CKuROECAMX1IZU/S7/PjrsWEVxIBmCnnSaT6aRlAcunWQZFLxbJsDjiTfw5F0inq4uq0UVAd R4225Z/2L4ZZu8yWjXhtGxVxNgXxi8kK+8RhCKEyDCGfar7QHBe2xzT4zs/t8fWFIIVxWXV+y68 xCQZKt0XrBr8FWrdoqASC1CFWY/bSAU2c3XBwJHrHCD18YGDM/uQ6DmU= X-Received: by 2002:a05:6a00:1c84:b0:82c:e76b:c68c with SMTP id d2e1a72fcca58-82ce86e2e62mr19741b3a.0.1774969292340; Tue, 31 Mar 2026 08:01:32 -0700 (PDT) X-Received: by 2002:a05:6a00:1c84:b0:82c:e76b:c68c with SMTP id d2e1a72fcca58-82ce86e2e62mr19680b3a.0.1774969291605; Tue, 31 Mar 2026 08:01:31 -0700 (PDT) Received: from hu-bvisredd-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82ca8465746sm11517231b3a.21.2026.03.31.08.01.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2026 08:01:31 -0700 (PDT) From: Vishnu Reddy Date: Tue, 31 Mar 2026 20:31:24 +0530 Subject: [PATCH v5] 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: <20260331-update_fps_calculation-v5-1-af91b1a5fa58@oss.qualcomm.com> X-B4-Tracking: v=1; b=H4sIAMThy2kC/43Qy2rDMBAF0F8xWldBj5HkZNX/KCXoMWoESexYt mkJ/vdOnU0WNe1m4A6aw0V3VnEoWNmhubMB51JLd6VgXhoWT/76gbwkykwJZYUWwKc++RGPua/ H6M9xOvuRTvi+RXTZGeGCZHTcD5jL5wq/vT/ygLeJ/PGxZMFX5LG7XMp4aLIRBveuTdILAOVTC Amh9Zh0G0ULKaG3ySL7sU6ljt3wtXae5Yr9VW+WXHJA9FE77Y2A167W3W2iJ9RgR2OVZ/WsmU1 NkYY6mBhjkArshqafNLWtadKCwmgNZIeQNjT4nwakSe0U/ZuwJudftGVZvgGGzDWD+QEAAA== 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=1774969288; l=5758; i=busanna.reddy@oss.qualcomm.com; s=20260216; h=from:subject:message-id; bh=PlaYA7y1JMu2F/o4KAogbQ82mxmDcO9REeDJEqBJ60o=; b=NtV1uRi6hohbLxNtBSv0q0vZj4iz/hZmDOHHKFysNPMWXJf2xF8G/KwW/qk1Y51Dpg+RvjPvA dDoi+0DgfvXBL37BdpJ+TKbqpCFAgk/V7XXBNb5v4LDS+q7CNXV32v1 X-Developer-Key: i=busanna.reddy@oss.qualcomm.com; a=ed25519; pk=9vmy9HahBKVAa+GBFj1yHVbz0ey/ucIs1hrlfx+qtok= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzMxMDE0NiBTYWx0ZWRfXwATrqrjWlaDu bLc5Ofq6EnfqWR3A+mzgbSt7fM/HSZlaNvmXlaaGARhcMxmjjzM+g17eVTt7zWvXm53hNCPFZCF 00uP8mHnHxqsLgQlVXboLbBeru1IRR7XwMIZ1u2ZOdkJn/d4cRcspgPu1fqUKT76IcJUgCQHQ4U nXm9uJq1SdK/qnsEC577bn+lb+/oIJDpUa+7KFlgqlVfvdtba/KoqOCu1y/Z3zBplWUudQetVXU HGCGfjtGtghWeXqIiu0rvlLqCqYTUXEvzcB8cg9AhHK6CfhqKPd2CUd3XrrnBaaBy/L4qQm3SFk P0r1uwxhLJjCh9uGoAu0WEK0Ua1qeH50hY+fyZNxswxqleUYRhFW1NukOmfNVU/oYhtzCC9jwcx NbgN5T2L2wAvYJhHds3dWGu7eTsmeQ== X-Proofpoint-GUID: y4a0c3ijhOaGNvqKzc0rjQFAr4yyAYiT X-Proofpoint-ORIG-GUID: y4a0c3ijhOaGNvqKzc0rjQFAr4yyAYiT X-Authority-Analysis: v=2.4 cv=NLjYOk6g c=1 sm=1 tr=0 ts=69cbe1cd cx=c_pps a=Qgeoaf8Lrialg5Z894R3/Q==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=DJpcGTmdVt4CTyJn9g5Z:22 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=WnfXBAunr1jJH0gWUAIA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=x9snwWr2DeNwDh03kgHS: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-31_03,2026-03-31_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 suspectscore=0 bulkscore=0 lowpriorityscore=0 spamscore=0 phishscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603310146 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. Reviewed-by: Vikash Garodia Signed-off-by: Vishnu Reddy --- Changes in v5: - Added description for defined members in struct iris_inst (Bryan O'Donogh= ue) - Link to v4: https://lore.kernel.org/r/20260325-update_fps_calculation-v4-= 1-13728c0065ff@oss.qualcomm.com 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 | 4 ++++ drivers/media/platform/qcom/iris/iris_vdec.c | 20 ++++++++++++++++++= ++ drivers/media/platform/qcom/iris/iris_vpu_common.c | 6 +++++- 3 files changed, 29 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..63dd889c9992 100644 --- a/drivers/media/platform/qcom/iris/iris_instance.h +++ b/drivers/media/platform/qcom/iris/iris_instance.h @@ -67,6 +67,8 @@ struct iris_fmt { * @metadata_idx: index for metadata buffer * @codec: codec type * @last_buffer_dequeued: a flag to indicate that last buffer is sent by d= river + * @last_buf_ns: start time of received input buffer for current one secon= d FPS window + * @frame_counter: input buffer counter for current one second FPS window * @frame_rate: frame rate of current instance * @operating_rate: operating rate of current instance * @hfi_rc_type: rate control type @@ -109,6 +111,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