tu: Add TU_DEBUG=comm
The debug flag overrides the process's comm/cmdline values with the process's comm/cmdline. This can be useful for debugging faults that happen after the process exits (when normally the comm/cmdline would no longer be available to capture in a GPU devcoredump). Signed-off-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34846>
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
#include "drm-uapi/msm_drm.h"
|
||||
#include "util/u_debug.h"
|
||||
#include "util/u_process.h"
|
||||
#include "util/hash_table.h"
|
||||
|
||||
#include "tu_cmd_buffer.h"
|
||||
@@ -126,6 +127,36 @@ tu_drm_has_preemption(const struct tu_physical_device *dev)
|
||||
return true;
|
||||
}
|
||||
|
||||
static int
|
||||
tu_drm_set_param(int fd, uint32_t param, uint64_t value, uint32_t len)
|
||||
{
|
||||
struct drm_msm_param param_req = {
|
||||
.pipe = MSM_PIPE_3D0,
|
||||
.param = param,
|
||||
.value = value,
|
||||
.len = len,
|
||||
};
|
||||
|
||||
int ret = drmCommandWriteRead(fd, DRM_MSM_SET_PARAM, ¶m_req,
|
||||
sizeof(param_req));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
tu_drm_set_debuginfo(int fd)
|
||||
{
|
||||
if (!TU_DEBUG(COMM))
|
||||
return;
|
||||
|
||||
const char *comm = util_get_process_name();
|
||||
if (comm)
|
||||
tu_drm_set_param(fd, MSM_PARAM_COMM, (uintptr_t)comm, strlen(comm));
|
||||
|
||||
static char cmdline[0x1000];
|
||||
if (util_get_command_line(cmdline, sizeof(cmdline)))
|
||||
tu_drm_set_param(fd, MSM_PARAM_CMDLINE, (uintptr_t)cmdline, strlen(cmdline));
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
tu_drm_get_priorities(const struct tu_physical_device *dev)
|
||||
{
|
||||
@@ -209,6 +240,8 @@ msm_device_init(struct tu_device *dev)
|
||||
"failed to open device %s", dev->physical_device->fd_path);
|
||||
}
|
||||
|
||||
tu_drm_set_debuginfo(fd);
|
||||
|
||||
int ret = tu_drm_get_param(fd, MSM_PARAM_FAULTS, &dev->fault_count);
|
||||
if (ret != 0) {
|
||||
close(fd);
|
||||
@@ -1070,6 +1103,8 @@ tu_knl_drm_msm_load(struct tu_instance *instance,
|
||||
(device->msm_minor_version >= 8) &&
|
||||
tu_drm_is_memory_type_supported(fd, MSM_BO_CACHED_COHERENT);
|
||||
|
||||
tu_drm_set_debuginfo(fd);
|
||||
|
||||
device->submitqueue_priority_count = tu_drm_get_priorities(device);
|
||||
|
||||
device->ubwc_config.highest_bank_bit = tu_drm_get_highest_bank_bit(device);
|
||||
|
||||
@@ -51,6 +51,7 @@ static const struct debug_control tu_debug_options[] = {
|
||||
{ "perfcraw", TU_DEBUG_PERFCRAW },
|
||||
{ "fdmoffset", TU_DEBUG_FDM_OFFSET },
|
||||
{ "check_cmd_buffer_status", TU_DEBUG_CHECK_CMD_BUFFER_STATUS },
|
||||
{ "comm", TU_DEBUG_COMM },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ enum tu_debug_flags : uint64_t
|
||||
TU_DEBUG_PERFCRAW = BITFIELD64_BIT(30),
|
||||
TU_DEBUG_FDM_OFFSET = BITFIELD64_BIT(31),
|
||||
TU_DEBUG_CHECK_CMD_BUFFER_STATUS = BITFIELD64_BIT(32),
|
||||
TU_DEBUG_COMM = BITFIELD64_BIT(33),
|
||||
};
|
||||
|
||||
struct tu_env {
|
||||
|
||||
Reference in New Issue
Block a user