Re: [PATCH] pm_ops: add irq enable/disable hooks

Rafael J. Wysocki
2007-04-06T00:02:13Z

On Friday, 6 April 2007 01:28, Johannes Berg wrote:
> On Fri, 2007-04-06 at 01:30 +0200, Rafael J. Wysocki wrote:
>
> > Well is this possible to do something like
> >
> > if (pm_ops->do_something_before_disabling_irqs)
> > pm_ops->do_something_before_disabling_irqs()
> > local_irq_save(flags);
> > if (pm_ops->do_something_after_disabling_irqs)
> > pm_ops->do_something_after_disabling_irqs()
> >
> > and analogously for enabling the IRQs?
>
> Ultimately yes, but is it worth the added complexity? Somebody mucking
> with pm_ops has to know what he's doing anyway.

Well, this seems to be more natural ("if you want to do something before/after
disabling the IRQs, define it" instead of "you can do something instead of
calling local_irq_save(), but please remember to disable the IRQs yourself
in that case").

BTW, it need not be in pm_ops (actually, why should it be there?).
Alternatively, you can define something like arch_prepare_for_disabling_irqs()
and/or arch_prepare_device_power_down() that will be empty on x86, for
example.

BTW2, I think BUG_ON(irqs_enabled) is needed after the arch does something
instead of or after local_irq_save().

Rafael