qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] trigger a gpio interrupt inside qemu
@ 2013-08-27 11:36 she roy
  2013-08-27 11:52 ` Max Filippov
  0 siblings, 1 reply; 11+ messages in thread
From: she roy @ 2013-08-27 11:36 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 2113 bytes --]

Is there somebody can help me to trigger a gpio interrupt inside qemu? I
wrote a simple function to trigger a interrupt in pl061.c as follow:
PL061State *gPl061;
void pl061_raise_irq()
{
    qemu_set_irq(gPl061->irq, 1);
}
gPl061 is assigned in function pl061_initfn:
static int pl061_initfn(SysBusDevice *sbd)
{
    DeviceState *dev = DEVICE(sbd);
    PL061State *s = PL061(dev);
    memory_region_init_io(&s->iomem, OBJECT(s), &pl061_ops, s, "pl061",
0x1000);
    sysbus_init_mmio(sbd, &s->iomem);
    sysbus_init_irq(sbd, &s->irq);
    qdev_init_gpio_in(dev, pl061_set_irq, 8);
    qdev_init_gpio_out(dev, s->out, 8);
    pl061_reset(s);
    gPl061 = s;
    return 0;
}
I installed an interrupt handler in the guest linux system:
MODULE_LICENSE("GPL");
MODULE_AUTHOR("sermonko");

int irq = 41;
char interface[] = "gpio";

int irq_handle_function(int irq, void *device_id)
{
    static int count = 1;
    MSG("[%d]receive the irq at %ld...\n", count, jiffies);
    count++;
    return IRQ_HANDLED;
}

int __init int_init_module()
{
    if(request_irq(irq, irq_handle_function, IRQF_SHARED, interface, (void
*)&irq))
    {
        MSG("regist irq failure...\n");
        return -EIO;
    }
    MSG("interface=%s and irq=%d...\n", interface, irq);
    MSG("regist irq success...\n");
    return 0;
}

void __exit int_cleanup_module()
{
    free_irq(irq, &irq);
    MSG("unregist irq...\n");
}
module_init(int_init_module);
module_exit(int_cleanup_module);
I start qemu using this command: qemu-system-arm -M versatilepb -kernel
output/images/zImage -drive file=output/images/rootfs.ext2,if=scsi -append
"root=/dev/sda console=ttyAMA0,115200" -serial stdio -net nic -net
bridge,br=br0
But when i call pl061_raise_irq inside qemu once, the guest run into an
infinite loop. it prints:
...
irq:[927012]receive the irq at -12002...
irq:[927013]receive the irq at -12002...
irq:[927014]receive the irq at -12002...
irq:[927015]receive the irq at -12002...
irq:[927016]receive the irq at -12002...
irq:[927017]receive the irq at -12002...
irq:[927018]receive the irq at -12002...
...
can somebody tell me what's wrong?

[-- Attachment #2: Type: text/html, Size: 21554 bytes --]

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

* Re: [Qemu-devel] trigger a gpio interrupt inside qemu
  2013-08-27 11:36 [Qemu-devel] trigger a gpio interrupt inside qemu she roy
@ 2013-08-27 11:52 ` Max Filippov
       [not found]   ` <CAMY-hrGSwRw1oq58Pz66sfmDb4SA-bZfBSiU6kmfkj6FBPK97A@mail.gmail.com>
  0 siblings, 1 reply; 11+ messages in thread
From: Max Filippov @ 2013-08-27 11:52 UTC (permalink / raw)
  To: she roy; +Cc: qemu-devel

On Tue, Aug 27, 2013 at 3:36 PM, she roy <she.min.roy@gmail.com> wrote:
> Is there somebody can help me to trigger a gpio interrupt inside qemu? I
> wrote a simple function to trigger a interrupt in pl061.c as follow:
> PL061State *gPl061;
> void pl061_raise_irq()
> {
>     qemu_set_irq(gPl061->irq, 1);
> }

[...]

> But when i call pl061_raise_irq inside qemu once, the guest run into an
> infinite loop. it prints:
> ...
> irq:[927012]receive the irq at -12002...
> irq:[927013]receive the irq at -12002...
> irq:[927014]receive the irq at -12002...
> irq:[927015]receive the irq at -12002...
> irq:[927016]receive the irq at -12002...
> irq:[927017]receive the irq at -12002...
> irq:[927018]receive the irq at -12002...
> ...
> can somebody tell me what's wrong?

You have raised IRQ in your pl061_raise_irq(), but you haven't lowered it.

-- 
Thanks.
-- Max

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

* [Qemu-devel] Fwd:  trigger a gpio interrupt inside qemu
       [not found]       ` <CAMY-hrGm7QUMq0mf2_Y-YvgPa6302zrsCa8YWui3aJo2mFHsPQ@mail.gmail.com>
