Skip to content

Commit b3060f5

Browse files
Xiang Liualexdeucher
authored andcommitted
drm/amdgpu: Get timestamp from system time
Get system local time and encode it to timestamp for CPER. Signed-off-by: Xiang Liu <[email protected]> Reviewed-by: Tao Zhou <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent f3e10e1 commit b3060f5

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_cper.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@ static void __inc_entry_length(struct cper_hdr *hdr, uint32_t size)
3636
hdr->record_length += size;
3737
}
3838

39+
static void amdgpu_cper_get_timestamp(struct cper_timestamp *timestamp)
40+
{
41+
struct tm tm;
42+
time64_t now = ktime_get_real_seconds();
43+
44+
time64_to_tm(now, 0, &tm);
45+
timestamp->seconds = tm.tm_sec;
46+
timestamp->minutes = tm.tm_min;
47+
timestamp->hours = tm.tm_hour;
48+
timestamp->flag = 0;
49+
timestamp->day = tm.tm_mday;
50+
timestamp->month = 1 + tm.tm_mon;
51+
timestamp->year = (1900 + tm.tm_year) % 100;
52+
timestamp->century = (1900 + tm.tm_year) / 100;
53+
}
54+
3955
void amdgpu_cper_entry_fill_hdr(struct amdgpu_device *adev,
4056
struct cper_hdr *hdr,
4157
enum amdgpu_cper_type type,
@@ -52,7 +68,8 @@ void amdgpu_cper_entry_fill_hdr(struct amdgpu_device *adev,
5268
hdr->valid_bits.platform_id = 1;
5369
hdr->valid_bits.partition_id = 1;
5470
hdr->valid_bits.timestamp = 1;
55-
/*TODO need to initialize hdr->timestamp */
71+
72+
amdgpu_cper_get_timestamp(&hdr->timestamp);
5673

5774
snprintf(hdr->record_id, 8, "%d", atomic_inc_return(&adev->cper.unique_id));
5875
snprintf(hdr->platform_id, 16, "0x%04X:0x%04X",

0 commit comments

Comments
 (0)