public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* RE: power management of user-space drivers
       [not found] ` <20110215231236.GE2785@local>
@ 2011-02-15 23:27   ` Benenati, Chris J
  2011-02-16  0:21     ` uio: " Hans J. Koch
  2011-02-16  0:20   ` Benenati, Chris J
  1 sibling, 1 reply; 7+ messages in thread
From: Benenati, Chris J @ 2011-02-15 23:27 UTC (permalink / raw)
  To: Hans J. Koch; +Cc: linux-kernel@vger.kernel.org

Thanks for your reply. I understand (pretty much) the suspend/resume interface and its registration via the Linux device model.

However, that is a kernel-level interface. Assuming you have a kernel component to your driver, I suppose it could register a suspend() function and communicate it to the user space part of the driver.

But in a case like suspend-to-RAM, the kernel freezes user space threads before the suspend() functions are invoked.  By the time the suspend function is called, it is too late to communicate with user space. 

Is there a form of user-space driver notification supported by the kernel? Or does the kernel portion of the driver have to register for kernel notifications (which precede thread freezing) and alert the user space portion before it is frozen? 

-----Original Message-----
From: Hans J. Koch [mailto:hjk@hansjkoch.de] 
Sent: Tuesday, February 15, 2011 3:13 PM
To: Benenati, Chris J
Cc: hjk@hansjkoch.de
Subject: Re: power management of user-space drivers

On Tue, Feb 15, 2011 at 01:46:03PM -0800, Benenati, Chris J wrote:
> Somebody brought your web page http://www.kernel.org/doc/htmldocs/uio-howto.html to my attention.

Hi Chris,
first of all: Please don't send private mail to kernel maintainers unless
you're willing to pay for private consultation. UIO is discussed on the
Linux Kernel Mailing List (LKML), and it's a benefit for everyone if these
discussions are public and can be found in the archives by search engines.

So, please make sure you Cc: LKML (linux-kernel@vger.kernel.org) in any
further mails.

> 
> How do you handle power management with such a driver?  For example, if state has to be saved before a suspend-to-RAM, or reinitialized on the subsequent resume.

You need to do that yourself, e.g. for a PCI card by implementing a suspend()
and resume() function and setting the respective pointers in struct pci_driver.
These functions will be called automatically by the driver core, and you can do
whatever you need there.

A way to implement such a thing for platform devices can be found in
drivers/uio/uio_pdrv_genirq.c

Thanks,
Hans


^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: power management of user-space drivers
       [not found] ` <20110215231236.GE2785@local>
  2011-02-15 23:27   ` power management of user-space drivers Benenati, Chris J
@ 2011-02-16  0:20   ` Benenati, Chris J
  1 sibling, 0 replies; 7+ messages in thread
From: Benenati, Chris J @ 2011-02-16  0:20 UTC (permalink / raw)
  To: Hans J. Koch; +Cc: linux-kernel@vger.kernel.org

[added line breaks]

Thanks for your reply. I understand (pretty much) the suspend/resume interface and
its registration via the Linux device model.

However, that is a kernel-level interface. Assuming you have a kernel component to 
your driver, I suppose it could register a suspend() function and communicate it to
the user space part of the driver.

But in a case like suspend-to-RAM, the kernel freezes user space threads before the
suspend() functions are invoked.  By the time the suspend function is called, it is
too late to communicate with user space. 

Is there a form of user-space driver notification supported by the kernel? Or does
the kernel portion of the driver have to register for kernel notifications (which
precede thread freezing) and alert the user space portion before it is frozen? 

-----Original Message-----
From: Hans J. Koch [mailto:hjk@hansjkoch.de] 
Sent: Tuesday, February 15, 2011 3:13 PM
To: Benenati, Chris J
Cc: hjk@hansjkoch.de
Subject: Re: power management of user-space drivers

On Tue, Feb 15, 2011 at 01:46:03PM -0800, Benenati, Chris J wrote:
> Somebody brought your web page http://www.kernel.org/doc/htmldocs/uio-howto.html
> to my attention.

Hi Chris,
first of all: Please don't send private mail to kernel maintainers unless
you're willing to pay for private consultation. UIO is discussed on the
Linux Kernel Mailing List (LKML), and it's a benefit for everyone if these
discussions are public and can be found in the archives by search engines.

So, please make sure you Cc: LKML (linux-kernel@vger.kernel.org) in any
further mails.

> 
> How do you handle power management with such a driver?  For example, if state
> has to be saved before a suspend-to-RAM, or reinitialized on the subsequent resume.

You need to do that yourself, e.g. for a PCI card by implementing a suspend()
and resume() function and setting the respective pointers in struct pci_driver.
These functions will be called automatically by the driver core, and you can do
whatever you need there.

A way to implement such a thing for platform devices can be found in
drivers/uio/uio_pdrv_genirq.c

Thanks,
Hans


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: uio: power management of user-space drivers
  2011-02-15 23:27   ` power management of user-space drivers Benenati, Chris J
