1 #ifndef _G_FECS_EVENT_LIST_NVOC_H_ 2 #define _G_FECS_EVENT_LIST_NVOC_H_ 3 #include "nvoc/runtime.h" 4 5 #ifdef __cplusplus 6 extern "C" { 7 #endif 8 9 /* 10 * SPDX-FileCopyrightText: Copyright (c) 2013-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. 11 * SPDX-License-Identifier: MIT 12 * 13 * Permission is hereby granted, free of charge, to any person obtaining a 14 * copy of this software and associated documentation files (the "Software"), 15 * to deal in the Software without restriction, including without limitation 16 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 * and/or sell copies of the Software, and to permit persons to whom the 18 * Software is furnished to do so, subject to the following conditions: 19 * 20 * The above copyright notice and this permission notice shall be included in 21 * all copies or substantial portions of the Software. 22 * 23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 29 * DEALINGS IN THE SOFTWARE. 30 */ 31 32 #include "g_fecs_event_list_nvoc.h" 33 34 #ifndef _FECS_EVENT_LIST_H_ 35 #define _FECS_EVENT_LIST_H_ 36 37 /*! 38 * @file fecs_event_list.h 39 * @brief Provides definition for FECS callback on EventBuffer, as well as a list holding the subscribers to the event 40 */ 41 42 #include "core/core.h" 43 #include "class/cl90cd.h" 44 #include "class/cl90cdfecs.h" 45 #include "containers/multimap.h" 46 #include "resserv/resserv.h" 47 #include "rmapi/client.h" 48 49 #include "ctrl/ctrl2080/ctrl2080gr.h" // NV2080_CTRL_GR_FECS_BIND_EVTBUF_LOD 50 51 struct KernelGraphics; 52 53 #ifndef __NVOC_CLASS_KernelGraphics_TYPEDEF__ 54 #define __NVOC_CLASS_KernelGraphics_TYPEDEF__ 55 typedef struct KernelGraphics KernelGraphics; 56 #endif /* __NVOC_CLASS_KernelGraphics_TYPEDEF__ */ 57 58 #ifndef __nvoc_class_id_KernelGraphics 59 #define __nvoc_class_id_KernelGraphics 0xea3fa9 60 #endif /* __nvoc_class_id_KernelGraphics */ 61 62 63 struct EventBuffer; 64 65 #ifndef __NVOC_CLASS_EventBuffer_TYPEDEF__ 66 #define __NVOC_CLASS_EventBuffer_TYPEDEF__ 67 typedef struct EventBuffer EventBuffer; 68 #endif /* __NVOC_CLASS_EventBuffer_TYPEDEF__ */ 69 70 #ifndef __nvoc_class_id_EventBuffer 71 #define __nvoc_class_id_EventBuffer 0x63502b 72 #endif /* __nvoc_class_id_EventBuffer */ 73 74 75 struct Subdevice; 76 77 #ifndef __NVOC_CLASS_Subdevice_TYPEDEF__ 78 #define __NVOC_CLASS_Subdevice_TYPEDEF__ 79 typedef struct Subdevice Subdevice; 80 #endif /* __NVOC_CLASS_Subdevice_TYPEDEF__ */ 81 82 #ifndef __nvoc_class_id_Subdevice 83 #define __nvoc_class_id_Subdevice 0x4b01b3 84 #endif /* __nvoc_class_id_Subdevice */ 85 86 87 88 // TODO move to cl90cdfecs.h 89 #define NV_EVENT_BUFFER_INVALID_MIG_GI 0xFF 90 #define NV_EVENT_BUFFER_INVALID_MIG_CI 0xFF 91 #define NV_EVENT_BUFFER_HIDDEN_MIG_GI 0xFE 92 #define NV_EVENT_BUFFER_HIDDEN_MIG_CI 0xFE 93 #define NV_EVENT_BUFFER_KERNEL_MIG_GI 0xFD 94 #define NV_EVENT_BUFFER_KERNEL_MIG_CI 0xFD 95 96 typedef struct 97 { 98 struct EventBuffer *pEventBuffer; 99 NvHandle hClient; 100 NvHandle hNotifier; 101 NvHandle hEventBuffer; 102 103 NvU64 pUserInfo; 104 105 NvBool bAdmin; 106 NvBool bKernel; 107 NvU32 eventMask; 108 109 NvU8 version; 110 NvU32 swizzId; 111 NvU32 computeInstanceId; 112 113 } NV_EVENT_BUFFER_BIND_POINT_FECS; 114 MAKE_MULTIMAP(FecsEventBufferBindMultiMap, NV_EVENT_BUFFER_BIND_POINT_FECS); 115 MAKE_MAP(EventBufferMap, EventBuffer*); 116 117 typedef struct 118 { 119 NvU8 tag; 120 NvU64 userInfo; 121 NvU32 context_id; 122 NvU32 pid; 123 NvU32 subpid; 124 NvU8 swizzId; 125 NvU8 computeInstanceId; 126 NvU16 dropCount; 127 NvU64 timestamp; 128 NvU64 noisyTimestamp; 129 } FECS_EVENT_NOTIFICATION_DATA; 130 131 typedef struct 132 { 133 NV_EVENT_BUFFER_RECORD_HEADER header; 134 NV_EVENT_BUFFER_FECS_RECORD_V2 record; 135 } FECS_EVENT_RECORD_OUTPUT; 136 ct_assert(NV_OFFSETOF(FECS_EVENT_RECORD_OUTPUT, record) == sizeof(NV_EVENT_BUFFER_RECORD_HEADER)); 137 ct_assert(sizeof(FECS_EVENT_RECORD_OUTPUT) == sizeof(NV_EVENT_BUFFER_RECORD_HEADER) + sizeof(NV_EVENT_BUFFER_FECS_RECORD_V2)); 138 139 140 NV_STATUS fecsAddBindpoint 141 ( 142 OBJGPU *pGpu, 143 struct RmClient *pClient, 144 RsResourceRef *pEventBufferRef, 145 struct Subdevice *pNotifier, 146 NvBool bAllUsers, 147 NV2080_CTRL_GR_FECS_BIND_EVTBUF_LOD levelOfDetail, 148 NvU32 eventFilter, 149 NvU8 version, 150 NvU32 *pReasonCode 151 ); 152 153 // Set cached internal routing handles and GR index for MIG 154 void fecsSetRoutingInfo 155 ( 156 OBJGPU *pGpu, 157 struct KernelGraphics *pKernelGraphics, 158 NvHandle hClient, 159 NvHandle hSubdevice, 160 NvU32 localGrEngineIdx 161 ); 162 163 // Clear cached internal routing handles and GR index for MIG 164 void fecsClearRoutingInfo(OBJGPU *, struct KernelGraphics *); 165 166 /*! Opaque FECS event buffer private data */ 167 typedef struct KGRAPHICS_FECS_TRACE_INFO KGRAPHICS_FECS_TRACE_INFO; 168 169 NV_STATUS fecsCtxswLoggingInit 170 ( 171 OBJGPU *pGpu, 172 struct KernelGraphics *pKernelGraphics, 173 KGRAPHICS_FECS_TRACE_INFO **ppFecsTraceInfo 174 ); 175 176 void fecsCtxswLoggingTeardown(OBJGPU *pGpu, struct KernelGraphics *pKernelGraphics); 177 178 /*! set num records to process per intr */ 179 void fecsSetRecordsPerIntr 180 ( 181 OBJGPU *pGpu, 182 struct KernelGraphics *pKernelGraphics, 183 NvU32 recordsPerIntr 184 ); 185 186 /** 187 * Returns true if a GR's FECS trace buffer has a record ready for processing 188 */ 189 NvBool fecsBufferChanged(OBJGPU *pGpu, struct KernelGraphics *pKernelGraphics); 190 191 /** 192 * Scrub the FECS tracing buffer and enable tracing (if a buffer has been mapped). 193 * 194 * The ctx logging state in GR will be set to enabled if the operation succeeded. 195 */ 196 void fecsBufferReset(OBJGPU *pGpu, struct KernelGraphics *pKernelGraphics); 197 198 /*! Is the FECS trace buffer mapped? */ 199 NvBool fecsBufferIsMapped(OBJGPU *pGpu, struct KernelGraphics *pKernelGraphics); 200 201 /** 202 * Map the FECS trace buffer 203 */ 204 NV_STATUS fecsBufferMap(OBJGPU *pGpu, struct KernelGraphics *pKernelGraphics); 205 206 /** 207 * Unmap the FECS trace buffer 208 */ 209 void fecsBufferUnmap(OBJGPU *pGpu, struct KernelGraphics *pKernelGraphics); 210 211 /** 212 * Disable FECS trace logging, unmap the trace log buffer, and remove any 213 * registered FECS trace logging callbacks. 214 * 215 * The ctx logging state in GR will be set to disabled after this operation. 216 */ 217 void fecsBufferTeardown(OBJGPU *pGpu, struct KernelGraphics *pKernelGraphics); 218 219 /** 220 * Disable FECS logging at hardware level 221 */ 222 void fecsBufferDisableHw(OBJGPU *pGpu, struct KernelGraphics *pKernelGraphics); 223 224 void fecsRemoveAllBindpoints(struct EventBuffer *pEventBuffer); 225 void fecsRemoveBindpoint(OBJGPU *pGpu, NvU64 uid, NV_EVENT_BUFFER_BIND_POINT_FECS* pBind); 226 227 /* The callback function that transfers FECS Buffer entries to an EventBuffer */ 228 void nvEventBufferFecsCallback(OBJGPU *pGpu, void *pArgs); 229 230 void notifyEventBuffers 231 ( 232 OBJGPU *pGpu, 233 FecsEventBufferBindMultiMapSubmap *pSubmap, 234 FECS_EVENT_NOTIFICATION_DATA const *pRecord 235 ); 236 237 /*! Atomically set intr callback pending, return NV_TRUE if wasn't pending prior */ 238 NvBool fecsSignalIntrPendingIfNotPending(OBJGPU *pGpu, struct KernelGraphics *pKernelGraphics); 239 240 /*! Atomically clear intr callback pending, return NV_TRUE if was pending */ 241 NvBool fecsClearIntrPendingIfPending(OBJGPU *pGpu, struct KernelGraphics *pKernelGraphics); 242 243 /*! Atomically check is intr callback pending */ 244 NvBool fecsIsIntrPending(OBJGPU *pGpu, struct KernelGraphics *pKernelGraphics); 245 246 /*! Opaque VGPU fecs event buffer private data */ 247 typedef struct VGPU_FECS_TRACE_STAGING_BUFFER VGPU_FECS_TRACE_STAGING_BUFFER; 248 249 /*! Retrieve the current VGPU staging buffer */ 250 VGPU_FECS_TRACE_STAGING_BUFFER *fecsGetVgpuStagingBuffer(OBJGPU *pGpu, struct KernelGraphics *pKernelGraphics); 251 252 /*! Store the given VGPU staging buffer */ 253 void fecsSetVgpuStagingBuffer 254 ( 255 OBJGPU *pGpu, 256 struct KernelGraphics *pKernelGraphics, 257 VGPU_FECS_TRACE_STAGING_BUFFER *pStagingBuffer 258 ); 259 260 #endif // _FECS_EVENT_LIST_H_ 261 262 #ifdef __cplusplus 263 } // extern "C" 264 #endif 265 266 #endif // _G_FECS_EVENT_LIST_NVOC_H_ 267