Skip to contentSkip to conversation

How kernel handle interrupts

DISCUSSION Woody Wu 3 participants 15 messages Dec 20, 2012 – Aug 5, 2013

lore
Share & tools
lore

Woody Wu

author
#0 lore raw

Hi, List

Where is the Kernel code that handles external interrupts? I want to have a look at it but haven't found out where it is.

Actually, I have some basic questions about interrupt handling in Linux.
1. After Kernel's ISR received an interrupt, I believe it will invoke a handler defined in a device driver if any. But it should be the device driver's responsibility or kernel ISR's responsibility to clear (or acknowledge) the interrupt?

2. My device, an AX88796B network controller, asserting the interrupt line in a level-triggered manner. Now I met problem with the device that might caused by the CPU interrupt mode is not set as level-triggered by edge trigger. My CPU is Samsung S3C2410, an ARM920T powered one. Does anyone know usually where and how should I do this kind of setting?

Thanks in advance.

Signature · 2 lines
woody
I can't go back to yesterday - because I was a different person then.
#1 lore raw
Quoted 11 lines · Woody Wu

Hi, List

Where is the Kernel code that handles external interrupts? I want to have a look at it but haven't found out where it is.

Actually, I have some basic questions about interrupt handling in Linux.
1. After Kernel's ISR received an interrupt, I believe it will invoke a handler defined in a device driver if any. But it should be the device driver's responsibility or kernel ISR's responsibility to clear (or acknowledge) the interrupt?

If the interrupt in question is currently being handled then in the case of edge triggered interrupt we just mask the interrupt,set it pending and bail out.Once the interrupt handler completes then we check for pending interrupt and handle it.In level triggered we don't do that. Kerenel ISR -this is mixture of core kernel interrupt handling code + your device driver interrupt handler(if this is chip driver which is supposed to get one interrupt and is reponsible for calling other interrupt handlers based on the chip register status then you do explicit masking unmasking yourself).
If you device driver is a interrupt controller driver then you register your driver with kernel interrupt handling code and need to write some callbacks such as .mask,.unmask and so on.This callbacks are called at appropiate places whenever the interrupt is raised.This interrupt is then passed to drivers who has requested for this interrupt by calling request_irq.

Quoted 3 lines

2. My device, an AX88796B network controller, asserting the interrupt line in a level-triggered manner. Now I met problem with the device

that

Quoted 3 lines

might caused by the CPU interrupt mode is not set as level-triggered by edge trigger. My CPU is Samsung S3C2410, an ARM920T powered one. Does anyone know usually where and how should I do this kind of setting?

Just pass the parameter "level triggered" in request_irq in your device driver.

Quoted 4 lines

Thanks in advance.

Quoted 8 lines

--
woody
I can't go back to yesterday - because I was a different person then.

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20121220/726cd73b/attachment.html

#13 lore raw
In reply to Woody Wu

Hi Woody,

Check "do_IRQ()" in arch/x86/kernel/irq.c. It is responsible to handle device specific interrupts, while ipi and timer interrupts are dealt elsewhere.

Hope this helps.

BR,
Shahbaz Khan

Quoted 29 lines · Woody Wu

Hi, List

Where is the Kernel code that handles external interrupts? I want to have a look at it but haven't found out where it is.

Actually, I have some basic questions about interrupt handling in Linux.
1. After Kernel's ISR received an interrupt, I believe it will invoke a handler defined in a device driver if any. But it should be the device driver's responsibility or kernel ISR's responsibility to clear (or acknowledge) the interrupt?

2. My device, an AX88796B network controller, asserting the interrupt line in a level-triggered manner. Now I met problem with the device that might caused by the CPU interrupt mode is not set as level-triggered by edge trigger. My CPU is Samsung S3C2410, an ARM920T powered one. Does anyone know usually where and how should I do this kind of setting?

Thanks in advance.

--
woody
I can't go back to yesterday - because I was a different person then.

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Signature · 4 lines
Shahbaz Khan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20121220/bbc8a3f0/attachment.html 
author
#14 lore raw
Quoted 6 lines · Shahbaz khan

Hi Woody,

Check "do_IRQ()" in arch/x86/kernel/irq.c. It is responsible to handle device specific interrupts, while ipi and timer interrupts are dealt elsewhere.

Thanks. Maybe you also know what's the name of the same function for ARM, which is actual arch I am working on.

Quoted 41 lines

Hope this helps.

BR,
Shahbaz Khan

Quoted 29 lines · Woody Wu

Hi, List

Where is the Kernel code that handles external interrupts? I want to have a look at it but haven't found out where it is.

Actually, I have some basic questions about interrupt handling in Linux.
1. After Kernel's ISR received an interrupt, I believe it will invoke a handler defined in a device driver if any. But it should be the device driver's responsibility or kernel ISR's responsibility to clear (or acknowledge) the interrupt?

2. My device, an AX88796B network controller, asserting the interrupt line in a level-triggered manner. Now I met problem with the device that might caused by the CPU interrupt mode is not set as level-triggered by edge trigger. My CPU is Samsung S3C2410, an ARM920T powered one. Does anyone know usually where and how should I do this kind of setting?

Thanks in advance.

--
woody
I can't go back to yesterday - because I was a different person then.

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Signature · 1 line
Shahbaz Khan
Signature · 2 lines
woody
I can't go back to yesterday - because I was a different person then.
author
#2 lore raw
In reply to anish singh

? 2012-12-21 AM2:05?"anish singh" <[email protected]>???

Quoted 9 lines · Woody Wu
Quoted 6 lines

Hi, List

Where is the Kernel code that handles external interrupts? I want to have a look at it but haven't found out where it is.

Quoted 7 lines
Quoted 5 lines

Actually, I have some basic questions about interrupt handling in Linux.
1. After Kernel's ISR received an interrupt, I believe it will invoke a handler defined in a device driver if any. But it should be the device driver's responsibility or kernel ISR's responsibility to clear (or acknowledge) the interrupt?

If the interrupt in question is currently being handled then in the case of edge triggered interrupt we just mask the interrupt,set it

pending and bail out.Once the interrupt handler completes then we check for pending interrupt and handle it.In level triggered we don't do that.

Quoted 1 line

Kerenel ISR -this is mixture of core kernel interrupt handling code +

your device driver interrupt handler(if this is chip driver which is supposed to get one interrupt and is reponsible for calling other interrupt handlers based on the chip register status then you do explicit masking unmasking yourself).

Quoted 1 line

If you device driver is a interrupt controller driver then you register

your driver with kernel interrupt handling code and need to write some callbacks such as .mask,.unmask and so on.This callbacks are called at appropiate places whenever the interrupt is raised.This interrupt is then passed to drivers who has requested for this interrupt by calling request_irq.

Sorry not fully understand . My device is an Ethernet controller. It needs to response TX and RX interrupts triggered by the device itself. In this case , my driver is a chip driver or interrupt controller driver in your terms?

If my driver needs to do the mask and unmask job, what's the kernel API I should call?

And , I don't understand why there exists differences between level and edge triggered interrupts in terms of kernel handling.

I know my questions might be basic , so would please tell me what's the kernel code for ARM architecture doing these complex jobs as you explained?

Thanks in advance !

Quoted 4 lines
Quoted 4 lines

2. My device, an AX88796B network controller, asserting the interrupt line in a level-triggered manner. Now I met problem with the device

that

Quoted 1 line
Quoted 1 line

might caused by the CPU interrupt mode is not set as level-triggered

by

Quoted 1 line
Quoted 1 line

edge trigger. My CPU is Samsung S3C2410, an ARM920T powered one.

Does

Quoted 2 lines
Quoted 1 line

anyone know usually where and how should I do this kind of setting?

Just pass the parameter "level triggered" in request_irq in your device

driver.

Quoted 5 lines
Quoted 5 lines

Thanks in advance.

Quoted 8 lines
Quoted 8 lines

--
woody
I can't go back to yesterday - because I was a different person then.

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20121221/9c0e469a/attachment.html

#3 lore raw
Quoted 38 lines · Woody Wu

? 2012-12-21 AM2:05?"anish singh" <[email protected]>? ??

Quoted 7 lines · Woody Wu
Quoted 4 lines

Hi, List

Where is the Kernel code that handles external interrupts? I want

to

Quoted 3 lines
Quoted 3 lines

have a look at it but haven't found out where it is.

Actually, I have some basic questions about interrupt handling in

Linux.

Quoted 1 line
Quoted 1 line

1. After Kernel's ISR received an interrupt, I believe it will

invoke a

Quoted 2 lines
Quoted 2 lines

handler defined in a device driver if any. But it should be the device driver's responsibility or kernel ISR's responsibility

to

Quoted 3 lines
Quoted 1 line

clear (or acknowledge) the interrupt?

If the interrupt in question is currently being handled then in the case of edge triggered interrupt we just mask the interrupt,set

it pending and bail out.Once the interrupt handler completes then we check for pending interrupt and handle it.In level triggered we don't do that.

Quoted 1 line

Kerenel ISR -this is mixture of core kernel interrupt handling code

+ your device driver interrupt handler(if this is chip driver which is supposed to get one interrupt and is reponsible for calling other interrupt handlers based on the chip register status then you do explicit masking unmasking yourself).

Quoted 1 line

If you device driver is a interrupt controller driver then you

register your driver with kernel interrupt handling code and need to write some callbacks such as .mask,.unmask and so on.This callbacks are called at appropiate places whenever the interrupt is raised.This interrupt is then passed to drivers who has requested for this interrupt by calling request_irq.

Quoted 4 lines

Sorry not fully understand . My device is an interrupt line is back to inactive.Ethernet controller. It needs to response TX and RX interrupts triggered by the device itself. In this case , my driver is a chip driver or interrupt controller driver in your terms?

Your device is neither of these.

Quoted 3 lines

If my driver needs to do the mask and unmask job, what's the kernel API I should call?

You don't need to worry about mask and unmask job AFAIK.

Quoted 3 lines

And , I don't understand why there exists differences between level and edge triggered interrupts in terms of kernel handling.

Level type interrupts are active as long as the hardware line has the active level. This may require to mask the interrupt and unmask it after the associated handler has acknowledged the device, so the interrupt line is back to inactive.
Edge interrupt occurs on the falling and/or rising edge of a hardware signal.The occurrence is latched into the irq controller hardware and must be acked in order to be re-enabled.
Read the code /kerel/irq/chip.c(handle_edge_irq & handle_level_irq)

