[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220627113459.590125-1-ogabbay@kernel.org>
Date: Mon, 27 Jun 2022 14:34:58 +0300
From: Oded Gabbay <ogabbay@...nel.org>
To: linux-kernel@...r.kernel.org
Cc: Dafna Hirschfeld <dhirschfeld@...ana.ai>,
kernel test robot <lkp@...el.com>
Subject: [PATCH 1/2] habanalabs/gaudi: replace hl_poll_timeout with while loop
From: Dafna Hirschfeld <dhirschfeld@...ana.ai>
in gaudi_scrub_device_mem, replace call to hl_poll_timeout
with a while loop to avoid using dummy variables.
Reported-by: kernel test robot <lkp@...el.com>
Signed-off-by: Dafna Hirschfeld <dhirschfeld@...ana.ai>
Reviewed-by: Oded Gabbay <ogabbay@...nel.org>
Signed-off-by: Oded Gabbay <ogabbay@...nel.org>
---
drivers/misc/habanalabs/gaudi/gaudi.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/drivers/misc/habanalabs/gaudi/gaudi.c b/drivers/misc/habanalabs/gaudi/gaudi.c
index 584feac7ee83..05d9817985d9 100644
--- a/drivers/misc/habanalabs/gaudi/gaudi.c
+++ b/drivers/misc/habanalabs/gaudi/gaudi.c
@@ -4827,23 +4827,22 @@ static int gaudi_scrub_device_dram(struct hl_device *hdev, u64 val)
static int gaudi_scrub_device_mem(struct hl_device *hdev)
{
struct asic_fixed_properties *prop = &hdev->asic_prop;
- u64 addr, size, dummy_val;
+ u64 wait_to_idle_time = hdev->pdev ? HBM_SCRUBBING_TIMEOUT_US :
+ min_t(u64, HBM_SCRUBBING_TIMEOUT_US * 10, HL_SIM_MAX_TIMEOUT_US);
+ u64 addr, size, val = hdev->memory_scrub_val;
+ ktime_t timeout;
int rc = 0;
- u64 val = hdev->memory_scrub_val;
if (!hdev->memory_scrub)
return 0;
- /* 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;
+ timeout = ktime_add_us(ktime_get(), wait_to_idle_time);
+ while (!hdev->asic_funcs->is_device_idle(hdev, NULL, 0, NULL)) {
+ if (ktime_compare(ktime_get(), timeout) > 0) {
+ dev_err(hdev->dev, "waiting for idle timeout\n");
+ return -ETIMEDOUT;
+ }
+ usleep_range((1000 >> 2) + 1, 1000);
}
/* Scrub SRAM */
--
2.25.1
Powered by blists - more mailing lists