diff options
author | Tomer Tayar <ttayar@habana.ai> | 2022-10-24 00:14:18 +0200 |
---|---|---|
committer | Oded Gabbay <ogabbay@kernel.org> | 2022-11-23 15:13:45 +0100 |
commit | fc69aa8640f8baf9c1246c17ca858bab9aea98b0 (patch) | |
tree | 2ffb2bdc767044076e48229daebbd6bf9699b5e1 /drivers/misc/habanalabs/common/device.c | |
parent | habanalabs: zero ts registration buff when allocated (diff) | |
download | linux-fc69aa8640f8baf9c1246c17ca858bab9aea98b0.tar.xz linux-fc69aa8640f8baf9c1246c17ca858bab9aea98b0.zip |
habanalabs: fix PCIe access to SRAM via debugfs
hl_access_sram_dram_region() uses a region base which is set within the
hl_set_dram_bar() function. However, for SRAM access this function is
not called, and we end up with a wrong value of region base and with a
bad calculated address.
Fix it by initializing the region base value independently of whether
hl_set_dram_bar() is called or not.
Signed-off-by: Tomer Tayar <ttayar@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
Diffstat (limited to 'drivers/misc/habanalabs/common/device.c')
-rw-r--r-- | drivers/misc/habanalabs/common/device.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/misc/habanalabs/common/device.c b/drivers/misc/habanalabs/common/device.c index 61ddcb1ce508..cb8ecc17bba1 100644 --- a/drivers/misc/habanalabs/common/device.c +++ b/drivers/misc/habanalabs/common/device.c @@ -69,17 +69,17 @@ int hl_access_sram_dram_region(struct hl_device *hdev, u64 addr, u64 *val, enum debugfs_access_type acc_type, enum pci_region region_type, bool set_dram_bar) { struct pci_mem_region *region = &hdev->pci_mem_region[region_type]; - u64 old_base = 0, rc, new_bar_region_base = 0; + u64 old_base = 0, rc, bar_region_base = region->region_base; void __iomem *acc_addr; if (set_dram_bar) { - old_base = hl_set_dram_bar(hdev, addr, region, &new_bar_region_base); + old_base = hl_set_dram_bar(hdev, addr, region, &bar_region_base); if (old_base == U64_MAX) return -EIO; } acc_addr = hdev->pcie_bar[region->bar_id] + region->offset_in_bar + - (addr - new_bar_region_base); + (addr - bar_region_base); switch (acc_type) { case DEBUGFS_READ8: |