linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Huang Ying <ying.huang@intel.com>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	Huang Ying <ying.huang@intel.com>
Subject: [BUGFIX] PM: Fix active child counting when disabled and forbidden
Date: Mon,  5 Nov 2012 09:17:17 +0800	[thread overview]
Message-ID: <1352078237-20622-1-git-send-email-ying.huang@intel.com> (raw)

In current runtime PM implementation, the active child count of the
parent device may be decreased if the runtime PM of the child device
is disabled and forbidden.  For example, to unbind a PCI driver with a
PCI device, the following code path is possible:

  pci_device_remove
    pm_runtime_set_suspended
      __pm_runtime_set_status
        atomic_add_unless(&parent->power.child_count, -1, 0)

That is, the parent device may be suspended, even if the runtime PM of
child device is forbidden to be suspended.  This violate the rule that
parent is allowed to be suspended only after all its children are
suspended, and may cause issue.

This issue is fixed via checking the usage count of the child device
because if the runtime PM of the child device is forbidden, the
usage_count of the child device will be non-zero.

Signed-off-by: Huang Ying <ying.huang@intel.com>
---
 drivers/base/power/runtime.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -916,7 +916,7 @@ int __pm_runtime_set_status(struct devic
 
 	if (status == RPM_SUSPENDED) {
 		/* It always is possible to set the status to 'suspended'. */
-		if (parent) {
+		if (parent && atomic_read(&dev->power.usage_count) == 0) {
 			atomic_add_unless(&parent->power.child_count, -1, 0);
 			notify_parent = !parent->power.ignore_children;
 		}

             reply	other threads:[~2012-11-05  1:17 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-05  1:17 Huang Ying [this message]
2012-11-05  1:56 ` [BUGFIX] PM: Fix active child counting when disabled and forbidden Alan Stern
2012-11-06  0:43   ` Huang Ying
2012-11-06 15:17     ` Alan Stern
2012-11-07  0:26       ` Huang Ying
2012-11-07 15:49         ` Alan Stern
2012-11-07 16:09           ` Rafael J. Wysocki
2012-11-07 17:17             ` Alan Stern
2012-11-07 20:21               ` Rafael J. Wysocki
2012-11-07 20:47                 ` Alan Stern
2012-11-07 21:44                   ` Rafael J. Wysocki
2012-11-07 21:56                     ` Alan Stern
2012-11-07 22:51                       ` Rafael J. Wysocki
2012-11-07 23:09                         ` Rafael J. Wysocki
2012-11-08  1:15                           ` Huang Ying
2012-11-08  1:35                             ` Rafael J. Wysocki
2012-11-08  2:04                               ` Huang Ying
2012-11-08  9:56                                 ` Rafael J. Wysocki
2012-11-08 17:07                                   ` Alan Stern
2012-11-09  2:36                                     ` Huang Ying
2012-11-09 16:41                                       ` Alan Stern
2012-11-12  0:37                                         ` Huang Ying
2012-11-12  2:36                                           ` Alan Stern
2012-11-12  5:55                                             ` Huang Ying
2012-11-12 16:32                                               ` Alan Stern
2012-11-13  1:19                                                 ` Huang Ying
2012-11-13  2:32                                                   ` Alan Stern
2012-11-13  5:12                                                     ` Huang Ying
2012-11-13 16:10                                                       ` Alan Stern
2012-11-14  1:08                                                         ` Huang Ying
2012-11-14  9:52                                                           ` Rafael J. Wysocki
2012-11-14 13:35                                                             ` Huang Ying
2012-11-14 16:06                                                               ` Alan Stern
2012-11-13 23:43                                                 ` Rafael J. Wysocki
2012-11-14 10:05                                     ` Rafael J. Wysocki
2012-11-14 16:42                                       ` Alan Stern
2012-11-14 19:42                                         ` Rafael J. Wysocki
2012-11-14 21:45                                           ` Alan Stern
2012-11-14 23:10                                             ` Rafael J. Wysocki
2012-11-15  1:03                                               ` Huang Ying
2012-11-15  9:51                                                 ` Rafael J. Wysocki
2012-11-15 10:09                                                   ` Rafael J. Wysocki
2012-11-15 15:27                                                     ` Alan Stern
2012-11-16  0:36                                                   ` Huang Ying
2012-11-16  0:44                                                     ` Rafael J. Wysocki
2012-11-16  0:48                                                       ` Huang Ying
2012-11-16  0:55                                                       ` Rafael J. Wysocki
2012-11-16  0:54                                                         ` Huang Ying
2012-11-16  1:29                                                           ` Rafael J. Wysocki
2012-11-16  1:27                                                             ` Huang Ying
2012-11-16 10:10                                                               ` Rafael J. Wysocki
2012-11-16  3:11                                                   ` Huang Ying

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=1352078237-20622-1-git-send-email-ying.huang@intel.com \
    --to=ying.huang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@sisk.pl \
    /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).