Re: [PATCH 3/3] drm/amdgpu: Add documentation for PRIME related code
On Fri, Jun 1, 2018 at 9:56 AM, Michel Dänzer wrote: > On 2018-06-01 03:44 PM, Alex Deucher wrote: >> On Fri, Jun 1, 2018 at 9:40 AM, Michel Dänzer wrote: >>> On 2018-06-01 02:58 PM, Alex Deucher wrote: On Thu, May 31, 2018 at 12:17 PM, Michel Dänzer wrote: > From: Michel Dänzer > > Signed-off-by: Michel Dänzer Series is: Reviewed-by: Alex Deucher >>> >>> 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) That's fine. I'll take them all through the amdgpu tree. Alex > > > -- > Earthling Michel Dänzer | http://www.amd.com > Libre software enthusiast | Mesa and X developer > ___ > amd-gfx mailing list > amd-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/amd-gfx ___ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 3/3] drm/amdgpu: Add documentation for PRIME related code
On 2018-06-01 03:44 PM, Alex Deucher wrote: > On Fri, Jun 1, 2018 at 9:40 AM, Michel Dänzer wrote: >> On 2018-06-01 02:58 PM, Alex Deucher wrote: >>> On Thu, May 31, 2018 at 12:17 PM, Michel Dänzer wrote: From: Michel Dänzer Signed-off-by: Michel Dänzer >>> >>> Series is: >>> Reviewed-by: Alex Deucher >> >> 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) -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer ___ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 3/3] drm/amdgpu: Add documentation for PRIME related code
On Fri, Jun 1, 2018 at 9:40 AM, Michel Dänzer wrote: > On 2018-06-01 02:58 PM, Alex Deucher wrote: >> On Thu, May 31, 2018 at 12:17 PM, Michel Dänzer wrote: >>> From: Michel Dänzer >>> >>> Signed-off-by: Michel Dänzer >> >> Series is: >> Reviewed-by: Alex Deucher > > 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 ___ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 3/3] drm/amdgpu: Add documentation for PRIME related code
On 2018-06-01 02:58 PM, Alex Deucher wrote: > On Thu, May 31, 2018 at 12:17 PM, Michel Dänzer wrote: >> From: Michel Dänzer >> >> Signed-off-by: Michel Dänzer > > Series is: > Reviewed-by: Alex Deucher 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? -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer ___ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 3/3] drm/amdgpu: Add documentation for PRIME related code
On Thu, May 31, 2018 at 12:17 PM, Michel Dänzer wrote: > From: Michel Dänzer > > Signed-off-by: Michel Dänzer Series is: Reviewed-by: Alex Deucher > --- > Documentation/gpu/amdgpu.rst | 14 +++ > drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c | 119 ++ > 2 files changed, 133 insertions(+) > > diff --git a/Documentation/gpu/amdgpu.rst b/Documentation/gpu/amdgpu.rst > index 41a14e4aa4ac..f557866f6788 100644 > --- a/Documentation/gpu/amdgpu.rst > +++ b/Documentation/gpu/amdgpu.rst > @@ -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: > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c > index 4683626b065f..d1f05489595b 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c > @@ -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 `. > + */ > + > #include > > #include "amdgpu.h" > @@ -32,6 +40,14 @@ > > static const struct dma_buf_ops amdgpu_dmabuf_ops; > > +/** > + * amdgpu_gem_prime_get_sg_table - _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 - _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 - _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(>dma_buf_vmap); > } > > +/** > + * amdgpu_gem_prime_mmap - _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 - _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 - _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
[PATCH 3/3] drm/amdgpu: Add documentation for PRIME related code
From: Michel Dänzer Signed-off-by: Michel Dänzer --- Documentation/gpu/amdgpu.rst | 14 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c | 119 ++ 2 files changed, 133 insertions(+) diff --git a/Documentation/gpu/amdgpu.rst b/Documentation/gpu/amdgpu.rst index 41a14e4aa4ac..f557866f6788 100644 --- a/Documentation/gpu/amdgpu.rst +++ b/Documentation/gpu/amdgpu.rst @@ -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: diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c index 4683626b065f..d1f05489595b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c @@ -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 `. + */ + #include #include "amdgpu.h" @@ -32,6 +40,14 @@ static const struct dma_buf_ops amdgpu_dmabuf_ops; +/** + * amdgpu_gem_prime_get_sg_table - _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 - _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 - _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(>dma_buf_vmap); } +/** + * amdgpu_gem_prime_mmap - _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 - _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 - _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 - _buf_ops.detach implementation + * @dma_buf: shared DMA buffer + * @attach: DMA-buf attachment + * + * This is called