From: Oded Gabbay <ogabbay@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Sagiv Ozeri <sozeri@habana.ai>
Subject: [PATCH 05/12] habanalabs: save f/w preboot minor version
Date: Mon, 4 Jul 2022 12:29:34 +0300 [thread overview]
Message-ID: <20220704092941.2237683-5-ogabbay@kernel.org> (raw)
In-Reply-To: <20220704092941.2237683-1-ogabbay@kernel.org>
From: Sagiv Ozeri <sozeri@habana.ai>
We need this property for backward compatibility against the f/w.
Signed-off-by: Sagiv Ozeri <sozeri@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
---
drivers/misc/habanalabs/common/firmware_if.c | 49 ++++++++++++++++----
drivers/misc/habanalabs/common/habanalabs.h | 4 +-
2 files changed, 44 insertions(+), 9 deletions(-)
diff --git a/drivers/misc/habanalabs/common/firmware_if.c b/drivers/misc/habanalabs/common/firmware_if.c
index 64c5cdfc6dcf..04ca4aaee446 100644
--- a/drivers/misc/habanalabs/common/firmware_if.c
+++ b/drivers/misc/habanalabs/common/firmware_if.c
@@ -41,7 +41,7 @@ static char *extract_fw_ver_from_str(const char *fw_str)
ver_offset = str - fw_str;
/* Copy until the next whitespace */
- whitespace = strnstr(str, " ", VERSION_MAX_LEN - ver_offset);
+ whitespace = strnstr(str, " ", VERSION_MAX_LEN - ver_offset);
if (!whitespace)
goto free_fw_ver;
@@ -54,6 +54,43 @@ static char *extract_fw_ver_from_str(const char *fw_str)
return NULL;
}
+static int extract_fw_sub_versions(struct hl_device *hdev, char *preboot_ver)
+{
+ char major[8], minor[8], *first_dot, *second_dot;
+ int rc;
+
+ first_dot = strnstr(preboot_ver, ".", 10);
+ if (first_dot) {
+ strscpy(major, preboot_ver, first_dot - preboot_ver + 1);
+ rc = kstrtou32(major, 10, &hdev->fw_major_version);
+ } else {
+ rc = -EINVAL;
+ }
+
+ if (rc) {
+ dev_err(hdev->dev, "Error %d parsing preboot major version\n", rc);
+ goto out;
+ }
+
+ /* skip the first dot */
+ first_dot++;
+
+ second_dot = strnstr(first_dot, ".", 10);
+ if (second_dot) {
+ strscpy(minor, first_dot, second_dot - first_dot + 1);
+ rc = kstrtou32(minor, 10, &hdev->fw_minor_version);
+ } else {
+ rc = -EINVAL;
+ }
+
+ if (rc)
+ dev_err(hdev->dev, "Error %d parsing preboot minor version\n", rc);
+
+out:
+ kfree(preboot_ver);
+ return rc;
+}
+
static int hl_request_fw(struct hl_device *hdev,
const struct firmware **firmware_p,
const char *fw_name)
@@ -2012,18 +2049,14 @@ static int hl_fw_dynamic_read_device_fw_version(struct hl_device *hdev,
preboot_ver = extract_fw_ver_from_str(prop->preboot_ver);
if (preboot_ver) {
- char major[8];
int rc;
dev_info(hdev->dev, "preboot version %s\n", preboot_ver);
- sprintf(major, "%.2s", preboot_ver);
- kfree(preboot_ver);
- rc = kstrtou32(major, 10, &hdev->fw_major_version);
- if (rc) {
- dev_err(hdev->dev, "Error %d parsing preboot major version\n", rc);
+ /* This function takes care of freeing preboot_ver */
+ rc = extract_fw_sub_versions(hdev, preboot_ver);
+ if (rc)
return rc;
- }
}
break;
diff --git a/drivers/misc/habanalabs/common/habanalabs.h b/drivers/misc/habanalabs/common/habanalabs.h
index 7e84f2ce49ae..72cb12f2068a 100644
--- a/drivers/misc/habanalabs/common/habanalabs.h
+++ b/drivers/misc/habanalabs/common/habanalabs.h
@@ -3012,7 +3012,8 @@ struct hl_reset_info {
* @last_error: holds information about last session in which CS timeout or razwi error occurred.
* @reset_info: holds current device reset information.
* @stream_master_qid_arr: pointer to array with QIDs of master streams.
- * @fw_major_version: major version of current loaded preboot
+ * @fw_major_version: major version of current loaded preboot.
+ * @fw_minor_version: minor version of current loaded preboot.
* @dram_used_mem: current DRAM memory consumption.
* @memory_scrub_val: the value to which the dram will be scrubbed to using cb scrub_device_dram
* @timeout_jiffies: device CS timeout value.
@@ -3186,6 +3187,7 @@ struct hl_device {
u32 *stream_master_qid_arr;
u32 fw_major_version;
+ u32 fw_minor_version;
atomic64_t dram_used_mem;
u64 memory_scrub_val;
u64 timeout_jiffies;
--
2.25.1
next prev parent reply other threads:[~2022-07-04 9:30 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-04 9:29 [PATCH 01/12] habanalabs/gaudi2: reset device upon critical ECC event Oded Gabbay
2022-07-04 9:29 ` [PATCH 02/12] habanalabs: wait for preboot ready after hard reset Oded Gabbay
2022-07-04 9:29 ` [PATCH 03/12] habanalabs: naming refactor of user interrupt flow Oded Gabbay
2022-07-04 9:29 ` [PATCH 04/12] habanalabs: add support for common decoder interrupts Oded Gabbay
2022-07-04 9:29 ` Oded Gabbay [this message]
2022-07-04 9:29 ` [PATCH 06/12] habanalabs: allow detection of unsupported f/w packets Oded Gabbay
2022-07-04 9:29 ` [PATCH 07/12] habanalabs/gaudi2: remove unused variable Oded Gabbay
2022-07-04 9:29 ` [PATCH 08/12] habanalabs/gaudi2: SM mask can only be 8-bit Oded Gabbay
2022-07-04 9:29 ` [PATCH 09/12] habanalabs: do not set max power on a secured device Oded Gabbay
2022-07-04 9:29 ` [PATCH 10/12] habanalabs: don't declare tmp twice in same function Oded Gabbay
2022-07-04 9:29 ` [PATCH 11/12] habanalabs: make sure variable is set before used Oded Gabbay
2022-07-04 9:29 ` [PATCH 12/12] habanalabs/gaudi2: remove unused defines Oded Gabbay
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220704092941.2237683-5-ogabbay@kernel.org \
--to=ogabbay@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sozeri@habana.ai \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox