Problems with arch/i386/kernel/apm.c

Problems with arch/i386/kernel/apm.c

Post by Jeff Gold » Wed, 13 Jun 2001 03:00:09



Hi folks,

I've been debugging a problem I've been having with APM.  When I
initiate an "apm --suspend" command, my Tulip card doesn't work
anymore.  However, if I then execute "ifconfig eth0 down ; ifconfig eth0
up" then everything is fine again.

I initially thought the problem was on the Tulip driver side, so I
instrumented the code and found that the driver was correctly processing
incoming and outgoing packets, but it appeared the tx ring was out of
sync with the driver.

Since the tulip_suspend, and tulip_resume functions were basically doing
the same thing as what "ifconfig eth0 down/up" (WRT to the Tulip driver)
I began to look elsewhere.  I think I've tracked the problem down to the
following code:

static int suspend(void)
{
        int             err;
        struct apm_user *as;

        ...
        cli();
        err = apm_set_power_state(APM_STATE_SUSPEND);
        ...
        send_event(APM_NORMAL_RESUME);
        sti();
        ...
        return err;

Quote:}                                                                                      

So it seems that drivers are suspended before the cli(), yet they are
resumed before the sti().  It seems to me that the sti() should come
before apm::send_event(APM_NORMAL_RESUME), and, in fact, if I swap the
two, Tulip survives suspend/resume

Please let me know if this is correct, I can provide a simple patch if
needed.  What I am really desiring to know is if there are any devices
that depend on the apm::send_event(APM_NORMAL_RESUME) happening while
interrupts are disabled.

-Jeff

--
Jeff Golds
Sr. Software Engineer

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

Problems with arch/i386/kernel/apm.c

Post by Jeff Garzi » Wed, 13 Jun 2001 03:20:06



> Please let me know if this is correct, I can provide a simple patch if
> needed.  What I am really desiring to know is if there are any devices
> that depend on the apm::send_event(APM_NORMAL_RESUME) happening while
> interrupts are disabled.

Good spotting...  If any devices depend on what you describe, I would
argue that their drivers should handle that not the core apm code...

--
Jeff Garzik      | Andre the Giant has a posse.
Building 1024    |
MandrakeSoft     |
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

Problems with arch/i386/kernel/apm.c

Post by Alan Co » Wed, 13 Jun 2001 03:50:09


Quote:> > needed.  What I am really desiring to know is if there are any devices
> > that depend on the apm::send_event(APM_NORMAL_RESUME) happening while
> > interrupts are disabled.

> Good spotting...  If any devices depend on what you describe, I would
> argue that their drivers should handle that not the core apm code...

The drivers can't handle it at the moment. I've been talking to many people
about this all hitting this sort of driver problem.

I think the fix is to keep two classes of power management objects and do
the following

        Call each 'nonirq' suspend function
        (aborting if need be)
        cli()
        Call each irq blocked suspend function
        suspend

resume:
        call each irq blocked resume function
        sti();
        call each nonirq resume

That is an easy change set to make and solves a lot of grief

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

Problems with arch/i386/kernel/apm.c

Post by John Fremli » Wed, 13 Jun 2001 04:50:07



[...]

Quote:> Please let me know if this is correct, I can provide a simple patch
> if needed.  What I am really desiring to know is if there are any
> devices that depend on the apm::send_event(APM_NORMAL_RESUME)
> happening while interrupts are disabled.

Yes, USB host controllers

--

        http://ape.n3.net
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

Problems with arch/i386/kernel/apm.c

Post by Patrick Moche » Thu, 14 Jun 2001 09:10:07



> > > needed.  What I am really desiring to know is if there are any devices
> > > that depend on the apm::send_event(APM_NORMAL_RESUME) happening while
> > > interrupts are disabled.

> > Good spotting...  If any devices depend on what you describe, I would
> > argue that their drivers should handle that not the core apm code...

> The drivers can't handle it at the moment. I've been talking to many people
> about this all hitting this sort of driver problem.

> I think the fix is to keep two classes of power management objects and do
> the following

>    Call each 'nonirq' suspend function
>    (aborting if need be)
>    cli()
>    Call each irq blocked suspend function
>    suspend

It shouldn't be necessary to keep two classes of PM objects; instead walk
the device tree twice on suspend.

The first one is an opportunity for the driver to save any device state; a
method to notify the driver that it's going to sleep (as some PPC people
requested); or to do what it needs to with interrupts enabled.

This also gives the system a graceful way to abort the process should any
of the drivers complain that it absolutely cannot suspend (none of the
devices will actually be powered off at that point).

We then disable interrupts and walk the tree again, actually shutting off
devices. This way, no special cases are made, and no partitioning of the
power management objects is needed.

Quote:> resume:
>    call each irq blocked resume function
>    sti();
>    call each nonirq resume

Is this really necessary? We should (note _should_) be able to enable
interrupts, then walk the device tree to resume everything.

Linus confirmed this assumption, but it may turn out to not be the case.
If that is so, then it will be easy enough to do a two stage walk of the
tree, like in suspend - one to power on the device and reinitialize it,
the next to restore state and continue on once interrupts have been
enabled.

        -pat

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

Problems with arch/i386/kernel/apm.c

Post by Alan Co » Fri, 15 Jun 2001 17:30:11


Quote:> Linus confirmed this assumption, but it may turn out to not be the case.

It isnt the case. It's also horrible for debugging if you dont do it two
stage because with two stages you can force some restores to be done with
irqs off so you can see where the bug is
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
 
 
 

1. kernel BUG at arch/i386/kernel/apm.c:1699!

------------[ cut here ]------------
kernel BUG at arch/i386/kernel/apm.c:1699!

#ifdef CONFIG_SMP
        /* 2002/08/01 - WT
         * This is to avoid random crashes at boot time during initialization
         * on SMP systems in case of "apm=power-off" mode. Seen on ASUS A7M266D.
         * Some bioses don't like being called from CPU != 0.
         * Method suggested by Ingo Molnar.
         */
        if (smp_processor_id() != 0) {
                current->cpus_allowed = 1;
                schedule();
                if (unlikely(smp_processor_id() != 0))
                        BUG();
        }
#endif

Why ? :()

2.5.42-mm2, 2xPPro-233, etc ...

--
Paul P 'Stingray' Komkoff 'Greatest' Jr /// (icq)23200764 /// (http)stingr.net
  When you're invisible, the only one really watching you is you (my keychain)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

2. ring0-linux debugger

3. Kernel 2.4.14, arch/i386/kernel/apm.c, SMP power-off busted?

4. Intel 845E (MSI 6566E ver.1 without HT support) and Red Hat 9...

5. 2.5.33 - Unresolved symbols in arch/i386/kernel/apm.o - depmod: cpu_gdt_table

6. Cable modem bonding??

7. arch/i386/kernel/bluesmoke.c, kernel 2.4.18

8. pppd signal 11

9. problems with Linux-2.1.X kernel modules (i386 arch)

10. problem about arch/i386/kernel/traps.c

11. Problem with arch/i386/kernel/irq.c

12. 2.5.23 - arch/i386/kernel/mpparse.c problem

13. arch/i386/kernel/entry.S