summaryrefslogtreecommitdiff
path: root/drivers/misc/habanalabs/gaudi/gaudi.c
diff options
context:
space:
mode:
authorDafna Hirschfeld <dhirschfeld@habana.ai>2022-06-23 07:28:17 +0300
committerOded Gabbay <ogabbay@kernel.org>2022-07-12 09:09:25 +0300
commit8c834a1442ad4e06f2be2574eee4a6985ad297aa (patch)
treef2317796afbe7e48a7d6d84e8186b0a9e81c95c4 /drivers/misc/habanalabs/gaudi/gaudi.c
parentc1048d14c009e2c5c777956f8481296f8526a864 (diff)
downloadlinux-8c834a1442ad4e06f2be2574eee4a6985ad297aa.tar.gz
habanalabs: don't send addr and size to scrub_device_mem cb
We use scrub_device_mem only to scrub the entire SRAM and entire DRAM. Therefore there is no need to send addr and size args to the callback. Signed-off-by: Dafna Hirschfeld <dhirschfeld@habana.ai> Reviewed-by: Oded Gabbay <ogabbay@kernel.org> Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
Diffstat (limited to 'drivers/misc/habanalabs/gaudi/gaudi.c')
-rw-r--r--drivers/misc/habanalabs/gaudi/gaudi.c64
1 files changed, 31 insertions, 33 deletions
diff --git a/drivers/misc/habanalabs/gaudi/gaudi.c b/drivers/misc/habanalabs/gaudi/gaudi.c
index 453de3d27d0c..bc5e74505d03 100644
--- a/drivers/misc/habanalabs/gaudi/gaudi.c
+++ b/drivers/misc/habanalabs/gaudi/gaudi.c
@@ -1657,7 +1657,7 @@ static int gaudi_late_init(struct hl_device *hdev)
}
/* Scrub both SRAM and DRAM */
- rc = hdev->asic_funcs->scrub_device_mem(hdev, 0, 0);
+ rc = hdev->asic_funcs->scrub_device_mem(hdev);
if (rc)
goto disable_pci_access;
@@ -4846,51 +4846,49 @@ static int gaudi_scrub_device_dram(struct hl_device *hdev, u64 val)
return 0;
}
-static int gaudi_scrub_device_mem(struct hl_device *hdev, u64 addr, u64 size)
+static int gaudi_scrub_device_mem(struct hl_device *hdev)
{
struct asic_fixed_properties *prop = &hdev->asic_prop;
+ u64 addr, size, dummy_val;
int rc = 0;
u64 val = 0;
if (!hdev->memory_scrub)
return 0;
- if (!addr && !size) {
- /* Wait till device is idle */
- rc = hl_poll_timeout(
- hdev,
- mmDMA0_CORE_STS0/* dummy */,
- val/* dummy */,
- (hdev->asic_funcs->is_device_idle(hdev, NULL,
- 0, NULL)),
- 1000,
- HBM_SCRUBBING_TIMEOUT_US);
- if (rc) {
- dev_err(hdev->dev, "waiting for idle timeout\n");
- return -EIO;
- }
+ /* Wait till device is idle */
+ rc = hl_poll_timeout(hdev,
+ mmDMA0_CORE_STS0 /* dummy */,
+ dummy_val /* dummy */,
+ (hdev->asic_funcs->is_device_idle(hdev, NULL, 0, NULL)),
+ 1000,
+ HBM_SCRUBBING_TIMEOUT_US);
+ if (rc) {
+ dev_err(hdev->dev, "waiting for idle timeout\n");
+ return -EIO;
+ }
- /* Scrub SRAM */
- addr = prop->sram_user_base_address;
- size = hdev->pldm ? 0x10000 :
- (prop->sram_size - SRAM_USER_BASE_OFFSET);
- val = 0x7777777777777777ull;
+ /* Scrub SRAM */
+ addr = prop->sram_user_base_address;
+ size = hdev->pldm ? 0x10000 : prop->sram_size - SRAM_USER_BASE_OFFSET;
+ val = 0x7777777777777777ull;
- rc = gaudi_memset_device_memory(hdev, addr, size, val);
- if (rc) {
- dev_err(hdev->dev,
- "Failed to clear SRAM in mem scrub all\n");
- return rc;
- }
+ dev_dbg(hdev->dev, "Scrubing SRAM: 0x%09llx - 0x%09llx val: 0x%llx\n",
+ addr, addr + size, val);
+ rc = gaudi_memset_device_memory(hdev, addr, size, val);
+ if (rc) {
+ dev_err(hdev->dev, "Failed to clear SRAM (%d)\n", rc);
+ return rc;
+ }
- /* Scrub HBM using all DMA channels in parallel */
- rc = gaudi_scrub_device_dram(hdev, 0xdeadbeaf);
- if (rc)
- dev_err(hdev->dev,
- "Failed to clear HBM in mem scrub all\n");
+ /* Scrub HBM using all DMA channels in parallel */
+ rc = gaudi_scrub_device_dram(hdev, 0xdeadbeaf);
+ if (rc) {
+ dev_err(hdev->dev, "Failed to clear HBM (%d)\n", rc);
+ return rc;
}
- return rc;
+ return 0;
}
static void *gaudi_get_int_queue_base(struct hl_device *hdev,