1-
1+ ===========
22VGA Arbiter
33===========
44
@@ -19,21 +19,8 @@ control bus resources. Therefore an arbitration scheme outside of the X server
1919is needed to control the sharing of these resources. This document introduces
2020the operation of the VGA arbiter implemented for the Linux kernel.
2121
22- ----------------------------------------------------------------------------
23-
24- I. Details and Theory of Operation
25- I.1 vgaarb
26- I.2 libpciaccess
27- I.3 xf86VGAArbiter (X server implementation)
28- II. Credits
29- III.References
30-
31-
32- I. Details and Theory of Operation
33- ==================================
34-
35- I.1 vgaarb
36- ----------
22+ vgaarb kernel/userspace ABI
23+ ---------------------------
3724
3825The vgaarb is a module of the Linux Kernel. When it is initially loaded, it
3926scans all PCI devices and adds the VGA ones inside the arbitration. The
@@ -44,42 +31,52 @@ explicitly tell it by calling vga_set_legacy_decoding().
4431The kernel exports a char device interface (/dev/vga_arbiter) to the clients,
4532which has the following semantics:
4633
47- open : open user instance of the arbiter. By default, it's attached to
48- the default VGA device of the system.
49-
50- close : close user instance. Release locks made by the user
51-
52- read : return a string indicating the status of the target like:
53-
54- "<card_ID>,decodes=<io_state>,owns=<io_state>,locks=<io_state> (ic,mc)"
55-
56- An IO state string is of the form {io,mem,io+mem,none}, mc and
57- ic are respectively mem and io lock counts (for debugging/
58- diagnostic only). "decodes" indicate what the card currently
59- decodes, "owns" indicates what is currently enabled on it, and
60- "locks" indicates what is locked by this card. If the card is
61- unplugged, we get "invalid" then for card_ID and an -ENODEV
62- error is returned for any command until a new card is targeted.
63-
64-
65- write : write a command to the arbiter. List of commands:
66-
67- target <card_ID> : switch target to card <card_ID> (see below)
68- lock <io_state> : acquires locks on target ("none" is an invalid io_state)
69- trylock <io_state> : non-blocking acquire locks on target (returns EBUSY if
70- unsuccessful)
71- unlock <io_state> : release locks on target
72- unlock all : release all locks on target held by this user (not
73- implemented yet)
74- decodes <io_state> : set the legacy decoding attributes for the card
75-
76- poll : event if something changes on any card (not just the
77- target)
78-
79- card_ID is of the form "PCI:domain:bus:dev.fn". It can be set to "default"
80- to go back to the system default card (TODO: not implemented yet). Currently,
81- only PCI is supported as a prefix, but the userland API may support other bus
82- types in the future, even if the current kernel implementation doesn't.
34+ open
35+ Opens a user instance of the arbiter. By default, it's attached to the
36+ default VGA device of the system.
37+
38+ close
39+ Close a user instance. Release locks made by the user
40+
41+ read
42+ Return a string indicating the status of the target like:
43+
44+ "<card_ID>,decodes=<io_state>,owns=<io_state>,locks=<io_state> (ic,mc)"
45+
46+ An IO state string is of the form {io,mem,io+mem,none}, mc and
47+ ic are respectively mem and io lock counts (for debugging/
48+ diagnostic only). "decodes" indicate what the card currently
49+ decodes, "owns" indicates what is currently enabled on it, and
50+ "locks" indicates what is locked by this card. If the card is
51+ unplugged, we get "invalid" then for card_ID and an -ENODEV
52+ error is returned for any command until a new card is targeted.
53+
54+
55+ write
56+ Write a command to the arbiter. List of commands:
57+
58+ target <card_ID>
59+ switch target to card <card_ID> (see below)
60+ lock <io_state>
61+ acquires locks on target ("none" is an invalid io_state)
62+ trylock <io_state>
63+ non-blocking acquire locks on target (returns EBUSY if
64+ unsuccessful)
65+ unlock <io_state>
66+ release locks on target
67+ unlock all
68+ release all locks on target held by this user (not implemented
69+ yet)
70+ decodes <io_state>
71+ set the legacy decoding attributes for the card
72+
73+ poll
74+ event if something changes on any card (not just the target)
75+
76+ card_ID is of the form "PCI:domain: bus:dev.fn". It can be set to "default"
77+ to go back to the system default card (TODO: not implemented yet). Currently,
78+ only PCI is supported as a prefix, but the userland API may support other bus
79+ types in the future, even if the current kernel implementation doesn't.
8380
8481Note about locks:
8582
@@ -97,29 +94,35 @@ in the arbiter.
9794There is also an in-kernel API of the arbiter in case DRM, vgacon, or other
9895drivers want to use it.
9996
97+ In-kernel interface
98+ -------------------
99+
100+ .. kernel-doc :: include/linux/vgaarb.h
101+ :internal:
100102
101- I.2 libpciaccess
102- ----------------
103+ .. kernel-doc :: drivers/gpu/vga/vgaarb.c
104+ :export:
105+
106+ libpciaccess
107+ ------------
103108
104109To use the vga arbiter char device it was implemented an API inside the
105110libpciaccess library. One field was added to struct pci_device (each device
106- on the system):
111+ on the system)::
107112
108113 /* the type of resource decoded by the device */
109114 int vgaarb_rsrc;
110115
111- Besides it, in pci_system were added:
116+ Besides it, in pci_system were added::
112117
113118 int vgaarb_fd;
114119 int vga_count;
115120 struct pci_device *vga_target;
116121 struct pci_device *vga_default_dev;
117122
118-
119123The vga_count is used to track how many cards are being arbitrated, so for
120124instance, if there is only one card, then it can completely escape arbitration.
121125
122-
123126These functions below acquire VGA resources for the given card and mark those
124127resources as locked. If the resources requested are "normal" (and not legacy)
125128resources, the arbiter will first check whether the card is doing legacy
@@ -136,44 +139,44 @@ VGA memory and IO afaik). If the card already owns the resources, the function
136139succeeds. vga_arb_trylock() will return (-EBUSY) instead of blocking. Nested
137140calls are supported (a per-resource counter is maintained).
138141
142+ Set the target device of this client. ::
139143
140- Set the target device of this client.
141144 int pci_device_vgaarb_set_target (struct pci_device *dev);
142145
143-
144146For instance, in x86 if two devices on the same bus want to lock different
145147resources, both will succeed (lock). If devices are in different buses and
146- trying to lock different resources, only the first who tried succeeds.
148+ trying to lock different resources, only the first who tried succeeds. ::
149+
147150 int pci_device_vgaarb_lock (void);
148151 int pci_device_vgaarb_trylock (void);
149152
150- Unlock resources of device.
153+ Unlock resources of device. ::
154+
151155 int pci_device_vgaarb_unlock (void);
152156
153157Indicates to the arbiter if the card decodes legacy VGA IOs, legacy VGA
154158Memory, both, or none. All cards default to both, the card driver (fbdev for
155159example) should tell the arbiter if it has disabled legacy decoding, so the
156160card can be left out of the arbitration process (and can be safe to take
157- interrupts at any time.
161+ interrupts at any time. ::
162+
158163 int pci_device_vgaarb_decodes (int new_vgaarb_rsrc);
159164
160- Connects to the arbiter device, allocates the struct
161- int pci_device_vgaarb_init (void);
165+ Connects to the arbiter device, allocates the struct ::
162166
163- Close the connection
164- void pci_device_vgaarb_fini (void);
167+ int pci_device_vgaarb_init (void);
165168
169+ Close the connection ::
166170
167- I.3 xf86VGAArbiter (X server implementation)
168- --------------------------------------------
171+ void pci_device_vgaarb_fini (void);
169172
170- (TODO)
173+ xf86VGAArbiter (X server implementation)
174+ ----------------------------------------
171175
172176X server basically wraps all the functions that touch VGA registers somehow.
173177
174-
175- II. Credits
176- ===========
178+ References
179+ ----------
177180
178181Benjamin Herrenschmidt (IBM?) started this work when he discussed such design
179182with the Xorg community in 2005 [1, 2]. In the end of 2007, Paulo Zanoni and
@@ -182,11 +185,7 @@ enhancing the kernel code to adapt as a kernel module and also did the
182185implementation of the user space side [3]. Now (2009) Tiago Vignatti and Dave
183186Airlie finally put this work in shape and queued to Jesse Barnes' PCI tree.
184187
185-
186- III. References
187- ==============
188-
189- [0] http://cgit.freedesktop.org/xorg/xserver/commit/?id=4b42448a2388d40f257774fbffdccaea87bd0347
190- [1] http://lists.freedesktop.org/archives/xorg/2005-March/006663.html
191- [2] http://lists.freedesktop.org/archives/xorg/2005-March/006745.html
192- [3] http://lists.freedesktop.org/archives/xorg/2007-October/029507.html
188+ 0) http://cgit.freedesktop.org/xorg/xserver/commit/?id=4b42448a2388d40f257774fbffdccaea87bd0347
189+ 1) http://lists.freedesktop.org/archives/xorg/2005-March/006663.html
190+ 2) http://lists.freedesktop.org/archives/xorg/2005-March/006745.html
191+ 3) http://lists.freedesktop.org/archives/xorg/2007-October/029507.html
0 commit comments