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 A80A8C43460 for ; Tue, 27 Apr 2021 09:42:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7DD22613BF for ; Tue, 27 Apr 2021 09:42:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235265AbhD0Jn0 (ORCPT ); Tue, 27 Apr 2021 05:43:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:43448 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231148AbhD0JnY (ORCPT ); Tue, 27 Apr 2021 05:43:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8FAB8613B4; Tue, 27 Apr 2021 09:42:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619516561; bh=cCsXwAcyngCcHKVryOwBkBlvyM5OFInMmuy/vcrTNbE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=nQGPC/YzQ6tBi9NYQj7e1e3N9EvP/zd2pgL+xJTQv4ISAw6LyoJPePKAYDS7toc5M FpMFunG31iGzpi8VAfxovcPQ6wuiDwsLJMxyidG5y2+lNmox3P53N4sQcq6Qj+0DXl A6LNrlH2alTv6uTfbOzsHqN9vimhJHfWUvCjG+CfeYmw65w/99ptJV9adTnVj38fCG JxKFC3qn40GIe03j1dh/8AxcIwpi/d9rcwo1941UokGkbDcylwNkVXxOqcUUn8WTOt Hb8hFysO4iPPK3k73ptjYPXUXJ4I29stGLn6330dW1NAkgUavwYw+vy63iwpyNSZG7 yfxoXb1zW2fcA== Date: Tue, 27 Apr 2021 11:42:35 +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: <20210427114235.45a7b2a4@coco.lan> In-Reply-To: <20210427113055.745d0560@coco.lan> References: <9c7d683907b9f9cf4a99f57f978671ec7f5a1dbc.1619191723.git.mchehab+huawei@kernel.org> <20210427113055.745d0560@coco.lan> 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 11:30:55 +0200 Mauro Carvalho Chehab escreveu: > 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); In time: I actually meant: pm_runtime_set_suspended(&pdev->dev); but after double-checking the PM runtime code, it sounds to me that just calling pm_runtime_disable() would be enough. Not 100% sure here. Btw, some media drivers call it after pm_runtime_disable(), while others don't do. Thanks, 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 90297C433B4 for ; Tue, 27 Apr 2021 09:44:47 +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 D23B9613B4 for ; Tue, 27 Apr 2021 09:44:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D23B9613B4 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=ckrogYFasGxC3EuAsD9f0IGkGi3hKLieixQlZPtcHdc=; b=D/vsqEr0fEZkX9MIm0BhHslIq /oMkRIbKrA4BI8bSsW4ftVQ0ueaJ1qc0F8dPiElBygOv/PUqpNO8lCv74H+gWbovgHWIy+cAEAySx 71He0vxpUWZ3k6bT45YX4U63k/Bc2KBjzfCwaJImW9pve0raPXPivTUc/9c1wTG+To56ucoYNSUt4 2QYY1hlR7pLbp65hs1P7p1Kuf9QajFjASLhY03DeSg+T5ynqYdBDXWs4CCI5ObOXKwarQIs6yuqN2 6PCDrRnhhZq6sOavg5bSj3ArkLYMIE86PjZnpOJ2QNOIHWGBFz36oRs4JHGm5FIF5en0AASN/vueu htJkn7G3Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lbKEy-001Fc5-6U; Tue, 27 Apr 2021 09:42:49 +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 1lbKEu-001Fbl-W3 for linux-arm-kernel@desiato.infradead.org; Tue, 27 Apr 2021 09:42:45 +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=HQSh6siBs8YI0G05jK8b88mJs6mLSdn5hE0k1d4P/bY=; b=Gf8UG/xyRu8CAlYeBHDW9EKfig qyep6acRNQD40hFJiJTmOf60q5rOeX3xhBfSMzpTThR1PTwVjrNK9EhYPW7sAhsOE5vNh9BOszne0 p/YxNpBPPGH3a3J3mFbIYvsW8sWrQbDWqJZ9xt4ZjUgEhrDU9HIJomfPHnaEgnZnRQW+jJXLphIXE Mzjpl2gej7DuqFoo/CTtfcY2neC2xzXPm2lXuYqmSnwlneEYsIqY9tAYajUWjM+j56CgSdZdy1rwl SXeXVFh97ufNTjLa6g2DYhT95vOg4Sh4KPvSD4dmVDKO/neK+znORMiJkviZXUY2dHQc6oHcqITz3 LJ+fz8IA==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lbKEs-00Gao9-3D for linux-arm-kernel@lists.infradead.org; Tue, 27 Apr 2021 09:42:43 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8FAB8613B4; Tue, 27 Apr 2021 09:42:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619516561; bh=cCsXwAcyngCcHKVryOwBkBlvyM5OFInMmuy/vcrTNbE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=nQGPC/YzQ6tBi9NYQj7e1e3N9EvP/zd2pgL+xJTQv4ISAw6LyoJPePKAYDS7toc5M FpMFunG31iGzpi8VAfxovcPQ6wuiDwsLJMxyidG5y2+lNmox3P53N4sQcq6Qj+0DXl A6LNrlH2alTv6uTfbOzsHqN9vimhJHfWUvCjG+CfeYmw65w/99ptJV9adTnVj38fCG JxKFC3qn40GIe03j1dh/8AxcIwpi/d9rcwo1941UokGkbDcylwNkVXxOqcUUn8WTOt Hb8hFysO4iPPK3k73ptjYPXUXJ4I29stGLn6330dW1NAkgUavwYw+vy63iwpyNSZG7 yfxoXb1zW2fcA== Date: Tue, 27 Apr 2021 11:42:35 +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: <20210427114235.45a7b2a4@coco.lan> In-Reply-To: <20210427113055.745d0560@coco.lan> References: <9c7d683907b9f9cf4a99f57f978671ec7f5a1dbc.1619191723.git.mchehab+huawei@kernel.org> <20210427113055.745d0560@coco.lan> 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_024242_233330_C6EA30C3 X-CRM114-Status: GOOD ( 27.76 ) 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 11:30:55 +0200 Mauro Carvalho Chehab escreveu: > 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); In time: I actually meant: pm_runtime_set_suspended(&pdev->dev); but after double-checking the PM runtime code, it sounds to me that just calling pm_runtime_disable() would be enough. Not 100% sure here. Btw, some media drivers call it after pm_runtime_disable(), while others don't do. Thanks, Mauro _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel