Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp294405lqp; Mon, 10 Jun 2024 04:38:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCURgJRp3ziRdIoLat2F944ijlDSRSyd1kv1bPk/H0UxAhownLYe4gjK4Xj/9HIKXdU9Vt8zfa5tFwHaelaaOZaajMMNUpDqMvx03Lp8Ow== X-Google-Smtp-Source: AGHT+IE4WFgXvWiz5Pb+v7HnP/iArYGJIwqaYqnVo398s4kZnQXjDHLmTP+5o3lWHMXEsKY/axDT X-Received: by 2002:a05:6a20:3946:b0:1b5:b9b9:bc8a with SMTP id adf61e73a8af0-1b5b9b9c42amr7445592637.19.1718019520845; Mon, 10 Jun 2024 04:38:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718019520; cv=pass; d=google.com; s=arc-20160816; b=U12U/YBIkTlhpeE8RZ07zJmT4iq17Ps/kd1IP9HV2ot4SlGqIjyGG1ni6ZZJLuHI2e jFAituDLSZfCRVA7Nzh4qiNC1m/o96NWLncp0RiPRu1Q5HwmLyMngfy/ODW+UQIzySmD U9UAhcJBlorZ2DqA5Z1GG+jIQ7Ovbr4V7W2fCiorNVFD1Zzux0ricBS0dxgOGnnZRjCC SFA9yZtCohKkIjL78gIi1KkIWNirAn9n3niE7y7rFo7OfbQ6GyXnMEQ/C1UyCEpbfxyK kT/vt2/C3Ojze83Jmc52IcYpEWnCg4L3WOratO4BIg5zlkX9PU74/a8vX6ptNFdpo5vK jE4A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=MrGhSKsGwNmJ9La/d3Iq0yxd17QDtn3luDfqQDter/8=; fh=GnYKBAEJHlTFi8WIQKmHGtuzM6HaLVg7TnENOYVK+6s=; b=y4KAYv69iRq+8LMWx4EsIF/87VD+MFEd8m32rIZW1oQ7CAiSiR8BdqcX/mUl5SDlY9 is5o7N1uAnvDBaRkk7beSMPUnUQsZaIDbOptrNVyelRgiNwEh8oKQqf5CWCwuwuEo+xc XdysGMlPXCq0VtSb5UojLYh4df6HWiNErEye7fCjQYKE3UYnAKmJOT5lvJpsPw5Yc0rL AugDia4rwqdCytGqUhC0PUSna5Dr+6wWAYhcaOxUIiU7uFKTr/xTm70B0ToeqI0C3t0C TI4CXbml/5mqsyEX43VbMTnbjTUuvC/AV8lSy99KuA3zfpPFYRegeLsHfl+8p222TMs3 8RPQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=wCWtl+vL; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-208085-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208085-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6e8036a17cdsi3832233a12.741.2024.06.10.04.38.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 04:38:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208085-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=wCWtl+vL; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-208085-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208085-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7D94F28470E for ; Mon, 10 Jun 2024 11:38:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 399817E11E; Mon, 10 Jun 2024 11:38:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="wCWtl+vL" Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (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 8BFC8537E9; Mon, 10 Jun 2024 11:38:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718019504; cv=none; b=RV/rEhe00V38rCr5fkL66yawrU2VjBwqI9c5JWRSIlSBto/XJcWV+dguiSJnejVSFlDVqTQ6UR9u8W2sqBtIj6yKwgUn+Ty2Akwje95zSNLQRFWKmF1AJHvmKdv8wYpL+wMCgAGcIp712xRza+vEDHlCDLEE37LGwhUyL4wJvX0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718019504; c=relaxed/simple; bh=5zWnGlA/sZUI0df8LRl+1oE1aI/eFOMmPhqgCeKWOZo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ASL57zbMf7h0b80HT/oSJFYkH57IXatr0wiY8DCYZsfPy3otWZxFwEP9/uBH57zz826/zDVVW7aP7NPFYJFBpJ2CaNmWW8yVIy7dvPY+XDGd2gjUZS45pLOhP4fKVtcCwzedNONb+hWFN/p7GFTqtPBu+oQAQGCGHFzqk4tmD7A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=wCWtl+vL; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C903D66F; Mon, 10 Jun 2024 13:38:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1718019489; bh=5zWnGlA/sZUI0df8LRl+1oE1aI/eFOMmPhqgCeKWOZo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=wCWtl+vLmPgAClQslHn9349CQyDVcYNJK4opxIegxm76lxRhnk5BWCLPLkQhms7/y eRwgEBpHje8Y7A5PoVG6pS2iGiWQWSU34B9Sxoebd1zbF35ARiu1nKqZ7jKMHSAsrb 8NEzvWgyn4JuKNuTK+NBwP9nQQdg3u6bh+5aj/a4= Date: Mon, 10 Jun 2024 14:38:00 +0300 From: Laurent Pinchart To: Ricardo Ribalda Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, "hn.chen" , Hans Verkuil , Sergey Senozhatsky Subject: Re: [PATCH v10 1/6] media: uvcvideo: Support timestamp lists of any size Message-ID: <20240610113800.GQ18479@pendragon.ideasonboard.com> References: <20240323-resend-hwtimestamp-v10-0-b08e590d97c7@chromium.org> <20240323-resend-hwtimestamp-v10-1-b08e590d97c7@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20240323-resend-hwtimestamp-v10-1-b08e590d97c7@chromium.org> Hi Ricardo, Thank you for the patch. On Sat, Mar 23, 2024 at 10:48:02AM +0000, Ricardo Ribalda wrote: > The tail of the list lives at the position before the head. This is > mathematically noted as: > ``` > (head-1) mod size. > ``` > Unfortunately C, does not have a modulus operator, but a remainder > operator (%). > The reminder operation has a different result than the modulus if > (head -1) is a negative number and size is not a power of two. > > Adding size to (head-1) allows the code to run with any value of size. > > This does not change the current behaviour of the driver, as the size is > always a power of two, but avoid tedious debugging if we ever change its > size. > > Reviewed-by: Sergey Senozhatsky > Signed-off-by: Ricardo Ribalda Reviewed-by: Laurent Pinchart > --- > drivers/media/usb/uvc/uvc_video.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c > index 7cbf4692bd875..659c9e9880a99 100644 > --- a/drivers/media/usb/uvc/uvc_video.c > +++ b/drivers/media/usb/uvc/uvc_video.c > @@ -732,7 +732,7 @@ void uvc_video_clock_update(struct uvc_streaming *stream, > goto done; > > first = &clock->samples[clock->head]; > - last = &clock->samples[(clock->head - 1) % clock->size]; > + last = &clock->samples[(clock->head - 1 + clock->size) % clock->size]; > > /* First step, PTS to SOF conversion. */ > delta_stc = buf->pts - (1UL << 31); > -- Regards, Laurent Pinchart