Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp988715rwi; Mon, 31 Oct 2022 09:51:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4AQFrd4iVD+vrcWGOxlXfKqoOLaYBrqPjyW4qrhsIdcOMf8vbY5GPX4qRZ04D+7yCnK58Y X-Received: by 2002:a17:902:9b88:b0:17c:97d6:5e78 with SMTP id y8-20020a1709029b8800b0017c97d65e78mr15219514plp.62.1667235061855; Mon, 31 Oct 2022 09:51:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667235061; cv=none; d=google.com; s=arc-20160816; b=JDT0M1+3owL5qn8jMEW2pXpwtFDXNdqt06nPhkg2MWQ5ZfTQP+U71yujpeic4Hajqi Vpp49uTzgVbCngNPTj1VwFi8EkH3Z8BjnAh1whbcWA5KHW+fkUsh3QO7HBw2fSG3aK3q mRvkSXCDhriPSdARgmXj2RtGsE183mKGgyyG5P/uM/OUWDo8aBvKH1sQWAV3NRnBEA3U 89LE7kAb6kJKOpWfsLxbM5w3v1hR6d96XSUIlM64JIULtRcJ/8VCQkZhE/ZKztS16V/S JdMDZaMaXpvOCARZ1BVbezVYD89uYBLCrPUDspSAMq5Dpl5xnhEKPvR3Cby8NWvdf+10 GN/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=iCzM+z8lbU3sUbT7i4WqD5Kg67j9Dyb20Cc1XCa8sRM=; b=CMpXZiHq70mfjPqnmtZiGhWItNeJ3lT02shmOOGtp2uDmBsI/SN3sD2YTCa07TGb/+ ZERx7GczV4pbgWGlcO8JpGIm1thRXa5siBjx8W3Ab4zSINEYi94PJy4JdIhm/jll/0tc Pv86dUPD4QZ4C0ZWdgwZr0cri7qC+HaksDVfFaDrAsmoyK3WCLCyGPrPrLyJ8oHM48I4 YApvNe/W0F6lNjSvqfxGyPL2R0kPODDJkitOb1z08E/gSToiEX2uj7DxcdkInRj9hOmX YxEyDCqIakk9awDVlPUCLnnSrk7ZrMAj1TzpyNPaEmeDbQnyW7PWNy8ik6QJ/pUbYo7z v5iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qKqmZWqo; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s16-20020a170902ea1000b00186c5e8ceddsi10634519plg.618.2022.10.31.09.50.48; Mon, 31 Oct 2022 09:51:01 -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=@gmail.com header.s=20210112 header.b=qKqmZWqo; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231290AbiJaQLQ (ORCPT + 98 others); Mon, 31 Oct 2022 12:11:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229947AbiJaQLO (ORCPT ); Mon, 31 Oct 2022 12:11:14 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7367DF61; Mon, 31 Oct 2022 09:11:13 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id 21so18166550edv.3; Mon, 31 Oct 2022 09:11:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=iCzM+z8lbU3sUbT7i4WqD5Kg67j9Dyb20Cc1XCa8sRM=; b=qKqmZWqo0DkJvx0vYCMHgc8guzN8iVhj59dDHl16HPXO4yL9xeYSfmTVB87fLCXkds /q0gAMJ3hYKLh/JC2740UsBREiIvBWInMT8We1fJapvSCu2k9WvdFpDG5O16LMPH/qYC u8Ia8txchf1OK2lP0+LYcYa0PvD3EMSyJVkgrf85D7gQ1lTdgbzTVbqOWi6llu9mJSKe 5BlUQSGfj9enWi8ecWCwMouY5FFuqy45snE6um9sh/TJPGfu+yCS0C8IGRKjyUSapizZ ARgl3abqhJTrr8ctR/z8vuF06gMSFbZ7EEgNrzrQtZwvlmb4ObZ02BI07zvN7zCpefQo ouxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=iCzM+z8lbU3sUbT7i4WqD5Kg67j9Dyb20Cc1XCa8sRM=; b=xr7jQ3+3JNkpmGtbQBzhpgP3CXS4mCyeYFVPyqjYdyQ75yQTvWTzpye68cbp3ri/yD uNVEzAMsi3wF7jdCz5YveWZ4U5bXOEcM287pYUD881kzLHbO45Drg+X0b0BJC/umin9Z fwBAzTzoULKYqjVClzp+m3Fqj/rpsyq1A4b5/2PosI64BvV2S6Wj6gSNTPIR3OtQoTHe VSozrosLBydiIn0SLRDNOY+RvFWBCE4hUbfny0oh6keqRf4JpqddzDLAFAEx4ASYU4O4 dbTzt8XKNn6YwNVwqL2kcmkBbS8PRzyPILPnh1HbjGgBc25orKZcj7h2eNjzJOoozM4m o16A== X-Gm-Message-State: ACrzQf3Q42wwpCizkIJGsQsB+8gKqQwoTk7DXzpZpZyqTXMdp+04WXlB xyydiqOf64WeEVRFr7AFquQJXaFB/SiuPdsEaOo= X-Received: by 2002:aa7:de0a:0:b0:462:d2a0:93a with SMTP id h10-20020aa7de0a000000b00462d2a0093amr13865340edv.275.1667232672211; Mon, 31 Oct 2022 09:11:12 -0700 (PDT) MIME-Version: 1.0 References: <20221014183459.181567-1-prabhakar.mahadev-lad.rj@bp.renesas.com> <20221014183459.181567-3-prabhakar.mahadev-lad.rj@bp.renesas.com> In-Reply-To: From: "Lad, Prabhakar" Date: Mon, 31 Oct 2022 16:10:45 +0000 Message-ID: Subject: Re: [PATCH v2 2/5] media: i2c: ov5645: Use runtime PM To: Sakari Ailus 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 Sakari, On Mon, Oct 31, 2022 at 2:25 PM Sakari Ailus wrote: > > 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. > Thank you for digging deep into this. I'll keep it as is and send a v3. Cheers, Prabhakar