linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
To: Matt Porter <mporter@kernel.crashing.org>
Cc: Matthew Wilcox <willy@debian.org>,
	Jeff Garzik <jgarzik@pobox.com>,
	linux-kernel@vger.kernel.org, davem@redhat.com
Subject: Re: Message Signalled Interrupt support?
Date: Tue, 13 May 2003 15:21:26 +0400	[thread overview]
Message-ID: <20030513152126.A16419@jurassic.park.msu.ru> (raw)
In-Reply-To: <20030512114851.B23510@home.com>; from mporter@kernel.crashing.org on Mon, May 12, 2003 at 11:48:51AM -0700

On Mon, May 12, 2003 at 11:48:51AM -0700, Matt Porter wrote:
> request_msi() needs an additional parameter to specify which MSI
> it is hooking.  A device can implement many messages in order to
> clarify which one of many events on a device has occurred.  It
> may be desired to hook a separate handler for each of those to
> avoid another read of a status register.

Assuming that platform specific PCI setup does reasonable real to virtual
IRQ mapping, request_msi() is not needed. We can use pdev->irq
as "base" vector and MSI message number as offset. Alpha works this
way, BTW.

I think of something like this:
/**
 * pci_using_msi - is this PCI device configured to use MSI?
 * @dev: PCI device structure of device being queried
 *
 * Tells whether or not a PCI device is configured to use Message Signaled
 * Interrupts. Returns number of allocated MSI messages, else 0.
 */
int
pci_using_msi(struct pci_dev *dev)
{
	int msi = pci_find_capability(dev, PCI_CAP_ID_MSI);
	u8 msgctl;

	if (!msi || !dev->irq)
		return 0;

	pci_read_config_byte(dev, msi + PCI_MSI_FLAGS, &msgctl);

	if (!(msgctl & PCI_MSI_FLAGS_ENABLE))
		return 0;
	
	return 1 << ((msgctl >> 4) & 7); /* # of messages allocated */
}

So that MSI-aware driver can do

	nummsgs = pci_using_msi(dev);
	if (!nummsgs)
		goto no_msi;
	for (msg = 0; msg < nummsgs; msg++) {
		...
		request_irq(dev->irq + msg, ...);
	}

Ivan.

  reply	other threads:[~2003-05-13 11:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-12 16:32 Message Signalled Interrupt support? Jeff Garzik
2003-05-12 16:53 ` Matthew Wilcox
2003-05-12 17:20   ` David S. Miller
2003-05-12 18:54     ` Mika Penttilä
2003-05-12 17:43   ` Matt Porter
2003-05-12 18:20     ` Matthew Wilcox
2003-05-12 18:48       ` Matt Porter
2003-05-13 11:21         ` Ivan Kokshaysky [this message]
2003-05-12 17:26 Chuck Ebbert
2003-05-12 17:53 Nakajima, Jun
2003-05-12 18:26 Nakajima, Jun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030513152126.A16419@jurassic.park.msu.ru \
    --to=ink@jurassic.park.msu.ru \
    --cc=davem@redhat.com \
    --cc=jgarzik@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mporter@kernel.crashing.org \
    --cc=willy@debian.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).