Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp387983rwl; Thu, 6 Apr 2023 21:52:37 -0700 (PDT) X-Google-Smtp-Source: AKy350YgjLQuUePGUsAtHQNAke/dpWOV1WRCRhUCGx5v0RcT5lSMJAUbyPw3uJLUZkeCZfTSpEDz X-Received: by 2002:a17:90b:1d8a:b0:23f:9fac:6b35 with SMTP id pf10-20020a17090b1d8a00b0023f9fac6b35mr1062207pjb.39.1680843157421; Thu, 06 Apr 2023 21:52:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680843157; cv=none; d=google.com; s=arc-20160816; b=g0jqTixZLMYE1KSv89SFk7Z7JhrtA5PPsDHYGezZEyH3UAfp4fdvVwPPRsSZF+D877 a/p+mlZmClUtEqfGHu4cDswwDFew5ys2LnEg8dCMFYcQRRjNCKCdjvD6R/VJ/f5RXYZB yIaLnnKg0lq7Ptf6tRF+YkCAdjIWOKkkx0hsFj94nBHgVLUyE1EAu7pg0sgJr+km7Tba MzY4sAKCB/SEv1ke1q+7Zn36QgHFdggbwoC5vH51/q60gCFTk4McUTJX1lAJeE36ZWVI /YykAuiE0qET2C9/VK4OrCtiH8OfSHD/lDDfa8PNYvKGhtrgxrZNpfxl1KsVWYU/Umwr VdaQ== 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=SMK+EHXC1E+PT+5G2uYVUWbsO5OWpFlzNNir3raJS5g=; b=kRXmV7eC3KZK8bDGq6yOeDCCyTwSV8jtaPuWNZVYvrNOK6GytaSgg8eacyYJ90NN69 dDb4yh15uFzQ3f8/GhDE2iF16UsyJ7XtXLwQq+NCjMS9cecOzt1DHJ2RcwESOwrPFVb4 xhpvrgOd6qKNZ6JruLrfrzzql+yz3gFD4m3kkOo2YENTZXJblihrC3RZUuWFLC/QI53E jJm0Px3xHhAhsWPNUgrWClotsWZFamC7mJtt07jsAiA+OuLAGjAOOygy+4kX77OerXTK eMZDFGaizMp9BxFJdn8T1VlX0n1CbRCwdTjb/WZeeqWClSqPf0xinkub+bTqy/b/butp a/ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=rmo6g0rQ; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ky15-20020a170902f98f00b001a1e308a820si2427552plb.624.2023.04.06.21.52.25; Thu, 06 Apr 2023 21:52: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 (test mode) header.i=@ideasonboard.com header.s=mail header.b=rmo6g0rQ; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233535AbjDGEcZ (ORCPT + 99 others); Fri, 7 Apr 2023 00:32:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230044AbjDGEcX (ORCPT ); Fri, 7 Apr 2023 00:32:23 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9FD68684; Thu, 6 Apr 2023 21:32:21 -0700 (PDT) Received: from pendragon.ideasonboard.com (fp76f193f3.tkyc206.ap.nuro.jp [118.241.147.243]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D806D8A4; Fri, 7 Apr 2023 06:32:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1680841940; bh=DLRyYL7JJWMS2lVd7UMcnWaWD08oLNGHSYb1rviAAL8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rmo6g0rQO3zngyyDEwS7w93QKDXHOqOQdVRItWUzeLvQRXJgEyK2Cw0xGundBT0pd Uz6Pe049SwNVTMTQdFnGEABxOv2vkoCVS0egAnekVnAO1rdTDKnbn5c5kCeO4ty8cM Vha69I3z9nCEd0sEL52vXJQ6UGDpS/c6Ns6A2t04= Date: Fri, 7 Apr 2023 07:32:27 +0300 From: Laurent Pinchart To: Sakari Ailus Cc: Martin Kepplinger , mchehab@kernel.org, kernel@puri.sm, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 1/2] media: hi846: fix usage of pm_runtime_get_if_in_use() Message-ID: <20230407043227.GI31272@pendragon.ideasonboard.com> References: <20230405092904.1129395-1-martin.kepplinger@puri.sm> <20230405092904.1129395-2-martin.kepplinger@puri.sm> <20230406013338.GK9915@pendragon.ideasonboard.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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 Thu, Apr 06, 2023 at 04:36:25PM +0300, Sakari Ailus wrote: > On Thu, Apr 06, 2023 at 04:33:38AM +0300, Laurent Pinchart wrote: > > On Wed, Apr 05, 2023 at 03:52:52PM +0300, Sakari Ailus wrote: > > > On Wed, Apr 05, 2023 at 11:29:03AM +0200, Martin Kepplinger wrote: > > > > pm_runtime_get_if_in_use() does not only return nonzero values when > > > > the device is in use, it can return a negative errno too. > > > > > > > > And especially during resuming from system suspend, when runtime pm > > > > is not yet up again, this can very well happen. And in such a case > > > > the subsequent pm_runtime_put() call would result in a refcount underflow! > > > > > > I think this issue should have a more generic solution, it's very difficult > > > to address this in drivers only with the current APIs. > > > > > > pm_runtime_get_if_in_use() will also return an error if runtime PM is > > > disabled, so this patch will break the driver for that configuration. > > > > I'm increasingly inclined to depend on CONFIG_PM for all camera sensor > > drivers. > > For what reason? This is the smallest of all problems related to power > management. Also runtime PM has no-op functions for just this purpose. Because it creates a myriad of sleep (or bigger) issues like this one, and more seem to be popping up (or coming to my attention at least) over time. > (Frankly it'd be great if we could make CONFIG_PM go away. So perhaps > requiring it everywhere is one feasible approach to do that.) I'm all for it :-) For camera sensor drivers, are you aware of use cases where !CONFIG_PM would be desired ? -- Regards, Laurent Pinchart