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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80F12C433F5 for ; Tue, 29 Mar 2022 13:03:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237080AbiC2NEo (ORCPT ); Tue, 29 Mar 2022 09:04:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237082AbiC2NEn (ORCPT ); Tue, 29 Mar 2022 09:04:43 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FF85DE096 for ; Tue, 29 Mar 2022 06:03:00 -0700 (PDT) Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5A329299; Tue, 29 Mar 2022 15:02:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1648558977; bh=PUGqMw39e78AtV+DbDaYFy3qDpJNZE1y+TPHgT42+K0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aZK/FoqjhCNH9fAUlAxpq59GVMQSNhgrl2wMpFVvtzAeB3tJemRTSsoouNMyNBT78 6d3CMNbY6VUnBLWKO+WGnNb929OiEl+dr3pNTkpYXKlUVEgzWxH/BnrBpiG+PBCUT9 +BxIoR6AzpqwqFgmIyluiGPiclMZMd1BDKOxJWgk= Date: Tue, 29 Mar 2022 16:02:54 +0300 From: Laurent Pinchart To: Sakari Ailus Cc: Paul Elder , Steve Longerbeam , Hans Verkuil , "Paul J. Murphy" , Martina Krasteva , Shawn Tu , Arec Kao , Kieran Bingham , Jimmy Su , Martin Kepplinger , Daniel Scally , Jacopo Mondi , Paul Kocialkowski , linux-media@vger.kernel.org Subject: Re: [PATCH v2] media: ov5640: Use runtime PM Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Hi Sakari, On Mon, Mar 14, 2022 at 11:11:18PM +0200, Sakari Ailus wrote: > On Mon, Mar 14, 2022 at 10:05:37PM +0200, Laurent Pinchart wrote: > ... > > > > Yes, after reading the version register (or doing any other harware > > > > access). Actually the full code would be > > > > > > > > > > > > pm_runtime_enable(dev); > > > > pm_runtime_resume_and_get(dev); > > > > > > > > /* Hardware access */ > > > > > > > > pm_runtime_set_autosuspend_delay(dev, 1000); > > > > pm_runtime_use_autosuspend(dev); > > > > pm_runtime_put_autosuspend(dev); > > > > > > > > (plus error handling). > > > > > > > > If the probe function doesn't need to access the hardware, then > > > > the above becomes > > > > > > > > pm_runtime_enable(dev); > > > > pm_runtime_set_autosuspend_delay(dev, 1000); > > > > pm_runtime_use_autosuspend(dev); > > > > > > > > instead of having to power up the device just in case !PM. > > > > > > > > > Also the latter only works on DT-based systems so it's not an option for > > > > > most of the drivers. Does the former work on ACPI systems ? > > > > How so, what's wrong with the above for ACPI-based system ? > > > > > > I²C devices are already powered on for probe on ACPI based systems. > > > > Not through RPM I suppose ? > > Runtime PM isn't involved, this takes place in the ACPI framework (via > dev_pm_domain_attach() called in i2c_device_probe()). How can we fix this ? It may have made sense a long time ago, but it's making RPM handling way too difficult in I2C drivers now. We need something better instead of continuing to rely on cargo-cult for probe functions. Most drivers are broken. -- Regards, Laurent Pinchart