Skip to contentSkip to conversation

System hangs in/after rtdm_lock_put_irqrestore

Xenomai-help Axel Beierlein 2 participants 5 messages Aug 29, 2007 – Aug 30, 2007 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

what could it be that an simple rt_dev_open locks up my system when it calls rtdm_lock_put_irqrestore?

[...]
if (rtdm_irq_request(&ctx->irq_handle,

		        MPC5xxx_PSC2_IRQ,
			rt_psc_interrupt,
			RTDM_IRQTYPE_SHARED | RTDM_IRQTYPE_EDGE,
				context->device->proc_name,
				ctx))
	{
		printk ("psc5200B.c: request_irq() failed\n");
		return -1;
	}

    rtdm_irq_enable(&ctx->irq_handle);

    rtdm_lock_get_irqsave(&ctx->lock, lock_ctx);

    ctx->imr_status = MPC5xxx_PSC_IMR_RXRDY;
	out_be16(&psc->mpc5xxx_psc_imr, ctx->imr_status);

	rtdm_lock_put_irqrestore(&ctx->lock, lock_ctx);
	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	Here i get the crash

The test prog is a simple fd=rt_dev_open("nameofdevice",0)......rt_dev_close(fd).

Axel

#1 lore raw
Quoted 5 lines · Axel Beierlein

what could it be that an simple rt_dev_open locks up my system when it calls rtdm_lock_put_irqrestore?

[...]
if (rtdm_irq_request(&ctx->irq_handle,

Quoted 16 lines
		        MPC5xxx_PSC2_IRQ,
			rt_psc_interrupt,
			RTDM_IRQTYPE_SHARED | RTDM_IRQTYPE_EDGE,
				context->device->proc_name,
				ctx))
	{
		printk ("psc5200B.c: request_irq() failed\n");
		return -1;
	}

     rtdm_irq_enable(&ctx->irq_handle);

     rtdm_lock_get_irqsave(&ctx->lock, lock_ctx);

     ctx->imr_status = MPC5xxx_PSC_IMR_RXRDY;
	out_be16(&psc->mpc5xxx_psc_imr, ctx->imr_status);

Let me guess: this line arms the related IRQ source at hw level, no?

Quoted 4 lines
	rtdm_lock_put_irqrestore(&ctx->lock, lock_ctx);
	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	Here i get the crash

Because it enabled local IRQ delivery again, and the system ends up in an IRQ storm, or some endless loop in the IRQ handler, or some crash related to IRQ handling. Still just guessing...

Jan

#3 lore raw
In reply to a message not in the archive
Quoted 41 lines · Axel Beierlein

Am 29.08.2007, 16:42 Uhr, schrieb Jan Kiszka <[email protected]>:

Quoted 16 lines
Quoted 15 lines · Axel Beierlein

what could it be that an simple rt_dev_open locks up my system when it calls rtdm_lock_put_irqrestore?

[...]
if (rtdm_irq_request(&ctx->irq_handle,

                MPC5xxx_PSC2_IRQ,
            rt_psc_interrupt,
            RTDM_IRQTYPE_SHARED | RTDM_IRQTYPE_EDGE,
                context->device->proc_name,
                ctx))
    {
        printk ("psc5200B.c: request_irq() failed\n");
        return -1;
    }
Quoted 9 lines
Quoted 6 lines
     rtdm_irq_enable(&ctx->irq_handle);

     rtdm_lock_get_irqsave(&ctx->lock, lock_ctx);

     ctx->imr_status = MPC5xxx_PSC_IMR_RXRDY;
    out_be16(&psc->mpc5xxx_psc_imr, ctx->imr_status);

Let me guess: this line arms the related IRQ source at hw level, no?

Yes you are right. This Bit enables the RX_Ready IRQ at hw level. Sorry for the little Code fragment but the code relates to your 16550A.c and i don´t want to post all the routines at the moment.

Quoted 9 lines
Quoted 4 lines
    rtdm_lock_put_irqrestore(&ctx->lock, lock_ctx);
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    Here i get the crash

Because it enabled local IRQ delivery again, and the system ends up in an IRQ storm, or some endless loop in the IRQ handler, or some crash related to IRQ handling. Still just guessing...

Quoted 6 lines
Quoted 2 lines

Jan

But how your UART driver handle this Problem? I have check the Irq Handler an implement an printk in it to see where it hangs, but it doesn´t step into this handler.

In case you have an IRQ storm or your handler runs in an endless loop, you won't be able to read that printk even if it's executed - Linux will have no chance to dump the message.

Start debugging with shrinking the handler down to a plain "return RTDM_IRQ_HANDLED" (or even RTDM_IRQ_NONE so that Xenomai disables the line), then slowly re-enabling and reviewing your code.

Jan

PS: reply-to-all

#4 lore raw

Am 30.08.2007, 08:55 Uhr, schrieb Jan Kiszka <[email protected]>:

Quoted 49 lines
Quoted 41 lines · Axel Beierlein

Am 29.08.2007, 16:42 Uhr, schrieb Jan Kiszka <[email protected]>:

Quoted 16 lines
Quoted 15 lines · Axel Beierlein

what could it be that an simple rt_dev_open locks up my system when it calls rtdm_lock_put_irqrestore?

