Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp876173rwi; Mon, 31 Oct 2022 08:33:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7zburgmycda3bR9gegv0OxeonDjcmBXeiFB66IPXGAV80GPAM4oOJt80kn01PXc9jVLXm6 X-Received: by 2002:a05:6402:2a03:b0:463:11e7:cd5f with SMTP id ey3-20020a0564022a0300b0046311e7cd5fmr11127316edb.274.1667230417278; Mon, 31 Oct 2022 08:33:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667230417; cv=none; d=google.com; s=arc-20160816; b=ZDxt5am3DTxZe0+w1H8jKzJbhEX1bofv7+LI0TIe4v+GrOo1cx4CKi/+DR2oB8J+7D JpWS+nXiDg/tp8ha7hG1t+MwR0geqZPGW6qdrwdsC0rSU6qYo+I0aEeJpm9DBTr+ds2t Ope8SM0TKBa3roCGItmrc55T18aAr5g0URUaiEc1ZQZei+nASPL5Qs2w2n6PdostsESF MfSOhII1ZZ7CVJMPyCBo1JB86+VEyySWmuptY9TidYA2dmkt+QFNwf/qOOq6goIdAu/g 0jxBIqocRwF13poMqwUf1+/ip9I2wGi5gAtHOVDOg8TVYDLJ2k2dj7fupEMRHWbwA2Mo +UqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=q1C1sSK1wOPpHrmuERewUm2aqnv24ykF1hbcAHDxJqk=; b=CMagI/PKfYTHdHATrKYwnrJBIT0UUK1us/pZnKSPMNnfylpGhIZSBKWu0ou4RoQoKM ajtgBKK90Lot0KM78My4vEH68z1rEV1/WeF1s/r3X7zo5DHewNZcXFpyQzdlK3W3X+Xy UHmnk7AsLaXq57JgJTxL9LOKybiV0NUXhJ1Yw+al/A8G0YnumfUzc23/O+h537Ec5jzX hDdapA2Qu8AJJhMiQ3PrJF6u6AlhX5I4Miczff29Uq0aXcMQNvmCXPwaXl24Hq3WR2jl 17/UVL33mn3mXwzIKzyDz7iBurEbG7g6ocFHf1B+Yl4EiHcQYakzRL+uT9sOWtEExotD ravw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XmutTOas; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g41-20020a056402322900b00457c6b5dc07si8003032eda.455.2022.10.31.08.32.59; Mon, 31 Oct 2022 08:33:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XmutTOas; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231560AbiJaOZq (ORCPT + 98 others); Mon, 31 Oct 2022 10:25:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231381AbiJaOZo (ORCPT ); Mon, 31 Oct 2022 10:25:44 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 936116260; Mon, 31 Oct 2022 07:25:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667226343; x=1698762343; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=lZSalSSwi49EzYHTba+DNGAOjjgmfsm6XxBlo4aUqfg=; b=XmutTOasqiv6i0LnIDmDQ7tI4tAlGeJSEDQHyQCLjcXP4puTkLIV8pVV lhisU+OB59wKoyyVRssDUiFa3lhib6gXTkSO1SD1fjmGS6ChZbhgFV80/ eKeCvg8tB/+OkOGRHjr3xgPeApNRSwcokKAcAPzo8017TfPlXIlc9/B0x N0JeiU0RslTlf/dQp4H77+Z99p/8aYjdi5IxeXxC5LGrR2kiuT5SlEum9 R9qBHIKiM+QsualrpsNJwbomKD7OT4YFh8S68Ff88PG0rWQpWm/La3wlt DZnz0+FUbDzakmt8BCjhkVA875UqIRVkRTSm2qtD0kIeAaf3UpvmLbxu1 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="309995139" X-IronPort-AV: E=Sophos;i="5.95,228,1661842800"; d="scan'208";a="309995139" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2022 07:25:43 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="636064988" X-IronPort-AV: E=Sophos;i="5.95,228,1661842800"; d="scan'208";a="636064988" Received: from punajuuri.fi.intel.com (HELO paasikivi.fi.intel.com) ([10.237.72.43]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2022 07:25:39 -0700 Received: from paasikivi.fi.intel.com (localhost [127.0.0.1]) by paasikivi.fi.intel.com (Postfix) with SMTP id 8C37B20210; Mon, 31 Oct 2022 16:25:37 +0200 (EET) Date: Mon, 31 Oct 2022 14:25:37 +0000 From: Sakari Ailus To: "Lad, Prabhakar" Cc: Laurent Pinchart , Krzysztof Kozlowski , Rob Herring , Mauro Carvalho Chehab , Hans Verkuil , Shawn Tu , Jacopo Mondi , linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Biju Das , Lad Prabhakar Subject: Re: [PATCH v2 2/5] media: i2c: ov5645: Use runtime PM Message-ID: References: <20221014183459.181567-1-prabhakar.mahadev-lad.rj@bp.renesas.com> <20221014183459.181567-3-prabhakar.mahadev-lad.rj@bp.renesas.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Prabhakar, On Thu, Oct 27, 2022 at 06:37:58PM +0000, Sakari Ailus wrote: > Hi Prabhakar, > > On Thu, Oct 27, 2022 at 05:32:07PM +0100, Lad, Prabhakar wrote: > > Hi Sakari, > > > > On Thu, Oct 27, 2022 at 1:47 PM Sakari Ailus > > wrote: > > > > > > Hi Prabhakar, > > > > > > On Thu, Oct 27, 2022 at 01:01:52PM +0100, Lad, Prabhakar wrote: > > > > Hi Sakari, > > > > > > > > On Thu, Oct 27, 2022 at 12:20 PM Sakari Ailus > > > > wrote: > > > > > > > > > > Hi Prabhakar, > > > > > > > > > > One more comment. > > > > > > > > > > On Fri, Oct 14, 2022 at 07:34:56PM +0100, Prabhakar wrote: > > > > > > @@ -1209,12 +1190,16 @@ static int ov5645_probe(struct i2c_client *client) > > > > > > > > > > > > dev_info(dev, "OV5645 detected at address 0x%02x\n", client->addr); > > > > > > > > > > > > + pm_runtime_set_active(dev); > > > > > > + pm_runtime_get_noresume(dev); > > > > > > + pm_runtime_enable(dev); > > > > > > > > > > You won't gain anything by eanbling runtime PM here. Just move it to the > > > > > end of the function before the rest of the calls. Error handling becomes > > > > > more simple. > > > > > > > > > If I move the above calls below I get the below warning: > > > > > > > > [ 2.633386] ov5645 0-003c: Runtime PM usage count underflow! > > > > > > > > This is because of the last patch which moves ov5645_entity_init_cfg() > > > > before registering the subdev. ov5645_entity_init_cfg() calls s_ctrl > > > > due to which we are seeing the above message. Please let me know how > > > > to proceed on this. > > > > > > Ah. Yes, this is a problem with the usage pattern of > > > pm_runtime_get_if_in_use(). But please don't change that. > > > > > > You can still move enabling runtime PM later in the function. > > > > > Agreed, the final version looks like below: > > > > pm_runtime_set_active(dev); > > pm_runtime_get_noresume(dev); > > > > You'll have to enable runtime PM here, before pm_runtime_get_if_in_use() > gets called. > > I'll see if it could be made to work in a sensible way when runtime PM > isn't enabled yet. There are various ways how runtime PM interface functions generally work, and generally return an error when runtime PM is disabled. Incrementing the usage_count when runtime PM is disabled would make pm_runtime_get_if_in_use() very special and not match what the rest would do. Therefore I think it's best to keep this in the driver. After all, mo other driver needs this in the media tree, which is the major user of the function. -- Kind regards, Sakari Ailus