diff options
author | Oded Gabbay <oded.gabbay@gmail.com> | 2019-05-31 17:25:20 +0200 |
---|---|---|
committer | Oded Gabbay <oded.gabbay@gmail.com> | 2019-05-31 17:25:20 +0200 |
commit | 747bf88c61772ec1e670ee04f4db6af15398c2ef (patch) | |
tree | 3e80ab5855fcd6773e0d14fd05e3c246379b82ba /drivers/misc/habanalabs | |
parent | habanalabs: remove DMA mask hack for Goya (diff) | |
download | linux-747bf88c61772ec1e670ee04f4db6af15398c2ef.tar.xz linux-747bf88c61772ec1e670ee04f4db6af15398c2ef.zip |
habanalabs: add WARN in case of bad MMU mapping
This patch checks if an MMU mapping is erroneous in that the physical
address that is being mapped is NOT divisible by the page size.
If that thing happens, then the H/W will issue a transaction which will be
translated to a wrong address, because part of the address will not be
taken (the remainder of address/page size).
Because the physical address is being handled by the driver, a WARN is
suitable here as it implies a bug in the driver code itself and not a user
bug.
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
Diffstat (limited to 'drivers/misc/habanalabs')
-rw-r--r-- | drivers/misc/habanalabs/mmu.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/misc/habanalabs/mmu.c b/drivers/misc/habanalabs/mmu.c index a80162c5c373..176c315836f1 100644 --- a/drivers/misc/habanalabs/mmu.c +++ b/drivers/misc/habanalabs/mmu.c @@ -913,6 +913,10 @@ int hl_mmu_map(struct hl_ctx *ctx, u64 virt_addr, u64 phys_addr, u32 page_size) return -EFAULT; } + WARN_ONCE((phys_addr & (real_page_size - 1)), + "Mapping 0x%llx with page size of 0x%x is erroneous! Address must be divisible by page size", + phys_addr, real_page_size); + npages = page_size / real_page_size; real_virt_addr = virt_addr; real_phys_addr = phys_addr; |