[PATCH 2/9] drm/amdgpu: Add vis_vramlimit module parameter

Christian König deathsimple at vodafone.de
Mon Jun 26 09:57:29 UTC 2017


Am 23.06.2017 um 19:39 schrieb John Brooks:
> Allow specifying a limit on visible VRAM via a module parameter. This is
> helpful for testing performance under visible VRAM pressure.
>
> Signed-off-by: John Brooks <john at fastquake.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu.h     | 1 +
>   drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++++
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 8 ++++++++
>   3 files changed, 13 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index c407d2d..fe73633 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -74,6 +74,7 @@
>    */
>   extern int amdgpu_modeset;
>   extern int amdgpu_vram_limit;
> +extern int amdgpu_vis_vram_limit;
>   extern int amdgpu_gart_size;
>   extern int amdgpu_moverate;
>   extern int amdgpu_benchmarking;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> index 4c7c262..a14f458 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> @@ -73,6 +73,7 @@
>   #define KMS_DRIVER_PATCHLEVEL	0
>   
>   int amdgpu_vram_limit = 0;
> +int amdgpu_vis_vram_limit = 0;
>   int amdgpu_gart_size = -1; /* auto */
>   int amdgpu_moverate = -1; /* auto */
>   int amdgpu_benchmarking = 0;
> @@ -119,6 +120,9 @@ int amdgpu_lbpw = -1;
>   MODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing, in megabytes");
>   module_param_named(vramlimit, amdgpu_vram_limit, int, 0600);
>   
> +MODULE_PARM_DESC(vis_vramlimit, "Restrict visible VRAM for testing, in megabytes");
> +module_param_named(vis_vramlimit, amdgpu_vis_vram_limit, int, 0444);
> +
>   MODULE_PARM_DESC(gartsize, "Size of PCIE/IGP gart to setup in megabytes (32, 64, etc., -1 = auto)");
>   module_param_named(gartsize, amdgpu_gart_size, int, 0600);
>   
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index c9b131b..0676a78 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -1095,6 +1095,7 @@ static struct ttm_bo_driver amdgpu_bo_driver = {
>   int amdgpu_ttm_init(struct amdgpu_device *adev)
>   {
>   	int r;
> +	u64 vis_vram_limit;
>   
>   	r = amdgpu_ttm_global_init(adev);
>   	if (r) {
> @@ -1118,6 +1119,13 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
>   		DRM_ERROR("Failed initializing VRAM heap.\n");
>   		return r;
>   	}
> +
> +	/* Reduce size of CPU-visible VRAM if requested */
> +	vis_vram_limit = amdgpu_vis_vram_limit * 1024 * 1024;

You need a 64bit cast here, otherwise you can get an overrun.

Apart from that the patch is Reviewed-by: Christian König 
<christian.koenig at amd.com>.

Regards,
Christian.

> +	if (amdgpu_vis_vram_limit > 0 &&
> +	    vis_vram_limit <= adev->mc.visible_vram_size)
> +		adev->mc.visible_vram_size = vis_vram_limit;
> +
>   	/* Change the size here instead of the init above so only lpfn is affected */
>   	amdgpu_ttm_set_active_vram_size(adev, adev->mc.visible_vram_size);
>   




More information about the dri-devel mailing list