Commit 737da536 authored by Sunil Khatri's avatar Sunil Khatri Committed by Alex Deucher
Browse files

drm/amdgpu: update the functions to use amdgpu version of hmm



At times we need a bo reference for hmm and for that add
a new struct amdgpu_hmm_range which will hold an optional
bo member and hmm_range.

Use amdgpu_hmm_range instead of hmm_range and let the bo
as an optional argument for the caller if they want to
the bo reference to be taken or they want to handle that
explicitly.

Signed-off-by: default avatarSunil Khatri <sunil.khatri@amd.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 071bba96
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ struct kgd_mem {
	struct mutex lock;
	struct amdgpu_bo *bo;
	struct dma_buf *dmabuf;
	struct hmm_range *range;
	struct amdgpu_hmm_range *range;
	struct list_head attachments;
	/* protected by amdkfd_process_info.lock */
	struct list_head validate_list;
+3 −3
Original line number Diff line number Diff line
@@ -1057,7 +1057,7 @@ static int init_user_pages(struct kgd_mem *mem, uint64_t user_addr,
	struct amdkfd_process_info *process_info = mem->process_info;
	struct amdgpu_bo *bo = mem->bo;
	struct ttm_operation_ctx ctx = { true, false };
	struct hmm_range *range;
	struct amdgpu_hmm_range *range;
	int ret = 0;

	mutex_lock(&process_info->lock);
@@ -1089,7 +1089,7 @@ static int init_user_pages(struct kgd_mem *mem, uint64_t user_addr,
		return 0;
	}

	range = amdgpu_hmm_range_alloc();
	range = amdgpu_hmm_range_alloc(NULL);
	if (unlikely(!range)) {
		ret = -ENOMEM;
		goto unregister_out;
@@ -2573,7 +2573,7 @@ static int update_invalid_user_pages(struct amdkfd_process_info *process_info,
			}
		}

		mem->range = amdgpu_hmm_range_alloc();
		mem->range = amdgpu_hmm_range_alloc(NULL);
		if (unlikely(!mem->range))
			return -ENOMEM;
		/* Get updated user pages */
+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ struct amdgpu_bo_list_entry {
	struct amdgpu_bo		*bo;
	struct amdgpu_bo_va		*bo_va;
	uint32_t			priority;
	struct hmm_range		*range;
	struct amdgpu_hmm_range		*range;
	bool				user_invalidated;
};

+3 −3
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@
#include <linux/pagemap.h>
#include <linux/sync_file.h>
#include <linux/dma-buf.h>
#include <linux/hmm.h>

#include <drm/amdgpu_drm.h>
#include <drm/drm_syncobj.h>
@@ -892,7 +891,7 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
		bool userpage_invalidated = false;
		struct amdgpu_bo *bo = e->bo;

		e->range = amdgpu_hmm_range_alloc();
		e->range = amdgpu_hmm_range_alloc(NULL);
		if (unlikely(!e->range))
			return -ENOMEM;

@@ -901,7 +900,8 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
			goto out_free_user_pages;

		for (i = 0; i < bo->tbo.ttm->num_pages; i++) {
			if (bo->tbo.ttm->pages[i] != hmm_pfn_to_page(e->range->hmm_pfns[i])) {
			if (bo->tbo.ttm->pages[i] !=
				hmm_pfn_to_page(e->range->hmm_range.hmm_pfns[i])) {
				userpage_invalidated = true;
				break;
			}
+2 −2
Original line number Diff line number Diff line
@@ -531,7 +531,7 @@ int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void *data,
	struct drm_amdgpu_gem_userptr *args = data;
	struct amdgpu_fpriv *fpriv = filp->driver_priv;
	struct drm_gem_object *gobj;
	struct hmm_range *range;
	struct amdgpu_hmm_range *range;
	struct amdgpu_bo *bo;
	uint32_t handle;
	int r;
@@ -572,7 +572,7 @@ int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void *data,
		goto release_object;

	if (args->flags & AMDGPU_GEM_USERPTR_VALIDATE) {
		range = amdgpu_hmm_range_alloc();
		range = amdgpu_hmm_range_alloc(NULL);
		if (unlikely(!range))
			return -ENOMEM;
		r = amdgpu_ttm_tt_get_user_pages(bo, range);
Loading