@ 2013-08-28  8:01         ` she roy
  2013-08-28  8:15           ` Max Filippov
  2013-08-28  8:19           ` Peter Maydell
  0 siblings, 2 replies; 11+ messages in thread
From: she roy @ 2013-08-28  8:01 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1850 bytes --]

---------- Forwarded message ----------
From: she roy <she.min.roy@gmail.com>
Date: 2013/8/28
Subject: Re: [Qemu-devel] trigger a gpio interrupt inside qemu
To: Max Filippov <jcmvbkbc@gmail.com>


I tested   qemu_irq_pulse(gPl061->irq); the guest did not generate an
interrupt. so I changed to

qemu_set_irq(gPl061->irq, 1);
sleep(1);
qemu_set_irq(gPl061->irq, 0);

A lot of interrupts generated. Is it possible to generate just one
interrupt?

Thanks.


2013/8/27 Max Filippov <jcmvbkbc@gmail.com>

> On Tue, Aug 27, 2013 at 3:55 PM, she roy <she.min.roy@gmail.com> wrote:
> > How to lower it? Thank you very much!
> >
>
> qemu_set_irq(gPl061->irq, 0);
>
> Or you could try
>
> void pl061_raise_irq()
> {
>    qemu_irq_pulse(gPl061->irq);
> }
>
> > 2013/8/27 Max Filippov <jcmvbkbc@gmail.com>
> >>
> >> On Tue, Aug 27, 2013 at 3:36 PM, she roy <she.min.roy@gmail.com> wrote:
> >> > Is there somebody can help me to trigger a gpio interrupt inside
> qemu? I
> >> > wrote a simple function to trigger a interrupt in pl061.c as follow:
> >> > PL061State *gPl061;
> >> > void pl061_raise_irq()
> >> > {
> >> >     qemu_set_irq(gPl061->irq, 1);
> >> > }
> >>
> >> [...]
> >>
> >> > But when i call pl061_raise_irq inside qemu once, the guest run into
> an
> >> > infinite loop. it prints:
> >> > ...
> >> > irq:[927012]receive the irq at -12002...
> >> > irq:[927013]receive the irq at -12002...
> >> > irq:[927014]receive the irq at -12002...
> >> > irq:[927015]receive the irq at -12002...
> >> > irq:[927016]receive the irq at -12002...
> >> > irq:[927017]receive the irq at -12002...
> >> > irq:[927018]receive the irq at -12002...
> >> > ...
> >> > can somebody tell me what's wrong?
> >>
> >> You have raised IRQ in your pl061_raise_irq(), but you haven't lowered
> it.
> >>
> >> --
> >> Thanks.
> >> -- Max
> >
> >
>
>
>
> --
> Thanks.
> -- Max
>

[-- Attachment #2: Type: text/html, Size: 3680 bytes --]

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

* Re: [Qemu-devel] Fwd: trigger a gpio interrupt inside qemu
  2013-08-28  8:01         ` [Qemu-devel] Fwd: " she roy
