Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

accel/habanalabs: add Infineon version check

On HL338 ASICs, the Infineon first‑stage firmware is not present and
the reported version is 0. In this case printing a version number is
misleading, as it suggests valid firmware when it does not exist.

Fix this by printing the first‑stage Infineon firmware version only
if the reported value is non‑zero. This avoids confusing or incorrect
log messages on devices where the first stage is not applicable.

Signed-off-by: Pavan S <pavan.sreenivas@intel.com>
Reviewed-by: Koby Elbaz <koby.elbaz@intel.com>
Signed-off-by: Koby Elbaz <koby.elbaz@intel.com>

authored by

Pavan S and committed by
Koby Elbaz
6ca282c3 a0d866ba

+9 -2
+9 -2
drivers/accel/habanalabs/common/sysfs.c
··· 96 96 infineon_second_stage_third_instance = 97 97 (infineon_second_stage_version >> 16) & mask; 98 98 99 - if (cpucp_info->infineon_second_stage_version) 99 + if (cpucp_info->infineon_version && cpucp_info->infineon_second_stage_version) 100 100 return sprintf(buf, "%#04x %#04x:%#04x:%#04x\n", 101 101 le32_to_cpu(cpucp_info->infineon_version), 102 102 infineon_second_stage_first_instance, 103 103 infineon_second_stage_second_instance, 104 104 infineon_second_stage_third_instance); 105 - else 105 + else if (cpucp_info->infineon_second_stage_version) 106 + return sprintf(buf, "%#04x:%#04x:%#04x\n", 107 + infineon_second_stage_first_instance, 108 + infineon_second_stage_second_instance, 109 + infineon_second_stage_third_instance); 110 + else if (cpucp_info->infineon_version) 106 111 return sprintf(buf, "%#04x\n", le32_to_cpu(cpucp_info->infineon_version)); 112 + 113 + return 0; 107 114 } 108 115 109 116 static DEVICE_ATTR_RO(vrm_ver);