[PATCH] amd/powerplay: use kmemdup instead of kmalloc + memcpy

Christian König deathsimple at vodafone.de
Sun Sep 4 12:32:19 UTC 2016


Am 04.09.2016 um 04:36 schrieb Edward O'Callaghan:
> Save a few clocks by replacing calls to kmalloc followed by memcpy
> with a single call to kmemdup.
>
> Signed-off-by: Edward O'Callaghan <funfunctor at folklore1984.net>

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

> ---
>   drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 9 +++------
>   1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
> index 2de34a5..5ff1124 100644
> --- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
> +++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
> @@ -765,15 +765,12 @@ static int pp_dpm_set_pp_table(void *handle, const char *buf, size_t size)
>   	PP_CHECK_HW(hwmgr);
>   
>   	if (!hwmgr->hardcode_pp_table) {
> -		hwmgr->hardcode_pp_table =
> -				kzalloc(hwmgr->soft_pp_table_size, GFP_KERNEL);
> +		hwmgr->hardcode_pp_table = kmemdup(hwmgr->soft_pp_table,
> +						   hwmgr->soft_pp_table_size,
> +						   GFP_KERNEL);
>   
>   		if (!hwmgr->hardcode_pp_table)
>   			return -ENOMEM;
> -
> -		/* to avoid powerplay crash when hardcode pptable is empty */
> -		memcpy(hwmgr->hardcode_pp_table, hwmgr->soft_pp_table,
> -				hwmgr->soft_pp_table_size);
>   	}
>   
>   	memcpy(hwmgr->hardcode_pp_table, buf, size);




More information about the amd-gfx mailing list