mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Gjorgji Rosikopulos (Consultant)" <gjorgji.rosikopulos@oss.qualcomm.com>
To: Loic Poulain <loic.poulain@oss.qualcomm.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Bryan O'Donoghue <bryan.odonoghue@linaro.org>,
	Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH v3 7/8] media: qcom: camss: Timestamp buffers at start of frame
Date: Wed, 2 Dec 2026 16:48:00 +0200	[thread overview]
Message-ID: <c1d11f6d-07ff-44db-b3d8-09fd27622781@oss.qualcomm.com> (raw)
In-Reply-To: <CAFEp6-1KO0XNic92xqVmgorw45MprqSDD6bBN-+W3ZTY_wL-EA@mail.gmail.com>

Hi Loic,

On 12/2/2026 4:42 PM, Loic Poulain wrote:
> On Tue, Dec 1, 2026 at 4:39 PM Gjorgji Rosikopulos (Consultant)
> <gjorgji.rosikopulos@oss.qualcomm.com> 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)
>>> <gjorgji.rosikopulos@oss.qualcomm.com> 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 <loic.poulain@oss.qualcomm.com>
>>>>> ---
>>>>>  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;
>>>>>
>>>>
>>


  reply	other threads:[~2026-12-02 14:48 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 16:11 [PATCH v3 0/8] media: qcom: camss: Report the hardware SOF timestamp Loic Poulain
2026-11-27 16:11 ` [PATCH v3 1/8] media: qcom: camss: csid: Add an operation to read the " Loic Poulain
2026-12-01 11:19   ` Gjorgji Rosikopulos (Consultant)
2026-12-01 14:20     ` Loic Poulain
2026-11-27 16:11 ` [PATCH v3 2/8] media: qcom: camss: csid-340: Report the hardware " Loic Poulain
2026-12-01 11:22   ` Gjorgji Rosikopulos (Consultant)
2026-11-27 16:11 ` [PATCH v3 3/8] media: camss: Define timestamp registers for csid-gen2 Loic Poulain
2026-12-01 11:25   ` Gjorgji Rosikopulos (Consultant)
2026-11-27 16:11 ` [PATCH v3 4/8] media: camss: csid-gen2: Report the hardware SOF timestamp Loic Poulain
2026-12-01 11:36   ` Gjorgji Rosikopulos (Consultant)
2026-11-27 16:11 ` [PATCH v3 5/8] media: qcom: camss: csid-gen3: Fix the RDI timestamp controls on Titan 690 Loic Poulain
2026-11-27 16:11 ` [PATCH v3 6/8] media: qcom: camss: csid-gen3: Report the hardware SOF timestamp Loic Poulain
2026-11-27 16:11 ` [PATCH v3 7/8] media: qcom: camss: Timestamp buffers at start of frame Loic Poulain
2026-12-01 11:53   ` Gjorgji Rosikopulos (Consultant)
2026-12-01 14:41     ` Loic Poulain
2026-12-01 15:39       ` Gjorgji Rosikopulos (Consultant)
2026-12-02 14:42         ` Loic Poulain
2026-12-02 14:48           ` Gjorgji Rosikopulos (Consultant) [this message]
2026-11-27 16:11 ` [PATCH v3 8/8] media: qcom: camss: Tell userspace we're using start-of-frame timestamps Loic Poulain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c1d11f6d-07ff-44db-b3d8-09fd27622781@oss.qualcomm.com \
    --to=gjorgji.rosikopulos@oss.qualcomm.com \
    --cc=bryan.odonoghue@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=loic.poulain@oss.qualcomm.com \
    --cc=mchehab@kernel.org \
    --cc=vladimir.zapolskiy@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®