Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4107846
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:34:12+00:00 2026-05-20T21:34:12+00:00

I am writing a device driver to handle interrupts for a PCIe card, which

  • 0

I am writing a device driver to handle interrupts for a PCIe card, which currently works for any interrupt vector raised on the IRQ line.

But it has a few types that can be raised, flagged by the Vector register. So now I need to read the vector information and be a bit cleverer…
So, do I :-

1/ Have separate dev nodes /dev/int1, /dev/int2, etc for each interrupt type, and just doc that int1 is for vector type A etc?
1.1/ As each file/char-devices will have its own minor number, when opened I’ll know which is which. i think.
1.2/ ldd3 seems to demo this method.

2/ Have one node /dev/int (as I do now) and have multiple processes hanging off the same read method? sounds better?!
2.1/ Then only wake the correct process up…?
2.2/ Do I use separate wait_queue_head_t wait_queues? Or different flag/test conditions?

In the read method:-

    wait_event_interruptible(wait_queue, flag);

In the handler not real code! :-

    int vector = read_vector();
    if vector = A then 
        wake_up_interruptible(wait_queue, flag)
        return IRQ_HANDLED;
    else
        return IRQ_NONE/IRQ_RETVAL?

EDIT: notes from peoples comments :-
1) my user-space code mmap‘s all of the PCIe firmware registers
2) User-space code has a few threads, each perform a blocking read on the device driver device nodes, which then returns data from the firmware when an interrupt occurs. I need the correct thread woken up depending on the interrupt type.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T21:34:13+00:00Added an answer on May 20, 2026 at 9:34 pm

    I am not sure I understand correctly what you mean with the Vector register (a pointer to some documentation would help me precise for your case).

    Anyway, any PCI device gets a unique interrupt number (given by the BIOS or some firmware on other architectures than x86). You just need to register this interrupt in your driver.

    priv->name = DRV_NAME;
    err = request_irq(pdev->irq, your_irqhandler, IRQF_SHARED, priv->name,
              pdev);
    if (err) {
        dev_err(&pdev->dev, "cannot request IRQ\n");
        goto err_out_unmap;
    }
    

    One other thing that I do not really understand is why you would export your interrupts as a dev node: interrupts are certainly something that need to remain in your driver/kernel code. But I guess here you want to export a device that is then accessed in userspace. I just find /dev/int no to be a good naming.

    For your question about multiple dev nodes: if your different interrupt sources then provide access to different hardware resources (even if on the same PCI board) I would go for option 1), with a wait_queue for each device. Otherwise, I would go for option 2)

    Since your interrupts are coming from the same physical device, if you chose option 1) or option 2), the interrupt line will have to be shared and you will have to read the vector in your interrupt handler to define which hardware resource raised the interrupt.

    For option 1), it would be something like this:

    static irqreturn_t pex_irqhandler(int irq, void *dev) {
        struct pci_dev *pdev = dev;
        int result;
    
        result = pci_read_config_byte(pdev, PCI_INTERRUPT_LINE, &myirq);
    
        if (result) {
             int vector = read_vector();
             if (vector == A) {
                    set_flagA(flag);
             } else if (vector == B) {
                    set_flagB(flag);
             }
             wake_up_interruptible(wait_queue, flag);
             return IRQ_HANDLED;
        } else {
             return IRQ_NONE;
    }
    

    For option 2, it would be similar, but you would have only one if clause (for the respective vector value) in every different interrupt handler that you would request for every node.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a kernel object (.ko file, which is usually device driver) of Linux.
I wrote a char device driver and am now writing a QT wrapper which
I am writing a C# program which captures signals from a external device, and
I'm writing a device driver that is loaded by a 3rd-party driver. I need
I'm writing a driver and I want to get network counters of some device
I'm learning about the blocking I/O functions for writing linux device driver and I'm
I am writing a RFID device driver and encounter an compiling error below: [root@localhost
I'm writing a simple USB driver for our device using UMDF over WinUsb. The
I'm writing my first Linux kernel module, which actually is a RAM disk driver
I'm writing a device driver to access the memory in a FPGA on a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.