Quoted 2 lines

I know my questions might be basic , so would please tell me what's

If it was not basic then this question wouldn't be in kernelnewbies right :)?

Quoted 2 lines

the kernel code for ARM architecture doing these complex jobs as you
explained?

You don't need to worry about it but if you want to know further then I suggest tracing the call flow from asm interrupt handler(I believe do_irq but not sure) in arm to handle_edge_irq call flow by adding some logs or just browsing the code.

Quoted 33 lines

Thanks in advance !

Quoted 3 lines
Quoted 3 lines

2. My device, an AX88796B network controller, asserting the

interrupt

Quoted 1 line
Quoted 1 line

line in a level-triggered manner. Now I met problem with the

device that

Quoted 1 line
Quoted 1 line

might caused by the CPU interrupt mode is not set as

level-triggered by

Quoted 1 line
Quoted 1 line

edge trigger. My CPU is Samsung S3C2410, an ARM920T powered

one. Does

Quoted 1 line
Quoted 1 line

anyone know usually where and how should I do this kind of

setting?

Quoted 1 line

Just pass the parameter "level triggered" in request_irq in your

device driver.

Quoted 8 lines
Quoted 8 lines

Thanks in advance.

--
woody
I can't go back to yesterday - because I was a different person

then.

Quoted 5 lines
Quoted 5 lines

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

author
#4 lore raw

? 2012-12-21 PM6:53?"anish kumar" <[email protected]>???

Quoted 48 lines · Woody Wu
Quoted 38 lines

? 2012-12-21 AM2:05?"anish singh" <[email protected]>? ??

Quoted 7 lines · Woody Wu
Quoted 4 lines

Hi, List

Where is the Kernel code that handles external interrupts? I want

to

Quoted 3 lines
Quoted 3 lines

have a look at it but haven't found out where it is.

Actually, I have some basic questions about interrupt handling in

Linux.

Quoted 1 line
Quoted 1 line

1. After Kernel's ISR received an interrupt, I believe it will

invoke a

Quoted 2 lines
Quoted 2 lines

handler defined in a device driver if any. But it should be the device driver's responsibility or kernel ISR's responsibility

to

Quoted 3 lines
Quoted 1 line

clear (or acknowledge) the interrupt?

If the interrupt in question is currently being handled then in the case of edge triggered interrupt we just mask the interrupt,set

it pending and bail out.Once the interrupt handler completes then we check for pending interrupt and handle it.In level triggered we don't do that.

Quoted 1 line

Kerenel ISR -this is mixture of core kernel interrupt handling code

+ your device driver interrupt handler(if this is chip driver which is supposed to get one interrupt and is reponsible for calling other interrupt handlers based on the chip register status then you do explicit masking unmasking yourself).

Quoted 1 line

If you device driver is a interrupt controller driver then you

register your driver with kernel interrupt handling code and need to write some callbacks such as .mask,.unmask and so on.This callbacks are called at appropiate places whenever the interrupt is raised.This interrupt is then passed to drivers who has requested for this interrupt by calling request_irq.

Quoted 4 lines

Sorry not fully understand . My device is an interrupt line is back to inactive.Ethernet controller. It needs to response TX and RX interrupts triggered by the device itself. In this case , my driver is a chip driver or interrupt controller driver in your terms?

Your device is neither of these.

Quoted 3 lines

If my driver needs to do the mask and unmask job, what's the kernel API I should call?

Quoted 8 lines

You don't need to worry about mask and unmask job AFAIK.

Quoted 3 lines

And , I don't understand why there exists differences between level and edge triggered interrupts in terms of kernel handling.

Level type interrupts are active as long as the hardware line has the active level. This may require to mask the interrupt and unmask it after the associated handler has acknowledged the device, so the interrupt line is back to inactive.

This is a little confusing. You just said I don't need to worry mask and unmask things. But now you say I need to for the level triggered interrupts... And, what's the mask and unmask APIs that I can call?

Quoted 4 lines

Edge interrupt occurs on the falling and/or rising edge of a hardware signal.The occurrence is latched into the irq controller hardware and must be acked in order to be re-enabled.
Read the code /kerel/irq/chip.c(handle_edge_irq & handle_level_irq)

Thanks for pointing me there.

Quoted 10 lines
Quoted 2 lines

I know my questions might be basic , so would please tell me what's

If it was not basic then this question wouldn't be in kernelnewbies right :)?

Quoted 2 lines

the kernel code for ARM architecture doing these complex jobs as you
explained?

You don't need to worry about it but if you want to know further then I suggest tracing the call flow from asm interrupt handler(I believe do_irq but not sure) in arm to handle_edge_irq call flow by adding some logs or just browsing the code.

Okay I will be reading the code. If you have time please also be kind to help answer my previous questions in this message. Thanks a lot!

Quoted 25 lines
Quoted 25 lines

Thanks in advance !

Quoted 3 lines
Quoted 3 lines

2. My device, an AX88796B network controller, asserting the

interrupt

Quoted 1 line
Quoted 1 line

line in a level-triggered manner. Now I met problem with the

device that

Quoted 1 line
Quoted 1 line

might caused by the CPU interrupt mode is not set as

level-triggered by

Quoted 1 line
Quoted 1 line

edge trigger. My CPU is Samsung S3C2410, an ARM920T powered

one. Does

Quoted 1 line
Quoted 1 line

anyone know usually where and how should I do this kind of

setting?

Quoted 1 line

Just pass the parameter "level triggered" in request_irq in your

device driver.

Quoted 8 lines
Quoted 8 lines

Thanks in advance.

--
woody
I can't go back to yesterday - because I was a different person

Quoted 10 lines
Quoted 8 lines

then.

Quoted 5 lines
Quoted 5 lines

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20121221/c5f7089e/attachment-0001.html

author
#5 lore raw
In reply to anish singh
Quoted 28 lines · anish singh
Quoted 11 lines · Woody Wu

Hi, List

Where is the Kernel code that handles external interrupts? I want to have a look at it but haven't found out where it is.

Actually, I have some basic questions about interrupt handling in Linux.
1. After Kernel's ISR received an interrupt, I believe it will invoke a handler defined in a device driver if any. But it should be the device driver's responsibility or kernel ISR's responsibility to clear (or acknowledge) the interrupt?

If the interrupt in question is currently being handled then in the case of edge triggered interrupt we just mask the interrupt,set it pending and bail out.Once the interrupt handler completes then we check for pending interrupt and handle it.In level triggered we don't do that. Kerenel ISR -this is mixture of core kernel interrupt handling code + your device driver interrupt handler(if this is chip driver which is supposed to get one interrupt and is reponsible for calling other interrupt handlers based on the chip register status then you do explicit masking unmasking yourself).
If you device driver is a interrupt controller driver then you register your driver with kernel interrupt handling code and need to write some callbacks such as .mask,.unmask and so on.This callbacks are called at appropiate places whenever the interrupt is raised.This interrupt is then passed to drivers who has requested for this interrupt by calling request_irq.

Quoted 1 line
Quoted 8 lines
Quoted 2 lines

2. My device, an AX88796B network controller, asserting the interrupt line in a level-triggered manner. Now I met problem with the device

that

Quoted 3 lines

might caused by the CPU interrupt mode is not set as level-triggered by edge trigger. My CPU is Samsung S3C2410, an ARM920T powered one. Does anyone know usually where and how should I do this kind of setting?

Just pass the parameter "level triggered" in request_irq in your device driver.

Hi Sign,

I searched the interrupt.h for the all the defined flags that I can pass to the request_irq, but there is no a flag looks like "level triggered". Would you tell me what you mean the parameter "level triggered"?

Thanks.

Quoted 12 lines
Quoted 12 lines

Thanks in advance.

--
woody
I can't go back to yesterday - because I was a different person then.

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Signature · 2 lines
woody
I can't go back to yesterday - because I was a different person then.
#6 lore raw

Re: How kernel handle interrupts[AX88796B network controller]

Quoted 35 lines · Woody Wu
Quoted 34 lines · anish singh
Quoted 11 lines · Woody Wu

Hi, List

Where is the Kernel code that handles external interrupts? I want to have a look at it but haven't found out where it is.

Actually, I have some basic questions about interrupt handling in Linux.
1. After Kernel's ISR received an interrupt, I believe it will invoke a handler defined in a device driver if any. But it should be the device driver's responsibility or kernel ISR's responsibility to clear (or acknowledge) the interrupt?

If the interrupt in question is currently being handled then in the case of edge triggered interrupt we just mask the interrupt,set it pending and bail out.Once the interrupt handler completes then we check for pending interrupt and handle it.In level triggered we don't do that. Kerenel ISR -this is mixture of core kernel interrupt handling code + your device driver interrupt handler(if this is chip driver which is supposed to get one interrupt and is reponsible for calling other interrupt handlers based on the chip register status then you do explicit masking unmasking yourself).
If you device driver is a interrupt controller driver then you register your driver with kernel interrupt handling code and need to write some callbacks such as .mask,.unmask and so on.This callbacks are called at appropiate places whenever the interrupt is raised.This interrupt is then passed to drivers who has requested for this interrupt by calling request_irq.

Quoted 3 lines

2. My device, an AX88796B network controller, asserting the interrupt line in a level-triggered manner. Now I met problem with the device

that

Quoted 3 lines

might caused by the CPU interrupt mode is not set as level-triggered by edge trigger. My CPU is Samsung S3C2410, an ARM920T powered one. Does anyone know usually where and how should I do this kind of setting?

Quoted 8 lines
Quoted 2 lines

Just pass the parameter "level triggered" in request_irq in your device driver.

Hi Sign,

I searched the interrupt.h for the all the defined flags that I can pass to the request_irq, but there is no a flag looks like "level triggered". Would you tell me what you mean the parameter "level triggered"?

irq_set_irq_type(info->irq, IRQ_TYPE_LEVEL_LOW)

include/linux/irq.h
IRQ_TYPE_LEVEL_HIGH - high level triggered
IRQ_TYPE_LEVEL_LOW - low level triggered

Quoted 16 lines

Thanks.

