Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp674372rwe; Fri, 26 Aug 2022 12:04:57 -0700 (PDT) X-Google-Smtp-Source: AA6agR6owkKWAvvgUC81VLAHrBTTfBq1TciPTS0cM/111gnql4Dp2yxd0RW06jozByqEOMDaUOpS X-Received: by 2002:a17:902:d584:b0:173:19a2:b831 with SMTP id k4-20020a170902d58400b0017319a2b831mr4920152plh.126.1661540697545; Fri, 26 Aug 2022 12:04:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661540697; cv=none; d=google.com; s=arc-20160816; b=aK363aZDi9mujHcN8/4N3FrX9Ub+f94MyJs3HFI4n9tVJTnDSRrCFv5YTyl4qr1cJl QjeJLNh8Ng4j3ChcgLI3Sjzl68HsHK62qYtmnVEYAqvOOYxkhpFqTKPHOdqlBXE9R3FV ETQN+z9SvPRn2Eq4rFdSo+3+YorGEfiSmiYDI8FijD3uQgk559Jzb4QV2r9GTqFVGrFP 6O/QtOpWYSBCSTIB7Rv5RwkEvQEmV85MuNK1YWQV7F+B83fM1vCX1HedrxZHoZMsWjsP W55T12JEEez0AH7UJpeCUpTpHGS28SXbW2htL7A7OFBzvuXLA9KRSikjUdQ0FEFEDw6w Fe+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=exMkT/hiGFF3pOn5KCEAYUiJladoXUFR3sqm5Gxb2/c=; b=StCi/vFevkTDUuswj9tJ7h8vvD0ck2KsLDpoNxL1BXHB1FlUuJaVG9UEEqnkSyoE5a PfsZ/BAeyURLJDLdmjTWJ3xMi0jC1RcB3rbUJMz7wgEraID+DESqOBV1u1K9/gRHMWrj n9ZVPXOcyKF2EKt4V+XQ1NYwLfPa6Q3QywYsHI6WfSueUSubJu7bZ0axqfAuJ3TfgPdw BE1DqkXKWb7F1O1LTflwon4lhEereM2jJS799x/FLqbfKjHEbJ4ksTjRDSTkRwzI7dlH C3I/h/IK9PorXOqUekdYwcozeZKqCkyqem9XVVgMJ4kK3ZHpROCsr3+Wc5oqBF4n5vad sZ8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=P6UQxQBR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x65-20020a633144000000b00415ef8c15f1si2397921pgx.486.2022.08.26.12.04.45; Fri, 26 Aug 2022 12:04:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=P6UQxQBR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345180AbiHZShD (ORCPT + 99 others); Fri, 26 Aug 2022 14:37:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344546AbiHZSen (ORCPT ); Fri, 26 Aug 2022 14:34:43 -0400 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 776D0E68F4; Fri, 26 Aug 2022 11:33:53 -0700 (PDT) Received: (Authenticated sender: paul.kocialkowski@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 259BFFF807; Fri, 26 Aug 2022 18:33:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1661538832; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=exMkT/hiGFF3pOn5KCEAYUiJladoXUFR3sqm5Gxb2/c=; b=P6UQxQBRBP0wd/ocKfGVovHnLi3E2pjcpGlVBFLZrVwyCsENUbN0yfa9A52kxtme/33hUI Ax5KyHAAb0Kl1vtU9erk56ZWU8rfUGu4Dt5Jyq0aTxUAsi0WT8+woiSpHptTW+Hu7euhv1 ngj7B3AeNXyfBihUpwKH1X84kucO1saN9hFzAdubyXGoujJT34s4WLc3eQSDEYksZnFbmu JiTx35EkNM2o3qH0yw9N2wcSfdGqsoViAaMzPTtdt/sloyCKhp0NCNVdUAT2V5rrTC6ERN TaXWjuzVMhdsjtTNkzY46ucbZqKWAV4jzQsU9SRpz2M2rEglXGuNLDmEgTJk2Q== From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Cc: Yong Deng , Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Laurent Pinchart , Maxime Ripard , Thomas Petazzoni Subject: [PATCH v6 41/43] media: sun6i-csi: Add extra checks to the interrupt routine Date: Fri, 26 Aug 2022 20:32:38 +0200 Message-Id: <20220826183240.604834-42-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220826183240.604834-1-paul.kocialkowski@bootlin.com> References: <20220826183240.604834-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Check against the enabled bits and make sure capture is running before serving an interrupt, to add extra safety in the process. Signed-off-by: Paul Kocialkowski Acked-by: Jernej Skrabec --- drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c index eaf62cab0b64..46c5f98702e1 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c @@ -89,13 +89,17 @@ static void sun6i_csi_v4l2_cleanup(struct sun6i_csi_device *csi_dev) static irqreturn_t sun6i_csi_interrupt(int irq, void *private) { struct sun6i_csi_device *csi_dev = private; + bool capture_streaming = csi_dev->capture.state.streaming; struct regmap *regmap = csi_dev->regmap; - u32 status; + u32 status = 0, enable = 0; regmap_read(regmap, SUN6I_CSI_CH_INT_STA_REG, &status); + regmap_read(regmap, SUN6I_CSI_CH_INT_EN_REG, &enable); - if (!(status & 0xFF)) + if (!status) return IRQ_NONE; + else if (!(status & enable) || !capture_streaming) + goto complete; if ((status & SUN6I_CSI_CH_INT_STA_FIFO0_OF) || (status & SUN6I_CSI_CH_INT_STA_FIFO1_OF) || @@ -116,6 +120,7 @@ static irqreturn_t sun6i_csi_interrupt(int irq, void *private) if (status & SUN6I_CSI_CH_INT_STA_VS) sun6i_csi_capture_sync(csi_dev); +complete: regmap_write(regmap, SUN6I_CSI_CH_INT_STA_REG, status); return IRQ_HANDLED; -- 2.37.1