@ 2013-08-28  8:15           ` Max Filippov
  2013-08-28  8:19             ` she roy
  2013-08-28  8:19           ` Peter Maydell
  1 sibling, 1 reply; 11+ messages in thread
From: Max Filippov @ 2013-08-28  8:15 UTC (permalink / raw)
  To: she roy; +Cc: qemu-devel

On Wed, Aug 28, 2013 at 12:01 PM, she roy <she.min.roy@gmail.com> wrote:
> I tested   qemu_irq_pulse(gPl061->irq); the guest did not generate an
> interrupt. so I changed to
>
> qemu_set_irq(gPl061->irq, 1);
> sleep(1);
> qemu_set_irq(gPl061->irq, 0);
>
> A lot of interrupts generated. Is it possible to generate just one
> interrupt?

This looks like level-triggered interrupt behaviour. In such cases
interrupt handler
in the device driver is usually responsible for disabling IRQ line
while processing
interrupt. You can add a register to your device, writing to which would call

qemu_set_irq(gPl061->irq, 0)

and write to that register from your driver's ISR.
Or you can choose an edge-triggered IRQ to play with.

> 2013/8/27 Max Filippov <jcmvbkbc@gmail.com>
>>
>> On Tue, Aug 27, 2013 at 3:55 PM, she roy <she.min.roy@gmail.com> wrote:
>> > How to lower it? Thank you very much!
>> >
>>
>> qemu_set_irq(gPl061->irq, 0);
>>
>> Or you could try
>>
>> void pl061_raise_irq()
>> {
>>    qemu_irq_pulse(gPl061->irq);
>> }
>>
>> > 2013/8/27 Max Filippov <jcmvbkbc@gmail.com>
>> >>
>> >> On Tue, Aug 27, 2013 at 3:36 PM, she roy <she.min.roy@gmail.com> wrote:
>> >> > Is there somebody can help me to trigger a gpio interrupt inside
>> >> > qemu? I
>> >> > wrote a simple function to trigger a interrupt in pl061.c as follow:
>> >> > PL061State *gPl061;
>> >> > void pl061_raise_irq()
>> >> > {
>> >> >     qemu_set_irq(gPl061->irq, 1);
>> >> > }
>> >>
>> >> [...]
>> >>
>> >> > But when i call pl061_raise_irq inside qemu once, the guest run into
>> >> > an
>> >> > infinite loop. it prints:
>> >> > ...
>> >> > irq:[927012]receive the irq at -12002...
>> >> > irq:[927013]receive the irq at -12002...
>> >> > irq:[927014]receive the irq at -12002...
>> >> > irq:[927015]receive the irq at -12002...
>> >> > irq:[927016]receive the irq at -12002...
>> >> > irq:[927017]receive the irq at -12002...
>> >> > irq:[927018]receive the irq at -12002...
>> >> > ...
>> >> > can somebody tell me what's wrong?
>> >>
>> >> You have raised IRQ in your pl061_raise_irq(), but you haven't lowered
>> >> it.

-- 
Thanks.
-- Max

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

* Re: [Qemu-devel] Fwd: trigger a gpio interrupt inside qemu
  2013-08-28  8:15           ` Max Filippov
@ 2013-08-28  8:19             ` she roy
  2013-08-28  8:27               ` Max Filippov
  0 siblings, 1 reply; 11+ messages in thread
From: she roy @ 2013-08-28  8:19 UTC (permalink / raw)
  To: Max Filippov; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 2432 bytes --]

PL061 has a register GPIOIS to control if the interrupt is lever-triggered
or edge-triggered, I will try this. Thanks.


2013/8/28 Max Filippov <jcmvbkbc@gmail.com>

