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=1796391092; b=mvLQHwr0trXK2912lbK+VCQQc9Pfo+1KbTGcCK4ogwOj56zgI4y9ASx9QmcS90n4+iUA AIieP0a7+uM1loX5VUhN4WGxLITAs5/gHSEk2cZdi88I//uGY085zGN1Pv24MV+1wx+Ey wBcAotkMCRooHetSq7Pr5R3asbqxSZLBmPBno03R4pmCmSsMisKZCvcU7UbtHMeNO1XfP vh0gIKsJB54HK4nq/0h5xaWi+yKVNeXfOpwbiwuGXq6EYN6bNUFj9CW1f5IMPfrQZDaw/ X/37a9b0GTRhmKszbLiW6LFiPe77guTkbkc91jxREssQ2mBV0F0r2DFrIEPoO4j+R9w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796391092; 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-ORIG-GUID: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-Spam-Info: X-Proofpoint-GUID:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=2xh+7GzQ2LpE4XVBHoWLNO0bYsCCUAsD0kxFnViNw7w=; b=5B3g8ZwCWDF+MvGYa5y1N8Pa3U5FBLlCLp/2RhlCYdC5eovcWBpRv6mLN2iFiSOkKeva vPSf13nittiEu3h53I6sSCGosQ+Swmod7uC6VHXSksNhYxClkqod1ryj427W+XqRqLk7n TUcbV0hTt46gcWNMc7Cl6qKMi+vRZ71Wo6XpLwAPwGiz6cL1dczeWwAf/mPPmVA8ai0My FSsxuN55Ma/RApkPspbZkp6C/6Ze8mM5XtHFi6p9097S1iRm9uUJVpuaJIa/VuiKSsPHT gXUuP3xTWUgTE8y6e/KBrY9NJAwiWR6WXC4b0PrgIkpV5HO7K5v709VQXcrC93ImhXw== 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=Fg9Oy+s3; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=cwoPvRTx; 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 A3FFA606A322 for ; Fri, 4 Dec 2026 13:31:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A3FFA606A322 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=Fg9Oy+s3; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=cwoPvRTx Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B4BJ8iF2472508 for ; Fri, 4 Dec 2026 13:31:30 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= 2xh+7GzQ2LpE4XVBHoWLNO0bYsCCUAsD0kxFnViNw7w=; b=Fg9Oy+s3Jaay5hfx Z6CMpyk4VSknUHmJ+hTlS6Jw+HxWhs46TP/9m9Zug+S+HgyHfMlI/L1iytap3+Pl lafUAvH9M1D8eY6VFp6lhiwbtc+otQSta3HjLf1eMwvOF1CFvASx9vctCAJTV5sa 61GuygZayu2p6LEdP7ApRJpU+h4oqjD2Rpn4oeUL6t47nxOB+lNxH80stDl8tUkC +mMsuAOQj3xQQWjh89Kr9tTxyqltlKIXRirjiDd/tFOWBjU3/h4/TEJGbtlCmUgl A1r5qho+Oe3WKOBw2ICsbW7PrwNmeWIZN0NRe1bib/HQsQi5MUiX+B66+IAMAYU8 Uy4xeg== Received: from mail-yw1-f200.google.com (mail-yw1-f200.google.com [209.85.128.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4jbq7xsfvr-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 04 Dec 2026 13:31:30 +0000 (GMT) Received: by mail-yw1-f200.google.com with SMTP id 00721157ae682-8b3ad0823c3so14222267b3.2 for ; Fri, 04 Dec 2026 05:31:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1796391090; x=1796995890; 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=2xh+7GzQ2LpE4XVBHoWLNO0bYsCCUAsD0kxFnViNw7w=; b=cwoPvRTx47IiqOMWec+vf5IKOfWDsJPBH1Qx+2wnv+sSXQoPO1aYB0fCi5z1x/4Dtd Ao/gSZ5BJkbzYvG/0vY7nQEguHocngkcfBZX4l5rzCyGQsL566l8QxDcc9IWCKGe0/xK a03kkHZ1qtmq1l46XMkInbsTC3P2I05wsOkk+b0knqVvPWFxBZh6xtDT4ILFt+u+MSeO qkOwG7rTXusjHmVjA3WVdnC3IvxkxGWMZkTzwnm2l3FDvbvH2RwuRGiJQrylyywTQLK7 aPXoUaUiKubYIDi1J34N2pcaduL4mG2iue7F6h8s0+WJ5D2rdm9lDPGOUp1oa9QP+gpN 7kjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796391090; x=1796995890; 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=2xh+7GzQ2LpE4XVBHoWLNO0bYsCCUAsD0kxFnViNw7w=; b=cR5voXGNcG4DSD5IkZQjyjNqHK/WKUy34Nb0jbCI5v69gShh6yTpzackFQdseWuATc suGEsPIKQcsx/pRybTov+WmDcHSDdq7ze8nqkTYAKI0NBZY/s5qXzdniRQ1qVD3rYoxy LKk5gv0g0QCO59rI0p7RQvZ4OLnqN9GUOiaBw0U+NNl/s2zFvMrFL1lvy1Cwg+rhRMGc 3UL0wnqBTTQy3mmRaRMD2/AozRCqKQZsLmAuYffpyrqSsFUiubUhub5n/a6jJYNvcYZQ 3v9aBCyTzsUu2/FEFKZ1bprqiSErvZjPext1NplxlbRmMVy4a5SIPv85hlh1pHuvjctt t2Cw== X-Forwarded-Encrypted: i=1; AL+hErF30WtME3DBHfFYuzVqwRChCwSMzCE4Dz2QIhSWOB4Y6uRW4yx0kmP7WqOZi//Ih1BXYE0JaTr+oHd4/PU=@vger.kernel.org X-Gm-Message-State: AB4q+uFJSGpPl+p2PNtQIaFJ8d/ud71hNcuaDn73FTnOIexCKLv9uPY2 CdZohWIZg44WRxbtrz4ZYzrmW9N3AF8bXoNRpdMYouNsyAUJbbWmgB+DQHwn5sbtc3C5DQlezgy bdOKQEGY7uyn7MstiEeQ93AwYNIqAPNy28OfoQzg+m6ztNjqCnWi6CSMM/QD3Oqo8o/M= X-Gm-Gg: AZFdTZc13zDfmBHFDzj/AGM+QbjyyNEwdAdh6wIrpHxRVgHghNO8iBQi+exjlVyMBFn bEHjDgbCXriHro+V+dQUjKJ3SVvFF39lK0YbyPx71cGmuYDJwQFMJnGm95QccckL+YZsbMGKZ3u V5BNDKs6Mb0fMXsHI0tuPr0em/c06dnBFn/3fkXi9wHAQJwnoT+Z5BuUFCZo0G5Uvsk4lvRW2Fn PRdKIWYvQioOUj0MHB2ECMgQObut8mNI0pWYKi1n4NOZBqxxeqU66A27lGN41TjFFQ/bSDJPKwW RWShFtoCgfiG54XYro/CphJb29pdQ4D8bze0hGZ022tBkzl3F2uBuJZ+XRykiuEM8767sdwqUMw cj2WOAwXacFjSoTVgut/WXAHuc3WLP7mhXGbdwhLd0kQN9N5Ji9rpxOw14cg0MJoti2zeZDDD+2 5VHio5dOYWMIA= X-Received: by 2002:a05:690c:6c87:b0:8ae:a9c6:2740 with SMTP id 00721157ae682-8b660db66e4mr11136867b3.48.1796391089644; Fri, 04 Dec 2026 05:31:29 -0800 (PST) X-Received: by 2002:a05:690c:6c87:b0:8ae:a9c6:2740 with SMTP id 00721157ae682-8b660db66e4mr11136717b3.48.1796391089030; Fri, 04 Dec 2026 05:31:29 -0800 (PST) Received: from [192.168.1.35] ([85.196.172.179]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbea0b5e3csm53408145e9.0.2026.12.04.05.31.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Dec 2026 05:31:28 -0800 (PST) Message-ID: <0d6301cd-8720-4bdc-b83b-2393e425d3c0@oss.qualcomm.com> Date: Fri, 4 Dec 2026 15:31:26 +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 v4 11/14] media: qcom: camss: Stamp the buffer the write master is filling To: Loic Poulain , Mauro Carvalho Chehab , Bryan O'Donoghue , Vladimir Zapolskiy Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org References: <20261203-camss-hw-ts-v4-0-c271022b4b0d@oss.qualcomm.com> <20261203-camss-hw-ts-v4-11-c271022b4b0d@oss.qualcomm.com> Content-Language: en-US From: "Gjorgji Rosikopulos (Consultant)" In-Reply-To: <20261203-camss-hw-ts-v4-11-c271022b4b0d@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Authority-Analysis: v=2.4 cv=Jv1kP84C c=1 sm=1 tr=0 ts=6b12c0b2 cx=c_pps a=NMvoxGxYzVyQPkMeJjVPKg==:117 a=Q/e3f29T3Hw2hnAEzBPF7w==:17 a=IkcTkHD0fZMA:10 a=pUM-KoujPXoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=ZpdpYltYx_vBUK5n70dp:22 a=EUspDBNiAAAA:8 a=FEviH0T0C00q3j6ikyYA:9 a=QEXdDO2ut3YA:10 a=kLokIza1BN8a-hAJ3hfR:22 X-Proofpoint-ORIG-GUID: N-6lkpCpIcjybfGbvHbGGhZZuIn6D--7 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjA0MDA1MyBTYWx0ZWRfX2+qTcNebUQPS 3c5McFep7nZwZxDOSifq1g5FvQGa70dcfr7Ee8EGym027PtYc8SRm3/ZJ7lq3BLwbHyRRqAXtss ZplDsqFajEY+F9Sd2+uDyxBMPYFP8NEItDvoOS8tyFmsTZWfzYtiZbOe7vEpRJX8jeL/SbbsoPv V3PEqF4zUghZjQ0jLQ3AhXE2lynTD2pdesuzapUDXmml0JnMTdAYAKuhxcAZ0ATIh9D072P5wPP tC1C8dx6q+vcSZfSbxgREKGnxIXTaIMCk/9DXZjnn911cM70Hx4feGmBqIG83yKWTtfElAQJwJ3 sSHjM4kF8GafeI/cUMhHsT/Yz1xnfOU+o7ofPhv8D6DWAUh+I6CBJlAygMkR4uEPfhMSmsjODKx /M0uY/FCdGNdmbGMCWImvz3j6NwaMoYSe/9Zga6HD6DmM9ao3elQM4sLL0Syx0ypjg8yMnhEIsi ibxNkJhafMNjI7YY2vQ== X-Proofpoint-Spam-Info: AW1haW4tMjYxMjA0MDA1MyBTYWx0ZWRfX7dwvGJE7eU/8 uPlIQ4jIsZYMqoxayis+RR412RLz/CjyeL1jvJpvaaUghOzt6xcTzgljCoWHEwDuuhdxlwYLmzd HuGymwvxWfSf9taO7r0vkMb5bQ3xyWo= X-Proofpoint-GUID: N-6lkpCpIcjybfGbvHbGGhZZuIn6D--7 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-04_02,2026-12-03_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 spamscore=0 impostorscore=0 adultscore=0 malwarescore=0 clxscore=1015 priorityscore=1501 bulkscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612040053 Hi Loic, On 12/3/2026 6:53 PM, Loic Poulain wrote: > The SOF timestamp is read at buf done and applied to the buffer that > just completed, which assumes the frame that last started is the frame > being handed back. With two buffers in flight that is one frame out: the > buffer completing was started by the previous SOF, not the one whose > timestamp is still on record. > > Describe the buffer from the frame start instead. Ask the write master > which address it is filling, match it against the buffers the output > holds and stamp that one, leaving vfe_buf_done() to describe only > buffers nobody got to, which keeps hardware without an address report > working as before. A zero timestamp is the sentinel for that, which vb2 > guarantees by clearing it on every queue. > > Buffers are filled in order, so a frame starting into the second slot > while the first has never been described means that first frame start > never reached us. Say so rather than describing the wrong buffer. > > Suggested-by: Gjorgji Rosikopulos > Signed-off-by: Loic Poulain > --- > drivers/media/platform/qcom/camss/camss-vfe.c | 70 ++++++++++++++++++++++++--- > drivers/media/platform/qcom/camss/camss-vfe.h | 2 + > 2 files changed, 66 insertions(+), 6 deletions(-) > > diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c > index 87fc09f7849c6e147d2a3a8fc85233c2e1f52ebb..0d06728e54456ea56923611cf9c19f3a0cacec98 100644 > --- a/drivers/media/platform/qcom/camss/camss-vfe.c > +++ b/drivers/media/platform/qcom/camss/camss-vfe.c > @@ -473,12 +473,15 @@ void vfe_buf_done(struct vfe_device *vfe, int wm) > goto out_unlock; > } > > - if (line->sof) { > - ready_buf->vb.vb2_buf.timestamp = atomic64_read(&line->sof->ts); > - ready_buf->vb.sequence = atomic_read(&line->sof->seq); > - } else { > - ready_buf->vb.vb2_buf.timestamp = ktime_get_ns(); > - ready_buf->vb.sequence = output->sequence++; > + /* Tag TS/seq info now if not already done */ > + if (!ready_buf->vb.vb2_buf.timestamp) { > + if (line->sof) { > + ready_buf->vb.vb2_buf.timestamp = atomic64_read(&line->sof->ts); > + ready_buf->vb.sequence = atomic_read(&line->sof->seq); > + } else { > + ready_buf->vb.vb2_buf.timestamp = ktime_get_ns(); > + ready_buf->vb.sequence = output->sequence++; > + } > } > > index = 0; > @@ -509,6 +512,55 @@ void vfe_buf_done(struct vfe_device *vfe, int wm) > spin_unlock_irqrestore(&vfe->output_lock, flags); > } > > +/* Retrieve the buffer starting at a given address. */ > +static struct camss_buffer *vfe_wm_curr_buf(struct vfe_device *vfe, > + struct vfe_output *output, u32 addr) > +{ > + lockdep_assert_held(&vfe->output_lock); > + > + for (unsigned int i = 0; i < ARRAY_SIZE(output->buf); i++) > + if (output->buf[i] && output->buf[i]->addr[0] == addr) > + return output->buf[i]; > + > + return NULL; > +} > + > +/* On SOF, associate the current buffer with the seq number and timestamp. */ > +static void vfe_sof_notify(void *priv) > +{ > + struct vfe_line *line = priv; > + struct vfe_output *output = &line->output; > + struct vfe_device *vfe = to_vfe(line); > + struct camss_buffer *buf; > + u32 addr; > + > + guard(spinlock_irqsave)(&vfe->output_lock); Nice. But i think we should have constant usage of the spinlock/mutex api's It will be nice to modernize the whole code and use RAII patterns for allocation and locking... But as of today adding it just here i am little bit against. > + > + if (output->state != VFE_OUTPUT_ON) > + return; > + > + addr = vfe->res->hw_ops->vfe_wm_curr_addr(vfe, output->wm_idx[0]); > + if (!addr) > + return; > + > + buf = vfe_wm_curr_buf(vfe, output, addr); > + if (!buf) { > + dev_warn_ratelimited(vfe->camss->dev, > + "VFE:%d line:%d SOF while no buffer ready at 0x%x\n", > + vfe->id, line->id, addr); > + return; > + } > + > + /* Buffers are filled in order */ > + if (buf == output->buf[1] && output->buf[0] && > + !output->buf[0]->vb.vb2_buf.timestamp) > + dev_warn_ratelimited(vfe->camss->dev, "VFE:%d line:%d missed SOF\n", > + vfe->id, line->id); This is interesting. But if this is the case most probably the buf done was also missed, do you think we should add code to make buf_done on stalled buffers? Note that Atanas is hitting this stability error with his tests once or twice when system fully loaded. And in ife pixel path implementation if this is detected we are returning the done buffers to userspace (most probably they are not corrupted just that we have missed to serve the irq on time). Atanas has some local patch which can be posted later if you think it should not be part of this series. > + > + buf->vb.vb2_buf.timestamp = atomic64_read(&line->sof->ts); > + buf->vb.sequence = atomic_read(&line->sof->seq); > +} > + > int vfe_enable_output_v2(struct vfe_line *line) > { > struct vfe_device *vfe = to_vfe(line); > @@ -569,6 +621,9 @@ int vfe_enable_output_v2(struct vfe_line *line) > ops->reg_update(vfe, line->id); > } > > + if (line->sof && ops->vfe_wm_curr_addr) > + csid_set_sof_notify(line->sof, vfe_sof_notify, line); > + > spin_unlock_irqrestore(&vfe->output_lock, flags); > > return 0; > @@ -849,6 +904,9 @@ int vfe_disable(struct vfe_line *line) > struct vfe_device *vfe = to_vfe(line); > int ret = 0; > > + if (line->sof) > + csid_set_sof_notify(line->sof, NULL, NULL); Why we are doing this here can we get some explanation? > + > vfe_disable_output(line); > > vfe_put_output(line); > diff --git a/drivers/media/platform/qcom/camss/camss-vfe.h b/drivers/media/platform/qcom/camss/camss-vfe.h > index b0921e348f2c73a5533c196400c70da187be2cee..ca2d47219545ea91b1bbf1a616bb0b4b36b507d6 100644 > --- a/drivers/media/platform/qcom/camss/camss-vfe.h > +++ b/drivers/media/platform/qcom/camss/camss-vfe.h > @@ -122,6 +122,8 @@ struct vfe_hw_ops { > struct vfe_line *line); > void (*vfe_wm_stop)(struct vfe_device *vfe, u8 wm); > void (*vfe_buf_done)(struct vfe_device *vfe, int port_id); > + /* Address of the frame the write master is filling, 0 if unsupported */ > + u32 (*vfe_wm_curr_addr)(struct vfe_device *vfe, u8 wm); > void (*vfe_wm_update)(struct vfe_device *vfe, u8 wm, u32 addr, > struct vfe_line *line); > }; > ~Gjorgji