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 3C64B2E762C for ; Wed, 25 Mar 2026 16:31:41 +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=1774456302; cv=none; b=NtrupnV+wJg33Bw7Dy/ShiaHqZWJqv8eFe8azwFVV0vK1M+rxAkmjkeX4/TIggnij7xNOfBduGQejiVVH7YQRsumR1CnjHSUZ6JRlunTnHfNylbiaEz+QTMclEoWEKJD0PHU+G+NWuUsLu4nKPXWzhi8ZFqaccg6m+mF4DvehQo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774456302; c=relaxed/simple; bh=ymhMvWPSz4H4x8d7P5by57C7aV5WDypPse6VD1B411w=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=olvnQtXDcMQa4OqxUy0D/4qlBj3csDS6nwCU0iioIW/ETiEr8nLyXYaSVS+jkvD/EcVSTvSYBQdcrABAH9p+JlozZP5JxPHMc07AoPOetKnLBmXZsBQtqxRtGDD4AGAIplXJE1f/mPlBGJzSfD7y3FNVfW7alo/rE+KmnLBty84= 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=OgJ/sRoN; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Sxnl6WBv; 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="OgJ/sRoN"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Sxnl6WBv" 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 62PFH7dH1554724 for ; Wed, 25 Mar 2026 16:31:40 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= VI/nXBelBqAIi/vUA24Uppo5J0Y3H2/eUHUlYHlPMeY=; b=OgJ/sRoNU9ISluUC TVN3WlFhOHylNbCwHQsaVvNmUmjthMcsxel9GTCSgwFw6ciWAwpIBpGOxdDFKLPy bN216Ud4Z5+s0nTX6T6fhfJ0Bc+8076JxhakL5KXCQzmD+56r8D8HO9BdVUrSQnD 6Dk7Sv47DkOs/3T7u/iP56L1+WDAaMkoqGGo/JyfZbhIVdH514YQWO6ZTfWvdRPV nNZtXndBwfXVegbsxARWxuB3qUepwQ5rQQzyIphvfgEJ1u9aRE8xDedZgVqJV2kc g79HSNacjC9b/BpzzCbxSGJRccxKnn5zEWmla4ZmMIZm7akIAlxu5yezJQFE9sFh zMLO9g== 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 4d4gj78r5u-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 25 Mar 2026 16:31:40 +0000 (GMT) Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-c739120475fso68900a12.3 for ; Wed, 25 Mar 2026 09:31:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1774456300; x=1775061100; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=VI/nXBelBqAIi/vUA24Uppo5J0Y3H2/eUHUlYHlPMeY=; b=Sxnl6WBvHj1rJXxMepXpNWcnmCp9SFmxj+jIjxhl2qcpfiC3sK+W3UNnsMVM5sYZFp NWPpRARYwyXCyv5Q9gOge3E/3IEO7GWR5ml9VTci0a01WUS/HLy6l+6L/fFb0RBMuOl9 /B/vukP358zd4/S2uf4Xi1E/Gh01PNovr1O8W//AS7XwcSILtbE/ZZ84aCtBEAWMQfNf GzHFI+5w0PGDKQfTN+DG4IlJtieNuaQM4q6bgtjBgnqcVwUv5fnSogdJ5Dobo5aZxAEa BHyBItbUAbLyiXwz6ZR8OUWRpTOYjAakAPnLrRxu5zV40RpUbHTbne/RpWAtQofKCF9x Xx+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774456300; x=1775061100; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language: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=VI/nXBelBqAIi/vUA24Uppo5J0Y3H2/eUHUlYHlPMeY=; b=sBwsj+jfS1mEGs+Ykk+vmTm6miI0I+EDUY4jdixS5M7P1Py/cp2nXPT4DPguDZEaN4 cl4dkm36fqoCbyEt9lE4SrAMso/HICMiMCk1rhk5IwfcSyufgmAiIPDaVvroA8lLvp3y cLclq2/EYXai7SX9BOTRChSuE6ZcLmRWtPpFjcUMTxUxxeaqCVwQsB42f56qSLQAhFlH jLd3o9m/p3QoZYao8T9bj+0BF8h3ctXVVY0wm+M90Cr9d1A5A7MDhpzlP7UKWIJB3gvZ eekjwNSv0mzXzb0mD7YQUhByHaKj0dcc7Xb4PImbTIe+FDUVd66tv2V2J/wtDs5kFFv8 VtxA== X-Forwarded-Encrypted: i=1; AJvYcCVZomC2/7uTV+UJ5BmZf51vct6IuOlNwzkJDTwdMRr8nPsrZXOjfW3P3JhE0TiYkc3YOTUHOZVeWuvPZGo=@vger.kernel.org X-Gm-Message-State: AOJu0YxBkipswd4RAbJ4bjvXqcmFYfn5I3kAklUax3qIXjkNiIlzmwk5 U91QHuamQhuG1gVID4iXh/axUUO/itTsCoUCPFnOU1EyeN0WmK5FQ4lwrWYXCxZBTAHygpv4tWA EaQx7STdJmh6YO7VDtWQclN0N+WQptbWiqdERox7O6fTionOEasiUfx3VS1FQ/Guvmes= X-Gm-Gg: ATEYQzyc0HL0sUCTaSKlYtZv0y9itGMWkQ54ywtTQ2I1KjWBwwSaYJUmr5ZZbxV25Cl 9JIi9LMMI6f0u2GEe961eJraHCTnVD8fkQccoPF8maGHVqsP7csQmoP2VW+Tg5yFCVMrEYxNO5m /BazLbbnvYU1oPwvw8N5E476ivgJOkolZVtcynHIX3s31iVbt4VFhF4o2WrQQ/+Bw9TLkdhmctA AqXJjvO3nVQFrpPL/HKq0Rw+hGyrSWOkohXg5+l30STDGu2PtBciGvyxSpmYsnX8GkPedNNUAZj 1TTkclC1+VtkM7u4fbOoL+AHaj3QXhHPrCSClX3TmKQhmV3JmPWm/cqKTZAXphJ9CeDOUB+kot7 hTMKE5JZMugZmU6762IAY9XU1Fw9ZcKuaCGBMn/r2fZ2p9LA2jcur3O0= X-Received: by 2002:a05:6300:210d:b0:39b:f026:6f91 with SMTP id adf61e73a8af0-39c4ae4f8ecmr4487968637.67.1774456299632; Wed, 25 Mar 2026 09:31:39 -0700 (PDT) X-Received: by 2002:a05:6300:210d:b0:39b:f026:6f91 with SMTP id adf61e73a8af0-39c4ae4f8ecmr4487925637.67.1774456299041; Wed, 25 Mar 2026 09:31:39 -0700 (PDT) Received: from [10.100.155.18] ([106.221.177.92]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c767382c12asm9435a12.14.2026.03.25.09.31.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 Mar 2026 09:31:38 -0700 (PDT) Message-ID: Date: Wed, 25 Mar 2026 22:01:33 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH v3] media: iris: add FPS calculation and VPP FW overhead in frequency formula Content-Language: en-US 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 References: <20260325-update_fps_calculation-v3-1-b2ec654f7e4d@oss.qualcomm.com> <4a81a54d-2dc5-476c-82ed-9481aee8515b@oss.qualcomm.com> From: Vishnu Reddy In-Reply-To: <4a81a54d-2dc5-476c-82ed-9481aee8515b@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Authority-Analysis: v=2.4 cv=M9hA6iws c=1 sm=1 tr=0 ts=69c40dec cx=c_pps a=Qgeoaf8Lrialg5Z894R3/Q==:117 a=RZvIcqPQUX9fBvPB5l+mIA==: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=kjtj7dyyPmjPXOxDuj8A:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=x9snwWr2DeNwDh03kgHS:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzI1MDExOSBTYWx0ZWRfX8o4MAOAwIrOc p/hX2hSIXBySHksrklfKgZt0OQ3vWwQn7FDcnIgEPV8HsKfrm762YZkfoZLGT/XetpExlXUemft 8BdFNcYMVFC2wIE8zngWfURvx3BYpYd0aaSewup2pha5PCkh4NspxKzVh4dPLpv0yf6rZpYUUx9 BQsbkwpbeO/oe5+NLQRvx8en/bsBdcjqPdr2+1mibrB5+61j839NOnWRDV1SmlLyzsnkJ9vL9dS tvPA/LVi01H5bqg13uxk1XZlhhmCDdATxnpJq9MKOG70JP3RU6/51a/I+F2He6QIL/RB3/edVJy yrLJYgsSGVAFVnT4BBtn+OAmXqWpvg+56vo1ncQhqQp3AuEXrWMTX9wXvNMdsYTK2LVBphtO6fZ WBN+6ZPYT9i5i+RniOSGgv4+b+YtV15KSKIfT05Nbs5DCxVTgGAV6SrkVL55uwwNWP9g9Wd9pH2 paN8tCE9VNIugcdkJBg== X-Proofpoint-GUID: qW8ebHcBlMWWX0d7BWJy9KzDa9xMbHA_ X-Proofpoint-ORIG-GUID: qW8ebHcBlMWWX0d7BWJy9KzDa9xMbHA_ 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 clxscore=1015 priorityscore=1501 bulkscore=0 impostorscore=0 spamscore=0 adultscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603250119 On 3/25/2026 1:23 PM, Vikash Garodia wrote: > > > On 3/25/2026 9:58 AM, 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 v3: >> - Updated the frame_count condition check >> - 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 >> - 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; > > s/last_buf_recv_time_ns/last_buf_ns Ack > >> +    u32                frame_count; > > s/frame_count/frame_counter Ack > >>       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..6d982802e5d4 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(); > > s/cur_buf_recv_time_ns/cur_buf_ns Ack > >> + >> +        if (!inst->frame_count) { >> +            inst->last_buf_recv_time_ns = cur_buf_recv_time_ns; >> +            inst->frame_rate = MAXIMUM_FPS; > > move this to default initialization Ack > >> +        } >> +        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; > > drop this Ack > >> +            inst->frame_count = 0; >> +        } >> +        inst->frame_count++; > > move this above IF block, so that the reset of > inst->last_buf_recv_time_ns can be handled in first IF block Ack Regards, Vishnu Reddy > >> +    } >> + >>       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, >