Quoted 12 lines
Quoted 12 lines

Thanks in advance.

--
woody
I can't go back to yesterday - because I was a different person then.

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

author
#7 lore raw

Re: How kernel handle interrupts[AX88796B network controller]

Quoted 41 lines · anish kumar
Quoted 40 lines · Woody Wu
Quoted 28 lines · anish singh
Quoted 11 lines · Woody Wu

Hi, List

Where is the Kernel code that handles external interrupts? I want to have a look at it but haven't found out where it is.

Actually, I have some basic questions about interrupt handling in Linux.
1. After Kernel's ISR received an interrupt, I believe it will invoke a handler defined in a device driver if any. But it should be the device driver's responsibility or kernel ISR's responsibility to clear (or acknowledge) the interrupt?

If the interrupt in question is currently being handled then in the case of edge triggered interrupt we just mask the interrupt,set it pending and bail out.Once the interrupt handler completes then we check for pending interrupt and handle it.In level triggered we don't do that. Kerenel ISR -this is mixture of core kernel interrupt handling code + your device driver interrupt handler(if this is chip driver which is supposed to get one interrupt and is reponsible for calling other interrupt handlers based on the chip register status then you do explicit masking unmasking yourself).
If you device driver is a interrupt controller driver then you register your driver with kernel interrupt handling code and need to write some callbacks such as .mask,.unmask and so on.This callbacks are called at appropiate places whenever the interrupt is raised.This interrupt is then passed to drivers who has requested for this interrupt by calling request_irq.

Quoted 1 line
Quoted 8 lines
Quoted 2 lines

2. My device, an AX88796B network controller, asserting the interrupt line in a level-triggered manner. Now I met problem with the device

that

Quoted 3 lines

might caused by the CPU interrupt mode is not set as level-triggered by edge trigger. My CPU is Samsung S3C2410, an ARM920T powered one. Does anyone know usually where and how should I do this kind of setting?

Just pass the parameter "level triggered" in request_irq in your device driver.

Hi Sign,

Quoted 8 lines
Quoted 3 lines

I searched the interrupt.h for the all the defined flags that I can pass to the request_irq, but there is no a flag looks like "level triggered". Would you tell me what you mean the parameter "level triggered"?

irq_set_irq_type(info->irq, IRQ_TYPE_LEVEL_LOW)

include/linux/irq.h
IRQ_TYPE_LEVEL_HIGH - high level triggered
IRQ_TYPE_LEVEL_LOW - low level triggered

Thanks. Now I find the function.

I searched some code about irq in ARM architecure. Some other people talked about do_IRQ() probabaly is wrong for ARM. There is simply no that function in ARM. Maybe the do_IRQ in x86 is replaced by handle_IRQ.

For the irq_set_irq_type(), do you think what's the correct place to call it? Inside my device driver or outside the device driver (probably in the board definition file)? If that should be called inside a device driver, should it be the driver probe function or in the open function? After or before the invocation of request_irq()?

Sorry for asking too many question. I found the kernel + device driver irq handling part still not clear to me.

Quoted 17 lines
Quoted 16 lines

Thanks.

Quoted 12 lines
Quoted 12 lines

Thanks in advance.

--
woody
I can't go back to yesterday - because I was a different person then.

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Signature · 2 lines
woody
I can't go back to yesterday - because I was a different person then.
author
#10 lore raw

Re: How kernel handle interrupts[AX88796B network controller]

In reply to anish kumar
Quoted 41 lines · anish kumar
Quoted 40 lines · Woody Wu
Quoted 28 lines · anish singh
Quoted 11 lines · Woody Wu

Hi, List

Where is the Kernel code that handles external interrupts? I want to have a look at it but haven't found out where it is.

Actually, I have some basic questions about interrupt handling in Linux.
1. After Kernel's ISR received an interrupt, I believe it will invoke a handler defined in a device driver if any. But it should be the device driver's responsibility or kernel ISR's responsibility to clear (or acknowledge) the interrupt?

If the interrupt in question is currently being handled then in the case of edge triggered interrupt we just mask the interrupt,set it pending and bail out.Once the interrupt handler completes then we check for pending interrupt and handle it.In level triggered we don't do that. Kerenel ISR -this is mixture of core kernel interrupt handling code + your device driver interrupt handler(if this is chip driver which is supposed to get one interrupt and is reponsible for calling other interrupt handlers based on the chip register status then you do explicit masking unmasking yourself).
If you device driver is a interrupt controller driver then you register your driver with kernel interrupt handling code and need to write some callbacks such as .mask,.unmask and so on.This callbacks are called at appropiate places whenever the interrupt is raised.This interrupt is then passed to drivers who has requested for this interrupt by calling request_irq.

Quoted 1 line
Quoted 8 lines
Quoted 2 lines

2. My device, an AX88796B network controller, asserting the interrupt line in a level-triggered manner. Now I met problem with the device

that

Quoted 3 lines

might caused by the CPU interrupt mode is not set as level-triggered by edge trigger. My CPU is Samsung S3C2410, an ARM920T powered one. Does anyone know usually where and how should I do this kind of setting?

Just pass the parameter "level triggered" in request_irq in your device driver.

Hi Sign,

