accel/habanalabs: Switch to use %ptTs
PATCH v2 1/1 accel/habanalabs: Switch to use %ptTs
Use %ptTs instead of open-coded variant to print contents of time64_t type in human readable form.
---
v2: fixed the parameters to be the pointers
drivers/accel/habanalabs/common/device.c | 25 +++--------------------- 1 file changed, 3 insertions(+), 22 deletions(-)
drivers/accel/habanalabs/common/device.c +3 -22
@@ -1066,28 +1066,11 @@ static bool is_pci_link_healthy(struct hl_device *hdev)return (device_id == hdev->pdev->device); } -static void stringify_time_of_last_heartbeat (struct hl_device *hdev,char *time_str,size_t size, -bool is_pq_hb) -{ -time64_t seconds = is_pq_hb ? hdev->heartbeat_debug_info.last_pq_heartbeat_ts - : hdev->heartbeat_debug_info.last_eq_heartbeat_ts; -struct tm tm; - -if (!seconds) -return ; - -time64_to_tm (seconds,0 , &tm); - -snprintf (time_str, size,"%ld-%02d-%02d %02d:%02d:%02d (UTC)" , - tm.tm_year +1900 , tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); -} -static bool hl_device_eq_heartbeat_received (struct hl_device *hdev) {struct eq_heartbeat_debug_info *heartbeat_debug_info = &hdev->heartbeat_debug_info;u32 cpu_q_id = heartbeat_debug_info->cpu_queue_id, pq_pi_mask = (HL_QUEUE_LENGTH <<1 ) -1 ;struct asic_fixed_properties *prop = &hdev->asic_prop; -char pq_time_str[64 ] ="N/A" , eq_time_str[64 ] ="N/A" ;if (!prop->cpucp_info.eq_health_check_supported)return true;
@@ -1095,17 +1078,15 @@ static bool hl_device_eq_heartbeat_received(struct hl_device *hdev)if (!hdev->eq_heartbeat_received) {dev_err (hdev->dev,"EQ heartbeat event was not received!\n" ); -stringify_time_of_last_heartbeat (hdev, pq_time_str,sizeof (pq_time_str), true); -stringify_time_of_last_heartbeat (hdev, eq_time_str,sizeof (eq_time_str), false);dev_err (hdev->dev, -"EQ: {CI %u, HB counter %u, last HB time: %s}, PQ: {PI: %u, CI: %u (%u), last HB time: %s}\n" , +"EQ: {CI %u, HB counter %u, last HB time: %ptTs}, PQ: {PI: %u, CI: %u (%u), last HB time: %ptTs}\n" , hdev->event_queue.ci, heartbeat_debug_info->heartbeat_event_counter, - eq_time_str, + &hdev->heartbeat_debug_info.last_eq_heartbeat_ts, hdev->kernel_queues[cpu_q_id].pi,atomic_read (&hdev->kernel_queues[cpu_q_id].ci),atomic_read (&hdev->kernel_queues[cpu_q_id].ci) & pq_pi_mask, - pq_time_str); + &hdev->heartbeat_debug_info.last_pq_heartbeat_ts);hl_eq_dump (hdev, &hdev->event_queue);
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
Quoted 2 lines · Andy Shevchenko
Use %ptTs instead of open-coded variant to print contents of
time64_ttype in human readable form.
Any comments on this, please? If no, can it be applied?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 31 lines · Andy Shevchenko
Use %ptTs instead of open-coded variant to print contents of
time64_ttype in human readable form.Signed-off-by Andy Shevchenko <[email protected]>---
v2: fixed the parameters to be the pointers
drivers/accel/habanalabs/common/device.c | 25 +++--------------------- 1 file changed, 3 insertions(+), 22 deletions(-)drivers/accel/habanalabs/common/device.c +0
-12@@ -1066,28 +1066,11 @@ static bool is_pci_link_healthy(struct hl_device *hdev)return (device_id == hdev->pdev->device); } -static void stringify_time_of_last_heartbeat (struct hl_device *hdev,char *time_str,size_t size, -bool is_pq_hb) -{ -time64_t seconds = is_pq_hb ? hdev->heartbeat_debug_info.last_pq_heartbeat_ts - : hdev->heartbeat_debug_info.last_eq_heartbeat_ts; -struct tm tm; - -if (!seconds) -return ; - -time64_to_tm (seconds,0 , &tm); -
drivers/accel/habanalabs/common/device.c static bool is_pci_link_healthy(struct hl_device *hdev) · line 1090
Quoted 10 lines
drivers/accel/habanalabs/common/device.c +0
-5-snprintf (time_str, size,"%ld-%02d-%02d %02d:%02d:%02d (UTC)" , - tm.tm_year +1900 , tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); -} -static bool hl_device_eq_heartbeat_received (struct hl_device *hdev) {struct eq_heartbeat_debug_info *heartbeat_debug_info = &hdev->heartbeat_debug_info;u32 cpu_q_id = heartbeat_debug_info->cpu_queue_id, pq_pi_mask = (HL_QUEUE_LENGTH <<1 ) -1 ;struct asic_fixed_properties *prop = &hdev->asic_prop; -char pq_time_str[64 ] ="N/A" , eq_time_str[64 ] ="N/A" ;
The "N/A" gets replaced with, I presume, "1970-01-01 00:00:00" for 0 timestamps, which is not the same thing.
But I honestly don't know anything about the driver.
BR,
Jani.
Quoted 23 lines
drivers/accel/habanalabs/common/device.c +3
-5if (!prop->cpucp_info.eq_health_check_supported)return true;@@ -1095,17 +1078,15 @@ static bool hl_device_eq_heartbeat_received(struct hl_device *hdev)if (!hdev->eq_heartbeat_received) {dev_err (hdev->dev,"EQ heartbeat event was not received!\n" ); -stringify_time_of_last_heartbeat (hdev, pq_time_str,sizeof (pq_time_str), true); -stringify_time_of_last_heartbeat (hdev, eq_time_str,sizeof (eq_time_str), false);dev_err (hdev->dev, -"EQ: {CI %u, HB counter %u, last HB time: %s}, PQ: {PI: %u, CI: %u (%u), last HB time: %s}\n" , +"EQ: {CI %u, HB counter %u, last HB time: %ptTs}, PQ: {PI: %u, CI: %u (%u), last HB time: %ptTs}\n" , hdev->event_queue.ci, heartbeat_debug_info->heartbeat_event_counter, - eq_time_str, + &hdev->heartbeat_debug_info.last_eq_heartbeat_ts, hdev->kernel_queues[cpu_q_id].pi,atomic_read (&hdev->kernel_queues[cpu_q_id].ci),atomic_read (&hdev->kernel_queues[cpu_q_id].ci) & pq_pi_mask, - pq_time_str); + &hdev->heartbeat_debug_info.last_pq_heartbeat_ts);hl_eq_dump (hdev, &hdev->event_queue);
Signature · 1 line
Jani Nikula, Intel
Quoted 3 lines · Jani Nikula
Quoted 2 lines · Andy Shevchenko
Use %ptTs instead of open-coded variant to print contents of
time64_ttype in human readable form.
...
Quoted 4 lines
drivers/accel/habanalabs/common/device.c static bool is_pci_link_healthy(struct hl_device *hdev) · line 1090
Quoted 1 line
drivers/accel/habanalabs/common/device.c +0
-1-char pq_time_str[64 ] ="N/A" , eq_time_str[64 ] ="N/A" ;The "N/A" gets replaced with, I presume, "1970-01-01 00:00:00" for 0 timestamps, which is not the same thing.
It's used only in dev_err() below which is why it's fine to update. Should I mention this in the commit message?
Quoted 1 line
But I honestly don't know anything about the driver.
Signature · 2 lines
With Best Regards, Andy Shevchenko