1*aa86e750SPerry Yuan======================================= 2*aa86e750SPerry YuanPeak Tops Limiter (PTL) sysfs Interface 3*aa86e750SPerry Yuan======================================= 4*aa86e750SPerry Yuan 5*aa86e750SPerry YuanOverview 6*aa86e750SPerry Yuan-------- 7*aa86e750SPerry YuanThe Peak Tops Limiter (PTL) sysfs interface enables users to control and 8*aa86e750SPerry Yuanconfigure the PTL feature for each GPU individually. All PTL-related 9*aa86e750SPerry Yuansysfs files are located under `/sys/class/drm/cardX/device/ptl/`, where 10*aa86e750SPerry Yuan`X` is the GPU index. Through these files, users can enable or disable 11*aa86e750SPerry YuanPTL, set preferred data formats, and query supported formats for each GPU. 12*aa86e750SPerry Yuan 13*aa86e750SPerry YuanPTL sysfs files 14*aa86e750SPerry Yuan---------------- 15*aa86e750SPerry YuanThe following files are available under `/sys/class/drm/cardX/device/ptl/`: 16*aa86e750SPerry Yuan 17*aa86e750SPerry Yuan- `ptl_enable` 18*aa86e750SPerry Yuan- `ptl_format` 19*aa86e750SPerry Yuan- `ptl_supported_formats` 20*aa86e750SPerry Yuan 21*aa86e750SPerry YuanPTL Enable/Disable 22*aa86e750SPerry Yuan------------------ 23*aa86e750SPerry YuanFile: `ptl_enable` 24*aa86e750SPerry YuanType: Read/Write (rw) 25*aa86e750SPerry Yuan 26*aa86e750SPerry YuanRead: Returns the current PTL status as a string: `enabled` if PTL 27*aa86e750SPerry Yuanis active, or `disabled` if inactive. 28*aa86e750SPerry Yuan 29*aa86e750SPerry YuanWrite: 30*aa86e750SPerry Yuan 31*aa86e750SPerry Yuan- Write `1` or `enabled` to enable PTL 32*aa86e750SPerry Yuan- Write `0` or `disabled` to disable PTL 33*aa86e750SPerry Yuan 34*aa86e750SPerry YuanExamples:: 35*aa86e750SPerry Yuan 36*aa86e750SPerry Yuan # Query PTL status 37*aa86e750SPerry Yuan cat /sys/class/drm/card1/device/ptl/ptl_enable 38*aa86e750SPerry Yuan # Output: enabled 39*aa86e750SPerry Yuan 40*aa86e750SPerry Yuan # Enable PTL 41*aa86e750SPerry Yuan sudo bash -c "echo 1 > /sys/class/drm/card1/device/ptl/ptl_enable" 42*aa86e750SPerry Yuan 43*aa86e750SPerry Yuan # Disable PTL 44*aa86e750SPerry Yuan sudo bash -c "echo 0 > /sys/class/drm/card1/device/ptl/ptl_enable" 45*aa86e750SPerry Yuan 46*aa86e750SPerry YuanPTL Format (Preferred Data Formats) 47*aa86e750SPerry Yuan----------------------------------- 48*aa86e750SPerry YuanFile: `ptl_format` 49*aa86e750SPerry YuanType: Read/Write (rw) 50*aa86e750SPerry Yuan 51*aa86e750SPerry YuanRead: Returns the two preferred formats, e.g. `I8,F32`. 52*aa86e750SPerry Yuan 53*aa86e750SPerry YuanWrite: Accepts two formats separated by a comma, e.g. `I8,F32`. 54*aa86e750SPerry Yuan 55*aa86e750SPerry Yuan- Both formats must be supported and different. 56*aa86e750SPerry Yuan- If an invalid format is provided (not supported, or both formats are the 57*aa86e750SPerry Yuan same), the driver will return "write error: Invalid argument". 58*aa86e750SPerry Yuan 59*aa86e750SPerry YuanExamples:: 60*aa86e750SPerry Yuan 61*aa86e750SPerry Yuan # Query PTL formats 62*aa86e750SPerry Yuan cat /sys/class/drm/card1/device/ptl/ptl_format 63*aa86e750SPerry Yuan # Output: I8,F32 64*aa86e750SPerry Yuan 65*aa86e750SPerry Yuan # Set PTL formats 66*aa86e750SPerry Yuan sudo bash -c "echo I8,F32 > /sys/class/drm/card1/device/ptl/ptl_format" 67*aa86e750SPerry Yuan 68*aa86e750SPerry YuanSupported Formats 69*aa86e750SPerry Yuan----------------- 70*aa86e750SPerry YuanFile: `ptl_supported_formats` 71*aa86e750SPerry YuanType: Read-only (r) 72*aa86e750SPerry Yuan 73*aa86e750SPerry YuanRead: Returns a comma-separated list of supported formats, e.g. 74*aa86e750SPerry Yuan`I8,F16,BF16,F32,F64`. 75*aa86e750SPerry Yuan 76*aa86e750SPerry YuanExample:: 77*aa86e750SPerry Yuan 78*aa86e750SPerry Yuan # Check supported formats 79*aa86e750SPerry Yuan cat /sys/class/drm/card1/device/ptl/ptl_supported_formats 80*aa86e750SPerry Yuan # Output: I8,F16,BF16,F32,F64 81*aa86e750SPerry Yuan 82*aa86e750SPerry YuanBehavioral Notes 83*aa86e750SPerry Yuan---------------- 84*aa86e750SPerry Yuan- PTL formats can only be set when PTL is enabled. 85*aa86e750SPerry Yuan- If PTL is disabled, `ptl_format` returns `N/A`. 86*aa86e750SPerry Yuan- Only two formats can be set at a time, and they must be from the supported set and different.. 87*aa86e750SPerry Yuan- All commands support per-GPU targeting. 88*aa86e750SPerry Yuan- Root permission is required to enable/disable PTL or change formats. 89*aa86e750SPerry Yuan- If the hardware does not support PTL, the PTL sysfs directory will not 90*aa86e750SPerry Yuan be created. 91*aa86e750SPerry Yuan 92*aa86e750SPerry YuanImplementation 93*aa86e750SPerry Yuan-------------- 94*aa86e750SPerry YuanThe PTL sysfs nodes are implemented in `drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c`. 95