From nobody Wed Apr 1 20:39:41 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 411E643CEE6 for ; Wed, 1 Apr 2026 13:49:50 +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=1775051391; cv=none; b=fNPrslAD5eJBCrPkBFKtY1BQWO8s9iceZZYJsCPwt8eoKyTL6eCUqmUT52D+AKnwhi72OZ4rorz98/78v0Msh1k0DB7Tc9YJgxjpPVx+CIYlsF0z36H6S5PIWD9f4BWa9CcjTUxUdDwhPGk9v1TPt3P7fn0+QWg/kXY5l/wBc5A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775051391; c=relaxed/simple; bh=rW46XFPPp2C7fNwBbAzHJuh71JQi/lNqZu/462qrWPQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=S7fD2TL3sz5PNprUuo3fp60b4ReiTjfeTtAT4mv4QrujDF9hD/n1Npqe/vOFWMkqz+iAHOWs7pD9kJnK37SMOCQzMPPsLqFsYvmUGv1fYq7YxvXx/O5obC0WJDiAoNr7FGqMEqinABStdTqNGpBvBQfGVmgKu7RfQXir6JYopts= 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=NDlu8AVO; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=R4qJdY3/; 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="NDlu8AVO"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="R4qJdY3/" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 631DPlDw1894047 for ; Wed, 1 Apr 2026 13:49:49 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=pLcwugmveaGuc3b8rkj7O5 lUNjS3ZVBSKuNHEhcgUvk=; b=NDlu8AVOWqk4EiJzvBAseAYapxJvgtCzCHicbS RFvQJ+mTdVT0ha9L/Q5ZAKggOh0/NA190CWL4/PZ20YZ8f3k4Xq77uAhGQkUcdJW T2SPjhogcNiVOgLDohhiT9UVYnGpllMBlSKW97YOffLqVnldgz6rr92zdCLyhNWo z2xvchnUdpZB7/MNz1PoyiTisNsBqzjexHgh3Go7KnOVG7FbM/9w6lZ5X/M8bcvQ ODNqLdibFXezc/hXhAMyBT/7XQrgcY9Wlf9ZkVxDOH1fzJKkz00aPS1H1vNK2kWB PHM7NmAQ/VAoPZJrmxyeO71235WJL2dhbQLboAwF+KigZQWg== Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4d9483r2kd-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 01 Apr 2026 13:49:49 +0000 (GMT) Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-2b0bf2b3879so217977445ad.1 for ; Wed, 01 Apr 2026 06:49:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1775051389; x=1775656189; 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=pLcwugmveaGuc3b8rkj7O5lUNjS3ZVBSKuNHEhcgUvk=; b=R4qJdY3/SPXUBRI13/lXJuZrEhenLb53gY7eDN5+wILC1T29qnyNCTFXIR/acWWyaO E5ejLKKHCTFvdrb8RRpGLaFYmpK7IPCYxmZN7LugjODeXCJSjqnBleXwT/sysyFOaLyX 4mnpFyu62CwahlA5Ex0wsGGRPjspYu4hk8t+R9qo5cNNurK0GFwSYLQpHrg/HmUbZV+e BeifY9Pt+ElVQ6JxLtNAZfS3eopvddUVB6sCRGN/BtJaVAMF03gqOLJE7tYX5tGpaEAW CJEbVpcgiLAuyYJHvp+xWAgsD6Sm/ROzUJC32An6TWS+bJwk4Zh4mgjtOHIGKp3oN4fm bQdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775051389; x=1775656189; 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=pLcwugmveaGuc3b8rkj7O5lUNjS3ZVBSKuNHEhcgUvk=; b=YFS5K2bFidaQJ+Pv7B7zMppro9Aa8H2pI6ixAzeIYjA5PcBihUw9EI1u10ja9YnFlA bE//qjPk1MrvgtRl6+gnAzoOs5fXkXCwCiVHHNfTu4RJ9Moh/iBB/xQ/h2K2/JItEk8y 3v5fogCDHfTaUg7/6XJt9anXY3UDX34ZVEnH08dMV9TkS24teqXS9psWFfEUlc1Wfn38 +4rF44sRAcCMzxWwchqSDJlhJY8cO+77i4Z7HZ3xAIL63M+gLwWgpG6qnp2NimhUv0fx 5YKL2sKrnn83rvjDue4IC7gWR6fBcvv1LZdo+aTFa3QsIdMAeXckub0N8Ls+WuYsMvYH VrwA== X-Forwarded-Encrypted: i=1; AJvYcCVNzGsW3+StycTsmLem5lMezu44A7zK9QMj/0GhUP6E0rE2J1oYdt4FNXh02eIvg8hPcSZ9Lkl928Z7vdc=@vger.kernel.org X-Gm-Message-State: AOJu0YwxJmC9J7U0dFu+imDwUevhOkSMhR4Ch3McTEbj05oOKAwmnzJ0 mSPS2Qb+lSG1knX8scOmuzaw2T/GJbKBnYFFHSUO9gFd+Mrt+JOkZ+3SvqUOq4YzSbyHj04lcL+ zxKKCWG0wzrUJLvy1/OPWgKzcNo5l6nD0SFtn4JorsLtFvmdlIRUvkbhSLKp+hSVwvn4= X-Gm-Gg: ATEYQzzT3Fv4m0Dkqz8d371sUDiWxFCacCPT62ICIOZ5U4yxlNvpTCdh3ij0y0qbNcL RloOFXKeMkb+Gvf+ySQ6MBGapGIzbakmqG8l2tgTPo+4kNrCeBeC016JJxDRIdrjc0dZomE8Pxe tEdaXodOE/BSsKHJwvP2SS4quFK5ayLFR6ZQj/2Tp6d+uWaiBW2L8aNJWw99BtwIrsvjencqDXE 1NMtS29PAr5y3iuoLtAcme4KH7iXThvKZbJ3KtIQDdDri5pyn3FwYSA4pjOw6nu5domD0t2O1ET SszsyM36B7L0XvYbDiO7DoB/tKix7OS8YkvnSspPha0GFEr8mrbQyGc7EEpOwVixOUYelJqJN2D 3xVgvhH7XVcUczMM6X4KzG0T6c+mYebUC+LQJ0GYHMMeueSGCaNU0lrQ= X-Received: by 2002:a17:903:37cd:b0:2ae:ced7:4650 with SMTP id d9443c01a7336-2b269cffdd9mr36809105ad.24.1775051388543; Wed, 01 Apr 2026 06:49:48 -0700 (PDT) X-Received: by 2002:a17:903:37cd:b0:2ae:ced7:4650 with SMTP id d9443c01a7336-2b269cffdd9mr36808785ad.24.1775051388035; Wed, 01 Apr 2026 06:49:48 -0700 (PDT) Received: from hu-bvisredd-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b242642615sm146649295ad.11.2026.04.01.06.49.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Apr 2026 06:49:47 -0700 (PDT) From: Vishnu Reddy Date: Wed, 01 Apr 2026 19:19:29 +0530 Subject: [PATCH v6] 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: <20260401-update_fps_calculation-v6-1-f44f8154ca39@oss.qualcomm.com> X-B4-Tracking: v=1; b=H4sIAGgizWkC/43QTWrDMBAF4KsYreugf9lZ9R6lhJE0agRJ7Fi2a Qm+e6fOxouadjPwBs3HQw9WcMhY2LF6sAHnXHJ3o2BfKhbOcPvAOkfKTHJpueK6nvoII55SX04 BLmG6wEgnddsguuQMd14wOu4HTPlzhd/en3nA+0T++FwyDwXr0F2veTxWyXCDrWuiAK61hOh9R N0ARtUE3ugYEWy0yH6scy5jN3ytnWexYn/Vm0Utao0IQTkFhuvXrpTDfaIn1OBAY5VnudXMriZ JQ+VNCMELqe2Opjaa3NcUaV5isEYnhzruaPp/miZNKCfp37g1Ke1oZqMpsasZ0iC1wgswCUzzi 7YsyzdhuNpzRwIAAA== 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=1775051384; l=6667; i=busanna.reddy@oss.qualcomm.com; s=20260216; h=from:subject:message-id; bh=rW46XFPPp2C7fNwBbAzHJuh71JQi/lNqZu/462qrWPQ=; b=IZRCfGGxGVZHKaINWSGDHDMoqEA3eR/774HyA9SUmi7R3DGnF9Z/S4OVMbaQ6ryKH2YEiBgRJ pOF0s2//mDlAiv0wPtJ0EMI44b7REUolmoOBdwv4s/QlzFRgdYz7VXY X-Developer-Key: i=busanna.reddy@oss.qualcomm.com; a=ed25519; pk=9vmy9HahBKVAa+GBFj1yHVbz0ey/ucIs1hrlfx+qtok= X-Authority-Analysis: v=2.4 cv=RYydyltv c=1 sm=1 tr=0 ts=69cd227d cx=c_pps a=JL+w9abYAAE89/QcEU+0QA==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=4OJABYYT5sTn56tSQdkA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=324X-CrmTo6CU4MGRt3R:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDAxMDEyOCBTYWx0ZWRfX/mz4tPFWuoft vSZLzwMH6z2QT+dglw5Bfok5h3QwpESfpxkfYjG9A1RjufkN0NSHS1RcMEmj7aSvkgVWgPs2Lq0 cb1vee4zJrA9kVTIB4oqZ7CQQs6R+hLfVfvUhLFOqyDx1dZ6wp9YJ4nFxmynLiR/AoWC0AW23er LQ2I+RY+2tADmtsY2ekwchZV6wYJZAA5uQTXw2pjKNYSN/jAHraXoSlJJIvauInQCy6lxJexC3A wD8vqpZrWmXFBc/8Ah3LIatCfzu4dvnIGyCSshHosfnpJHB79ttglXJ3SGIum6TKWFh2lbH/NR0 h0AXx7BBY4aJCGRHi3eS6eo8Qb/4WwpJgJIEdgP+TOhhsmKIOar1ip+SMhhBA+REUGB7lnJ7JXm bRpj3O8fDPheuyfyL+1aQthe8StKH8xVhOticJHhYNMk3Pt0dU834jSXaDSner1bga6OG5sjnl5 jPCG8tYhGY8SzRamZRQ== X-Proofpoint-ORIG-GUID: DO69G6dhkHdvh1MUycC5ehBiDXNllKww X-Proofpoint-GUID: DO69G6dhkHdvh1MUycC5ehBiDXNllKww 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-04-01_04,2026-04-01_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 clxscore=1015 adultscore=0 bulkscore=0 spamscore=0 phishscore=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2604010128 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 v6: - Updated the vpu2 frequency calculation also to take the actual FPS - Link to v5: https://lore.kernel.org/r/20260331-update_fps_calculation-v5-= 1-af91b1a5fa58@oss.qualcomm.com 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_vpu2.c | 2 +- drivers/media/platform/qcom/iris/iris_vpu_common.c | 6 +++++- 4 files changed, 30 insertions(+), 2 deletions(-) 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_vpu2.c b/drivers/media/p= latform/qcom/iris/iris_vpu2.c index 9c103a2e4e4e..73c201f4f338 100644 --- a/drivers/media/platform/qcom/iris/iris_vpu2.c +++ b/drivers/media/platform/qcom/iris/iris_vpu2.c @@ -18,7 +18,7 @@ static u64 iris_vpu2_calc_freq(struct iris_inst *inst, si= ze_t data_size) struct v4l2_format *inp_f =3D inst->fmt_src; u32 mbs_per_second, mbpf, height, width; unsigned long vpp_freq, vsp_freq; - 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); 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