All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Harish Kasiviswanathan
	<Harish.Kasiviswanathan-5C7GfCeVMHo@public.gmane.org>,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH v2 2/2] drm/amdgpu: Add amdgpu_find_mm_node()
Date: Thu, 12 Oct 2017 10:08:08 +0200	[thread overview]
Message-ID: <3f44ec38-b4b1-0a7d-fb5a-c14f6d0d451f@gmail.com> (raw)
In-Reply-To: <1507751374-11295-2-git-send-email-Harish.Kasiviswanathan-5C7GfCeVMHo@public.gmane.org>

Am 11.10.2017 um 21:49 schrieb Harish Kasiviswanathan:
> v2: Use amdgpu_find_mm_node() in amdgpu_ttm_io_mem_pfn()
>
> Change-Id: I12231e18bb60152843cd0e0213ddd0d0e04e7497
> Signed-off-by: Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 49 ++++++++++++++++++---------------
>   1 file changed, 27 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index c5e1e35..99b1971 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -290,7 +290,24 @@ static uint64_t amdgpu_mm_node_addr(struct ttm_buffer_object *bo,
>   }
>   
>   /**
> - * amdgpu_ttm_copy_mem_to_mem - Helper function for copy
> + * amdgpu_find_mm_node - Helper function finds the drm_mm_node
> + *  corresponding to @offset. It also modifies the offset to be
> + *  within the drm_mm_node returned
> + */
> +static struct drm_mm_node *amdgpu_find_mm_node(struct ttm_mem_reg *mem,
> +					       unsigned long *offset)
> +{
> +	struct drm_mm_node *mm_node = mem->mm_node;
> +
> +	while (*offset >= (mm_node->size << PAGE_SHIFT)) {
> +		*offset -= (mm_node->size << PAGE_SHIFT);
> +		++mm_node;
> +	}
> +	return mm_node;
> +}
> +
> +/**
> + * amdgpu_copy_ttm_mem_to_mem - Helper function for copy
>    *
>    * The function copies @size bytes from {src->mem + src->offset} to
>    * {dst->mem + dst->offset}. src->bo and dst->bo could be same BO for a
> @@ -319,21 +336,13 @@ int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev,
>   		return -EINVAL;
>   	}
>   
> -	src_mm = src->mem->mm_node;
> -	while (src->offset >= (src_mm->size << PAGE_SHIFT)) {
> -		src->offset -= (src_mm->size << PAGE_SHIFT);
> -		++src_mm;
> -	}
> +	src_mm = amdgpu_find_mm_node(src->mem, &src->offset);
>   	src_node_start = amdgpu_mm_node_addr(src->bo, src_mm, src->mem) +
>   					     src->offset;
>   	src_node_size = (src_mm->size << PAGE_SHIFT) - src->offset;
>   	src_page_offset = src_node_start & (PAGE_SIZE - 1);
>   
> -	dst_mm = dst->mem->mm_node;
> -	while (dst->offset >= (dst_mm->size << PAGE_SHIFT)) {
> -		dst->offset -= (dst_mm->size << PAGE_SHIFT);
> -		++dst_mm;
> -	}
> +	dst_mm = amdgpu_find_mm_node(dst->mem, &dst->offset);
>   	dst_node_start = amdgpu_mm_node_addr(dst->bo, dst_mm, dst->mem) +
>   					     dst->offset;
>   	dst_node_size = (dst_mm->size << PAGE_SHIFT) - dst->offset;
> @@ -653,13 +662,12 @@ static void amdgpu_ttm_io_mem_free(struct ttm_bo_device *bdev, struct ttm_mem_re
>   static unsigned long amdgpu_ttm_io_mem_pfn(struct ttm_buffer_object *bo,
>   					   unsigned long page_offset)
>   {
> -	struct drm_mm_node *mm = bo->mem.mm_node;
> -	uint64_t size = mm->size;
> -	uint64_t offset = page_offset;
> +	struct drm_mm_node *mm;
> +	unsigned long offset = (page_offset << PAGE_SHIFT);
>   
> -	page_offset = do_div(offset, size);
> -	mm += offset;
> -	return (bo->mem.bus.base >> PAGE_SHIFT) + mm->start + page_offset;
> +	mm = amdgpu_find_mm_node(&bo->mem, &offset);
> +	return (bo->mem.bus.base >> PAGE_SHIFT) + mm->start +
> +		(offset >> PAGE_SHIFT);
>   }
>   
>   /*
> @@ -1216,7 +1224,7 @@ static int amdgpu_ttm_access_memory(struct ttm_buffer_object *bo,
>   {
>   	struct amdgpu_bo *abo = container_of(bo, struct amdgpu_bo, tbo);
>   	struct amdgpu_device *adev = amdgpu_ttm_adev(abo->tbo.bdev);
> -	struct drm_mm_node *nodes = abo->tbo.mem.mm_node;
> +	struct drm_mm_node *nodes;
>   	uint32_t value = 0;
>   	int ret = 0;
>   	uint64_t pos;
> @@ -1225,10 +1233,7 @@ static int amdgpu_ttm_access_memory(struct ttm_buffer_object *bo,
>   	if (bo->mem.mem_type != TTM_PL_VRAM)
>   		return -EIO;
>   
> -	while (offset >= (nodes->size << PAGE_SHIFT)) {
> -		offset -= nodes->size << PAGE_SHIFT;
> -		++nodes;
> -	}
> +	nodes = amdgpu_find_mm_node(&abo->tbo.mem, &offset);
>   	pos = (nodes->start << PAGE_SHIFT) + offset;
>   
>   	while (len && pos < adev->mc.mc_vram_size) {


_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2017-10-12  8:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-11 19:49 [PATCH v2 1/2] drm/amdgpu: Refactor amdgpu_move_blit Harish Kasiviswanathan
     [not found] ` <1507751374-11295-1-git-send-email-Harish.Kasiviswanathan-5C7GfCeVMHo@public.gmane.org>
2017-10-11 19:49   ` [PATCH v2 2/2] drm/amdgpu: Add amdgpu_find_mm_node() Harish Kasiviswanathan
     [not found]     ` <1507751374-11295-2-git-send-email-Harish.Kasiviswanathan-5C7GfCeVMHo@public.gmane.org>
2017-10-12  8:08       ` Christian König [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-10-06 22:08 [PATCH v2 1/2] drm/amdgpu: Refactor amdgpu_move_blit Harish Kasiviswanathan
     [not found] ` <1507327732-8797-1-git-send-email-Harish.Kasiviswanathan-5C7GfCeVMHo@public.gmane.org>
2017-10-06 22:08   ` [PATCH v2 2/2] drm/amdgpu: Add amdgpu_find_mm_node() Harish Kasiviswanathan
     [not found]     ` <1507327732-8797-2-git-send-email-Harish.Kasiviswanathan-5C7GfCeVMHo@public.gmane.org>
2017-10-09  9:10       ` Christian König
     [not found]         ` <7bac471e-759e-d596-67e4-be0173cecabc-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-10-10 15:28           ` Kasiviswanathan, Harish

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3f44ec38-b4b1-0a7d-fb5a-c14f6d0d451f@gmail.com \
    --to=ckoenig.leichtzumerken-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=Harish.Kasiviswanathan-5C7GfCeVMHo@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=christian.koenig-5C7GfCeVMHo@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.