[...]
if (rtdm_irq_request(&ctx->irq_handle,

                MPC5xxx_PSC2_IRQ,
            rt_psc_interrupt,
            RTDM_IRQTYPE_SHARED | RTDM_IRQTYPE_EDGE,
                context->device->proc_name,
                ctx))
    {
        printk ("psc5200B.c: request_irq() failed\n");
        return -1;
    }
Quoted 9 lines
Quoted 6 lines
     rtdm_irq_enable(&ctx->irq_handle);

     rtdm_lock_get_irqsave(&ctx->lock, lock_ctx);

     ctx->imr_status = MPC5xxx_PSC_IMR_RXRDY;
    out_be16(&psc->mpc5xxx_psc_imr, ctx->imr_status);

Let me guess: this line arms the related IRQ source at hw level, no?

Yes you are right. This Bit enables the RX_Ready IRQ at hw level. Sorry for the little Code fragment but the code relates to your 16550A.c and i don´t want to post all the routines at the moment.

Quoted 9 lines
Quoted 4 lines
    rtdm_lock_put_irqrestore(&ctx->lock, lock_ctx);
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    Here i get the crash

Because it enabled local IRQ delivery again, and the system ends up in an IRQ storm, or some endless loop in the IRQ handler, or some crash related to IRQ handling. Still just guessing...

Quoted 6 lines
Quoted 2 lines

Jan

But how your UART driver handle this Problem? I have check the Irq Handler an implement an printk in it to see where it hangs, but it doesn´t step into this handler.

Quoted 7 lines

In case you have an IRQ storm or your handler runs in an endless loop, you won't be able to read that printk even if it's executed - Linux will have no chance to dump the message.

Start debugging with shrinking the handler down to a plain "return RTDM_IRQ_HANDLED" (or even RTDM_IRQ_NONE so that Xenomai disables the line), then slowly re-enabling and reviewing your code.

That has no effect. It doesn´t step into it.
I think there is another Problem, cause when i go back to the userspace applikation after i have opened the device the system locks up when i call a funktion like getchar() Just in following dev_open and dev_close is workin for only one time. But when i call the same applikation a second time it locks up in the rt_open routine at rtdm_lock_put_irqrestore.

Quoted 4 lines

Jan

PS: reply-to-all

Ups, wrong button. Now i know why my message doesn´t appear in the mailing list ;-)

Axel

#5 lore raw
Quoted 59 lines · Axel Beierlein

Am 30.08.2007, 08:55 Uhr, schrieb Jan Kiszka <[email protected]>:

Quoted 49 lines
Quoted 41 lines · Axel Beierlein

Am 29.08.2007, 16:42 Uhr, schrieb Jan Kiszka <[email protected]>:

Quoted 16 lines
Quoted 15 lines · Axel Beierlein

what could it be that an simple rt_dev_open locks up my system when it calls rtdm_lock_put_irqrestore?

[...]
if (rtdm_irq_request(&ctx->irq_handle,

                MPC5xxx_PSC2_IRQ,
            rt_psc_interrupt,
            RTDM_IRQTYPE_SHARED | RTDM_IRQTYPE_EDGE,
                context->device->proc_name,
                ctx))
    {
        printk ("psc5200B.c: request_irq() failed\n");
        return -1;
    }
Quoted 9 lines
Quoted 6 lines
     rtdm_irq_enable(&ctx->irq_handle);

     rtdm_lock_get_irqsave(&ctx->lock, lock_ctx);

     ctx->imr_status = MPC5xxx_PSC_IMR_RXRDY;
    out_be16(&psc->mpc5xxx_psc_imr, ctx->imr_status);

Let me guess: this line arms the related IRQ source at hw level, no?

Yes you are right. This Bit enables the RX_Ready IRQ at hw level. Sorry for the little Code fragment but the code relates to your 16550A.c and i don´t want to post all the routines at the moment.

Quoted 9 lines
Quoted 4 lines
    rtdm_lock_put_irqrestore(&ctx->lock, lock_ctx);
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    Here i get the crash

Because it enabled local IRQ delivery again, and the system ends up in an IRQ storm, or some endless loop in the IRQ handler, or some crash related to IRQ handling. Still just guessing...

Quoted 6 lines
Quoted 2 lines

Jan

But how your UART driver handle this Problem? I have check the Irq Handler an implement an printk in it to see where it hangs, but it doesn´t step into this handler.

Quoted 7 lines

In case you have an IRQ storm or your handler runs in an endless loop, you won't be able to read that printk even if it's executed - Linux will have no chance to dump the message.

Start debugging with shrinking the handler down to a plain "return RTDM_IRQ_HANDLED" (or even RTDM_IRQ_NONE so that Xenomai disables the line), then slowly re-enabling and reviewing your code.

Quoted 7 lines

That has no effect. It doesn´t step into it.
I think there is another Problem, cause when i go back to the userspace applikation after i have opened the device the system locks up when i call a funktion like getchar()
Just in following dev_open and dev_close is workin for only one time. But when i call the same applikation a second time it locks up in the rt_open routine at rtdm_lock_put_irqrestore.

Something must be very wrong. Do you register the correct IRQ line / modify the right hw registers? Also, don't you have some hardware debugger at hand to find out where the system goes to, what IRQs show up?

Jan