[PATCH 087/109] drm/amd/ras: improve ras log timestamp precision
Alex Deucher <[email protected]>
| Newsgroups | org.freedesktop.lists.amd-gfx |
|---|---|
| Message-ID | <[email protected]> |
From: YiPeng Chai <[email protected]> Improve ras log timestamp precision. Signed-off-by: YiPeng Chai <[email protected]> Reviewed-by: Hawking Zhang <[email protected]> (cherry picked from commit 2e5d98b306cdc6e1992bc068ce696d35d75ba26d) Signed-off-by: Alex Deucher <[email protected]> --- drivers/gpu/drm/amd/ras/core/log_ring.c | 4 ++-- drivers/gpu/drm/amd/ras/core/ras_cper.c | 3 ++- drivers/gpu/drm/amd/ras/ras_mgr/ras_sys.h | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/ras/core/log_ring.c b/drivers/gpu/drm/amd/ras/core/log_ring.c index b57749bc63d0f..28cda7528e2bd 100644 --- a/drivers/gpu/drm/amd/ras/core/log_ring.c +++ b/drivers/gpu/drm/amd/ras/core/log_ring.c @@ -212,7 +212,7 @@ struct ras_log_batch_tag *ras_log_ring_create_batch_tag(struct ras_core_context spin_unlock_irqrestore(&log_ring->spin_lock, flags); batch_tag->sub_seqno = 0; - batch_tag->timestamp = ras_core_get_utc_second_timestamp(ras_core); + batch_tag->timestamp = ktime_get_real_ns(); return batch_tag; } @@ -249,7 +249,7 @@ void ras_log_ring_add_log_event(struct ras_core_context *ras_core, memset(log, 0, sizeof(*log)); log->timestamp = - batch_tag ? batch_tag->timestamp : ras_core_get_utc_second_timestamp(ras_core); + batch_tag ? batch_tag->timestamp : ktime_get_real_ns(); log->event = event; if (data && size && size <= sizeof(log->body)) diff --git a/drivers/gpu/drm/amd/ras/core/ras_cper.c b/drivers/gpu/drm/amd/ras/core/ras_cper.c index 4047f9b0806e2..bb60fcd283a87 100644 --- a/drivers/gpu/drm/amd/ras/core/ras_cper.c +++ b/drivers/gpu/drm/amd/ras/core/ras_cper.c @@ -25,6 +25,7 @@ #include "core_status.h" #include "log_ring.h" #include "ras_cper.h" +#define ns_to_seconds(ns) div_u64(ns, NSEC_PER_SEC) static const struct ras_cper_guid MCE = CPER_NOTIFY__MCE; static const struct ras_cper_guid CMC = CPER_NOTIFY__CMC; @@ -69,7 +70,7 @@ static void fill_section_hdr(struct ras_core_context *ras_core, ras_core_get_device_system_info(ras_core, &dev_info); - cper_get_timestamp(ras_core, &hdr->timestamp, trace->timestamp); + cper_get_timestamp(ras_core, &hdr->timestamp, ns_to_seconds(trace->timestamp)); snprintf(record_id, sizeof(record_id), "%d:%llX", dev_info.socket_id, RAS_LOG_SEQNO_TO_BATCH_IDX(trace->seqno)); diff --git a/drivers/gpu/drm/amd/ras/ras_mgr/ras_sys.h b/drivers/gpu/drm/amd/ras/ras_mgr/ras_sys.h index 2775c7bf41b7e..de3da5571ef82 100644 --- a/drivers/gpu/drm/amd/ras/ras_mgr/ras_sys.h +++ b/drivers/gpu/drm/amd/ras/ras_mgr/ras_sys.h @@ -28,6 +28,8 @@ #include <linux/printk.h> #include <linux/dev_printk.h> #include <linux/mempool.h> +#include <linux/math64.h> +#include <linux/time.h> #include "amdgpu.h" /* inject address is 52 bits */ -- 2.55.0