Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-16 Thread Rafael J. Wysocki
On Friday, November 16, 2012 09:27:05 AM Huang Ying wrote: > On Fri, 2012-11-16 at 02:29 +0100, Rafael J. Wysocki wrote: > > On Friday, November 16, 2012 08:54:56 AM Huang Ying wrote: > > > On Fri, 2012-11-16 at 01:55 +0100, Rafael J. Wysocki wrote: > > > > On Friday, November 16, 2012 01:44:00 AM

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-15 Thread Huang Ying
On Thu, 2012-11-15 at 10:51 +0100, Rafael J. Wysocki wrote: > On Thursday, November 15, 2012 09:03:44 AM Huang Ying wrote: > > On Thu, 2012-11-15 at 00:10 +0100, Rafael J. Wysocki wrote: > > > On Wednesday, November 14, 2012 04:45:01 PM Alan Stern wrote: > > > > On Wed, 14 Nov 2012, Rafael J. Wysoc

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-15 Thread Huang Ying
On Fri, 2012-11-16 at 02:29 +0100, Rafael J. Wysocki wrote: > On Friday, November 16, 2012 08:54:56 AM Huang Ying wrote: > > On Fri, 2012-11-16 at 01:55 +0100, Rafael J. Wysocki wrote: > > > On Friday, November 16, 2012 01:44:00 AM Rafael J. Wysocki wrote: > > > > On Friday, November 16, 2012 08:36

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-15 Thread Rafael J. Wysocki
On Friday, November 16, 2012 08:54:56 AM Huang Ying wrote: > On Fri, 2012-11-16 at 01:55 +0100, Rafael J. Wysocki wrote: > > On Friday, November 16, 2012 01:44:00 AM Rafael J. Wysocki wrote: > > > On Friday, November 16, 2012 08:36:14 AM Huang Ying wrote: > > > > On Thu, 2012-11-15 at 10:51 +0100,

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-15 Thread Huang Ying
On Fri, 2012-11-16 at 01:55 +0100, Rafael J. Wysocki wrote: > On Friday, November 16, 2012 01:44:00 AM Rafael J. Wysocki wrote: > > On Friday, November 16, 2012 08:36:14 AM Huang Ying wrote: > > > On Thu, 2012-11-15 at 10:51 +0100, Rafael J. Wysocki wrote: > > [...] > > > > > > > For this situat

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-15 Thread Rafael J. Wysocki
On Friday, November 16, 2012 01:44:00 AM Rafael J. Wysocki wrote: > On Friday, November 16, 2012 08:36:14 AM Huang Ying wrote: > > On Thu, 2012-11-15 at 10:51 +0100, Rafael J. Wysocki wrote: [...] > > > > For this situation, if user "echo auto > .../power/control" for the > > device, the runtime

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-15 Thread Huang Ying
On Fri, 2012-11-16 at 01:44 +0100, Rafael J. Wysocki wrote: > On Friday, November 16, 2012 08:36:14 AM Huang Ying wrote: > > On Thu, 2012-11-15 at 10:51 +0100, Rafael J. Wysocki wrote: > > > On Thursday, November 15, 2012 09:03:44 AM Huang Ying wrote: > > > > On Thu, 2012-11-15 at 00:10 +0100, Rafa

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-15 Thread Rafael J. Wysocki
On Friday, November 16, 2012 08:36:14 AM Huang Ying wrote: > On Thu, 2012-11-15 at 10:51 +0100, Rafael J. Wysocki wrote: > > On Thursday, November 15, 2012 09:03:44 AM Huang Ying wrote: > > > On Thu, 2012-11-15 at 00:10 +0100, Rafael J. Wysocki wrote: > > > > On Wednesday, November 14, 2012 04:45:0

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-15 Thread Huang Ying
On Thu, 2012-11-15 at 10:51 +0100, Rafael J. Wysocki wrote: > On Thursday, November 15, 2012 09:03:44 AM Huang Ying wrote: > > On Thu, 2012-11-15 at 00:10 +0100, Rafael J. Wysocki wrote: > > > On Wednesday, November 14, 2012 04:45:01 PM Alan Stern wrote: > > > > On Wed, 14 Nov 2012, Rafael J. Wysoc

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-15 Thread Alan Stern
On Thu, 15 Nov 2012, Rafael J. Wysocki wrote: > > So it looks like what we want to do is: > > > > (1) Enable runtime PM in pci_pm_init() and set the status to RPM_ACTIVE > > right > > before, so that it is in agreement with the pm_runtime_forbid() we do in > > there. > > > > (2) If user

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-15 Thread Rafael J. Wysocki
On Thursday, November 15, 2012 10:51:42 AM Rafael J. Wysocki wrote: > On Thursday, November 15, 2012 09:03:44 AM Huang Ying wrote: > > On Thu, 2012-11-15 at 00:10 +0100, Rafael J. Wysocki wrote: > > > On Wednesday, November 14, 2012 04:45:01 PM Alan Stern wrote: > > > > On Wed, 14 Nov 2012, Rafael

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-15 Thread Rafael J. Wysocki
On Thursday, November 15, 2012 09:03:44 AM Huang Ying wrote: > On Thu, 2012-11-15 at 00:10 +0100, Rafael J. Wysocki wrote: > > On Wednesday, November 14, 2012 04:45:01 PM Alan Stern wrote: > > > On Wed, 14 Nov 2012, Rafael J. Wysocki wrote: > > > > > > > > This has the side effect that when a driv

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-14 Thread Huang Ying
On Thu, 2012-11-15 at 00:10 +0100, Rafael J. Wysocki wrote: > On Wednesday, November 14, 2012 04:45:01 PM Alan Stern wrote: > > On Wed, 14 Nov 2012, Rafael J. Wysocki wrote: > > > > > > This has the side effect that when a driver unbinds, it can't leave the > > > > device in a special low-power s

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-14 Thread Rafael J. Wysocki
On Wednesday, November 14, 2012 04:45:01 PM Alan Stern wrote: > On Wed, 14 Nov 2012, Rafael J. Wysocki wrote: > > > > This has the side effect that when a driver unbinds, it can't leave the > > > device in a special low-power state. The device will always end up in > > > the generic low-power s

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-14 Thread Alan Stern
On Wed, 14 Nov 2012, Rafael J. Wysocki wrote: > > This has the side effect that when a driver unbinds, it can't leave the > > device in a special low-power state. The device will always end up in > > the generic low-power state supported by the PCI core. > > Well, I'm not sure I'd like that. >

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-14 Thread Rafael J. Wysocki
On Wednesday, November 14, 2012 11:42:33 AM Alan Stern wrote: > On Wed, 14 Nov 2012, Rafael J. Wysocki wrote: > > > On Thursday, November 08, 2012 12:07:54 PM Alan Stern wrote: > > > On Thu, 8 Nov 2012, Rafael J. Wysocki wrote: > > > > [...] > > > > I'd like to revisit this for a while if you do

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-14 Thread Alan Stern
On Wed, 14 Nov 2012, Rafael J. Wysocki wrote: > On Thursday, November 08, 2012 12:07:54 PM Alan Stern wrote: > > On Thu, 8 Nov 2012, Rafael J. Wysocki wrote: > > [...] > > I'd like to revisit this for a while if you don't mind. Not at all. > > Your revised patch does do the job, except for a f

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-14 Thread Alan Stern
On Wed, 14 Nov 2012, Huang Ying wrote: > > What changes specifically do you mean to be precise? > > I mean the following changes from Alan's email. > > pm_runtime_set_suspended should fail if dev->power.runtime_auto > is clear. > > pm_runtime_forbid should call pm_runtim

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-14 Thread Huang Ying
On Wed, 2012-11-14 at 10:52 +0100, Rafael J. Wysocki wrote: > On Wednesday, November 14, 2012 09:08:28 AM Huang Ying wrote: > > On Tue, 2012-11-13 at 11:10 -0500, Alan Stern wrote: > > > On Tue, 13 Nov 2012, Huang Ying wrote: > > > > > > > > This is not quite right. Consider a device that is in r

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-14 Thread Rafael J. Wysocki
On Thursday, November 08, 2012 12:07:54 PM Alan Stern wrote: > On Thu, 8 Nov 2012, Rafael J. Wysocki wrote: [...] I'd like to revisit this for a while if you don't mind. > Your revised patch does do the job, except for a few problems. > Namely, while local_pci_probe() and pci_device_remove() a

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-14 Thread Rafael J. Wysocki
On Wednesday, November 14, 2012 09:08:28 AM Huang Ying wrote: > On Tue, 2012-11-13 at 11:10 -0500, Alan Stern wrote: > > On Tue, 13 Nov 2012, Huang Ying wrote: > > > > > > This is not quite right. Consider a device that is in runtime suspend > > > > when a system sleep starts. When the system s

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-13 Thread Huang Ying
On Tue, 2012-11-13 at 11:10 -0500, Alan Stern wrote: > On Tue, 13 Nov 2012, Huang Ying wrote: > > > > This is not quite right. Consider a device that is in runtime suspend > > > when a system sleep starts. When the system sleep ends, the device > > > will be resumed but the PM core will still

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-13 Thread Rafael J. Wysocki
On Monday, November 12, 2012 11:32:26 AM Alan Stern wrote: > On Mon, 12 Nov 2012, Huang Ying wrote: > > > > > Is it absolute necessary to call pm_runtime_set_suspended? If the > > > > device is disabled, the transition to SUSPENDED state will not be > > > > triggered even if the device is ACTIVE.

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-13 Thread Alan Stern
On Tue, 13 Nov 2012, Huang Ying wrote: > > This is not quite right. Consider a device that is in runtime suspend > > when a system sleep starts. When the system sleep ends, the device > > will be resumed but the PM core will still think its state is > > SUSPENDED. The subsystem has to tell t

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-12 Thread Huang Ying
On Mon, 2012-11-12 at 21:32 -0500, Alan Stern wrote: > On Tue, 13 Nov 2012, Huang Ying wrote: > > > Sorry, my original idea is: > > > > pm_runtime_disable will put device into SUSPENDED state if > > dev->power.runtime_auto is clear. pm_runtime_allow will put > > device into SUSPENDED

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-12 Thread Alan Stern
On Tue, 13 Nov 2012, Huang Ying wrote: > Sorry, my original idea is: > > pm_runtime_disable will put device into SUSPENDED state if > dev->power.runtime_auto is clear. pm_runtime_allow will put > device into SUSPENDED state if dev->power.disable_depth > 0. That's close to what

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-12 Thread Huang Ying
On Mon, 2012-11-12 at 11:32 -0500, Alan Stern wrote: > On Mon, 12 Nov 2012, Huang Ying wrote: > > > > > Is it absolute necessary to call pm_runtime_set_suspended? If the > > > > device is disabled, the transition to SUSPENDED state will not be > > > > triggered even if the device is ACTIVE. > > >

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-12 Thread Alan Stern
On Mon, 12 Nov 2012, Huang Ying wrote: > > > Is it absolute necessary to call pm_runtime_set_suspended? If the > > > device is disabled, the transition to SUSPENDED state will not be > > > triggered even if the device is ACTIVE. > > > > It's not absolutely necessary to do this, but we ought to b

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-11 Thread Huang Ying
On Sun, 2012-11-11 at 21:36 -0500, Alan Stern wrote: > On Mon, 12 Nov 2012, Huang Ying wrote: > > > > The first question: How should the PCI subsystem prevent the parents of > > > driverless VGA devices from being runtime suspended while userspace is > > > accessing them? > > > > I think Rafael

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-11 Thread Alan Stern
On Mon, 12 Nov 2012, Huang Ying wrote: > > The first question: How should the PCI subsystem prevent the parents of > > driverless VGA devices from being runtime suspended while userspace is > > accessing them? > > I think Rafael's patch is good for that. But his patch isn't needed if we make t

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-11 Thread Huang Ying
On Fri, 2012-11-09 at 11:41 -0500, Alan Stern wrote: > On Fri, 9 Nov 2012, Huang Ying wrote: > > > On Thu, 2012-11-08 at 12:07 -0500, Alan Stern wrote: > > > On Thu, 8 Nov 2012, Rafael J. Wysocki wrote: > > > > > > > > > > is it a good idea to allow to set device state to SUSPENDED if > > > > >

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-09 Thread Alan Stern
On Fri, 9 Nov 2012, Huang Ying wrote: > On Thu, 2012-11-08 at 12:07 -0500, Alan Stern wrote: > > On Thu, 8 Nov 2012, Rafael J. Wysocki wrote: > > > > > > > > is it a good idea to allow to set device state to SUSPENDED if the > > > > > > device > > > > > > is disabled? > > > > > > > > > > No, it

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-08 Thread Huang Ying
On Thu, 2012-11-08 at 12:07 -0500, Alan Stern wrote: > On Thu, 8 Nov 2012, Rafael J. Wysocki wrote: > > > > > > is it a good idea to allow to set device state to SUSPENDED if the > > > > > device > > > > > is disabled? > > > > > > > > No, it is not. The status should always be ACTIVE as long as

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-08 Thread Alan Stern
On Thu, 8 Nov 2012, Rafael J. Wysocki wrote: > > > > is it a good idea to allow to set device state to SUSPENDED if the > > > > device > > > > is disabled? > > > > > > No, it is not. The status should always be ACTIVE as long as usage_count > > > > 0. That isn't strictly true, because pm_runt

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-08 Thread Rafael J. Wysocki
On Thursday, November 08, 2012 10:04:36 AM Huang Ying wrote: > On Thu, 2012-11-08 at 02:35 +0100, Rafael J. Wysocki wrote: > > On Thursday, November 08, 2012 09:15:08 AM Huang Ying wrote: > > > On Thu, 2012-11-08 at 00:09 +0100, Rafael J. Wysocki wrote: [...] > > > I think the patch can fix the i

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-07 Thread Huang Ying
On Thu, 2012-11-08 at 02:35 +0100, Rafael J. Wysocki wrote: > On Thursday, November 08, 2012 09:15:08 AM Huang Ying wrote: > > On Thu, 2012-11-08 at 00:09 +0100, Rafael J. Wysocki wrote: > > > On Wednesday, November 07, 2012 11:51:15 PM Rafael J. Wysocki wrote: > > > > On Wednesday, November 07, 20

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-07 Thread Rafael J. Wysocki
On Thursday, November 08, 2012 09:15:08 AM Huang Ying wrote: > On Thu, 2012-11-08 at 00:09 +0100, Rafael J. Wysocki wrote: > > On Wednesday, November 07, 2012 11:51:15 PM Rafael J. Wysocki wrote: > > > On Wednesday, November 07, 2012 04:56:49 PM Alan Stern wrote: > > > > On Wed, 7 Nov 2012, Rafael

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-07 Thread Huang Ying
On Thu, 2012-11-08 at 00:09 +0100, Rafael J. Wysocki wrote: > On Wednesday, November 07, 2012 11:51:15 PM Rafael J. Wysocki wrote: > > On Wednesday, November 07, 2012 04:56:49 PM Alan Stern wrote: > > > On Wed, 7 Nov 2012, Rafael J. Wysocki wrote: > > > > > > > > Right. The reasoning behind my pr

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-07 Thread Rafael J. Wysocki
On Wednesday, November 07, 2012 11:51:15 PM Rafael J. Wysocki wrote: > On Wednesday, November 07, 2012 04:56:49 PM Alan Stern wrote: > > On Wed, 7 Nov 2012, Rafael J. Wysocki wrote: > > > > > > Right. The reasoning behind my proposal goes like this: When there's > > > > no driver, the subsystem c

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-07 Thread Rafael J. Wysocki
On Wednesday, November 07, 2012 04:56:49 PM Alan Stern wrote: > On Wed, 7 Nov 2012, Rafael J. Wysocki wrote: > > > > Right. The reasoning behind my proposal goes like this: When there's > > > no driver, the subsystem can let userspace directly control the > > > device's power level through the po

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-07 Thread Alan Stern
On Wed, 7 Nov 2012, Rafael J. Wysocki wrote: > > Right. The reasoning behind my proposal goes like this: When there's > > no driver, the subsystem can let userspace directly control the > > device's power level through the power/control attribute. > > Well, we might as well just leave the runtim

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-07 Thread Rafael J. Wysocki
On Wednesday, November 07, 2012 03:47:02 PM Alan Stern wrote: > On Wed, 7 Nov 2012, Rafael J. Wysocki wrote: > > > On Wednesday, November 07, 2012 12:17:02 PM Alan Stern wrote: > > > On Wed, 7 Nov 2012, Rafael J. Wysocki wrote: > > > > > > > > The PCI subsystem assumes that > > > > > driverless

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-07 Thread Alan Stern
On Wed, 7 Nov 2012, Rafael J. Wysocki wrote: > On Wednesday, November 07, 2012 12:17:02 PM Alan Stern wrote: > > On Wed, 7 Nov 2012, Rafael J. Wysocki wrote: > > > > > > The PCI subsystem assumes that > > > > driverless devices are not in use, so they are disabled for runtime PM > > > > and mar

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-07 Thread Rafael J. Wysocki
On Wednesday, November 07, 2012 12:17:02 PM Alan Stern wrote: > On Wed, 7 Nov 2012, Rafael J. Wysocki wrote: > > > > The PCI subsystem assumes that > > > driverless devices are not in use, so they are disabled for runtime PM > > > and marked as suspended. This is not appropriate for VGA devices

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-07 Thread Alan Stern
On Wed, 7 Nov 2012, Rafael J. Wysocki wrote: > > The PCI subsystem assumes that > > driverless devices are not in use, so they are disabled for runtime PM > > and marked as suspended. This is not appropriate for VGA devices, > > which can indeed be used without a driver. > > > > I'm not sure

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-07 Thread Rafael J. Wysocki
On Wednesday, November 07, 2012 10:49:04 AM Alan Stern wrote: > On Wed, 7 Nov 2012, Huang Ying wrote: > > > > > Devices will be disabled if the PCI driver is unbound from the PCI > > > > device. > > > > > > Yes. But without a PCI driver, nothing will call > > > pm_runtime_set_suspended. > > >

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-07 Thread Alan Stern
On Wed, 7 Nov 2012, Huang Ying wrote: > > > Devices will be disabled if the PCI driver is unbound from the PCI > > > device. > > > > Yes. But without a PCI driver, nothing will call > > pm_runtime_set_suspended. > > pm_runtime_set_suspended will be called in pci_device_remove or error > path o

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-06 Thread Huang Ying
On Tue, 2012-11-06 at 10:17 -0500, Alan Stern wrote: > On Tue, 6 Nov 2012, Huang Ying wrote: > > > On Sun, 2012-11-04 at 20:56 -0500, Alan Stern wrote: > > > On Mon, 5 Nov 2012, Huang Ying wrote: > > > > > > > In current runtime PM implementation, the active child count of the > > > > parent devi

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-06 Thread Alan Stern
On Tue, 6 Nov 2012, Huang Ying wrote: > On Sun, 2012-11-04 at 20:56 -0500, Alan Stern wrote: > > On Mon, 5 Nov 2012, Huang Ying wrote: > > > > > 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

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-05 Thread Huang Ying
On Sun, 2012-11-04 at 20:56 -0500, Alan Stern wrote: > On Mon, 5 Nov 2012, Huang Ying wrote: > > > 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 P

Re: [BUGFIX] PM: Fix active child counting when disabled and forbidden

2012-11-04 Thread Alan Stern
On Mon, 5 Nov 2012, Huang Ying wrote: > 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 possi