amd/vpelib: Add system event logging

\[WHY\]
System event logs are different than string logging. They are meant to
generate light weight events with ID and variable args and can be
coalesced with events generated by other IP components.

\[HOW\]
Add a callback function, which is implemented by the client (Like PAL)

VPELIB adds defines for a list of possible event IDs

The client is expected to handle the callback
And translate and emit the event through
native system infrastructure like ETW logging.

\[TESTING\]
Tested on system that triggers sys event, and viewed the event through
ETW viewer

Signed-off-by : Anthony Koo <anthony.koo@amd.com>

Reviewed-by: Roy Chan <Roy.Chan@amd.com>
Acked-by: Chenyu Chen <Chen-Yu.Chen@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32646>
This commit is contained in:
Koo, Anthony 2024-11-26 16:46:41 -05:00 committed by Marge Bot
parent fe58bb70e6
commit 54c4accdb1
3 changed files with 46 additions and 0 deletions

View file

@ -95,6 +95,27 @@ enum vpe_status {
given case. */
};
/*****************************************************
* Enum for emitting VPE System Events
*****************************************************/
/** @enum vpe_event_id
* @brief Event IDs are VPE events that can be emitted through
* the EventLog callback. For each event ID, the number of params
* emitted must by synchronized with handler
*/
enum vpe_event_id {
VPE_EVENT_CHECK_SUPPORT, /**< Event emitted by vpe_check_support.
Params:
UInt32 num_streams,
UInt32 target_rect.width,
UInt32 target_rect.height,
UInt32 target_rect.height
*/
VPE_EVENT_MAX_ID /**< Max ID represents the number of event IDs supported */
};
/** @enum vpe_ip_level
* @brief HW IP level
*/
@ -312,6 +333,11 @@ struct vpe_cap_funcs {
*/
typedef void (*vpe_log_func_t)(void *log_ctx, const char *fmt, ...);
/** @brief Sys Event function
* @param[in] event_id event to emit to system log
*/
typedef void (*vpe_sys_event_func_t)(enum vpe_event_id event_id, ...);
/** @brief system memory zalloc, allocated memory initailized with 0
*
* @param[in] mem_ctx given in the struct @ref vpe_init_data
@ -333,6 +359,8 @@ struct vpe_callback_funcs {
void *log_ctx; /**< optional. provided by the caller and pass back to callback */
vpe_log_func_t log; /**< Logging function */
vpe_sys_event_func_t sys_event; /**< System event function */
void *mem_ctx; /**< optional. provided by the caller and pass back to callback */
vpe_zalloc_func_t zalloc; /**< Memory allocation */
vpe_free_func_t free; /**< Free memory. In sync with @ref zalloc */

View file

@ -46,6 +46,11 @@ extern "C" {
vpe_priv->init.funcs.log(vpe_priv->init.funcs.log_ctx, __VA_ARGS__); \
} while (0)
#define vpe_event(event_id, ...) \
do { \
vpe_priv->init.funcs.sys_event(event_id, __VA_ARGS__); \
} while (0)
#define container_of(ptr, type, member) (type *)(void *)((char *)ptr - offsetof(type, member))
#define VPE_MIN_VIEWPORT_SIZE \

View file

@ -40,6 +40,11 @@
#include <stdlib.h>
#include <time.h>
static void dummy_sys_event(enum vpe_event_id eventId, ...)
{
// Do nothing, if no callback is provided for sys event
}
static void override_debug_option(
struct vpe_debug_options *debug, const struct vpe_debug_options *user_debug)
{
@ -196,6 +201,11 @@ struct vpe *vpe_create(const struct vpe_init_data *params)
vpe_priv->init = *params;
// Make sys event an optional feature but hooking up to dummy function if no callback is
// provided
if (vpe_priv->init.funcs.sys_event == NULL)
vpe_priv->init.funcs.sys_event = dummy_sys_event;
vpe_priv->pub.level =
vpe_resource_parse_ip_version(params->ver_major, params->ver_minor, params->ver_rev);
@ -600,6 +610,9 @@ enum vpe_status vpe_check_support(
if (vpe_priv->init.debug.assert_when_not_support)
VPE_ASSERT(status == VPE_STATUS_OK);
vpe_event(VPE_EVENT_CHECK_SUPPORT, vpe_priv->num_streams, param->target_rect.width,
param->target_rect.height, status);
return status;
}