Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp1882377rwi; Thu, 3 Nov 2022 10:05:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4LL5/RWVdWbXJMSDnFAt1l0rz9raaVmV+jN+VPKsRVrWf/bCFsrNHeYN1ymC0HjyZo+/xS X-Received: by 2002:a17:907:6d9b:b0:78d:f24b:e358 with SMTP id sb27-20020a1709076d9b00b0078df24be358mr29295840ejc.714.1667495129682; Thu, 03 Nov 2022 10:05:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667495129; cv=none; d=google.com; s=arc-20160816; b=aJrnKhkgYSlQSkVEK7nqzCIdYiCQhjeimIvDfWJdt7vaIFm3AaNg8QsBSRzvvXs/qc mrWvm8XoHqBp25yO89jn8lUuKQZv/Iacmhg2/bGP2561viZIYWIHNwrdU1tnd8hpxL7Q p/Ct0/Y0+K5qCLZBBmkgRKlNK026BemY/Z+T18bEsbYl89ODapNW79XaZmpTM9I+JJ0c YnI0kAFklw0XG+IWR49BTaqSaYYwflqa0ToEEa7pbE703rqUfX190K/YuSN1kAhsq/QC m5JMYCgEST1Fba9wAgUh09P8olFTi8ai7Vf7+fEvBQT2m6tOkZUtgP7zQvCRhfueqgR6 vG1w== 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=/ybiF9hMG300Px1O442DTixRO6cyKnlrebYwSIZbK9I=; b=M3LIc9HdsHspkhS7SjMBO30K4KGjkdpcQRdWIF1IQrwMnMXOtLUa1HVq0z7eIM05tm ESvacAG/GgjUbs3zczaa1DrwJ/HWNm+QbvwhFbk22MTFEGiCYaN2PrLfBCXoCbZCkRLS CO3oY+JW449O0/mFBnWLPivDsC9iETqe3TI67mZUGxN5uboz+Gok/pCMY71fIZXd1su5 iIfG67ifXcis0KdODCFjVuOfW7HArHF9zayvqltwiKm1RsxpSX80Gpbss56WYyE8GK7L zvkDc3dVp+XNQT9YWJuPbrmVyk0LLH7E3H9T4hUKG/ajSVYF8t7YpYroUyQfUSgrDNVx s/CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=PaCK0ftL; 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 eb6-20020a0564020d0600b0045ce40540ebsi2005425edb.269.2022.11.03.10.05.04; Thu, 03 Nov 2022 10:05:29 -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=PaCK0ftL; 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 S231768AbiKCQd4 (ORCPT + 97 others); Thu, 3 Nov 2022 12:33:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232274AbiKCQci (ORCPT ); Thu, 3 Nov 2022 12:32:38 -0400 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADDAF1D0FC; Thu, 3 Nov 2022 09:32:21 -0700 (PDT) Received: (Authenticated sender: paul.kocialkowski@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id E5D1324000A; Thu, 3 Nov 2022 16:32:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1667493140; 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=/ybiF9hMG300Px1O442DTixRO6cyKnlrebYwSIZbK9I=; b=PaCK0ftLWObcmWLmbGfLklGibseApJKFvoR8MLzaaJBR8E2ipkhwavOY4mxHbQAHdV+Z83 el5YxxkrwTWD1b+TZhSCrVVSsdO0PprZsjZdVBx4Eyn2ozKDfcjR9NcDmI+jTivun+Bx2Z yAYDPtwToLfKohFfpJLZV1jL7+IjUHeY5sDP7eSbaV1SsnEmIemzYUduKxw0tOA8Q2D4jX u8kHTPFHHH9tsUl6eekN8TNaZ8HqSlxCmnrmYtSNMRgTwi84Et1Y+UePhZAYsGiQgf6bdQ pAXgSlZuCSfJhAgS1wTAcK43M7okf2cXLUbvScHg6ahj3Z1qhKjYYB1UqnMJWQ== 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 v7 26/28] media: sun6i-csi: Add extra checks to the interrupt routine Date: Thu, 3 Nov 2022 17:31:11 +0100 Message-Id: <20221103163113.245462-27-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221103163113.245462-1-paul.kocialkowski@bootlin.com> References: <20221103163113.245462-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_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS 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.38.1