]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
Merge tag 'misc-habanalabs-fixes-2019-06-06' of git://people.freedesktop.org/~gabbayo...
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 6 Jun 2019 13:13:22 +0000 (15:13 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 6 Jun 2019 13:13:22 +0000 (15:13 +0200)
Oded writes:

This tag contains the following fixes:

- Fix the code that checks whether we can use 2MB page size when mapping
  memory in the ASIC's MMU. The current code had a "hole" which happened
  in architectures other then x86-64.

- Fix the debugfs interface to read/write from/to the device using device
  virtual addresses. There was a bug in the translation regarding
  addresses that were mapped using 2MB page size.

- Fix a bug in the debug/profiling code, where the code didn't read the
  full address but only the lower 32-bits of the address.

* tag 'misc-habanalabs-fixes-2019-06-06' of git://people.freedesktop.org/~gabbayo/linux:
  habanalabs: Read upper bits of trace buffer from RWPHI
  habanalabs: Fix virtual address access via debugfs for 2MB pages
  habanalabs: fix bug in checking huge page optimization

drivers/misc/habanalabs/debugfs.c
drivers/misc/habanalabs/goya/goya_coresight.c
drivers/misc/habanalabs/memory.c

index 0ce5621c1324bea0efe83246b6ca73e534f6fcc0..ba418aaa404c5a8258f769014fcf89dbff343e4e 100644 (file)
@@ -500,6 +500,7 @@ static int device_va_to_pa(struct hl_device *hdev, u64 virt_addr,
 {
        struct hl_ctx *ctx = hdev->user_ctx;
        u64 hop_addr, hop_pte_addr, hop_pte;
+       u64 offset_mask = HOP4_MASK | OFFSET_MASK;
        int rc = 0;
 
        if (!ctx) {
@@ -542,12 +543,14 @@ static int device_va_to_pa(struct hl_device *hdev, u64 virt_addr,
                        goto not_mapped;
                hop_pte_addr = get_hop4_pte_addr(ctx, hop_addr, virt_addr);
                hop_pte = hdev->asic_funcs->read_pte(hdev, hop_pte_addr);
+
+               offset_mask = OFFSET_MASK;
        }
 
        if (!(hop_pte & PAGE_PRESENT_MASK))
                goto not_mapped;
 
-       *phys_addr = (hop_pte & PTE_PHYS_ADDR_MASK) | (virt_addr & OFFSET_MASK);
+       *phys_addr = (hop_pte & ~offset_mask) | (virt_addr & offset_mask);
 
        goto out;
 
index 39f62ce72660922128e54ec084fcefd59d9bb697..d7ec7ad84cc688342544f5aa4ba031d8d9424d7f 100644 (file)
@@ -425,8 +425,18 @@ static int goya_config_etr(struct hl_device *hdev,
                WREG32(base_reg + 0x28, 0);
                WREG32(base_reg + 0x304, 0);
 
-               if (params->output_size >= sizeof(u32))
-                       *(u32 *) params->output = RREG32(base_reg + 0x18);
+               if (params->output_size >= sizeof(u64)) {
+                       u32 rwp, rwphi;
+
+                       /*
+                        * The trace buffer address is 40 bits wide. The end of
+                        * the buffer is set in the RWP register (lower 32
+                        * bits), and in the RWPHI register (upper 8 bits).
+                        */
+                       rwp = RREG32(base_reg + 0x18);
+                       rwphi = RREG32(base_reg + 0x3c) & 0xff;
+                       *(u64 *) params->output = ((u64) rwphi << 32) | rwp;
+               }
        }
 
        return 0;
index d67d24c13efd8444be07f4c9f0481dd4ca20d3ac..693877e37fd87d45d45c4539aa3f7219ce363cd8 100644 (file)
@@ -675,11 +675,6 @@ static int init_phys_pg_pack_from_userptr(struct hl_ctx *ctx,
 
                total_npages += npages;
 
-               if (first) {
-                       first = false;
-                       dma_addr &= PAGE_MASK_2MB;
-               }
-
                if ((npages % PGS_IN_2MB_PAGE) ||
                                        (dma_addr & (PAGE_SIZE_2MB - 1)))
                        is_huge_page_opt = false;
@@ -704,7 +699,6 @@ static int init_phys_pg_pack_from_userptr(struct hl_ctx *ctx,
        phys_pg_pack->total_size = total_npages * page_size;
 
        j = 0;
-       first = true;
        for_each_sg(userptr->sgt->sgl, sg, userptr->sgt->nents, i) {
                npages = get_sg_info(sg, &dma_addr);