2009-06-11 18:55:45

by Jesse Barnes

[permalink] [raw]
Subject: Re: [PATCH 2/2] PCI PM: Read device power state from register after updating it

On Tue, 26 May 2009 21:52:29 +0200
"Rafael J. Wysocki" <[email protected]> wrote:

> On Monday 18 May 2009, Rafael J. Wysocki wrote:
> > From: Rafael J. Wysocki <[email protected]>
> >
> > After attempting to change the power state of a PCI device
> > pci_raw_set_power_state() doesn't check if the value it wrote into
> > the device's PCI_PM_CTRL register has been stored in there. Still,
> > it modifies the device's current_state field as though that's the
> > case. This may cause the driver of the device to think that its
> > power state has been changed while in fact it hasn't.
> >
> > To prevent such situations from happening modify
> > pci_raw_set_power_state() so that it reads the device's PCI_PM_CTRL
> > register after writing into it and uses the value read from the
> > register to update the device's current_state field. Also make it
> > return -EIO if the new state of the device is not equal to the state
> > requested by the called.
> >
> > To distinguish this error condition from the other ones make
> > pci_raw_set_power_state() return -ENOSYS instead of -EIO when it is
> > impossible to change the power state of the device, because it
> > doesn't support the native PCI PM at all or the requested target
> > state is not supported by it.
>
> Having reconsidered it I think that -ENODEV is probably better than
> -ENOSYS for this purpose. Updated patch follows.

Applied to linux-next, thanks Rafael.

--
Jesse Barnes, Intel Open Source Technology Center


2009-06-11 19:53:11

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH 2/2] PCI PM: Read device power state from register after updating it

On Thursday 11 June 2009, Jesse Barnes wrote:
> On Tue, 26 May 2009 21:52:29 +0200
> "Rafael J. Wysocki" <[email protected]> wrote:
>
> > On Monday 18 May 2009, Rafael J. Wysocki wrote:
> > > From: Rafael J. Wysocki <[email protected]>
> > >
> > > After attempting to change the power state of a PCI device
> > > pci_raw_set_power_state() doesn't check if the value it wrote into
> > > the device's PCI_PM_CTRL register has been stored in there. Still,
> > > it modifies the device's current_state field as though that's the
> > > case. This may cause the driver of the device to think that its
> > > power state has been changed while in fact it hasn't.
> > >
> > > To prevent such situations from happening modify
> > > pci_raw_set_power_state() so that it reads the device's PCI_PM_CTRL
> > > register after writing into it and uses the value read from the
> > > register to update the device's current_state field. Also make it
> > > return -EIO if the new state of the device is not equal to the state
> > > requested by the called.
> > >
> > > To distinguish this error condition from the other ones make
> > > pci_raw_set_power_state() return -ENOSYS instead of -EIO when it is
> > > impossible to change the power state of the device, because it
> > > doesn't support the native PCI PM at all or the requested target
> > > state is not supported by it.
> >
> > Having reconsidered it I think that -ENODEV is probably better than
> > -ENOSYS for this purpose. Updated patch follows.
>
> Applied to linux-next, thanks Rafael.

Please drop. It has been reported by Jiri to cause a regression to happen.

Best,
Rafael

2009-06-11 20:01:42

by Jesse Barnes

[permalink] [raw]
Subject: Re: [PATCH 2/2] PCI PM: Read device power state from register after updating it

On Thu, 11 Jun 2009 12:53:16 -0700
"Rafael J. Wysocki" <[email protected]> wrote:

> On Thursday 11 June 2009, Jesse Barnes wrote:
> > On Tue, 26 May 2009 21:52:29 +0200
> > "Rafael J. Wysocki" <[email protected]> wrote:
> >
> > > On Monday 18 May 2009, Rafael J. Wysocki wrote:
> > > > From: Rafael J. Wysocki <[email protected]>
> > > >
> > > > After attempting to change the power state of a PCI device
> > > > pci_raw_set_power_state() doesn't check if the value it wrote
> > > > into the device's PCI_PM_CTRL register has been stored in
> > > > there. Still, it modifies the device's current_state field as
> > > > though that's the case. This may cause the driver of the
> > > > device to think that its power state has been changed while in
> > > > fact it hasn't.
> > > >
> > > > To prevent such situations from happening modify
> > > > pci_raw_set_power_state() so that it reads the device's
> > > > PCI_PM_CTRL register after writing into it and uses the value
> > > > read from the register to update the device's current_state
> > > > field. Also make it return -EIO if the new state of the device
> > > > is not equal to the state requested by the called.
> > > >
> > > > To distinguish this error condition from the other ones make
> > > > pci_raw_set_power_state() return -ENOSYS instead of -EIO when
> > > > it is impossible to change the power state of the device,
> > > > because it doesn't support the native PCI PM at all or the
> > > > requested target state is not supported by it.
> > >
> > > Having reconsidered it I think that -ENODEV is probably better
> > > than -ENOSYS for this purpose. Updated patch follows.
> >
> > Applied to linux-next, thanks Rafael.
>
> Please drop. It has been reported by Jiri to cause a regression to
> happen.

Ah as I went through the rebase I thought I remembered something like
that. Will drop.

Thanks,
--
Jesse Barnes, Intel Open Source Technology Center