~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/gpu/vgaarbiter.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /Documentation/gpu/vgaarbiter.rst (Version linux-6.12-rc7) and /Documentation/gpu/vgaarbiter.rst (Version linux-6.3.13)


  1 ===========                                         1 ===========
  2 VGA Arbiter                                         2 VGA Arbiter
  3 ===========                                         3 ===========
  4                                                     4 
  5 Graphic devices are accessed through ranges in      5 Graphic devices are accessed through ranges in I/O or memory space. While most
  6 modern devices allow relocation of such ranges      6 modern devices allow relocation of such ranges, some "Legacy" VGA devices
  7 implemented on PCI will typically have the sam      7 implemented on PCI will typically have the same "hard-decoded" addresses as
  8 they did on ISA. For more details see "PCI Bus      8 they did on ISA. For more details see "PCI Bus Binding to IEEE Std 1275-1994
  9 Standard for Boot (Initialization Configuratio      9 Standard for Boot (Initialization Configuration) Firmware Revision 2.1"
 10 Section 7, Legacy Devices.                         10 Section 7, Legacy Devices.
 11                                                    11 
 12 The Resource Access Control (RAC) module insid     12 The Resource Access Control (RAC) module inside the X server [0] existed for
 13 the legacy VGA arbitration task (besides other     13 the legacy VGA arbitration task (besides other bus management tasks) when more
 14 than one legacy device co-exists on the same m     14 than one legacy device co-exists on the same machine. But the problem happens
 15 when these devices are trying to be accessed b     15 when these devices are trying to be accessed by different userspace clients
 16 (e.g. two server in parallel). Their address a     16 (e.g. two server in parallel). Their address assignments conflict. Moreover,
 17 ideally, being a userspace application, it is      17 ideally, being a userspace application, it is not the role of the X server to
 18 control bus resources. Therefore an arbitratio     18 control bus resources. Therefore an arbitration scheme outside of the X server
 19 is needed to control the sharing of these reso     19 is needed to control the sharing of these resources. This document introduces
 20 the operation of the VGA arbiter implemented f     20 the operation of the VGA arbiter implemented for the Linux kernel.
 21                                                    21 
 22 vgaarb kernel/userspace ABI                        22 vgaarb kernel/userspace ABI
 23 ---------------------------                        23 ---------------------------
 24                                                    24 
 25 The vgaarb is a module of the Linux Kernel. Wh     25 The vgaarb is a module of the Linux Kernel. When it is initially loaded, it
 26 scans all PCI devices and adds the VGA ones in     26 scans all PCI devices and adds the VGA ones inside the arbitration. The
 27 arbiter then enables/disables the decoding on      27 arbiter then enables/disables the decoding on different devices of the VGA
 28 legacy instructions. Devices which do not want     28 legacy instructions. Devices which do not want/need to use the arbiter may
 29 explicitly tell it by calling vga_set_legacy_d     29 explicitly tell it by calling vga_set_legacy_decoding().
 30                                                    30 
 31 The kernel exports a char device interface (/d     31 The kernel exports a char device interface (/dev/vga_arbiter) to the clients,
 32 which has the following semantics:                 32 which has the following semantics:
 33                                                    33 
 34 open                                               34 open
 35         Opens a user instance of the arbiter.      35         Opens a user instance of the arbiter. By default, it's attached to the
 36         default VGA device of the system.          36         default VGA device of the system.
 37                                                    37 
 38 close                                              38 close
 39         Close a user instance. Release locks m     39         Close a user instance. Release locks made by the user
 40                                                    40 
 41 read                                               41 read
 42         Return a string indicating the status      42         Return a string indicating the status of the target like:
 43                                                    43 
 44         "<card_ID>,decodes=<io_state>,owns=<io     44         "<card_ID>,decodes=<io_state>,owns=<io_state>,locks=<io_state> (ic,mc)"
 45                                                    45 
 46         An IO state string is of the form {io,     46         An IO state string is of the form {io,mem,io+mem,none}, mc and
 47         ic are respectively mem and io lock co     47         ic are respectively mem and io lock counts (for debugging/
 48         diagnostic only). "decodes" indicate w     48         diagnostic only). "decodes" indicate what the card currently
 49         decodes, "owns" indicates what is curr     49         decodes, "owns" indicates what is currently enabled on it, and
 50         "locks" indicates what is locked by th     50         "locks" indicates what is locked by this card. If the card is
 51         unplugged, we get "invalid" then for c     51         unplugged, we get "invalid" then for card_ID and an -ENODEV
 52         error is returned for any command unti     52         error is returned for any command until a new card is targeted.
 53                                                    53 
 54                                                    54 
 55 write                                              55 write
 56         Write a command to the arbiter. List o     56         Write a command to the arbiter. List of commands:
 57                                                    57 
 58         target <card_ID>                           58         target <card_ID>
 59                 switch target to card <card_ID     59                 switch target to card <card_ID> (see below)
 60         lock <io_state>                            60         lock <io_state>
 61                 acquires locks on target ("non     61                 acquires locks on target ("none" is an invalid io_state)
 62         trylock <io_state>                         62         trylock <io_state>
 63                 non-blocking acquire locks on      63                 non-blocking acquire locks on target (returns EBUSY if
 64                 unsuccessful)                      64                 unsuccessful)
 65         unlock <io_state>                          65         unlock <io_state>
 66                 release locks on target            66                 release locks on target
 67         unlock all                                 67         unlock all
 68                 release all locks on target he     68                 release all locks on target held by this user (not implemented
 69                 yet)                               69                 yet)
 70         decodes <io_state>                         70         decodes <io_state>
 71                 set the legacy decoding attrib     71                 set the legacy decoding attributes for the card
 72                                                    72 
 73         poll                                       73         poll
 74                 event if something changes on      74                 event if something changes on any card (not just the target)
 75                                                    75 
 76         card_ID is of the form "PCI:domain:bus     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      77         to go back to the system default card (TODO: not implemented yet). Currently,
 78         only PCI is supported as a prefix, but     78         only PCI is supported as a prefix, but the userland API may support other bus
 79         types in the future, even if the curre     79         types in the future, even if the current kernel implementation doesn't.
 80                                                    80 
 81 Note about locks:                                  81 Note about locks:
 82                                                    82 
 83 The driver keeps track of which user has which     83 The driver keeps track of which user has which locks on which card. It
 84 supports stacking, like the kernel one. This c     84 supports stacking, like the kernel one. This complexifies the implementation
 85 a bit, but makes the arbiter more tolerant to      85 a bit, but makes the arbiter more tolerant to user space problems and able
 86 to properly cleanup in all cases when a proces     86 to properly cleanup in all cases when a process dies.
 87 Currently, a max of 16 cards can have locks si     87 Currently, a max of 16 cards can have locks simultaneously issued from
 88 user space for a given user (file descriptor i     88 user space for a given user (file descriptor instance) of the arbiter.
 89                                                    89 
 90 In the case of devices hot-{un,}plugged, there     90 In the case of devices hot-{un,}plugged, there is a hook - pci_notify() - to
 91 notify them being added/removed in the system      91 notify them being added/removed in the system and automatically added/removed
 92 in the arbiter.                                    92 in the arbiter.
 93                                                    93 
 94 There is also an in-kernel API of the arbiter      94 There is also an in-kernel API of the arbiter in case DRM, vgacon, or other
 95 drivers want to use it.                            95 drivers want to use it.
 96                                                    96 
 97 In-kernel interface                                97 In-kernel interface
 98 -------------------                                98 -------------------
 99                                                    99 
100 .. kernel-doc:: include/linux/vgaarb.h            100 .. kernel-doc:: include/linux/vgaarb.h
101    :internal:                                     101    :internal:
102                                                   102 
103 .. kernel-doc:: drivers/pci/vgaarb.c              103 .. kernel-doc:: drivers/pci/vgaarb.c
104    :export:                                       104    :export:
105                                                   105 
106 libpciaccess                                      106 libpciaccess
107 ------------                                      107 ------------
108                                                   108 
109 To use the vga arbiter char device it was impl    109 To use the vga arbiter char device it was implemented an API inside the
110 libpciaccess library. One field was added to s    110 libpciaccess library. One field was added to struct pci_device (each device
111 on the system)::                                  111 on the system)::
112                                                   112 
113     /* the type of resource decoded by the dev    113     /* the type of resource decoded by the device */
114     int vgaarb_rsrc;                              114     int vgaarb_rsrc;
115                                                   115 
116 Besides it, in pci_system were added::            116 Besides it, in pci_system were added::
117                                                   117 
118     int vgaarb_fd;                                118     int vgaarb_fd;
119     int vga_count;                                119     int vga_count;
120     struct pci_device *vga_target;                120     struct pci_device *vga_target;
121     struct pci_device *vga_default_dev;           121     struct pci_device *vga_default_dev;
122                                                   122 
123 The vga_count is used to track how many cards     123 The vga_count is used to track how many cards are being arbitrated, so for
124 instance, if there is only one card, then it c    124 instance, if there is only one card, then it can completely escape arbitration.
125                                                   125 
126 These functions below acquire VGA resources fo    126 These functions below acquire VGA resources for the given card and mark those
127 resources as locked. If the resources requeste    127 resources as locked. If the resources requested are "normal" (and not legacy)
128 resources, the arbiter will first check whethe    128 resources, the arbiter will first check whether the card is doing legacy
129 decoding for that type of resource. If yes, th    129 decoding for that type of resource. If yes, the lock is "converted" into a
130 legacy resource lock. The arbiter will first l    130 legacy resource lock. The arbiter will first look for all VGA cards that
131 might conflict and disable their IOs and/or Me    131 might conflict and disable their IOs and/or Memory access, including VGA
132 forwarding on P2P bridges if necessary, so tha    132 forwarding on P2P bridges if necessary, so that the requested resources can
133 be used. Then, the card is marked as locking t    133 be used. Then, the card is marked as locking these resources and the IO and/or
134 Memory access is enabled on the card (includin    134 Memory access is enabled on the card (including VGA forwarding on parent
135 P2P bridges if any). In the case of vga_arb_lo    135 P2P bridges if any). In the case of vga_arb_lock(), the function will block
136 if some conflicting card is already locking on    136 if some conflicting card is already locking one of the required resources (or
137 any resource on a different bus segment, since    137 any resource on a different bus segment, since P2P bridges don't differentiate
138 VGA memory and IO afaik). If the card already     138 VGA memory and IO afaik). If the card already owns the resources, the function
139 succeeds.  vga_arb_trylock() will return (-EBU    139 succeeds.  vga_arb_trylock() will return (-EBUSY) instead of blocking. Nested
140 calls are supported (a per-resource counter is    140 calls are supported (a per-resource counter is maintained).
141                                                   141 
142 Set the target device of this client. ::          142 Set the target device of this client. ::
143                                                   143 
144     int  pci_device_vgaarb_set_target   (struc    144     int  pci_device_vgaarb_set_target   (struct pci_device *dev);
145                                                   145 
146 For instance, in x86 if two devices on the sam    146 For instance, in x86 if two devices on the same bus want to lock different
147 resources, both will succeed (lock). If device    147 resources, both will succeed (lock). If devices are in different buses and
148 trying to lock different resources, only the f    148 trying to lock different resources, only the first who tried succeeds. ::
149                                                   149 
150     int  pci_device_vgaarb_lock         (void)    150     int  pci_device_vgaarb_lock         (void);
151     int  pci_device_vgaarb_trylock      (void)    151     int  pci_device_vgaarb_trylock      (void);
152                                                   152 
153 Unlock resources of device. ::                    153 Unlock resources of device. ::
154                                                   154 
155     int  pci_device_vgaarb_unlock       (void)    155     int  pci_device_vgaarb_unlock       (void);
156                                                   156 
157 Indicates to the arbiter if the card decodes l    157 Indicates to the arbiter if the card decodes legacy VGA IOs, legacy VGA
158 Memory, both, or none. All cards default to bo    158 Memory, both, or none. All cards default to both, the card driver (fbdev for
159 example) should tell the arbiter if it has dis    159 example) should tell the arbiter if it has disabled legacy decoding, so the
160 card can be left out of the arbitration proces    160 card can be left out of the arbitration process (and can be safe to take
161 interrupts at any time. ::                        161 interrupts at any time. ::
162                                                   162 
163     int  pci_device_vgaarb_decodes      (int n    163     int  pci_device_vgaarb_decodes      (int new_vgaarb_rsrc);
164                                                   164 
165 Connects to the arbiter device, allocates the     165 Connects to the arbiter device, allocates the struct ::
166                                                   166 
167     int  pci_device_vgaarb_init         (void)    167     int  pci_device_vgaarb_init         (void);
168                                                   168 
169 Close the connection ::                           169 Close the connection ::
170                                                   170 
171     void pci_device_vgaarb_fini         (void)    171     void pci_device_vgaarb_fini         (void);
172                                                   172 
173 xf86VGAArbiter (X server implementation)          173 xf86VGAArbiter (X server implementation)
174 ----------------------------------------          174 ----------------------------------------
175                                                   175 
176 X server basically wraps all the functions tha    176 X server basically wraps all the functions that touch VGA registers somehow.
177                                                   177 
178 References                                        178 References
179 ----------                                        179 ----------
180                                                   180 
181 Benjamin Herrenschmidt (IBM?) started this wor    181 Benjamin Herrenschmidt (IBM?) started this work when he discussed such design
182 with the Xorg community in 2005 [1, 2]. In the    182 with the Xorg community in 2005 [1, 2]. In the end of 2007, Paulo Zanoni and
183 Tiago Vignatti (both of C3SL/Federal Universit    183 Tiago Vignatti (both of C3SL/Federal University of ParanĂ¡) proceeded his work
184 enhancing the kernel code to adapt as a kernel    184 enhancing the kernel code to adapt as a kernel module and also did the
185 implementation of the user space side [3]. Now    185 implementation of the user space side [3]. Now (2009) Tiago Vignatti and Dave
186 Airlie finally put this work in shape and queu    186 Airlie finally put this work in shape and queued to Jesse Barnes' PCI tree.
187                                                   187 
188 0) https://cgit.freedesktop.org/xorg/xserver/c    188 0) https://cgit.freedesktop.org/xorg/xserver/commit/?id=4b42448a2388d40f257774fbffdccaea87bd0347
189 1) https://lists.freedesktop.org/archives/xorg    189 1) https://lists.freedesktop.org/archives/xorg/2005-March/006663.html
190 2) https://lists.freedesktop.org/archives/xorg    190 2) https://lists.freedesktop.org/archives/xorg/2005-March/006745.html
191 3) https://lists.freedesktop.org/archives/xorg    191 3) https://lists.freedesktop.org/archives/xorg/2007-October/029507.html
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php