@ 2011-02-16  0:21     ` Hans J. Koch
  2011-02-16  0:35       ` Benenati, Chris J
  2011-02-16  1:17       ` Greg KH
  0 siblings, 2 replies; 7+ messages in thread
From: Hans J. Koch @ 2011-02-16  0:21 UTC (permalink / raw)
  To: Benenati, Chris J; +Cc: Hans J. Koch, linux-kernel@vger.kernel.org, Greg KH

On Tue, Feb 15, 2011 at 03:27:10PM -0800, Benenati, Chris J wrote:

Could you please limit the line length in your mails to something like
80 characters?

> Thanks for your reply. I understand (pretty much) the suspend/resume interface and its registration via the Linux device model.
> 
> However, that is a kernel-level interface. Assuming you have a kernel component to your driver, I suppose it could register a suspend() function and communicate it to the user space part of the driver.
> 
> But in a case like suspend-to-RAM, the kernel freezes user space threads before the suspend() functions are invoked.  By the time the suspend function is called, it is too late to communicate with user space. 
> 
> Is there a form of user-space driver notification supported by the kernel? Or does the kernel portion of the driver have to register for kernel notifications (which precede thread freezing) and alert the user space portion before it is frozen? 

What are you trying to achieve?
Could you give an example of the problem you're facing in your application?

Let me guess: suspend/resume functions are supposed to leave your hardware in
a consistent state and you don't know the state if the suspend() catches you
in the middle of your userspace processing?
I remember the Android guys had problems like that and invented some
"suspend blockers". However, I don't remember what the final answer in that
discussion was. Greg?

Thanks,
Hans

> 
> -----Original Message-----
> From: Hans J. Koch [mailto:hjk@hansjkoch.de] 
> Sent: Tuesday, February 15, 2011 3:13 PM
> To: Benenati, Chris J
> Cc: hjk@hansjkoch.de
> Subject: Re: power management of user-space drivers
> 
> On Tue, Feb 15, 2011 at 01:46:03PM -0800, Benenati, Chris J wrote:
> > Somebody brought your web page http://www.kernel.org/doc/htmldocs/uio-howto.html to my attention.
> 
> Hi Chris,
> first of all: Please don't send private mail to kernel maintainers unless
> you're willing to pay for private consultation. UIO is discussed on the
> Linux Kernel Mailing List (LKML), and it's a benefit for everyone if these
> discussions are public and can be found in the archives by search engines.
> 
> So, please make sure you Cc: LKML (linux-kernel@vger.kernel.org) in any
> further mails.
> 
> > 
> > How do you handle power management with such a driver?  For example, if state has to be saved before a suspend-to-RAM, or reinitialized on the subsequent resume.
> 
> You need to do that yourself, e.g. for a PCI card by implementing a suspend()
> and resume() function and setting the respective pointers in struct pci_driver.
> These functions will be called automatically by the driver core, and you can do
> whatever you need there.
> 
> A way to implement such a thing for platform devices can be found in
> drivers/uio/uio_pdrv_genirq.c
> 
> Thanks,
> Hans
> 
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: uio: power management of user-space drivers
  2011-02-16  0:21     ` uio: " Hans J. Koch