> On Wed, Aug 28, 2013 at 12:01 PM, she roy <she.min.roy@gmail.com> wrote:
> > I tested   qemu_irq_pulse(gPl061->irq); the guest did not generate an
> > interrupt. so I changed to
> >
> > qemu_set_irq(gPl061->irq, 1);
> > sleep(1);
> > qemu_set_irq(gPl061->irq, 0);
> >
> > A lot of interrupts generated. Is it possible to generate just one
> > interrupt?
>
> This looks like level-triggered interrupt behaviour. In such cases
> interrupt handler
> in the device driver is usually responsible for disabling IRQ line
> while processing
> interrupt. You can add a register to your device, writing to which would
> call
>
> qemu_set_irq(gPl061->irq, 0)
>
> and write to that register from your driver's ISR.
> Or you can choose an edge-triggered IRQ to play with.
>
> > 2013/8/27 Max Filippov <jcmvbkbc@gmail.com>
> >>
> >> On Tue, Aug 27, 2013 at 3:55 PM, she roy <she.min.roy@gmail.com> wrote:
> >> > How to lower it? Thank you very much!
> >> >
> >>
> >> qemu_set_irq(gPl061->irq, 0);
> >>
> >> Or you could try
> >>
> >> void pl061_raise_irq()
> >> {
> >>    qemu_irq_pulse(gPl061->irq);
> >> }
> >>
> >> > 2013/8/27 Max Filippov <jcmvbkbc@gmail.com>
> >> >>
> >> >> On Tue, Aug 27, 2013 at 3:36 PM, she roy <she.min.roy@gmail.com>
> wrote:
> >> >> > Is there somebody can help me to trigger a gpio interrupt inside
> >> >> > qemu? I
> >> >> > wrote a simple function to trigger a interrupt in pl061.c as
> follow:
> >> >> > PL061State *gPl061;
> >> >> > void pl061_raise_irq()
> >> >> > {
> >> >> >     qemu_set_irq(gPl061->irq, 1);
> >> >> > }
> >> >>
> >> >> [...]
> >> >>
> >> >> > But when i call pl061_raise_irq inside qemu once, the guest run
> into
> >> >> > an
> >> >> > infinite loop. it prints:
> >> >> > ...
> >> >> > irq:[927012]receive the irq at -12002...
> >> >> > irq:[927013]receive the irq at -12002...
> >> >> > irq:[927014]receive the irq at -12002...
> >> >> > irq:[927015]receive the irq at -12002...
> >> >> > irq:[927016]receive the irq at -12002...
> >> >> > irq:[927017]receive the irq at -12002...
> >> >> > irq:[927018]receive the irq at -12002...
> >> >> > ...
> >> >> > can somebody tell me what's wrong?
> >> >>
> >> >> You have raised IRQ in your pl061_raise_irq(), but you haven't
> lowered
> >> >> it.
>
> --
> Thanks.
> -- Max
>

