Skip to contentSkip to conversation

suggestion on resumption

DISCUSSION Oliver Neukum 3 participants 6 messages Nov 26, 2009 – Nov 28, 2009

lore
Share & tools
lore
#0 lore raw

Hi,

using the USB autosuspend framework I've often faced characteristic problems coding resume() methods. This has led me to an idea. Resume() would be much easier to code if I knew about the reason of resumption, especially about the code path resume() is called in. I wonder whether we could introduce a message argument to resume and give it a few bits from the caller.

Regards
Oliver

#1 lore raw
Quoted 8 lines · Oliver Neukum

Hi,

using the USB autosuspend framework I've often faced characteristic problems coding resume() methods. This has led me to an idea. Resume() would be much easier to code if I knew about the reason of resumption, especially about the code path resume() is called in. I wonder whether we could introduce a message argument to resume and give it a few bits from the caller.

Each of the callbacks in struct dev_pm_ops is executed in exactly one context, so for each of them it is known why it was called.

Thanks,
Rafael

#2 lore raw

Am Freitag, 27. November 2009 01:47:44 schrieb Rafael J. Wysocki:

Quoted 10 lines · Oliver Neukum
Quoted 8 lines

Hi,

using the USB autosuspend framework I've often faced characteristic problems coding resume() methods. This has led me to an idea. Resume() would be much easier to code if I knew about the reason of resumption, especially about the code path resume() is called in. I wonder whether we could introduce a message argument to resume and give it a few bits from the caller.

Quoted 2 lines

Each of the callbacks in struct dev_pm_ops is executed in exactly one
context, so for each of them it is known why it was called.

But the resume method in the driver doesn't learn. It is an extrem hassle not to know whether you are called synchronously (ie from open which already holds a lock) or asynchronously (which means you need to guard against open)

Regards
Oliver

#3 lore raw
Quoted 11 lines · Oliver Neukum

Am Freitag, 27. November 2009 01:47:44 schrieb Rafael J. Wysocki:

Quoted 10 lines · Oliver Neukum
Quoted 8 lines

Hi,

using the USB autosuspend framework I've often faced characteristic problems coding resume() methods. This has led me to an idea. Resume() would be much easier to code if I knew about the reason of resumption, especially about the code path resume() is called in. I wonder whether we could introduce a message argument to resume and give it a few bits from the caller.

Quoted 7 lines
Quoted 2 lines

Each of the callbacks in struct dev_pm_ops is executed in exactly one
context, so for each of them it is known why it was called.

But the resume method in the driver doesn't learn. It is an extrem hassle not to know whether you are called synchronously (ie from open which already holds a lock) or asynchronously (which means you need to guard against open)

With the new Runtime PM framework, there isn't always a one-to-one correspondence between resume requests and method callbacks. So the "reason" for a callback isn't always well defined. And even if it were, the callback might happen in a different thread from the request.

The way to guard against open from an asynchronous context is to approach the problem the other way around: Guard against async contexts while open is running. In other words, have open do an autoresume.

Exactly what situation are you concerned about?

Alan Stern

#4 lore raw

Am Freitag, 27. November 2009 18:43:12 schrieb Alan Stern:

Quoted 9 lines
Quoted 4 lines

But the resume method in the driver doesn't learn. It is an extrem hassle not to know whether you are called synchronously (ie from open which already holds a lock) or asynchronously (which means you need to guard against open)

With the new Runtime PM framework, there isn't always a one-to-one correspondence between resume requests and method callbacks. So the "reason" for a callback isn't always well defined. And even if it were, the callback might happen in a different thread from the request.

That is exactly what I need to know.

Quoted 3 lines

The way to guard against open from an asynchronous context is to approach the problem the other way around: Guard against async contexts while open is running. In other words, have open do an autoresume.

That is the problem locking requirements are different when I do that and I don't know what's the case.

Regards
Oliver

#5 lore raw
Quoted 11 lines · Oliver Neukum

Am Freitag, 27. November 2009 18:43:12 schrieb Alan Stern:

Quoted 9 lines
Quoted 4 lines

But the resume method in the driver doesn't learn. It is an extrem hassle not to know whether you are called synchronously (ie from open which already holds a lock) or asynchronously (which means you need to guard against open)

With the new Runtime PM framework, there isn't always a one-to-one correspondence between resume requests and method callbacks. So the "reason" for a callback isn't always well defined. And even if it were, the callback might happen in a different thread from the request.

Quoted 8 lines

That is exactly what I need to know.

Quoted 3 lines

The way to guard against open from an asynchronous context is to approach the problem the other way around: Guard against async contexts while open is running. In other words, have open do an autoresume.

That is the problem locking requirements are different when I do that and I don't know what's the case.

What are the details?

Alan Stern