acpi-info.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ========================================
  3. ACPI considerations for PCI host bridges
  4. ========================================
  5. The general rule is that the ACPI namespace should describe everything the
  6. OS might use unless there's another way for the OS to find it [1, 2].
  7. For example, there's no standard hardware mechanism for enumerating PCI
  8. host bridges, so the ACPI namespace must describe each host bridge, the
  9. method for accessing PCI config space below it, the address space windows
  10. the host bridge forwards to PCI (using _CRS), and the routing of legacy
  11. INTx interrupts (using _PRT).
  12. PCI devices, which are below the host bridge, generally do not need to be
  13. described via ACPI. The OS can discover them via the standard PCI
  14. enumeration mechanism, using config accesses to discover and identify
  15. devices and read and size their BARs. However, ACPI may describe PCI
  16. devices if it provides power management or hotplug functionality for them
  17. or if the device has INTx interrupts connected by platform interrupt
  18. controllers and a _PRT is needed to describe those connections.
  19. ACPI resource description is done via _CRS objects of devices in the ACPI
  20. namespace [2]. The _CRS is like a generalized PCI BAR: the OS can read
  21. _CRS and figure out what resource is being consumed even if it doesn't have
  22. a driver for the device [3]. That's important because it means an old OS
  23. can work correctly even on a system with new devices unknown to the OS.
  24. The new devices might not do anything, but the OS can at least make sure no
  25. resources conflict with them.
  26. Static tables like MCFG, HPET, ECDT, etc., are *not* mechanisms for
  27. reserving address space. The static tables are for things the OS needs to
  28. know early in boot, before it can parse the ACPI namespace. If a new table
  29. is defined, an old OS needs to operate correctly even though it ignores the
  30. table. _CRS allows that because it is generic and understood by the old
  31. OS; a static table does not.
  32. If the OS is expected to manage a non-discoverable device described via
  33. ACPI, that device will have a specific _HID/_CID that tells the OS what
  34. driver to bind to it, and the _CRS tells the OS and the driver where the
  35. device's registers are.
  36. PCI host bridges are PNP0A03 or PNP0A08 devices. Their _CRS should
  37. describe all the address space they consume. This includes all the windows
  38. they forward down to the PCI bus, as well as registers of the host bridge
  39. itself that are not forwarded to PCI. The host bridge registers include
  40. things like secondary/subordinate bus registers that determine the bus
  41. range below the bridge, window registers that describe the apertures, etc.
  42. These are all device-specific, non-architected things, so the only way a
  43. PNP0A03/PNP0A08 driver can manage them is via _PRS/_CRS/_SRS, which contain
  44. the device-specific details. The host bridge registers also include ECAM
  45. space, since it is consumed by the host bridge.
  46. ACPI defines a Consumer/Producer bit to distinguish the bridge registers
  47. ("Consumer") from the bridge apertures ("Producer") [4, 5], but early
  48. BIOSes didn't use that bit correctly. The result is that the current ACPI
  49. spec defines Consumer/Producer only for the Extended Address Space
  50. descriptors; the bit should be ignored in the older QWord/DWord/Word
  51. Address Space descriptors. Consequently, OSes have to assume all
  52. QWord/DWord/Word descriptors are windows.
  53. Prior to the addition of Extended Address Space descriptors, the failure of
  54. Consumer/Producer meant there was no way to describe bridge registers in
  55. the PNP0A03/PNP0A08 device itself. The workaround was to describe the
  56. bridge registers (including ECAM space) in PNP0C02 catch-all devices [6].
  57. With the exception of ECAM, the bridge register space is device-specific
  58. anyway, so the generic PNP0A03/PNP0A08 driver (pci_root.c) has no need to
  59. know about it.
  60. New architectures should be able to use "Consumer" Extended Address Space
  61. descriptors in the PNP0A03 device for bridge registers, including ECAM,
  62. although a strict interpretation of [6] might prohibit this. Old x86 and
  63. ia64 kernels assume all address space descriptors, including "Consumer"
  64. Extended Address Space ones, are windows, so it would not be safe to
  65. describe bridge registers this way on those architectures.
  66. PNP0C02 "motherboard" devices are basically a catch-all. There's no
  67. programming model for them other than "don't use these resources for
  68. anything else." So a PNP0C02 _CRS should claim any address space that is
  69. (1) not claimed by _CRS under any other device object in the ACPI namespace
  70. and (2) should not be assigned by the OS to something else.
  71. The PCIe spec requires the Enhanced Configuration Access Method (ECAM)
  72. unless there's a standard firmware interface for config access, e.g., the
  73. ia64 SAL interface [7]. A host bridge consumes ECAM memory address space
  74. and converts memory accesses into PCI configuration accesses. The spec
  75. defines the ECAM address space layout and functionality; only the base of
  76. the address space is device-specific. An ACPI OS learns the base address
  77. from either the static MCFG table or a _CBA method in the PNP0A03 device.
  78. The MCFG table must describe the ECAM space of non-hot pluggable host
  79. bridges [8]. Since MCFG is a static table and can't be updated by hotplug,
  80. a _CBA method in the PNP0A03 device describes the ECAM space of a
  81. hot-pluggable host bridge [9]. Note that for both MCFG and _CBA, the base
  82. address always corresponds to bus 0, even if the bus range below the bridge
  83. (which is reported via _CRS) doesn't start at 0.
  84. [1] ACPI 6.2, sec 6.1:
  85. For any device that is on a non-enumerable type of bus (for example, an
  86. ISA bus), OSPM enumerates the devices' identifier(s) and the ACPI
  87. system firmware must supply an _HID object ... for each device to
  88. enable OSPM to do that.
  89. [2] ACPI 6.2, sec 3.7:
  90. The OS enumerates motherboard devices simply by reading through the
  91. ACPI Namespace looking for devices with hardware IDs.
  92. Each device enumerated by ACPI includes ACPI-defined objects in the
  93. ACPI Namespace that report the hardware resources the device could
  94. occupy [_PRS], an object that reports the resources that are currently
  95. used by the device [_CRS], and objects for configuring those resources
  96. [_SRS]. The information is used by the Plug and Play OS (OSPM) to
  97. configure the devices.
  98. [3] ACPI 6.2, sec 6.2:
  99. OSPM uses device configuration objects to configure hardware resources
  100. for devices enumerated via ACPI. Device configuration objects provide
  101. information about current and possible resource requirements, the
  102. relationship between shared resources, and methods for configuring
  103. hardware resources.
  104. When OSPM enumerates a device, it calls _PRS to determine the resource
  105. requirements of the device. It may also call _CRS to find the current
  106. resource settings for the device. Using this information, the Plug and
  107. Play system determines what resources the device should consume and
  108. sets those resources by calling the device’s _SRS control method.
  109. In ACPI, devices can consume resources (for example, legacy keyboards),
  110. provide resources (for example, a proprietary PCI bridge), or do both.
  111. Unless otherwise specified, resources for a device are assumed to be
  112. taken from the nearest matching resource above the device in the device
  113. hierarchy.
  114. [4] ACPI 6.2, sec 6.4.3.5.1, 2, 3, 4:
  115. QWord/DWord/Word Address Space Descriptor (.1, .2, .3)
  116. General Flags: Bit [0] Ignored
  117. Extended Address Space Descriptor (.4)
  118. General Flags: Bit [0] Consumer/Producer:
  119. * 1 – This device consumes this resource
  120. * 0 – This device produces and consumes this resource
  121. [5] ACPI 6.2, sec 19.6.43:
  122. ResourceUsage specifies whether the Memory range is consumed by
  123. this device (ResourceConsumer) or passed on to child devices
  124. (ResourceProducer). If nothing is specified, then
  125. ResourceConsumer is assumed.
  126. [6] PCI Firmware 3.2, sec 4.1.2:
  127. If the operating system does not natively comprehend reserving the
  128. MMCFG region, the MMCFG region must be reserved by firmware. The
  129. address range reported in the MCFG table or by _CBA method (see Section
  130. 4.1.3) must be reserved by declaring a motherboard resource. For most
  131. systems, the motherboard resource would appear at the root of the ACPI
  132. namespace (under \_SB) in a node with a _HID of EISAID (PNP0C02), and
  133. the resources in this case should not be claimed in the root PCI bus’s
  134. _CRS. The resources can optionally be returned in Int15 E820 or
  135. EFIGetMemoryMap as reserved memory but must always be reported through
  136. ACPI as a motherboard resource.
  137. [7] PCI Express 4.0, sec 7.2.2:
  138. For systems that are PC-compatible, or that do not implement a
  139. processor-architecture-specific firmware interface standard that allows
  140. access to the Configuration Space, the ECAM is required as defined in
  141. this section.
  142. [8] PCI Firmware 3.2, sec 4.1.2:
  143. The MCFG table is an ACPI table that is used to communicate the base
  144. addresses corresponding to the non-hot removable PCI Segment Groups
  145. range within a PCI Segment Group available to the operating system at
  146. boot. This is required for the PC-compatible systems.
  147. The MCFG table is only used to communicate the base addresses
  148. corresponding to the PCI Segment Groups available to the system at
  149. boot.
  150. [9] PCI Firmware 3.2, sec 4.1.3:
  151. The _CBA (Memory mapped Configuration Base Address) control method is
  152. an optional ACPI object that returns the 64-bit memory mapped
  153. configuration base address for the hot plug capable host bridge. The
  154. base address returned by _CBA is processor-relative address. The _CBA
  155. control method evaluates to an Integer.
  156. This control method appears under a host bridge object. When the _CBA
  157. method appears under an active host bridge object, the operating system
  158. evaluates this structure to identify the memory mapped configuration
  159. base address corresponding to the PCI Segment Group for the bus number
  160. range specified in _CRS method. An ACPI name space object that contains
  161. the _CBA method must also contain a corresponding _SEG method.