137df9560STom St Denis /* 237df9560STom St Denis * Copyright 2021 Advanced Micro Devices, Inc. 337df9560STom St Denis * 437df9560STom St Denis * Permission is hereby granted, free of charge, to any person obtaining a 537df9560STom St Denis * copy of this software and associated documentation files (the "Software"), 637df9560STom St Denis * to deal in the Software without restriction, including without limitation 737df9560STom St Denis * the rights to use, copy, modify, merge, publish, distribute, sublicense, 837df9560STom St Denis * and/or sell copies of the Software, and to permit persons to whom the 937df9560STom St Denis * Software is furnished to do so, subject to the following conditions: 1037df9560STom St Denis * 1137df9560STom St Denis * The above copyright notice and this permission notice shall be included in 1237df9560STom St Denis * all copies or substantial portions of the Software. 1337df9560STom St Denis * 1437df9560STom St Denis * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1537df9560STom St Denis * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1637df9560STom St Denis * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1737df9560STom St Denis * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 1837df9560STom St Denis * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 1937df9560STom St Denis * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 2037df9560STom St Denis * OTHER DEALINGS IN THE SOFTWARE. 2137df9560STom St Denis * 2237df9560STom St Denis */ 2337df9560STom St Denis #include <linux/ioctl.h> 2437df9560STom St Denis 2537df9560STom St Denis /* 2637df9560STom St Denis * MMIO debugfs IOCTL structure 2737df9560STom St Denis */ 2837df9560STom St Denis struct amdgpu_debugfs_regs2_iocdata { 2937df9560STom St Denis __u32 use_srbm, use_grbm, pg_lock; 3037df9560STom St Denis struct { 3137df9560STom St Denis __u32 se, sh, instance; 3237df9560STom St Denis } grbm; 3337df9560STom St Denis struct { 3437df9560STom St Denis __u32 me, pipe, queue, vmid; 3537df9560STom St Denis } srbm; 3637df9560STom St Denis }; 3737df9560STom St Denis 38*553f973aSTom St Denis struct amdgpu_debugfs_regs2_iocdata_v2 { 39*553f973aSTom St Denis __u32 use_srbm, use_grbm, pg_lock; 40*553f973aSTom St Denis struct { 41*553f973aSTom St Denis __u32 se, sh, instance; 42*553f973aSTom St Denis } grbm; 43*553f973aSTom St Denis struct { 44*553f973aSTom St Denis __u32 me, pipe, queue, vmid; 45*553f973aSTom St Denis } srbm; 46*553f973aSTom St Denis u32 xcc_id; 47*553f973aSTom St Denis }; 48*553f973aSTom St Denis 49*553f973aSTom St Denis struct amdgpu_debugfs_gprwave_iocdata { 50*553f973aSTom St Denis u32 gpr_or_wave, se, sh, cu, wave, simd, xcc_id; 51*553f973aSTom St Denis struct { 52*553f973aSTom St Denis u32 thread, vpgr_or_sgpr; 53*553f973aSTom St Denis } gpr; 54*553f973aSTom St Denis }; 55*553f973aSTom St Denis 5637df9560STom St Denis /* 5737df9560STom St Denis * MMIO debugfs state data (per file* handle) 5837df9560STom St Denis */ 5937df9560STom St Denis struct amdgpu_debugfs_regs2_data { 6037df9560STom St Denis struct amdgpu_device *adev; 6137df9560STom St Denis struct mutex lock; 62*553f973aSTom St Denis struct amdgpu_debugfs_regs2_iocdata_v2 id; 63*553f973aSTom St Denis }; 64*553f973aSTom St Denis 65*553f973aSTom St Denis struct amdgpu_debugfs_gprwave_data { 66*553f973aSTom St Denis struct amdgpu_device *adev; 67*553f973aSTom St Denis struct mutex lock; 68*553f973aSTom St Denis struct amdgpu_debugfs_gprwave_iocdata id; 6937df9560STom St Denis }; 7037df9560STom St Denis 7137df9560STom St Denis enum AMDGPU_DEBUGFS_REGS2_CMDS { 7237df9560STom St Denis AMDGPU_DEBUGFS_REGS2_CMD_SET_STATE=0, 73*553f973aSTom St Denis AMDGPU_DEBUGFS_REGS2_CMD_SET_STATE_V2, 7437df9560STom St Denis }; 7537df9560STom St Denis 76*553f973aSTom St Denis enum AMDGPU_DEBUGFS_GPRWAVE_CMDS { 77*553f973aSTom St Denis AMDGPU_DEBUGFS_GPRWAVE_CMD_SET_STATE=0, 78*553f973aSTom St Denis }; 79*553f973aSTom St Denis 80*553f973aSTom St Denis //reg2 interface 8137df9560STom St Denis #define AMDGPU_DEBUGFS_REGS2_IOC_SET_STATE _IOWR(0x20, AMDGPU_DEBUGFS_REGS2_CMD_SET_STATE, struct amdgpu_debugfs_regs2_iocdata) 82*553f973aSTom St Denis #define AMDGPU_DEBUGFS_REGS2_IOC_SET_STATE_V2 _IOWR(0x20, AMDGPU_DEBUGFS_REGS2_CMD_SET_STATE_V2, struct amdgpu_debugfs_regs2_iocdata_v2) 83*553f973aSTom St Denis 84*553f973aSTom St Denis //gprwave interface 85*553f973aSTom St Denis #define AMDGPU_DEBUGFS_GPRWAVE_IOC_SET_STATE _IOWR(0x20, AMDGPU_DEBUGFS_GPRWAVE_CMD_SET_STATE, struct amdgpu_debugfs_gprwave_iocdata) 86