[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200603201337.GA225528@ziepe.ca>
Date: Wed, 3 Jun 2020 17:13:37 -0300
From: Jason Gunthorpe <jgg@...lanox.com>
To: Dave Airlie <airlied@...il.com>,
Christoph Hellwig <hch@...radead.org>,
Christian König <christian.koenig@....com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Daniel Vetter <daniel.vetter@...ll.ch>,
dri-devel <dri-devel@...ts.freedesktop.org>,
LKML <linux-kernel@...r.kernel.org>,
Logan Gunthorpe <logang@...tatee.com>
Subject: Re: [git pull] drm for 5.8-rc1
On Tue, Jun 02, 2020 at 04:06:32PM +1000, Dave Airlie wrote:
> Hi Linus,
>
> This is the main drm pull request for 5.8-rc1.
>
> Highlights:
> Core DRM had a lot of refactoring around managed drm resources to make
> drivers simpler.
> Intel Tigerlake support is on by default
> amdgpu now support p2p PCI buffer sharing and encrypted GPU memory
Christoph Hellwig basically NAK'd this approach, why is it getting
merged all of a sudden??
https://lore.kernel.org/intel-gfx/20200311152838.GA24280@infradead.org/
Are we now OK with this same approach open coded in a driver?
This wasn't Cc'd to the usual people doing work in this PCI P2P area??
See
commit f44ffd677fb3562ac0a1ff9c8ae52672be741f00
Author: Christian König <christian.koenig@....com>
Date: Fri Mar 23 16:56:37 2018 +0100
drm/amdgpu: add support for exporting VRAM using DMA-buf v3
We should be able to do this now after checking all the prerequisites.
v2: fix entrie count in the sgt
v3: manually construct the sg
Signed-off-by: Christian König <christian.koenig@....com>
Acked-by: Daniel Vetter <daniel.vetter@...ll.ch>
Acked-by: Sumit Semwal <sumit.semwal@...aro.org>
Link: https://patchwork.freedesktop.org/patch/359295
[..]
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
index 82a3299e53c042..128a667ed8fa0d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
@@ -22,6 +22,7 @@
* Authors: Christian König
*/
+#include <linux/dma-mapping.h>
#include "amdgpu.h"
#include "amdgpu_vm.h"
#include "amdgpu_atomfirmware.h"
@@ -458,6 +459,104 @@ static void amdgpu_vram_mgr_del(struct ttm_mem_type_manager *man,
mem->mm_node = NULL;
}
+/**
+ * amdgpu_vram_mgr_alloc_sgt - allocate and fill a sg table
+ *
+ * @adev: amdgpu device pointer
+ * @mem: TTM memory object
+ * @dev: the other device
+ * @dir: dma direction
+ * @sgt: resulting sg table
+ *
+ * Allocate and fill a sg table from a VRAM allocation.
+ */
+int amdgpu_vram_mgr_alloc_sgt(struct amdgpu_device *adev,
+ struct ttm_mem_reg *mem,
+ struct device *dev,
+ enum dma_data_direction dir,
+ struct sg_table **sgt)
+{
+ struct drm_mm_node *node;
+ struct scatterlist *sg;
+ int num_entries = 0;
+ unsigned int pages;
+ int i, r;
+
+ *sgt = kmalloc(sizeof(*sg), GFP_KERNEL);
+ if (!*sgt)
+ return -ENOMEM;
+
+ for (pages = mem->num_pages, node = mem->mm_node;
+ pages; pages -= node->size, ++node)
+ ++num_entries;
+
+ r = sg_alloc_table(*sgt, num_entries, GFP_KERNEL);
+ if (r)
+ goto error_free;
+
+ for_each_sg((*sgt)->sgl, sg, num_entries, i)
+ sg->length = 0;
+
+ node = mem->mm_node;
+ for_each_sg((*sgt)->sgl, sg, num_entries, i) {
+ phys_addr_t phys = (node->start << PAGE_SHIFT) +
+ adev->gmc.aper_base;
+ size_t size = node->size << PAGE_SHIFT;
+ dma_addr_t addr;
+
+ ++node;
+ addr = dma_map_resource(dev, phys, size, dir,
+ DMA_ATTR_SKIP_CPU_SYNC);
+ r = dma_mapping_error(dev, addr);
+ if (r)
+ goto error_unmap;
+
+ sg_set_page(sg, NULL, size, 0);
+ sg_dma_address(sg) = addr;
+ sg_dma_len(sg) = size;
^^^^^^^^^^^^^^
Jason
Powered by blists - more mailing lists