Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2378570pxj; Mon, 31 May 2021 00:09:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrG9iUiqNGV/R1JxJOsJgSwRnVDj7TdlhEEgZRhSwFcNhljGldMJ1TIAuwGK/H03jErMBM X-Received: by 2002:a05:6e02:2188:: with SMTP id j8mr16479695ila.194.1622444986573; Mon, 31 May 2021 00:09:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622444986; cv=none; d=google.com; s=arc-20160816; b=n5t2bgGaZc2m2VYivkNcgyU5dpfY8kMiJS2h/D6iBND5yrC5S+isyEK1jf/bWZJd6k L+3C/3jSf37IPUm5OVsL0AJsOP+VqT5pWRqko6zhtttiRA85vt5dhKTv969kiOkAXN6U H7tOvVLo7No7aW1sqBOtz0AJd2w8Cf5hzv0Y7pAyVrazrdZVqbowsiC9hIBDhNeMGCco gWoBwPG9HRJVKeCSJu/0lda9ENhJPMc5rE6x+IuXzRGXHylw5/rk6vP5CEZamMjz3Ni4 nQyK925TN2GBxMVsUXoEdFxIkaxEd+IJ20OEBJR6tGXi5WwmfXM+GV91VKqJYLDxm6TV K8qw== 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=1vUcOLOLJFvqTx0Q1+alN5ka8ZC+o11y2paCA+C3hD8=; b=ICQCp23rNp7eV/dNU/vD17n/MgsEWIqHko92pb70pnNQV6GGowFo8v4CceumWutGVc t2BX3di04SZEywMmsGsQhfBQT2Pd/5Bqipo2a60gqL+DvOgDoZgtjRoCQddGl/a2/wpE YQYuzARwf0pRHeApqWHcHmB4OjcSSd6kB2nSO6MgcGzlhwoYBH4B/17WIiGd+5sv3nZx TN7DF7ZzJ9KUDqfgi0ePRainCV9LPI3MUSoCssIoBdW6VCqL73+woHnT/daGC/VreeV2 yosEq/J7EjVM6r3HpiepZi6KbL+2qzUNr/fcpY0dtQPyry9gpXtZwZ/1alZ47v43Gmta tEpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S2UNFqxE; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y10si13051803jaf.62.2021.05.31.00.09.33; Mon, 31 May 2021 00:09:46 -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 header.i=@linaro.org header.s=google header.b=S2UNFqxE; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230111AbhEaHK2 (ORCPT + 99 others); Mon, 31 May 2021 03:10:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230070AbhEaHKZ (ORCPT ); Mon, 31 May 2021 03:10:25 -0400 Received: from mail-ua1-x92e.google.com (mail-ua1-x92e.google.com [IPv6:2607:f8b0:4864:20::92e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20DB9C06174A for ; Mon, 31 May 2021 00:08:46 -0700 (PDT) Received: by mail-ua1-x92e.google.com with SMTP id l12so409416uai.0 for ; Mon, 31 May 2021 00:08:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1vUcOLOLJFvqTx0Q1+alN5ka8ZC+o11y2paCA+C3hD8=; b=S2UNFqxEhgyn5voEcAQ5yYLEXfKVM2XwBNQgOUuhiwcTjPFzIfdtCZ4Yvj7mDRJSeG GDGUB0fLTUyYVPw25QdBjMlLftuN8zV0eLOH+bRziHVmayRjeAwUy9YTYl+QBGJ0taUg VMerwRBPrcWxjU2kKN2y2litigUU+LidXGKJfcGdTHpU7bal0AR64t8iq17b8g1KHJkE GAMQU1+BnASUYJbx317ew5z8+0Hd/DU2+g+0UczzK4+AssS9z1mOzBw0zwT0ADvKazdg W6uFCvdLj5ZywyQ+nPT2cDTjKM7XLcZjF2B0uDxzeNQHqbT3KGFoCJcCT1d9IfyUZQrR y5ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1vUcOLOLJFvqTx0Q1+alN5ka8ZC+o11y2paCA+C3hD8=; b=ehwsOTPDXQibVgAJp0L4dmpOkYtS+LSYDOOsaKqj1H/puxgpGbOWSi1E7ExuklGc/g TnkmA5pYZJt0OGAgZfX2WJJVB1BmkwlueZYpfwk7FjlAKeTntxU73Hp5y8hGkd+SqvOB qpguC5/G5XwtPyxzhBHjnRAKfbbcVV+Gz4AvDRwlP2frEsag1DFSYGXssrEXd6aewlnq ZSsnz1hgXvdMzdM7fEaPrmewsEQnMMdQ6AlOIgGo+NAA57Xqscbcvinv/tiZ0gHNEyMI qJARe0TVhPOViMEbdf3l3Hlb64bg2FTjVA0OkVBlL62ASJ06d/4T/gq4xcRD9v3ZrsqT V4Pw== X-Gm-Message-State: AOAM532Osp7V7IEgw4QPKNFA3b9Z38C3O6NbfzVakmhCe7lbKN3MQ/8l zTIoDPQCUrgfRgvnsNTi0N/GhQYQNMoK93sBlyhafQ== X-Received: by 2002:ab0:100f:: with SMTP id f15mr9827076uab.100.1622444924930; Mon, 31 May 2021 00:08:44 -0700 (PDT) MIME-Version: 1.0 References: <20210528091202.11603-1-ulf.hansson@linaro.org> <20210528152719.GA1473569@rowland.harvard.edu> In-Reply-To: <20210528152719.GA1473569@rowland.harvard.edu> From: Ulf Hansson Date: Mon, 31 May 2021 09:08:08 +0200 Message-ID: Subject: Re: [PATCH 2/2] PM: runtime: Allow unassigned ->runtime_suspend|resume callbacks To: Alan Stern Cc: "Rafael J . Wysocki" , Linux PM , Saravana Kannan , Adrian Hunter , Tony Lindgren , Kevin Hilman , Geert Uytterhoeven , Linux ARM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 28 May 2021 at 17:27, Alan Stern wrote: > > On Fri, May 28, 2021 at 11:12:02AM +0200, Ulf Hansson wrote: > > We are currently allowing ->rpm_idle() callbacks to be unassigned without > > returning an error code from rpm_idle(). This has been useful to avoid > > boilerplate code in drivers. Let's take this approach a step further, by > > allowing unassigned ->runtime_suspend|resume() callbacks as well. > > > > In this way, a consumer/supplier device link can be used to let a consumer > > device be power managed through its supplier device, without requiring > > assigned ->runtime_suspend|resume() callbacks for the consumer device, for > > example. > > > > Signed-off-by: Ulf Hansson > > --- > > drivers/base/power/runtime.c | 8 +++----- > > 1 file changed, 3 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c > > index 68bebbf81347..8a66eaf731e4 100644 > > --- a/drivers/base/power/runtime.c > > +++ b/drivers/base/power/runtime.c > > @@ -345,7 +345,7 @@ static void rpm_suspend_suppliers(struct device *dev) > > static int __rpm_callback(int (*cb)(struct device *), struct device *dev) > > __releases(&dev->power.lock) __acquires(&dev->power.lock) > > { > > - int retval, idx; > > + int retval = 0, idx; > > bool use_links = dev->power.links_count > 0; > > > > if (dev->power.irq_safe) { > > @@ -373,7 +373,8 @@ static int __rpm_callback(int (*cb)(struct device *), struct device *dev) > > } > > } > > > > - retval = cb(dev); > > + if (cb) > > + retval = cb(dev); > > > > if (dev->power.irq_safe) { > > spin_lock(&dev->power.lock); > > @@ -484,9 +485,6 @@ static int rpm_callback(int (*cb)(struct device *), struct device *dev) > > { > > int retval; > > > > - if (!cb) > > - return -ENOSYS; > > This is a change in behavior, right? What about drivers or subsystems > that don't support runtime PM and consequently don't have any RPM > callbacks assigned? Yes, you are right. However, drivers/subsystems that support runtime PM should also call pm_runtime_enable() and if they don't, the rpm_callback() should not get called for them. Then, at least to me, I think it would be quite odd that a subsystem/driver that calls pm_runtime_enable(), would be checking return values from pm_runtime_get|put_*() for -ENOSYS? I mean, why bother calling pm_runtime_enable() in the first place? > > Also, assuming Rafael accepts this change, don't you also need to update > the runtime-PM documentation? Good point, thanks! Let me add a patch updating the docs. > > Alan Stern > Kind regards Uffe