From patchwork Wed Nov 22 15:21:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13465027 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 C7190C61D99 for ; Wed, 22 Nov 2023 15:22:32 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=VD78NLoGgbqgTIIhp8hJdKFhn5J31/iW8Aq3vXQyyrs=; b=ibIFMfcCkoUpsq Atqxudfdf/Jxdb5lZs941NZ7EEkVxBaxnO/rK9uDbS6I932Db/gEQzIgmop/63KVzRBw8sDpQUAL4 ybqk19tJLStiImXnxFNo2iZEHGPTboOeoq/FDMgNp5D4+N0A0ZAZTht+iaazh1WUeFBK5WK9QlrPK artvaOgzVvcQIMHtt+8laOYYT963TheQT8Ija2xn4rosl3ZE70rNNj9LhEydXHlX2OgQsst4REiMF snsZkdsmx2OkJiI+qUHfcOrTAzDtETppP6HUHAQ5sn3Killzvm9RAl0B6elas2CJjTtYVUqZSoI5Z z+dQ3pUDksGwCFqGMmQQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r5p36-002EZO-23; Wed, 22 Nov 2023 15:21:56 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r5p33-002EXE-2W for linux-arm-kernel@lists.infradead.org; Wed, 22 Nov 2023 15:21:55 +0000 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 9BFE529A; Wed, 22 Nov 2023 16:21:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1700666481; bh=a5vaX6GZvtlfsAJNQBP0qAAJygXfjxV7faNEkvKdK9o=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=wIgzJjSfWQ/kP8yC8CEoH2R9L9SOleWmnXyPCuqzZaeqVR6Lgd/2/rcRNG+chaYbi IVIJGZar0WWFOA0Ys5uFHR+YFnZEmlfCAfE+DNSsY8Qqq5vfipWuiLY0Qq4+1jO23O 3/prCLB2LmnzDJwVOVx897QIqgCnzhMtV/Wz0rUQ= From: Tomi Valkeinen Date: Wed, 22 Nov 2023 17:21:34 +0200 Subject: [PATCH v2 1/2] media: imx-mipi-csis: Fix clock handling in remove() MIME-Version: 1.0 Message-Id: <20231122-imx-csis-v2-1-e44b8dc4cb66@ideasonboard.com> References: <20231122-imx-csis-v2-0-e44b8dc4cb66@ideasonboard.com> In-Reply-To: <20231122-imx-csis-v2-0-e44b8dc4cb66@ideasonboard.com> To: Kieran Bingham , Rui Miguel Silva , Laurent Pinchart , Martin Kepplinger , Purism Kernel Team , Mauro Carvalho Chehab , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Cc: linux-media@vger.kernel.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=1351; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=a5vaX6GZvtlfsAJNQBP0qAAJygXfjxV7faNEkvKdK9o=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBlXhyNxfbxyP5pZgrruxd6JZbUxZTPsCrogRzmE YfMDSZT4t2JAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZV4cjQAKCRD6PaqMvJYe 9fOTD/0bQ/m+qas+P6A2bvwFTA9FVHi6b1pk2wZNrbMFhwjOFDiTRQSfKsR8sOKfoWBuXR7YQ9p 0DahtKNW5EmY1OBIgnapXcjvWnZ/pFq10bhbWs/ocsggSRacLTCit9yN9y/GevVxFM8pDDEBoca YxpJE3VUBlBY8TbOGksntlttUj93EdwjoDju2+zSFVLxENApox4jDvuotlgHxHI/5HZzJthT/Fk wODTbbq/EMqsD7lJkTDyzvfxzf1zDJ+X1bgMkVQPyq5EsSl2YKv5k+dE/a8Mr9UmFdroNLvWiGB qi8jA8qyDYqsXc10QfJTCwj7s/+NQbgliO0jGkuXgtKK4h4evfaeO8KXREkYzxRwAcbyl5rcnHz n+BvqCDb5AhUbJXqDvNKrthoJD4L9hlJICLRXWlNyeO9XHhxfb/FuchG3M0U2rXQ4F7BxtvhYGP UlsKx7opxlWlEmSROo6Sa3il5PtvWRz0ZgFkF3TiFGiKGdsKMW+5lwITUtu0mRw+fOt9LKSixPI JPIjlkdOo4OJTqmz7GHMHGNjPN+57s8QYWMbANpeQj3rSupQyAhCJyR4Hg3exPAbZ2aZA9AyAlT 5Oo8YUO4GQ3lSvVl7XA9xhHTgSr6DvTGWluI6pNfkbB8uNvA2y01kAyGgCy00cALlCOHZNhUPod nvdkjvcWVSiQx8A== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231122_072153_958622_F01B1699 X-CRM114-Status: GOOD ( 11.59 ) 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 The driver always calls mipi_csis_runtime_suspend() and mipi_csis_clk_disable() in remove(). This causes multiple WARNs from the kernel, as the clocks get disabled too many times. Fix the remove() to call mipi_csis_runtime_suspend() and mipi_csis_clk_disable() in a way that reverses what is done in probe(). Fixes: 7807063b862b ("media: staging/imx7: add MIPI CSI-2 receiver subdev for i.MX7") Reviewed-by: Laurent Pinchart Signed-off-by: Tomi Valkeinen --- drivers/media/platform/nxp/imx-mipi-csis.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c index 6cb20b45e0a1..b39d7aeba750 100644 --- a/drivers/media/platform/nxp/imx-mipi-csis.c +++ b/drivers/media/platform/nxp/imx-mipi-csis.c @@ -1502,8 +1502,10 @@ static void mipi_csis_remove(struct platform_device *pdev) v4l2_async_nf_cleanup(&csis->notifier); v4l2_async_unregister_subdev(&csis->sd); + if (!pm_runtime_enabled(&pdev->dev)) + mipi_csis_runtime_suspend(&pdev->dev); + pm_runtime_disable(&pdev->dev); - mipi_csis_runtime_suspend(&pdev->dev); mipi_csis_clk_disable(csis); v4l2_subdev_cleanup(&csis->sd); media_entity_cleanup(&csis->sd.entity); From patchwork Wed Nov 22 15:21:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13465028 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 4C876C61D97 for ; Wed, 22 Nov 2023 15:22:35 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YVYnYIE5SqDpV/NUIHmtgW0gbKt5fGlEw+U7QuZspH8=; b=aW8Jp+2W/I8J7O ZK3mKlcQ/MY30yc8cjJWU4VPtK5NoRLvcgDo8N7UNCKmMOLHtvFVL3WRvwyAMV/zqHQxqo8pTKnDO jR81fkP65KCHoEEK1VpNF5WZx8ezQkNr6Ewz04fIhTVqy9SrWrWXvkBEVbutWzGQ1ZETT7U0rXFpz /s1bNzUYm/wvefULSYJGnmkACP6gotIvSXzT400QpprH2uLfpcn0CFgLiAyhX/vy2FrhKwq035f15 YB21q/KZbZJ8djnWASkMmaiwW+CjN/p0K/zbidniSDUpMaEkY7NamhMpAwcIUmpNgyi80ABbq9Nti 28j11yJ51stk/OHmDVRw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r5p3G-002Edx-1d; Wed, 22 Nov 2023 15:22:06 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r5p34-002EXc-27 for linux-arm-kernel@lists.infradead.org; Wed, 22 Nov 2023 15:21:56 +0000 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 932E0641; Wed, 22 Nov 2023 16:21:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1700666482; bh=oLh+PYyvynzrtsVKhC9dRmFuGMQd356Ob1Vi0pnH3uI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Eov64+qh5+l2JI/hZS6I7DOpXiFQdbP67UBBuwXV4ASAwfL5ewOKcA6UTg+pvdV4n 5ydILDHildwhCI5zyY256SizMFqXQYFeUvWFoteoVorJVUBlBlGsAuyX6RTzt/v7mB 20LmrdmF2OGZAYL6afR3XeZOuj3qstq1Dlmw9at4= From: Tomi Valkeinen Date: Wed, 22 Nov 2023 17:21:35 +0200 Subject: [PATCH v2 2/2] media: imx-mipi-csis: Drop extra clock enable at probe() MIME-Version: 1.0 Message-Id: <20231122-imx-csis-v2-2-e44b8dc4cb66@ideasonboard.com> References: <20231122-imx-csis-v2-0-e44b8dc4cb66@ideasonboard.com> In-Reply-To: <20231122-imx-csis-v2-0-e44b8dc4cb66@ideasonboard.com> To: Kieran Bingham , Rui Miguel Silva , Laurent Pinchart , Martin Kepplinger , Purism Kernel Team , Mauro Carvalho Chehab , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Cc: linux-media@vger.kernel.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=2436; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=oLh+PYyvynzrtsVKhC9dRmFuGMQd356Ob1Vi0pnH3uI=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBlXhyO7E0e4Yi0seizlKIhwM6sPd6QWD4XXH963 56XWdMxPb6JAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZV4cjgAKCRD6PaqMvJYe 9eavD/wIeF/Msot/w6WJqthTJU/S9QIUb6BUTmAtOot7zFYQdMM3aGinlcQxnQ2LVHnZ092dP1E 15Sg1PVzM90NdXVwZybVnUhEPFfKuAm5nM5fYX7PyFXksAQFvXv8KEItyjWJzMJpTPADUAqVH5p kMpFmDbyq1a4xSVpFXb5zMVdHAKNAHaFOtaI2+Ha/gYvF6EQLhn8Hl7eY8ZI3TQtBE2amTzOxaT 1N121JJMCFk2F9sJBgCUobGenO3eg/oV92rzUOva7LudQNT/H7T78c8p7OU6AIAenW94ZVajQKC OXB4M4B/VP2+ZB1ApBV3CWbD68FQtjsdkDsNsNDH3Q0gnnWHQDd7iumoI+xq3ts34tn6iznTUjT eD0zgyFpekj/jyMpjd9s9jlvY4VuekXUjADWKLNWqx6x1ZZ+5OGAMvcFQrUfS5StgJISb7vfkM1 5Gav39YZjF9U1HXziFt1YPKDRjskx8YUIVf6Yk4ZIu+Jj4Eous6qV1UULjxR2D0VCYr79akfNno PXf2VDmc/+NeSqTn8+ii9yxpq6atzVjBwZagXH+BsOtHk77hyXkMPy1xjb6L6ejrCkF8QKKJcVS Ej10zkGTeGIBa9cAKXFxlxspBgd8n9mOoiANcs/9znxoK8C0VD/c8Ub1VFfWCqUnF3gXk+S+hp0 Y0Ea9XqGjyOYruw== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231122_072154_834052_66A3ED5F X-CRM114-Status: GOOD ( 15.25 ) 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 The driver always enables the clocks at probe() and disables them only at remove(). It is not clear why the driver does this, as it supports runtime PM, and enables and disables the clocks in the runtime resume and suspend callbacks. Also, in the case runtime PM is not available, the driver calls the resume and suspend callbacks manually from probe() and remove(). Drop the unnecessary clock enable, thus enabling the clocks only when actually needed. Fixes: 7807063b862b ("media: staging/imx7: add MIPI CSI-2 receiver subdev for i.MX7") Reviewed-by: Laurent Pinchart Signed-off-by: Tomi Valkeinen --- drivers/media/platform/nxp/imx-mipi-csis.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c index b39d7aeba750..b08f6d2e7516 100644 --- a/drivers/media/platform/nxp/imx-mipi-csis.c +++ b/drivers/media/platform/nxp/imx-mipi-csis.c @@ -1435,24 +1435,18 @@ static int mipi_csis_probe(struct platform_device *pdev) /* Reset PHY and enable the clocks. */ mipi_csis_phy_reset(csis); - ret = mipi_csis_clk_enable(csis); - if (ret < 0) { - dev_err(csis->dev, "failed to enable clocks: %d\n", ret); - return ret; - } - /* Now that the hardware is initialized, request the interrupt. */ ret = devm_request_irq(dev, irq, mipi_csis_irq_handler, 0, dev_name(dev), csis); if (ret) { dev_err(dev, "Interrupt request failed\n"); - goto err_disable_clock; + return ret; } /* Initialize and register the subdev. */ ret = mipi_csis_subdev_init(csis); if (ret < 0) - goto err_disable_clock; + return ret; platform_set_drvdata(pdev, &csis->sd); @@ -1486,8 +1480,6 @@ static int mipi_csis_probe(struct platform_device *pdev) v4l2_async_nf_unregister(&csis->notifier); v4l2_async_nf_cleanup(&csis->notifier); v4l2_async_unregister_subdev(&csis->sd); -err_disable_clock: - mipi_csis_clk_disable(csis); return ret; } @@ -1506,7 +1498,6 @@ static void mipi_csis_remove(struct platform_device *pdev) mipi_csis_runtime_suspend(&pdev->dev); pm_runtime_disable(&pdev->dev); - mipi_csis_clk_disable(csis); v4l2_subdev_cleanup(&csis->sd); media_entity_cleanup(&csis->sd.entity); pm_runtime_set_suspended(&pdev->dev);