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=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 87DA2C48BE8 for ; Wed, 16 Jun 2021 08:03:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7750561159 for ; Wed, 16 Jun 2021 08:03:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232170AbhFPIFg (ORCPT ); Wed, 16 Jun 2021 04:05:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:59826 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232180AbhFPIF0 (ORCPT ); Wed, 16 Jun 2021 04:05:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2A0DD6054E; Wed, 16 Jun 2021 08:03:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623830600; bh=ncVQbKvI+5ZDzKcl17LQck+CzDMFm6fJjp6HiCL65d0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=UAxJ+V3Ka3GiqQPvQFw14fFvacfVGwvqaByAJ2vZQHxMP/ZijqBsrbmKf5HsmaNuM SD6y985sWOEGiflOMmb9aB1Dl2nfW68UGr3Ve62aY92b04+zFr9sR7kgCbKRzHTP0y lITqks6LYLpk8EX7u0rHFczgjeo8YRow2j4UlMxtckHjXECTt6DCFfq20rYvIKuKe/ 7fF2DKseD4FRKL5IqHFZgrZ3DCcYF4XCioPoKxZMGuScy3H5llKd0QtclfKPP82KXM 0JGMSyvdOXUVXKTaNigx5j7h0aXA4swFfzYpDiBn0+JXZL3LZ+8PA2K7o0hoH6WtR5 PE71/cVh2yylA== Date: Wed, 16 Jun 2021 10:03:14 +0200 From: Mauro Carvalho Chehab To: Cc: , , , , , , , , , , Subject: Re: [PATCH 08/25] media: atmel: properly get pm_runtime Message-ID: <20210616100314.143a5bb5@coco.lan> In-Reply-To: References: <975645970144b6c8401ab9bd1243619978a868a9.1620207353.git.mchehab+huawei@kernel.org> <20210505130835.000006b7@Huawei.com> <20210610113827.57db9e77@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 Thu, 10 Jun 2021 12:00:42 +0000 escreveu: > On 6/10/21 12:38 PM, Mauro Carvalho Chehab wrote: > > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe > > > > Em Thu, 10 Jun 2021 09:04:07 +0000 > > escreveu: > > > >>>> diff --git a/drivers/media/platform/atmel/atmel-isc-base.c b/drivers/media/platform/atmel/atmel-isc-base.c > >>>> index fe3ec8d0eaee..ce8e1351fa53 100644 > >>>> --- a/drivers/media/platform/atmel/atmel-isc-base.c > >>>> +++ b/drivers/media/platform/atmel/atmel-isc-base.c > >>>> @@ -294,9 +294,13 @@ static int isc_wait_clk_stable(struct clk_hw *hw) > >>>> static int isc_clk_prepare(struct clk_hw *hw) > >>>> { > >>>> struct isc_clk *isc_clk = to_isc_clk(hw); > >>>> + int ret; > >>>> > >>>> - if (isc_clk->id == ISC_ISPCK) > >>>> - pm_runtime_get_sync(isc_clk->dev); > >>>> + if (isc_clk->id == ISC_ISPCK) { > >>>> + ret = pm_runtime_resume_and_get(isc_clk->dev); > >>>> + if (ret < 0) > >>>> + return ret; > >>>> + } > >> > >> Hi Mauro, > >> > >> With this patch, the ISC is broken on latest media tree. It looks like > >> pm_runtime_resume_and_get for the ISC_ISPCK clock returns -ENOACCESS and > >> thus, the probe of the driver fails: > >> > >> atmel-sama5d2-isc f0008000.isc: failed to enable ispck: -13 > >> atmel-sama5d2-isc: probe of f0008000.isc failed with error -13 > >> > >> > >> Could you point out how I could fix this ? Maybe the isc_clk->dev is not > >> properly handled/initialized in some other part of the code ? > > > > Looking at RPM implementation: > > > > static int rpm_resume(struct device *dev, int rpmflags) > > { > > ... > > if (dev->power.runtime_error) > > retval = -EINVAL; > > else if (dev->power.disable_depth == 1 && dev->power.is_suspended > > && dev->power.runtime_status == RPM_ACTIVE) > > retval = 1; > > else if (dev->power.disable_depth > 0) > > retval = -EACCES; > > ... > > > > It sounds that RPM is disabled for this clock. Did you call > > pm_runtime_enable() before calling isc_clk_prepare()? > > > > Thanks, > > Mauro > > > > I tried to call pm_runtime_enable for the clk at clk_init time, but > doing that makes the runtime for the ISC fail like this: > > atmel-sama5d2-isc f0008000.isc: Unbalanced pm_runtime_enable! Making RPM balanced is complex ;-) Yet, clearly there's something weird at the PM code. I mean, ignoring a -ENOACCESS error like the original code sounds wrong, as it basically means that pm_runtime_get_sync() were doing nothing (except by incrementing a refcount). Some drivers call clk_prepare()/clk_unprepare() at their .prepare/.unprepare ops. Those functions internally call RPM get logic recursively, to ensure that the RPM state of the parents are also at the right state. 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=-10.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 E99D5C48BE6 for ; Wed, 16 Jun 2021 08:04:59 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B896F6054E for ; Wed, 16 Jun 2021 08:04:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B896F6054E 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=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject: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=D9t9XTNMQ6bTEXiZe6JmHqOn0UzoVAyd/UEwkTNMIbQ=; b=GSEKz04cvMOXW6 lJXZbldFD+3SvLCciEy/WoCy4b6tpdXRtymrIdxcWD83Y1Vba/R8WgFkfnm/ieQ9lnp/7ZvSeqrIb yyZ8ZAOoq1QabLeyj9kEWqnj9dKxIKCnPKRCfs6asn13CWxSXpyPKh6pkVbRFyZJUsTwhBqtQetBe EMOoVHw8QOs24D8pD1PXAsr1JpAhWmvkZ4FfeCNqPkvuHmvHhTUQ6Y3j7Lk8M+ad14eIeYBYv4Wny ZbERRKkCz/twgZwTztekp/7EjIn8Hkyt3b5C33lSe+Z0hnJB2es9ILvKsyTYPsIWK4P/X7VOW7NGs Q9aqvbdcZUjw/t5Ip8SQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltQWE-005Jez-88; Wed, 16 Jun 2021 08:03:26 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltQW9-005JdP-1k for linux-arm-kernel@lists.infradead.org; Wed, 16 Jun 2021 08:03:22 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2A0DD6054E; Wed, 16 Jun 2021 08:03:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623830600; bh=ncVQbKvI+5ZDzKcl17LQck+CzDMFm6fJjp6HiCL65d0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=UAxJ+V3Ka3GiqQPvQFw14fFvacfVGwvqaByAJ2vZQHxMP/ZijqBsrbmKf5HsmaNuM SD6y985sWOEGiflOMmb9aB1Dl2nfW68UGr3Ve62aY92b04+zFr9sR7kgCbKRzHTP0y lITqks6LYLpk8EX7u0rHFczgjeo8YRow2j4UlMxtckHjXECTt6DCFfq20rYvIKuKe/ 7fF2DKseD4FRKL5IqHFZgrZ3DCcYF4XCioPoKxZMGuScy3H5llKd0QtclfKPP82KXM 0JGMSyvdOXUVXKTaNigx5j7h0aXA4swFfzYpDiBn0+JXZL3LZ+8PA2K7o0hoH6WtR5 PE71/cVh2yylA== Date: Wed, 16 Jun 2021 10:03:14 +0200 From: Mauro Carvalho Chehab To: Subject: Re: [PATCH 08/25] media: atmel: properly get pm_runtime Message-ID: <20210616100314.143a5bb5@coco.lan> In-Reply-To: References: <975645970144b6c8401ab9bd1243619978a868a9.1620207353.git.mchehab+huawei@kernel.org> <20210505130835.000006b7@Huawei.com> <20210610113827.57db9e77@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-20210616_010321_243159_F325526A X-CRM114-Status: GOOD ( 25.98 ) 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: , Cc: alexandre.belloni@bootlin.com, linux-kernel@vger.kernel.org, linuxarm@huawei.com, Ludovic.Desroches@microchip.com, Jonathan.Cameron@Huawei.com, mauro.chehab@huawei.com, mchehab@kernel.org, Claudiu.Beznea@microchip.com, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org 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 Thu, 10 Jun 2021 12:00:42 +0000 escreveu: > On 6/10/21 12:38 PM, Mauro Carvalho Chehab wrote: > > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe > > > > Em Thu, 10 Jun 2021 09:04:07 +0000 > > escreveu: > > > >>>> diff --git a/drivers/media/platform/atmel/atmel-isc-base.c b/drivers/media/platform/atmel/atmel-isc-base.c > >>>> index fe3ec8d0eaee..ce8e1351fa53 100644 > >>>> --- a/drivers/media/platform/atmel/atmel-isc-base.c > >>>> +++ b/drivers/media/platform/atmel/atmel-isc-base.c > >>>> @@ -294,9 +294,13 @@ static int isc_wait_clk_stable(struct clk_hw *hw) > >>>> static int isc_clk_prepare(struct clk_hw *hw) > >>>> { > >>>> struct isc_clk *isc_clk = to_isc_clk(hw); > >>>> + int ret; > >>>> > >>>> - if (isc_clk->id == ISC_ISPCK) > >>>> - pm_runtime_get_sync(isc_clk->dev); > >>>> + if (isc_clk->id == ISC_ISPCK) { > >>>> + ret = pm_runtime_resume_and_get(isc_clk->dev); > >>>> + if (ret < 0) > >>>> + return ret; > >>>> + } > >> > >> Hi Mauro, > >> > >> With this patch, the ISC is broken on latest media tree. It looks like > >> pm_runtime_resume_and_get for the ISC_ISPCK clock returns -ENOACCESS and > >> thus, the probe of the driver fails: > >> > >> atmel-sama5d2-isc f0008000.isc: failed to enable ispck: -13 > >> atmel-sama5d2-isc: probe of f0008000.isc failed with error -13 > >> > >> > >> Could you point out how I could fix this ? Maybe the isc_clk->dev is not > >> properly handled/initialized in some other part of the code ? > > > > Looking at RPM implementation: > > > > static int rpm_resume(struct device *dev, int rpmflags) > > { > > ... > > if (dev->power.runtime_error) > > retval = -EINVAL; > > else if (dev->power.disable_depth == 1 && dev->power.is_suspended > > && dev->power.runtime_status == RPM_ACTIVE) > > retval = 1; > > else if (dev->power.disable_depth > 0) > > retval = -EACCES; > > ... > > > > It sounds that RPM is disabled for this clock. Did you call > > pm_runtime_enable() before calling isc_clk_prepare()? > > > > Thanks, > > Mauro > > > > I tried to call pm_runtime_enable for the clk at clk_init time, but > doing that makes the runtime for the ISC fail like this: > > atmel-sama5d2-isc f0008000.isc: Unbalanced pm_runtime_enable! Making RPM balanced is complex ;-) Yet, clearly there's something weird at the PM code. I mean, ignoring a -ENOACCESS error like the original code sounds wrong, as it basically means that pm_runtime_get_sync() were doing nothing (except by incrementing a refcount). Some drivers call clk_prepare()/clk_unprepare() at their .prepare/.unprepare ops. Those functions internally call RPM get logic recursively, to ensure that the RPM state of the parents are also at the right state. Thanks, Mauro _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel