From mboxrd@z Thu Jan 1 00:00:00 1970 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 212F21A5B9E for ; Fri, 13 Mar 2026 07:24:54 +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=1773386700; cv=none; b=T+GBaP1/A5Ua/57Tq89K1jOQcm2YM0jm0Aewclfn7M4AfZaaNtPdyyuhbwzn0jFg5kmK0Tosk62TajG4sQPa15swHPySKBcT/Y6NS0PDq5R5AMbpfP+UDpMtI0H9Xk6T2CXtUPOy4VeF/9dVOtF1wn9aOcY5JZIZxQm4mM+YqEc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773386700; c=relaxed/simple; bh=foHRywailjJxzdcOwn3/CZ0hF1meLi8Y4MTuQ6z8S7Q=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=tAf/45iueiYS9nnkh1SahMSMXdCRte/aJS0Qk8yyxKX6fnQXkEJ7ahrq7G8/hCNmvyOeGkkKxnreMNp85aNb8KOTt8+4dheRvT1TlToLRmIpLDOYHVzRPnDoZmZjH8j0R8B4IGhuine/+P3vgMkbvND1olRHzi13ZuYZBYqE5Nc= 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=GpZzOZJ+; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=MNiB5bn1; 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="GpZzOZJ+"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="MNiB5bn1" Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62D5tco04140736 for ; Fri, 13 Mar 2026 07:24:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= DEjQdyHeoqq+29wLeWmNmhHhPSneeKqLUXgDf7wtXFo=; b=GpZzOZJ+8fUwzcK3 Wo2qVcVDIB/ZsEC1wUGtwTnRZUwCiQN08PuP86Nk+U+8671hhVUyf7PlMDK8FCpk q5B+o0Crgjj3AsCX566Z9LjzcSptyac/CS/hQ4Rrp4GvgCHhClsVX26fCr3vzbbM hYKirBSG3Pq91GehnHanHcikLap5jt6B6wAEkySEd03suZSHiSPMtoPFf64+Crf2 vRHcTVGoNlERk2pAu4JY+HoU5hoYknB7dDV5I6H7Psnqfbu3cAjR+fn0krOBN/4j EVnssocus4Fmj/45un2FZpbiwMYkNcLk5NY5jCbtRNAHvLQMvgLtS5V3iEIndEpg C/Cz2w== Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4cvbn28gb5-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 13 Mar 2026 07:24:54 +0000 (GMT) Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-2ae57228f64so19352565ad.0 for ; Fri, 13 Mar 2026 00:24:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1773386694; x=1773991494; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=DEjQdyHeoqq+29wLeWmNmhHhPSneeKqLUXgDf7wtXFo=; b=MNiB5bn1fRwjONARJxf8ougFGN9l4LCsL3mWbZjx+/YRA6/FjLJVg0pFpLltBBH8aH MCAR7GWJz9d96Tuh/rpwZiGFnqYRCYCnze0/JUSM8bH0GbWWhqGJriUUzJOrr3j0SBux 8/5Lsv/HNPexiebDB33KZes2O5pg+IyMrEC35I0jIVzyeaalpRCRgmAQJId77ltZwPJW MUKDsjMQtAqNbYYNUbGYKFbgpmlmSEvVaWbHIEZVAD/0GNObBcKN0+0DhPmEFLxLpvuB EoJEHl2xTLC5hvP8MH1zjPEcw1y9EhRGF/MsQoxbLJB/ALB6ZfMzDM0XwsQ3J4a2sy6G TR7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773386694; x=1773991494; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=DEjQdyHeoqq+29wLeWmNmhHhPSneeKqLUXgDf7wtXFo=; b=V3rQrwxSssBDYVWbCt9ycZwgH9TvHSPhjyudsPn9H6Gn+JgnrhKCflkTrlCyKftZsg jfc/xCOWdDqQTwxGV7XuZe7ptOmMU6NYi5fAgeuxt+S5Gmli7lcFJxMm0/OnbE/IAfSR f6OrnwSKn4iLmSVZ6+6EiYJfa7Q29iJ6LiQkJkzwkSuF+knmmjbbgh3M+xlWHOHeRz1i zVkCWEtdqwI6rA43gjEoto8JdQPEMVwB9MWsCCQdWdkvioYng53T+rZqnXT7dGOTXsx5 /xGdN0PDJ6L6yLDpoVKJXFStXsZu/pHuvw/cIiFpUZbfJVg5PVIRntR2eUx4sbDLgDb5 zd0w== X-Forwarded-Encrypted: i=1; AJvYcCXy+RjdQDGQ224ZVrcOkmz9eOr4jshDFpC7a0mqkkgyrfVL8etiz54pKLMMnwW0R1x9zHwZZZIoZOmCD4I=@vger.kernel.org X-Gm-Message-State: AOJu0YxhG3MmSd/6VpxHmnt8LlIcBSZDinMnP40wgvgyFoIUMnj/WeMM 9YtIoAFGcAE9sEFbMGJUWZFdF8wcig8Yp1PKUPUtJRqWoDKHZWbGneL45v6BGf3WuTU9lxxcacp RzMRC4Fp+Wi3MSyleZv0l/0vYVniBe6PDLVmJ8tgbNM2ZbkyKd9EDBdTWCISRhTHR4IQ= X-Gm-Gg: ATEYQzxb6sXdMECAOB5h1eNEOY5p2LlbDJmYCId3x6S/4Na/bJeTAxd/iMMPCTdtTF4 Rmtz12ARi5zlN2IYvgFk0CD4cOdFzQrXycr426Xx9MHX+q3ZeR3Ea25lJAscXeieotbUaLdPGoM Lg6ZYCN/0qO9o3rcnI7sirVur0SyZgMC5g5KLTy0GCAZ9BUZtnBsxWFfAcn8zJ5I73T5UvE+0yS 8emScnoagbPCNpAGYhJUbedO41w5MkFDi/f9E8KbiKWrkXZrsyBluH9TsMQX7LwuBEb0Qw2nfPU I2vEzJnc7QEj2N2Xs/Ep07j+PUCLsF6yoCwqSZpZR47jYh7r/QjLBvnXatYQbjGdCiQqtom3wxP 6EqhpsNBLKP2N0wZOFLaHkMC7wEK2nZNaeohwI6/hNs1s3TnIb8uUuGjZ X-Received: by 2002:a17:902:f683:b0:2ae:467f:11d8 with SMTP id d9443c01a7336-2aecaa52b09mr22979625ad.30.1773386693494; Fri, 13 Mar 2026 00:24:53 -0700 (PDT) X-Received: by 2002:a17:902:f683:b0:2ae:467f:11d8 with SMTP id d9443c01a7336-2aecaa52b09mr22979405ad.30.1773386693003; Fri, 13 Mar 2026 00:24:53 -0700 (PDT) Received: from [192.168.0.172] ([49.205.254.220]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2aece7ee5f4sm11984755ad.52.2026.03.13.00.24.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 13 Mar 2026 00:24:52 -0700 (PDT) Message-ID: <19e9afa8-b0fa-43e1-8758-b58e6c7a095c@oss.qualcomm.com> Date: Fri, 13 Mar 2026 12:54:47 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] media: iris: add FPS calculation and VPP FW overhead in frequency formula To: Vishnu Reddy , 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 References: <20260305-update_fps_calculation-v2-1-e3b5cccb1246@oss.qualcomm.com> Content-Language: en-US From: Vikash Garodia In-Reply-To: <20260305-update_fps_calculation-v2-1-e3b5cccb1246@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Proofpoint-ORIG-GUID: u4gyrEaQpifPyvnLdqs2TQxZ1t2mSX9J X-Proofpoint-GUID: u4gyrEaQpifPyvnLdqs2TQxZ1t2mSX9J X-Authority-Analysis: v=2.4 cv=ZKfaWH7b c=1 sm=1 tr=0 ts=69b3bbc6 cx=c_pps a=MTSHoo12Qbhz2p7MsH1ifg==:117 a=EbT04XG53EGSLiegdi54Hw==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=eoimf2acIAo5FJnRuUoq:22 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=zq2kz8iOUWQeT6CNkjIA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=GvdueXVYPmCkWapjIL-Q:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzEzMDA1OCBTYWx0ZWRfXxYmlYVG42CnN a5jhzjCPv3asYyctEUvwbafRcqPXjhDH/L3aKbsF7R3M3NzfX409I7EPO3vUeNTAGCrCv1sOw97 Eq7sfkr7pjIqnYFuACNcx5pqrRum76vz+QwMrC60zA66HE8TnrQ5U+R9jZCC9v7YkkTrY4CzEvl UODRDDhhVEflDts0ZbjBalcRZ4dcHdm6OcSpjKqVvFPITFrUHHwOqTRdTBsQnz+tfHRhhPlkkkm SIOVMxr51Q7xi/WSdt/TC2BsJ39cnwUdb4WezBhoh8DpWBGhu+JlQ92FIq5jkO5md2J2WZX6Wsl cjMoM1qjRcBypzpjfjy+eQ0rgn7dfoeW9iNWlfJ+1WaRGg1+nv9z1xBmuHGVzgff06jz24D6rkM 8KVaq69t5jSYkamiE/L2B7Y9SXLUojiC375o3gvOac5a53L89C/dvRqGLIzuHKglvRppiyJ3wPO uj+w3pEvn7y8z4fEO3A== 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-13_01,2026-03-12_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 spamscore=0 malwarescore=0 suspectscore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 priorityscore=1501 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603130058 On 3/5/2026 7:00 PM, Vishnu Reddy wrote: > The driver was using a fixed default FPS value when calculating the VPU > frequency. This caused wrong frequency requests for high‑frame‑rate > 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 > --- > Changes in v2: > - Replaced div_u64 with mult_frac > - 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 | 21 +++++++++++++++++++++ > drivers/media/platform/qcom/iris/iris_vpu_common.c | 6 +++++- > 3 files changed, 28 insertions(+), 1 deletion(-) > > diff --git a/drivers/media/platform/qcom/iris/iris_instance.h b/drivers/media/platform/qcom/iris/iris_instance.h > index 16965150f427..180cba36a7f2 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_recv_time_ns; > + u32 frame_count; > u32 frame_rate; > u32 operating_rate; > u32 hfi_rc_type; > diff --git a/drivers/media/platform/qcom/iris/iris_vdec.c b/drivers/media/platform/qcom/iris/iris_vdec.c > index 719217399a30..88820060e22a 100644 > --- a/drivers/media/platform/qcom/iris/iris_vdec.c > +++ b/drivers/media/platform/qcom/iris/iris_vdec.c > @@ -369,6 +369,8 @@ int iris_vdec_streamon_input(struct iris_inst *inst) > if (ret) > return ret; > > + inst->frame_count = 0; > + > return iris_process_streamon_input(inst); > } > > @@ -411,6 +413,7 @@ int iris_vdec_qbuf(struct iris_inst *inst, struct vb2_v4l2_buffer *vbuf) > { > struct iris_buffer *buf = to_iris_buffer(vbuf); > struct vb2_buffer *vb2 = &vbuf->vb2_buf; > + u64 cur_buf_recv_time_ns, time_delta_ns; > struct vb2_queue *q; > int ret; > > @@ -427,6 +430,24 @@ int iris_vdec_qbuf(struct iris_inst *inst, struct vb2_v4l2_buffer *vbuf) > return 0; > } > > + if (buf->type == BUF_INPUT) { > + cur_buf_recv_time_ns = ktime_get_ns(); > + > + if (inst->frame_count == 0) { > + inst->last_buf_recv_time_ns = cur_buf_recv_time_ns; > + inst->frame_rate = MAXIMUM_FPS; > + } > + time_delta_ns = cur_buf_recv_time_ns - inst->last_buf_recv_time_ns; > + > + if (time_delta_ns >= NSEC_PER_SEC) { > + inst->frame_rate = clamp_t(u32, inst->frame_count, DEFAULT_FPS, > + MAXIMUM_FPS); > + inst->last_buf_recv_time_ns = cur_buf_recv_time_ns; > + inst->frame_count = 0; > + } > + inst->frame_count++; > + } > + simplifying it ? u64 now_ns, delta_ns; if (buf->type == BUF_INPUT) { now_ns = ktime_get_ns(); if (!inst->input_frame_count) inst->buf_fps_start_ts = now_ns; inst->input_frame_count++; delta_ns = now_ns - inst->buf_fps_start_ts; if (delta_ns < NSEC_PER_SEC) //skip the further logic; inst->frame_rate = clamp_t(u32, input_frame_count, DEFAULT_FPS, MAXIMUM_FPS); inst->input_frame_count = 0; } } > iris_scale_power(inst); > > return iris_queue_buffer(inst, buf); > diff --git a/drivers/media/platform/qcom/iris/iris_vpu_common.c b/drivers/media/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_inst *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 = DEFAULT_FPS; > + u32 fps = inst->frame_rate; > > width = max(inp_f->fmt.pix_mp.width, inst->crop.width); > height = max(inp_f->fmt.pix_mp.height, inst->crop.height); > @@ -435,6 +435,10 @@ u64 iris_vpu3x_vpu4x_calculate_frequency(struct iris_inst *inst, size_t data_siz > if (inst->fw_caps[PIPE].value > 1) > vpp_cycles += div_u64(vpp_cycles * 59, 1000); > > + /* 1.05 is VPP FW overhead */ > + if (inst->fw_caps[STAGE].value == STAGE_2) > + vpp_cycles += mult_frac(vpp_cycles, 5, 100); > + > vsp_cycles = fps * data_size * 8; > vsp_cycles = div_u64(vsp_cycles, 2); > /* VSP FW overhead 1.05 */ > > --- > base-commit: f505e978d1a0442adbbde48aed38c084ddea6d6e > change-id: 20260304-update_fps_calculation-98ee7f7507b1 > > Best regards,