dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: daniel@ffwll.ch
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 3/9] drm/radeon: stop implementing init_mem_type
Date: Mon, 27 Jul 2020 12:30:00 +0200	[thread overview]
Message-ID: <20200727103000.GR6419@phenom.ffwll.local> (raw)
In-Reply-To: <20200723151621.3536-3-christian.koenig@amd.com>

On Thu, Jul 23, 2020 at 05:16:15PM +0200, Christian König wrote:
> Instead just initialize the memory type parameters
> before calling ttm_bo_init_mm.
> 
> Signed-off-by: Christian König <christian.koenig@amd.com>

Hm what's the motivation here? I do agree that the init_mem_type callback
is rather midlayer-y (having a per-type cast in a callback is a very clear
signal something with the layering is all busted). So removing this sounds
like a good idea, but not really following why just for radeon? Or simply
wip?
-Daniel



> ---
>  drivers/gpu/drm/radeon/radeon_ttm.c | 70 ++++++++++++++---------------
>  1 file changed, 35 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
> index 9aba18a143e7..b0b59c553785 100644
> --- a/drivers/gpu/drm/radeon/radeon_ttm.c
> +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
> @@ -69,43 +69,43 @@ struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev)
>  static int radeon_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
>  				struct ttm_mem_type_manager *man)
>  {
> -	struct radeon_device *rdev;
> +	return 0;
> +}
>  
> -	rdev = radeon_get_rdev(bdev);
> +static int radeon_ttm_init_vram(struct radeon_device *rdev)
> +{
> +	struct ttm_mem_type_manager *man = &rdev->mman.bdev.man[TTM_PL_VRAM];
>  
> -	switch (type) {
> -	case TTM_PL_SYSTEM:
> -		/* System memory */
> -		break;
> -	case TTM_PL_TT:
> -		man->func = &ttm_bo_manager_func;
> -		man->available_caching = TTM_PL_MASK_CACHING;
> -		man->default_caching = TTM_PL_FLAG_CACHED;
> -		man->use_tt = true;
> +	man->func = &ttm_bo_manager_func;
> +	man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
> +	man->default_caching = TTM_PL_FLAG_WC;
> +
> +	return ttm_bo_init_mm(&rdev->mman.bdev, TTM_PL_VRAM,
> +			      rdev->mc.real_vram_size >> PAGE_SHIFT);
> +}
> +
> +static int radeon_ttm_init_gtt(struct radeon_device *rdev)
> +{
> +	struct ttm_mem_type_manager *man = &rdev->mman.bdev.man[TTM_PL_TT];
> +
> +	man->func = &ttm_bo_manager_func;
> +	man->available_caching = TTM_PL_MASK_CACHING;
> +	man->default_caching = TTM_PL_FLAG_CACHED;
> +	man->use_tt = true;
>  #if IS_ENABLED(CONFIG_AGP)
> -		if (rdev->flags & RADEON_IS_AGP) {
> -			if (!rdev->ddev->agp) {
> -				DRM_ERROR("AGP is not enabled for memory type %u\n",
> -					  (unsigned)type);
> -				return -EINVAL;
> -			}
> -			man->available_caching = TTM_PL_FLAG_UNCACHED |
> -						 TTM_PL_FLAG_WC;
> -			man->default_caching = TTM_PL_FLAG_WC;
> +	if (rdev->flags & RADEON_IS_AGP) {
> +		if (!rdev->ddev->agp) {
> +			DRM_ERROR("AGP is not enabled\n");
> +			return -EINVAL;
>  		}
> -#endif
> -		break;
> -	case TTM_PL_VRAM:
> -		/* "On-card" video ram */
> -		man->func = &ttm_bo_manager_func;
> -		man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
> +		man->available_caching = TTM_PL_FLAG_UNCACHED |
> +					 TTM_PL_FLAG_WC;
>  		man->default_caching = TTM_PL_FLAG_WC;
> -		break;
> -	default:
> -		DRM_ERROR("Unsupported memory type %u\n", (unsigned)type);
> -		return -EINVAL;
>  	}
> -	return 0;
> +#endif
> +
> +	return ttm_bo_init_mm(&rdev->mman.bdev, TTM_PL_TT,
> +			      rdev->mc.gtt_size >> PAGE_SHIFT);
>  }
>  
>  static void radeon_evict_flags(struct ttm_buffer_object *bo,
> @@ -778,8 +778,8 @@ int radeon_ttm_init(struct radeon_device *rdev)
>  		return r;
>  	}
>  	rdev->mman.initialized = true;
> -	r = ttm_bo_init_mm(&rdev->mman.bdev, TTM_PL_VRAM,
> -				rdev->mc.real_vram_size >> PAGE_SHIFT);
> +
> +	r = radeon_ttm_init_vram(rdev);
>  	if (r) {
>  		DRM_ERROR("Failed initializing VRAM heap.\n");
>  		return r;
> @@ -804,8 +804,8 @@ int radeon_ttm_init(struct radeon_device *rdev)
>  	}
>  	DRM_INFO("radeon: %uM of VRAM memory ready\n",
>  		 (unsigned) (rdev->mc.real_vram_size / (1024 * 1024)));
> -	r = ttm_bo_init_mm(&rdev->mman.bdev, TTM_PL_TT,
> -				rdev->mc.gtt_size >> PAGE_SHIFT);
> +
> +	r = radeon_ttm_init_gtt(rdev);
>  	if (r) {
>  		DRM_ERROR("Failed initializing GTT heap.\n");
>  		return r;
> -- 
> 2.17.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2020-07-27 10:30 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-23 15:16 [PATCH 1/9] drm/ttm: initialize the system domain with defaults Christian König
2020-07-23 15:16 ` [PATCH 2/9] drm/ttm: remove TTM_MEMTYPE_FLAG_FIXED Christian König
2020-07-27  9:48   ` daniel
2020-07-27  9:54     ` Christian König
2020-07-27 10:27       ` daniel
2020-07-23 15:16 ` [PATCH 3/9] drm/radeon: stop implementing init_mem_type Christian König
2020-07-27 10:30   ` daniel [this message]
2020-07-27 10:30     ` daniel
2020-07-27 10:54     ` Christian König
2020-07-27  9:42 ` [PATCH 1/9] drm/ttm: initialize the system domain with defaults daniel
2020-07-27 10:39   ` Christian König
2020-07-27 10:50     ` Hellstrom, Thomas
2020-07-27 12:23       ` Christian König
2020-07-27 13:01         ` Hellstrom, Thomas
  -- strict thread matches above, loose matches on Subject: below --
2020-07-23 15:17 More TTM cleanups Christian König
2020-07-23 15:17 ` [PATCH 3/9] drm/radeon: stop implementing init_mem_type Christian König
2020-07-30  9:00 [PATCH 1/9] drm/ttm: initialize the system domain with defaults v2 Christian König
2020-07-30  9:00 ` [PATCH 3/9] drm/radeon: stop implementing init_mem_type 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=20200727103000.GR6419@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox