LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 09-03-2013, 01:27 PM   #1
zvivered
Member
 
Registered: Sep 2007
Posts: 294

Rep: Reputation: 23
Thumbs down Is it possible to prevent interrupts sharing ?


Dear Members,

I'm writing a linux device driver (RHEL 5.8) for a DIO card. It has 16 channels. On each channel when the input goas from '1' to '0' (TTL) an interrupt is created.

Accoding to /proc/interrutps, the IRQ is shared with other USB devices.

Is it possible to avoid it ?

My ISR handler is:

/**********************************************************************/
static irqreturn_t irq_handler (int irq, void *data)
{
short status;

status = ioread16 ((void*)(virtual_bar0_base_s+0x1A));
if (status !=0)
iowrite16 (status,(void*)(virtual_bar0_base_s+0x1A));

return IRQ_HANDLED;
}

/**********************************************************************/
0x1A is the interrupt status register. If an interrupt from the DIO is pending, the relevant bit (according to channel) is '1'.

0x1A is also the clear register.

In case of an interrupt I must write the status to the clear register.

Is it possible that this ISR is called also upon an interrupt caused by USB device ?

I noticed that when interrupts are enabled in the DIO, USB devices works very slow.

Thanks,
Zvika
 
Old 09-04-2013, 10:48 AM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940
On the x86 architecture, at least, there are "not nearly enough" IRQs out there, so all of them are quite-heavily shared.
 
Old 09-05-2013, 06:26 AM   #3
zvivered
Member
 
Registered: Sep 2007
Posts: 294

Original Poster
Rep: Reputation: 23
What ISR handlers are called ?

Quote:
Originally Posted by sundialsvcs View Post
On the x86 architecture, at least, there are "not nearly enough" IRQs out there, so all of them are quite-heavily shared.
Thank you for your reply.

In case of a shared interrupt (e.g USB device and my device) is it possible that a USB event will cause O.S to call my handler ?

Is it possible that an event in my card will cause O.S to call the USB ISR handlers ?

Should I check it in my handler and return IRQ_NONE ?

Thanks,
Zvika
 
Old 09-05-2013, 09:03 AM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940
"The cardinal rule of interrupt handlers," in any operating system, is that an interrupt serves only to notify (the "first-level handler" layer of your code ...) that something has just happened that might, or might not, be of interest to you.

You have to examine the status-flags presented by your device to see if it's the one that's ringing. If it is your device, then you squash the interrupt ("whack the alarm clock so that it stops ringing ...") and schedule what is supposed to happen next. Then, get out of there, letting the operating system know that the interrupt was "handled" by you.

But if it is not your device, you simply exit and let the operating-system call the next first-level handler that it may have in its list for that IRQ.

The majority of the actual work of your driver happens at the "second-level handler," which is what you scheduled. It is executed "promptly," but not immediately, by the dispatcher ... and at that point, interrupts are enabled again.

"Use the Source, Luke!" There are literally hundreds of device drivers out there, and one of them has got to be "sufficiently close to whatever-it-is that you are trying to do here" that you can basically steal from it. (Just be sure that the example that you're looking at is recent, and that it corresponds to your particular kernel-version/distro, since the low-level "plumbing" at this level of Linux has evolved over these many years.)

Last edited by sundialsvcs; 09-05-2013 at 09:05 AM.
 
2 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How prevent lighttpd sharing persistent sockets for different requests arm embedded golden_boy615 Linux - Embedded & Single-board computer 0 04-03-2012 06:21 AM
Interrupts elico Linux - Newbie 1 02-20-2012 02:21 AM
Can anyone please explain about "Function call interrupts" entry in /proc/interrupts? cyclops.xmen Linux - Software 2 12-09-2009 12:13 PM
Interrupts mrchsreddy Linux - Newbie 2 11-18-2008 06:27 PM
about interrupts eshwar_ind Programming 1 02-25-2004 12:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 12:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration