Subject: Re: disable interrput under ppc?

From: "Wang, Baojun" <[email-masked]>
Date: Wed, 5 Sep 2007 10:00:46 +0800

On Wednesday 05 September 2007, you wrote:
> On Tue, 4 Sep 2007 13:24:33 -0500
>
> Scott Wood <[email-masked]> wrote:
> > On Tue, Sep 04, 2007 at 10:44:14AM +0800, Wang, Baojun wrote:
> > > hi, list
> > >
> > >   How can I disable interrput like `cli' in x86?
> >
> > local_irq_disable().
> >
> > > I want the following code freeze the box but it doesn't, $MSR is
> > > altered however the box is still alive, how can I freeze the box like
> > > `cli' in x86? Thanks very much!
> >
> > Disabling interrupts doesn't freeze the machine by itself -- it depends
> > on what you do afterwards, which you didn't show.
I need to check whether the interrupt have been disabled already, so I'm 
expected after local_irq_disable() ( __asm__ __volatile__ ("wrteei 
0": : :"memory) ), the machine is dead but it doesn't.
> If you're using a BOOKE variant, there is a way to use the DBCR0
> register to set debug wait enable or something to basically hang the
> CPU until something external clears that bit.  But why you would want
> to do that, I have no idea.
Sorry, I just want to check whether disable_irq/enable_irq is functioning.
> josh

I'm not really getting confused about the following code:

  // Executing all pending events
  while ((event = get_next_set_bit_and_clear
          (pending, xm_root_domain -> events -> masked_events)) != -1) {
    // An event  pending when there  is not any  handler installed
    // catching it??? it must be an error
    //assert (xm_root_domain -> event_handler [event]);
    if (!xm_root_domain -> events -> event_handler [event]) continue;
      // Before executing an event handler, events' flag is disabled
      // and the event is masked

    printk(KERN_EMERG"sync_root_events: looping!\n");

    set_bit (xm_root_domain -> events -> masked_events, event);
    printk(KERN_EMERG"sync_root_events: looping 2!\n");
    disable_events_flag (xm_root_domain);
    printk(KERN_EMERG"sync_root_events: looping 3!\n");
    printk(KERN_EMERG"hw_irq_disabled?: %d\n", hw_irq_disabled());
    hw_enable_irq ();
    printk(KERN_EMERG"sync_root_events: looping 4!\n");
    // Here, the event handler is executed always
    // with the same conditions, that is, event flag disabled
    // and the executed event masked as well
    (*xm_root_domain -> events -> event_handler[event])
      (event, regs);
    printk(KERN_EMERG"sync_root_events: looping 5!\n");
    hw_disable_irq();
    printk(KERN_EMERG"sync_root_events: looping 6!\n");
    // Events flag is automatically enabled (iret emulation)
    enable_events_flag (xm_root_domain);
  }

hw_enable_irq() and hw_disable_irq() is exactly the same as 
local_irq_enable()/local_irq_disable(), but the output shows while running 
hw_eable_irq() (at that point irq is disabled), the rest of the code is 
blocked, and I don't know why:

output:
[  172.049381] sync_root_events: looping!
[  172.053159] sync_root_events: looping 2!
[  172.057094] sync_root_events: looping 3!
[  172.061027] hw_irq_disabled?: 1
[  172.997338] sync_root_events: looping!
[  173.001095] sync_root_events: looping 2!
[  173.005028] sync_root_events: looping 3!
[  173.008961] hw_irq_disabled?: 1

I'm sorry If I'm asking a bad question, I'm not familiar with ppc/kernel 
programming at this moment. Great thanks to Scott and josh for your reply. 

  Regards,
Wang
-- 
Wang, Baojun                                        Lanzhou University
Distributed & Embedded System Lab              http://dslab.lzu.edu.cn
School of Information Science and Engeneering        [email-masked]
Tianshui South Road 222. Lanzhou 730000                     .P.R.China
Tel:+86-931-8912025                                Fax:+86-931-8912022