* [PATCH 1/2] habanalabs/gaudi: replace hl_poll_timeout with while loop
@ 2022-06-27 11:34 Oded Gabbay
2022-06-27 11:34 ` [PATCH 2/2] habanalabs: use %pa to print pci bar size Oded Gabbay
0 siblings, 1 reply; 2+ messages in thread
From: Oded Gabbay @ 2022-06-27 11:34 UTC (permalink / raw)
To: linux-kernel; +Cc: Dafna Hirschfeld, kernel test robot
From: Dafna Hirschfeld <dhirschfeld@habana.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@intel.com>
Signed-off-by: Dafna Hirschfeld <dhirschfeld@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 2/2] habanalabs: use %pa to print pci bar size
2022-06-27 11:34 [PATCH 1/2] habanalabs/gaudi: replace hl_poll_timeout with while loop Oded Gabbay
@ 2022-06-27 11:34 ` Oded Gabbay
0 siblings, 0 replies; 2+ messages in thread
From: Oded Gabbay @ 2022-06-27 11:34 UTC (permalink / raw)
To: linux-kernel
PCI bar size is resource_size_t so we should use %pa to make it work
correctly on all architectures.
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
---
drivers/misc/habanalabs/gaudi/gaudi.c | 25 +++++++++++--------------
drivers/misc/habanalabs/goya/goya.c | 25 +++++++++++--------------
2 files changed, 22 insertions(+), 28 deletions(-)
diff --git a/drivers/misc/habanalabs/gaudi/gaudi.c b/drivers/misc/habanalabs/gaudi/gaudi.c
index 05d9817985d9..8fa0b86ccb6b 100644
--- a/drivers/misc/habanalabs/gaudi/gaudi.c
+++ b/drivers/misc/habanalabs/gaudi/gaudi.c
@@ -801,6 +801,7 @@ static int gaudi_early_init(struct hl_device *hdev)
{
struct asic_fixed_properties *prop = &hdev->asic_prop;
struct pci_dev *pdev = hdev->pdev;
+ resource_size_t pci_bar_size;
u32 fw_boot_status;
int rc;
@@ -811,24 +812,20 @@ static int gaudi_early_init(struct hl_device *hdev)
}
/* Check BAR sizes */
- if (pci_resource_len(pdev, SRAM_BAR_ID) != SRAM_BAR_SIZE) {
- dev_err(hdev->dev,
- "Not " HL_NAME "? BAR %d size %llu, expecting %llu\n",
- SRAM_BAR_ID,
- (unsigned long long) pci_resource_len(pdev,
- SRAM_BAR_ID),
- SRAM_BAR_SIZE);
+ pci_bar_size = pci_resource_len(pdev, SRAM_BAR_ID);
+
+ if (pci_bar_size != SRAM_BAR_SIZE) {
+ dev_err(hdev->dev, "Not " HL_NAME "? BAR %d size %pa, expecting %llu\n",
+ SRAM_BAR_ID, &pci_bar_size, SRAM_BAR_SIZE);
rc = -ENODEV;
goto free_queue_props;
}
- if (pci_resource_len(pdev, CFG_BAR_ID) != CFG_BAR_SIZE) {
- dev_err(hdev->dev,
- "Not " HL_NAME "? BAR %d size %llu, expecting %llu\n",
- CFG_BAR_ID,
- (unsigned long long) pci_resource_len(pdev,
- CFG_BAR_ID),
- CFG_BAR_SIZE);
+ pci_bar_size = pci_resource_len(pdev, CFG_BAR_ID);
+
+ if (pci_bar_size != CFG_BAR_SIZE) {
+ dev_err(hdev->dev, "Not " HL_NAME "? BAR %d size %pa, expecting %llu\n",
+ CFG_BAR_ID, &pci_bar_size, CFG_BAR_SIZE);
rc = -ENODEV;
goto free_queue_props;
}
diff --git a/drivers/misc/habanalabs/goya/goya.c b/drivers/misc/habanalabs/goya/goya.c
index 9bde01de4fcf..3255d2044c6c 100644
--- a/drivers/misc/habanalabs/goya/goya.c
+++ b/drivers/misc/habanalabs/goya/goya.c
@@ -608,6 +608,7 @@ static int goya_early_init(struct hl_device *hdev)
{
struct asic_fixed_properties *prop = &hdev->asic_prop;
struct pci_dev *pdev = hdev->pdev;
+ resource_size_t pci_bar_size;
u32 fw_boot_status, val;
int rc;
@@ -618,24 +619,20 @@ static int goya_early_init(struct hl_device *hdev)
}
/* Check BAR sizes */
- if (pci_resource_len(pdev, SRAM_CFG_BAR_ID) != CFG_BAR_SIZE) {
- dev_err(hdev->dev,
- "Not " HL_NAME "? BAR %d size %llu, expecting %llu\n",
- SRAM_CFG_BAR_ID,
- (unsigned long long) pci_resource_len(pdev,
- SRAM_CFG_BAR_ID),
- CFG_BAR_SIZE);
+ pci_bar_size = pci_resource_len(pdev, SRAM_CFG_BAR_ID);
+
+ if (pci_bar_size != CFG_BAR_SIZE) {
+ dev_err(hdev->dev, "Not " HL_NAME "? BAR %d size %pa, expecting %llu\n",
+ SRAM_CFG_BAR_ID, &pci_bar_size, CFG_BAR_SIZE);
rc = -ENODEV;
goto free_queue_props;
}
- if (pci_resource_len(pdev, MSIX_BAR_ID) != MSIX_BAR_SIZE) {
- dev_err(hdev->dev,
- "Not " HL_NAME "? BAR %d size %llu, expecting %llu\n",
- MSIX_BAR_ID,
- (unsigned long long) pci_resource_len(pdev,
- MSIX_BAR_ID),
- MSIX_BAR_SIZE);
+ pci_bar_size = pci_resource_len(pdev, MSIX_BAR_ID);
+
+ if (pci_bar_size != MSIX_BAR_SIZE) {
+ dev_err(hdev->dev, "Not " HL_NAME "? BAR %d size %pa, expecting %llu\n",
+ MSIX_BAR_ID, &pci_bar_size, MSIX_BAR_SIZE);
rc = -ENODEV;
goto free_queue_props;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-06-27 11:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-27 11:34 [PATCH 1/2] habanalabs/gaudi: replace hl_poll_timeout with while loop Oded Gabbay
2022-06-27 11:34 ` [PATCH 2/2] habanalabs: use %pa to print pci bar size Oded Gabbay
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox