Skip to contentSkip to conversation

Experimental P2P buffer sharing

PATCH In review Felix Kuehling 3 participants 9 messages Jul 6, 2017 – Jul 7, 2017 3 messages not in the archive

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

cover Experimental P2P buffer sharing

This patch series adds experimental P2P buffer sharing. It's disabled by default and can be enabled with amdgpu.p2p_sharing=1.

TODO:
* Add a whitelist of chipsets that support P2P access
* Refine UVD/VCE handling on newer IP versions with GPUVM support
* Handle foreign BOs in DC path
* Test for regressions in existing multi-GPU buffer sharing use cases

Amber Lin (1):
drm/amdgpu: handle foreign BOs in the VM mapping

Christian König (4):
drm/amdgpu: disallow foreign BOs for UVD/VCE drm/amdgpu: disallow foreign BOs in the display path drm/amdgpu: separate BO from GEM object drm/amdgpu: enable foreign DMA-buf objects v2

Felix Kuehling (1):
drm: Add helper to check exporting driver of a DMA-buf

 drivers/gpu/drm/amd/amdgpu/amdgpu.h         | 16 +++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c      |  3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c |  6 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c     |  6 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c     | 41 +++++++++++----
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c  |  7 +--
 drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c   | 80 ++++++++++++++++++++++++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c     | 17 +++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c      | 17 ++++--
 drivers/gpu/drm/drm_prime.c                 | 24 +++++++++
 include/drm/drmP.h                          |  2 +
 11 files changed, 193 insertions(+), 26 deletions(-)
Signature · 6 lines
1.9.1

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

A message that is not in the archive (sent off-list or not yet received): 1499372187-18375-1-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 1/6 drm: Add helper to check exporting driver of a DMA-buf

This allows drivers to check if a DMA-buf contains a GEM object and whether it comes from the same driver. It may be from the same or a different device.

---
 drivers/gpu/drm/drm_prime.c | 24 ++++++++++++++++++++++++
 include/drm/drmP.h          |  2 ++
 2 files changed, 26 insertions(+)
