From nobody Thu Apr 2 17:17:48 2026 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 D41A73C3C1E; Fri, 27 Mar 2026 17:10:47 +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=1774631449; cv=none; b=oEUb2+tF6gg1u9/4Ndbx2iLWNjiTJiWsO8p5OfMIeg+vgM8REI6uClJlX9CKyluJuofCCAaKfPK70Q5m4ogvdPZ25MwYn0qfMkEvRbCDPTQWM2MIcbcE11rCwUEXY7yI0H7oqC28PIMZGMjfaIg5flM681i7Us02fF9YSaXYBnc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774631449; c=relaxed/simple; bh=qYNVJErGbpDMrNMDY0tRycGjHWbALYmvbRwfv/gRKvs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cieK1pyIe5c0AQ9hwpazHCvjKRutAg41F4NT3bCTfwuwf7ZWJu8ieyMCmO4Z3djtAqwraKVyDFbYT5m1KOPe8B3C+V8SS2qvchemLySE3iLvsIKUY6GayJA5nixLxXppFnR1pPF1XnFq3fWTpwxY72ArMP867hg1BneDVG9Degw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (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=QHWxbcOt; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="QHWxbcOt" Received: from [100.93.44.16] (net-93-65-100-155.cust.vodafonedsl.it [93.65.100.155]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4B44C3040; Fri, 27 Mar 2026 18:09:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1774631359; bh=qYNVJErGbpDMrNMDY0tRycGjHWbALYmvbRwfv/gRKvs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=QHWxbcOtHniFytO7Wv6i2m18FzT5C/zCrepBGDMECZr/8kmx5x0LfgtGLIcb71HMl bIysu1JKZ5pfprJEzzq830cwzvlsmAR5M5aVeucepkh/KvlrjMOacKYGgaabHsufbW Ukg5GP/Q8Waj5j3T7dg+Mptgh/pWrMdfKy4hOeGg= From: Jacopo Mondi Date: Fri, 27 Mar 2026 18:10:10 +0100 Subject: [PATCH 05/14] media: rzg2l-cru: Remove locking from start/stop routines 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-Transfer-Encoding: quoted-printable Message-Id: <20260327-b4-cru-rework-v1-5-3b7d0430f538@ideasonboard.com> References: <20260327-b4-cru-rework-v1-0-3b7d0430f538@ideasonboard.com> In-Reply-To: <20260327-b4-cru-rework-v1-0-3b7d0430f538@ideasonboard.com> To: Mauro Carvalho Chehab , Laurent Pinchart , Biju Das , Hans Verkuil , Sakari Ailus , Tommaso Merciai Cc: Daniel Scally , =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= , Lad Prabhakar , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jacopo Mondi , Jacopo Mondi X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2479; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=rDJiPzdHrlyY1cOGAeuzTJ0dhKGoLcCuHePAhuQK1sE=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBpxroJMlRhPcgp8xIoRJhQw9zKxd7KeaN/szIVM SoGTJ0qPuOJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaca6CQAKCRByNAaPFqFW PAgCEACbZdq/cT0GhFCHMNgl9sKfILIQsuNlVTMF7wxWW07MhMeGl+pAvlQh4cUECl16g7QSfjB 0UD+xmAMsHUazy0vMVej2y20RyF7ataIi8NRT6UdpGfu3svaIaTZX1M1wYflCXP/TVj6mnTXB/c n6fZHBFlxviVV9Wz9n7EmKhwaNQURqakPnNEUJqkhacB2xnHeXr9dYfAvBgendtMnUNriCbMH/N xX4HrGeRoFMq5umC4AonaFiv/x89EWUaqToes7nvwKgX8reamPDD1K+hSXsFu3YS+1fFzBtQwCF bCYbORPgvM4FBoA6NdDY5b3mertSF2ayp+tYBUr3dQScrlV8EqAtM7XTIsftrjMk7pkj/VKsozD ORCmnhuAqrieUiGJjbQDlBxUf3HuIB2P2UudOKlkHeKtkCxgq57PYerNppNQpDaCkKC/3E2jrIH DY8uJsJUWIM+038xdH6ifnFyjJVIwv6P8lavfk29SV9Zpo0H9WDGxVWyICcyV2o1PVtXtIB13/q xYYOK3efn+mMBUVnBWtr6ulmWTrvx6w9QOPFuot5hKhVFj78h9Cf4s72P/l6UZfA0RJc8DxNAah 3lp3h0844mbqv5qiV4vBV+N5t9pLDudp3Sq2i29cJs1IPvVik2kxAPdhSo0AMjLOHqhVxFcvOTR zf5u1C2IK0M/GKQ== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B From: Jacopo Mondi The start/stop streaming routines do not need to lock the whole function body against possible concurrent accesses to the CRU buffers or hardware registers. The stop function starts by disabling interrupts, and only this portion needs to be protected not to race against a possible IRQ. Once interrupts are disabled, nothing in the video device driver can race and once the peripheral has been disabled we can release all pending buffers. Signed-off-by: Jacopo Mondi Reviewed-by: Daniel Scally Reviewed-by: Lad Prabhakar Reviewed-by: Tommaso Merciai Tested-by: Tommaso Merciai --- drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c | 18 +++++---------= ---- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drive= rs/media/platform/renesas/rzg2l-cru/rzg2l-video.c index b041c72837c6..43b1d35fb963 100644 --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c @@ -341,23 +341,19 @@ bool rzg2l_fifo_empty(struct rzg2l_cru_dev *cru) void rzg2l_cru_stop_image_processing(struct rzg2l_cru_dev *cru) { unsigned int retries =3D 0; - unsigned long flags; u32 icnms; =20 - spin_lock_irqsave(&cru->qlock, flags); - - /* Disable and clear the interrupt */ - cru->info->disable_interrupts(cru); + scoped_guard(spinlock_irq, &cru->qlock) { + /* Disable and clear the interrupt */ + cru->info->disable_interrupts(cru); + } =20 /* Stop the operation of image conversion */ rzg2l_cru_write(cru, ICnEN, 0); =20 /* Wait for streaming to stop */ - while ((rzg2l_cru_read(cru, ICnMS) & ICnMS_IA) && retries++ < RZG2L_RETRI= ES) { - spin_unlock_irqrestore(&cru->qlock, flags); + while ((rzg2l_cru_read(cru, ICnMS) & ICnMS_IA) && retries++ < RZG2L_RETRI= ES) msleep(RZG2L_TIMEOUT_MS); - spin_lock_irqsave(&cru->qlock, flags); - } =20 icnms =3D rzg2l_cru_read(cru, ICnMS) & ICnMS_IA; if (icnms) @@ -401,8 +397,6 @@ void rzg2l_cru_stop_image_processing(struct rzg2l_cru_d= ev *cru) =20 /* Resets the image processing module */ rzg2l_cru_write(cru, CRUnRST, 0); - - spin_unlock_irqrestore(&cru->qlock, flags); } =20 static int rzg2l_cru_get_virtual_channel(struct rzg2l_cru_dev *cru) @@ -470,8 +464,6 @@ int rzg2l_cru_start_image_processing(struct rzg2l_cru_d= ev *cru) csi_vc =3D ret; cru->svc_channel =3D csi_vc; =20 - guard(spinlock_irqsave)(&cru->qlock); - /* Select a video input */ rzg2l_cru_write(cru, CRUnCTRL, CRUnCTRL_VINSEL(0)); =20 --=20 2.53.0