Quoted 8 lines
Quoted 3 lines

I searched the interrupt.h for the all the defined flags that I can pass to the request_irq, but there is no a flag looks like "level triggered". Would you tell me what you mean the parameter "level triggered"?

irq_set_irq_type(info->irq, IRQ_TYPE_LEVEL_LOW)

include/linux/irq.h
IRQ_TYPE_LEVEL_HIGH - high level triggered
IRQ_TYPE_LEVEL_LOW - low level triggered

Thanks. You saved my ass.

Be curious, I found the api changes from 2.6 to 3.7. In 2.6, there are pair of funtions, set_irq_type and set_irq_handle (there is no irq_set_irq_type in 2.6). Problem is, I cannot find something like irq_set_irq_handle in 3.7. Does that mean, in 3.7, when irq_set_irq_type is changed, the associated flow handler is also changed? In my case, the interrupt was originally assgined with a edge flow handler and set type as edge irq. After I, by invoking irq_set_irq_type, change it to level irq, I think the flow handler should also be changed to a level handle. Is that happened automatically behind? I search through the code, but did not find where is it.

Quoted 17 lines
Quoted 16 lines

Thanks.

Quoted 12 lines
Quoted 12 lines

Thanks in advance.

--
woody
I can't go back to yesterday - because I was a different person then.

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Signature · 2 lines
woody
I can't go back to yesterday - because I was a different person then.
author
#11 lore raw

Re: How kernel handle interrupts[AX88796B network controller]

Quoted 53 lines · Woody Wu
Quoted 41 lines · anish kumar
Quoted 40 lines · Woody Wu
Quoted 28 lines · anish singh
Quoted 11 lines · Woody Wu

Hi, List

Where is the Kernel code that handles external interrupts? I want to have a look at it but haven't found out where it is.

Actually, I have some basic questions about interrupt handling in Linux.
1. After Kernel's ISR received an interrupt, I believe it will invoke a handler defined in a device driver if any. But it should be the device driver's responsibility or kernel ISR's responsibility to clear (or acknowledge) the interrupt?

If the interrupt in question is currently being handled then in the case of edge triggered interrupt we just mask the interrupt,set it pending and bail out.Once the interrupt handler completes then we check for pending interrupt and handle it.In level triggered we don't do that. Kerenel ISR -this is mixture of core kernel interrupt handling code + your device driver interrupt handler(if this is chip driver which is supposed to get one interrupt and is reponsible for calling other interrupt handlers based on the chip register status then you do explicit masking unmasking yourself).
If you device driver is a interrupt controller driver then you register your driver with kernel interrupt handling code and need to write some callbacks such as .mask,.unmask and so on.This callbacks are called at appropiate places whenever the interrupt is raised.This interrupt is then passed to drivers who has requested for this interrupt by calling request_irq.

Quoted 1 line
Quoted 8 lines
Quoted 2 lines

2. My device, an AX88796B network controller, asserting the interrupt line in a level-triggered manner. Now I met problem with the device

that

Quoted 3 lines

might caused by the CPU interrupt mode is not set as level-triggered by edge trigger. My CPU is Samsung S3C2410, an ARM920T powered one. Does anyone know usually where and how should I do this kind of setting?

Just pass the parameter "level triggered" in request_irq in your device driver.

Hi Sign,

Quoted 8 lines
Quoted 3 lines

I searched the interrupt.h for the all the defined flags that I can pass to the request_irq, but there is no a flag looks like "level triggered". Would you tell me what you mean the parameter "level triggered"?

irq_set_irq_type(info->irq, IRQ_TYPE_LEVEL_LOW)

include/linux/irq.h
IRQ_TYPE_LEVEL_HIGH - high level triggered
IRQ_TYPE_LEVEL_LOW - low level triggered

Thanks. You saved my ass.

Quoted 11 lines

Be curious, I found the api changes from 2.6 to 3.7. In 2.6, there are pair of funtions, set_irq_type and set_irq_handle (there is no irq_set_irq_type in 2.6). Problem is, I cannot find something like irq_set_irq_handle in 3.7. Does that mean, in 3.7, when irq_set_irq_type is changed, the associated flow handler is also changed? In my case, the interrupt was originally assgined with a edge flow handler and set type as edge irq. After I, by invoking irq_set_irq_type, change it to level irq, I think the flow handler should also be changed to a level handle. Is that happened automatically behind? I search through the code, but did not find where is it.

Make it simple, is it necessary to also change the irq flow handler after changed a irq type (from edge to level)? Is yes, what's the public api that let user change flow handler for an irq?

Thanks in advance.

Quoted 23 lines
Quoted 19 lines
Quoted 18 lines

Thanks.

Quoted 12 lines
Quoted 12 lines

Thanks in advance.

--
woody
I can't go back to yesterday - because I was a different person then.

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Signature · 2 lines
woody
I can't go back to yesterday - because I was a different person then.
Signature · 2 lines
woody
I can't go back to yesterday - because I was a different person then.
#12 lore raw

Re: How kernel handle interrupts[AX88796B network controller]

In reply to Woody Wu
Quoted 53 lines · Woody Wu
Quoted 41 lines · anish kumar
Quoted 40 lines · Woody Wu
Quoted 28 lines · anish singh
Quoted 11 lines · Woody Wu

