Skip to contentSkip to conversation

drm/doc: Add a label for the PRIME Buffer Sharing chapter

PATCH In review Michel Dänzer 3 participants 9 messages May 31, 2018 – Jun 1, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 drm/doc: Add a label for the PRIME Buffer Sharing chapter

From: Michel Dänzer <[email protected]>

So that it can be referenced from e.g. DOC comments.

---
 Documentation/gpu/drm-mm.rst | 2 ++
 1 file changed, 2 insertions(+)
Documentation/gpu/drm-mm.rst +2 -0
index 96ebcc2a7b41..21b6b72a9ba8 100644
@@ -395,6 +395,8 @@ VMA Offset Manager
 .. kernel-doc:: drivers/gpu/drm/drm_vma_manager.c
    :export:
 
+.. _prime_buffer_sharing:
+
 PRIME Buffer Sharing
 ====================
 
Signature · 6 lines
2.17.0

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

PATCH 2/3 drm/doc: Add initial amdgpu driver documentation

From: Michel Dänzer <[email protected]>

---
 Documentation/gpu/amdgpu.rst  | 6 ++++++
 Documentation/gpu/drivers.rst | 1 +
 2 files changed, 7 insertions(+)
 create mode 100644 Documentation/gpu/amdgpu.rst
Documentation/gpu/amdgpu.rst new file +6 -0
new file mode 100644
index 000000000000..41a14e4aa4ac
@@ -0,0 +1,6 @@
+=========================
+ drm/amdgpu AMDgpu driver
+=========================
+
+The drm/amdgpu driver supports all AMD Radeon GPUs based on the Graphics Core
+Next (GCN) architecture.
Documentation/gpu/drivers.rst +1 -0
index e8c84419a2a1..604b6d6975af 100644
@@ -4,6 +4,7 @@ GPU Driver Documentation
 
 .. toctree::
 
+   amdgpu
    i915
    meson
    pl111
Signature · 6 lines
2.17.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

PATCH 3/3 drm/amdgpu: Add documentation for PRIME related code

In reply to Michel Dänzer

From: Michel Dänzer <[email protected]>

---
 Documentation/gpu/amdgpu.rst              |  14 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c | 119 ++++++++++++++++++++++
 2 files changed, 133 insertions(+)
Documentation/gpu/amdgpu.rst +14 -0
index 41a14e4aa4ac..f557866f6788 100644
@@ -4,3 +4,17 @@
 
 The drm/amdgpu driver supports all AMD Radeon GPUs based on the Graphics Core
 Next (GCN) architecture.
+
+Core Driver Infrastructure
+==========================
+
+This section covers core driver infrastructure.
+
+PRIME Buffer Sharing
+--------------------
+
+.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c
+   :doc: PRIME Buffer Sharing
+
+.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c
+   :internal:
drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c +119 -0

191 lines not on this page · raw message

Signature · 6 lines
2.17.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 3/3
#3 lore raw

Re: [PATCH 3/3] drm/amdgpu: Add documentation for PRIME related code

Quoted 3 lines · Michel Dänzer

From: Michel Dänzer <[email protected]>

Series is:

Quoted 237 lines
---
 Documentation/gpu/amdgpu.rst              |  14 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c | 119 ++++++++++++++++++++++
 2 files changed, 133 insertions(+)
Documentation/gpu/amdgpu.rst +14 -0
index 41a14e4aa4ac..f557866f6788 100644
@@ -4,3 +4,17 @@
 
 The drm/amdgpu driver supports all AMD Radeon GPUs based on the Graphics Core
 Next (GCN) architecture.
+
+Core Driver Infrastructure
+==========================
+
+This section covers core driver infrastructure.
+
+PRIME Buffer Sharing
+--------------------
+
+.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c
+   :doc: PRIME Buffer Sharing
+
+.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c
+   :internal:
drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c +119 -1
index 4683626b065f..d1f05489595b 100644
@@ -23,6 +23,14 @@
  *
  * Authors: Alex Deucher
  */
+
+/**
+ * DOC: PRIME Buffer Sharing
+ *
+ * The following callback implementations are used for :ref:`sharing GEM buffer
+ * objects between different devices via PRIME <prime_buffer_sharing>`.
+ */
+
 #include <drm/drmP.h>
 
 #include "amdgpu.h"
@@ -32,6 +40,14 @@
 
 static const struct dma_buf_ops amdgpu_dmabuf_ops;
 
+/**
+ * amdgpu_gem_prime_get_sg_table - &drm_driver.gem_prime_get_sg_table
+ * implementation
+ * @obj: GEM buffer object
+ *
+ * Returns:
+ * A scatter/gather table for the pinned pages of the buffer object's memory.
+ */
 struct sg_table *amdgpu_gem_prime_get_sg_table(struct drm_gem_object *obj)
 {
        struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj);
@@ -40,6 +56,15 @@ struct sg_table *amdgpu_gem_prime_get_sg_table(struct drm_gem_object *obj)
        return drm_prime_pages_to_sg(bo->tbo.ttm->pages, npages);
 }
 
+/**
+ * amdgpu_gem_prime_vmap - &dma_buf_ops.vmap implementation
+ * @obj: GEM buffer object
+ *
+ * Sets up an in-kernel virtual mapping of the buffer object's memory.
+ *
+ * Returns:
+ * The virtual address of the mapping or an error pointer.
+ */
 void *amdgpu_gem_prime_vmap(struct drm_gem_object *obj)
 {
        struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj);
@@ -53,6 +78,13 @@ void *amdgpu_gem_prime_vmap(struct drm_gem_object *obj)
        return bo->dma_buf_vmap.virtual;
 }
 
+/**
+ * amdgpu_gem_prime_vunmap - &dma_buf_ops.vunmap implementation
+ * @obj: GEM buffer object
+ * @vaddr: virtual address (unused)
+ *
+ * Tears down the in-kernel virtual mapping of the buffer object's memory.
+ */
 void amdgpu_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr)
 {
        struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj);
@@ -60,6 +92,17 @@ void amdgpu_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr)
        ttm_bo_kunmap(&bo->dma_buf_vmap);
 }
 
+/**
+ * amdgpu_gem_prime_mmap - &drm_driver.gem_prime_mmap implementation
+ * @obj: GEM buffer object
+ * @vma: virtual memory area
+ *
+ * Sets up a userspace mapping of the buffer object's memory in the given
+ * virtual memory area.
+ *
+ * Returns:
+ * 0 on success or negative error code.
+ */
 int amdgpu_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
 {
        struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj);
@@ -94,6 +137,19 @@ int amdgpu_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma
        return ret;
 }
 
+/**
+ * amdgpu_gem_prime_import_sg_table - &drm_driver.gem_prime_import_sg_table
+ * implementation
+ * @dev: DRM device
+ * @attach: DMA-buf attachment
+ * @sg: Scatter/gather table
+ *
+ * Import shared DMA buffer memory exported by another device.
+ *
+ * Returns:
+ * A new GEM buffer object of the given DRM device, representing the memory
+ * described by the given DMA-buf attachment and scatter/gather table.
+ */
 struct drm_gem_object *
 amdgpu_gem_prime_import_sg_table(struct drm_device *dev,
                                 struct dma_buf_attachment *attach,
@@ -132,6 +188,19 @@ amdgpu_gem_prime_import_sg_table(struct drm_device *dev,
        return ERR_PTR(ret);
 }
 
+/**
+ * amdgpu_gem_map_attach - &dma_buf_ops.attach implementation
+ * @dma_buf: shared DMA buffer
+ * @target_dev: target device
+ * @attach: DMA-buf attachment
+ *
+ * Makes sure that the shared DMA buffer can be accessed by the target device.
+ * For now, simply pins it to the GTT domain, where it should be accessible by
+ * all DMA devices.
+ *
+ * Returns:
+ * 0 on success or negative error code.
+ */
 static int amdgpu_gem_map_attach(struct dma_buf *dma_buf,
                                 struct device *target_dev,
                                 struct dma_buf_attachment *attach)
@@ -181,6 +250,14 @@ static int amdgpu_gem_map_attach(struct dma_buf *dma_buf,
        return r;
 }
 
+/**
+ * amdgpu_gem_map_detach - &dma_buf_ops.detach implementation
+ * @dma_buf: shared DMA buffer
+ * @attach: DMA-buf attachment
+ *
+ * This is called when a shared DMA buffer no longer needs to be accessible by
+ * the other device. For now, simply unpins the buffer from GTT.
+ */
 static void amdgpu_gem_map_detach(struct dma_buf *dma_buf,
                                  struct dma_buf_attachment *attach)
 {
@@ -202,6 +279,13 @@ static void amdgpu_gem_map_detach(struct dma_buf *dma_buf,
        drm_gem_map_detach(dma_buf, attach);
 }
 
+/**
+ * amdgpu_gem_prime_res_obj - &drm_driver.gem_prime_res_obj implementation
+ * @obj: GEM buffer object
+ *
+ * Returns:
+ * The buffer object's reservation object.
+ */
 struct reservation_object *amdgpu_gem_prime_res_obj(struct drm_gem_object *obj)
 {
        struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj);
@@ -209,6 +293,18 @@ struct reservation_object *amdgpu_gem_prime_res_obj(struct drm_gem_object *obj)
        return bo->tbo.resv;
 }
 
+/**
+ * amdgpu_gem_begin_cpu_access - &dma_buf_ops.begin_cpu_access implementation
+ * @dma_buf: shared DMA buffer
+ * @direction: direction of DMA transfer
+ *
+ * This is called before CPU access to the shared DMA buffer's memory. If it's
+ * a read access, the buffer is moved to the GTT domain if possible, for optimal
+ * CPU read performance.
+ *
+ * Returns:
+ * 0 on success or negative error code.
+ */
 static int amdgpu_gem_begin_cpu_access(struct dma_buf *dma_buf,
                                       enum dma_data_direction direction)
 {
@@ -253,6 +349,18 @@ static const struct dma_buf_ops amdgpu_dmabuf_ops = {
        .vunmap = drm_gem_dmabuf_vunmap,
 };
 
+/**
+ * amdgpu_gem_prime_export - &drm_driver.gem_prime_export implementation
+ * @dev: DRM device
+ * @gobj: GEM buffer object
+ * @flags: flags like DRM_CLOEXEC and DRM_RDWR
+ *
+ * The main work is done by the &drm_gem_prime_export helper, which in turn
+ * uses &amdgpu_gem_prime_res_obj.
+ *
+ * Returns:
+ * Shared DMA buffer representing the GEM buffer object from the given device.
+ */
 struct dma_buf *amdgpu_gem_prime_export(struct drm_device *dev,
                                        struct drm_gem_object *gobj,
                                        int flags)
@@ -273,6 +381,17 @@ struct dma_buf *amdgpu_gem_prime_export(struct drm_device *dev,
        return buf;
 }
 
+/**
+ * amdgpu_gem_prime_import - &drm_driver.gem_prime_import implementation
+ * @dev: DRM device
+ * @dma_buf: Shared DMA buffer
+ *
+ * The main work is done by the &drm_gem_prime_import helper, which in turn
+ * uses &amdgpu_gem_prime_import_sg_table.
+ *
+ * Returns:
+ * GEM buffer object representing the shared DMA buffer for the given device.
+ */
 struct drm_gem_object *amdgpu_gem_prime_import(struct drm_device *dev,
                                            struct dma_buf *dma_buf)
 {
--

2.17.0

Quoted 4 lines

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

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

#4 lore raw

Re: [PATCH 3/3] drm/amdgpu: Add documentation for PRIME related code

Quoted 7 lines · Alex Deucher
Quoted 3 lines · Michel Dänzer

From: Michel Dänzer <[email protected]>

Series is:

Thanks. Is it okay to merge all of these via the amdgpu tree, or should I wait for an ack from Jon and/or core DRM maintainers for that?

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#5 lore raw

Re: [PATCH 3/3] drm/amdgpu: Add documentation for PRIME related code

Quoted 11 lines · Michel Dänzer
Quoted 7 lines · Alex Deucher
Quoted 3 lines · Michel Dänzer

From: Michel Dänzer <[email protected]>

Series is:

Thanks. Is it okay to merge all of these via the amdgpu tree, or should I wait for an ack from Jon and/or core DRM maintainers for that?

GPU documentation usually goes through the drm trees. You might want to push patch 1 (drm_mm.rst fix) via drm_misc, but the rest are can go in via the amdgpu tree since they are amdgpu specific.

Alex
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw

Re: [PATCH 3/3] drm/amdgpu: Add documentation for PRIME related code

Quoted 10 lines · Alex Deucher
Quoted 9 lines · Michel Dänzer
Quoted 7 lines · Alex Deucher
Quoted 3 lines · Michel Dänzer

From: Michel Dänzer <[email protected]>

Series is:

Quoted 6 lines
Quoted 2 lines

Thanks. Is it okay to merge all of these via the amdgpu tree, or should I wait for an ack from Jon and/or core DRM maintainers for that?

GPU documentation usually goes through the drm trees. You might want to push patch 1 (drm_mm.rst fix) via drm_misc, but the rest are can go in via the amdgpu tree since they are amdgpu specific.

I'd prefer merging all three patches together, since without patch 1, patch 3 generates the warning below while generating documentation, and the reference to the PRIME Buffer Sharing section doesn't work.

.../linux/Documentation/gpu/amdgpu.rst:2: WARNING: undefined label:
prime_buffer_sharing (if the link has no caption the label must precede a section header)

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
maintainer
#8 lore raw

Re: [PATCH 3/3] drm/amdgpu: Add documentation for PRIME related code

In reply to Michel Dänzer
Quoted 2 lines · On Fri, 1 Jun 2018 15:40:44 +0200 Michel Dänzer <[email protected]> wrote:

Thanks. Is it okay to merge all of these via the amdgpu tree, or should I wait for an ack from Jon and/or core DRM maintainers for that?

I've been assuming they would go through a DRM tree, no need to wait for me.

Thanks,

jon

#7 lore raw

Re: [PATCH 3/3] drm/amdgpu: Add documentation for PRIME related code

In reply to Michel Dänzer
Quoted 18 lines · Michel Dänzer
Quoted 10 lines · Alex Deucher
Quoted 9 lines · Michel Dänzer
Quoted 7 lines · Alex Deucher
Quoted 3 lines · Michel Dänzer

From: Michel Dänzer <[email protected]>

Series is:

Quoted 6 lines
Quoted 2 lines

Thanks. Is it okay to merge all of these via the amdgpu tree, or should I wait for an ack from Jon and/or core DRM maintainers for that?

GPU documentation usually goes through the drm trees. You might want to push patch 1 (drm_mm.rst fix) via drm_misc, but the rest are can go in via the amdgpu tree since they are amdgpu specific.

Quoted 7 lines

I'd prefer merging all three patches together, since without patch 1, patch 3 generates the warning below while generating documentation, and the reference to the PRIME Buffer Sharing section doesn't work.

.../linux/Documentation/gpu/amdgpu.rst:2: WARNING: undefined label:
prime_buffer_sharing (if the link has no caption the label must precede a section header)

That's fine. I'll take them all through the amdgpu tree.

Alex

Quoted 9 lines

--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Mesa and X developer
_______________________________________________
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