mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* RE: 2.5.66-bk12: acpi_power_off: sleeping function called from il legal context
@ 2003-04-07 17:56 Grover, Andrew
  2003-04-07 19:06 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: Grover, Andrew @ 2003-04-07 17:56 UTC (permalink / raw)
  To: Andrew Morton, Zwane Mwaikambo; +Cc: felipe_alfaro, linux-kernel

> From: Andrew Morton [mailto:akpm@digeo.com] 
> Zwane Mwaikambo <zwane@linuxpower.ca> wrote:
> >
> > -	if (in_atomic())
> > +	if (in_atomic() || irqs_disabled())
> >  		timeout = 0;
> 
> Andy, why does the ACPI code have this test?
> 
> Is it to determine whether a caller of this functon is 
> currently holding a spinlock?  If so then it will only work 
> on a preemptible kernel.

No, see below.

> A non-preempt kernel will not increment preempt_count() when 
> it takes a spinlock and ACPI could mistakenly schedule away 
> and cause a system deadlock.

acpi_enter_sleep_state should not be acquiring any semaphores. All calls
to acpi_set_register in that function should be called with
ACPI_MTX_DO_NOT_LOCK. Problem solved. :)

Andrew, as to why we are doing this:

The main function of the ACPI interpreter is to execute control methods.
We never execute a control method from an interrupt, we always do it
from thread context. We have semaphores to protect various resources,
and use this function (acpi_os_wait_semaphore) to acquire them. We
usually call it with timeout value ACPI_WAIT_FOREVER, which results in a
down().

However, we also have to execute control methods early in the boot
sequence. down() would never block but it thinks it might, so we want to
call down_trylock instead. in_atomic() seemed to be a good (?) way to
tell whether we need to avoid down() or not.

Thoughts on better ways to do this, perhaps? I guess I should at least
add a comment above that line.

Regards -- Andy

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

* Re: 2.5.66-bk12: acpi_power_off: sleeping function called from il legal context
  2003-04-07 17:56 2.5.66-bk12: acpi_power_off: sleeping function called from il legal context Grover, Andrew
@ 2003-04-07 19:06 ` Andrew Morton
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2003-04-07 19:06 UTC (permalink / raw)
  To: Grover, Andrew; +Cc: zwane, felipe_alfaro, linux-kernel

"Grover, Andrew" <andrew.grover@intel.com> wrote:
>
> However, we also have to execute control methods early in the boot
> sequence. down() would never block but it thinks it might, so we want to
> call down_trylock instead. in_atomic() seemed to be a good (?) way to
> tell whether we need to avoid down() or not.
> 
> Thoughts on better ways to do this, perhaps? I guess I should at least
> add a comment above that line.
> 

So really it's just the debug code which is being misleading?  hm.

Couldn't you set some magical global ACPI flag:

acpi_super_early_init()
{
	acpi_in_super_early_init = 1;
	do_stuff();
	acpi_in_super_early_init = 0;
}

And test that flag in acpi_os_wait_semaphore()?

It's a bit grubby, but so is the problem.

We do have this `system_running' flags in init/main.c which perhaps should be
fleshed out into a more fine-grained way of communicating the kernel's
start/run/stop state.


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

end of thread, other threads:[~2003-04-07 19:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-07 17:56 2.5.66-bk12: acpi_power_off: sleeping function called from il legal context Grover, Andrew
2003-04-07 19:06 ` Andrew Morton

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

all inboxes | Powered by JetHome®