Am 01.08.2017 um 14:29 schrieb Tom St Denis:
On 01/08/17 07:55 AM, Christian König wrote:
Am 01.08.2017 um 13:51 schrieb Tom St Denis:
This helps map DMA addresses back to physical addresses.

Signed-off-by: Tom St Denis <[email protected]>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 28 ++++++++++++++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c   |  8 ++++++++
  2 files changed, 36 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
index 509f7a63d40c..5b2bb28da504 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
@@ -14,6 +14,34 @@
  #define AMDGPU_JOB_GET_TIMELINE_NAME(job) \
job->base.s_fence->finished.ops->get_timeline_name(&job->base.s_fence->finished)
+TRACE_EVENT(amdgpu_ttm_tt_populate,
+ TP_PROTO(uint16_t domain, uint8_t bus, uint8_t slot, uint8_t func, uint64_t dma_address, uint64_t phys_address),
+        TP_ARGS(domain, bus, slot, func, dma_address, phys_address),
+        TP_STRUCT__entry(
+                __field(uint16_t, domain)
+                __field(uint8_t, bus)
+                __field(uint8_t, slot)
+                __field(uint8_t, func)
+                __field(uint64_t, dma)
+                __field(uint64_t, phys)
+                ),

Better just give adev here and extract the values during the fast assign.

Easy enough, I've done this now.


+        TP_fast_assign(
+               __entry->domain = domain;
+               __entry->bus = bus;
+               __entry->slot = slot;
+               __entry->func = func;
+               __entry->dma = dma_address;
+               __entry->phys = phys_address;
+               ),
+        TP_printk("%04x:%02x:%02x.%x: 0x%llx => 0x%llx",
+              (unsigned)__entry->domain,
+              (unsigned)__entry->bus,
+              (unsigned)__entry->slot,
+              (unsigned)__entry->func,
+              (unsigned long long)__entry->dma,
+              (unsigned long long)__entry->phys)
+);
+
  TRACE_EVENT(amdgpu_mm_rreg,
          TP_PROTO(unsigned did, uint32_t reg, uint32_t value),
          TP_ARGS(did, reg, value),
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 8da59d212b3b..1cf274603476 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -43,6 +43,7 @@
  #include <linux/pagemap.h>
  #include <linux/debugfs.h>
  #include "amdgpu.h"
+#include "amdgpu_trace.h"
  #include "bif/bif_4_1_d.h"
  #define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT)
@@ -944,6 +945,13 @@ static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm)
              ttm_pool_unpopulate(ttm);
              return -EFAULT;
          }
+        trace_amdgpu_ttm_tt_populate(
+            pci_domain_nr(adev->pdev->bus),
+            adev->pdev->bus->number,
+            PCI_SLOT(adev->pdev->devfn),
+            PCI_FUNC(adev->pdev->devfn),
+            gtt->ttm.dma_address[i],
+            page_to_phys(ttm->pages[i]));

Please add that tracing for the dma pool path as well.

With that fixed the change looks good to me,
Christian.

Unsure what you mean here. The ttm_pool_populate() seems to be preparing the page list to back the request.

You need to cover multiple code path here:
1. The one you currently implemented which uses ttm_dma_populate() and pci_map_page().
2. The one using ttm_dma_populate().
3. The one using drm_prime_sg_to_page_addr_arrays() a bit above for imported BOs.
4. The in amdgpu_ttm_tt_pin_userptr() which uses dma_map_sg() for userptrs.

Basically all just take gtt->ttm.ttm.pages and fill gtt->ttm.dma_address.

I suggest to add a helper you can call to trace all pages->dma_address mappings inside a ttm.

Regards,
Christian.


Tom
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reply via email to