From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58B7DC43460 for ; Tue, 27 Apr 2021 09:31:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0B9C8613B4 for ; Tue, 27 Apr 2021 09:31:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235174AbhD0Jbx (ORCPT ); Tue, 27 Apr 2021 05:31:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:37318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230316AbhD0Jbv (ORCPT ); Tue, 27 Apr 2021 05:31:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A6658613BC; Tue, 27 Apr 2021 09:30:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619515862; bh=wwdocN+FFNO7ugt/9z3SiJCzGGGQpkTsBljNkYzdRsc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=dR+eRUUcFpK7r3Qo3uMIc89WSn+V7tyH+0fKhATah0oY8qwXPKKIcMoDR0TqWJxTs 4OuaQI7kmex4sPg8XSzBZ73DSWcXLaaRm+6dF3BuoWLDeGMO49BFvieaqwl4fBViot hgpZveuEPLA9kiaLDEEz/3Sdqk4ofewrIDhYu7EZJqilkKf6143HgVByg5YHRM22kN ItCWCT0uoAQYx56BlKs2SDX1QRKLKAFX3MT/jJiqoz/Fkjo59cE8XGjtix1OpbTGga mG1W746ovMPtbkkyxUbKWBWApKyoHXBdn6sUdh87o1J7Mj04R3JL/In/U8JfHfjVZQ VXliqcie3Qa3A== Date: Tue, 27 Apr 2021 11:30:55 +0200 From: Mauro Carvalho Chehab To: Sylwester Nawrocki Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Ezequiel Garcia , Hans Verkuil , Krzysztof Kozlowski , Mauro Carvalho Chehab , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org Subject: Re: [PATCH 58/78] media: exynos-gsc: use pm_runtime_resume_and_get() Message-ID: <20210427113055.745d0560@coco.lan> In-Reply-To: References: <9c7d683907b9f9cf4a99f57f978671ec7f5a1dbc.1619191723.git.mchehab+huawei@kernel.org> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Tue, 27 Apr 2021 10:18:12 +0200 Sylwester Nawrocki escreveu: > On 24.04.2021 08:45, Mauro Carvalho Chehab wrote: > > Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") > > added pm_runtime_resume_and_get() in order to automatically handle > > dev->power.usage_count decrement on errors. > > > > Use the new API, in order to cleanup the error check logic. > > > > Signed-off-by: Mauro Carvalho Chehab > > --- > > drivers/media/platform/exynos-gsc/gsc-core.c | 3 +-- > > drivers/media/platform/exynos-gsc/gsc-m2m.c | 2 +- > > 2 files changed, 2 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c b/drivers/media/platform/exynos-gsc/gsc-core.c > > index 9f41c2e7097a..9d5841194f6b 100644 > > --- a/drivers/media/platform/exynos-gsc/gsc-core.c > > +++ b/drivers/media/platform/exynos-gsc/gsc-core.c > > @@ -1210,7 +1210,7 @@ static int gsc_remove(struct platform_device *pdev) > > struct gsc_dev *gsc = platform_get_drvdata(pdev); > > int i; > > > > - pm_runtime_get_sync(&pdev->dev); > > + pm_runtime_resume_and_get(&pdev->dev); > > > > gsc_unregister_m2m_device(gsc); > > v4l2_device_unregister(&gsc->v4l2_dev); > > @@ -1219,7 +1219,6 @@ static int gsc_remove(struct platform_device *pdev) > > for (i = 0; i < gsc->num_clocks; i++) > > clk_disable_unprepare(gsc->clock[i]); > > > > - pm_runtime_put_noidle(&pdev->dev); > > If we do this then the device usage count will not get decremented > after the pm_runtime_resume_and_get() call above and after driver > unload/load cycle it will not be possible to suspend the device. > I wouldn't be changing anything in gsc_remove(), pm_runtime_get_sync() > works better in that case. Good point. Actually, I don't see any reason why to call a PM resume function - either being pm_runtime_get_sync() or pm_runtime_resume_and_get(). The code there could simply be: static int gsc_remove(struct platform_device *pdev) { struct gsc_dev *gsc = platform_get_drvdata(pdev); int i; gsc_unregister_m2m_device(gsc); v4l2_device_unregister(&gsc->v4l2_dev); vb2_dma_contig_clear_max_seg_size(&pdev->dev); for (i = 0; i < gsc->num_clocks; i++) clk_disable_unprepare(gsc->clock[i]); pm_runtime_disable(&pdev->dev); dev_dbg(&pdev->dev, "%s driver unloaded\n", pdev->name); return 0; } Eventually also adding: pm_runtime_suspended(&pdev->dev); just after pm_runtime_disable(). Regards, Mauro From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32B1DC433ED for ; Tue, 27 Apr 2021 09:33:20 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 72AE3613BF for ; Tue, 27 Apr 2021 09:33:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 72AE3613BF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=A3LmrvOcM0Vp9zwYeFP8Z00p5pSkJzziqNrdWW3yZ1U=; b=Kygw4kWWpIU+nOv/jUhurdjKI o2Q6yPabaR9IHUkE2q7sWalba9AE3/v4cYbaNeAuU9qE4q8uqsVY997HI2UZqWh+EQ+kv3VE/JTWA 2FI+UvRLVlUEQ2T1Heqbe9zU/yCr09Uv5VNTlrmxPamkLXsFsD683q/6SWzYO/DSI6xHtscp1mOtT LTAENskqLcSmse7bJtpAnV4XViWM25vIBbBzqZWDR6Cl5ZN/Ji7Auo5+EOc9u8Y00Bt5UP+RiEPUp tjoKOt7z59vX4EKLATlvJOM0F0YhvgOnTulWzEeMnhSSOpfc0Fakr564d2A3pwyT9kfKGttt/6b9C e2FyLd45w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lbK3i-001E7R-6F; Tue, 27 Apr 2021 09:31:10 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lbK3e-001E7I-BR for linux-arm-kernel@desiato.infradead.org; Tue, 27 Apr 2021 09:31:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Subject:Cc:To: From:Date:Sender:Reply-To:Content-ID:Content-Description; bh=hzP3/q/HARkKMvalhUt07THw7GVz6CvUFVk2ZIn+ZNE=; b=f73gItUufMaQaiqXWezNmmIWur XUKGOFUKInIjOntBDrq+RGQz+KySE7JITeJBUXn9AvKAjPd+2FSEYo5yYBNA7QabalHcQX0iIXW1G 2E7M1UUW4FwBHGaEBz9blHmVcYr+vvt6ILAVpo0wrbR+edOrcJTiTrdoFrqmei/sQo3xj5H2APUZM 1SSFax+2Ppda8oA14N2f+bqDJ99YJMagNNeOe9ICpcvYXwdskeGBOP4KdlufpWZiH/sLQUoX/L4SS bzpL9D3RSHYNsVOZruFD4NSqYofe5rwlCnH3IcDZdbO2MBnkwxs6APu2D+BrE9ubBlnvQG8mJpCGL fuWoqx2g==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lbK3b-00GaCk-Jw for linux-arm-kernel@lists.infradead.org; Tue, 27 Apr 2021 09:31:05 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id A6658613BC; Tue, 27 Apr 2021 09:30:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619515862; bh=wwdocN+FFNO7ugt/9z3SiJCzGGGQpkTsBljNkYzdRsc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=dR+eRUUcFpK7r3Qo3uMIc89WSn+V7tyH+0fKhATah0oY8qwXPKKIcMoDR0TqWJxTs 4OuaQI7kmex4sPg8XSzBZ73DSWcXLaaRm+6dF3BuoWLDeGMO49BFvieaqwl4fBViot hgpZveuEPLA9kiaLDEEz/3Sdqk4ofewrIDhYu7EZJqilkKf6143HgVByg5YHRM22kN ItCWCT0uoAQYx56BlKs2SDX1QRKLKAFX3MT/jJiqoz/Fkjo59cE8XGjtix1OpbTGga mG1W746ovMPtbkkyxUbKWBWApKyoHXBdn6sUdh87o1J7Mj04R3JL/In/U8JfHfjVZQ VXliqcie3Qa3A== Date: Tue, 27 Apr 2021 11:30:55 +0200 From: Mauro Carvalho Chehab To: Sylwester Nawrocki Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Ezequiel Garcia , Hans Verkuil , Krzysztof Kozlowski , Mauro Carvalho Chehab , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org Subject: Re: [PATCH 58/78] media: exynos-gsc: use pm_runtime_resume_and_get() Message-ID: <20210427113055.745d0560@coco.lan> In-Reply-To: References: <9c7d683907b9f9cf4a99f57f978671ec7f5a1dbc.1619191723.git.mchehab+huawei@kernel.org> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210427_023103_747357_6D248FB1 X-CRM114-Status: GOOD ( 21.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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Em Tue, 27 Apr 2021 10:18:12 +0200 Sylwester Nawrocki escreveu: > On 24.04.2021 08:45, Mauro Carvalho Chehab wrote: > > Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") > > added pm_runtime_resume_and_get() in order to automatically handle > > dev->power.usage_count decrement on errors. > > > > Use the new API, in order to cleanup the error check logic. > > > > Signed-off-by: Mauro Carvalho Chehab > > --- > > drivers/media/platform/exynos-gsc/gsc-core.c | 3 +-- > > drivers/media/platform/exynos-gsc/gsc-m2m.c | 2 +- > > 2 files changed, 2 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c b/drivers/media/platform/exynos-gsc/gsc-core.c > > index 9f41c2e7097a..9d5841194f6b 100644 > > --- a/drivers/media/platform/exynos-gsc/gsc-core.c > > +++ b/drivers/media/platform/exynos-gsc/gsc-core.c > > @@ -1210,7 +1210,7 @@ static int gsc_remove(struct platform_device *pdev) > > struct gsc_dev *gsc = platform_get_drvdata(pdev); > > int i; > > > > - pm_runtime_get_sync(&pdev->dev); > > + pm_runtime_resume_and_get(&pdev->dev); > > > > gsc_unregister_m2m_device(gsc); > > v4l2_device_unregister(&gsc->v4l2_dev); > > @@ -1219,7 +1219,6 @@ static int gsc_remove(struct platform_device *pdev) > > for (i = 0; i < gsc->num_clocks; i++) > > clk_disable_unprepare(gsc->clock[i]); > > > > - pm_runtime_put_noidle(&pdev->dev); > > If we do this then the device usage count will not get decremented > after the pm_runtime_resume_and_get() call above and after driver > unload/load cycle it will not be possible to suspend the device. > I wouldn't be changing anything in gsc_remove(), pm_runtime_get_sync() > works better in that case. Good point. Actually, I don't see any reason why to call a PM resume function - either being pm_runtime_get_sync() or pm_runtime_resume_and_get(). The code there could simply be: static int gsc_remove(struct platform_device *pdev) { struct gsc_dev *gsc = platform_get_drvdata(pdev); int i; gsc_unregister_m2m_device(gsc); v4l2_device_unregister(&gsc->v4l2_dev); vb2_dma_contig_clear_max_seg_size(&pdev->dev); for (i = 0; i < gsc->num_clocks; i++) clk_disable_unprepare(gsc->clock[i]); pm_runtime_disable(&pdev->dev); dev_dbg(&pdev->dev, "%s driver unloaded\n", pdev->name); return 0; } Eventually also adding: pm_runtime_suspended(&pdev->dev); just after pm_runtime_disable(). Regards, Mauro _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel