<div dir="auto"><div>Hi Christian, two comments below<br><div class="gmail_extra"><br><div class="gmail_quote">Den 30 juni 2017 1:22 em skrev "Christian König" <<a href="mailto:deathsimple@vodafone.de">deathsimple@vodafone.de</a>>:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Christian König <<a href="mailto:christian.koenig@amd.com">christian.koenig@amd.com</a>><br>
<br>
This allows us to write the mapped PTEs into<br>
an IB instead of the table directly.<br>
<br>
Signed-off-by: Christian König <<a href="mailto:christian.koenig@amd.com">christian.koenig@amd.com</a>><br>
---<br>
 drivers/gpu/drm/amd/amdgpu/<wbr>amdgpu.h      |  3 ++<br>
 drivers/gpu/drm/amd/amdgpu/<wbr>amdgpu_gart.c | 64 ++++++++++++++++++++++++------<wbr>--<br>
 2 files changed, 52 insertions(+), 15 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/<wbr>amdgpu.h b/drivers/gpu/drm/amd/amdgpu/<wbr>amdgpu.h<br>
index 810796a..4a2b33d 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/<wbr>amdgpu.h<br>
+++ b/drivers/gpu/drm/amd/amdgpu/<wbr>amdgpu.h<br>
@@ -572,6 +572,9 @@ int amdgpu_gart_init(struct amdgpu_device *adev);<br>
 void amdgpu_gart_fini(struct amdgpu_device *adev);<br>
 int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,<br>
                        int pages);<br>
+int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,<br>
+                   int pages, dma_addr_t *dma_addr, uint64_t flags,<br>
+                   void *dst);<br>
 int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,<br>
                     int pages, struct page **pagelist,<br>
                     dma_addr_t *dma_addr, uint64_t flags);<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/<wbr>amdgpu_gart.c b/drivers/gpu/drm/amd/amdgpu/<wbr>amdgpu_gart.c<br>
index 8877015..d99b2b2 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/<wbr>amdgpu_gart.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/<wbr>amdgpu_gart.c<br>
@@ -280,6 +280,43 @@ int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,<br>
 }<br>
<br>
 /**<br>
+ * amdgpu_gart_map - map dma_addresses into GART entries<br>
+ *<br>
+ * @adev: amdgpu_device pointer<br>
+ * @offset: offset into the GPU's gart aperture<br>
+ * @pages: number of pages to bind<br>
+ * @dma_addr: DMA addresses of pages<br>
+ *<br>
+ * Map the dma_addresses into GART entries (all asics).<br>
+ * Returns 0 for success, -EINVAL for failure.<br>
+ */<br>
+int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,<br>
+                   int pages, dma_addr_t *dma_addr, uint64_t flags,<br>
+                   void *dst)<br>
+{<br>
+       uint64_t page_base;<br>
+       unsigned t, p;<br>
+       int i, j;<br>
+<br>
+       if (!adev->gart.ready) {<br>
+               WARN(1, "trying to bind memory to uninitialized GART !\n");<br>
+               return -EINVAL;<br>
+       }<br>
+<br>
+       t = offset / AMDGPU_GPU_PAGE_SIZE;<br>
+       p = t / (PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE);<br>
+<br>
+       for (i = 0; i < pages; i++, p++) {<br>
+               page_base = dma_addr[i];<br>
+               for (j = 0; j < (PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE); j++, t++) {<br>
+                       amdgpu_gart_set_pte_pde(adev, dst, t, page_base, flags);<br>
+                       page_base += AMDGPU_GPU_PAGE_SIZE;<br>
+               }<br>
+       }<br>
+       return 0;<br>
+}<br></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">The p variable seems set but not used in the above function.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+/**<br>
  * amdgpu_gart_bind - bind pages into the gart page table<br>
  *<br>
  * @adev: amdgpu_device pointer<br>
@@ -296,31 +333,28 @@ int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,<br>
                     int pages, struct page **pagelist, dma_addr_t *dma_addr,<br>
                     uint64_t flags)<br>
 {<br>
-       unsigned t;<br>
-       unsigned p;<br>
-       uint64_t page_base;<br>
-       int i, j;<br>
+#ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS<br>
+       unsigned i;<br>
+#endif<br>
+       int r;<br>
<br>
        if (!adev->gart.ready) {<br>
                WARN(1, "trying to bind memory to uninitialized GART !\n");<br>
                return -EINVAL;<br>
        }<br>
<br>
-       t = offset / AMDGPU_GPU_PAGE_SIZE;<br>
-       p = t / (PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE);<br>
-<br>
-       for (i = 0; i < pages; i++, p++) {<br>
 #ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS<br>
+       for (i = 0; i < pages; i++, p++)<br>
                adev->gart.pages[p] = pagelist[i];<br>
 #endif<br></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">The p variable is not declared in this function so building with </div><div dir="auto"><span style="font-family:sans-serif">CONFIG_DRM_AMDGPU_GART_DEBUGFS will fail.</span><br></div><div dir="auto"><span style="font-family:sans-serif"><br></span></div><div dir="auto"><span style="font-family:sans-serif">Regards,</span></div><div dir="auto"><span style="font-family:sans-serif">Nils</span></div><div dir="auto"><span style="font-family:sans-serif"><br></span></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
-               if (adev->gart.ptr) {<br>
-                       page_base = dma_addr[i];<br>
-                       for (j = 0; j < (PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE); j++, t++) {<br>
-                               amdgpu_gart_set_pte_pde(adev, adev->gart.ptr, t, page_base, flags);<br>
-                               page_base += AMDGPU_GPU_PAGE_SIZE;<br>
-                       }<br>
-               }<br>
+<br>
+       if (adev->gart.ptr) {<br>
+               r = amdgpu_gart_map(adev, offset, pages, dma_addr, flags,<br>
+                           adev->gart.ptr);<br>
+               if (r)<br>
+                       return r;<br>
        }<br>
+<br>
        mb();<br>
        amdgpu_gart_flush_gpu_tlb(<wbr>adev, 0);<br>
        return 0;<br>
<font color="#888888">--<br>
2.7.4<br>
<br>
______________________________<wbr>_________________<br>
amd-gfx mailing list<br>
<a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/amd-gfx</a><br>
</font></blockquote></div><br></div></div></div>