From patchwork Fri Apr 15 15:28:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 12815141 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 90D11C433F5 for ; Fri, 15 Apr 2022 16:00:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pzSPklM5yeC6+Cp2768lF56mvii/FZUTehDuN/Ock5Q=; b=SkJmLOtwvfU9DG Y8hl7MAqQoj1yGEJqoKiDKX9CGE4SCdzmHY94wbWMC3dHlI58CWxkOHZcyN9HVbIqE1/Cz7EjWGh6 klpKcDPnxic9ufnSvPpAJF78uHM4iFc00rfQyYaGKri7l492Off0dLDyQSQav1kGMRJ8N2KpHaO5x O66+16bUuy/NFniorNWTUnkQYTNHEEG6UzYfJCueV6CL/iABSSMATvy2FhSd8k3c8WpMv+D7lxDfr DIpwH+km8Z4n5d3wiyuITxp//chnYIwWES3keDFUHpT2pLelgEoWy3GkyqtUyvqvnP9U0xdmCmVXv VUvyZHG7qyc/YIWFXbBQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nfOLh-00AkIo-6q; Fri, 15 Apr 2022 15:59:06 +0000 Received: from relay4-d.mail.gandi.net ([217.70.183.196]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nfNsj-00AXfu-AK for linux-arm-kernel@lists.infradead.org; Fri, 15 Apr 2022 15:29:16 +0000 Received: (Authenticated sender: paul.kocialkowski@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id D38A1E0008; Fri, 15 Apr 2022 15:29:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1650036547; 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=a4cnzWuTGffjryQBqgGBFOHFWDCSqhQFuFNHTBbesc8=; b=XCVcJmrQqhxE4TzSjVzyggVUK/fFX8TRrpguo+t7PW1LjswkIxkA0cRKrw7LxabH5vqx7I W63h81hAagaar/3XXMrrmRjndAwFXluaYP0X4Bgbx9A7az5FSb8sCB8bMRMxgr+pM6YvU7 +NPw+kAmxS+zbBDGV7k76u9OERUb+2V5AGQRvc7ZnIxY6S69lWjdxfYMJL58Icb+M5TPXM Z9RrEsF34TOJ2uCJiEG4sybHHU9mKY1lx9HGJkHYZn8WRTULXpMck882bIxngGJJgPakNS FxtV34AdpZBhAqgz1ymHtRqVuGhszOaHLCdPZKR0yvWOHTL1s5B6Wmpr9Ihgfw== 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 v4 41/45] media: sun6i-csi: Add extra checks to the interrupt routine Date: Fri, 15 Apr 2022 17:28:07 +0200 Message-Id: <20220415152811.636419-42-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20220415152811.636419-1-paul.kocialkowski@bootlin.com> References: <20220415152811.636419-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220415_082909_540839_F95E7B3E X-CRM114-Status: GOOD ( 12.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 43b6557b3207..3963a88a2e0b 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c @@ -105,13 +105,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) || @@ -132,6 +136,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;