Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp4335510pxy; Tue, 27 Apr 2021 02:32:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlHiZ9qvFaYfAzgrKOg5E/n8P8yrLI2RyqRppN8YTt4lYaN1Tl3WK12HtaFUiiVablQCAT X-Received: by 2002:a17:906:ecb8:: with SMTP id qh24mr23255073ejb.162.1619515944228; Tue, 27 Apr 2021 02:32:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619515944; cv=none; d=google.com; s=arc-20160816; b=rug5nMKP3e2mtcdUZ+LdDujCZQEtdGd97l/48Ylta1hmJWfzPkc2RQeHVWpIrtTPZ7 a41eza83v9rip3EmZNjby8G9pvO765ssHFuMOmUseUbQFnU8D7PoI8iJ+7vzmJvaTcyO QwfJcgKLxK3dQ2PfnFVLvG+4PxFhvG9IOcI84aeRBCF/LNZsMJbhWlZpb1DEYe3XxDhw sGUPH9zWh3nBTUDyOXy5r/UrySLla+AZHXlPw4gIlPrlPCr8vgTduc4TzJiEojDk6tUh j/Ijb5yvc2R7A7lYlyWan48qzwGenynRx6F2yd6Jzzl0QdtUB9Rhqc7JvRRwgDadNG6e wCCA== 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:subject:cc:to:from:date :dkim-signature; bh=hzP3/q/HARkKMvalhUt07THw7GVz6CvUFVk2ZIn+ZNE=; b=0BnF9JBwe4HkJ6EVXa61wcWX6l2V3fGnZcPqWvb70fgFmP+GDJvm0p24ffh3ogX4oh AsRU/81VrrphZ54kG9O6eNyNY+3QOu5sfNJXo5X1jEt8/9GdOR2M2qLxBLNAlrJwyEHm W0rpbvj/kKdIYpUFzlOYmtTel6YG4LiGM8WrNTUuCZK+m7SOhOcpLhZ0c1gJ6nr44QX/ 4ETZSr7DMAR1TWYGjlFkQ4VV0fydx19+qRtPeWT/8oaEe5EVbuWJlWMu7177acAF8m5J yLMtUMu9dcHNs0QP+lwg+6LNq20k/bcny/KUBd5N5a802Wc2CI1ro3ecnx/ZYG+RmPem Ontg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dR+eRUUc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i11si2324122edb.109.2021.04.27.02.31.59; Tue, 27 Apr 2021 02:32:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dR+eRUUc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235101AbhD0Jbw (ORCPT + 99 others); Tue, 27 Apr 2021 05:31:52 -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