From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=213.167.242.64 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796289569; b=V7VtLmGIY1JIY8F2TEIOJCWZyOC5jznouroNBcOpwZyfvexRty6gtbF1ER5cQyhragI4 eCyfzQ7sF4ldEqihdlb+P9vaWkc45ad5ytxRCXG//4MZy+tTsQYzm6jsULTNK2wu3NE6p KKZp+8IAw327abS5nGM9eSe5Adu8qDLcH+4c2XtpTEJRn7cHlbEdX1+X+KWLjL8CtbhZ2 6lBL2tFictif3u642pJOyBbxibMKPDmN/h+GIZCVEtMIGhEYnldk58G+SfQqY5AKZ0VXj LV2QJnM9DHoPUW3f5FpXa2mdN5b3IBxNtY9Bf0TXyLxejUdVO9wnEH09ThxI35geAhQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796289569; h=DMARC-Filter:Received:DKIM-Signature:Date:From:To:Cc:Subject: Message-ID:References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To; bh=oC6zlLZ4dH7eaQ9z1t/DRh6bUjzs7LqwqxzzMdLpmvw=; b=G50NdiHQfm6XrkQZm2pDoHv7plA21Hdk1X/bR6/Yu2j5Cc50iABC0yxXcmfzroXhk0Da Yu/Vj2jr/zKGY1LWt6XPbwVSsYrLXl4F21Hx3Np5w5ssyLqpDB0+H8WyQ1hjKXtL6LIeL Tl/bitUJBoIZsOGJY1puslJ+KG7xYGOfQJAmUT2bNa3JprfGR2KE67a86AyUIKoPH4Pbo wCmfEVaLs0ivq/iQrhKRs/D6XVIjLyjc7E6p58VQuauNukiDbqtXTIrB9karMOYRyP51s elJ+rVRVZFSE7DeMj0nFKp6jhG70jEUeLkQihLn4qgLAmgo1VXBJcZmYoIy8cASthCw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass header.d=ideasonboard.com header.i=@ideasonboard.com header.a=rsa-sha256 header.s=mail header.b=GTODtos5; arc=none smtp.remote-ip=213.167.242.64 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (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 E5878606A688; Thu, 3 Dec 2026 09:19:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E5878606A688 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.a=rsa-sha256 header.s=mail header.b=GTODtos5 Received: from ideasonboard.com (unknown [93.65.100.155]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3EF7782A; Thu, 3 Dec 2026 10:16:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1796289406; bh=yymc/ttLBGNyoKB+HWailB9vluQA6WykzS27rDdeP0g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GTODtos5ngJZNFgauEqpT03YkVGZLhTsJX5jJMzM9fwF+7d1aFXq7HAEnJSywgtZg PJ7I4Nfdhq4n/aEoXUbDyKj7EStjtNbmTvn6OtkvLbUEtIw7vYggRwifDL/td2uNb/ YG5D+xBpLZx34uDRDU0uBX78v06SueC99mpNTzwE= Date: Thu, 3 Dec 2026 10:19:22 +0100 From: Jacopo Mondi To: Yaohan Li Cc: Daniel Scally , Jacopo Mondi , Mauro Carvalho Chehab , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] media: renesas: rzv2h-ivc: stop interrupt before disabling clocks on suspend Message-ID: References: <20261203085319.2392838-1-shunsheng1218@gmail.com> X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20261203085319.2392838-1-shunsheng1218@gmail.com> On Thu, Dec 03, 2026 at 04:53:19PM +0800, Yaohan Li wrote: > rzv2h_ivc_runtime_resume() enables the clocks, deasserts resets, unmasks > RZV2H_IVC_REG_FM_INT_EN, and finally requests ivc->irqnum. > > rzv2h_ivc_runtime_suspend() tears these down in the wrong order: it > asserts resets and disables all three clocks while RZV2H_IVC_REG_FM_INT_EN > is still enabled and before calling free_irq(). If an interrupt arrives How can an interrupt arrive ater the reset signal has been asserted ? > or is still running during that window, rzv2h_ivc_isr() can call > rzv2h_ivc_transfer_buffer() and write MMIO registers while the block is > held in reset with its clocks gated. > > Mask RZV2H_IVC_REG_FM_INT_EN and free ivc->irqnum before asserting resets > and disabling the clocks, matching the resume path in reverse. > > Fixes: f0b3984d821b ("media: platform: Add Renesas Input Video Control block driver") > Cc: stable@vger.kernel.org > Signed-off-by: Yaohan Li > --- > Based on v7.4-rc5 (fe6ff8d5d675); applies cleanly on media-committers fixes > and next. Scoped strictly to the rzv2h_ivc_runtime_suspend() teardown > order; active-remove / V4L2 lifetime is left untouched. > > I don't have physical Renesas RZ/V2H hardware, so I tested this in QEMU > (x86_64, KASAN + PROVE_LOCKING) with the in-tree rzv2h-ivc.ko bound to a > platform device backed by reserved MMIO, three CCF clk_hw clocks, and a > virtual IRQ across 5 runtime suspend/resume and system force-suspend/resume > cycles (unmodified driver disables all three clocks while FM_INT_EN is still > set and ivc->irqnum is still bound; patched clears FM_INT_EN and frees the > IRQ first with 0 KASAN or lockdep warnings). Also build-tested on x86_64 > and arm64 with W=1 (0 warnings). > > AI assistance: Claude and Gemini helped check the runtime PM ordering, write > the QEMU test module, and draft the changelog. I reviewed the driver code, > test logs, and final patch myself. > > drivers/media/platform/renesas/rzv2h-ivc/rzv2h-ivc-dev.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/media/platform/renesas/rzv2h-ivc/rzv2h-ivc-dev.c b/drivers/media/platform/renesas/rzv2h-ivc/rzv2h-ivc-dev.c > index e2a14ebeb1141..937891e45e38b 100644 > --- a/drivers/media/platform/renesas/rzv2h-ivc/rzv2h-ivc-dev.c > +++ b/drivers/media/platform/renesas/rzv2h-ivc/rzv2h-ivc-dev.c > @@ -164,9 +164,10 @@ static int rzv2h_ivc_runtime_suspend(struct device *dev) > { > struct rzv2h_ivc *ivc = dev_get_drvdata(dev); > > + rzv2h_ivc_write(ivc, RZV2H_IVC_REG_FM_INT_EN, 0x0); > + free_irq(ivc->irqnum, dev); > reset_control_bulk_assert(ARRAY_SIZE(ivc->resets), ivc->resets); > clk_bulk_disable_unprepare(ARRAY_SIZE(ivc->clks), ivc->clks); > - free_irq(ivc->irqnum, dev); > > return 0; > } > -- > 2.34.1 >