blob: 4ea0133d3a0a219a1a62f65b968095e35dcd5ab0 [file] [log] [blame]
/*************************************************************************/ /*!
@File pvr_gputrace.c
@Title PVR GPU Trace module Linux implementation
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@License MIT
The contents of this file are subject to the MIT license as set out below.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ /**************************************************************************/
extern "C"
{
#include "device.h"
#include "pvr_debug.h"
#include "pvr_gputrace.h"
#include "pvrsrv_apphint.h"
#include "pvrsrv_error.h"
#include "rgxhwperf.h"
}
#include "platform_trace.h"
#include "magma_util/macros.h"
#include <zircon/syscalls.h>
/******************************************************************************
Module In-bound API
******************************************************************************/
uint64_t
GetFlowId(const IMG_UINT32 ui32CtxId, const IMG_UINT32 ui32JobId)
{
return (static_cast<uint64_t>(ui32CtxId) << 32) | ui32JobId;
}
void
PVRGpuTraceClientWork(PVRSRV_DEVICE_NODE *psDevNode,
const IMG_UINT32 ui32CtxId,
const IMG_UINT32 ui32JobId,
const IMG_CHAR *pszKickType)
{
PVR_ASSERT(pszKickType);
PVR_DPF((PVR_DBG_VERBOSE,
"PVRGpuTraceClientKick(%s): contextId %u, "
"jobId %u",
pszKickType, ui32CtxId, ui32JobId));
TRACE_INSTANT("magma", "Kick", TRACE_SCOPE_THREAD, "type", pszKickType, "ui32CtxId", ui32CtxId, "ui32JobId",
ui32JobId);
TRACE_FLOW_BEGIN("magma", "work", GetFlowId(ui32CtxId, ui32JobId));
}
void
PVRGpuTraceWorkSwitch(IMG_UINT64 ui64HWTimestampInOSTimeNs,
const IMG_UINT32 ui32CtxId,
const IMG_UINT32 ui32CtxPriority,
const IMG_UINT32 ui32JobId,
const IMG_CHAR *pszWorkType,
PVR_GPUTRACE_SWITCH_TYPE eSwType)
{
PVR_ASSERT(pszWorkType);
// ui64HWTimestampInOSTime is in ns.
uint64_t ATTRIBUTE_UNUSED ticks = ui64HWTimestampInOSTimeNs * zx_ticks_per_second() / 1000000000;
if (eSwType == PVR_GPUTRACE_SWITCH_TYPE_BEGIN)
{
TRACE_VTHREAD_DURATION_BEGIN("magma", pszWorkType, "GPU", 0, ticks, "ui32CtxId", ui32CtxId, "ui32CtxPriority",
ui32CtxPriority, "ui32JobId", ui32JobId);
TRACE_VTHREAD_FLOW_END("magma", "work", "GPU", 0, GetFlowId(ui32CtxId, ui32JobId), ticks);
}
else if (eSwType == PVR_GPUTRACE_SWITCH_TYPE_END)
{
TRACE_VTHREAD_DURATION_END("magma", pszWorkType, "GPU", 0, ticks, "ui32CtxId", ui32CtxId, "ui32CtxPriority",
ui32CtxPriority, "ui32JobId", ui32JobId);
}
else
{
TRACE_VTHREAD_DURATION_BEGIN("magma", pszWorkType, "GPU", 0, ticks, "ui32CtxId", ui32CtxId, "ui32CtxPriority",
ui32CtxPriority, "ui32JobId", ui32JobId);
TRACE_VTHREAD_DURATION_END("magma", pszWorkType, "GPU", 0, ticks, "ui32CtxId", ui32CtxId, "ui32CtxPriority",
ui32CtxPriority, "ui32JobId", ui32JobId);
}
}
void
PVRGpuTraceUfo(IMG_UINT64 ui64OSTimestampNs,
const RGX_HWPERF_UFO_EV eEvType,
const IMG_UINT32 ui32ExtJobRef,
const IMG_UINT32 ui32CtxId,
const IMG_UINT32 ui32JobId,
const IMG_UINT32 ui32UFOCount,
const RGX_HWPERF_UFO_DATA_ELEMENT *puData)
{
// Never enabled.
}
void
PVRGpuTraceFirmware(IMG_UINT64 ui64HWTimestampInOSTimeNs, const IMG_CHAR *pszWorkType, PVR_GPUTRACE_SWITCH_TYPE eSwType)
{
// Never enabled.
}
void
PVRGpuTraceEventsLost(const RGX_HWPERF_STREAM_ID eStreamId, const IMG_UINT32 ui32LastOrdinal, const IMG_UINT32 ui32CurrOrdinal)
{
// Ignore
}
PVRSRV_ERROR
PVRGpuTraceSupportInit(void)
{
PVRSRV_ERROR eError;
eError = RGXHWPerfFTraceGPUInitSupport();
PVR_LOGR_IF_ERROR(eError, "RGXHWPerfFTraceGPUSupportInit");
return PVRSRV_OK;
}
void
PVRGpuTraceSupportDeInit(void)
{
RGXHWPerfFTraceGPUDeInitSupport();
}
PVRSRV_ERROR
PVRGpuTraceInitDevice(PVRSRV_DEVICE_NODE *psDeviceNode)
{
PVRSRV_ERROR eError;
eError = RGXHWPerfFTraceGPUInitDevice(psDeviceNode);
PVR_LOGG_IF_ERROR(eError, "RGXHWPerfFTraceGPUInitDevice", e0);
return PVRSRV_OK;
e0:
RGXHWPerfFTraceGPUDeInitDevice(psDeviceNode);
return eError;
}
void
PVRGpuTraceDeInitDevice(PVRSRV_DEVICE_NODE *psDeviceNode)
{
RGXHWPerfFTraceGPUDeInitDevice(psDeviceNode);
}
/******************************************************************************
End of file (pvr_gputrace.c)
******************************************************************************/