1*7362facfSGregory Price.. SPDX-License-Identifier: GPL-2.0 2*7362facfSGregory Price 3*7362facfSGregory Price================== 4*7362facfSGregory PriceCXL Device Hotplug 5*7362facfSGregory Price================== 6*7362facfSGregory Price 7*7362facfSGregory PriceDevice hotplug refers to *physical* hotplug of a device (addition or removal 8*7362facfSGregory Priceof a physical device from the machine). 9*7362facfSGregory Price 10*7362facfSGregory PriceBIOS/EFI software is expected to configure sufficient resources **at boot 11*7362facfSGregory Pricetime** to allow hotplugged devices to be configured by software (such as 12*7362facfSGregory Priceproximity domains, HPA regions, and host-bridge configurations). 13*7362facfSGregory Price 14*7362facfSGregory PriceBIOS/EFI is not expected (**nor suggested**) to configure hotplugged 15*7362facfSGregory Pricedevices at hotplug time (i.e. HDM decoders should be left unprogrammed). 16*7362facfSGregory Price 17*7362facfSGregory PriceThis document covers some examples of those resources, but should not 18*7362facfSGregory Pricebe considered exhaustive. 19*7362facfSGregory Price 20*7362facfSGregory PriceHot-Remove 21*7362facfSGregory Price========== 22*7362facfSGregory PriceHot removal of a device typically requires careful removal of software 23*7362facfSGregory Priceconstructs (memory regions, associated drivers) which manage these devices. 24*7362facfSGregory Price 25*7362facfSGregory PriceHard-removing a CXL.mem device without carefully tearing down driver stacks 26*7362facfSGregory Priceis likely to cause the system to machine-check (or at least SIGBUS if memory 27*7362facfSGregory Priceaccess is limited to user space). 28*7362facfSGregory Price 29*7362facfSGregory PriceMemory Device Hot-Add 30*7362facfSGregory Price===================== 31*7362facfSGregory PriceA device present at boot may be associated with a CXL Fixed Memory Window 32*7362facfSGregory Pricereported in :doc:`CEDT<acpi/cedt>`. That CFMWS may match the size of the 33*7362facfSGregory Pricedevice, but the construction of the CEDT CFMWS is platform-defined. 34*7362facfSGregory Price 35*7362facfSGregory PriceHot-adding a memory device requires this pre-defined, **static** CFMWS to 36*7362facfSGregory Pricehave sufficient HPA space to describe that device. 37*7362facfSGregory Price 38*7362facfSGregory PriceThere are a few common scenarios to consider. 39*7362facfSGregory Price 40*7362facfSGregory PriceSingle-Endpoint Memory Device Present at Boot 41*7362facfSGregory Price--------------------------------------------- 42*7362facfSGregory PriceA device present at boot likely had its capacity reported in the 43*7362facfSGregory Price:doc:`CEDT<acpi/cedt>`. If a device is removed and a new device hotplugged, 44*7362facfSGregory Pricethe capacity of the new device will be limited to the original CFMWS capacity. 45*7362facfSGregory Price 46*7362facfSGregory PriceAdding capacity larger than the original device will cause memory region 47*7362facfSGregory Pricecreation to fail if the region size is greater than the CFMWS size. 48*7362facfSGregory Price 49*7362facfSGregory PriceThe CFMWS is **static** and cannot be adjusted. Platforms which may expect 50*7362facfSGregory Pricedifferent sized devices to be hotplugged must allocate sufficient CFMWS space 51*7362facfSGregory Price**at boot time** to cover all future expected devices. 52*7362facfSGregory Price 53*7362facfSGregory PriceMulti-Endpoint Memory Device Present at Boot 54*7362facfSGregory Price-------------------------------------------- 55*7362facfSGregory PriceNon-switch-based Multi-Endpoint devices are outside the scope of what the 56*7362facfSGregory PriceCXL specification describes, but they are technically possible. We describe 57*7362facfSGregory Pricethem here for instructive reasons only - this does not imply Linux support. 58*7362facfSGregory Price 59*7362facfSGregory PriceA hot-plug capable CXL memory device, such as one which presents multiple 60*7362facfSGregory Priceexpanders as a single large-capacity device, should report the **maximum 61*7362facfSGregory Pricepossible capacity** for the device at boot. :: 62*7362facfSGregory Price 63*7362facfSGregory Price HB0 64*7362facfSGregory Price RP0 65*7362facfSGregory Price | 66*7362facfSGregory Price [Multi-Endpoint Memory Device] 67*7362facfSGregory Price _____|_____ 68*7362facfSGregory Price | | 69*7362facfSGregory Price [Endpoint0] [Empty] 70*7362facfSGregory Price 71*7362facfSGregory Price 72*7362facfSGregory PriceLimiting the size to the capacity preset at boot will limit hot-add support 73*7362facfSGregory Priceto replacing capacity that was present at boot. 74*7362facfSGregory Price 75*7362facfSGregory PriceNo CXL Device Present at Boot 76*7362facfSGregory Price----------------------------- 77*7362facfSGregory PriceWhen no CXL memory device is present on boot, some platforms omit the CFMWS 78*7362facfSGregory Pricein the :doc:`CEDT<acpi/cedt>`. When this occurs, hot-add is not possible. 79*7362facfSGregory Price 80*7362facfSGregory PriceThis describes the base case for any given device not being present at boot. 81*7362facfSGregory PriceIf a future possible device is not described in the CEDT at boot, hot-add 82*7362facfSGregory Priceof that device is either limited or not possible. 83*7362facfSGregory Price 84*7362facfSGregory PriceFor a platform to support hot-add of a full memory device, it must allocate 85*7362facfSGregory Pricea CEDT CFMWS region with sufficient memory capacity to cover all future 86*7362facfSGregory Pricepotentially added capacity (along with any relevant CEDT CHBS entry). 87*7362facfSGregory Price 88*7362facfSGregory PriceTo support memory hotplug directly on the host bridge/root port, or on a switch 89*7362facfSGregory Pricedownstream of the host bridge, a platform must construct a CEDT CFMWS at boot 90*7362facfSGregory Pricewith sufficient resources to support the max possible (or expected) hotplug 91*7362facfSGregory Pricememory capacity. :: 92*7362facfSGregory Price 93*7362facfSGregory Price HB0 HB1 94*7362facfSGregory Price RP0 RP1 RP2 95*7362facfSGregory Price | | | 96*7362facfSGregory Price Empty Empty USP 97*7362facfSGregory Price ________|________ 98*7362facfSGregory Price | | | | 99*7362facfSGregory Price DSP DSP DSP DSP 100*7362facfSGregory Price | | | | 101*7362facfSGregory Price All Empty 102*7362facfSGregory Price 103*7362facfSGregory PriceFor example, a BIOS/EFI may expose an option to configure a CEDT CFMWS with 104*7362facfSGregory Pricea pre-configured amount of memory capacity (per host bridge, or host bridge 105*7362facfSGregory Priceinterleave set), even if no device is attached to Root Ports or Downstream 106*7362facfSGregory PricePorts at boot (as depicted in the figure above). 107*7362facfSGregory Price 108*7362facfSGregory Price 109*7362facfSGregory PriceInterleave Sets 110*7362facfSGregory Price=============== 111*7362facfSGregory Price 112*7362facfSGregory PriceHost Bridge Interleave 113*7362facfSGregory Price---------------------- 114*7362facfSGregory PriceHost-bridge interleaved memory regions are defined **statically** in the 115*7362facfSGregory Price:doc:`CEDT<acpi/cedt>`. To apply cross-host-bridge interleave, a CFMWS entry 116*7362facfSGregory Pricedescribing that interleave must have been provided **at boot**. Hotplugged 117*7362facfSGregory Pricedevices cannot add host-bridge interleave capabilities at hotplug time. 118*7362facfSGregory Price 119*7362facfSGregory PriceSee the :doc:`Flexible CEDT Configuration<example-configurations/flexible>` 120*7362facfSGregory Priceexample to see how a platform can provide this kind of flexibility regarding 121*7362facfSGregory Pricehotplugged memory devices. BIOS/EFI software should consider options to 122*7362facfSGregory Pricepresent flexible CEDT configurations with hotplug support. 123*7362facfSGregory Price 124*7362facfSGregory PriceHDM Interleave 125*7362facfSGregory Price-------------- 126*7362facfSGregory PriceDecoder-applied interleave can flexibly handle hotplugged devices, as decoders 127*7362facfSGregory Pricecan be re-programmed after hotplug. 128*7362facfSGregory Price 129*7362facfSGregory PriceTo add or remove a device to/from an existing HDM-applied interleaved region, 130*7362facfSGregory Pricethat region must be torn down an re-created. 131