aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/PCI
diff options
context:
space:
mode:
authorMatthew Wilcox <willy@linux.intel.com>2009-03-17 08:54:05 -0400
committerJesse Barnes <jbarnes@virtuousgeek.org>2009-03-20 13:48:11 -0400
commitc41ade2ee1dc146d2de2ee470a87cd6b878a08f4 (patch)
tree28de511376f31c5b6cc84348e46408a879f7a9f4 /Documentation/PCI
parent0994375e9614f78657031e04e30019b9cdb62795 (diff)
Rewrite MSI-HOWTO
I didn't find the previous version very useful, so I rewrote it. Signed-off-by: Matthew Wilcox <willy@linux.intel.com> Reviewed-by: Randy Dunlap <randy.dunlap@oracle.com> Reviewed-by: Grant Grundler <grundler@parisc-linunx.org> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'Documentation/PCI')
-rw-r--r--Documentation/PCI/MSI-HOWTO.txt758
1 files changed, 277 insertions, 481 deletions
diff --git a/Documentation/PCI/MSI-HOWTO.txt b/Documentation/PCI/MSI-HOWTO.txt
index 256defd7e174..1c02431f1d1a 100644
--- a/Documentation/PCI/MSI-HOWTO.txt
+++ b/Documentation/PCI/MSI-HOWTO.txt
@@ -4,506 +4,302 @@
4 Revised Feb 12, 2004 by Martine Silbermann 4 Revised Feb 12, 2004 by Martine Silbermann
5 email: Martine.Silbermann@hp.com 5 email: Martine.Silbermann@hp.com
6 Revised Jun 25, 2004 by Tom L Nguyen 6 Revised Jun 25, 2004 by Tom L Nguyen
7 Revised Jul 9, 2008 by Matthew Wilcox <willy@linux.intel.com>
8 Copyright 2003, 2008 Intel Corporation
7 9
81. About this guide 101. About this guide
9 11
10This guide describes the basics of Message Signaled Interrupts (MSI), 12This guide describes the basics of Message Signaled Interrupts (MSIs),
11the advantages of using MSI over traditional interrupt mechanisms, 13the advantages of using MSI over traditional interrupt mechanisms, how
12and how to enable your driver to use MSI or MSI-X. Also included is 14to change your driver to use MSI or MSI-X and some basic diagnostics to
13a Frequently Asked Questions (FAQ) section. 15try if a device doesn't support MSIs.
14 16
151.1 Terminology 17
16 182. What are MSIs?
17PCI devices can be single-function or multi-function. In either case, 19
18when this text talks about enabling or disabling MSI on a "device 20A Message Signaled Interrupt is a write from the device to a special
19function," it is referring to one specific PCI device and function and 21address which causes an interrupt to be received by the CPU.
20not to all functions on a PCI device (unless the PCI device has only 22
21one function). 23The MSI capability was first specified in PCI 2.2 and was later enhanced
22 24in PCI 3.0 to allow each interrupt to be masked individually. The MSI-X
232. Copyright 2003 Intel Corporation 25capability was also introduced with PCI 3.0. It supports more interrupts
24 26per device than MSI and allows interrupts to be independently configured.
253. What is MSI/MSI-X? 27
26 28Devices may support both MSI and MSI-X, but only one can be enabled at
27Message Signaled Interrupt (MSI), as described in the PCI Local Bus 29a time.
28Specification Revision 2.3 or later, is an optional feature, and a 30
29required feature for PCI Express devices. MSI enables a device function 31
30to request service by sending an Inbound Memory Write on its PCI bus to 323. Why use MSIs?
31the FSB as a Message Signal Interrupt transaction. Because MSI is 33
32generated in the form of a Memory Write, all transaction conditions, 34There are three reasons why using MSIs can give an advantage over
33such as a Retry, Master-Abort, Target-Abort or normal completion, are 35traditional pin-based interrupts.
34supported. 36
35 37Pin-based PCI interrupts are often shared amongst several devices.
36A PCI device that supports MSI must also support pin IRQ assertion 38To support this, the kernel must call each interrupt handler associated
37interrupt mechanism to provide backward compatibility for systems that 39with an interrupt, which leads to reduced performance for the system as
38do not support MSI. In systems which support MSI, the bus driver is 40a whole. MSIs are never shared, so this problem cannot arise.
39responsible for initializing the message address and message data of 41
40the device function's MSI/MSI-X capability structure during device 42When a device writes data to memory, then raises a pin-based interrupt,
41initial configuration. 43it is possible that the interrupt may arrive before all the data has
42 44arrived in memory (this becomes more likely with devices behind PCI-PCI
43An MSI capable device function indicates MSI support by implementing 45bridges). In order to ensure that all the data has arrived in memory,
44the MSI/MSI-X capability structure in its PCI capability list. The 46the interrupt handler must read a register on the device which raised
45device function may implement both the MSI capability structure and 47the interrupt. PCI transaction ordering rules require that all the data
46the MSI-X capability structure; however, the bus driver should not 48arrives in memory before the value can be returned from the register.
47enable both. 49Using MSIs avoids this problem as the interrupt-generating write cannot
48 50pass the data writes, so by the time the interrupt is raised, the driver
49The MSI capability structure contains Message Control register, 51knows that all the data has arrived in memory.
50Message Address register and Message Data register. These registers 52
51provide the bus driver control over MSI. The Message Control register 53PCI devices can only support a single pin-based interrupt per function.
52indicates the MSI capability supported by the device. The Message 54Often drivers have to query the device to find out what event has
53Address register specifies the target address and the Message Data 55occurred, slowing down interrupt handling for the common case. With
54register specifies the characteristics of the message. To request 56MSIs, a device can support more interrupts, allowing each interrupt
55service, the device function writes the content of the Message Data 57to be specialised to a different purpose. One possible design gives
56register to the target address. The device and its software driver 58infrequent conditions (such as errors) their own interrupt which allows
57are prohibited from writing to these registers. 59the driver to handle the normal interrupt handling path more efficiently.
58 60Other possible designs include giving one interrupt to each packet queue
59The MSI-X capability structure is an optional extension to MSI. It 61in a network card or each port in a storage controller.
60uses an independent and separate capability structure. There are 62
61some key advantages to implementing the MSI-X capability structure 63
62over the MSI capability structure as described below. 644. How to use MSIs
63 65
64 - Support a larger maximum number of vectors per function. 66PCI devices are initialised to use pin-based interrupts. The device
65 67driver has to set up the device to use MSI or MSI-X. Not all machines
66 - Provide the ability for system software to configure 68support MSIs correctly, and for those machines, the APIs described below
67 each vector with an independent message address and message 69will simply fail and the device will continue to use pin-based interrupts.
68 data, specified by a table that resides in Memory Space. 70
69 714.1 Include kernel support for MSIs
70 - MSI and MSI-X both support per-vector masking. Per-vector 72
71 masking is an optional extension of MSI but a required 73To support MSI or MSI-X, the kernel must be built with the CONFIG_PCI_MSI
72 feature for MSI-X. Per-vector masking provides the kernel the 74option enabled. This option is only available on some architectures,
73 ability to mask/unmask a single MSI while running its 75and it may depend on some other options also being set. For example,
74 interrupt service routine. If per-vector masking is 76on x86, you must also enable X86_UP_APIC or SMP in order to see the
75 not supported, then the device driver should provide the 77CONFIG_PCI_MSI option.
76 hardware/software synchronization to ensure that the device 78
77 generates MSI when the driver wants it to do so. 794.2 Using MSI
78 80
794. Why use MSI? 81Most of the hard work is done for the driver in the PCI layer. It simply
80 82has to request that the PCI layer set up the MSI capability for this
81As a benefit to the simplification of board design, MSI allows board 83device.
82designers to remove out-of-band interrupt routing. MSI is another 84
83step towards a legacy-free environment. 854.2.1 pci_enable_msi
84
85Due to increasing pressure on chipset and processor packages to
86reduce pin count, the need for interrupt pins is expected to
87diminish over time. Devices, due to pin constraints, may implement
88messages to increase performance.
89
90PCI Express endpoints uses INTx emulation (in-band messages) instead
91of IRQ pin assertion. Using INTx emulation requires interrupt
92sharing among devices connected to the same node (PCI bridge) while
93MSI is unique (non-shared) and does not require BIOS configuration
94support. As a result, the PCI Express technology requires MSI
95support for better interrupt performance.
96
97Using MSI enables the device functions to support two or more
98vectors, which can be configured to target different CPUs to
99increase scalability.
100
1015. Configuring a driver to use MSI/MSI-X
102
103By default, the kernel will not enable MSI/MSI-X on all devices that
104support this capability. The CONFIG_PCI_MSI kernel option
105must be selected to enable MSI/MSI-X support.
106
1075.1 Including MSI/MSI-X support into the kernel
108
109To allow MSI/MSI-X capable device drivers to selectively enable
110MSI/MSI-X (using pci_enable_msi()/pci_enable_msix() as described
111below), the VECTOR based scheme needs to be enabled by setting
112CONFIG_PCI_MSI during kernel config.
113
114Since the target of the inbound message is the local APIC, providing
115CONFIG_X86_LOCAL_APIC must be enabled as well as CONFIG_PCI_MSI.
116
1175.2 Configuring for MSI support
118
119Due to the non-contiguous fashion in vector assignment of the
120existing Linux kernel, this version does not support multiple
121messages regardless of a device function is capable of supporting
122more than one vector. To enable MSI on a device function's MSI
123capability structure requires a device driver to call the function
124pci_enable_msi() explicitly.
125
1265.2.1 API pci_enable_msi
127 86
128int pci_enable_msi(struct pci_dev *dev) 87int pci_enable_msi(struct pci_dev *dev)
129 88
130With this new API, a device driver that wants to have MSI 89A successful call will allocate ONE interrupt to the device, regardless
131enabled on its device function must call this API to enable MSI. 90of how many MSIs the device supports. The device will be switched from