From: "Christian König" <christian.koenig@amd.com>
To: Dave Airlie <airlied@gmail.com>, dri-devel@lists.freedesktop.org
Cc: sroland@vmware.com, bskeggs@redhat.com, kraxel@redhat.com
Subject: Re: [PATCH 17/23] drm/ttm: split populated/bound state flags.
Date: Thu, 27 Aug 2020 13:52:40 +0200 [thread overview]
Message-ID: <472cde7f-39d0-1802-e0cf-58219142de41@amd.com> (raw)
In-Reply-To: <20200826014428.828392-18-airlied@gmail.com>
Am 26.08.20 um 03:44 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> Get bound out is the next step.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 4 ++--
> drivers/gpu/drm/nouveau/nouveau_bo.c | 4 ++--
> drivers/gpu/drm/radeon/radeon_mn.c | 2 +-
> drivers/gpu/drm/radeon/radeon_ttm.c | 4 ++--
> drivers/gpu/drm/ttm/ttm_bo_util.c | 2 +-
> drivers/gpu/drm/ttm/ttm_page_alloc.c | 6 +++---
> drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 6 +++---
> drivers/gpu/drm/ttm/ttm_tt.c | 19 +++++++++----------
> drivers/gpu/drm/vmwgfx/vmwgfx_blit.c | 4 ++--
> drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 2 +-
> include/drm/ttm/ttm_tt.h | 10 ++++------
> 11 files changed, 30 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index adac24625191..c1c3691c3b9f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -1301,7 +1301,7 @@ static int amdgpu_ttm_tt_populate(struct ttm_bo_device *bdev,
> return -ENOMEM;
>
> ttm->page_flags |= TTM_PAGE_FLAG_SG;
> - ttm->state = tt_unbound;
> + ttm->populated = true;
> return 0;
> }
>
> @@ -1321,7 +1321,7 @@ static int amdgpu_ttm_tt_populate(struct ttm_bo_device *bdev,
> drm_prime_sg_to_page_addr_arrays(gtt->ttm.sg, ttm->pages,
> gtt->ttm.dma_address,
> ttm->num_pages);
> - ttm->state = tt_unbound;
> + ttm->populated = true;
> return 0;
> }
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
> index 478e498da965..e9de922ae921 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_bo.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
> @@ -1264,14 +1264,14 @@ nouveau_ttm_tt_populate(struct ttm_bo_device *bdev,
> struct device *dev;
> bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG);
>
> - if (ttm->state != tt_unpopulated)
> + if (ttm->populated)
> return 0;
>
> if (slave && ttm_dma->sg) {
> /* make userspace faulting work */
> drm_prime_sg_to_page_addr_arrays(ttm_dma->sg, ttm->pages,
> ttm_dma->dma_address, ttm->num_pages);
> - ttm->state = tt_unbound;
> + ttm->populated = true;
> return 0;
> }
>
> diff --git a/drivers/gpu/drm/radeon/radeon_mn.c b/drivers/gpu/drm/radeon/radeon_mn.c
> index f93829f08a4d..5f57df7e6f08 100644
> --- a/drivers/gpu/drm/radeon/radeon_mn.c
> +++ b/drivers/gpu/drm/radeon/radeon_mn.c
> @@ -53,7 +53,7 @@ static bool radeon_mn_invalidate(struct mmu_interval_notifier *mn,
> struct ttm_operation_ctx ctx = { false, false };
> long r;
>
> - if (!bo->tbo.ttm || bo->tbo.ttm->state != tt_bound)
> + if (!bo->tbo.ttm || bo->tbo.ttm->bound == false)
I think using ! instead of "== false" would look better here.
Christian.
> return true;
>
> if (!mmu_notifier_range_blockable(range))
> diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
> index f5cbe5d13d33..f9e4e64a6d64 100644
> --- a/drivers/gpu/drm/radeon/radeon_ttm.c
> +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
> @@ -615,14 +615,14 @@ static int radeon_ttm_tt_populate(struct ttm_bo_device *bdev,
> return -ENOMEM;
>
> ttm->page_flags |= TTM_PAGE_FLAG_SG;
> - ttm->state = tt_unbound;
> + ttm->populated = true;
> return 0;
> }
>
> if (slave && gtt->ttm.sg) {
> drm_prime_sg_to_page_addr_arrays(gtt->ttm.sg, ttm->pages,
> gtt->ttm.dma_address, ttm->num_pages);
> - ttm->state = tt_unbound;
> + ttm->populated = true;
> return 0;
> }
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
> index 3b17fe3cb57a..d5d841270e38 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_util.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
> @@ -251,7 +251,7 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
> * Don't move nonexistent data. Clear destination instead.
> */
> if (old_iomap == NULL &&
> - (ttm == NULL || (ttm->state == tt_unpopulated &&
> + (ttm == NULL || (!ttm->populated &&
> !(ttm->page_flags & TTM_PAGE_FLAG_SWAPPED)))) {
> memset_io(new_iomap, 0, new_mem->num_pages*PAGE_SIZE);
> goto out2;
> diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
> index b40a4678c296..2d30a2deadb5 100644
> --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
> +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
> @@ -1044,7 +1044,7 @@ ttm_pool_unpopulate_helper(struct ttm_tt *ttm, unsigned mem_count_update)
> put_pages:
> ttm_put_pages(ttm->pages, ttm->num_pages, ttm->page_flags,
> ttm->caching_state);
> - ttm->state = tt_unpopulated;
> + ttm->populated = false;
> }
>
> int ttm_pool_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx)
> @@ -1053,7 +1053,7 @@ int ttm_pool_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx)
> unsigned i;
> int ret;
>
> - if (ttm->state != tt_unpopulated)
> + if (ttm->populated)
> return 0;
>
> if (ttm_check_under_lowerlimit(mem_glob, ttm->num_pages, ctx))
> @@ -1083,7 +1083,7 @@ int ttm_pool_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx)
> }
> }
>
> - ttm->state = tt_unbound;
> + ttm->populated = true;
> return 0;
> }
> EXPORT_SYMBOL(ttm_pool_populate);
> diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
> index faefaaef7909..9a3b7145d9cb 100644
> --- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
> +++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
> @@ -894,7 +894,7 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev,
> unsigned i;
> int ret;
>
> - if (ttm->state != tt_unpopulated)
> + if (ttm->populated)
> return 0;
>
> if (ttm_check_under_lowerlimit(mem_glob, num_pages, ctx))
> @@ -982,7 +982,7 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev,
> }
> }
>
> - ttm->state = tt_unbound;
> + ttm->populated = true;
> return 0;
> }
> EXPORT_SYMBOL_GPL(ttm_dma_populate);
> @@ -1076,7 +1076,7 @@ void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev)
> /* shrink pool if necessary (only on !is_cached pools)*/
> if (npages)
> ttm_dma_page_pool_free(pool, npages, false);
> - ttm->state = tt_unpopulated;
> + ttm->populated = false;
> }
> EXPORT_SYMBOL_GPL(ttm_dma_unpopulate);
>
> diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
> index 1b9960085d11..ee6fda175da6 100644
> --- a/drivers/gpu/drm/ttm/ttm_tt.c
> +++ b/drivers/gpu/drm/ttm/ttm_tt.c
> @@ -156,7 +156,7 @@ static int ttm_tt_set_caching(struct ttm_tt *ttm,
> if (ttm->caching_state == c_state)
> return 0;
>
> - if (ttm->state == tt_unpopulated) {
> + if (!ttm->populated) {
> /* Change caching but don't populate */
> ttm->caching_state = c_state;
> return 0;
> @@ -214,7 +214,7 @@ void ttm_tt_destroy(struct ttm_bo_device *bdev, struct ttm_tt *ttm)
>
> ttm_tt_unbind(bdev, ttm);
>
> - if (ttm->state == tt_unbound)
> + if (ttm->populated)
> ttm_tt_unpopulate(bdev, ttm);
>
> if (!(ttm->page_flags & TTM_PAGE_FLAG_PERSISTENT_SWAP) &&
> @@ -232,8 +232,8 @@ static void ttm_tt_init_fields(struct ttm_tt *ttm,
> ttm->num_pages = bo->num_pages;
> ttm->caching_state = tt_cached;
> ttm->page_flags = page_flags;
> - ttm->state = tt_unpopulated;
> ttm->swap_storage = NULL;
> + ttm->populated = false;
> }
>
> int ttm_tt_init(struct ttm_tt *ttm, struct ttm_buffer_object *bo,
> @@ -311,9 +311,9 @@ EXPORT_SYMBOL(ttm_dma_tt_fini);
>
> void ttm_tt_unbind(struct ttm_bo_device *bdev, struct ttm_tt *ttm)
> {
> - if (ttm->state == tt_bound) {
> + if (ttm->bound) {
> bdev->driver->ttm_tt_unbind(bdev, ttm);
> - ttm->state = tt_unbound;
> + ttm->bound = false;
> }
> }
>
> @@ -326,7 +326,7 @@ int ttm_tt_bind(struct ttm_bo_device *bdev,
> if (!ttm)
> return -EINVAL;
>
> - if (ttm->state == tt_bound)
> + if (ttm->bound)
> return 0;
>
> ret = ttm_tt_populate(bdev, ttm, ctx);
> @@ -337,7 +337,7 @@ int ttm_tt_bind(struct ttm_bo_device *bdev,
> if (unlikely(ret != 0))
> return ret;
>
> - ttm->state = tt_bound;
> + ttm->bound = true;
>
> return 0;
> }
> @@ -395,7 +395,6 @@ int ttm_tt_swapout(struct ttm_bo_device *bdev,
> int i;
> int ret = -ENOMEM;
>
> - BUG_ON(ttm->state != tt_unbound && ttm->state != tt_unpopulated);
> BUG_ON(ttm->caching_state != tt_cached);
>
> if (!persistent_swap_storage) {
> @@ -462,7 +461,7 @@ int ttm_tt_populate(struct ttm_bo_device *bdev,
> {
> int ret;
>
> - if (ttm->state != tt_unpopulated)
> + if (ttm->populated)
> return 0;
>
> if (bdev->driver->ttm_tt_populate)
> @@ -491,7 +490,7 @@ static void ttm_tt_clear_mapping(struct ttm_tt *ttm)
> void ttm_tt_unpopulate(struct ttm_bo_device *bdev,
> struct ttm_tt *ttm)
> {
> - if (ttm->state == tt_unpopulated)
> + if (!ttm->populated)
> return;
>
> ttm_tt_clear_mapping(ttm);
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_blit.c b/drivers/gpu/drm/vmwgfx/vmwgfx_blit.c
> index 0cd21590ded9..77205f92bc9b 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_blit.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_blit.c
> @@ -464,13 +464,13 @@ int vmw_bo_cpu_blit(struct ttm_buffer_object *dst,
> if (!(src->mem.placement & TTM_PL_FLAG_NO_EVICT))
> dma_resv_assert_held(src->base.resv);
>
> - if (dst->ttm->state == tt_unpopulated) {
> + if (dst->ttm->populated == false) {
> ret = dst->bdev->driver->ttm_tt_populate(dst->bdev, dst->ttm, &ctx);
> if (ret)
> return ret;
> }
>
> - if (src->ttm->state == tt_unpopulated) {
> + if (src->ttm->populated == false) {
> ret = src->bdev->driver->ttm_tt_populate(src->bdev, src->ttm, &ctx);
> if (ret)
> return ret;
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> index 6757be98be14..1925c41d2bda 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> @@ -623,7 +623,7 @@ static int vmw_ttm_populate(struct ttm_bo_device *bdev,
> struct ttm_mem_global *glob = vmw_mem_glob(dev_priv);
> int ret;
>
> - if (ttm->state != tt_unpopulated)
> + if (ttm->populated)
> return 0;
>
> if (dev_priv->map_mode == vmw_dma_alloc_coherent) {
> diff --git a/include/drm/ttm/ttm_tt.h b/include/drm/ttm/ttm_tt.h
> index 534d0ef24072..c6e88f01062e 100644
> --- a/include/drm/ttm/ttm_tt.h
> +++ b/include/drm/ttm/ttm_tt.h
> @@ -57,7 +57,8 @@ enum ttm_caching_state {
> * @be: Pointer to the ttm backend.
> * @swap_storage: Pointer to shmem struct file for swap storage.
> * @caching_state: The current caching state of the pages.
> - * @state: The current binding state of the pages.
> + * @populated: if the backing store is populated
> + * @bound: if this object has been bound to a global table.
> *
> * This is a structure holding the pages, caching- and aperture binding
> * status for a buffer object that isn't backed by fixed (VRAM / AGP)
> @@ -69,11 +70,8 @@ struct ttm_tt {
> unsigned long num_pages;
> struct file *swap_storage;
> enum ttm_caching_state caching_state;
> - enum {
> - tt_bound,
> - tt_unbound,
> - tt_unpopulated,
> - } state;
> + bool populated;
> + bool bound;
> };
>
> /**
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2020-08-27 11:52 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-26 1:44 [00/23] ttm tt refactoring Dave Airlie
2020-08-26 1:44 ` [PATCH 01/23] drm/amdgpu/ttm: remove unused parameter to move blit Dave Airlie
2020-08-26 1:44 ` [PATCH 02/23] drm/radeon/ttm: don't store driver copy of device pointer Dave Airlie
2020-09-01 11:53 ` Daniel Vetter
2020-08-26 1:44 ` [PATCH 03/23] drm/ttm: remove bdev from ttm_tt Dave Airlie
2020-08-26 1:44 ` [PATCH 04/23] drm/ttm: add optional bind/unbind via driver Dave Airlie
2020-08-26 1:44 ` [PATCH 05/23] drm/qxl: move bind/unbind/destroy to the driver function table Dave Airlie
2020-08-26 1:44 ` [PATCH 06/23] drm/ttm/agp: export bind/unbind/destroy for drivers to use Dave Airlie
2020-08-26 1:44 ` [PATCH 07/23] drm/radeon/ttm: move to driver binding/destroy functions Dave Airlie
2020-08-27 11:42 ` Christian König
2020-08-26 1:44 ` [PATCH 08/23] drm/nouveau/ttm: use driver bind/unbind/destroy functions Dave Airlie
2020-08-26 1:44 ` [PATCH 09/23] drm/vmwgfx: move to driver binding functions Dave Airlie
2020-08-26 1:44 ` [PATCH 10/23] drm/amdgpu/ttm: move to driver backend binding funcs Dave Airlie
2020-08-26 1:44 ` [PATCH 11/23] drm/gem_vram/ttm: move to driver backend destroy function Dave Airlie
2020-08-26 5:14 ` Thomas Zimmermann
2020-08-26 1:44 ` [PATCH 12/23] drm/ttm/agp: drop back end bindings from agp Dave Airlie
2020-08-26 1:44 ` [PATCH 13/23] drm/ttm: get rid of agp specific populate/unpopulate paths Dave Airlie
2020-08-26 1:44 ` [PATCH 14/23] drm/ttm/agp: remove bdev from agp helpers Dave Airlie
2020-08-26 1:44 ` [PATCH 15/23] drm/ttm: drop the tt backend function paths Dave Airlie
2020-08-26 1:44 ` [PATCH 16/23] drm/ttm: move sg pointer into ttm_dma_tt Dave Airlie
2020-08-26 1:44 ` [PATCH 17/23] drm/ttm: split populated/bound state flags Dave Airlie
2020-08-27 11:52 ` Christian König [this message]
2020-08-26 1:44 ` [PATCH 18/23] drm/ttm: move bound flag and use a utility wrapper Dave Airlie
2020-08-26 1:44 ` [PATCH 19/23] drm/ttm: split bind and populate out Dave Airlie
2020-08-26 1:44 ` [PATCH 20/23] drm/ttm: add populated accessors Dave Airlie
2020-08-26 1:44 ` [PATCH 21/23] drm/ttm: store populated status in upper page flag bits Dave Airlie
2020-08-26 1:44 ` [PATCH 22/23] drm/ttm: two minor struct reorgs to fill holes Dave Airlie
2020-08-26 1:44 ` [PATCH 23/23] drm/ttm: change ordering of args to map/unmap helpers Dave Airlie
2020-08-27 11:55 ` [00/23] ttm tt refactoring 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=472cde7f-39d0-1802-e0cf-58219142de41@amd.com \
--to=christian.koenig@amd.com \
--cc=airlied@gmail.com \
--cc=bskeggs@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kraxel@redhat.com \
--cc=sroland@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