drivers/gpu/drm/drm_prime.c +24 -0
index 25aa455..a50baec 100644
@@ -594,6 +594,30 @@ int drm_gem_prime_handle_to_fd(struct drm_device *dev,
 EXPORT_SYMBOL(drm_gem_prime_handle_to_fd);
 
 /**
+ * drm_gem_prime_dmabuf_is_from_driver - check exporting driver of a dma-buf
+ * @dma_buf: dma-buf object to check
+ * @driver: driver that is the expected exporter of the dma-buf
+ *
+ * Returns true if @driver exported @dma_buf. Returns false if
+ * @dma_buf was exported by a different driver.
+ */
+bool drm_gem_prime_dmabuf_is_from_driver(const struct dma_buf *dma_buf,
+					 const struct drm_driver *driver)
+{
+	struct drm_gem_object *obj;
+
+	if (dma_buf->ops != &drm_gem_prime_dmabuf_ops)
+		return false;
+
+	obj = dma_buf->priv;
+	if (obj->dev->driver != driver)
+		return false;
+
+	return true;
+}
+EXPORT_SYMBOL(drm_gem_prime_dmabuf_is_from_driver);
+
+/**
  * drm_gem_prime_import - helper library implementation of the import callback
  * @dev: drm_device to import into
  * @dma_buf: dma-buf object to import
include/drm/drmP.h +2 -0
index 6105c05..052f747 100644
@@ -767,6 +767,8 @@ extern struct dma_buf *drm_gem_prime_export(struct drm_device *dev,
 extern int drm_gem_prime_handle_to_fd(struct drm_device *dev,
 		struct drm_file *file_priv, uint32_t handle, uint32_t flags,
 		int *prime_fd);
+extern bool drm_gem_prime_dmabuf_is_from_driver(const struct dma_buf *dma_buf,
+		const struct drm_driver *driver);
 extern struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev,
 		struct dma_buf *dma_buf);
 extern int drm_gem_prime_fd_to_handle(struct drm_device *dev,
Signature · 6 lines
1.9.1

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

A message that is not in the archive (sent off-list or not yet received): 1499372187-18375-2-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org

#4 lore raw

Re: [PATCH 1/6] drm: Add helper to check exporting driver of a DMA-buf

Am 06.07.2017 um 22:16 schrieb Felix Kuehling:

Quoted 5 lines

This allows drivers to check if a DMA-buf contains a GEM object and whether it comes from the same driver. It may be from the same or a different device.

I think Daniel/Dave hadmore a function which returns the casted GEM object or NULL in mind, but that should o it as well.

Patch is Reviewed-by: Christian König <[email protected]>

Regards,
Christian.

Quoted 45 lines
---
  drivers/gpu/drm/drm_prime.c | 24 ++++++++++++++++++++++++
  include/drm/drmP.h          |  2 ++
  2 files changed, 26 insertions(+)
drivers/gpu/drm/drm_prime.c +24 -0
index 25aa455..a50baec 100644
@@ -594,6 +594,30 @@ int drm_gem_prime_handle_to_fd(struct drm_device *dev,
  EXPORT_SYMBOL(drm_gem_prime_handle_to_fd);
 
  /**
+ * drm_gem_prime_dmabuf_is_from_driver - check exporting driver of a dma-buf
+ * @dma_buf: dma-buf object to check
+ * @driver: driver that is the expected exporter of the dma-buf
+ *
+ * Returns true if @driver exported @dma_buf. Returns false if
+ * @dma_buf was exported by a different driver.
+ */
+bool drm_gem_prime_dmabuf_is_from_driver(const struct dma_buf *dma_buf,
+					 const struct drm_driver *driver)
+{
+	struct drm_gem_object *obj;
+
+	if (dma_buf->ops != &drm_gem_prime_dmabuf_ops)
+		return false;
+
+	obj = dma_buf->priv;
+	if (obj->dev->driver != driver)
+		return false;
+
+	return true;
+}
+EXPORT_SYMBOL(drm_gem_prime_dmabuf_is_from_driver);
+
+/**
   * drm_gem_prime_import - helper library implementation of the import callback
   * @dev: drm_device to import into
   * @dma_buf: dma-buf object to import
include/drm/drmP.h +0 -0
index 6105c05..052f747 100644

include/drm/drmP.h extern struct dma_buf *drm_gem_prime_export(struct drm_device *dev, · line 774

Quoted 8 lines
include/drm/drmP.h +2 -0
@@ -767,6 +767,8 @@ extern struct dma_buf *drm_gem_prime_export(struct drm_device *dev,
  extern int drm_gem_prime_handle_to_fd(struct drm_device *dev,
  		struct drm_file *file_priv, uint32_t handle, uint32_t flags,
  		int *prime_fd);
+extern bool drm_gem_prime_dmabuf_is_from_driver(const struct dma_buf *dma_buf,
+		const struct drm_driver *driver);
  extern struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev,
  		struct dma_buf *dma_buf);
  extern int drm_gem_prime_fd_to_handle(struct drm_device *dev,

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

A message that is not in the archive (sent off-list or not yet received): 14397440-3488-5d96-4b4c-95e76906ecb8-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#6 lore raw

Re: [PATCH 1/6] drm: Add helper to check exporting driver of a DMA-buf

Quoted 11 lines · Christian König

Am 06.07.2017 um 22:16 schrieb Felix Kuehling:

Quoted 5 lines

This allows drivers to check if a DMA-buf contains a GEM object and whether it comes from the same driver. It may be from the same or a different device.

I think Daniel/Dave hadmore a function which returns the casted GEM object or NULL in mind, but that should o it as well.

Patch is Reviewed-by: Christian König <[email protected]>

Yeah I think the try_to_cast is the much cleaner interface. Also, can we pls cc the entire patch series to dri-devel, makes it much easier to see th entire context? I can't really say whether this or try_to_cast is a good idea without that ...
-Daniel

Quoted 62 lines

Regards,
Christian.

Quoted 44 lines
---
  drivers/gpu/drm/drm_prime.c | 24 ++++++++++++++++++++++++
  include/drm/drmP.h          |  2 ++
  2 files changed, 26 insertions(+)
drivers/gpu/drm/drm_prime.c +24 -0
index 25aa455..a50baec 100644
@@ -594,6 +594,30 @@ int drm_gem_prime_handle_to_fd(struct drm_device *dev,
  EXPORT_SYMBOL(drm_gem_prime_handle_to_fd);
  /**
+ * drm_gem_prime_dmabuf_is_from_driver - check exporting driver of a dma-buf
+ * @dma_buf: dma-buf object to check
+ * @driver: driver that is the expected exporter of the dma-buf
+ *
+ * Returns true if @driver exported @dma_buf. Returns false if
+ * @dma_buf was exported by a different driver.
+ */
+bool drm_gem_prime_dmabuf_is_from_driver(const struct dma_buf *dma_buf,
+					 const struct drm_driver *driver)
+{
+	struct drm_gem_object *obj;
+
+	if (dma_buf->ops != &drm_gem_prime_dmabuf_ops)
+		return false;
+
+	obj = dma_buf->priv;
+	if (obj->dev->driver != driver)
+		return false;
+
+	return true;
+}
+EXPORT_SYMBOL(drm_gem_prime_dmabuf_is_from_driver);
+
+/**
   * drm_gem_prime_import - helper library implementation of the import callback
   * @dev: drm_device to import into
   * @dma_buf: dma-buf object to import
include/drm/drmP.h +0 -0
index 6105c05..052f747 100644

include/drm/drmP.h extern struct dma_buf *drm_gem_prime_export(struct drm_device *dev, · line 774

Quoted 8 lines
include/drm/drmP.h +2 -0
@@ -767,6 +767,8 @@ extern struct dma_buf *drm_gem_prime_export(struct drm_device *dev,
  extern int drm_gem_prime_handle_to_fd(struct drm_device *dev,
  		struct drm_file *file_priv, uint32_t handle, uint32_t flags,
  		int *prime_fd);
+extern bool drm_gem_prime_dmabuf_is_from_driver(const struct dma_buf *dma_buf,
+		const struct drm_driver *driver);
  extern struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev,
  		struct dma_buf *dma_buf);
  extern int drm_gem_prime_fd_to_handle(struct drm_device *dev,

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

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#7 lore raw

PATCH 2/6 drm/amdgpu: disallow foreign BOs for UVD/VCE

In reply to a message not in the archive

From: Christian König <[email protected]>

They don't support VM mode yet.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2 -1
index 82131d7..24035e4 100644
@@ -1343,7 +1343,8 @@ struct amdgpu_bo_va_mapping *
 		struct amdgpu_bo_list_entry *lobj;
 
 		lobj = &parser->bo_list->array[i];
-		if (!lobj->bo_va)
+		if (!lobj->bo_va ||
+		    amdgpu_ttm_adev(lobj->bo_va->bo->tbo.bdev) != parser->adev)
 			continue;
 
 		list_for_each_entry(mapping, &lobj->bo_va->valids, list) {
Signature · 6 lines
1.9.1

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

PATCH 3/6 drm/amdgpu: disallow foreign BOs in the display path

In reply to a message not in the archive

From: Christian König <[email protected]>

Pinning them in other devices VRAM would obviously not work.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +6 -0
index 3341c34..bd6b0dc 100644
@@ -180,6 +180,12 @@ int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc,
 	obj = new_amdgpu_fb->obj;
 	new_abo = gem_to_amdgpu_bo(obj);
 
+	if (amdgpu_ttm_adev(new_abo->tbo.bdev) != adev) {
+		DRM_ERROR("Foreign BOs not allowed in the display engine\n");
+		r = -EINVAL;
+		goto cleanup;
+	}
+
 	/* pin the new buffer */
 	r = amdgpu_bo_reserve(new_abo, false);
 	if (unlikely(r != 0)) {
Signature · 6 lines
1.9.1

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

PATCH 4/6 drm/amdgpu: separate BO from GEM object

In reply to a message not in the archive

From: Christian König <[email protected]>

This allows us to have multiple GEM objects for one BO.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        | 12 +++++++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c    | 41 +++++++++++++++++++++++-------
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c |  7 +----
 drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c  | 20 ++++++++++++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c    | 17 +++++++++++--
 5 files changed, 77 insertions(+), 20 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +10 -2
index 2129fbb..f3d99cb 100644
@@ -414,6 +414,12 @@ struct amdgpu_bo_va {
 
 #define AMDGPU_GEM_DOMAIN_MAX		0x3
 
+struct amdgpu_gem_object {
+	struct drm_gem_object		base;
+	struct list_head		list;
+	struct amdgpu_bo		*bo;
+};
+
 struct amdgpu_bo {
 	/* Protected by tbo.reserved */
 	u32				prefered_domains;
@@ -430,12 +436,14 @@ struct amdgpu_bo {
 	void				*metadata;
 	u32				metadata_size;
 	unsigned			prime_shared_count;
+	/* GEM objects refereing to this BO */
+	struct list_head	gem_objects;
+
 	/* list of all virtual address to which this bo
 	 * is associated to
 	 */
 	struct list_head		va;
 	/* Constant after initialization */
-	struct drm_gem_object		gem_base;
 	struct amdgpu_bo		*parent;
 	struct amdgpu_bo		*shadow;
 
@@ -444,7 +452,7 @@ struct amdgpu_bo {
 	struct list_head		mn_list;
 	struct list_head		shadow_list;
 };
-#define gem_to_amdgpu_bo(gobj) container_of((gobj), struct amdgpu_bo, gem_base)
+#define gem_to_amdgpu_bo(gobj) container_of((gobj), struct amdgpu_gem_object, base)->bo
 
 void amdgpu_gem_object_free(struct drm_gem_object *obj);
 int amdgpu_gem_object_open(struct drm_gem_object *obj,
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +32 -9

66 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -6
index c34cf2c..44b7e71 100644
@@ -95,7 +95,6 @@ static void amdgpu_ttm_bo_destroy(struct ttm_buffer_object *tbo)
 
 	amdgpu_update_memory_usage(adev, &bo->tbo.mem, NULL);
 
-	drm_gem_object_release(&bo->gem_base);
 	amdgpu_bo_unref(&bo->parent);
 	if (!list_empty(&bo->shadow_list)) {
 		mutex_lock(&adev->shadow_list_lock);
@@ -344,13 +343,9 @@ int amdgpu_bo_create_restricted(struct amdgpu_device *adev,
 	bo = kzalloc(sizeof(struct amdgpu_bo), GFP_KERNEL);
 	if (bo == NULL)
 		return -ENOMEM;
-	r = drm_gem_object_init(adev->ddev, &bo->gem_base, size);
-	if (unlikely(r)) {
-		kfree(bo);
-		return r;
-	}
 	INIT_LIST_HEAD(&bo->shadow_list);
 	INIT_LIST_HEAD(&bo->va);
+	INIT_LIST_HEAD(&bo->gem_objects);
 	bo->prefered_domains = domain & (AMDGPU_GEM_DOMAIN_VRAM |
 					 AMDGPU_GEM_DOMAIN_GTT |
 					 AMDGPU_GEM_DOMAIN_CPU |
drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c +19 -1
index 6bdc866..b9425ed 100644
@@ -65,6 +65,7 @@ struct drm_gem_object *
 	struct reservation_object *resv = attach->dmabuf->resv;
 	struct amdgpu_device *adev = dev->dev_private;
 	struct amdgpu_bo *bo;
+	struct amdgpu_gem_object *gobj;
 	int ret;
 
 	ww_mutex_lock(&resv->lock, NULL);
@@ -75,7 +76,24 @@ struct drm_gem_object *
 		return ERR_PTR(ret);
 
 	bo->prime_shared_count = 1;
-	return &bo->gem_base;
+
+	gobj = kzalloc(sizeof(struct amdgpu_gem_object), GFP_KERNEL);
+	if (unlikely(!gobj)) {
+		amdgpu_bo_unref(&bo);
+		return ERR_PTR(-ENOMEM);
+	}
+
+	ret = drm_gem_object_init(adev->ddev, &gobj->base, amdgpu_bo_size(bo));
+	if (unlikely(ret)) {
+		kfree(gobj);
+		amdgpu_bo_unref(&bo);
+		return ERR_PTR(ret);
+	}
+
+	list_add(&gobj->list, &bo->gem_objects);
+	gobj->bo = amdgpu_bo_ref(bo);
+
+	return &gobj->base;
 }
 
 int amdgpu_gem_prime_pin(struct drm_gem_object *obj)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +15 -2
index 3f927c2..d0198f3 100644
@@ -235,11 +235,24 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo,
 static int amdgpu_verify_access(struct ttm_buffer_object *bo, struct file *filp)
 {
 	struct amdgpu_bo *abo = container_of(bo, struct amdgpu_bo, tbo);
+	struct drm_file *file_priv = filp->private_data;
+	struct amdgpu_gem_object *gobj;
 
 	if (amdgpu_ttm_tt_get_usermm(bo->ttm))
 		return -EPERM;
-	return drm_vma_node_verify_access(&abo->gem_base.vma_node,
-					  filp->private_data);
+
+	ww_mutex_lock(&abo->tbo.resv->lock, NULL);
+	list_for_each_entry(gobj, &abo->gem_objects, list) {
+		if (gobj->base.dev != file_priv->minor->dev)
+			continue;
+
+		ww_mutex_unlock(&abo->tbo.resv->lock);
+		return drm_vma_node_verify_access(&gobj->base.vma_node,
+						  file_priv);
+	}
+	ww_mutex_unlock(&abo->tbo.resv->lock);
+
+	return -EPERM;
 }
 
 static void amdgpu_move_null(struct ttm_buffer_object *bo,
Signature · 6 lines
1.9.1

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

PATCH 5/6 drm/amdgpu: handle foreign BOs in the VM mapping

In reply to a message not in the archive

From: Amber Lin <[email protected]>

Set the system bit for foreign BO mappings and use the remote VRAM BAR address as the VRAM base offset.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +13 -4
index 1d1810d..5f08e81 100644
@@ -1582,6 +1582,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,
 				      dma_addr_t *pages_addr,
 				      struct amdgpu_vm *vm,
 				      struct amdgpu_bo_va_mapping *mapping,
+				      uint64_t vram_base_offset,
 				      uint64_t flags,
 				      struct drm_mm_node *nodes,
 				      struct dma_fence **fence)
@@ -1640,7 +1641,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,
 				max_entries = min(max_entries, 16ull * 1024ull);
 			addr = 0;
 		} else if (flags & AMDGPU_PTE_VALID) {
-			addr += adev->vm_manager.vram_base_offset;
+			addr += vram_base_offset;
 		}
 		addr += pfn << PAGE_SHIFT;
 
@@ -1685,6 +1686,8 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev,
 	struct ttm_mem_reg *mem;
 	struct drm_mm_node *nodes;
 	struct dma_fence *exclusive;
+	uint64_t vram_base_offset = adev->vm_manager.vram_base_offset;
+	struct amdgpu_device *bo_adev;
 	int r;
 
 	if (clear || !bo_va->bo) {
@@ -1706,9 +1709,15 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev,
 
 	if (bo_va->bo) {
 		flags = amdgpu_ttm_tt_pte_flags(adev, bo_va->bo->tbo.ttm, mem);
+		bo_adev = amdgpu_ttm_adev(bo_va->bo->tbo.bdev);
 		gtt_flags = (amdgpu_ttm_is_bound(bo_va->bo->tbo.ttm) &&
-			adev == amdgpu_ttm_adev(bo_va->bo->tbo.bdev)) ?
+			adev == bo_adev) ?
 			flags : 0;
+		if (mem && mem->mem_type == TTM_PL_VRAM &&
+			adev != bo_adev) {
+			flags |= AMDGPU_PTE_SYSTEM;
+			vram_base_offset = bo_adev->mc.aper_base;
+		}
 	} else {
 		flags = 0x0;
 		gtt_flags = ~0x0;
@@ -1722,8 +1731,8 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev,
 	list_for_each_entry(mapping, &bo_va->invalids, list) {
 		r = amdgpu_vm_bo_split_mapping(adev, exclusive,
 					       gtt_flags, pages_addr, vm,
-					       mapping, flags, nodes,
-					       &bo_va->last_pt_update);
+					       mapping, vram_base_offset, flags,
+					       nodes, &bo_va->last_pt_update);
 		if (r)
 			return r;
 	}
Signature · 6 lines
1.9.1

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

PATCH 6/6 drm/amdgpu: enable foreign DMA-buf objects v2

In reply to a message not in the archive

From: Christian König <[email protected]>

We should be able to handle BOs from other instances as well.

v2:
* Add a module option that is off-by-default
* Use new DRM helper function to check the exporting driver

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h       |  4 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c   |  6 +++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c | 60 +++++++++++++++++++++++++++++++
 3 files changed, 69 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +4 -0
index f3d99cb..a8b0e21 100644
@@ -126,6 +126,8 @@
 extern int amdgpu_cik_support;
 #endif
 
+extern int amdgpu_p2p_sharing;
+
 #define AMDGPU_DEFAULT_GTT_SIZE_MB		3072ULL /* 3GB by default */
 #define AMDGPU_WAIT_IDLE_TIMEOUT_IN_MS	        3000
 #define AMDGPU_MAX_USEC_TIMEOUT			100000	/* 100 ms */
@@ -468,6 +470,8 @@ struct drm_gem_object *
 struct dma_buf *amdgpu_gem_prime_export(struct drm_device *dev,
 					struct drm_gem_object *gobj,
 					int flags);
+struct drm_gem_object *amdgpu_gem_prime_import(struct drm_device *dev,
+					       struct dma_buf *dma_buf);
 int amdgpu_gem_prime_pin(struct drm_gem_object *obj);
 void amdgpu_gem_prime_unpin(struct drm_gem_object *obj);
 struct reservation_object *amdgpu_gem_prime_res_obj(struct drm_gem_object *);
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +5 -1
index 02cf24e..3ff51a4 100644
@@ -118,6 +118,7 @@
 int amdgpu_param_buf_per_se = 0;
 int amdgpu_job_hang_limit = 0;
 int amdgpu_lbpw = -1;
+int amdgpu_p2p_sharing = 0;
 
 MODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing, in megabytes");
 module_param_named(vramlimit, amdgpu_vram_limit, int, 0600);
@@ -267,6 +268,9 @@
 module_param_named(cik_support, amdgpu_cik_support, int, 0444);
 #endif
 
+MODULE_PARM_DESC(p2p_sharing, "Enable P2P buffer sharing (1 = enabled, 0 = disabled (default))");
+module_param_named(p2p_sharing, amdgpu_p2p_sharing, int, 0444);
+
 
 static const struct pci_device_id pciidlist[] = {
 #ifdef  CONFIG_DRM_AMDGPU_SI
@@ -813,7 +817,7 @@ long amdgpu_drm_ioctl(struct file *filp,
 	.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
 	.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
 	.gem_prime_export = amdgpu_gem_prime_export,
-	.gem_prime_import = drm_gem_prime_import,
+	.gem_prime_import = amdgpu_gem_prime_import,
 	.gem_prime_pin = amdgpu_gem_prime_pin,
 	.gem_prime_unpin = amdgpu_gem_prime_unpin,
 	.gem_prime_res_obj = amdgpu_gem_prime_res_obj,
drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c +60 -0

63 lines not on this page · raw message

Signature · 6 lines
1.9.1

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