Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp5912212pxv; Wed, 7 Jul 2021 14:55:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZ3UQbcjOkkpGQl52FNr8rdGDccU9SHqbxfMsvVk5ybxzbELvl+FnG4wbf0uL08bNqAod8 X-Received: by 2002:a05:6402:c10:: with SMTP id co16mr32208326edb.192.1625694922590; Wed, 07 Jul 2021 14:55:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625694922; cv=none; d=google.com; s=arc-20160816; b=wRCv/kAHe2HBUtbNiMS9fUu/oZmzKUDvxB4e/i4Fu5kefkDO5oTSLxSSrbyhQl4mIO 5Wci2MdQD2h2NQmXvFy4pPxdUKB5Y5X7sYOdAqTJhF6gD/tihiKqRm+gWuBHD1GXtLEy fisFYk2SSo2DojU1ebK08kVG86QhUNU1PlCuZDAUDQBo9/Stf1HLcQCM+9mhTBdn2dbl xn/Gw22uIpUcAvCMOxG7YqPr5V0PIeYXYOrIcylPEAFlKJqFEcWSbkxQ6rs6xAK8BGSn MqAUNx7JEGm288+vn02HPy+pxgW4tQzB/jMf1YpAtN5r9CYt0nb9SGBlJxcpF0wfIccZ gOmw== 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=5hdctBq3SMlGutDcaZBPhGcVFHyHSmLK798TEqba1c8=; b=RDO51cSxUziEm1WOdZaMmmfFC8mmTuCu+xnWzGrjBxTggCexJSUlrHrdmmajlGyrlT Exn22R7K8lWyRgppkg30SBcgnqOsPCUqI2PNdN0P4tDiwgH4b9jyJQETWK8tSBRHtGwn rO0yNcZcn1VUnFZempisBMqc0r3Ae+/mllZRODiM+0CtY4oTSxVv6HaZPAXBkbIUn00j SsJddaF0ZUYaeZszkq52GJLFDQ3tJjBPORszrTfOUGuNyWHZ1tU/mI2XRvRevRlI15Bz +EkadniCv51pNS7k7WeTtSfc1703jRPpO+NnnqfFIxvuPMXIVd6gOe3jAbgDPL0BMrHO zpQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=wEm0jXB3; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m1si360981edc.121.2021.07.07.14.54.59; Wed, 07 Jul 2021 14:55:22 -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 (test mode) header.i=@ideasonboard.com header.s=mail header.b=wEm0jXB3; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231245AbhGGVyn (ORCPT + 99 others); Wed, 7 Jul 2021 17:54:43 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:45354 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230019AbhGGVym (ORCPT ); Wed, 7 Jul 2021 17:54:42 -0400 Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id EA355466; Wed, 7 Jul 2021 23:51:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1625694720; bh=OSAPN5cM+ghp47WMtV8+9rqlGAFzG+ZMGLoDO2gfpyw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=wEm0jXB3V1H5KzyVKhye7wbJ3SzZDINTZG/Yk31MqVdmN5GqdOu6A/WbYuzUwyJXP SWNlj8pJstt/MeAs21l+GaarVo68m/FTvKY81tMh2nBFdd+tDge0dv99SoZ4CyVjqa WmSFWgS54gUveZXezfBWFfIpI+gsRcJHKpNY6foM= Date: Thu, 8 Jul 2021 00:51:16 +0300 From: Laurent Pinchart To: Sakari Ailus Cc: Pratyush Yadav , Mauro Carvalho Chehab , Vignesh Raghavendra , Tomi Valkeinen , Nikhil Devshatwar , Dongchun Zhu , Jacopo Mondi , Kieran Bingham , Martina Krasteva , Paul Kocialkowski , Raag Jadav , Steve Longerbeam , Tianshu Qiu , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: Re: [PATCH v3 01/11] media: ov5640: Use runtime PM to control sensor power Message-ID: References: <20210624192200.22559-1-p.yadav@ti.com> <20210624192200.22559-2-p.yadav@ti.com> <20210707203718.GX3@paasikivi.fi.intel.com> <20210707214415.GY3@paasikivi.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210707214415.GY3@paasikivi.fi.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sakari, On Thu, Jul 08, 2021 at 12:44:15AM +0300, Sakari Ailus wrote: > On Thu, Jul 08, 2021 at 12:00:57AM +0300, Laurent Pinchart wrote: > > On Wed, Jul 07, 2021 at 11:37:18PM +0300, Sakari Ailus wrote: > > > On Fri, Jun 25, 2021 at 12:51:50AM +0530, Pratyush Yadav wrote: > > > > Calling s_power subdev callback is discouraged. Instead, the subdevs > > > > should use runtime PM to control its power. Use runtime PM callbacks to > > > > control sensor power. The pm counter is incremented when the stream is > > > > started and decremented when the stream is stopped. > > > > > > > > Refactor s_stream() a bit to make this new control flow easier. Add a > > > > helper to choose whether mipi or dvp set_stream needs to be called. The > > > > logic flow is also changed to make it a bit clearer. > > > > > > > > Signed-off-by: Pratyush Yadav > > > > > > > > --- > > > > > > > > Changes in v3: > > > > - Clean up the logic in ov5640_s_stream() a bit. > > > > - Use pm_runtime_resume_and_get() instead of pm_runtime_get_sync(). > > > > - Rename the label error_pm to disable_pm. > > > > > > > > Changes in v2: > > > > - New in v2. > > > > > > > > drivers/media/i2c/Kconfig | 2 +- > > > > drivers/media/i2c/ov5640.c | 127 +++++++++++++++++++++++-------------- > > > > 2 files changed, 79 insertions(+), 50 deletions(-) > > > > > > > > diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig > > > > index 588f8eb95984..8f43a4d7bcc1 100644 > > > > --- a/drivers/media/i2c/Kconfig > > > > +++ b/drivers/media/i2c/Kconfig > > > > @@ -929,7 +929,7 @@ config VIDEO_OV2740 > > > > > > > > config VIDEO_OV5640 > > > > tristate "OmniVision OV5640 sensor support" > > > > - depends on OF > > > > + depends on OF && PM > > > > > > Could you add support for runtime PM without requiring CONFIG_PM? > > > > > > Essentially you'll need to power on the device in probe and power it off in > > > probe, and make sure the runtime PM nop variant functions return the value > > > you'd expect. > > > > I've gone through that in several sensor drivers, and it really > > increases the complexity to get it right, to a point where I'm not > > comfortable asking someone to do the same (not to mention the very, very > > I don't think it's very complicated, really. Looking at examples of other > drivers (e.g. imx334) doing exactly the same helps as you don't need to > check for individual functions. > > The complexity of the power management in this driver is mostly because of > evolutionary development done over time, it's an old driver. https://git.linuxtv.org/pinchartl/media.git/commit/?h=sensors/ar0330/driver&id=e72ca23c4c6b1ab6b06ac48280726e09d63cc818 Look at the changes to ar0330_probe(). As far as I understand, anything less than that would be incorrect, and it's way too easy to get it wrong. > > high chance that it won't be done correctly). What's the practical > > drawback in requiring CONFIG_PM ? > > Good question. CONFIG_PM is something you can disable (for a reason I can't > think of though). Why should a driver depend on it when it could perfectly > work without it as well? Because it requires additional complexity in the driver, times the number of sensor drivers we have in the kernel. Not even mentioning test coverage, I'm pretty sure very few people would test the sensor drivers without CONFIG_PM. > Although this might not amount to a practical drawback. :-) -- Regards, Laurent Pinchart