habanalabs: fix user mappings calculation in case of page fault
authorDani Liberman <dliberman@habana.ai>
Wed, 19 Oct 2022 17:24:55 +0000 (20:24 +0300)
committerOded Gabbay <ogabbay@kernel.org>
Wed, 23 Nov 2022 14:13:43 +0000 (16:13 +0200)
As there are 2 types of user mappings, pmmu and hmmu, calculate
only the relevant mappings for the requested type.

Signed-off-by: Dani Liberman <dliberman@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
drivers/misc/habanalabs/common/device.c

index 0026fe4..0e88396 100644 (file)
@@ -2305,8 +2305,13 @@ static void hl_capture_user_mappings(struct hl_device *hdev, bool is_pmmu)
        }
 
        mutex_lock(&ctx->mem_hash_lock);
-       hash_for_each(ctx->mem_hash, i, hnode, node)
-               pgf_info->num_of_user_mappings++;
+       hash_for_each(ctx->mem_hash, i, hnode, node) {
+               vm_type = hnode->ptr;
+               if (((*vm_type == VM_TYPE_USERPTR) && is_pmmu) ||
+                               ((*vm_type == VM_TYPE_PHYS_PACK) && !is_pmmu))
+                       pgf_info->num_of_user_mappings++;
+
+       }
 
        if (!pgf_info->num_of_user_mappings)
                goto finish;