habanalabs/gaudi: use standard error codes
authorOded Gabbay <ogabbay@kernel.org>
Sun, 6 Jun 2021 08:38:12 +0000 (11:38 +0300)
committerOded Gabbay <ogabbay@kernel.org>
Fri, 18 Jun 2021 12:23:41 +0000 (15:23 +0300)
When there is an ECC error in the HBM, return a standard error code,
-EIO in this case, and not a positive value.

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

index 703f414..9b4bd38 100644 (file)
@@ -7471,7 +7471,7 @@ static int gaudi_hbm_read_interrupts(struct hl_device *hdev, int device,
                        struct hl_eq_hbm_ecc_data *hbm_ecc_data)
 {
        u32 base, val, val2, wr_par, rd_par, ca_par, derr, serr, type, ch;
-       int err = 0;
+       int rc = 0;
 
        if (hdev->asic_prop.fw_app_cpu_boot_dev_sts0 &
                                        CPU_BOOT_DEV_STS0_HBM_ECC_EN) {
@@ -7516,7 +7516,7 @@ static int gaudi_hbm_read_interrupts(struct hl_device *hdev, int device,
                val = RREG32_MASK(base + ch * 0x1000 + 0x06C, 0x0000FFFF);
                val = (val & 0xFF) | ((val >> 8) & 0xFF);
                if (val) {
-                       err = 1;
+                       rc = -EIO;
                        dev_err(hdev->dev,
                                "HBM%d pc%d interrupts info: WR_PAR=%d, RD_PAR=%d, CA_PAR=%d, SERR=%d, DERR=%d\n",
                                device, ch * 2, val & 0x1, (val >> 1) & 0x1,
@@ -7536,7 +7536,7 @@ static int gaudi_hbm_read_interrupts(struct hl_device *hdev, int device,
                val = RREG32_MASK(base + ch * 0x1000 + 0x07C, 0x0000FFFF);
                val = (val & 0xFF) | ((val >> 8) & 0xFF);
                if (val) {
-                       err = 1;
+                       rc = -EIO;
                        dev_err(hdev->dev,
                                "HBM%d pc%d interrupts info: WR_PAR=%d, RD_PAR=%d, CA_PAR=%d, SERR=%d, DERR=%d\n",
                                device, ch * 2 + 1, val & 0x1, (val >> 1) & 0x1,
@@ -7565,7 +7565,7 @@ static int gaudi_hbm_read_interrupts(struct hl_device *hdev, int device,
        val  = RREG32(base + 0x8F30);
        val2 = RREG32(base + 0x8F34);
        if (val | val2) {
-               err = 1;
+               rc = -EIO;
                dev_err(hdev->dev,
                        "HBM %d MC SRAM SERR info: Reg 0x8F30=0x%x, Reg 0x8F34=0x%x\n",
                        device, val, val2);
@@ -7573,13 +7573,13 @@ static int gaudi_hbm_read_interrupts(struct hl_device *hdev, int device,
        val  = RREG32(base + 0x8F40);
        val2 = RREG32(base + 0x8F44);
        if (val | val2) {
-               err = 1;
+               rc = -EIO;
                dev_err(hdev->dev,
                        "HBM %d MC SRAM DERR info: Reg 0x8F40=0x%x, Reg 0x8F44=0x%x\n",
                        device, val, val2);
        }
 
-       return err;
+       return rc;
 }
 
 static int gaudi_hbm_event_to_dev(u16 hbm_event_type)