OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2009 NVIDIA Corporation. |
| 3 * All rights reserved. |
| 4 * |
| 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: |
| 7 * |
| 8 * Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. |
| 10 * |
| 11 * Redistributions in binary form must reproduce the above copyright notice, |
| 12 * this list of conditions and the following disclaimer in the documentation |
| 13 * and/or other materials provided with the distribution. |
| 14 * |
| 15 * Neither the name of the NVIDIA Corporation nor the names of its contributors |
| 16 * may be used to endorse or promote products derived from this software |
| 17 * without specific prior written permission. |
| 18 * |
| 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 29 * POSSIBILITY OF SUCH DAMAGE. |
| 30 * |
| 31 */ |
| 32 |
| 33 #define NV_IDL_IS_DISPATCH |
| 34 |
| 35 #include "nvcommon.h" |
| 36 #include "nvos.h" |
| 37 #include "nvassert.h" |
| 38 #include "nvreftrack.h" |
| 39 #include "nvidlcmd.h" |
| 40 #include "nvrm_memctrl.h" |
| 41 |
| 42 #define OFFSET( s, e ) (NvU32)(void *)(&(((s*)0)->e)) |
| 43 |
| 44 |
| 45 typedef struct NvRmCorePerfMonStop_in_t |
| 46 { |
| 47 NvU32 package_; |
| 48 NvU32 function_; |
| 49 NvRmDeviceHandle hRmDevice; |
| 50 NvU32 * pCountList; |
| 51 } NV_ALIGN(4) NvRmCorePerfMonStop_in; |
| 52 |
| 53 typedef struct NvRmCorePerfMonStop_inout_t |
| 54 { |
| 55 NvU32 pCountListSize; |
| 56 } NV_ALIGN(4) NvRmCorePerfMonStop_inout; |
| 57 |
| 58 typedef struct NvRmCorePerfMonStop_out_t |
| 59 { |
| 60 NvError ret_; |
| 61 NvU32 pTotalCycleCount; |
| 62 } NV_ALIGN(4) NvRmCorePerfMonStop_out; |
| 63 |
| 64 typedef struct NvRmCorePerfMonStop_params_t |
| 65 { |
| 66 NvRmCorePerfMonStop_in in; |
| 67 NvRmCorePerfMonStop_inout inout; |
| 68 NvRmCorePerfMonStop_out out; |
| 69 } NvRmCorePerfMonStop_params; |
| 70 |
| 71 typedef struct NvRmCorePerfMonStart_in_t |
| 72 { |
| 73 NvU32 package_; |
| 74 NvU32 function_; |
| 75 NvRmDeviceHandle hRmDevice; |
| 76 NvU32 * pEventList; |
| 77 } NV_ALIGN(4) NvRmCorePerfMonStart_in; |
| 78 |
| 79 typedef struct NvRmCorePerfMonStart_inout_t |
| 80 { |
| 81 NvU32 pEventListSize; |
| 82 } NV_ALIGN(4) NvRmCorePerfMonStart_inout; |
| 83 |
| 84 typedef struct NvRmCorePerfMonStart_out_t |
| 85 { |
| 86 NvError ret_; |
| 87 } NV_ALIGN(4) NvRmCorePerfMonStart_out; |
| 88 |
| 89 typedef struct NvRmCorePerfMonStart_params_t |
| 90 { |
| 91 NvRmCorePerfMonStart_in in; |
| 92 NvRmCorePerfMonStart_inout inout; |
| 93 NvRmCorePerfMonStart_out out; |
| 94 } NvRmCorePerfMonStart_params; |
| 95 |
| 96 typedef struct ReadObsData_in_t |
| 97 { |
| 98 NvU32 package_; |
| 99 NvU32 function_; |
| 100 NvRmDeviceHandle rm; |
| 101 NvRmModuleID modId; |
| 102 NvU32 start_index; |
| 103 NvU32 length; |
| 104 } NV_ALIGN(4) ReadObsData_in; |
| 105 |
| 106 typedef struct ReadObsData_inout_t |
| 107 { |
| 108 NvU32 dummy_; |
| 109 } NV_ALIGN(4) ReadObsData_inout; |
| 110 |
| 111 typedef struct ReadObsData_out_t |
| 112 { |
| 113 NvError ret_; |
| 114 NvU32 value; |
| 115 } NV_ALIGN(4) ReadObsData_out; |
| 116 |
| 117 typedef struct ReadObsData_params_t |
| 118 { |
| 119 ReadObsData_in in; |
| 120 ReadObsData_inout inout; |
| 121 ReadObsData_out out; |
| 122 } ReadObsData_params; |
| 123 |
| 124 typedef struct McStat_Report_in_t |
| 125 { |
| 126 NvU32 package_; |
| 127 NvU32 function_; |
| 128 NvU32 client_id_0; |
| 129 NvU32 client_0_cycles; |
| 130 NvU32 client_id_1; |
| 131 NvU32 client_1_cycles; |
| 132 NvU32 llc_client_id; |
| 133 NvU32 llc_client_clocks; |
| 134 NvU32 llc_client_cycles; |
| 135 NvU32 mc_clocks; |
| 136 } NV_ALIGN(4) McStat_Report_in; |
| 137 |
| 138 typedef struct McStat_Report_inout_t |
| 139 { |
| 140 NvU32 dummy_; |
| 141 } NV_ALIGN(4) McStat_Report_inout; |
| 142 |
| 143 typedef struct McStat_Report_out_t |
| 144 { |
| 145 NvU32 dummy_; |
| 146 } NV_ALIGN(4) McStat_Report_out; |
| 147 |
| 148 typedef struct McStat_Report_params_t |
| 149 { |
| 150 McStat_Report_in in; |
| 151 McStat_Report_inout inout; |
| 152 McStat_Report_out out; |
| 153 } McStat_Report_params; |
| 154 |
| 155 typedef struct McStat_Stop_in_t |
| 156 { |
| 157 NvU32 package_; |
| 158 NvU32 function_; |
| 159 NvRmDeviceHandle rm; |
| 160 } NV_ALIGN(4) McStat_Stop_in; |
| 161 |
| 162 typedef struct McStat_Stop_inout_t |
| 163 { |
| 164 NvU32 dummy_; |
| 165 } NV_ALIGN(4) McStat_Stop_inout; |
| 166 |
| 167 typedef struct McStat_Stop_out_t |
| 168 { |
| 169 NvU32 client_0_cycles; |
| 170 NvU32 client_1_cycles; |
| 171 NvU32 llc_client_cycles; |
| 172 NvU32 llc_client_clocks; |
| 173 NvU32 mc_clocks; |
| 174 } NV_ALIGN(4) McStat_Stop_out; |
| 175 |
| 176 typedef struct McStat_Stop_params_t |
| 177 { |
| 178 McStat_Stop_in in; |
| 179 McStat_Stop_inout inout; |
| 180 McStat_Stop_out out; |
| 181 } McStat_Stop_params; |
| 182 |
| 183 typedef struct McStat_Start_in_t |
| 184 { |
| 185 NvU32 package_; |
| 186 NvU32 function_; |
| 187 NvRmDeviceHandle rm; |
| 188 NvU32 client_id_0; |
| 189 NvU32 client_id_1; |
| 190 NvU32 llc_client_id; |
| 191 } NV_ALIGN(4) McStat_Start_in; |
| 192 |
| 193 typedef struct McStat_Start_inout_t |
| 194 { |
| 195 NvU32 dummy_; |
| 196 } NV_ALIGN(4) McStat_Start_inout; |
| 197 |
| 198 typedef struct McStat_Start_out_t |
| 199 { |
| 200 NvU32 dummy_; |
| 201 } NV_ALIGN(4) McStat_Start_out; |
| 202 |
| 203 typedef struct McStat_Start_params_t |
| 204 { |
| 205 McStat_Start_in in; |
| 206 McStat_Start_inout inout; |
| 207 McStat_Start_out out; |
| 208 } McStat_Start_params; |
| 209 |
| 210 static NvError NvRmCorePerfMonStop_dispatch_( void *InBuffer, NvU32 InSize, void
*OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 211 { |
| 212 NvError err_ = NvSuccess; |
| 213 NvRmCorePerfMonStop_in *p_in; |
| 214 NvRmCorePerfMonStop_inout *p_inout; |
| 215 NvRmCorePerfMonStop_out *p_out; |
| 216 NvRmCorePerfMonStop_inout inout; |
| 217 NvU32 *pCountList = NULL; |
| 218 |
| 219 p_in = (NvRmCorePerfMonStop_in *)InBuffer; |
| 220 p_inout = (NvRmCorePerfMonStop_inout *)((NvU8 *)InBuffer + OFFSET(NvRmCorePe
rfMonStop_params, inout)); |
| 221 p_out = (NvRmCorePerfMonStop_out *)((NvU8 *)OutBuffer + OFFSET(NvRmCorePerfM
onStop_params, out) - OFFSET(NvRmCorePerfMonStop_params, inout)); |
| 222 |
| 223 (void)inout; |
| 224 inout.pCountListSize = p_inout->pCountListSize; |
| 225 if( p_inout->pCountListSize && p_in->pCountList ) |
| 226 { |
| 227 pCountList = (NvU32 *)NvOsAlloc( p_inout->pCountListSize * sizeof( NvU3
2 ) ); |
| 228 if( !pCountList ) |
| 229 { |
| 230 err_ = NvError_InsufficientMemory; |
| 231 goto clean; |
| 232 } |
| 233 } |
| 234 |
| 235 p_out->ret_ = NvRmCorePerfMonStop( p_in->hRmDevice, &inout.pCountListSize, p
CountList, &p_out->pTotalCycleCount ); |
| 236 |
| 237 |
| 238 p_inout = (NvRmCorePerfMonStop_inout *)OutBuffer; |
| 239 p_inout->pCountListSize = inout.pCountListSize; |
| 240 if(p_in->pCountList && pCountList) |
| 241 { |
| 242 err_ = NvOsCopyOut( p_in->pCountList, pCountList, p_inout->pCountListSiz
e * sizeof( NvU32 ) ); |
| 243 if( err_ != NvSuccess ) |
| 244 { |
| 245 err_ = NvError_BadParameter; |
| 246 } |
| 247 } |
| 248 clean: |
| 249 NvOsFree( pCountList ); |
| 250 return err_; |
| 251 } |
| 252 |
| 253 static NvError NvRmCorePerfMonStart_dispatch_( void *InBuffer, NvU32 InSize, voi
d *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 254 { |
| 255 NvError err_ = NvSuccess; |
| 256 NvRmCorePerfMonStart_in *p_in; |
| 257 NvRmCorePerfMonStart_inout *p_inout; |
| 258 NvRmCorePerfMonStart_out *p_out; |
| 259 NvRmCorePerfMonStart_inout inout; |
| 260 NvU32 *pEventList = NULL; |
| 261 |
| 262 p_in = (NvRmCorePerfMonStart_in *)InBuffer; |
| 263 p_inout = (NvRmCorePerfMonStart_inout *)((NvU8 *)InBuffer + OFFSET(NvRmCoreP
erfMonStart_params, inout)); |
| 264 p_out = (NvRmCorePerfMonStart_out *)((NvU8 *)OutBuffer + OFFSET(NvRmCorePerf
MonStart_params, out) - OFFSET(NvRmCorePerfMonStart_params, inout)); |
| 265 |
| 266 (void)inout; |
| 267 inout.pEventListSize = p_inout->pEventListSize; |
| 268 if( p_inout->pEventListSize && p_in->pEventList ) |
| 269 { |
| 270 pEventList = (NvU32 *)NvOsAlloc( p_inout->pEventListSize * sizeof( NvU3
2 ) ); |
| 271 if( !pEventList ) |
| 272 { |
| 273 err_ = NvError_InsufficientMemory; |
| 274 goto clean; |
| 275 } |
| 276 if( p_in->pEventList ) |
| 277 { |
| 278 err_ = NvOsCopyIn( pEventList, p_in->pEventList, p_inout->pEventList
Size * sizeof( NvU32 ) ); |
| 279 if( err_ != NvSuccess ) |
| 280 { |
| 281 err_ = NvError_BadParameter; |
| 282 goto clean; |
| 283 } |
| 284 } |
| 285 } |
| 286 |
| 287 p_out->ret_ = NvRmCorePerfMonStart( p_in->hRmDevice, &inout.pEventListSize,
pEventList ); |
| 288 |
| 289 |
| 290 p_inout = (NvRmCorePerfMonStart_inout *)OutBuffer; |
| 291 p_inout->pEventListSize = inout.pEventListSize; |
| 292 clean: |
| 293 NvOsFree( pEventList ); |
| 294 return err_; |
| 295 } |
| 296 |
| 297 static NvError ReadObsData_dispatch_( void *InBuffer, NvU32 InSize, void *OutBuf
fer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 298 { |
| 299 NvError err_ = NvSuccess; |
| 300 ReadObsData_in *p_in; |
| 301 ReadObsData_out *p_out; |
| 302 |
| 303 p_in = (ReadObsData_in *)InBuffer; |
| 304 p_out = (ReadObsData_out *)((NvU8 *)OutBuffer + OFFSET(ReadObsData_params, o
ut) - OFFSET(ReadObsData_params, inout)); |
| 305 |
| 306 |
| 307 p_out->ret_ = ReadObsData( p_in->rm, p_in->modId, p_in->start_index, p_in->l
ength, &p_out->value ); |
| 308 |
| 309 return err_; |
| 310 } |
| 311 |
| 312 static NvError McStat_Report_dispatch_( void *InBuffer, NvU32 InSize, void *OutB
uffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 313 { |
| 314 NvError err_ = NvSuccess; |
| 315 McStat_Report_in *p_in; |
| 316 |
| 317 p_in = (McStat_Report_in *)InBuffer; |
| 318 |
| 319 |
| 320 McStat_Report( p_in->client_id_0, p_in->client_0_cycles, p_in->client_id_1,
p_in->client_1_cycles, p_in->llc_client_id, p_in->llc_client_clocks, p_in->llc_c
lient_cycles, p_in->mc_clocks ); |
| 321 |
| 322 return err_; |
| 323 } |
| 324 |
| 325 static NvError McStat_Stop_dispatch_( void *InBuffer, NvU32 InSize, void *OutBuf
fer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 326 { |
| 327 NvError err_ = NvSuccess; |
| 328 McStat_Stop_in *p_in; |
| 329 McStat_Stop_out *p_out; |
| 330 |
| 331 p_in = (McStat_Stop_in *)InBuffer; |
| 332 p_out = (McStat_Stop_out *)((NvU8 *)OutBuffer + OFFSET(McStat_Stop_params, o
ut) - OFFSET(McStat_Stop_params, inout)); |
| 333 |
| 334 |
| 335 McStat_Stop( p_in->rm, &p_out->client_0_cycles, &p_out->client_1_cycles, &p_
out->llc_client_cycles, &p_out->llc_client_clocks, &p_out->mc_clocks ); |
| 336 |
| 337 return err_; |
| 338 } |
| 339 |
| 340 static NvError McStat_Start_dispatch_( void *InBuffer, NvU32 InSize, void *OutBu
ffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 341 { |
| 342 NvError err_ = NvSuccess; |
| 343 McStat_Start_in *p_in; |
| 344 |
| 345 p_in = (McStat_Start_in *)InBuffer; |
| 346 |
| 347 |
| 348 McStat_Start( p_in->rm, p_in->client_id_0, p_in->client_id_1, p_in->llc_clie
nt_id ); |
| 349 |
| 350 return err_; |
| 351 } |
| 352 |
| 353 NvError nvrm_memctrl_Dispatch( NvU32 function, void *InBuffer, NvU32 InSize, voi
d *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx ); |
| 354 NvError nvrm_memctrl_Dispatch( NvU32 function, void *InBuffer, NvU32 InSize, voi
d *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx ) |
| 355 { |
| 356 NvError err_ = NvSuccess; |
| 357 |
| 358 switch( function ) { |
| 359 case 5: |
| 360 err_ = NvRmCorePerfMonStop_dispatch_( InBuffer, InSize, OutBuffer, OutSi
ze, Ctx ); |
| 361 break; |
| 362 case 4: |
| 363 err_ = NvRmCorePerfMonStart_dispatch_( InBuffer, InSize, OutBuffer, OutS
ize, Ctx ); |
| 364 break; |
| 365 case 3: |
| 366 err_ = ReadObsData_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ctx
); |
| 367 break; |
| 368 case 2: |
| 369 err_ = McStat_Report_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ct
x ); |
| 370 break; |
| 371 case 1: |
| 372 err_ = McStat_Stop_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ctx
); |
| 373 break; |
| 374 case 0: |
| 375 err_ = McStat_Start_dispatch_( InBuffer, InSize, OutBuffer, OutSize, Ctx
); |
| 376 break; |
| 377 default: |
| 378 err_ = NvError_BadParameter; |
| 379 break; |
| 380 } |
| 381 |
| 382 return err_; |
| 383 } |
OLD | NEW |