7
Most read
8
Most read
10
Most read
© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Interrupts
2© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
What to Expect?
W's & How's of Interrupts?
The IRQ
Interrupt Handling & Handlers
Soft IRQs
3© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
W's of an Interrupt?
What is an Interrupt?
Intervention to get Attention
Here, from the Devices to the CPU
Why is an Interrupt required?
Mismatch of Device & CPU speeds
Get overall better efficiency & latency
4© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
How does interrupt work?
Interrupt is a Hardware thing
It needs Physical connection
In Processors
Typically have one or two interrupt lines
Handled by a Interrupt Controller, called PIC
And PIC informs the Processor through its one line
In Micro-controllers
Each GPIO can act as an interrupt line
Interrupt Controller is in-built
In both cases, the CPU then decodes the IRQ
And calls the corresponding registered interrupt handler
5© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Interrupt ReQuest (IRQ)
Number derived by CPU & Board
Programmed or Hard Coded with Interrupt Controller
Hence, one key component of LSPs
In x86
CPU Specific: 0x00 to 0x1F (Hard coded)
Board Specific: 0x20 to 0xFF
Header: <asm/interrupt.h> → <asm/irq.h> → irq*.h
In Microcontrollers
Depends on the controller
Header: <asm/interrupt.h> → <asm/irq.h> → irq*.h
6© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Programming Interface
Header: <asm/interrupt.h>
Type:
typedef irqreturn_t (*irq_handler_t)(int, void *);
APIs
int request_irq(unsigned int irq, irq_handler_t handler, unsigned long
flags, const char *name, void *dev_id);
void free_irq(unsigned int irq, void *dev_id);
int can_request_irq(irq, flags);
Flags
IRQF_TRIGGER_RISING, ..., IRQF_TRIGGER_HIGH, ...
IRQF_SAMPLE_RANDOM
IRQF_SHARED, ...
7© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
IRQ Handler Do's & Don'ts
No sleeping – direct or indirect
Example: schedule_timeout, input_register_device
No mutexes
Rather use spin_locks, if you must
Can't exchange data with User Space
In their own context. current is invalid
If lot to be done, break it into two
Top Half & Bottom Half
Need not be re-entrant
May get interrupted by higher priority interrupt handlers
8© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
The Additional Info
IRQ Control
enable_irq(irq);
disable_irq(irq);
IRQ Handler returns
IRQ_NONE
IRQ_HANDLED
Check for execution state
in_interrupt();
Synchronous interrupts, treated alike
Exceptions to report grave runtime errors
Software interrupts such as the int 0x80 used for system calls in x86
architecture
9© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Message Signaled Interrupts
Specifically for PCI Devices
Advantages
No sharing, No sync issues, More interrupts
Modes: MSI or MSI-X (only one at a time)
MSI (since PCI 2.2)
Special Address: PCI config space
Interrupts / Device: Upto 32 in powers of 2
MSI-X (since PCI 3.0)
Special Address: Bus address
Interrupts / Device: Sparse & upto 2048
10© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
MSI/MSI-X APIs
MSI
int pci_enable_msi(strcut pci_dev *);
int pci_enable_msi_block(strcut pci_dev *, int cnt);
void pci_disable_msi(strcut pci_dev *);
MSI-X
int pci_enable_msix(strcut pci_dev *, struct
msix_entry *, int nvec);
struct msix_entry
{ u16 vector /* allocated irq */, entry; };
void pci_disable_msix(strcut pci_dev *);
11© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Soft IRQs
12© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
What is a Soft IRQ?
Basic Bottom Half
Synchronous Interrupt
Have strong locking requirements
Used for the performance sensitive subsystems
Not same as Software Interrupt
13© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Typical Soft IRQs
Timer
Network
Block
Tasklet
Scheduler
High Resolution Timer
14© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Linux Execution Model
Interrupt Handlers
Soft IRQ Handlers
Kernel Threads
Timer Network...
Timer Network...Scheduler
...
User Processes
Work Q
Kernel
Thread
User Process
Pn
User Process
P1
...
15© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Programming
Header: <linux/interrupt.h>
APIs
void open_softirq(int nr, void (*action)(struct
softirq_action *));
void raise_softirq(unsigned int nr);
16© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Top & Bottom Halves
Top Half
Registered through request_irq
Bottom Half
Tasklet
Soft IRQ Context
Fast & Atomic
Only different tasklets can run on different CPUs
Work Queue
Special Kernel Process Context
Allowed to sleep
Can run simultaneously on different CPUs
17© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
What all have we learnt?
W's & How's of Interrupts?
The IRQ
Interrupt Handling & Handlers
Message Signalled Interrupts
Soft IRQs: The Bottom Halves
18© 2010-15 SysPlay Workshops <workshop@sysplay.in>
All Rights Reserved.
Any Queries?

More Related Content

PDF
Network Drivers
PDF
Embedded linux network device driver development
PDF
USB Drivers
PPTX
PCI BUS
PDF
Embedded Operating System - Linux
PPTX
Slideshare - PCIe
Network Drivers
Embedded linux network device driver development
USB Drivers
PCI BUS
Embedded Operating System - Linux
Slideshare - PCIe

What's hot (20)

PDF
The linux networking architecture
PDF
Project ACRN: SR-IOV implementation
PDF
Bootloaders
PDF
Embedded Linux Kernel - Build your custom kernel
PDF
Introduction to Linux
DOCX
Intellectual property in vlsi
PPTX
Multiprocessor
PPTX
AMBA 3 APB Protocol
PPTX
Riscv 20160507-patterson
PDF
U-Boot - An universal bootloader
PPT
Pcie drivers basics
PPTX
PCI Slot
PPTX
Memory hierarchy
PDF
QEMU in Cross building
PPTX
Interrupts
PPTX
Bootloader and bootloading
PPTX
RISC-V Boot Process: One Step at a Time
PPTX
Design and Implementation of Synchronous FIFO Interfaced with RAM.pptx
PPTX
Multiprocessor Architecture (Advanced computer architecture)
PDF
SFO15-TR9: PSCI, ACPI (and UEFI to boot)
The linux networking architecture
Project ACRN: SR-IOV implementation
Bootloaders
Embedded Linux Kernel - Build your custom kernel
Introduction to Linux
Intellectual property in vlsi
Multiprocessor
AMBA 3 APB Protocol
Riscv 20160507-patterson
U-Boot - An universal bootloader
Pcie drivers basics
PCI Slot
Memory hierarchy
QEMU in Cross building
Interrupts
Bootloader and bootloading
RISC-V Boot Process: One Step at a Time
Design and Implementation of Synchronous FIFO Interfaced with RAM.pptx
Multiprocessor Architecture (Advanced computer architecture)
SFO15-TR9: PSCI, ACPI (and UEFI to boot)
Ad

Viewers also liked (20)

PDF
PCI Drivers
PDF
File System Modules
PDF
Block Drivers
PDF
Introduction to Linux Drivers
PDF
Kernel Debugging & Profiling
PDF
References
PDF
gcc and friends
PDF
Embedded C
PDF
Character Drivers
PDF
Low-level Accesses
PDF
Kernel Programming
PDF
Audio Drivers
PDF
Video Drivers
PDF
BeagleBoard-xM Bootloaders
PDF
BeagleBone Black Bootloaders
PDF
Linux Porting
PCI Drivers
File System Modules
Block Drivers
Introduction to Linux Drivers
Kernel Debugging & Profiling
References
gcc and friends
Embedded C
Character Drivers
Low-level Accesses
Kernel Programming
Audio Drivers
Video Drivers
BeagleBoard-xM Bootloaders
BeagleBone Black Bootloaders
Linux Porting
Ad

Similar to Interrupts (20)

PDF
IRQs: the Hard, the Soft, the Threaded and the Preemptible
PPTX
Interrupts on 8086 microprocessor by vijay kumar.k
PPTX
Interrupt in real time system
PPTX
3-programmable interrupt con lesson13.pptx
PPT
63071507 interrupts-up
PPTX
MICROPROCESSOR_Anurad gor systej ndjksauduiha MAITY.pptx
PDF
Unit 3 (Complete) - 8086 Interrupt Structure.pdf
PPTX
Interrupts of 8086
PPTX
Interrupts
PPT
Vino's 8086 interrupts
PPTX
Interrupts and types of interrupts
PPTX
Linux Interrupts
PPTX
3.12_8086 microprocessor Interrupts.pptx
PPTX
MPMC UNIT 2 MPMC UNIT 2 MPMC UNIT 2 MPMC UNIT 2
PPTX
MPMC UNIT 2 MPMC UNIT 2 MPMC UNIT 2 MPMC UNIT 2
PPTX
Interrupt 8085
PPT
Interrupts_S05,interrupt vector table.ppt
PPTX
8051 interrupt Presentation Download for ECE
PPTX
Interrupts in 8085
PPT
8251
IRQs: the Hard, the Soft, the Threaded and the Preemptible
Interrupts on 8086 microprocessor by vijay kumar.k
Interrupt in real time system
3-programmable interrupt con lesson13.pptx
63071507 interrupts-up
MICROPROCESSOR_Anurad gor systej ndjksauduiha MAITY.pptx
Unit 3 (Complete) - 8086 Interrupt Structure.pdf
Interrupts of 8086
Interrupts
Vino's 8086 interrupts
Interrupts and types of interrupts
Linux Interrupts
3.12_8086 microprocessor Interrupts.pptx
MPMC UNIT 2 MPMC UNIT 2 MPMC UNIT 2 MPMC UNIT 2
MPMC UNIT 2 MPMC UNIT 2 MPMC UNIT 2 MPMC UNIT 2
Interrupt 8085
Interrupts_S05,interrupt vector table.ppt
8051 interrupt Presentation Download for ECE
Interrupts in 8085
8251

More from Anil Kumar Pugalia (20)

PDF
File System Modules
PDF
Kernel Debugging & Profiling
PDF
PDF
System Calls
PDF
Introduction to Linux
PDF
Embedded Software Design
PDF
Playing with R L C Circuits
PDF
Mobile Hacking using Linux Drivers
PDF
Shell Scripting
PDF
Functional Programming with LISP
PDF
Power of vi
PDF
"make" system
PDF
Hardware Design for Software Hackers
PDF
RPM Building
PDF
Linux User Space Debugging & Profiling
PDF
Linux Network Management
PDF
System Calls
PDF
PDF
Synchronization
File System Modules
Kernel Debugging & Profiling
System Calls
Introduction to Linux
Embedded Software Design
Playing with R L C Circuits
Mobile Hacking using Linux Drivers
Shell Scripting
Functional Programming with LISP
Power of vi
"make" system
Hardware Design for Software Hackers
RPM Building
Linux User Space Debugging & Profiling
Linux Network Management
System Calls
Synchronization

Recently uploaded (20)

PPTX
Training Program for knowledge in solar cell and solar industry
PDF
How IoT Sensor Integration in 2025 is Transforming Industries Worldwide
PDF
A review of recent deep learning applications in wood surface defect identifi...
PDF
“A New Era of 3D Sensing: Transforming Industries and Creating Opportunities,...
PDF
Architecture types and enterprise applications.pdf
DOCX
Basics of Cloud Computing - Cloud Ecosystem
PDF
Comparative analysis of machine learning models for fake news detection in so...
PDF
Developing a website for English-speaking practice to English as a foreign la...
PDF
Enhancing plagiarism detection using data pre-processing and machine learning...
PPTX
The various Industrial Revolutions .pptx
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
Improvisation in detection of pomegranate leaf disease using transfer learni...
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PDF
STKI Israel Market Study 2025 version august
PPTX
Configure Apache Mutual Authentication
PPTX
Benefits of Physical activity for teenagers.pptx
PPTX
Custom Battery Pack Design Considerations for Performance and Safety
PPTX
Modernising the Digital Integration Hub
PDF
Flame analysis and combustion estimation using large language and vision assi...
PDF
sustainability-14-14877-v2.pddhzftheheeeee
Training Program for knowledge in solar cell and solar industry
How IoT Sensor Integration in 2025 is Transforming Industries Worldwide
A review of recent deep learning applications in wood surface defect identifi...
“A New Era of 3D Sensing: Transforming Industries and Creating Opportunities,...
Architecture types and enterprise applications.pdf
Basics of Cloud Computing - Cloud Ecosystem
Comparative analysis of machine learning models for fake news detection in so...
Developing a website for English-speaking practice to English as a foreign la...
Enhancing plagiarism detection using data pre-processing and machine learning...
The various Industrial Revolutions .pptx
Final SEM Unit 1 for mit wpu at pune .pptx
Improvisation in detection of pomegranate leaf disease using transfer learni...
A contest of sentiment analysis: k-nearest neighbor versus neural network
STKI Israel Market Study 2025 version august
Configure Apache Mutual Authentication
Benefits of Physical activity for teenagers.pptx
Custom Battery Pack Design Considerations for Performance and Safety
Modernising the Digital Integration Hub
Flame analysis and combustion estimation using large language and vision assi...
sustainability-14-14877-v2.pddhzftheheeeee

Interrupts

  • 1. © 2010-15 SysPlay Workshops <[email protected]> All Rights Reserved. Interrupts
  • 2. 2© 2010-15 SysPlay Workshops <[email protected]> All Rights Reserved. What to Expect? W's & How's of Interrupts? The IRQ Interrupt Handling & Handlers Soft IRQs
  • 3. 3© 2010-15 SysPlay Workshops <[email protected]> All Rights Reserved. W's of an Interrupt? What is an Interrupt? Intervention to get Attention Here, from the Devices to the CPU Why is an Interrupt required? Mismatch of Device & CPU speeds Get overall better efficiency & latency
  • 4. 4© 2010-15 SysPlay Workshops <[email protected]> All Rights Reserved. How does interrupt work? Interrupt is a Hardware thing It needs Physical connection In Processors Typically have one or two interrupt lines Handled by a Interrupt Controller, called PIC And PIC informs the Processor through its one line In Micro-controllers Each GPIO can act as an interrupt line Interrupt Controller is in-built In both cases, the CPU then decodes the IRQ And calls the corresponding registered interrupt handler
  • 5. 5© 2010-15 SysPlay Workshops <[email protected]> All Rights Reserved. Interrupt ReQuest (IRQ) Number derived by CPU & Board Programmed or Hard Coded with Interrupt Controller Hence, one key component of LSPs In x86 CPU Specific: 0x00 to 0x1F (Hard coded) Board Specific: 0x20 to 0xFF Header: <asm/interrupt.h> → <asm/irq.h> → irq*.h In Microcontrollers Depends on the controller Header: <asm/interrupt.h> → <asm/irq.h> → irq*.h
  • 6. 6© 2010-15 SysPlay Workshops <[email protected]> All Rights Reserved. Programming Interface Header: <asm/interrupt.h> Type: typedef irqreturn_t (*irq_handler_t)(int, void *); APIs int request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, const char *name, void *dev_id); void free_irq(unsigned int irq, void *dev_id); int can_request_irq(irq, flags); Flags IRQF_TRIGGER_RISING, ..., IRQF_TRIGGER_HIGH, ... IRQF_SAMPLE_RANDOM IRQF_SHARED, ...
  • 7. 7© 2010-15 SysPlay Workshops <[email protected]> All Rights Reserved. IRQ Handler Do's & Don'ts No sleeping – direct or indirect Example: schedule_timeout, input_register_device No mutexes Rather use spin_locks, if you must Can't exchange data with User Space In their own context. current is invalid If lot to be done, break it into two Top Half & Bottom Half Need not be re-entrant May get interrupted by higher priority interrupt handlers
  • 8. 8© 2010-15 SysPlay Workshops <[email protected]> All Rights Reserved. The Additional Info IRQ Control enable_irq(irq); disable_irq(irq); IRQ Handler returns IRQ_NONE IRQ_HANDLED Check for execution state in_interrupt(); Synchronous interrupts, treated alike Exceptions to report grave runtime errors Software interrupts such as the int 0x80 used for system calls in x86 architecture
  • 9. 9© 2010-15 SysPlay Workshops <[email protected]> All Rights Reserved. Message Signaled Interrupts Specifically for PCI Devices Advantages No sharing, No sync issues, More interrupts Modes: MSI or MSI-X (only one at a time) MSI (since PCI 2.2) Special Address: PCI config space Interrupts / Device: Upto 32 in powers of 2 MSI-X (since PCI 3.0) Special Address: Bus address Interrupts / Device: Sparse & upto 2048
  • 10. 10© 2010-15 SysPlay Workshops <[email protected]> All Rights Reserved. MSI/MSI-X APIs MSI int pci_enable_msi(strcut pci_dev *); int pci_enable_msi_block(strcut pci_dev *, int cnt); void pci_disable_msi(strcut pci_dev *); MSI-X int pci_enable_msix(strcut pci_dev *, struct msix_entry *, int nvec); struct msix_entry { u16 vector /* allocated irq */, entry; }; void pci_disable_msix(strcut pci_dev *);
  • 11. 11© 2010-15 SysPlay Workshops <[email protected]> All Rights Reserved. Soft IRQs
  • 12. 12© 2010-15 SysPlay Workshops <[email protected]> All Rights Reserved. What is a Soft IRQ? Basic Bottom Half Synchronous Interrupt Have strong locking requirements Used for the performance sensitive subsystems Not same as Software Interrupt
  • 13. 13© 2010-15 SysPlay Workshops <[email protected]> All Rights Reserved. Typical Soft IRQs Timer Network Block Tasklet Scheduler High Resolution Timer
  • 14. 14© 2010-15 SysPlay Workshops <[email protected]> All Rights Reserved. Linux Execution Model Interrupt Handlers Soft IRQ Handlers Kernel Threads Timer Network... Timer Network...Scheduler ... User Processes Work Q Kernel Thread User Process Pn User Process P1 ...
  • 15. 15© 2010-15 SysPlay Workshops <[email protected]> All Rights Reserved. Programming Header: <linux/interrupt.h> APIs void open_softirq(int nr, void (*action)(struct softirq_action *)); void raise_softirq(unsigned int nr);
  • 16. 16© 2010-15 SysPlay Workshops <[email protected]> All Rights Reserved. Top & Bottom Halves Top Half Registered through request_irq Bottom Half Tasklet Soft IRQ Context Fast & Atomic Only different tasklets can run on different CPUs Work Queue Special Kernel Process Context Allowed to sleep Can run simultaneously on different CPUs
  • 17. 17© 2010-15 SysPlay Workshops <[email protected]> All Rights Reserved. What all have we learnt? W's & How's of Interrupts? The IRQ Interrupt Handling & Handlers Message Signalled Interrupts Soft IRQs: The Bottom Halves
  • 18. 18© 2010-15 SysPlay Workshops <[email protected]> All Rights Reserved. Any Queries?