Hi, List

Where is the Kernel code that handles external interrupts? I want to have a look at it but haven't found out where it is.

Actually, I have some basic questions about interrupt handling in Linux.
1. After Kernel's ISR received an interrupt, I believe it will invoke a handler defined in a device driver if any. But it should be the device driver's responsibility or kernel ISR's responsibility to clear (or acknowledge) the interrupt?

If the interrupt in question is currently being handled then in the case of edge triggered interrupt we just mask the interrupt,set it pending and bail out.Once the interrupt handler completes then we check for pending interrupt and handle it.In level triggered we don't do that. Kerenel ISR -this is mixture of core kernel interrupt handling code + your device driver interrupt handler(if this is chip driver which is supposed to get one interrupt and is reponsible for calling other interrupt handlers based on the chip register status then you do explicit masking unmasking yourself).
If you device driver is a interrupt controller driver then you register your driver with kernel interrupt handling code and need to write some callbacks such as .mask,.unmask and so on.This callbacks are called at appropiate places whenever the interrupt is raised.This interrupt is then passed to drivers who has requested for this interrupt by calling request_irq.

Quoted 1 line
Quoted 8 lines
Quoted 2 lines

2. My device, an AX88796B network controller, asserting the interrupt line in a level-triggered manner. Now I met problem with the device

that

Quoted 3 lines

might caused by the CPU interrupt mode is not set as level-triggered by edge trigger. My CPU is Samsung S3C2410, an ARM920T powered one. Does anyone know usually where and how should I do this kind of setting?

Just pass the parameter "level triggered" in request_irq in your device driver.

Hi Sign,

Quoted 8 lines
Quoted 3 lines

I searched the interrupt.h for the all the defined flags that I can pass to the request_irq, but there is no a flag looks like "level triggered". Would you tell me what you mean the parameter "level triggered"?

irq_set_irq_type(info->irq, IRQ_TYPE_LEVEL_LOW)

include/linux/irq.h
IRQ_TYPE_LEVEL_HIGH - high level triggered
IRQ_TYPE_LEVEL_LOW - low level triggered

Thanks. You saved my ass.

Quoted 11 lines

Be curious, I found the api changes from 2.6 to 3.7. In 2.6, there are pair of funtions, set_irq_type and set_irq_handle (there is no irq_set_irq_type in 2.6). Problem is, I cannot find something like irq_set_irq_handle in 3.7. Does that mean, in 3.7, when irq_set_irq_type is changed, the associated flow handler is also changed? In my case, the interrupt was originally assgined with a edge flow handler and set type as edge irq. After I, by invoking irq_set_irq_type, change it to level irq, I think the flow handler should also be changed to a level handle. Is that happened automatically behind? I search through the code, but did not find where is it.

Why not try calling irq_set_irq_type and check what happens?

Quoted 20 lines
Quoted 19 lines
Quoted 18 lines

Thanks.

Quoted 12 lines
Quoted 12 lines

Thanks in advance.

--
woody
I can't go back to yesterday - because I was a different person then.

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

#8 lore raw

Re: How kernel handle interrupts[AX88796B network controller]

In reply to Woody Wu
Quoted 51 lines · Woody Wu
Quoted 41 lines · anish kumar
Quoted 40 lines · Woody Wu
Quoted 28 lines · anish singh
Quoted 11 lines · Woody Wu

Hi, List

Where is the Kernel code that handles external interrupts? I want to have a look at it but haven't found out where it is.

Actually, I have some basic questions about interrupt handling in Linux.
1. After Kernel's ISR received an interrupt, I believe it will invoke a handler defined in a device driver if any. But it should be the device driver's responsibility or kernel ISR's responsibility to clear (or acknowledge) the interrupt?

If the interrupt in question is currently being handled then in the case of edge triggered interrupt we just mask the interrupt,set it pending and bail out.Once the interrupt handler completes then we check for pending interrupt and handle it.In level triggered we don't do that. Kerenel ISR -this is mixture of core kernel interrupt handling code + your device driver interrupt handler(if this is chip driver which is supposed to get one interrupt and is reponsible for calling other interrupt handlers based on the chip register status then you do explicit masking unmasking yourself).
If you device driver is a interrupt controller driver then you register your driver with kernel interrupt handling code and need to write some callbacks such as .mask,.unmask and so on.This callbacks are called at appropiate places whenever the interrupt is raised.This interrupt is then passed to drivers who has requested for this interrupt by calling request_irq.

Quoted 1 line
Quoted 8 lines
Quoted 2 lines

2. My device, an AX88796B network controller, asserting the interrupt line in a level-triggered manner. Now I met problem with the device

that

Quoted 3 lines

might caused by the CPU interrupt mode is not set as level-triggered by edge trigger. My CPU is Samsung S3C2410, an ARM920T powered one. Does anyone know usually where and how should I do this kind of setting?

Just pass the parameter "level triggered" in request_irq in your device driver.

Hi Sign,

Quoted 8 lines
Quoted 3 lines

I searched the interrupt.h for the all the defined flags that I can pass to the request_irq, but there is no a flag looks like "level triggered". Would you tell me what you mean the parameter "level triggered"?

