amd-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Luben Tuikov <luben.tuikov@amd.com>
To: Nirmoy Das <nirmoy.aiemd@gmail.com>, dri-devel@lists.freedesktop.org
Cc: David1.Zhou@amd.com, thellstrom@vmware.com, airlied@linux.ie,
	kenny.ho@amd.com, brian.welty@intel.com,
	maarten.lankhorst@linux.intel.com, amd-gfx@lists.freedesktop.org,
	nirmoy.das@amd.com, linux-graphics-maintainer@vmware.com,
	bskeggs@redhat.com, daniel@ffwll.ch, alexander.deucher@amd.com,
	sean@poorly.run, christian.koenig@amd.com, kraxel@redhat.com
Subject: Re: [PATCH 2/8] drm/radeon: don't use ttm bo->offset
Date: Thu, 20 Feb 2020 20:19:50 -0500	[thread overview]
Message-ID: <9e26a27b-eeaa-39b3-dacc-9f3777f3cf92@amd.com> (raw)
In-Reply-To: <20200219135322.56463-3-nirmoy.das@amd.com>

On 2020-02-19 08:53, Nirmoy Das wrote:
> Calculate GPU offset in radeon_bo_gpu_offset without depending on
> bo->offset
> 
> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
> Reviewed-and-tested-by: Christian König <christian.koenig@amd.com>
> ---
>  drivers/gpu/drm/radeon/radeon.h        |  1 +
>  drivers/gpu/drm/radeon/radeon_object.h | 16 +++++++++++++++-
>  drivers/gpu/drm/radeon/radeon_ttm.c    |  4 +---
>  3 files changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
> index 30e32adc1fc6..b7c3fb2bfb54 100644
> --- a/drivers/gpu/drm/radeon/radeon.h
> +++ b/drivers/gpu/drm/radeon/radeon.h
> @@ -2828,6 +2828,7 @@ extern void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size
>  extern void radeon_program_register_sequence(struct radeon_device *rdev,
>  					     const u32 *registers,
>  					     const u32 array_size);
> +struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev);
>  
>  /*
>   * vm
> diff --git a/drivers/gpu/drm/radeon/radeon_object.h b/drivers/gpu/drm/radeon/radeon_object.h
> index d23f2ed4126e..4d37571c7ff5 100644
> --- a/drivers/gpu/drm/radeon/radeon_object.h
> +++ b/drivers/gpu/drm/radeon/radeon_object.h
> @@ -90,7 +90,21 @@ static inline void radeon_bo_unreserve(struct radeon_bo *bo)
>   */
>  static inline u64 radeon_bo_gpu_offset(struct radeon_bo *bo)
>  {
> -	return bo->tbo.offset;
> +	struct radeon_device *rdev;
> +	u64 start = 0;
> +
> +	rdev = radeon_get_rdev(bo->tbo.bdev);
> +
> +	switch(bo->tbo.mem.mem_type) {

LKCS wants a space after a keyword, "switch (" .

> +	case TTM_PL_TT:
> +		start = rdev->mc.gtt_start;
> +		break;
> +	case TTM_PL_VRAM:
> +		start = rdev->mc.vram_start;
> +		break;
> +	}

Could this lookup have been parameterized by "mem_type"
to be looked up by an index (possibly "mem_type") to result
in something new like (pseudo-code):
     start = rdev->mc.mem_start_table[bo->tbo.mem.mem_type];
Where "mem_start_table" is a new table holding memory starts
of particular memories.
Then you don't need the switch-case.

Regards,
Luben

> +
> +	return (bo->tbo.mem.start << PAGE_SHIFT) + start;
>  }
>  
>  static inline unsigned long radeon_bo_size(struct radeon_bo *bo)
> diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
> index badf1b6d1549..1c8303468e8f 100644
> --- a/drivers/gpu/drm/radeon/radeon_ttm.c
> +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
> @@ -56,7 +56,7 @@
>  static int radeon_ttm_debugfs_init(struct radeon_device *rdev);
>  static void radeon_ttm_debugfs_fini(struct radeon_device *rdev);
>  
> -static struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev)
> +struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev)
>  {
>  	struct radeon_mman *mman;
>  	struct radeon_device *rdev;
> @@ -82,7 +82,6 @@ static int radeon_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
>  		break;
>  	case TTM_PL_TT:
>  		man->func = &ttm_bo_manager_func;
> -		man->gpu_offset = rdev->mc.gtt_start;
>  		man->available_caching = TTM_PL_MASK_CACHING;
>  		man->default_caching = TTM_PL_FLAG_CACHED;
>  		man->flags = TTM_MEMTYPE_FLAG_MAPPABLE | TTM_MEMTYPE_FLAG_CMA;
> @@ -104,7 +103,6 @@ static int radeon_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
>  	case TTM_PL_VRAM:
>  		/* "On-card" video ram */
>  		man->func = &ttm_bo_manager_func;
> -		man->gpu_offset = rdev->mc.vram_start;
>  		man->flags = TTM_MEMTYPE_FLAG_FIXED |
>  			     TTM_MEMTYPE_FLAG_MAPPABLE;
>  		man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
> 

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

  reply	other threads:[~2020-02-21  1:20 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-19 13:53 [PATCH v3 0/8] do not store GPU address in TTM Nirmoy Das
2020-02-19 13:53 ` [PATCH 1/8] drm/amdgpu: move ttm bo->offset to amdgpu_bo Nirmoy Das
2020-02-21  1:14   ` Luben Tuikov
2020-02-19 13:53 ` [PATCH 2/8] drm/radeon: don't use ttm bo->offset Nirmoy Das
2020-02-21  1:19   ` Luben Tuikov [this message]
2020-02-19 13:53 ` [PATCH 3/8] drm/vmwgfx: " Nirmoy Das
2020-02-21  8:45   ` Thomas Hellström (VMware)
2020-02-19 13:53 ` [PATCH 4/8] drm/nouveau: don't use ttm bo->offset v3 Nirmoy Das
2020-02-21  1:22   ` Luben Tuikov
2020-02-19 13:53 ` [PATCH 5/8] drm/qxl: don't use ttm bo->offset Nirmoy Das
2020-02-19 13:53 ` [PATCH 6/8] drm/vram-helper: don't use ttm bo->offset v2 Nirmoy Das
2020-02-20 18:09   ` Daniel Vetter
2020-02-20 18:29     ` Nirmoy
2020-02-21 11:02   ` Thomas Zimmermann
2020-02-19 13:53 ` [PATCH 7/8] drm/bochs: use drm_gem_vram_offset to get bo offset v2 Nirmoy Das
2020-02-20 18:11   ` Daniel Vetter
2020-02-19 13:53 ` [PATCH 8/8] drm/ttm: do not keep GPU dependent addresses Nirmoy Das
2020-02-21  8:48 ` [PATCH v3 0/8] do not store GPU address in TTM Thomas Hellström (VMware)
  -- strict thread matches above, loose matches on Subject: below --
2020-03-05 13:29 [PATCH v4 " Nirmoy Das
2020-03-05 13:29 ` [PATCH 2/8] drm/radeon: don't use ttm bo->offset Nirmoy Das
2020-03-05 19:19   ` Luben Tuikov
2020-03-05 19:37     ` Ho, Kenny
2020-03-05 20:18       ` Luben Tuikov
2020-02-17 15:04 [PATCH 0/8] do not store GPU address in TTM Nirmoy Das
2020-02-17 15:04 ` [PATCH 2/8] drm/radeon: don't use ttm bo->offset Nirmoy Das

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=9e26a27b-eeaa-39b3-dacc-9f3777f3cf92@amd.com \
    --to=luben.tuikov@amd.com \
    --cc=David1.Zhou@amd.com \
    --cc=airlied@linux.ie \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=brian.welty@intel.com \
    --cc=bskeggs@redhat.com \
    --cc=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kenny.ho@amd.com \
    --cc=kraxel@redhat.com \
    --cc=linux-graphics-maintainer@vmware.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=nirmoy.aiemd@gmail.com \
    --cc=nirmoy.das@amd.com \
    --cc=sean@poorly.run \
    --cc=thellstrom@vmware.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).