From patchwork Wed Dec 6 10:12:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 174453 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4005893vqy; Wed, 6 Dec 2023 02:13:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IFuFJIS37C8zovWJejb8ZPGxW8H4650J/k/aoW+66HaUwe2G43Hc6rvxTcdCTyRwP6Ofoo5 X-Received: by 2002:a17:902:ef85:b0:1d0:7f06:1751 with SMTP id iz5-20020a170902ef8500b001d07f061751mr607666plb.79.1701857597121; Wed, 06 Dec 2023 02:13:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701857597; cv=none; d=google.com; s=arc-20160816; b=o2fIuCcHvTAeQXS423zS8sEFN9yl2CLxHjk7w9DOTJv0M+XMVPgm6RH17UlAwpjhIg rEmqDSO80ebf/BqP7nTqN1W1YCc7U+qk0+V9NByqJqdhLI/CLGqKsge7k7TL+Q6CfLNE W2ZuiE/d8pkBSSS17TlYOaM2ke5pfxXqWxE6dDbQqCjjW9WEXwWuwTN11NOepbY0COqo r7abxDEREFQp0jfDO+TaroVmIYMSI061K1JLCQbg48nGaRQZSb/5FfAekBuafrfCdx0F cWj0ff6lIeX6k4+fegSFIjZ3IdZXjGI5aQglsKnNNBQMUN2qVXinWlaA3FlnW4pauwMu ZTiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=Ry9R6yyPBnVMk6f21d8y/r5YOO3GFQR+ubLUeW5VHwU=; fh=6fL1NhFCGI+wAVvsHH1pL+P1muGn2uwGLcwd3RTuFww=; b=rKH98o8ogcl4NtAwVRO6ZBg3zlII6MVpSK+WkDe7BMi+ApnQ8h+fqwvxXq4PZ9IYkE DBW/toh12aagdTNtqhaw/CXdY1E0xT/nKkm9MamNGRnHVBzY3W2YCt9X5z1lVfJh3f1O r7f/mvBeJ3znfFQOvg84Hrpr+qb/23YsL1KOBri5s4gJJX3xqVDogJpCpbZH0k26p+Pk K5RlrBNEeFsZphI1J3XYQpkoBfooK9OoMV6uDpdAPVIaySDkh9tHIFpu896V1uqS3Fj6 Z4tAptQQdPLhImafIFAXtCfn3Zl9RQhBr8Mpq8tv1XV2x8GbUC7oFLLauXnEtI8yLjHL rsqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=LwVWe7fY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id h6-20020a170902f54600b001d0231f5e30si2376164plf.295.2023.12.06.02.13.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 02:13:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=LwVWe7fY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 32BDB80BB3CB; Wed, 6 Dec 2023 02:13:14 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377622AbjLFKMx (ORCPT + 99 others); Wed, 6 Dec 2023 05:12:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377550AbjLFKMt (ORCPT ); Wed, 6 Dec 2023 05:12:49 -0500 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 847F9D46; Wed, 6 Dec 2023 02:12:54 -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 D3FFB14DC; Wed, 6 Dec 2023 11:12:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1701857531; bh=FsHDUhUOSdmxO1qno4l01PDWe1nNLgupoeHmIzcStq0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=LwVWe7fYRMeptio1qhiK7QyUSytVlcl8HZexC+03MTX0Ai/LY/NOYTIgzk4IKyDCF W7ZO/hV36GBLi7DOq4B09njNrCAS8B4U+YWNJTTixxl9lakF1PDaLopc0ycamnzhUg nvvPYthYsZEirxkRwvlYA1LW5091IxL7VHuTIQQk= From: Tomi Valkeinen Date: Wed, 06 Dec 2023 12:12:28 +0200 Subject: [PATCH v2 1/4] media: rkisp1: Drop IRQF_SHARED MIME-Version: 1.0 Message-Id: <20231206-rkisp-irq-fix-v2-1-6ba4185eeb1f@ideasonboard.com> References: <20231206-rkisp-irq-fix-v2-0-6ba4185eeb1f@ideasonboard.com> In-Reply-To: <20231206-rkisp-irq-fix-v2-0-6ba4185eeb1f@ideasonboard.com> To: Dafna Hirschfeld , Laurent Pinchart , Mauro Carvalho Chehab , Heiko Stuebner , Paul Elder Cc: Alexander Stein , 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 X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=1223; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=FsHDUhUOSdmxO1qno4l01PDWe1nNLgupoeHmIzcStq0=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBlcEkg4oQWDIpxgRjng5riAxA98dypRcWlQusOt gHRf/zsXYaJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZXBJIAAKCRD6PaqMvJYe 9Qt2D/9VM6a4+9d6s6OGE5LzaUWHgDu2WoXfUkyZ+cD9Zb65uEiK6uQxQJRa7OEfRqn7Us0XlG9 O56i09/y211GvZiwC4Q/CJlN7slXeGor51/DQsMvaEjmdeTwupE8XJ4Kp5Xb8IfkigKd8DcD6Ok oH/GFRJ6YA95YwQDnd7s3fVxawUE9t/z6jYCtF56e7cRJ9Tpzf/dXM5ebb8Ymiku0K4RCZpjuUr K8mTjmTacegvUqPofVSc6DJyoaqUucYfEpbTdYAilz7fqpLaLL0djdjytER7y4RGkv7CiuB46Dx lZdu9KXd1YHMrYJ02un7ETntsbO6Y9lg1lf4tFsyw2rU+lGtZlqBjeEFUbfFn1KkcXKkn3ubv5A 7SCe1udyuRXV3tinIZ+oAGG9p1hLrBn1OwwHNLhxvYx0eDcKLMrwleRG7EhWe9WL1TNe6V/Ir9V iaJkQv919QYja1YKjjM7gnIZUZXM8qclZYVAb7P7XFfvPKOUTU8NH1Pa7Z0cahSvXmKdx3ZoK/A 2WU0EK8+c4IVeJskD0I/oFzL/BUJMEl8LmyH4UpItj15RKAFzX5kjALNkC4fEm8bnskkmpVojT7 J6zMWDC8ZpYY23v8iqK3Qv6JpJY8z89dKvPDVGpSA+aIyOqUZfm8AJMPLZYujbVVAombu0D4zQl qFV4XmjbLpJIIoQ== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 06 Dec 2023 02:13:14 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784527031797459721 X-GMAIL-MSGID: 1784527031797459721 In all known platforms the ISP has dedicated IRQ lines, but for some reason the driver uses IRQF_SHARED. Supporting IRQF_SHARED properly requires handling interrupts even when our device is disabled, and the driver does not handle this. To avoid adding such code, and to be sure the driver won't accidentally be used in a platform with shared interrupts, let's drop the IRQF_SHARED flag. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index 2b9886fd0800..d4950294b7b9 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -573,7 +573,7 @@ static int rkisp1_probe(struct platform_device *pdev) if (irq < 0) return irq; - ret = devm_request_irq(dev, irq, info->isrs[i].isr, IRQF_SHARED, + ret = devm_request_irq(dev, irq, info->isrs[i].isr, 0, dev_driver_string(dev), dev); if (ret) { dev_err(dev, "request irq failed: %d\n", ret); From patchwork Wed Dec 6 10:12:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 174452 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4005853vqy; Wed, 6 Dec 2023 02:13:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IE7qT4XZ+obXbYqGMifFmWcFSQV/YjI3c/9UqG4y7S7T+pVj6RhLhkuafLkdRF4EBGpiFn5 X-Received: by 2002:a92:d68f:0:b0:35d:6991:a535 with SMTP id p15-20020a92d68f000000b0035d6991a535mr987774iln.30.1701857593741; Wed, 06 Dec 2023 02:13:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701857593; cv=none; d=google.com; s=arc-20160816; b=Lygk5RNxafI6z/tI2sbSrRDs/5kXZXSCoV1sz9nN9A3hYwS7cPAP5q2XA8ZIUcJyrb d9PbwV4zDx7Hpa8sObpRBOI8Au/XzN5kbiofZnwtBPUIM8qSVPjHz5RUwDeujhoS8gZj U4gX8Wtrc5+2oPs/OGTB5lVB4g8VHkTFArCcjTsQ3yIVFrp9OXq57VXw11k1WHS3ZjZO duOaq9hbCGCX2awnOXNCZaCQVKZL5Rw64SoTu71GH8FWHImlISSvQXrRQgjwx1oZ56CM etzAPqIiiO03aQljGbonz4NIRugemBfnqWWs4NlIQ/xgAx5vmuz9lW0REjZX1mgN26kX RW0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=st3yNcNWgRRruLRtw67rBI8I3dsxd5qa7XH85FT91SQ=; fh=6fL1NhFCGI+wAVvsHH1pL+P1muGn2uwGLcwd3RTuFww=; b=XIivaNUw05BYdmJy1NWg1hN6CZm4RmUuBhAKBtTRgov62wnGV+hlrrcU3lLO+2LAo7 LkzfLr84qisH32cJN3++d2b+FVD0MmOXAata7Uhe8JrS4nIaw1Rs/rgxo3yQj1ZPUYTY N8+KBTvR0R/JQ62QrdUX/YnZv8g6RNH0nV4udY0pWNNUTuZvKhujf12OqmoukwNHkDqu +FYCJTWnQXmmPY/xIQh5XUiwIwHW9ugzDp93dxdZNTf4x2T1CFE1DMIclrh76/t5kT6+ L79CR6VlRm79SOXckNEY4SR9ClGfvjxlB6fRMQIvJ8eQDZNrq1imMSCRfOcEL1IP2t66 huNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=cz2haK2O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id r28-20020a635d1c000000b005c219415020si10889174pgb.262.2023.12.06.02.13.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 02:13:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=cz2haK2O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 8C348802F540; Wed, 6 Dec 2023 02:13:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377533AbjLFKNB (ORCPT + 99 others); Wed, 6 Dec 2023 05:13:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377608AbjLFKMv (ORCPT ); Wed, 6 Dec 2023 05:12:51 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67F38D67; Wed, 6 Dec 2023 02:12:57 -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 BEFD21F73; Wed, 6 Dec 2023 11:12:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1701857532; bh=kTEQJAdraKwrzcd8ZJfODsKyAzCts6sPzE51t6mPv5U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=cz2haK2OD5bPWnsON1BgC7pXGyYxdoSU5/LFsDYGcDMEQKRBpbOa9angdhJunGisq +toHkNLKqCXqRr/o8MhkAPkDmg3jCoKpMCOFqR6oCXzOrWeAgMsvSHH70cTgQ37YaU pRcQOWuWBntCvDjIqAqJ++QzXsF/GYzSy3UJYaOQ= From: Tomi Valkeinen Date: Wed, 06 Dec 2023 12:12:29 +0200 Subject: [PATCH v2 2/4] media: rkisp1: Fix IRQ handler return values MIME-Version: 1.0 Message-Id: <20231206-rkisp-irq-fix-v2-2-6ba4185eeb1f@ideasonboard.com> References: <20231206-rkisp-irq-fix-v2-0-6ba4185eeb1f@ideasonboard.com> In-Reply-To: <20231206-rkisp-irq-fix-v2-0-6ba4185eeb1f@ideasonboard.com> To: Dafna Hirschfeld , Laurent Pinchart , Mauro Carvalho Chehab , Heiko Stuebner , Paul Elder Cc: Alexander Stein , 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 X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=1657; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=kTEQJAdraKwrzcd8ZJfODsKyAzCts6sPzE51t6mPv5U=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBlcEkhBdljqzcxdBz+n0Wffu84QmzeeRNvsvGC9 cGZSQNUbE+JAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZXBJIQAKCRD6PaqMvJYe 9aUMD/sECwuIEzxXDMinK22ykn6sULYtxlmWoqQFVcpYw+bgJVHt+hioXxZCPYN3ombSxlxQvUP XAf9qCLnbP6ywYh/g2iz/pf2CUJ8lr2vwMgD/mn+krMg3H0RubK5JM2mDdxp4Q/41VR6ETh+el1 /9xu2KTLFtOvjltjNUANLQJr8a16LwuDh8Ah5GtaD/T3qaVx7/ztWxkhCmKMn501fvi1lWHkwb3 6INakLtaDUMWNK33/ves8vzO77xQwemh9VBeh+Si8npZjrUDuui31TZcrdE9J3P66MLC3avRfVx NzE030mRNOv6eYYpXloFk1yCeCDdsSC4hae7M7YUyKPtUy0xnhHb4GFdzI52a3B3uZNp0KumFA6 /WVfNjO1scszA5xbpCUmiQVNTewp4GYp0jIRm39SBqA+M2Bvts2aydSdIGRmlsja2Fm7nGa2upJ V4XOnY+Kd2NI1REQ67usKfmPk5TXUALa9KpqGGeIBYeuFZn37joHclghA7Tjr96hAjmnBqOqILu DsVaqLUsQjaEV/batt9ydgvTYOq97ISZW2gZrmbCoLbxExWCsdL2Q1sNTtijABONT2r5lB3xBJZ dKeb0vSidXxLX4g0Gwon37xOsfFbpPP+lNSem+uVNur/4R7fOWj++2pGUM1k0VxDgLmYh1lGff8 wBMUB02ZqLQ45CQ== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 06 Dec 2023 02:13:10 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784527028019196322 X-GMAIL-MSGID: 1784527028019196322 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 Reviewed-by: Laurent Pinchart --- drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index d4950294b7b9..030eb8c79546 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -444,17 +444,25 @@ static int rkisp1_entities_register(struct rkisp1_device *rkisp1) static irqreturn_t rkisp1_isr(int irq, void *ctx) { + 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; + 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[] = { From patchwork Wed Dec 6 10:12:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 174454 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4005937vqy; Wed, 6 Dec 2023 02:13:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IEV4n6cNtYHSgJLIrsKqGavriBFsg+VadETp8JTPogLZSOYNofKZf4Cas0zlqsCKinkLOwc X-Received: by 2002:a17:902:8f98:b0:1d0:7c58:33df with SMTP id z24-20020a1709028f9800b001d07c5833dfmr496844plo.80.1701857602524; Wed, 06 Dec 2023 02:13:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701857602; cv=none; d=google.com; s=arc-20160816; b=nyMMCFqmBXckVkB7Q95WD5bkXngRUFgrAXlhr0ZTbqqtxvQ9oJ8mz/fhd7G76CgMyx giLTOn0khu6wkBgSgIqH/NHPBE2n7HexLnvolyzOWZ2jjwvunGMS+XAzX97bpLOUU8pr rbGdtT21iogStU65Y7m9jMQwjX/Dk2/8WebIJOKjPnLpnRh9xuArfXFVImUOESBR98p9 I9AueCTJz03GhdPOoPcNOsioNdYn1hbaVgTeVsO2WqwZEKGwqtMDOzSRQUZgL7b7aH8x tYBOu7RWJAvH3zDeWB1ijLASvR1EzIje4lk7Edvg4KHxb3INgelUoip+1MTmW/puA4/C EfcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=Ck4w/TgkhFUaRvIq6GsmtPZ8JwgSDBeosuqA16OM2lY=; fh=6fL1NhFCGI+wAVvsHH1pL+P1muGn2uwGLcwd3RTuFww=; b=ZPM7cZV0/5v2g41EnnczGeA5NVOFeC+18KHDpRUUZCSSXdlJB3aVUUBjbnNFlriZmN dt062J7KAB30ny1X0R09ygkflP9rqzzJMRX+4kS6rSkOxAkTTSpdoKNaSa8EGcO0f9Lo x5FnGFxyuOBCq7hAniYegTwQnbLLglbNVfP4EilsZT4hns9drSlTt4htf8IJTx7g5sEV 8S2ioxRMtuvgEE76SN6lLTJ398g+HJTqH449C1EY0PIwVei6ixq/35ULC0QVYOGOnaga 0VmaegU0Pq1SSgPFkrGRBfaFNzPk0G0XKVr0ctkYJ6nSOQoEeT0dxitqyoAyd05j+EoU aKHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=HEoiK+OC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id k1-20020a170902ba8100b001cc3527145bsi8414208pls.29.2023.12.06.02.13.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 02:13:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=HEoiK+OC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id E9C44803BEB2; Wed, 6 Dec 2023 02:13:16 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377637AbjLFKNE (ORCPT + 99 others); Wed, 6 Dec 2023 05:13:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377562AbjLFKMy (ORCPT ); Wed, 6 Dec 2023 05:12:54 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B240D6D; Wed, 6 Dec 2023 02:12:58 -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 A42DA20EA; Wed, 6 Dec 2023 11:12:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1701857533; bh=VviOwphn+4RrO5iGwi9wzijWsSEuvXaefVURZe6+FbI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=HEoiK+OCfToUQ64whKk44P2r0aabAUh7ob8T9Xy2/IgS89hQXw3AiyUW4bzf+pxPR NmPGAiTJutCi38fNSoGTAeQKDAoZ8GBY/1lGj936FruYpnDZnMP7WnGp6cyHGdcMPc wp2w1hBjt9iq9b8fNorJ/01mdEigFwdZy6yPGQuo= From: Tomi Valkeinen Date: Wed, 06 Dec 2023 12:12:30 +0200 Subject: [PATCH v2 3/4] media: rkisp1: Store IRQ lines MIME-Version: 1.0 Message-Id: <20231206-rkisp-irq-fix-v2-3-6ba4185eeb1f@ideasonboard.com> References: <20231206-rkisp-irq-fix-v2-0-6ba4185eeb1f@ideasonboard.com> In-Reply-To: <20231206-rkisp-irq-fix-v2-0-6ba4185eeb1f@ideasonboard.com> To: Dafna Hirschfeld , Laurent Pinchart , Mauro Carvalho Chehab , Heiko Stuebner , Paul Elder Cc: Alexander Stein , 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 X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=4211; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=VviOwphn+4RrO5iGwi9wzijWsSEuvXaefVURZe6+FbI=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBlcEkhINtZt/jrHcvd8PyxoqiGU8w5A9HQZ0mOF +aiJUoPTEWJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZXBJIQAKCRD6PaqMvJYe 9Ts5EACkSyWCPkI9IGqrr3Fxt4RlHxqx5t3XNKBKgBit8k0HzhBoILndDUENez6ZxzgCrOKPCq4 n1w8oNKMxJ5kEouMU8sJUk3qZ/rewbb8E1JvisK4FdFWnrARFa1dv9LywMB9dwr1GklObpn6S9v /FGcdy0pG5J3ww2dMIQ7HEX1tZYSH0r1q7RhMEnFu2PZNxhjlt048pJq4YdqOuT+eGJxeiDHSwv 3dBmSul27T5iRlOUSPd3r8+edm8N7s25AmpWuNxOcu8r6xwb9QvLACxcqQKOr5B+dbVZY1Eh/LL h/PxYAd8pEz6fbLo9OsTZikwLN0H9JD3nPKxZnPB/8qa+TU8ePAqMTzDISEIys9/s6qI3mn576Y n84vMqc5yOJ6+gBCwaN49yPaXR2iAzshb4lw9LFhnU1TEe+8w6aUfwqFXmGWUR5portRnbKM7dB zNvBYdXmzESUX6a9SPPCPpiMclWQ7GmcVv/tIExWm+m2l0QXlyzbV8oT/VpjBePsWtjWxYxHaEO 43OYp2qQkj6NBxBtpDs+LeukBNCCgJGpWc7l1vU/tkJFb8wK7P+LR05OfpWsJ8yQM9MY04dAGdX 5eeu77I9M0T1yhroWUBcHjTg7cnCYaUhK4LqXFCjQY8SPLCJNguYZWM+HwNQg6h9i3ulb+RiBEV Gqo1EBMeMEIt3NQ== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 06 Dec 2023 02:13:17 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784527037159053149 X-GMAIL-MSGID: 1784527037159053149 Store the IRQ lines used by the driver for easy access. These are needed in future patches which fix IRQ race issues. Signed-off-by: Tomi Valkeinen --- .../media/platform/rockchip/rkisp1/rkisp1-common.h | 11 ++++++++++- drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c | 19 ++++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h index 960ab89c659b..ec28907d978e 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h @@ -62,6 +62,14 @@ struct regmap; RKISP1_CIF_ISP_EXP_END | \ RKISP1_CIF_ISP_HIST_MEASURE_RDY) +/* IRQ lines */ +enum rkisp1_irq_line { + RKISP1_IRQ_ISP = 0, + RKISP1_IRQ_MI, + RKISP1_IRQ_MIPI, + RKISP1_NUM_IRQS, +}; + /* enum for the resizer pads */ enum rkisp1_rsz_pad { RKISP1_RSZ_PAD_SINK, @@ -437,7 +445,6 @@ struct rkisp1_debug { * struct rkisp1_device - ISP platform device * * @base_addr: base register address - * @irq: the irq number * @dev: a pointer to the struct device * @clk_size: number of clocks * @clks: array of clocks @@ -457,6 +464,7 @@ struct rkisp1_debug { * @stream_lock: serializes {start/stop}_streaming callbacks between the capture devices. * @debug: debug params to be exposed on debugfs * @info: version-specific ISP information + * @irqs: IRQ line numbers */ struct rkisp1_device { void __iomem *base_addr; @@ -479,6 +487,7 @@ struct rkisp1_device { struct mutex stream_lock; /* serialize {start/stop}_streaming cb between capture devices */ struct rkisp1_debug debug; const struct rkisp1_info *info; + int irqs[RKISP1_NUM_IRQS]; }; /* diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index 030eb8c79546..492ff5e6770d 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -115,6 +115,7 @@ struct rkisp1_isr_data { const char *name; irqreturn_t (*isr)(int irq, void *ctx); + u32 line_mask; }; /* ---------------------------------------------------------------------------- @@ -473,9 +474,9 @@ static const char * const px30_isp_clks[] = { }; static const struct rkisp1_isr_data px30_isp_isrs[] = { - { "isp", rkisp1_isp_isr }, - { "mi", rkisp1_capture_isr }, - { "mipi", rkisp1_csi_isr }, + { "isp", rkisp1_isp_isr, BIT(RKISP1_IRQ_ISP) }, + { "mi", rkisp1_capture_isr, BIT(RKISP1_IRQ_MI) }, + { "mipi", rkisp1_csi_isr, BIT(RKISP1_IRQ_MIPI) }, }; static const struct rkisp1_info px30_isp_info = { @@ -496,7 +497,7 @@ static const char * const rk3399_isp_clks[] = { }; static const struct rkisp1_isr_data rk3399_isp_isrs[] = { - { NULL, rkisp1_isr }, + { NULL, rkisp1_isr, BIT(RKISP1_IRQ_ISP) | BIT(RKISP1_IRQ_MI) | BIT(RKISP1_IRQ_MIPI) }, }; static const struct rkisp1_info rk3399_isp_info = { @@ -517,7 +518,7 @@ static const char * const imx8mp_isp_clks[] = { }; static const struct rkisp1_isr_data imx8mp_isp_isrs[] = { - { NULL, rkisp1_isr }, + { NULL, rkisp1_isr, BIT(RKISP1_IRQ_ISP) | BIT(RKISP1_IRQ_MI) | BIT(RKISP1_IRQ_MIPI) }, }; static const struct rkisp1_info imx8mp_isp_info = { @@ -574,6 +575,9 @@ static int rkisp1_probe(struct platform_device *pdev) if (IS_ERR(rkisp1->base_addr)) return PTR_ERR(rkisp1->base_addr); + for (unsigned int il = 0; il < RKISP1_NUM_IRQS; ++il) + rkisp1->irqs[il] = -1; + for (i = 0; i < info->isr_size; i++) { irq = info->isrs[i].name ? platform_get_irq_byname(pdev, info->isrs[i].name) @@ -581,6 +585,11 @@ static int rkisp1_probe(struct platform_device *pdev) if (irq < 0) return irq; + for (unsigned int il = 0; il < RKISP1_NUM_IRQS; ++il) { + if (info->isrs[i].line_mask & BIT(il)) + rkisp1->irqs[il] = irq; + } + ret = devm_request_irq(dev, irq, info->isrs[i].isr, 0, dev_driver_string(dev), dev); if (ret) { From patchwork Wed Dec 6 10:12:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 174456 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4006024vqy; Wed, 6 Dec 2023 02:13:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IFHnlHMw4W70x2uNEnDMvHja1nq6nJ+LgLgLBzV2ci2No00ys93eNsrVjxcWIORnhyCM7f8 X-Received: by 2002:a17:902:e74d:b0:1d0:c2be:3d92 with SMTP id p13-20020a170902e74d00b001d0c2be3d92mr762012plf.39.1701857615649; Wed, 06 Dec 2023 02:13:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701857615; cv=none; d=google.com; s=arc-20160816; b=A/ZTcjvC2NTU+v9JGGNHV+aAGtZ3K1F7zNVuzKTAByP0E1A76xvOlG5VvY9Wo0L3qr EdlD8L84TRVpmJrLgIsJTSg32I58Ot1EqqG41GuNv+ajQfveXCDHy1qs4JdpGWbxAkM0 Nh/F3jHdVysXjBbScdKoBm8FTntGcfdurW6sV5CIEtPuodc9RXcTvYYX9FlA1zPDbjIo XUyPU3gnt6j/uiLPhoQMNTSKjWOYKWKrFyX/NbqTWdAUmb5EJYvmzn0ERPs4pJ9MK/1c wcNGLstEl6AEed/r96sRG1sKSzgmCkIlcQhN5MoGVULCuBmLZtjIHEROM+ZbROwnHnAQ Ue2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=Zwd877/A38DdmLoA0A/3gPQdF3dEaHsOy5q0a+s+htQ=; fh=6fL1NhFCGI+wAVvsHH1pL+P1muGn2uwGLcwd3RTuFww=; b=MVh8QG0BA+39bmwr77REHom6Ue/dSzj/JlhG77+ETP0qUb/NBIAM8pTlvr+pp4uDE0 IWqjNPaa+mvOEHL/gGJub86Y55Kp7S62C4+XS9lHnZaVsqkxKRU6w1YATBdgxCNdVgwb UrUBD8G4bPusTssJdLknGCRPpLjN0QHDwx7PioUupeeURJrp2HBrVZmJX7n1FDWCr59/ sysvEUFhFf4vp6OCB2DXcSluB+q7An/Q70BmD+n8dnflq5sAxhSM3p6RzizzDPgwTHAM 3d3PR9rjUOOx1t8e1VdnbUysFrICq5TfYxCQ4t3BwrULd2i7myN0toOdKxUfw/jBYqpD vyKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=mlZdKuCI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id o9-20020a170902d4c900b001cfbf5c045bsi6027656plg.458.2023.12.06.02.13.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 02:13:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=mlZdKuCI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 06ECF80BB209; Wed, 6 Dec 2023 02:13:32 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377682AbjLFKNH (ORCPT + 99 others); Wed, 6 Dec 2023 05:13:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377651AbjLFKNB (ORCPT ); Wed, 6 Dec 2023 05:13:01 -0500 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 80E91D64; Wed, 6 Dec 2023 02:13:00 -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 8EA622B09; Wed, 6 Dec 2023 11:12:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1701857534; bh=PKUcBdc8Qj6XeTMDCk4F0nRr2AQygA1lnSwR9BIZ64A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=mlZdKuCICZ5xqmYpghtsHBC1xpLI76Ws+DZsoYvWi8URIodqTSDt9hGX+aot1nvHW C9gdyHqwHmp09usqo56v9453JXWr3org8nQ9xwPX54CN1RXnilaS1EasyJKBLFCxSe /KhuS6lrDaxHWLYIpJpq4Jg4LfbyItKa0/eQnoBk= From: Tomi Valkeinen Date: Wed, 06 Dec 2023 12:12:31 +0200 Subject: [PATCH v2 4/4] media: rkisp1: Fix IRQ disable race issue MIME-Version: 1.0 Message-Id: <20231206-rkisp-irq-fix-v2-4-6ba4185eeb1f@ideasonboard.com> References: <20231206-rkisp-irq-fix-v2-0-6ba4185eeb1f@ideasonboard.com> In-Reply-To: <20231206-rkisp-irq-fix-v2-0-6ba4185eeb1f@ideasonboard.com> To: Dafna Hirschfeld , Laurent Pinchart , Mauro Carvalho Chehab , Heiko Stuebner , Paul Elder Cc: Alexander Stein , 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 X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=3439; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=PKUcBdc8Qj6XeTMDCk4F0nRr2AQygA1lnSwR9BIZ64A=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBlcEkhuPu8R/u0zTPQ1W//B0yzANJaz5h46O91S MX9rZ0rGhKJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZXBJIQAKCRD6PaqMvJYe 9SQ1D/0WNlBX1kQYLY1htxMCKTBE6WutW9vj9EDMkljHP4bFOTt76UdikAxDBt1ozRlskCeF6cE PNe0r5Ck2WlI7E+Ucfu1SmRgsqZf80Or7Lz3sqGYscuwl5RF1QUYnzmULiaNOSmkkJHc/ZIIemb p+G7vvjytJrpg1MGF/qJmhVlGCVZJhLn+r8oAHx80cCgzvnf9apfFuz0soMDZLzC60zk1TK9+/F mjhOSBnU8njOvS7TdFQJsxhr5fCWsZYXahNF41pY+luL+ZgS7KNpbkqprCw1k63yeO6XABJ9pAh Cyx7CtSaKsrLGO7GhnKZpcrO7cdQROBDpG4ymbwxFVMKnED45uChqhg9y663qTHBahXIVUhuyBX QwKPpwY7wFCORjm0WtGPW7dfE8Mgam1vqPHnzfi7s/JDZQMKNZvr1jlG3wgbHgF6/U7ngoDiR4E 2U1qi4jqTB/V2vAKvSfqkJ1Zc4DcssxYYOcmO3iQVPkNCiBHwdXzttxza0KTWktARVZ5lyIaEXE hxTlkWxglasejh0NocZF5jfIeOPfHV5JhHFOmJ/6iaLAo1IEgFRRe5QGsm267E6IW3Obuk9+DZ1 4rNodgTAdPKsYrQNbUDie5BXKjTjOwZUJ/uvb0/aKOm0G/15ajtHheOslDXihbxjSBiiX1RlVSW Ckl3LxDwT6v/JPA== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 06 Dec 2023 02:13:32 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784527050991484802 X-GMAIL-MSGID: 1784527050991484802 In rkisp1_isp_stop() and rkisp1_csi_disable() the driver masks the interrupts and then apparently assumes that the interrupt handler won't be running, and proceeds in the stop procedure. This is not the case, as the interrupt handler can already be running, which would lead to the ISP being disabled while the interrupt handler handling a captured frame. This brings up two issues: 1) the ISP could be powered off while the interrupt handler is still running and accessing registers, leading to board lockup, and 2) the interrupt handler code and the code that disables the streaming might do things that conflict. It is not clear to me if 2) causes a real issue, but 1) can be seen with a suitable delay (or printk in my case) in the interrupt handler, leading to board lockup. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c | 14 +++++++++++++- drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c | 20 +++++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c index 47f4353a1784..0bab3303f2e4 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c @@ -125,8 +125,20 @@ static void rkisp1_csi_disable(struct rkisp1_csi *csi) struct rkisp1_device *rkisp1 = csi->rkisp1; u32 val; - /* Mask and clear interrupts. */ + /* Mask MIPI interrupts. */ rkisp1_write(rkisp1, RKISP1_CIF_MIPI_IMSC, 0); + + /* Flush posted writes */ + rkisp1_read(rkisp1, RKISP1_CIF_MIPI_IMSC); + + /* + * Wait until the IRQ handler has ended. The IRQ handler may get called + * even after this, but it will return immediately as the MIPI + * interrupts have been masked. + */ + synchronize_irq(rkisp1->irqs[RKISP1_IRQ_MIPI]); + + /* Clear MIPI interrupt status */ rkisp1_write(rkisp1, RKISP1_CIF_MIPI_ICR, ~0); val = rkisp1_read(rkisp1, RKISP1_CIF_MIPI_CTRL); diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index dafbfd230542..33b5a714d117 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c @@ -364,11 +364,25 @@ static void rkisp1_isp_stop(struct rkisp1_isp *isp) * ISP(mi) stop in mi frame end -> Stop ISP(mipi) -> * Stop ISP(isp) ->wait for ISP isp off */ - /* stop and clear MI and ISP interrupts */ - rkisp1_write(rkisp1, RKISP1_CIF_ISP_IMSC, 0); - rkisp1_write(rkisp1, RKISP1_CIF_ISP_ICR, ~0); + /* Mask MI and ISP interrupts */ + rkisp1_write(rkisp1, RKISP1_CIF_ISP_IMSC, 0); rkisp1_write(rkisp1, RKISP1_CIF_MI_IMSC, 0); + + /* Flush posted writes */ + rkisp1_read(rkisp1, RKISP1_CIF_MI_IMSC); + + /* + * Wait until the IRQ handler has ended. The IRQ handler may get called + * even after this, but it will return immediately as the MI and ISP + * interrupts have been masked. + */ + synchronize_irq(rkisp1->irqs[RKISP1_IRQ_ISP]); + if (rkisp1->irqs[RKISP1_IRQ_ISP] != rkisp1->irqs[RKISP1_IRQ_MI]) + synchronize_irq(rkisp1->irqs[RKISP1_IRQ_MI]); + + /* Clear MI and ISP interrupt status */ + rkisp1_write(rkisp1, RKISP1_CIF_ISP_ICR, ~0); rkisp1_write(rkisp1, RKISP1_CIF_MI_ICR, ~0); /* stop ISP */