irq_set_irq_type(info->irq, IRQ_TYPE_LEVEL_LOW)

include/linux/irq.h
IRQ_TYPE_LEVEL_HIGH - high level triggered
IRQ_TYPE_LEVEL_LOW - low level triggered

Quoted 6 lines

Thanks. Now I find the function.

I searched some code about irq in ARM architecure. Some other people talked about do_IRQ() probabaly is wrong for ARM. There is simply no that function in ARM. Maybe the do_IRQ in x86 is replaced by handle_IRQ.

arch/arm/kernel/entry-armv.S
__irq_svc is called by the arm processor which in turn calls irq_handler macro.I think this is the lowest level handler after which linux interrupt handling takes over.

Quoted 6 lines

For the irq_set_irq_type(), do you think what's the correct place to call it? Inside my device driver or outside the device driver (probably in the board definition file)? If that should be called inside a device driver, should it be the driver probe function or in the open function? After or before the invocation of request_irq()?

irq_set_irq_type() should be called by device driver code not by the board file.It should be called in the probe function AFAIK.

Quoted 3 lines

Sorry for asking too many question. I found the kernel + device driver irq handling part still not clear to me.

You are welcome to ask as many question as you want.

Quoted 20 lines
Quoted 19 lines
Quoted 18 lines

Thanks.

Quoted 12 lines
Quoted 12 lines

Thanks in advance.

--
woody
I can't go back to yesterday - because I was a different person then.

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

author
#9 lore raw

Re: How kernel handle interrupts[AX88796B network controller]

Quoted 54 lines · anish kumar
Quoted 53 lines · Woody Wu
Quoted 41 lines · anish kumar
Quoted 40 lines · Woody Wu
Quoted 28 lines · anish singh
Quoted 11 lines · Woody Wu

Hi, List

Where is the Kernel code that handles external interrupts? I want to have a look at it but haven't found out where it is.

Actually, I have some basic questions about interrupt handling in Linux.
1. After Kernel's ISR received an interrupt, I believe it will invoke a handler defined in a device driver if any. But it should be the device driver's responsibility or kernel ISR's responsibility to clear (or acknowledge) the interrupt?

If the interrupt in question is currently being handled then in the case of edge triggered interrupt we just mask the interrupt,set it pending and bail out.Once the interrupt handler completes then we check for pending interrupt and handle it.In level triggered we don't do that. Kerenel ISR -this is mixture of core kernel interrupt handling code + your device driver interrupt handler(if this is chip driver which is supposed to get one interrupt and is reponsible for calling other interrupt handlers based on the chip register status then you do explicit masking unmasking yourself).
If you device driver is a interrupt controller driver then you register your driver with kernel interrupt handling code and need to write some callbacks such as .mask,.unmask and so on.This callbacks are called at appropiate places whenever the interrupt is raised.This interrupt is then passed to drivers who has requested for this interrupt by calling request_irq.

Quoted 1 line
Quoted 8 lines
Quoted 2 lines

2. My device, an AX88796B network controller, asserting the interrupt line in a level-triggered manner. Now I met problem with the device

that

Quoted 3 lines

might caused by the CPU interrupt mode is not set as level-triggered by edge trigger. My CPU is Samsung S3C2410, an ARM920T powered one. Does anyone know usually where and how should I do this kind of setting?

Just pass the parameter "level triggered" in request_irq in your device driver.

Hi Sign,

Quoted 8 lines
Quoted 3 lines

I searched the interrupt.h for the all the defined flags that I can pass to the request_irq, but there is no a flag looks like "level triggered". Would you tell me what you mean the parameter "level triggered"?

irq_set_irq_type(info->irq, IRQ_TYPE_LEVEL_LOW)

include/linux/irq.h
IRQ_TYPE_LEVEL_HIGH - high level triggered
IRQ_TYPE_LEVEL_LOW - low level triggered

Thanks. Now I find the function.

Quoted 8 lines
Quoted 4 lines

I searched some code about irq in ARM architecure. Some other people talked about do_IRQ() probabaly is wrong for ARM. There is simply no that function in ARM. Maybe the do_IRQ in x86 is replaced by handle_IRQ.

arch/arm/kernel/entry-armv.S
__irq_svc is called by the arm processor which in turn calls irq_handler macro.I think this is the lowest level handler after which linux interrupt handling takes over.

Only today, I saw this email you replied. Many thanks!

Quoted 33 lines
Quoted 6 lines

For the irq_set_irq_type(), do you think what's the correct place to call it? Inside my device driver or outside the device driver (probably in the board definition file)? If that should be called inside a device driver, should it be the driver probe function or in the open function? After or before the invocation of request_irq()?

irq_set_irq_type() should be called by device driver code not by the board file.It should be called in the probe function AFAIK.

Quoted 3 lines

Sorry for asking too many question. I found the kernel + device driver irq handling part still not clear to me.

You are welcome to ask as many question as you want.

Quoted 20 lines
Quoted 19 lines
Quoted 18 lines

Thanks.

Quoted 12 lines
Quoted 12 lines

Thanks in advance.

--
woody
I can't go back to yesterday - because I was a different person then.

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Signature · 1 line
I can't go back to yesterday - because I was a different person then