From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796222886; b=nW81Gczw0Fgex75Mi7nLF9Wx3R9WgwGBz8JPtQLkjKDlT+jy+12rRrtAkW4wGCik0yaB EruHtjbNr3RD1REl+l1XUzyuorNmPW2G/NLSXG1wN1kpktf8pPw02mrQT3K/US4kJ3D6R b/rsWaL2tkeCMDrMcQGaGcXdGmiRAClpF0RMEZiBWofB76eBmBW/F9ki2VezpUhjWp8gw Jxz86mziLw+6J/KUtg+yeToVDE+Mcf1eO94CH3ZvLISZzGS/eFc6hhEsZDx+oDssqlHRc kus9bzIUX4wHNSJ2jiCntjFOQchGyJuy17jb2QVOlpKsiEeyrCXo8vCi5tmRpIVI96g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796222886; h=DMARC-Filter:Received:DKIM-Signature:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:X-Authority-Analysis:X-Proofpoint-GUID: X-Proofpoint-Spam-Info:X-Proofpoint-ORIG-GUID: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=2sbLAMGu8x2ur2VVxd2RyVwGJQStSAanB+nZwPGj/q0=; b=TDJFbLFqZaYJcVZu/LUZPOEWcIIhBNorXbXaySKlViqKSBS6ZTSmA+gCr90Wcue5joIq yuveGplVXDkQfyLBV2Wh0m7Wc5GDXfCsosRH7+l9lW8JHWe4HlkhREIbxXXxebkhKqhwo DJxcF3oP6OUZkpO8vG4gOrKdcl2YsTjRAcw2Av+TaQsJ/S0VbbYaz3eTQErVViku5Rcbn Irmy3PFSTVZk4Aq8IYdXP/cC7yvWeqX31yERbo5Xwkrh/Tj+QMjk7CzlQWCS6x08lD4Qz Mrjdpy9JhomjehPo16ljwA02lQje3VDY6BV/n/qElcr8emVbwwifsJTC4OcvfrJGWRw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=KfSyYv92; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=eShG9Isj; arc=none smtp.remote-ip=205.220.180.131 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD1B3606A322 for ; Wed, 2 Dec 2026 14:48:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DD1B3606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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.a=rsa-sha256 header.s=qcppdkim1 header.b=KfSyYv92; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=eShG9Isj Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B2EQGAl3230093 for ; Wed, 2 Dec 2026 14:48:04 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= 2sbLAMGu8x2ur2VVxd2RyVwGJQStSAanB+nZwPGj/q0=; b=KfSyYv92XmyjEtDs StWxgLV7B+zMo4M25h4t2iiW0isJf6v99uEpuaNnW0rLMBcAeuI+DK9Luhm0Vz/l EGIBCh8SfTjGfviNDh9fSY0RcLHN5x7gr+hXYr0QDxa9FSe7krq9tCVjALbXJc1w /PyutRpDuCCmU2/7Dl8yXqXP6BGPqEZEOjvri9ZnkQlmEUwdvoUzTfj8b6uIXekC Nuyg4PsfRZDkTDflB/YE1RaFYjnJ3e+B0N3aiUVq4xio032/ggwplUcHHPCmurUp O3ANbU2gD7SI9wExrwZwgs6siiTAsrLqfQB0e8IzoWzx8N9qkjaY1+N00p4d88zz GBOnBw== Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ja7v3kcje-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 02 Dec 2026 14:48:04 +0000 (GMT) Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-94967c6d4f4so1509402885a.2 for ; Wed, 02 Dec 2026 06:48:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1796222884; x=1796827684; darn=vger.kernel.org; h=content-transfer-encoding:content-type: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 :content-type; bh=2sbLAMGu8x2ur2VVxd2RyVwGJQStSAanB+nZwPGj/q0=; b=eShG9IsjZaR736DA7Qdzexl+SXjLH5+2DG86GL/bjMFwqk26vefD+pOum9leAxiAer QwXygs6nyfiKSW0mwOmONOhvGkzGyf7pZZQS1O7foiaNn0lAHvhzBcBge1o/UsKWLmmX npKQXqHpJy/eQ7k9FEJCNiHm8wnuVRhLi14bYIczqoXHilpOvhLMt0p0gVoQUptfcpvR kn4efHn2vG+eLqqqk1j24oB4QGx5we02FJX3+jkneTRsheDOQTpNIa8/TqXh/YCXIx+Y GR4yGj6+S31RgkjXQzQsLjf+tO0wv62hzkgPknrPQpsQWckThvy3DHFD0LP8QoYKpiv1 ckJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796222884; x=1796827684; h=content-transfer-encoding:content-type: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:content-type; bh=2sbLAMGu8x2ur2VVxd2RyVwGJQStSAanB+nZwPGj/q0=; b=xQw/nLZyjY7s4CBirdlB4FEAlULy4xANzbqBd5+Oz6az3Jcw5AojLwaer6o71rtsFM PLTSJflONe+Sx/7myuWirJqfVn1nmhdJukaedNr74JcvOgIOQqX8yHM4kziAfVjWGl6N bQzGXpxdF8KVulxup+3Rk3Mnjdo/m9I7XbcmXlfgCK3b9Mpirz54/tvfv6yRQMXjpwBT Ni0gyASmc37tq539sc8u4euEQDcPuuxe5WdHYtf02E7cMN8ohQW7JmDAA8bJFjHul1XW OboOlZRNgV+aezBaSNztvLaLyvdpo8gLUBmgOac+VL4dSjqE2sk6VBYnwjjgIQ5FTiop E9eQ== X-Forwarded-Encrypted: i=1; AL+hErG+szjL59NbNSywZfbsWaswAyn0B87Vpsj+ZxEuytkZvWEWBDGBHfIiKIzHX2eCEYyaRFTyd0G1PsHrb/g=@vger.kernel.org X-Gm-Message-State: APuU4Z8azEFuAbj5R+fG9LyYCqrtLPQ/pIvQjUEjRC6ABwu1utaBWx7L zC8y5GJTjBO1crkqoID22ZFAhLvpIz4+nr3YRQhgzAPB/ImbcoaDzpax55MruI8gv1FgymvKsKW u4P/shtL/7RuOv3IM16yRi4BBRfSLW3m6L89yQLYWgAbFnbjFhbpFXjtCbWEh+pYyPU0= X-Gm-Gg: AZFdTZc0GO6SIf7c1cBcO/Nnvv8CZG+0sG11TO+wG8sKWaJnxQ80uhsypF6Gcmz9DNe XEqXad4YNqcZwEbAfzC76nyuYKCdy63vX0xTYCFmqkYUR8FfVTxD/RlUqPSM8oXzwThcxje2TSM f6rsS27MHJEl/CWzv+fEklRDsWdju2VUVNKMsawHpekRfRP3gM2X2TULeL0dF+/fw6rvMl8s2cl nPtEzchYEEbgYqvholX9/ZEjApZJy1yQYKE2CxlAWqLKxYPJjqvEzYxwFN9Hu5+dxTCEov7Fgpp gRKpKElIjgEfLs/LyM5kZLWnONZFtoIweu9rSTNQtrzl2DUnxxfWL47bd9Ha/t47+dJ1l9M8EgR V8Gxqst4575uOaUCQWoY82s8FHUqdPx6TbNQLre/dGdGJMKN5URmlDEm2rFgNP/ARkmBqfuLe/x nMpCf0n4R6JJZ9 X-Received: by 2002:a05:620a:31aa:b0:949:3066:5551 with SMTP id af79cd13be357-949bac80948mr7596670185a.79.1796222883524; Wed, 02 Dec 2026 06:48:03 -0800 (PST) X-Received: by 2002:a05:620a:31aa:b0:949:3066:5551 with SMTP id af79cd13be357-949bac80948mr7596665285a.79.1796222882910; Wed, 02 Dec 2026 06:48:02 -0800 (PST) Received: from [192.168.25.64] ([94.155.124.210]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6b110d56sm78552653f8f.40.2026.12.02.06.48.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Dec 2026 06:48:02 -0800 (PST) Message-ID: Date: Wed, 2 Dec 2026 16:48:00 +0200 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 7/8] media: qcom: camss: Timestamp buffers at start of frame To: Loic Poulain Cc: Mauro Carvalho Chehab , Bryan O'Donoghue , Vladimir Zapolskiy , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org References: <20261127-camss-hw-ts-v3-0-e4b6ad98ce9c@oss.qualcomm.com> <20261127-camss-hw-ts-v3-7-e4b6ad98ce9c@oss.qualcomm.com> <804c1f0b-35cd-4a82-b67c-8c6397db8ab8@oss.qualcomm.com> Content-Language: en-US From: "Gjorgji Rosikopulos (Consultant)" In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Authority-Analysis: v=2.4 cv=WJ7qzXsR c=1 sm=1 tr=0 ts=6b102fa4 cx=c_pps a=50t2pK5VMbmlHzFWWp8p/g==:117 a=eGCDHFSXubCXFTSSGhjuOA==:17 a=IkcTkHD0fZMA:10 a=pUM-KoujPXoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=rJkE3RaqiGZ5pbrm-msn:22 a=EUspDBNiAAAA:8 a=YurxBTkMS18a0Qc3gWcA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=IoWCM6iH3mJn3m4BftBB:22 X-Proofpoint-GUID: EgPzZ3jg57gICPhAsU8AiTattpnN8YT- X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAyMDA1OCBTYWx0ZWRfXycmKsMBEWu4d UtFYCeqIS83TVLulhivLrACTbHgf6PHG/cLcMLG+/SHQiopTPnPQJA7VyKnEWWfvXANhkrAXLrc 5cPSdlXHDSy+GEwhoC55Orv4D/1b4oI= X-Proofpoint-ORIG-GUID: EgPzZ3jg57gICPhAsU8AiTattpnN8YT- X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAyMDA1OCBTYWx0ZWRfX/7FD5zvxqIn8 tdrZJGBeqfaenurnpcRgPcXAOSpdiHAkFTUdf03tuHDQfTO+AZ2qTyOjjQoybsxHAu7LavYgWzJ tlRo8ItnNa2wat3qlUUx6aIAKlHUPiMUYjWEykwHHr4w6LthaUBpPO2on6AE66iMqcONVRPTE4d dC9iulE976I5rPPey+dG/FIKi581f9NcLJrdJz5Aqwl9k8gogwsTv5oPRibtkQ5SiJN8DtLZUv8 H7QNzhVXkZ+t3gEXSrN7/B6+kiBZJzSQdjfJa7XZR5y4D2xiXAJQxtbAXfCEFUSNVeOm13MttPG +KPIpNQoi5PS/9ArvY2G5TwJmNMg6j0Efguewy9ynOfuuNFrwCrecslq1McC8CCRFX+aQSgUCbO pKUzdQzMuzqzIBr1Rj3Q2fYpeDhcdtlRkbKyeT+whFkoyfWcbE5xIGEeUM3hI8wtxdEVSkwrwmf 2uXFhpDbaVpqOX1TwOA== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-12-02_04,2026-12-01_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 bulkscore=0 malwarescore=0 adultscore=0 spamscore=0 phishscore=0 impostorscore=0 suspectscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612020058 Hi Loic, On 12/2/2026 4:42 PM, Loic Poulain wrote: > On Tue, Dec 1, 2026 at 4:39 PM Gjorgji Rosikopulos (Consultant) > wrote: >> >> Hi Loic, >> >> On 12/1/2026 4:41 PM, Loic Poulain wrote: >>> On Tue, Dec 1, 2026 at 12:53 PM Gjorgji Rosikopulos (Consultant) >>> wrote: >>>> >>>> Hi Loic, >>>> >>>> On 11/27/2026 6:11 PM, Loic Poulain wrote: >>>>> Buffers are stamped from the write master done interrupt, once the frame >>>>> has been written out to memory, while V4L2 defines vb2_buf.timestamp as >>>>> the time the first data byte was captured. Use the SOF time the CSID >>>>> already computes instead, handed to the VFE the same way as the SOF >>>>> sequence number. Hardware without SOF tracking keeps using the buf done >>>>> time. >>>>> >>>>> Signed-off-by: Loic Poulain >>>>> --- >>>>> drivers/media/platform/qcom/camss/camss-vfe-17x.c | 7 +++++-- >>>>> drivers/media/platform/qcom/camss/camss-vfe.c | 8 ++++++-- >>>>> drivers/media/platform/qcom/camss/camss-vfe.h | 1 + >>>>> 3 files changed, 12 insertions(+), 4 deletions(-) >>>>> >>>>> diff --git a/drivers/media/platform/qcom/camss/camss-vfe-17x.c b/drivers/media/platform/qcom/camss/camss-vfe-17x.c >>>>> index 4972d3ab65078387735ef2e853bf1c9c3d82baee..6b8df1f6e2a731ccd0e739edaa82221c18203f74 100644 >>>>> --- a/drivers/media/platform/qcom/camss/camss-vfe-17x.c >>>>> +++ b/drivers/media/platform/qcom/camss/camss-vfe-17x.c >>>>> @@ -472,7 +472,6 @@ static void vfe_isr_wm_done(struct vfe_device *vfe, u8 wm) >>>>> struct vfe_output *output; >>>>> unsigned long flags; >>>>> u32 index; >>>>> - u64 ts = ktime_get_ns(); >>>>> >>>>> spin_lock_irqsave(&vfe->output_lock, flags); >>>>> >>>>> @@ -490,7 +489,11 @@ static void vfe_isr_wm_done(struct vfe_device *vfe, u8 wm) >>>>> goto out_unlock; >>>>> } >>>>> >>>>> - ready_buf->vb.vb2_buf.timestamp = ts; >>>>> + if (line->sof_ts) >>>>> + ready_buf->vb.vb2_buf.timestamp = atomic64_read(line->sof_ts); >>>>> + else >>>>> + ready_buf->vb.vb2_buf.timestamp = ktime_get_ns(); >>>> >>>> I am not sure that this correct thing to do. WM done can be received >>>> after the next SOF in pixel path. I think that i have commented this for the sof_seq as well. >>>> The proper way is during SOF or RUP or EPOC to check what is the current active >>>> buffer (which is filled) and fill the sequence and timestamp there. >>> >>> Probably yes, The assumption here is that, under normal operation, >>> WM_DONE is received before the next SOF, so the SOF timestamp stored >>> by CSID still corresponds to the frame being completed. If that >>> assumption does not hold, then we likely have a more fundamental >>> scheduling or throughput issue. >> >> I am afraid it is not scheduling or throughput issue, it depends >> on vertical blanking of the sensor and output size of the IFE (IFE >> has some delay because of the line-buffers). So there is no guarantee >> that you will receive them always in same order. >> >>> >>> That said, I agree that explicitly associating the timestamp with the >>> active buffer would be more robust and would avoid relying on this >>> timing assumption. >>> >>> Now, the question is to find a reliable way to identify the currently >>> active/filling buffer from these events (SOF). >>> >>> For example in the sequence you describe we have: >>> SOF0 SOF1 WM_DONE SOF2 WM_DONE SOF3... >>> >>> When processing SOF1, which buffer should be associated with that >>> timestamp? Is SOF1 received because frame/buffer 0 was dropped, or >>> because it already corresponds to buffer 1? >>> >>> We would need a reliable way to determine which future WM_DONE event >>> should be associated with a given SOF event before we can safely move >>> the timestamping logic there. Otherwise, we may simply be moving the >>> same ambiguity from WM_DONE to SOF. >> >> In the ife implementation posted we have used the: >> >> bus_wr_addr_status_0 which contains the >> last consumed address and can be read after buf_done. >> >> bus_wr_addr_status_3 which contains the >> Current buffer address which is filled. >> >> With those two you can make association of the buffer >> filled during the events. >> >> Even further you can monitor what is the hw fifo position >> in respect to the sw queue and keep them in sync if some >> big delay happens during the irq handling. > > Ok agree, we can handle that by having the VFE line register for the > CSID SOF event and tag the buffer the write master is currently > filling. > Can we do it as a follow-up though? This series aligns the timestamp > with what is already done for the sequence number, and the per-buffer > association can come on top, especially with the vfe/ife/line upcoming > restructuring. Since the sof sequence has same issue i agree lets do it in follow up series, and should not be a stop for this implementation. ~Gjorgji > > >> >> ~Gjorgji >> >>> >>> Regards, >>> Loic >>> >>> >>>> >>>> ~Gjorgji >>>> >>>> >>>>> + >>>>> if (line->sof_seq) >>>>> ready_buf->vb.sequence = atomic_read(line->sof_seq); >>>>> else >>>>> diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c >>>>> index f9bd2367671f6e50c6948a6405f78b8c2b03e5f7..ab4edb14ed7486724f12fbd024e0600d70f8355d 100644 >>>>> --- a/drivers/media/platform/qcom/camss/camss-vfe.c >>>>> +++ b/drivers/media/platform/qcom/camss/camss-vfe.c >>>>> @@ -456,7 +456,6 @@ void vfe_buf_done(struct vfe_device *vfe, int wm) >>>>> struct vfe_output *output; >>>>> unsigned long flags; >>>>> u32 index; >>>>> - u64 ts = ktime_get_ns(); >>>>> >>>>> spin_lock_irqsave(&vfe->output_lock, flags); >>>>> >>>>> @@ -474,7 +473,11 @@ void vfe_buf_done(struct vfe_device *vfe, int wm) >>>>> goto out_unlock; >>>>> } >>>>> >>>>> - ready_buf->vb.vb2_buf.timestamp = ts; >>>>> + if (line->sof_ts) >>>>> + ready_buf->vb.vb2_buf.timestamp = atomic64_read(line->sof_ts); >>>>> + else >>>>> + ready_buf->vb.vb2_buf.timestamp = ktime_get_ns(); >>>>> + >>>>> if (line->sof_seq) >>>>> ready_buf->vb.sequence = atomic_read(line->sof_seq); >>>>> else >>>>> @@ -532,6 +535,7 @@ int vfe_enable_output_v2(struct vfe_line *line) >>>>> >>>>> csid_pad = media_pad_remote_pad_first(&line->pads[MSM_VFE_PAD_SINK]); >>>>> line->sof_seq = csid_get_sof_seq(csid_pad); >>>>> + line->sof_ts = csid_get_sof_ts(csid_pad); >>>>> >>>>> spin_lock_irqsave(&vfe->output_lock, flags); >>>>> >>>>> diff --git a/drivers/media/platform/qcom/camss/camss-vfe.h b/drivers/media/platform/qcom/camss/camss-vfe.h >>>>> index c37526caf9a6fc052c3f4ab4215e635167f6da95..8eda4592257169d04027a9a3c45233ac937eecae 100644 >>>>> --- a/drivers/media/platform/qcom/camss/camss-vfe.h >>>>> +++ b/drivers/media/platform/qcom/camss/camss-vfe.h >>>>> @@ -95,6 +95,7 @@ struct vfe_line { >>>>> const struct camss_format_info *formats; >>>>> unsigned int nformats; >>>>> atomic_t *sof_seq; >>>>> + atomic64_t *sof_ts; >>>>> }; >>>>> >>>>> struct vfe_device; >>>>> >>>> >>