[-- Attachment #2: Type: text/html, Size: 3820 bytes --]

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

* Re: [Qemu-devel] Fwd: trigger a gpio interrupt inside qemu
  2013-08-28  8:01         ` [Qemu-devel] Fwd: " she roy
  2013-08-28  8:15           ` Max Filippov
@ 2013-08-28  8:19           ` Peter Maydell
  2013-08-28  8:26             ` she roy
  1 sibling, 1 reply; 11+ messages in thread
From: Peter Maydell @ 2013-08-28  8:19 UTC (permalink / raw)
  To: she roy; +Cc: QEMU Developers

On 28 August 2013 09:01, she roy <she.min.roy@gmail.com> wrote:
> qemu_set_irq(gPl061->irq, 1);
> sleep(1);
> qemu_set_irq(gPl061->irq, 0);

Never call sleep() inside a qemu device implementation:
this will just make the whole of QEMU (including the guest)
stop running.

-- PMM

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

* Re: [Qemu-devel] Fwd: trigger a gpio interrupt inside qemu
  2013-08-28  8:19           ` Peter Maydell
@ 2013-08-28  8:26             ` she roy
  0 siblings, 0 replies; 11+ messages in thread
From: she roy @ 2013-08-28  8:26 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Developers

[-- Attachment #1: Type: text/plain, Size: 361 bytes --]

Thanks!


2013/8/28 Peter Maydell <peter.maydell@linaro.org>

> On 28 August 2013 09:01, she roy <she.min.roy@gmail.com> wrote:
> > qemu_set_irq(gPl061->irq, 1);
> > sleep(1);
> > qemu_set_irq(gPl061->irq, 0);
>
> Never call sleep() inside a qemu device implementation:
> this will just make the whole of QEMU (including the guest)
> stop running.
>
> -- PMM
>

[-- Attachment #2: Type: text/html, Size: 770 bytes --]

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

* Re: [Qemu-devel] Fwd: trigger a gpio interrupt inside qemu
  2013-08-28  8:19             ` she roy
@ 2013-08-28  8:27               ` Max Filippov
  2013-08-28  8:35                 ` Max Filippov
  2013-08-28  9:33                 ` she roy
  0 siblings, 2 replies; 11+ messages in thread
From: Max Filippov @ 2013-08-28  8:27 UTC (permalink / raw)
  To: she roy; +Cc: qemu-devel

On Wed, Aug 28, 2013 at 12:19 PM, she roy <she.min.roy@gmail.com> wrote:
> PL061 has a register GPIOIS to control if the interrupt is lever-triggered
> or edge-triggered, I will try this. Thanks.

This register defines which event on the GPIO side causes PL061 to
generate IRQ. The IRQ it generates is always signalled by level.
You need to update GPIOIC register from your driver's ISR to clear it.

>
> 2013/8/28 Max Filippov <jcmvbkbc@gmail.com>
>>
>> On Wed, Aug 28, 2013 at 12:01 PM, she roy <she.min.roy@gmail.com> wrote:
>> > I tested   qemu_irq_pulse(gPl061->irq); the guest did not generate an
>> > interrupt. so I changed to
>> >
>> > qemu_set_irq(gPl061->irq, 1);
>> > sleep(1);
>> > qemu_set_irq(gPl061->irq, 0);
>> >
>> > A lot of interrupts generated. Is it possible to generate just one
>> > interrupt?
>>
>> This looks like level-triggered interrupt behaviour. In such cases
>> interrupt handler
>> in the device driver is usually responsible for disabling IRQ line
>> while processing
>> interrupt. You can add a register to your device, writing to which would
>> call
>>
>> qemu_set_irq(gPl061->irq, 0)
>>
>> and write to that register from your driver's ISR.
>> Or you can choose an edge-triggered IRQ to play with.
>>
>> > 2013/8/27 Max Filippov <jcmvbkbc@gmail.com>
>> >>
>> >> On Tue, Aug 27, 2013 at 3:55 PM, she roy <she.min.roy@gmail.com> wrote:
>> >> > How to lower it? Thank you very much!
>> >> >
>> >>
>> >> qemu_set_irq(gPl061->irq, 0);
>> >>
>> >> Or you could try
>> >>
>> >> void pl061_raise_irq()
>> >> {
>> >>    qemu_irq_pulse(gPl061->irq);
>> >> }
>> >>
>> >> > 2013/8/27 Max Filippov <jcmvbkbc@gmail.com>
>> >> >>
>> >> >> On Tue, Aug 27, 2013 at 3:36 PM, she roy <she.min.roy@gmail.com>
>> >> >> wrote:
>> >> >> > Is there somebody can help me to trigger a gpio interrupt inside
>> >> >> > qemu? I
>> >> >> > wrote a simple function to trigger a interrupt in pl061.c as
>> >> >> > follow:
>> >> >> > PL061State *gPl061;
>> >> >> > void pl061_raise_irq()
>> >> >> > {
>> >> >> >     qemu_set_irq(gPl061->irq, 1);
>> >> >> > }
>> >> >>
>> >> >> [...]
>> >> >>
>> >> >> > But when i call pl061_raise_irq inside qemu once, the guest run
>> >> >> > into
>> >> >> > an
>> >> >> > infinite loop. it prints:
>> >> >> > ...
>> >> >> > irq:[927012]receive the irq at -12002...
>> >> >> > irq:[927013]receive the irq at -12002...
>> >> >> > irq:[927014]receive the irq at -12002...
>> >> >> > irq:[927015]receive the irq at -12002...
>> >> >> > irq:[927016]receive the irq at -12002...
>> >> >> > irq:[927017]receive the irq at -12002...
>> >> >> > irq:[927018]receive the irq at -12002...
>> >> >> > ...
>> >> >> > can somebody tell me what's wrong?
>> >> >>
>> >> >> You have raised IRQ in your pl061_raise_irq(), but you haven't
>> >> >> lowered
>> >> >> it.
>>
>> --
>> Thanks.
>> -- Max
>
>



-- 
Thanks.
-- Max

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

* Re: [Qemu-devel] Fwd: trigger a gpio interrupt inside qemu
  2013-08-28  8:27               ` Max Filippov
@ 2013-08-28  8:35                 ` Max Filippov
  2013-08-28  9:33                 ` she roy
  1 sibling, 0 replies; 11+ messages in thread
From: Max Filippov @ 2013-08-28  8:35 UTC (permalink / raw)
  To: she roy; +Cc: qemu-devel

On Wed, Aug 28, 2013 at 12:27 PM, Max Filippov <jcmvbkbc@gmail.com> wrote:
> On Wed, Aug 28, 2013 at 12:19 PM, she roy <she.min.roy@gmail.com> wrote:
>> PL061 has a register GPIOIS to control if the interrupt is lever-triggered
>> or edge-triggered, I will try this. Thanks.
>
> This register defines which event on the GPIO side causes PL061 to
> generate IRQ. The IRQ it generates is always signalled by level.
> You need to update GPIOIC register from your driver's ISR to clear it.

...and that probably won't work in your case because you've changed
PL061 IRQ line state without updating internal PL061 state, so it doesn't
know that it requests interrupt and will probably refuse to clear it.

>> 2013/8/28 Max Filippov <jcmvbkbc@gmail.com>
>>>
>>> On Wed, Aug 28, 2013 at 12:01 PM, she roy <she.min.roy@gmail.com> wrote:
>>> > I tested   qemu_irq_pulse(gPl061->irq); the guest did not generate an
>>> > interrupt. so I changed to
>>> >
>>> > qemu_set_irq(gPl061->irq, 1);
>>> > sleep(1);
>>> > qemu_set_irq(gPl061->irq, 0);
>>> >
>>> > A lot of interrupts generated. Is it possible to generate just one
>>> > interrupt?
>>>
>>> This looks like level-triggered interrupt behaviour. In such cases
>>> interrupt handler
>>> in the device driver is usually responsible for disabling IRQ line
>>> while processing
>>> interrupt. You can add a register to your device, writing to which would
>>> call
>>>
>>> qemu_set_irq(gPl061->irq, 0)
>>>
>>> and write to that register from your driver's ISR.
>>> Or you can choose an edge-triggered IRQ to play with.
>>>
>>> > 2013/8/27 Max Filippov <jcmvbkbc@gmail.com>
>>> >>
>>> >> On Tue, Aug 27, 2013 at 3:55 PM, she roy <she.min.roy@gmail.com> wrote:
>>> >> > How to lower it? Thank you very much!
>>> >> >
>>> >>
>>> >> qemu_set_irq(gPl061->irq, 0);
>>> >>
>>> >> Or you could try
>>> >>
>>> >> void pl061_raise_irq()
>>> >> {
>>> >>    qemu_irq_pulse(gPl061->irq);
>>> >> }
>>> >>
>>> >> > 2013/8/27 Max Filippov <jcmvbkbc@gmail.com>
>>> >> >>
>>> >> >> On Tue, Aug 27, 2013 at 3:36 PM, she roy <she.min.roy@gmail.com>
>>> >> >> wrote:
>>> >> >> > Is there somebody can help me to trigger a gpio interrupt inside
>>> >> >> > qemu? I
>>> >> >> > wrote a simple function to trigger a interrupt in pl061.c as
>>> >> >> > follow:
>>> >> >> > PL061State *gPl061;
>>> >> >> > void pl061_raise_irq()
>>> >> >> > {
>>> >> >> >     qemu_set_irq(gPl061->irq, 1);
>>> >> >> > }
>>> >> >>
>>> >> >> [...]
>>> >> >>
>>> >> >> > But when i call pl061_raise_irq inside qemu once, the guest run
>>> >> >> > into
>>> >> >> > an
>>> >> >> > infinite loop. it prints:
>>> >> >> > ...
>>> >> >> > irq:[927012]receive the irq at -12002...
>>> >> >> > irq:[927013]receive the irq at -12002...
>>> >> >> > irq:[927014]receive the irq at -12002...
>>> >> >> > irq:[927015]receive the irq at -12002...
>>> >> >> > irq:[927016]receive the irq at -12002...
>>> >> >> > irq:[927017]receive the irq at -12002...
>>> >> >> > irq:[927018]receive the irq at -12002...
>>> >> >> > ...
>>> >> >> > can somebody tell me what's wrong?
>>> >> >>
>>> >> >> You have raised IRQ in your pl061_raise_irq(), but you haven't
>>> >> >> lowered
>>> >> >> it.
>>>
>>> --
>>> Thanks.
>>> -- Max
>>
>>
>
>
>
> --
> Thanks.
> -- Max



-- 
Thanks.
-- Max

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

* Re: [Qemu-devel] Fwd: trigger a gpio interrupt inside qemu
  2013-08-28  8:27               ` Max Filippov
  2013-08-28  8:35                 ` Max Filippov
@ 2013-08-28  9:33                 ` she roy
  2013-08-28 11:00                   ` Peter Maydell
  1 sibling, 1 reply; 11+ messages in thread
From: she roy @ 2013-08-28  9:33 UTC (permalink / raw)
  To: Max Filippov; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 3381 bytes --]

I tried to set   GPIOIC in the ISR, but the result was the same, a lot of
interrupts generated. I guess it is because I call
>> > qemu_set_irq(gPl061->irq, 1);
>> > sleep(1);
>> > qemu_set_irq(gPl061->irq, 0);
in a thread I created. And I don't know how to call these functions in a
qemu thread.


2013/8/28 Max Filippov <jcmvbkbc@gmail.com>

> On Wed, Aug 28, 2013 at 12:19 PM, she roy <she.min.roy@gmail.com> wrote:
> > PL061 has a register GPIOIS to control if the interrupt is
> lever-triggered
> > or edge-triggered, I will try this. Thanks.
>
> This register defines which event on the GPIO side causes PL061 to
> generate IRQ. The IRQ it generates is always signalled by level.
> You need to update GPIOIC register from your driver's ISR to clear it.
>
> >
> > 2013/8/28 Max Filippov <jcmvbkbc@gmail.com>
> >>
> >> On Wed, Aug 28, 2013 at 12:01 PM, she roy <she.min.roy@gmail.com>
> wrote:
> >> > I tested   qemu_irq_pulse(gPl061->irq); the guest did not generate an
> >> > interrupt. so I changed to
> >> >
> >> > qemu_set_irq(gPl061->irq, 1);
> >> > sleep(1);
> >> > qemu_set_irq(gPl061->irq, 0);
> >> >
> >> > A lot of interrupts generated. Is it possible to generate just one
> >> > interrupt?
> >>
> >> This looks like level-triggered interrupt behaviour. In such cases
> >> interrupt handler
> >> in the device driver is usually responsible for disabling IRQ line
> >> while processing
> >> interrupt. You can add a register to your device, writing to which would
> >> call
> >>
> >> qemu_set_irq(gPl061->irq, 0)
> >>
> >> and write to that register from your driver's ISR.
> >> Or you can choose an edge-triggered IRQ to play with.
> >>
> >> > 2013/8/27 Max Filippov <jcmvbkbc@gmail.com>
> >> >>
> >> >> On Tue, Aug 27, 2013 at 3:55 PM, she roy <she.min.roy@gmail.com>
> wrote:
> >> >> > How to lower it? Thank you very much!
> >> >> >
> >> >>
> >> >> qemu_set_irq(gPl061->irq, 0);
> >> >>
> >> >> Or you could try
> >> >>
> >> >> void pl061_raise_irq()
> >> >> {
> >> >>    qemu_irq_pulse(gPl061->irq);
> >> >> }
> >> >>
> >> >> > 2013/8/27 Max Filippov <jcmvbkbc@gmail.com>
> >> >> >>
> >> >> >> On Tue, Aug 27, 2013 at 3:36 PM, she roy <she.min.roy@gmail.com>
> >> >> >> wrote:
> >> >> >> > Is there somebody can help me to trigger a gpio interrupt inside
> >> >> >> > qemu? I
> >> >> >> > wrote a simple function to trigger a interrupt in pl061.c as
> >> >> >> > follow:
> >> >> >> > PL061State *gPl061;
> >> >> >> > void pl061_raise_irq()
> >> >> >> > {
> >> >> >> >     qemu_set_irq(gPl061->irq, 1);
> >> >> >> > }
> >> >> >>
> >> >> >> [...]
> >> >> >>
> >> >> >> > But when i call pl061_raise_irq inside qemu once, the guest run
> >> >> >> > into
> >> >> >> > an
> >> >> >> > infinite loop. it prints:
> >> >> >> > ...
> >> >> >> > irq:[927012]receive the irq at -12002...
> >> >> >> > irq:[927013]receive the irq at -12002...
> >> >> >> > irq:[927014]receive the irq at -12002...
> >> >> >> > irq:[927015]receive the irq at -12002...
> >> >> >> > irq:[927016]receive the irq at -12002...
> >> >> >> > irq:[927017]receive the irq at -12002...
> >> >> >> > irq:[927018]receive the irq at -12002...
> >> >> >> > ...
> >> >> >> > can somebody tell me what's wrong?
> >> >> >>
> >> >> >> You have raised IRQ in your pl061_raise_irq(), but you haven't
> >> >> >> lowered
> >> >> >> it.
> >>
> >> --
> >> Thanks.
> >> -- Max
> >
> >
>
>
>
> --
> Thanks.
> -- Max
>

[-- Attachment #2: Type: text/html, Size: 6139 bytes --]

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

* Re: [Qemu-devel] Fwd: trigger a gpio interrupt inside qemu
  2013-08-28  9:33                 ` she roy
@ 2013-08-28 11:00                   ` Peter Maydell
  0 siblings, 0 replies; 11+ messages in thread
From: Peter Maydell @ 2013-08-28 11:00 UTC (permalink / raw)
  To: she roy; +Cc: Max Filippov, qemu-devel

On 28 August 2013 10:33, she roy <she.min.roy@gmail.com> wrote:
> I tried to set   GPIOIC in the ISR, but the result was the same, a lot of
> interrupts generated. I guess it is because I call
>>> > qemu_set_irq(gPl061->irq, 1);
>>> > sleep(1);
>>> > qemu_set_irq(gPl061->irq, 0);
> in a thread I created. And I don't know how to call these functions in a
> qemu thread.

Don't try to create extra threads either -- QEMU uses threads for
a fairly limited set of purposes and calling functions from random
new threads you've created is probably just going to go badly wrong.

If you really need an IRQ line which goes high and then low after
a while you need to set up a QEMU timer and lower the IRQ in
the timer callback. This is pretty weird behaviour unless you're
really modelling a timer device, though.

-- PMM

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

end of thread, other threads:[~2013-08-28 11:00 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-27 11:36 [Qemu-devel] trigger a gpio interrupt inside qemu she roy
2013-08-27 11:52 ` Max Filippov
     [not found]   ` <CAMY-hrGSwRw1oq58Pz66sfmDb4SA-bZfBSiU6kmfkj6FBPK97A@mail.gmail.com>
     [not found]     ` <CAMo8BfLxbM09rGoz3i=MqxM=+12B4aJLUMXZEOiJ-0yu8WaqWA@mail.gmail.com>
     [not found]       ` <CAMY-hrGm7QUMq0mf2_Y-YvgPa6302zrsCa8YWui3aJo2mFHsPQ@mail.gmail.com>
2013-08-28  8:01         ` [Qemu-devel] Fwd: " she roy
2013-08-28  8:15           ` Max Filippov
2013-08-28  8:19             ` she roy
2013-08-28  8:27               ` Max Filippov
2013-08-28  8:35                 ` Max Filippov
2013-08-28  9:33                 ` she roy
2013-08-28 11:00                   ` Peter Maydell
2013-08-28  8:19           ` Peter Maydell
2013-08-28  8:26             ` she roy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).