habanalabs: allow detection of unsupported f/w packets
authorOded Gabbay <ogabbay@kernel.org>
Thu, 30 Jun 2022 06:30:49 +0000 (09:30 +0300)
committerOded Gabbay <ogabbay@kernel.org>
Tue, 12 Jul 2022 06:09:29 +0000 (09:09 +0300)
If we send a packet to the f/w, and that packet is unsupported, we
want to be able to identify this situation and possibly ignore this.

Therefore, if the f/w returned an error, we need to propagate it
to the callers in the result value, if those callers were interested
in it.

In addition, no point of printing the error code here because each
caller prints its own error with a specific message.

Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
drivers/misc/habanalabs/common/firmware_if.c

index 04ca4aa..fd8dd33 100644 (file)
@@ -327,11 +327,15 @@ int hl_fw_send_cpu_message(struct hl_device *hdev, u32 hw_queue_id, u32 *msg,
 
        rc = (tmp & CPUCP_PKT_CTL_RC_MASK) >> CPUCP_PKT_CTL_RC_SHIFT;
        if (rc) {
-               dev_err(hdev->dev, "F/W ERROR %d for CPU packet %d\n",
-                       rc,
-                       (tmp & CPUCP_PKT_CTL_OPCODE_MASK)
-                                               >> CPUCP_PKT_CTL_OPCODE_SHIFT);
+               dev_dbg(hdev->dev, "F/W ERROR %d for CPU packet %d\n",
+                       rc, (tmp & CPUCP_PKT_CTL_OPCODE_MASK) >> CPUCP_PKT_CTL_OPCODE_SHIFT);
+
+               /* propagate the return code from the f/w to the callers who want to check it */
+               if (result)
+                       *result = rc;
+
                rc = -EIO;
+
        } else if (result) {
                *result = le64_to_cpu(pkt->result);
        }