Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ramalingam C <ramalingam.c@intel.com>
To: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Cc: intel-gfx <intel-gfx@lists.freedesktop.org>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	Hellstrom Thomas <thomas.hellstrom@intel.com>,
	Matthew Auld <matthew.auld@intel.com>,
	Christian Koenig <christian.koenig@amd.com>,
	Nirmoy Das <nirmoy.das@intel.com>
Subject: Re: [Intel-gfx] [PATCH v5 8/9] drm/i915/gem: Add extra pages in ttm_tt for ccs data
Date: Tue, 29 Mar 2022 00:27:12 +0530	[thread overview]
Message-ID: <20220328185711.GB19751@intel.com> (raw)
In-Reply-To: <ece35a9e-a8e7-b007-9d99-4902ce0a3a93@linux.intel.com>

On 2022-03-24 at 17:28:08 +0100, Thomas Hellström wrote:
> 
> On 3/21/22 23:44, Ramalingam C wrote:
> > On Xe-HP and later devices, dedicated compression control state (CCS)
> > stored in local memory is used for each surface, to support the
> > 3D and media compression formats.
> > 
> > The memory required for the CCS of the entire local memory is 1/256 of
> > the local memory size. So before the kernel boot, the required memory
> > is reserved for the CCS data and a secure register will be programmed
> > with the CCS base address
> > 
> > So when an object is allocated in local memory, dont need to explicitly
> > allocate the space for ccs data. But when the obj is evicted into the
> > smem, to hold the compression related data along with the obj extra space
> > is needed in smem. i.e obj_size + (obj_size/256).
> > 
> > Hence when a smem pages are allocated for an obj with lmem placement
> > possibility we create with the extra pages required for the ccs data for
> > the obj size.
> > 
> > v2:
> >    Used imperative wording [Thomas]
> > v3:
> >    Inflate the pages only when obj's placement is lmem only
> > 
> > Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
> > cc: Christian Koenig <christian.koenig@amd.com>
> > cc: Hellstrom Thomas <thomas.hellstrom@intel.com>
> > Reviewed-by: Thomas Hellstrom <thomas.hellstrom@linux.intel.com>
> > Reviewed-by: Nirmoy Das <nirmoy.das@intel.com>
> > ---
> >   drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 29 ++++++++++++++++++++++++-
> >   1 file changed, 28 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
> > index 3b9f99c765c4..0305a150b9d4 100644
> > --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
> > +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
> > @@ -20,6 +20,7 @@
> >   #include "gem/i915_gem_ttm.h"
> >   #include "gem/i915_gem_ttm_move.h"
> >   #include "gem/i915_gem_ttm_pm.h"
> > +#include "gt/intel_gpu_commands.h"
> >   #define I915_TTM_PRIO_PURGE     0
> >   #define I915_TTM_PRIO_NO_PAGES  1
> > @@ -262,12 +263,33 @@ static const struct i915_refct_sgt_ops tt_rsgt_ops = {
> >   	.release = i915_ttm_tt_release
> >   };
> > +static inline bool
> > +i915_gem_object_needs_ccs_pages(struct drm_i915_gem_object *obj)
> > +{
> > +	bool lmem_placement = false;
> > +	int i;
> > +
> > +	for (i = 0; i < obj->mm.n_placements; i++) {
> > +		/* Compression is not allowed for the objects with smem placement */
> > +		if (obj->mm.placements[i]->type == INTEL_MEMORY_SYSTEM)
> > +			return false;
> > +		if (!lmem_placement &&
> > +		    obj->mm.placements[i]->type == INTEL_MEMORY_LOCAL)
> > +			lmem_placement = true;
> > +	}
> > +
> > +	return lmem_placement;
> > +}
> > +
> >   static struct ttm_tt *i915_ttm_tt_create(struct ttm_buffer_object *bo,
> >   					 uint32_t page_flags)
> >   {
> > +	struct drm_i915_private *i915 = container_of(bo->bdev, typeof(*i915),
> > +						     bdev);
> >   	struct ttm_resource_manager *man =
> >   		ttm_manager_type(bo->bdev, bo->resource->mem_type);
> >   	struct drm_i915_gem_object *obj = i915_ttm_to_gem(bo);
> > +	unsigned long ccs_pages = 0;
> >   	enum ttm_caching caching;
> >   	struct i915_ttm_tt *i915_tt;
> >   	int ret;
> > @@ -290,7 +312,12 @@ static struct ttm_tt *i915_ttm_tt_create(struct ttm_buffer_object *bo,
> >   		i915_tt->is_shmem = true;
> >   	}
> > -	ret = ttm_tt_init(&i915_tt->ttm, bo, page_flags, caching, 0);
> > +	if (HAS_FLAT_CCS(i915) && i915_gem_object_needs_ccs_pages(obj))
> > +		ccs_pages = DIV_ROUND_UP(DIV_ROUND_UP(bo->base.size,
> > +						      NUM_BYTES_PER_CCS_BYTE),
> > +					 PAGE_SIZE);
> > +
> > +	ret = ttm_tt_init(&i915_tt->ttm, bo, page_flags, caching, ccs_pages);
> >   	if (ret)
> >   		goto err_free;
> 
> Since we need to respin could we add (in __i915_ttm_get_pages())
> 
> /* Verify that gem never sees inflated system pages. Keep that local to ttm
> */GEM_BUG_ON(bo->ttm && ((obj->base.size >> PAGE_SHIFT) <
> bo->ttm->num_pages))
Adding this gem warn on in next ver.

Ram
> 
> /Thomas
> 
> 
> 

  reply	other threads:[~2022-03-28 18:56 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-21 22:44 [Intel-gfx] [PATCH v5 0/9] drm/i915/ttm: Evict and restore of compressed object Ramalingam C
2022-03-21 22:44 ` [Intel-gfx] [PATCH v5 1/9] drm/i915/gt: Use XY_FAST_COLOR_BLT to clear obj on graphics ver 12+ Ramalingam C
2022-03-22 10:10   ` Thomas Hellström
2022-03-21 22:44 ` [Intel-gfx] [PATCH v5 2/9] drm/i915/gt: Optimize the migration and clear loop Ramalingam C
2022-03-24 15:35   ` Thomas Hellström (Intel)
2022-03-21 22:44 ` [Intel-gfx] [PATCH v5 3/9] drm/i915/gt: Clear compress metadata for Flat-ccs objects Ramalingam C
2022-03-24 16:14   ` Thomas Hellström (Intel)
2022-03-28 18:59     ` Ramalingam C
2022-03-21 22:44 ` [Intel-gfx] [PATCH v5 4/9] drm/i915/selftest_migrate: Consider the possible roundup of size Ramalingam C
2022-03-21 22:44 ` [Intel-gfx] [PATCH v5 5/9] drm/i915/selftest_migrate: Check CCS meta data clear Ramalingam C
2022-03-21 22:44 ` [Intel-gfx] [PATCH v5 6/9] drm/i915/gt: offset handling for multiple copy engines Ramalingam C
2022-03-24 16:20   ` Thomas Hellström (Intel)
2022-03-28 18:56     ` Ramalingam C
2022-03-21 22:44 ` [Intel-gfx] [PATCH v5 7/9] drm/ttm: Add a parameter to add extra pages into ttm_tt Ramalingam C
2022-03-21 22:44 ` [Intel-gfx] [PATCH v5 8/9] drm/i915/gem: Add extra pages in ttm_tt for ccs data Ramalingam C
2022-03-24 16:28   ` Thomas Hellström
2022-03-28 18:57     ` Ramalingam C [this message]
2022-03-21 22:44 ` [Intel-gfx] [PATCH v5 9/9] drm/i915/migrate: Evict and restore the flatccs capable lmem obj Ramalingam C
2022-03-22 11:20   ` [Intel-gfx] [PATCH v6 " Ramalingam C
2022-03-22  1:47 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/ttm: Evict and restore of compressed object (rev3) Patchwork
2022-03-22  1:49 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2022-03-22  1:53 ` [Intel-gfx] ✗ Fi.CI.DOCS: " Patchwork
2022-03-22  2:16 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
2022-03-22 12:02 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/ttm: Evict and restore of compressed object (rev4) Patchwork
2022-03-22 12:04 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2022-03-22 12:08 ` [Intel-gfx] ✗ Fi.CI.DOCS: " Patchwork
2022-03-22 12:34 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork

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=20220328185711.GB19751@intel.com \
    --to=ramalingam.c@intel.com \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=matthew.auld@intel.com \
    --cc=nirmoy.das@intel.com \
    --cc=thomas.hellstrom@intel.com \
    --cc=thomas.hellstrom@linux.intel.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