From: Matthew Auld <matthew.auld@intel.com>
To: Ramalingam C <ramalingam.c@intel.com>,
intel-gfx <intel-gfx@lists.freedesktop.org>,
dri-devel <dri-devel@lists.freedesktop.org>
Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Hellstrom Thomas" <thomas.hellstrom@intel.com>,
"Christian Koenig" <christian.koenig@amd.com>,
"Chris Wilson" <chris@chris-wilson.co.uk>
Subject: Re: [Intel-gfx] [PATCH v3 4/6] drm/i915/gem: Add extra pages in ttm_tt for ccs data
Date: Mon, 7 Mar 2022 15:32:24 +0000 [thread overview]
Message-ID: <d7046c6d-1346-8f2b-158a-7fc22bfe47f8@intel.com> (raw)
In-Reply-To: <20220307134038.30525-5-ramalingam.c@intel.com>
On 07/03/2022 13:40, 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]
>
> 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 Hellström <thomas.hellstrom@linux.intel.com>
> ---
> drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 23 ++++++++++++++++++++++-
> 1 file changed, 22 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 1a8262f5f692..c7a36861c38d 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
> @@ -255,12 +256,27 @@ static const struct i915_refct_sgt_ops tt_rsgt_ops = {
> .release = i915_ttm_tt_release
> };
>
> +static inline bool
> +i915_gem_object_has_lmem_placement(struct drm_i915_gem_object *obj)
> +{
> + int i;
> +
> + for (i = 0; i < obj->mm.n_placements; i++)
> + if (obj->mm.placements[i]->type == INTEL_MEMORY_LOCAL)
> + return true;
> +
> + return false;
> +}
> +
> 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;
> @@ -283,7 +299,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_has_lmem_placement(obj))
> + ccs_pages = DIV_ROUND_UP(DIV_ROUND_UP(bo->base.size,
> + NUM_BYTES_PER_CCS_BYTE),
> + PAGE_SIZE);
Did you figure out how to handle the case where we have LMEM + SMEM, and
are unable to place the object into LMEM, and then it just ends up being
kept in SMEM? AFAIK the vm.insert_entries code has always just assumed
that the vma sg_table size is the same as the vma->size, and so will
happily create PTEs for the hidden ccs page(s), which might corrupt the
users vm, depending on the exact layout.
Also it looks like the _shmem_writeback() call should now use
ttm_tt->num_pages, instead of the object size?
> +
> + ret = ttm_tt_init(&i915_tt->ttm, bo, page_flags, caching, ccs_pages);
> if (ret)
> goto err_free;
>
next prev parent reply other threads:[~2022-03-07 15:32 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-07 13:40 [Intel-gfx] [PATCH v3 0/6] drm/i915/ttm: Evict and restore of compressed object Ramalingam C
2022-03-07 13:40 ` [Intel-gfx] [PATCH v3 1/6] drm/i915/gt: Use XY_FASR_COLOR_BLT to clear obj on graphics ver 12+ Ramalingam C
2022-03-07 14:29 ` Hellstrom, Thomas
2022-03-07 13:40 ` [Intel-gfx] [PATCH v3 2/6] drm/i915/gt: Clear compress metadata for Flat-ccs objects Ramalingam C
2022-03-07 14:32 ` Hellstrom, Thomas
2022-03-07 13:40 ` [Intel-gfx] [PATCH v3 3/6] drm/ttm: Add a parameter to add extra pages into ttm_tt Ramalingam C
2022-03-07 13:40 ` [Intel-gfx] [PATCH v3 4/6] drm/i915/gem: Add extra pages in ttm_tt for ccs data Ramalingam C
2022-03-07 15:32 ` Matthew Auld [this message]
2022-03-07 13:40 ` [Intel-gfx] [PATCH v3 5/6] drm/i915/gt: Optimize the migration loop Ramalingam C
2022-03-07 13:40 ` [Intel-gfx] [PATCH v3 6/6] drm/i915/migrate: Evict and restore the flatccs capable lmem obj Ramalingam C
2022-03-07 14:31 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/ttm: Evict and restore of compressed object Patchwork
2022-03-07 14:33 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2022-03-07 15:04 ` [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=d7046c6d-1346-8f2b-158a-7fc22bfe47f8@intel.com \
--to=matthew.auld@intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=ramalingam.c@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