1 /* 2 * SPDX-FileCopyrightText: Copyright (c) 2021-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 * SPDX-License-Identifier: MIT 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included in 13 * all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 * DEALINGS IN THE SOFTWARE. 22 */ 23 24 /* ------------------------ Includes --------------------------------------- */ 25 #include "gpu/perf/kern_perf.h" 26 #include "gpu/perf/kern_perf_boost.h" 27 #include "rmapi/rmapi.h" 28 #include "gpu/gpu.h" 29 #include "gpu/subdevice/subdevice.h" 30 #include "resserv/rs_client.h" 31 #include "vgpu/rpc.h" 32 #include "ctrl/ctrl2080/ctrl2080perf.h" 33 34 /* ------------------------ Global Variables ------------------------------- */ 35 /* ------------------------ Static Function Prototypes --------------------- */ 36 /* ------------------------ Macros ----------------------------------------- */ 37 /* ------------------------ Public Functions ------------------------------- */ 38 39 /*! 40 * @copydoc NV2080_CTRL_CMD_PERF_BOOST 41 */ 42 NV_STATUS 43 subdeviceCtrlCmdKPerfBoost_IMPL 44 ( 45 Subdevice *pSubdevice, 46 NV2080_CTRL_PERF_BOOST_PARAMS *pBoostParams 47 ) 48 { 49 OBJGPU *pGpu = GPU_RES_GET_GPU(pSubdevice); 50 KernelPerf *pKernelPerf = GPU_GET_KERNEL_PERF(pGpu); 51 NV_STATUS status = NV_OK; 52 53 NV_CHECK_OR_RETURN(LEVEL_INFO, (pKernelPerf != NULL), NV_ERR_NOT_SUPPORTED); 54 55 status = kperfBoostSet_HAL(pKernelPerf, pSubdevice, pBoostParams); 56 return status; 57 } 58 59 /*! 60 * @copydoc kperfBoostSet 61 */ 62 NV_STATUS 63 kperfBoostSet_3x 64 ( 65 KernelPerf *pKernelPerf, 66 Subdevice *pSubdevice, 67 NV2080_CTRL_PERF_BOOST_PARAMS *pBoostParams 68 ) 69 { 70 OBJGPU *pGpu = GPU_RES_GET_GPU(pSubdevice); 71 RM_API *pRmApi = GPU_GET_PHYSICAL_RMAPI(pGpu); 72 NV_STATUS status = NV_OK; 73 NV2080_CTRL_INTERNAL_PERF_BOOST_SET_PARAMS_2X boostParams2x = {0}; 74 75 boostParams2x.flags = pBoostParams->flags; 76 boostParams2x.duration = pBoostParams->duration; 77 78 status = pRmApi->Control(pRmApi, 79 RES_GET_CLIENT_HANDLE(pSubdevice), 80 RES_GET_HANDLE(pSubdevice), 81 NV2080_CTRL_CMD_INTERNAL_PERF_BOOST_SET_2X, 82 &boostParams2x, 83 sizeof(boostParams2x)); 84 85 return status; 86 } 87 88 89