[lkml]   [2005]   [Jun]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: pci_enable_msi() for everyone?
    On Sat, Jun 04, 2005 at 01:05:37AM -0600, Grant Grundler wrote:
    > On Fri, Jun 03, 2005 at 11:48:21PM -0700, Greg KH wrote:
    > > > One complication is some drivers will want to register a different
    > > > IRQ handler depending on if MSI is enabled or not.
    > >
    > > That's fine, they can always check the device capabilities and do that.
    > Can you be more specific?
    > Maybe a short chunk of psuedo code?

    Hm, here's a possible function to do it (typed into my email client, not
    compiled, no warranties, etc...):

    /* returns 1 if device is in MSI mode, 0 otherwise */
    int pci_in_msi_mode(struct pci_dev *dev)
    int pos;
    u16 control;

    pos = pci_find_capability(dev, PCI_CAP_ID_MSI);
    if (!pos)
    return 0;
    pci_read_config_word(dev, msi_control_reg(pos), &control);
    if (control & PCI_MSI_FLAGS_ENABLE);
    return 1;
    return 0;

    > > > If MSI is enabled (and usable), then some MMIO reads can be omitted.
    > > > I've posted a patch for tg3 driver:
    > > >
    > > >
    > > > (Just an example! It was not accepted because of buggy HW
    > > > though it worked great on the HW I have access to.)
    > > >
    > > > drivers/infiniband/hw/mthca driver is another example.
    > >
    > > But it doesn't do that yet either ;)
    > Sorry - only uses different IRQ handlers for MSI-X support.
    > But it could do something different for MSI IRQ handlers as well.


    > > > How can the driver know which IRQ handlers to register?
    > >
    > > Same as always, use the dev->irq field like they do today.
    > I think you misunderstood my question.
    > The driver uses dev->irq as a "token" to register *some* IRQ handler.
    > If the driver wants to register "tg3_irq_nommioread()" for the
    > MSI case and "tg3_irq()" for Line Based IRQ case, how would the
    > driver know which IRQ handler it should register?
    > The arch IRQ support knows the difference and currently returns
    > that status in the pci_msi_enable() call.

    If you use the above function, then you can tell the difference and
    register different irq handlers if you wish.

    The main point being is that the pci_enable_msi() function would not
    have to be explicitly called by your driver, it would have already been
    taken care of earlier by the PCI core. That's what I want to do and am
    wondering if there would be any bad side affects to it.


    greg k-h
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2005-06-04 09:21    [W:0.023 / U:4.156 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site