Message ID | 20231205-rkisp-irq-fix-v1-2-f4045c74ba45@ideasonboard.com (mailing list archive) |
---|---|
State | Accepted |
Headers |
Received: from am.mirrors.kernel.org ([147.75.80.249]) by www.linuxtv.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <linux-media+bounces-1630-patchwork=linuxtv.org@vger.kernel.org>) id 1rAQVd-00BN8P-Fd for patchwork@linuxtv.org; Tue, 05 Dec 2023 08:10:25 +0000 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 am.mirrors.kernel.org (Postfix) with ESMTPS id D8DE01F21565 for <patchwork@linuxtv.org>; Tue, 5 Dec 2023 08:10:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A8A7A3BB5F; Tue, 5 Dec 2023 08:10:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="PnaOPacs" X-Original-To: linux-media@vger.kernel.org Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C15AA127; Tue, 5 Dec 2023 00:10:07 -0800 (PST) Received: from [127.0.1.1] (91-158-149-209.elisa-laajakaista.fi [91.158.149.209]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2FF0CEEE; Tue, 5 Dec 2023 09:09:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1701763764; bh=WNFwBf6lfujD0ZQ+VOP/UJchIYnz0NMJp9HloMbZytA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=PnaOPacsNt55CsSxBteS0KdXjZuHHlLbjuZw2U3XpRZbabFJD3MEq1VFag4cIAX0a G+DyM175on5WDyMg4NpXol3r2XHfXQO7jcaH2w8f/wEZhrPo/utPUtbZ7HbU6EUCsm YRpjZvs+dlf4TcgalR58edCgbVZG5D86YwSQPKRI= From: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Date: Tue, 05 Dec 2023 10:09:33 +0200 Subject: [PATCH 2/4] media: rkisp1: Fix IRQ handler return values Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: <linux-media.vger.kernel.org> List-Subscribe: <mailto:linux-media+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-media+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231205-rkisp-irq-fix-v1-2-f4045c74ba45@ideasonboard.com> References: <20231205-rkisp-irq-fix-v1-0-f4045c74ba45@ideasonboard.com> In-Reply-To: <20231205-rkisp-irq-fix-v1-0-f4045c74ba45@ideasonboard.com> To: Dafna Hirschfeld <dafna@fastmail.com>, Laurent Pinchart <laurent.pinchart@ideasonboard.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Heiko Stuebner <heiko@sntech.de>, Paul Elder <paul.elder@ideasonboard.com> Cc: Alexander Stein <alexander.stein@ew.tq-group.com>, kieran.bingham@ideasonboard.com, umang.jain@ideasonboard.com, aford173@gmail.com, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=1603; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=WNFwBf6lfujD0ZQ+VOP/UJchIYnz0NMJp9HloMbZytA=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBlbtrYHUyIcw9QFvbFkSIrfTb+8f/fz4Git+i/W 6Gu5IM4MJqJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZW7a2AAKCRD6PaqMvJYe 9dKSEACJtMy5hagG9Dgbka6/kKGcekwuWk4WVA+I0YyWHK3zz6ryIxYta3z/0swDdSIz7cAg58m af6c5kr2Mi5CgLYgh4sokjBBQOaX3AFIz0rGSxz2J/KFdQZOz4Yq9BBciF8qQBpetAIzDgcxgkq nEGmykPUCKesFrjk1gQOFIlq4EMbg0yfIuCs6E0Bc52Mu0yEy+91sgiCqwX76AOS62xaPUMVndJ vQB/A//jHQxdn5zeNtoUYlXcnpl7BT5CBQcIaEUTiMSCS29PZvBZ/kqmyFXQ4MasjBkBDGrHB6D GFc7xbsYYzqTn+tzg8Jcw7fZEPKoDV6Dg3eTo0biDVSCyu4l8CRFODZU+LcvXj+I7RmAJNOVgw+ qGbCKH1iE/IbygRVFS3nWQuKIp4rO0JjTBH8fbspQifIsjuk0DYeJj4DzqlpmnWbvNbobfc/kzq lxrCrLrEm7EJgaOx3Ww4iaE0XoFKzkkGx7TnBoX79ywepqARu6EWgb6ejdkd5rhhGn5aAPdVAH0 j7J6QM0mH41FwAky6Gzu5AjCwhUndC3p6zZy2wUQB4VW4zG9acoueE3xuXB3IUABBVELQeBs37v ZNaCMzxlAg4v/GpDtZTDoREqphZKSmtjvxSOQwNgdNH44JI2UPvm7xvK6THnIAQ49HuRYw6XYTS SfnS5jlZ1/b/xAQ== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 X-LSpam-Score: -4.8 (----) X-LSpam-Report: No, score=-4.8 required=5.0 tests=BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3 autolearn=ham autolearn_force=no |
Series |
media: rkisp1: Fix IRQ related issues
|
|
Commit Message
Tomi Valkeinen
Dec. 5, 2023, 8:09 a.m. UTC
The IRQ handler rkisp1_isr() calls sub-handlers, all of which returns an
irqreturn_t value, but rkisp1_isr() ignores those values and always
returns IRQ_HANDLED.
Fix this by collecting the return values, and returning IRQ_HANDLED or
IRQ_NONE as appropriate.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
Comments
On Tue, Dec 5, 2023 at 2:10 AM Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> wrote: > > The IRQ handler rkisp1_isr() calls sub-handlers, all of which returns an > irqreturn_t value, but rkisp1_isr() ignores those values and always > returns IRQ_HANDLED. > > Fix this by collecting the return values, and returning IRQ_HANDLED or > IRQ_NONE as appropriate. > > Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> > --- > drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c | 18 ++++++++++++++---- > 1 file changed, 14 insertions(+), 4 deletions(-) > > diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c > index 76f93614b4cf..1d60f4b8bd09 100644 > --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c > +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c > @@ -445,17 +445,27 @@ static int rkisp1_entities_register(struct rkisp1_device *rkisp1) > > static irqreturn_t rkisp1_isr(int irq, void *ctx) > { > + irqreturn_t ret; > + > /* > * Call rkisp1_capture_isr() first to handle the frame that > * potentially completed using the current frame_sequence number before > * it is potentially incremented by rkisp1_isp_isr() in the vertical > * sync. > */ > - rkisp1_capture_isr(irq, ctx); > - rkisp1_isp_isr(irq, ctx); > - rkisp1_csi_isr(irq, ctx); > > - return IRQ_HANDLED; > + ret = IRQ_NONE; > + > + if (rkisp1_capture_isr(irq, ctx) == IRQ_HANDLED) > + ret = IRQ_HANDLED; > + > + if (rkisp1_isp_isr(irq, ctx) == IRQ_HANDLED) > + ret = IRQ_HANDLED; > + > + if (rkisp1_csi_isr(irq, ctx) == IRQ_HANDLED) > + ret = IRQ_HANDLED; > + It seems like we're throwing away the value of ret each time the subsequent if statement is evaluated. Whether or not they return didn't matter before, and the only one that seems using the return code is the last one. Wouldn't it be simpler to use ret = rkisp1_capture_isr(irq, ctx), ret = rkisp1_isp_isr(irq, ctx) and ret = rkisp1_csi_isr(irq, ctx) if we care about the return code? How do you expect this to return if one of the first two don't return IRQ_HANDLED? adam > + return ret; > } > > static const char * const px30_isp_clks[] = { > > -- > 2.34.1 >
On 05/12/2023 13:57, Adam Ford wrote: > On Tue, Dec 5, 2023 at 2:10 AM Tomi Valkeinen > <tomi.valkeinen@ideasonboard.com> wrote: >> >> The IRQ handler rkisp1_isr() calls sub-handlers, all of which returns an >> irqreturn_t value, but rkisp1_isr() ignores those values and always >> returns IRQ_HANDLED. >> >> Fix this by collecting the return values, and returning IRQ_HANDLED or >> IRQ_NONE as appropriate. >> >> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> >> --- >> drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c | 18 ++++++++++++++---- >> 1 file changed, 14 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c >> index 76f93614b4cf..1d60f4b8bd09 100644 >> --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c >> +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c >> @@ -445,17 +445,27 @@ static int rkisp1_entities_register(struct rkisp1_device *rkisp1) >> >> static irqreturn_t rkisp1_isr(int irq, void *ctx) >> { >> + irqreturn_t ret; >> + >> /* >> * Call rkisp1_capture_isr() first to handle the frame that >> * potentially completed using the current frame_sequence number before >> * it is potentially incremented by rkisp1_isp_isr() in the vertical >> * sync. >> */ >> - rkisp1_capture_isr(irq, ctx); >> - rkisp1_isp_isr(irq, ctx); >> - rkisp1_csi_isr(irq, ctx); >> >> - return IRQ_HANDLED; >> + ret = IRQ_NONE; >> + >> + if (rkisp1_capture_isr(irq, ctx) == IRQ_HANDLED) >> + ret = IRQ_HANDLED; >> + >> + if (rkisp1_isp_isr(irq, ctx) == IRQ_HANDLED) >> + ret = IRQ_HANDLED; >> + >> + if (rkisp1_csi_isr(irq, ctx) == IRQ_HANDLED) >> + ret = IRQ_HANDLED; >> + > > It seems like we're throwing away the value of ret each time the > subsequent if statement is evaluated. Whether or not they return > didn't matter before, and the only one that seems using the return > code is the last one. > > Wouldn't it be simpler to use ret = rkisp1_capture_isr(irq, ctx), ret > = rkisp1_isp_isr(irq, ctx) and ret = rkisp1_csi_isr(irq, ctx) if we > care about the return code? > > How do you expect this to return if one of the first two don't return > IRQ_HANDLED? I'm sorry, I don't quite follow what you mean. Can you elaborate a bit? We want the rkisp1_isr() to return IRQ_NONE if none of the sub-handlers handled the interrupt. Otherwise, if any of the sub-handlers return IRQ_HANDLED, rkisp1_isr() returns IRQ_HANDLED. Tomi
Hi Tomi, Thank you for the patch. On Tue, Dec 05, 2023 at 10:09:33AM +0200, Tomi Valkeinen wrote: > The IRQ handler rkisp1_isr() calls sub-handlers, all of which returns an > irqreturn_t value, but rkisp1_isr() ignores those values and always > returns IRQ_HANDLED. > > Fix this by collecting the return values, and returning IRQ_HANDLED or > IRQ_NONE as appropriate. > > Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> > --- > drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c | 18 ++++++++++++++---- > 1 file changed, 14 insertions(+), 4 deletions(-) > > diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c > index 76f93614b4cf..1d60f4b8bd09 100644 > --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c > +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c > @@ -445,17 +445,27 @@ static int rkisp1_entities_register(struct rkisp1_device *rkisp1) > > static irqreturn_t rkisp1_isr(int irq, void *ctx) > { > + irqreturn_t ret; irqreturn_t ret = IRQ_NONE; > + > /* > * Call rkisp1_capture_isr() first to handle the frame that > * potentially completed using the current frame_sequence number before > * it is potentially incremented by rkisp1_isp_isr() in the vertical > * sync. > */ > - rkisp1_capture_isr(irq, ctx); > - rkisp1_isp_isr(irq, ctx); > - rkisp1_csi_isr(irq, ctx); > > - return IRQ_HANDLED; > + ret = IRQ_NONE; And drop this. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > + > + if (rkisp1_capture_isr(irq, ctx) == IRQ_HANDLED) > + ret = IRQ_HANDLED; > + > + if (rkisp1_isp_isr(irq, ctx) == IRQ_HANDLED) > + ret = IRQ_HANDLED; > + > + if (rkisp1_csi_isr(irq, ctx) == IRQ_HANDLED) > + ret = IRQ_HANDLED; > + > + return ret; > } > > static const char * const px30_isp_clks[] = {
On Tue, Dec 5, 2023 at 6:02 AM Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> wrote: > > On 05/12/2023 13:57, Adam Ford wrote: > > On Tue, Dec 5, 2023 at 2:10 AM Tomi Valkeinen > > <tomi.valkeinen@ideasonboard.com> wrote: > >> > >> The IRQ handler rkisp1_isr() calls sub-handlers, all of which returns an > >> irqreturn_t value, but rkisp1_isr() ignores those values and always > >> returns IRQ_HANDLED. > >> > >> Fix this by collecting the return values, and returning IRQ_HANDLED or > >> IRQ_NONE as appropriate. > >> > >> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> > >> --- > >> drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c | 18 ++++++++++++++---- > >> 1 file changed, 14 insertions(+), 4 deletions(-) > >> > >> diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c > >> index 76f93614b4cf..1d60f4b8bd09 100644 > >> --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c > >> +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c > >> @@ -445,17 +445,27 @@ static int rkisp1_entities_register(struct rkisp1_device *rkisp1) > >> > >> static irqreturn_t rkisp1_isr(int irq, void *ctx) > >> { > >> + irqreturn_t ret; > >> + > >> /* > >> * Call rkisp1_capture_isr() first to handle the frame that > >> * potentially completed using the current frame_sequence number before > >> * it is potentially incremented by rkisp1_isp_isr() in the vertical > >> * sync. > >> */ > >> - rkisp1_capture_isr(irq, ctx); > >> - rkisp1_isp_isr(irq, ctx); > >> - rkisp1_csi_isr(irq, ctx); > >> > >> - return IRQ_HANDLED; > >> + ret = IRQ_NONE; > >> + > >> + if (rkisp1_capture_isr(irq, ctx) == IRQ_HANDLED) > >> + ret = IRQ_HANDLED; > >> + > >> + if (rkisp1_isp_isr(irq, ctx) == IRQ_HANDLED) > >> + ret = IRQ_HANDLED; > >> + > >> + if (rkisp1_csi_isr(irq, ctx) == IRQ_HANDLED) > >> + ret = IRQ_HANDLED; > >> + > > > > It seems like we're throwing away the value of ret each time the > > subsequent if statement is evaluated. Whether or not they return > > didn't matter before, and the only one that seems using the return > > code is the last one. > > > > Wouldn't it be simpler to use ret = rkisp1_capture_isr(irq, ctx), ret > > = rkisp1_isp_isr(irq, ctx) and ret = rkisp1_csi_isr(irq, ctx) if we > > care about the return code? > > > > How do you expect this to return if one of the first two don't return > > IRQ_HANDLED? > > I'm sorry, I don't quite follow what you mean. Can you elaborate a bit? > > We want the rkisp1_isr() to return IRQ_NONE if none of the sub-handlers > handled the interrupt. Otherwise, if any of the sub-handlers return > IRQ_HANDLED, rkisp1_isr() returns IRQ_HANDLED. OK. I understand your explanation. I retract my comment. I'll try to test this series tonight on my imx8mp adam > > Tomi >
diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index 76f93614b4cf..1d60f4b8bd09 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -445,17 +445,27 @@ static int rkisp1_entities_register(struct rkisp1_device *rkisp1) static irqreturn_t rkisp1_isr(int irq, void *ctx) { + irqreturn_t ret; + /* * Call rkisp1_capture_isr() first to handle the frame that * potentially completed using the current frame_sequence number before * it is potentially incremented by rkisp1_isp_isr() in the vertical * sync. */ - rkisp1_capture_isr(irq, ctx); - rkisp1_isp_isr(irq, ctx); - rkisp1_csi_isr(irq, ctx); - return IRQ_HANDLED; + ret = IRQ_NONE; + + if (rkisp1_capture_isr(irq, ctx) == IRQ_HANDLED) + ret = IRQ_HANDLED; + + if (rkisp1_isp_isr(irq, ctx) == IRQ_HANDLED) + ret = IRQ_HANDLED; + + if (rkisp1_csi_isr(irq, ctx) == IRQ_HANDLED) + ret = IRQ_HANDLED; + + return ret; } static const char * const px30_isp_clks[] = {