All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Muhammad Falak R Wani <falakreyaz@gmail.com>,
	David Airlie <airlied@linux.ie>
Cc: Jammy Zhou <Jammy.Zhou@amd.com>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	Sonny Jiang <sonny.jiang@amd.com>,
	Alex Deucher <alexander.deucher@amd.com>,
	Leo Liu <leo.liu@amd.com>
Subject: Re: [PATCH] amdgpu/uvd: use kmemdup
Date: Thu, 19 May 2016 13:18:10 +0200	[thread overview]
Message-ID: <573DA0F2.2020503@amd.com> (raw)
In-Reply-To: <1463656317-13828-1-git-send-email-falakreyaz@gmail.com>

Am 19.05.2016 um 13:11 schrieb Muhammad Falak R Wani:
> Use kmemdup when some other buffer is immediately copied into allocated
> region. It replaces call to allocation followed by memcpy, by a single
> call to kmemdup.
>
> Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>

NAK, actually using memcpy() is wrong in the first place.

The UVD BO is in VRAM so the pointer is pointing to IO memory here, so 
this should be memcpy_fromio() instead of memcpy().

Christian.

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
> index 01abfc2..c977ab6 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
> @@ -295,12 +295,10 @@ int amdgpu_uvd_suspend(struct amdgpu_device *adev)
>   	size = amdgpu_bo_size(adev->uvd.vcpu_bo);
>   	ptr = adev->uvd.cpu_addr;
>   
> -	adev->uvd.saved_bo = kmalloc(size, GFP_KERNEL);
> +	adev->uvd.saved_bo = kmemdup(ptr, size, GFP_KERNEL);
>   	if (!adev->uvd.saved_bo)
>   		return -ENOMEM;
>   
> -	memcpy(adev->uvd.saved_bo, ptr, size);
> -
>   	return 0;
>   }
>   

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

WARNING: multiple messages have this Message-ID (diff)
From: "Christian König" <christian.koenig@amd.com>
To: Muhammad Falak R Wani <falakreyaz@gmail.com>,
	David Airlie <airlied@linux.ie>
Cc: Alex Deucher <alexander.deucher@amd.com>,
	Chunming Zhou <David1.Zhou@amd.com>,
	Jammy Zhou <Jammy.Zhou@amd.com>, Leo Liu <leo.liu@amd.com>,
	Sonny Jiang <sonny.jiang@amd.com>,
	<dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] amdgpu/uvd: use kmemdup
Date: Thu, 19 May 2016 13:18:10 +0200	[thread overview]
Message-ID: <573DA0F2.2020503@amd.com> (raw)
In-Reply-To: <1463656317-13828-1-git-send-email-falakreyaz@gmail.com>

Am 19.05.2016 um 13:11 schrieb Muhammad Falak R Wani:
> Use kmemdup when some other buffer is immediately copied into allocated
> region. It replaces call to allocation followed by memcpy, by a single
> call to kmemdup.
>
> Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>

NAK, actually using memcpy() is wrong in the first place.

The UVD BO is in VRAM so the pointer is pointing to IO memory here, so 
this should be memcpy_fromio() instead of memcpy().

Christian.

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
> index 01abfc2..c977ab6 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
> @@ -295,12 +295,10 @@ int amdgpu_uvd_suspend(struct amdgpu_device *adev)
>   	size = amdgpu_bo_size(adev->uvd.vcpu_bo);
>   	ptr = adev->uvd.cpu_addr;
>   
> -	adev->uvd.saved_bo = kmalloc(size, GFP_KERNEL);
> +	adev->uvd.saved_bo = kmemdup(ptr, size, GFP_KERNEL);
>   	if (!adev->uvd.saved_bo)
>   		return -ENOMEM;
>   
> -	memcpy(adev->uvd.saved_bo, ptr, size);
> -
>   	return 0;
>   }
>   

  reply	other threads:[~2016-05-19 11:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-19 11:11 [PATCH] amdgpu/uvd: use kmemdup Muhammad Falak R Wani
2016-05-19 11:18 ` Christian König [this message]
2016-05-19 11:18   ` Christian König
2016-05-19 11:49   ` Muhammad Falak R Wani
2016-05-19 12:08     ` Christian König
2016-05-19 12:08       ` Christian König

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=573DA0F2.2020503@amd.com \
    --to=christian.koenig@amd.com \
    --cc=Jammy.Zhou@amd.com \
    --cc=airlied@linux.ie \
    --cc=alexander.deucher@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=falakreyaz@gmail.com \
    --cc=leo.liu@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sonny.jiang@amd.com \
    /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.