linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lan Tianyu <lantianyu1986@gmail.com>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Lan Tianyu <tianyu.lan@intel.com>,
	gregkh@linuxfoundation.org, sarah.a.sharp@linux.intel.com,
	stern@rowland.harvard.edu, oneukum@suse.de,
	linux-usb@vger.kernel.org,
	Linux PM list <linux-pm@vger.kernel.org>
Subject: Re: [RFC PATCH v2 3/6] usb: add runtime pm support for usb port device
Date: Wed, 14 Nov 2012 22:14:57 +0800	[thread overview]
Message-ID: <50A3A761.8000302@gmail.com> (raw)
In-Reply-To: <50A39285.80305@gmail.com>

于 2012/11/14 20:45, Lan Tianyu 写道:
> 于 2012/11/14 17:49, Rafael J. Wysocki 写道:
>> On Wednesday, November 14, 2012 02:34:37 PM Lan Tianyu wrote:
>>> On 2012年11月14日 08:08, Rafael J. Wysocki wrote:
>>>> On Tuesday, November 13, 2012 04:00:02 PM Lan Tianyu wrote:
>>>>> This patch is to add runtime pm callback for usb port device.
>>>>> Set/clear PORT_POWER feature in the resume/suspend callbak.
>>>>> Add portnum for struct usb_port to record port number.
>>>>>
>>>>> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
>>>>
>>>> This one looks reasonable to me.  From the PM side
>>>>
>>>> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>>> Hi Rafael and Alan:
>>>     This patch has a collaboration problem with pm qos. Since pm core would
>>> pm_runtime_get_sync/put(port_dev) if pm qos flags was changed and port's
>>> suspend call_back() clear PORT_POWER feature without any check. This
>>> will cause PORT_POWER feather being cleared every time after pm qos
>>> flags being changed.
>>>
>>>     I have an idea that add check in the port's runtime idle callback.
>>> Check NO_POWER_OFF flag firstly. If set return. Second, for port without
>>> device, suspend port directly and for port with device, increase child
>>> device's runtime usage without resume and do barrier to ensure all
>>> suspend process finish, at last check the child runtime status. If it
>>> was suspended, suspend port and if do nothing.
>>>
>>> static int usb_port_runtime_idle(struct device *dev)
>>> {
>>>     struct usb_port *port_dev = to_usb_port(dev);
>>>     int retval = 0;
>>>
>>>     if (dev_pm_qos_flags(&port_dev->dev, PM_QOS_FLAG_NO_POWER_OFF)
>>>             == PM_QOS_FLAGS_ALL)
>>>         return 0;
>>>
>>>     if (!port_dev->child) {
>>>         retval = pm_runtime_suspend(&port_dev->dev);
>>>         if (!retval)
>>>             port_dev->power_on =false;
>>>     }
>>>     else {
>>
>> This usually is written as "} else {" in the kernel code.
>>
>>>         pm_runtime_get_noresume(&port_dev->child->dev);
>>>         pm_runtime_barrier(&port_dev->child->dev);
>>>         if (port_dev->child->dev.power.runtime_status
>>>                 == RPM_SUSPENDED) {
>>>             retval = pm_runtime_suspend(&port_dev->dev);
>>>             if (!retval)
>>>                 port_dev->power_on =false;
>>>         }
>>>         pm_runtime_put_noidle(&port_dev->child->dev);
>>>     }
>>
>> Hmm.  If child->dev is not suspended, then our usage_count should be
>> at least 1, so pm_runtime_suspend(&port_dev->dev) shouldn't actually
>> suspend us.  Isn't that the case?
> No, because the child device is not under port device and so even if
> child->dev is not suspended, port device's usage still can be 0 and
> power off the port.

Maybe I should add pm_runtime_get_noresume(&port_dev->dev) before enable
port's runtime pm. Just like following. Then it will work like you said.

@@ -72,6 +109,8 @@ int usb_hub_create_port_device(struct device *intfdev,
  	if (retval)
  		goto error_register;

+	pm_runtime_set_active(&port_dev->dev);
+	pm_runtime_get_noresume(&port_dev->dev); /* new add */
+	pm_runtime_enable(&port_dev->dev);
>>
>> Rafael
>>
>>
>

-- 
Best regards
Tianyu Lan

  reply	other threads:[~2012-11-14 14:15 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1352793605-4168-1-git-send-email-tianyu.lan@intel.com>
     [not found] ` <50A229E9.4060404@mvista.com>
     [not found]   ` <50A23EBF.1070304@gmail.com>
2012-11-13 23:56     ` [RFC PATCH v2 1/6] usb: Register usb port's acpi power resources Rafael J. Wysocki
2012-11-14  2:46       ` Lan Tianyu
     [not found] ` <1352793605-4168-3-git-send-email-tianyu.lan@intel.com>
2012-11-14  0:04   ` [RFC PATCH v2 2/6] usb: Add driver/usb/core/port.c file to fill usb port related code Rafael J. Wysocki
     [not found]     ` <2444119.E7TGPxnJj8-sKB8Sp2ER+y1GS7QM15AGw@public.gmane.org>
2012-11-14  3:17       ` Lan Tianyu
     [not found] ` <1352793605-4168-4-git-send-email-tianyu.lan@intel.com>
2012-11-14  0:08   ` [RFC PATCH v2 3/6] usb: add runtime pm support for usb port device Rafael J. Wysocki
2012-11-14  6:34     ` Lan Tianyu
2012-11-14  9:49       ` Rafael J. Wysocki
     [not found]         ` <2700525.6XmcYg8quR-sKB8Sp2ER+y1GS7QM15AGw@public.gmane.org>
2012-11-14 12:45           ` Lan Tianyu
2012-11-14 14:14             ` Lan Tianyu [this message]
     [not found]             ` <50A39285.80305-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-11-14 15:13               ` Lan Tianyu
2012-11-14 17:07                 ` Alan Stern
     [not found] ` <1352793605-4168-5-git-send-email-tianyu.lan@intel.com>
2012-11-14  0:16   ` [RFC PATCH v2 4/6] usb: add usb port auto power off mechanism Rafael J. Wysocki
     [not found] ` <1352793605-4168-6-git-send-email-tianyu.lan@intel.com>
2012-11-14  0:21   ` [RFC PATCH v2 5/6] usb: expose usb port's pm qos flags to user space Rafael J. Wysocki
     [not found] ` <1352793605-4168-7-git-send-email-tianyu.lan@intel.com>
2012-11-14  0:23   ` [RFC PATCH v2 6/6] usb: add usb port's pm qos flags request to change NO_POWER_OFF flag Rafael J. Wysocki

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=50A3A761.8000302@gmail.com \
    --to=lantianyu1986@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=oneukum@suse.de \
    --cc=rjw@sisk.pl \
    --cc=sarah.a.sharp@linux.intel.com \
    --cc=stern@rowland.harvard.edu \
    --cc=tianyu.lan@intel.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;
as well as URLs for NNTP newsgroup(s).