public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Wang <peter.wang@mediatek.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: <matthias.bgg@gmail.com>, <len.brown@intel.com>, <pavel@ucw.cz>,
	<rafael@kernel.org>, <stanley.chu@mediatek.com>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <linux-pm@vger.kernel.org>,
	<martin.petersen@oracle.com>, <avri.altman@wdc.com>,
	<alim.akhtar@samsung.com>, <jejb@linux.ibm.com>,
	<wsd_upstream@mediatek.com>, <linux-mediatek@lists.infradead.org>,
	<chun-hung.wu@mediatek.com>, <alice.chao@mediatek.com>,
	<cc.chou@mediatek.com>, <chaotian.jing@mediatek.com>,
	<jiajie.hao@mediatek.com>, <powen.kao@mediatek.com>,
	<qilin.tan@mediatek.com>, <lin.gui@mediatek.com>,
	<tun-yu.yu@mediatek.com>
Subject: Re: [PATCH v1] PM-runtime: Check supplier_preactivated before release supplier
Date: Tue, 28 Jun 2022 09:49:46 +0800	[thread overview]
Message-ID: <9946359f-8ceb-2bad-9a4e-1e8a1dfd24c6@mediatek.com> (raw)
In-Reply-To: <Yrm7QSRXKZg4/q7s@kroah.com>


On 6/27/22 10:14 PM, Greg KH wrote:
> On Mon, Jun 13, 2022 at 08:07:55PM +0800, peter.wang@mediatek.com wrote:
>> From: Peter Wang <peter.wang@mediatek.com>
>>
>> With divice link of DL_FLAG_PM_RUNTIME, if consumer call pm_runtime_get_suppliers
>> to prevent supplier enter suspend, pm_runtime_release_supplier should
>> check supplier_preactivated before let supplier enter suspend.
>>
>> If the link is drop or release, bypass check supplier_preactivated.
>>
>> Signed-off-by: Peter Wang <peter.wang@mediatek.com>
>> ---
>>   drivers/base/core.c          |  2 +-
>>   drivers/base/power/runtime.c | 15 ++++++++++++---
>>   include/linux/pm_runtime.h   |  5 +++--
>>   3 files changed, 16 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/base/core.c b/drivers/base/core.c
>> index 7cd789c4985d..3b9cc559928f 100644
>> --- a/drivers/base/core.c
>> +++ b/drivers/base/core.c
>> @@ -486,7 +486,7 @@ static void device_link_release_fn(struct work_struct *work)
>>   	/* Ensure that all references to the link object have been dropped. */
>>   	device_link_synchronize_removal();
>>   
>> -	pm_runtime_release_supplier(link, true);
>> +	pm_runtime_release_supplier(link, true, true);
>>   
>>   	put_device(link->consumer);
>>   	put_device(link->supplier);
>> diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
>> index 676dc72d912d..3c4f425937a1 100644
>> --- a/drivers/base/power/runtime.c
>> +++ b/drivers/base/power/runtime.c
>> @@ -314,10 +314,19 @@ static int rpm_get_suppliers(struct device *dev)
>>    * and if @check_idle is set, check if that device is idle (and so it can be
>>    * suspended).
>>    */
>> -void pm_runtime_release_supplier(struct device_link *link, bool check_idle)
>> +void pm_runtime_release_supplier(struct device_link *link, bool check_idle,
>> +	bool drop)
> This is just making this horrible api even worse.  Now there are 2
> boolean flags required, 2 more than really should even be here at all.
> Every time you see this function being used, you will now have to look
> up the definition  to see what it really does.
>
> Please make a new function that calls the internal function with the
> flag set properly, so that it is obvious what is happening when the call
> is made.
>
> and really, the same thing should be done for the check_idle flag,
> that's not good either.
>
> thanks,

Hi Gerg,

Good point! you are right, I wont change api next version

Thank you for review


> greg k-h

  parent reply	other threads:[~2022-06-28  1:49 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-13 12:07 [PATCH v1] PM-runtime: Check supplier_preactivated before release supplier peter.wang
2022-06-22  6:09 ` Peter Wang
2022-06-22  6:48   ` Greg KH
2022-06-27 14:14 ` Greg KH
2022-06-27 14:27   ` Rafael J. Wysocki
2022-06-28  1:49   ` Peter Wang [this message]
2022-06-27 19:00 ` Rafael J. Wysocki
2022-06-28  1:53   ` Peter Wang
2022-06-28 15:54     ` Rafael J. Wysocki
     [not found] ` <b55d5691-0b2d-56bb-26ff-dcac56770611@mediatek.com>
     [not found]   ` <CAJZ5v0gTpv2gt_Gm9rUd+8Jmp4=ij2=J20o7qO0sC-hm=w3=_A@mail.gmail.com>
2022-06-29 16:01     ` Rafael J. Wysocki
2022-06-30 14:26       ` Peter Wang
2022-06-30 14:47         ` Rafael J. Wysocki
2022-06-30 15:19           ` Peter Wang
2022-06-30 16:28             ` Rafael J. Wysocki
2022-07-01 10:21               ` Peter Wang
2022-08-02  3:19                 ` Peter Wang
2022-08-02 11:01                   ` Rafael J. Wysocki
2022-08-02 13:33                     ` Peter Wang
2022-10-12 10:31                       ` Nitin Rawat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9946359f-8ceb-2bad-9a4e-1e8a1dfd24c6@mediatek.com \
    --to=peter.wang@mediatek.com \
    --cc=alice.chao@mediatek.com \
    --cc=alim.akhtar@samsung.com \
    --cc=avri.altman@wdc.com \
    --cc=cc.chou@mediatek.com \
    --cc=chaotian.jing@mediatek.com \
    --cc=chun-hung.wu@mediatek.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jejb@linux.ibm.com \
    --cc=jiajie.hao@mediatek.com \
    --cc=len.brown@intel.com \
    --cc=lin.gui@mediatek.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=matthias.bgg@gmail.com \
    --cc=pavel@ucw.cz \
    --cc=powen.kao@mediatek.com \
    --cc=qilin.tan@mediatek.com \
    --cc=rafael@kernel.org \
    --cc=stanley.chu@mediatek.com \
    --cc=tun-yu.yu@mediatek.com \
    --cc=wsd_upstream@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox