title: How does MSI interrupt work in linux driver?
body: <p>Currently working on a PCI device driver. And the device is programmed like this:<br>
  When a DMA transmission is done, the device send a MSI interrupt to PC with MSI data "001" binary.  </p>
  
  <p>Now I'm writing a driver for this pci device, and for the MSI part, I have some questions.  </p>
  
  <p>In wikipedia, it says:  </p>
  
  <blockquote>
    <p>MSI allows the device to write a small amount of interrupt-describing data to a special memory-mapped I/O address, and the chipset then delivers the corresponding interrupt to a processor.  </p>
  </blockquote>
  
  <p>Q1: So in my case, the <code>small amount of interrupt-describing data</code> is the <code>"001"</code> sent from pci device to PC?  </p>
  
  <p>In my driver code, the MSI irq is registered like this:</p>
  
  <pre><code>err = pci_enable_msi(my_pci_dev);  
  err = request_irq(my_pci_dev-&gt;irq, irq_handler, 0, "PCI_FPGA_CARD", NULL);  
  </code></pre>
  
  <p>and the <code>irq_handler</code> is defined like this:  </p>
  
  <pre><code>static irqreturn_t irq_handler(int irq, void *dev_id)  
  {  
    printk(KERN_INFO "(irq_handler):  Called\n");  
    return IRQ_HANDLED;
  }  
  </code></pre>
  
  <p>Q2: With the 3 kernel functions above, how can we get the message <code>"001"</code>?<br>
  Q3: The PCI device support up to 8 MSI vectors, so to use all those 8 vectors, which code should I use below or neither is correct:</p>
  
  <pre><code>err = pci_enable_msi_block(my_pci_dev,8);
  err = request_irq(my_pci_dev-&gt;irq, irq_handler, 0, "PCI_FPGA_CARD", NULL);
  </code></pre>
  
  <p>or</p>
  
  <pre><code>err = pci_enable_msi(my_pci_dev);
  err = request_irq(my_pci_dev-&gt;irq, irq_handler_0, 0, "PCI_FPGA_CARD", NULL);
  err = request_irq(my_pci_dev-&gt;irq, irq_handler_1, 0, "PCI_FPGA_CARD", NULL);
  err = request_irq(my_pci_dev-&gt;irq, irq_handler_2, 0, "PCI_FPGA_CARD", NULL);
  err = request_irq(my_pci_dev-&gt;irq, irq_handler_3, 0, "PCI_FPGA_CARD", NULL);
  err = request_irq(my_pci_dev-&gt;irq, irq_handler_4, 0, "PCI_FPGA_CARD", NULL);
  err = request_irq(my_pci_dev-&gt;irq, irq_handler_5, 0, "PCI_FPGA_CARD", NULL);
  err = request_irq(my_pci_dev-&gt;irq, irq_handler_6, 0, "PCI_FPGA_CARD", NULL);
  err = request_irq(my_pci_dev-&gt;irq, irq_handler_7, 0, "PCI_FPGA_CARD", NULL);
  </code></pre>
  
  <p>3 questions ~~ thx for your help.</p>