diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-16 10:49:54 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-16 10:49:54 -0400 |
commit | 4406c56d0a4da7a37b9180abeaece6cd00bcc874 (patch) | |
tree | 65a85fa73a25d24cbed6d163fdcf8df1b934a0be /Documentation | |
parent | 6b7b352f2102e21f9d8f38e932f01d9c5705c073 (diff) | |
parent | 5e3573db2bd5db6925159279d99576a4635bdb66 (diff) |
Merge branch 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6
* 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6: (75 commits)
PCI hotplug: clean up acpi_run_hpp()
PCI hotplug: acpiphp: use generic pci_configure_slot()
PCI hotplug: shpchp: use generic pci_configure_slot()
PCI hotplug: pciehp: use generic pci_configure_slot()
PCI hotplug: add pci_configure_slot()
PCI hotplug: clean up acpi_get_hp_params_from_firmware() interface
PCI hotplug: acpiphp: don't cache hotplug_params in acpiphp_bridge
PCI hotplug: acpiphp: remove superfluous _HPP/_HPX evaluation
PCI: Clear saved_state after the state has been restored
PCI PM: Return error codes from pci_pm_resume()
PCI: use dev_printk in quirk messages
PCI / PCIe portdrv: Fix pcie_portdrv_slot_reset()
PCI Hotplug: convert acpi_pci_detect_ejectable() to take an acpi_handle
PCI Hotplug: acpiphp: find bridges the easy way
PCI: pcie portdrv: remove unused variable
PCI / ACPI PM: Propagate wake-up enable for devices w/o ACPI support
ACPI PM: Replace wakeup.prepared with reference counter
PCI PM: Introduce device flag wakeup_prepared
PCI / ACPI PM: Rework some debug messages
PCI PM: Simplify PCI wake-up code
...
Fixed up conflict in arch/powerpc/kernel/pci_64.c due to OF device tree
scanning having been moved and merged for the 32- and 64-bit cases. The
'needs_freset' initialization added in 6e19314cc ("PCI/powerpc: support
PCIe fundamental reset") is now in arch/powerpc/kernel/pci_of_scan.c.
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/ABI/testing/sysfs-bus-pci | 10 | ||||
-rw-r--r-- | Documentation/PCI/pci-error-recovery.txt | 119 | ||||
-rw-r--r-- | Documentation/vgaarbiter.txt | 194 |
3 files changed, 281 insertions, 42 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-pci b/Documentation/ABI/testing/sysfs-bus-pci index 6bf68053e4b8..25be3250f7d6 100644 --- a/Documentation/ABI/testing/sysfs-bus-pci +++ b/Documentation/ABI/testing/sysfs-bus-pci | |||
@@ -84,6 +84,16 @@ Description: | |||
84 | from this part of the device tree. | 84 | from this part of the device tree. |
85 | Depends on CONFIG_HOTPLUG. | 85 | Depends on CONFIG_HOTPLUG. |
86 | 86 | ||
87 | What: /sys/bus/pci/devices/.../reset | ||
88 | Date: July 2009 | ||
89 | Contact: Michael S. Tsirkin <mst@redhat.com> | ||
90 | Description: | ||
91 | Some devices allow an individual function to be reset | ||
92 | without affecting other functions in the same device. | ||
93 | For devices that have this support, a file named reset | ||
94 | will be present in sysfs. Writing 1 to this file | ||
95 | will perform reset. | ||
96 | |||
87 | What: /sys/bus/pci/devices/.../vpd | 97 | What: /sys/bus/pci/devices/.../vpd |
88 | Date: February 2008 | 98 | Date: February 2008 |
89 | Contact: Ben Hutchings <bhutchings@solarflare.com> | 99 | Contact: Ben Hutchings <bhutchings@solarflare.com> |
diff --git a/Documentation/PCI/pci-error-recovery.txt b/Documentation/PCI/pci-error-recovery.txt index 6650af432523..e83f2ea76415 100644 --- a/Documentation/PCI/pci-error-recovery.txt +++ b/Documentation/PCI/pci-error-recovery.txt | |||
@@ -4,15 +4,17 @@ | |||
4 | February 2, 2006 | 4 | February 2, 2006 |
5 | 5 | ||
6 | Current document maintainer: | 6 | Current document maintainer: |
7 | Linas Vepstas <linas@austin.ibm.com> | 7 | Linas Vepstas <linasvepstas@gmail.com> |
8 | updated by Richard Lary <rlary@us.ibm.com> | ||
9 | and Mike Mason <mmlnx@us.ibm.com> on 27-Jul-2009 | ||
8 | 10 | ||
9 | 11 | ||
10 | Many PCI bus controllers are able to detect a variety of hardware | 12 | Many PCI bus controllers are able to detect a variety of hardware |
11 | PCI errors on the bus, such as parity errors on the data and address | 13 | PCI errors on the bus, such as parity errors on the data and address |
12 | busses, as well as SERR and PERR errors. Some of the more advanced | 14 | busses, as well as SERR and PERR errors. Some of the more advanced |
13 | chipsets are able to deal with these errors; these include PCI-E chipsets, | 15 | chipsets are able to deal with these errors; these include PCI-E chipsets, |
14 | and the PCI-host bridges found on IBM Power4 and Power5-based pSeries | 16 | and the PCI-host bridges found on IBM Power4, Power5 and Power6-based |
15 | boxes. A typical action taken is to disconnect the affected device, | 17 | pSeries boxes. A typical action taken is to disconnect the affected device, |
16 | halting all I/O to it. The goal of a disconnection is to avoid system | 18 | halting all I/O to it. The goal of a disconnection is to avoid system |
17 | corruption; for example, to halt system memory corruption due to DMA's | 19 | corruption; for example, to halt system memory corruption due to DMA's |
18 | to "wild" addresses. Typically, a reconnection mechanism is also | 20 | to "wild" addresses. Typically, a reconnection mechanism is also |
@@ -37,10 +39,11 @@ is forced by the need to handle multi-function devices, that is, | |||
37 | devices that have multiple device drivers associated with them. | 39 | devices that have multiple device drivers associated with them. |
38 | In the first stage, each driver is allowed to indicate what type | 40 | In the first stage, each driver is allowed to indicate what type |
39 | of reset it desires, the choices being a simple re-enabling of I/O | 41 | of reset it desires, the choices being a simple re-enabling of I/O |
40 | or requesting a hard reset (a full electrical #RST of the PCI card). | 42 | or requesting a slot reset. |
41 | If any driver requests a full reset, that is what will be done. | ||
42 | 43 | ||
43 | After a full reset and/or a re-enabling of I/O, all drivers are | 44 | If any driver requests a slot reset, that is what will be done. |
45 | |||
46 | After a reset and/or a re-enabling of I/O, all drivers are | ||
44 | again notified, so that they may then perform any device setup/config | 47 | again notified, so that they may then perform any device setup/config |
45 | that may be required. After these have all completed, a final | 48 | that may be required. After these have all completed, a final |
46 | "resume normal operations" event is sent out. | 49 | "resume normal operations" event is sent out. |
@@ -101,7 +104,7 @@ if it implements any, it must implement error_detected(). If a callback | |||
101 | is not implemented, the corresponding feature is considered unsupported. | 104 | is not implemented, the corresponding feature is considered unsupported. |
102 | For example, if mmio_enabled() and resume() aren't there, then it | 105 | For example, if mmio_enabled() and resume() aren't there, then it |
103 | is assumed that the driver is not doing any direct recovery and requires | 106 | is assumed that the driver is not doing any direct recovery and requires |
104 | a reset. If link_reset() is not implemented, the card is assumed as | 107 | a slot reset. If link_reset() is not implemented, the card is assumed to |
105 | not care about link resets. Typically a driver will want to know about | 108 | not care about link resets. Typically a driver will want to know about |
106 | a slot_reset(). | 109 | a slot_reset(). |
107 | 110 | ||
@@ -111,7 +114,7 @@ sequence described below. | |||
111 | 114 | ||
112 | STEP 0: Error Event | 115 | STEP 0: Error Event |
113 | ------------------- | 116 | ------------------- |
114 | PCI bus error is detect by the PCI hardware. On powerpc, the slot | 117 | A PCI bus error is detected by the PCI hardware. On powerpc, the slot |
115 | is isolated, in that all I/O is blocked: all reads return 0xffffffff, | 118 | is isolated, in that all I/O is blocked: all reads return 0xffffffff, |
116 | all writes are ignored. | 119 | all writes are ignored. |
117 | 120 | ||
@@ -139,7 +142,7 @@ The driver must return one of the following result codes: | |||
139 | a chance to extract some diagnostic information (see | 142 | a chance to extract some diagnostic information (see |
140 | mmio_enable, below). | 143 | mmio_enable, below). |
141 | - PCI_ERS_RESULT_NEED_RESET: | 144 | - PCI_ERS_RESULT_NEED_RESET: |
142 | Driver returns this if it can't recover without a hard | 145 | Driver returns this if it can't recover without a |
143 | slot reset. | 146 | slot reset. |
144 | - PCI_ERS_RESULT_DISCONNECT: | 147 | - PCI_ERS_RESULT_DISCONNECT: |
145 | Driver returns this if it doesn't want to recover at all. | 148 | Driver returns this if it doesn't want to recover at all. |
@@ -169,11 +172,11 @@ is STEP 6 (Permanent Failure). | |||
169 | 172 | ||
170 | >>> The current powerpc implementation doesn't much care if the device | 173 | >>> The current powerpc implementation doesn't much care if the device |
171 | >>> attempts I/O at this point, or not. I/O's will fail, returning | 174 | >>> attempts I/O at this point, or not. I/O's will fail, returning |
172 | >>> a value of 0xff on read, and writes will be dropped. If the device | 175 | >>> a value of 0xff on read, and writes will be dropped. If more than |
173 | >>> driver attempts more than 10K I/O's to a frozen adapter, it will | 176 | >>> EEH_MAX_FAILS I/O's are attempted to a frozen adapter, EEH |
174 | >>> assume that the device driver has gone into an infinite loop, and | 177 | >>> assumes that the device driver has gone into an infinite loop |
175 | >>> it will panic the kernel. There doesn't seem to be any other | 178 | >>> and prints an error to syslog. A reboot is then required to |
176 | >>> way of stopping a device driver that insists on spinning on I/O. | 179 | >>> get the device working again. |
177 | 180 | ||
178 | STEP 2: MMIO Enabled | 181 | STEP 2: MMIO Enabled |
179 | ------------------- | 182 | ------------------- |
@@ -182,15 +185,14 @@ DMA), and then calls the mmio_enabled() callback on all affected | |||
182 | device drivers. | 185 | device drivers. |
183 | 186 | ||
184 | This is the "early recovery" call. IOs are allowed again, but DMA is | 187 | This is the "early recovery" call. IOs are allowed again, but DMA is |
185 | not (hrm... to be discussed, I prefer not), with some restrictions. This | 188 | not, with some restrictions. This is NOT a callback for the driver to |
186 | is NOT a callback for the driver to start operations again, only to | 189 | start operations again, only to peek/poke at the device, extract diagnostic |
187 | peek/poke at the device, extract diagnostic information, if any, and | 190 | information, if any, and eventually do things like trigger a device local |
188 | eventually do things like trigger a device local reset or some such, | 191 | reset or some such, but not restart operations. This callback is made if |
189 | but not restart operations. This is callback is made if all drivers on | 192 | all drivers on a segment agree that they can try to recover and if no automatic |
190 | a segment agree that they can try to recover and if no automatic link reset | 193 | link reset was performed by the HW. If the platform can't just re-enable IOs |
191 | was performed by the HW. If the platform can't just re-enable IOs without | 194 | without a slot reset or a link reset, it will not call this callback, and |
192 | a slot reset or a link reset, it wont call this callback, and instead | 195 | instead will have gone directly to STEP 3 (Link Reset) or STEP 4 (Slot Reset) |
193 | will have gone directly to STEP 3 (Link Reset) or STEP 4 (Slot Reset) | ||
194 | 196 | ||
195 | >>> The following is proposed; no platform implements this yet: | 197 | >>> The following is proposed; no platform implements this yet: |
196 | >>> Proposal: All I/O's should be done _synchronously_ from within | 198 | >>> Proposal: All I/O's should be done _synchronously_ from within |
@@ -228,9 +230,6 @@ proceeds to either STEP3 (Link Reset) or to STEP 5 (Resume Operations). | |||
228 | If any driver returned PCI_ERS_RESULT_NEED_RESET, then the platform | 230 | If any driver returned PCI_ERS_RESULT_NEED_RESET, then the platform |
229 | proceeds to STEP 4 (Slot Reset) | 231 | proceeds to STEP 4 (Slot Reset) |
230 | 232 | ||
231 | >>> The current powerpc implementation does not implement this callback. | ||
232 | |||
233 | |||
234 | STEP 3: Link Reset | 233 | STEP 3: Link Reset |
235 | ------------------ | 234 | ------------------ |
236 | The platform resets the link, and then calls the link_reset() callback | 235 | The platform resets the link, and then calls the link_reset() callback |
@@ -253,16 +252,33 @@ The platform then proceeds to either STEP 4 (Slot Reset) or STEP 5 | |||
253 | 252 | ||
254 | >>> The current powerpc implementation does not implement this callback. | 253 | >>> The current powerpc implementation does not implement this callback. |
255 | 254 | ||
256 | |||
257 | STEP 4: Slot Reset | 255 | STEP 4: Slot Reset |
258 | ------------------ | 256 | ------------------ |
259 | The platform performs a soft or hard reset of the device, and then | ||
260 | calls the slot_reset() callback. | ||
261 | 257 | ||
262 | A soft reset consists of asserting the adapter #RST line and then | 258 | In response to a return value of PCI_ERS_RESULT_NEED_RESET, the |
259 | the platform will peform a slot reset on the requesting PCI device(s). | ||
260 | The actual steps taken by a platform to perform a slot reset | ||
261 | will be platform-dependent. Upon completion of slot reset, the | ||
262 | platform will call the device slot_reset() callback. | ||
263 | |||
264 | Powerpc platforms implement two levels of slot reset: | ||
265 | soft reset(default) and fundamental(optional) reset. | ||
266 | |||
267 | Powerpc soft reset consists of asserting the adapter #RST line and then | ||
263 | restoring the PCI BAR's and PCI configuration header to a state | 268 | restoring the PCI BAR's and PCI configuration header to a state |
264 | that is equivalent to what it would be after a fresh system | 269 | that is equivalent to what it would be after a fresh system |
265 | power-on followed by power-on BIOS/system firmware initialization. | 270 | power-on followed by power-on BIOS/system firmware initialization. |
271 | Soft reset is also known as hot-reset. | ||
272 | |||
273 | Powerpc fundamental reset is supported by PCI Express cards only | ||
274 | and results in device's state machines, hardware logic, port states and | ||
275 | configuration registers to initialize to their default conditions. | ||
276 | |||
277 | For most PCI devices, a soft reset will be sufficient for recovery. | ||
278 | Optional fundamental reset is provided to support a limited number | ||
279 | of PCI Express PCI devices for which a soft reset is not sufficient | ||
280 | for recovery. | ||
281 | |||
266 | If the platform supports PCI hotplug, then the reset might be | 282 | If the platform supports PCI hotplug, then the reset might be |
267 | performed by toggling the slot electrical power off/on. | 283 | performed by toggling the slot electrical power off/on. |
268 | 284 | ||
@@ -274,10 +290,12 @@ may result in hung devices, kernel panics, or silent data corruption. | |||
274 | 290 | ||
275 | This call gives drivers the chance to re-initialize the hardware | 291 | This call gives drivers the chance to re-initialize the hardware |
276 | (re-download firmware, etc.). At this point, the driver may assume | 292 | (re-download firmware, etc.). At this point, the driver may assume |
277 | that he card is in a fresh state and is fully functional. In | 293 | that the card is in a fresh state and is fully functional. The slot |
278 | particular, interrupt generation should work normally. | 294 | is unfrozen and the driver has full access to PCI config space, |
295 | memory mapped I/O space and DMA. Interrupts (Legacy, MSI, or MSI-X) | ||
296 | will also be available. | ||
279 | 297 | ||
280 | Drivers should not yet restart normal I/O processing operations | 298 | Drivers should not restart normal I/O processing operations |
281 | at this point. If all device drivers report success on this | 299 | at this point. If all device drivers report success on this |
282 | callback, the platform will call resume() to complete the sequence, | 300 | callback, the platform will call resume() to complete the sequence, |
283 | and let the driver restart normal I/O processing. | 301 | and let the driver restart normal I/O processing. |
@@ -302,11 +320,21 @@ driver performs device init only from PCI function 0: | |||
302 | - PCI_ERS_RESULT_DISCONNECT | 320 | - PCI_ERS_RESULT_DISCONNECT |
303 | Same as above. | 321 | Same as above. |
304 | 322 | ||
323 | Drivers for PCI Express cards that require a fundamental reset must | ||
324 | set the needs_freset bit in the pci_dev structure in their probe function. | ||
325 | For example, the QLogic qla2xxx driver sets the needs_freset bit for certain | ||
326 | PCI card types: | ||
327 | |||
328 | + /* Set EEH reset type to fundamental if required by hba */ | ||
329 | + if (IS_QLA24XX(ha) || IS_QLA25XX(ha) || IS_QLA81XX(ha)) | ||
330 | + pdev->needs_freset = 1; | ||
331 | + | ||
332 | |||
305 | Platform proceeds either to STEP 5 (Resume Operations) or STEP 6 (Permanent | 333 | Platform proceeds either to STEP 5 (Resume Operations) or STEP 6 (Permanent |
306 | Failure). | 334 | Failure). |
307 | 335 | ||
308 | >>> The current powerpc implementation does not currently try a | 336 | >>> The current powerpc implementation does not try a power-cycle |
309 | >>> power-cycle reset if the driver returned PCI_ERS_RESULT_DISCONNECT. | 337 | >>> reset if the driver returned PCI_ERS_RESULT_DISCONNECT. |
310 | >>> However, it probably should. | 338 | >>> However, it probably should. |
311 | 339 | ||
312 | 340 | ||
@@ -348,7 +376,7 @@ software errors. | |||
348 | 376 | ||
349 | Conclusion; General Remarks | 377 | Conclusion; General Remarks |
350 | --------------------------- | 378 | --------------------------- |
351 | The way those callbacks are called is platform policy. A platform with | 379 | The way the callbacks are called is platform policy. A platform with |
352 | no slot reset capability may want to just "ignore" drivers that can't | 380 | no slot reset capability may want to just "ignore" drivers that can't |
353 | recover (disconnect them) and try to let other cards on the same segment | 381 | recover (disconnect them) and try to let other cards on the same segment |
354 | recover. Keep in mind that in most real life cases, though, there will | 382 | recover. Keep in mind that in most real life cases, though, there will |
@@ -361,8 +389,8 @@ That is, the recovery API only requires that: | |||
361 | 389 | ||
362 | - There is no guarantee that interrupt delivery can proceed from any | 390 | - There is no guarantee that interrupt delivery can proceed from any |
363 | device on the segment starting from the error detection and until the | 391 | device on the segment starting from the error detection and until the |
364 | resume callback is sent, at which point interrupts are expected to be | 392 | slot_reset callback is called, at which point interrupts are expected |
365 | fully operational. | 393 | to be fully operational. |
366 | 394 | ||
367 | - There is no guarantee that interrupt delivery is stopped, that is, | 395 | - There is no guarantee that interrupt delivery is stopped, that is, |
368 | a driver that gets an interrupt after detecting an error, or that detects | 396 | a driver that gets an interrupt after detecting an error, or that detects |
@@ -381,16 +409,23 @@ anyway :) | |||
381 | >>> Implementation details for the powerpc platform are discussed in | 409 | >>> Implementation details for the powerpc platform are discussed in |
382 | >>> the file Documentation/powerpc/eeh-pci-error-recovery.txt | 410 | >>> the file Documentation/powerpc/eeh-pci-error-recovery.txt |
383 | 411 | ||
384 | >>> As of this writing, there are six device drivers with patches | 412 | >>> As of this writing, there is a growing list of device drivers with |
385 | >>> implementing error recovery. Not all of these patches are in | 413 | >>> patches implementing error recovery. Not all of these patches are in |
386 | >>> mainline yet. These may be used as "examples": | 414 | >>> mainline yet. These may be used as "examples": |
387 | >>> | 415 | >>> |
388 | >>> drivers/scsi/ipr.c | 416 | >>> drivers/scsi/ipr |
389 | >>> drivers/scsi/sym53cxx_2 | 417 | >>> drivers/scsi/sym53c8xx_2 |
418 | >>> drivers/scsi/qla2xxx | ||
419 | >>> drivers/scsi/lpfc | ||
420 | >>> drivers/next/bnx2.c | ||
390 | >>> drivers/next/e100.c | 421 | >>> drivers/next/e100.c |
391 | >>> drivers/net/e1000 | 422 | >>> drivers/net/e1000 |
423 | >>> drivers/net/e1000e | ||
392 | >>> drivers/net/ixgb | 424 | >>> drivers/net/ixgb |
425 | >>> drivers/net/ixgbe | ||
426 | >>> drivers/net/cxgb3 | ||
393 | >>> drivers/net/s2io.c | 427 | >>> drivers/net/s2io.c |
428 | >>> drivers/net/qlge | ||
394 | 429 | ||
395 | The End | 430 | The End |
396 | ------- | 431 | ------- |
diff --git a/Documentation/vgaarbiter.txt b/Documentation/vgaarbiter.txt new file mode 100644 index 000000000000..987f9b0a5ece --- /dev/null +++ b/Documentation/vgaarbiter.txt | |||
@@ -0,0 +1,194 @@ | |||
1 | |||
2 | VGA Arbiter | ||
3 | =========== | ||
4 | |||
5 | Graphic devices are accessed through ranges in I/O or memory space. While most | ||
6 | modern devices allow relocation of such ranges, some "Legacy" VGA devices | ||
7 | implemented on PCI will typically have the same "hard-decoded" addresses as | ||
8 | they did on ISA. For more details see "PCI Bus Binding to IEEE Std 1275-1994 | ||
9 | Standard for Boot (Initialization Configuration) Firmware Revision 2.1" | ||
10 | Section 7, Legacy Devices. | ||
11 | |||
12 | The Resource Access Control (RAC) module inside the X server [0] existed for | ||
13 | the legacy VGA arbitration task (besides other bus management tasks) when more | ||
14 | than one legacy device co-exists on the same machine. But the problem happens | ||
15 | when these devices are trying to be accessed by different userspace clients | ||
16 | (e.g. two server in parallel). Their address assignments conflict. Moreover, | ||
17 | ideally, being an userspace application, it is not the role of the the X | ||
18 | server to control bus resources. Therefore an arbitration scheme outside of | ||
19 | the X server is needed to control the sharing of these resources. This | ||
20 | document introduces the operation of the VGA arbiter implemented for Linux | ||
21 | kernel. | ||
22 | |||
23 | ---------------------------------------------------------------------------- | ||
24 | |||
25 | I. Details and Theory of Operation | ||
26 | I.1 vgaarb | ||
27 | I.2 libpciaccess | ||
28 | I.3 xf86VGAArbiter (X server implementation) | ||
29 | II. Credits | ||
30 | III.References | ||
31 | |||
32 | |||
33 | I. Details and Theory of Operation | ||
34 | ================================== | ||
35 | |||
36 | I.1 vgaarb | ||
37 | ---------- | ||
38 | |||
39 | The vgaarb is a module of the Linux Kernel. When it is initially loaded, it | ||
40 | scans all PCI devices and adds the VGA ones inside the arbitration. The | ||
41 | arbiter then enables/disables the decoding on different devices of the VGA | ||
42 | legacy instructions. Device which do not want/need to use the arbiter may | ||
43 | explicitly tell it by calling vga_set_legacy_decoding(). | ||
44 | |||
45 | The kernel exports a char device interface (/dev/vga_arbiter) to the clients, | ||
46 | which has the following semantics: | ||
47 | |||
48 | open : open user instance of the arbiter. By default, it's attached to | ||
49 | the default VGA device of the system. | ||
50 | |||
51 | close : close user instance. Release locks made by the user | ||
52 | |||
53 | read : return a string indicating the status of the target like: | ||
54 | |||
55 | "<card_ID>,decodes=<io_state>,owns=<io_state>,locks=<io_state> (ic,mc)" | ||
56 | |||
57 | An IO state string is of the form {io,mem,io+mem,none}, mc and | ||
58 | ic are respectively mem and io lock counts (for debugging/ | ||
59 | diagnostic only). "decodes" indicate what the card currently | ||
60 | decodes, "owns" indicates what is currently enabled on it, and | ||
61 | "locks" indicates what is locked by this card. If the card is | ||
62 | unplugged, we get "invalid" then for card_ID and an -ENODEV | ||
63 | error is returned for any command until a new card is targeted. | ||
64 | |||
65 | |||
66 | write : write a command to the arbiter. List of commands: | ||
67 | |||
68 | target <card_ID> : switch target to card <card_ID> (see below) | ||
69 | lock <io_state> : acquires locks on target ("none" is an invalid io_state) | ||
70 | trylock <io_state> : non-blocking acquire locks on target (returns EBUSY if | ||
71 | unsuccessful) | ||
72 | unlock <io_state> : release locks on target | ||
73 | unlock all : release all locks on target held by this user (not | ||
74 | implemented yet) | ||
75 | decodes <io_state> : set the legacy decoding attributes for the card | ||
76 | |||
77 | poll : event if something changes on any card (not just the | ||
78 | target) | ||
79 | |||
80 | card_ID is of the form "PCI:domain:bus:dev.fn". It can be set to "default" | ||
81 | to go back to the system default card (TODO: not implemented yet). Currently, | ||
82 | only PCI is supported as a prefix, but the userland API may support other bus | ||
83 | types in the future, even if the current kernel implementation doesn't. | ||
84 | |||
85 | Note about locks: | ||
86 | |||
87 | The driver keeps track of which user has which locks on which card. It | ||
88 | supports stacking, like the kernel one. This complexifies the implementation | ||
89 | a bit, but makes the arbiter more tolerant to user space problems and able | ||
90 | to properly cleanup in all cases when a process dies. | ||
91 | Currently, a max of 16 cards can have locks simultaneously issued from | ||
92 | user space for a given user (file descriptor instance) of the arbiter. | ||
93 | |||
94 | In the case of devices hot-{un,}plugged, there is a hook - pci_notify() - to | ||
95 | notify them being added/removed in the system and automatically added/removed | ||
96 | in the arbiter. | ||
97 | |||
98 | There's also a in-kernel API of the arbiter in the case of DRM, vgacon and | ||
99 | others which may use the arbiter. | ||
100 | |||
101 | |||
102 | I.2 libpciaccess | ||
103 | ---------------- | ||
104 | |||
105 | To use the vga arbiter char device it was implemented an API inside the | ||
106 | libpciaccess library. One fieldd was added to struct pci_device (each device | ||
107 | on the system): | ||
108 | |||
109 | /* the type of resource decoded by the device */ | ||
110 | int vgaarb_rsrc; | ||
111 | |||
112 | Besides it, in pci_system were added: | ||
113 | |||
114 | int vgaarb_fd; | ||
115 | int vga_count; | ||
116 | struct pci_device *vga_target; | ||
117 | struct pci_device *vga_default_dev; | ||
118 | |||
119 | |||
120 | The vga_count is usually need to keep informed how many cards are being | ||
121 | arbitrated, so for instance if there's only one then it can totally escape the | ||
122 | scheme. | ||
123 | |||
124 | |||
125 | These functions below acquire VGA resources for the given card and mark those | ||
126 | resources as locked. If the resources requested are "normal" (and not legacy) | ||
127 | resources, the arbiter will first check whether the card is doing legacy | ||
128 | decoding for that type of resource. If yes, the lock is "converted" into a | ||
129 | legacy resource lock. The arbiter will first look for all VGA cards that | ||
130 | might conflict and disable their IOs and/or Memory access, including VGA | ||
131 | forwarding on P2P bridges if necessary, so that the requested resources can | ||
132 | be used. Then, the card is marked as locking these resources and the IO and/or | ||
133 | Memory access is enabled on the card (including VGA forwarding on parent | ||
134 | P2P bridges if any). In the case of vga_arb_lock(), the function will block | ||
135 | if some conflicting card is already locking one of the required resources (or | ||
136 | any resource on a different bus segment, since P2P bridges don't differentiate | ||
137 | VGA memory and IO afaik). If the card already owns the resources, the function | ||
138 | succeeds. vga_arb_trylock() will return (-EBUSY) instead of blocking. Nested | ||
139 | calls are supported (a per-resource counter is maintained). | ||
140 | |||
141 | |||
142 | Set the target device of this client. | ||
143 | int pci_device_vgaarb_set_target (struct pci_device *dev); | ||
144 | |||
145 | |||
146 | For instance, in x86 if two devices on the same bus want to lock different | ||
147 | resources, both will succeed (lock). If devices are in different buses and | ||
148 | trying to lock different resources, only the first who tried succeeds. | ||
149 | int pci_device_vgaarb_lock (void); | ||
150 | int pci_device_vgaarb_trylock (void); | ||
151 | |||
152 | Unlock resources of device. | ||
153 | int pci_device_vgaarb_unlock (void); | ||
154 | |||
155 | Indicates to the arbiter if the card decodes legacy VGA IOs, legacy VGA | ||
156 | Memory, both, or none. All cards default to both, the card driver (fbdev for | ||
157 | example) should tell the arbiter if it has disabled legacy decoding, so the | ||
158 | card can be left out of the arbitration process (and can be safe to take | ||
159 | interrupts at any time. | ||
160 | int pci_device_vgaarb_decodes (int new_vgaarb_rsrc); | ||
161 | |||
162 | Connects to the arbiter device, allocates the struct | ||
163 | int pci_device_vgaarb_init (void); | ||
164 | |||
165 | Close the connection | ||
166 | void pci_device_vgaarb_fini (void); | ||
167 | |||
168 | |||
169 | I.3 xf86VGAArbiter (X server implementation) | ||
170 | -------------------------------------------- | ||
171 | |||
172 | (TODO) | ||
173 | |||
174 | X server basically wraps all the functions that touch VGA registers somehow. | ||
175 | |||
176 | |||
177 | II. Credits | ||
178 | =========== | ||
179 | |||
180 | Benjamin Herrenschmidt (IBM?) started this work when he discussed such design | ||
181 | with the Xorg community in 2005 [1, 2]. In the end of 2007, Paulo Zanoni and | ||
182 | Tiago Vignatti (both of C3SL/Federal University of Paraná) proceeded his work | ||
183 | enhancing the kernel code to adapt as a kernel module and also did the | ||
184 | implementation of the user space side [3]. Now (2009) Tiago Vignatti and Dave | ||
185 | Airlie finally put this work in shape and queued to Jesse Barnes' PCI tree. | ||
186 | |||
187 | |||
188 | III. References | ||
189 | ============== | ||
190 | |||
191 | [0] http://cgit.freedesktop.org/xorg/xserver/commit/?id=4b42448a2388d40f257774fbffdccaea87bd0347 | ||
192 | [1] http://lists.freedesktop.org/archives/xorg/2005-March/006663.html | ||
193 | [2] http://lists.freedesktop.org/archives/xorg/2005-March/006745.html | ||
194 | [3] http://lists.freedesktop.org/archives/xorg/2007-October/029507.html | ||