@ 2011-02-16  0:35       ` Benenati, Chris J
  2011-02-16  1:40         ` Greg KH
  2011-02-16  1:17       ` Greg KH
  1 sibling, 1 reply; 7+ messages in thread
From: Benenati, Chris J @ 2011-02-16  0:35 UTC (permalink / raw)
  To: Hans J. Koch; +Cc: linux-kernel@vger.kernel.org, Greg KH

Well, for example, a device may have complex application-driven hardware state,
which in turn in turn can be driven by user inputs. That state will be lost when
the system powers down.  It might be necessary to invoke the driver suspend()
function before power is dropped, to read registers and preserve that state.
It is definitely necessary to call the resume function to reprogram the registers
when the power is restored.

-----Original Message-----
From: Hans J. Koch [mailto:hjk@hansjkoch.de] 
Sent: Tuesday, February 15, 2011 4:21 PM
To: Benenati, Chris J
Cc: Hans J. Koch; linux-kernel@vger.kernel.org; Greg KH
Subject: Re: uio: power management of user-space drivers

On Tue, Feb 15, 2011 at 03:27:10PM -0800, Benenati, Chris J wrote:

Could you please limit the line length in your mails to something like
80 characters?

> Thanks for your reply. I understand (pretty much) the suspend/resume interface
> and its registration via the Linux device model.
> 
> However, that is a kernel-level interface. Assuming you have a kernel component to
> your driver, I suppose it could register a suspend() function and communicate it to
> the user space part of the driver.
> 
> But in a case like suspend-to-RAM, the kernel freezes user space threads before the
> suspend() functions are invoked.  By the time the suspend function is called, it
> is too late to communicate with user space. 
> 
> Is there a form of user-space driver notification supported by the kernel? Or does
> the kernel portion of the driver have to register for kernel notifications (which
> precede thread freezing) and alert the user space portion before it is frozen? 

What are you trying to achieve?
Could you give an example of the problem you're facing in your application?

Let me guess: suspend/resume functions are supposed to leave your hardware in
a consistent state and you don't know the state if the suspend() catches you
in the middle of your userspace processing?
I remember the Android guys had problems like that and invented some
"suspend blockers". However, I don't remember what the final answer in that
discussion was. Greg?

Thanks,
Hans

> 
> -----Original Message-----
> From: Hans J. Koch [mailto:hjk@hansjkoch.de] 
> Sent: Tuesday, February 15, 2011 3:13 PM
> To: Benenati, Chris J
> Cc: hjk@hansjkoch.de
> Subject: Re: power management of user-space drivers
> 
> On Tue, Feb 15, 2011 at 01:46:03PM -0800, Benenati, Chris J wrote:
> > Somebody brought your web page http://www.kernel.org/doc/htmldocs/uio-howto.html to my attention.
> 
> Hi Chris,
> first of all: Please don't send private mail to kernel maintainers unless
> you're willing to pay for private consultation. UIO is discussed on the
> Linux Kernel Mailing List (LKML), and it's a benefit for everyone if these
> discussions are public and can be found in the archives by search engines.
> 
> So, please make sure you Cc: LKML (linux-kernel@vger.kernel.org) in any
> further mails.
> 
> > 
> > How do you handle power management with such a driver?  For example, if state has to be saved before a suspend-to-RAM, or reinitialized on the subsequent resume.
> 
> You need to do that yourself, e.g. for a PCI card by implementing a suspend()
> and resume() function and setting the respective pointers in struct pci_driver.
> These functions will be called automatically by the driver core, and you can do
> whatever you need there.
> 
> A way to implement such a thing for platform devices can be found in
> drivers/uio/uio_pdrv_genirq.c
> 
> Thanks,
> Hans
 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: uio: power management of user-space drivers
  2011-02-16  0:21     ` uio: " Hans J. Koch
  2011-02-16  0:35       ` Benenati, Chris J
@ 2011-02-16  1:17       ` Greg KH
  2011-02-16 18:15         ` Hans J. Koch
  1 sibling, 1 reply; 7+ messages in thread
From: Greg KH @ 2011-02-16  1:17 UTC (permalink / raw)
  To: Hans J. Koch; +Cc: Benenati, Chris J, linux-kernel@vger.kernel.org

On Wed, Feb 16, 2011 at 01:21:04AM +0100, Hans J. Koch wrote:
> Let me guess: suspend/resume functions are supposed to leave your hardware in
> a consistent state and you don't know the state if the suspend() catches you
> in the middle of your userspace processing?
> I remember the Android guys had problems like that and invented some
> "suspend blockers". However, I don't remember what the final answer in that
> discussion was. Greg?

It's all in the kernel today.  See:
	http://lwn.net/Articles/416690/
for all of the details you will ever need.

Hope this helps,

greg k-h

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: uio: power management of user-space drivers
  2011-02-16  0:35       ` Benenati, Chris J
@ 2011-02-16  1:40         ` Greg KH
  0 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2011-02-16  1:40 UTC (permalink / raw)
  To: Benenati, Chris J; +Cc: Hans J. Koch, linux-kernel@vger.kernel.org, Greg KH


A: No.
Q: Should I include quotations after my reply?

http://daringfireball.net/2007/07/on_top

On Tue, Feb 15, 2011 at 04:35:16PM -0800, Benenati, Chris J wrote:
> Well, for example, a device may have complex application-driven hardware state,
> which in turn in turn can be driven by user inputs. That state will be lost when
> the system powers down.  It might be necessary to invoke the driver suspend()
> function before power is dropped, to read registers and preserve that state.
> It is definitely necessary to call the resume function to reprogram the registers
> when the power is restored.

Then write a real driver for your device if this type of "complex"
hardware state must be controlled.  Don't use UIO for things it was not
ment to be used for.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: uio: power management of user-space drivers
  2011-02-16  1:17       ` Greg KH
@ 2011-02-16 18:15         ` Hans J. Koch
  0 siblings, 0 replies; 7+ messages in thread
From: Hans J. Koch @ 2011-02-16 18:15 UTC (permalink / raw)
  To: Greg KH; +Cc: Hans J. Koch, Benenati, Chris J, linux-kernel@vger.kernel.org

On Tue, Feb 15, 2011 at 05:17:54PM -0800, Greg KH wrote:
> On Wed, Feb 16, 2011 at 01:21:04AM +0100, Hans J. Koch wrote:
> > Let me guess: suspend/resume functions are supposed to leave your hardware in
> > a consistent state and you don't know the state if the suspend() catches you
> > in the middle of your userspace processing?
> > I remember the Android guys had problems like that and invented some
> > "suspend blockers". However, I don't remember what the final answer in that
> > discussion was. Greg?
> 
> It's all in the kernel today.  See:
> 	http://lwn.net/Articles/416690/
> for all of the details you will ever need.

Interesting. After reading that, I've got the impression that this could be
used by UIO drivers and maybe solve Chris' problem. Or did I miss something?

Thanks,
Hans

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-02-16 18:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <0635488208022A4F82521A04A4772E15C555EC7E@orsmsx503.amr.corp.intel.com>
     [not found] ` <20110215231236.GE2785@local>
2011-02-15 23:27   ` power management of user-space drivers Benenati, Chris J
2011-02-16  0:21     ` uio: " Hans J. Koch
2011-02-16  0:35       ` Benenati, Chris J
2011-02-16  1:40         ` Greg KH
2011-02-16  1:17       ` Greg KH
2011-02-16 18:15         ` Hans J. Koch
2011-02-16  0:20   ` Benenati, Chris J

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox