drm/vram-helper: stop using TTM placement flags
Subsystems (7)
PATCH 1/4 drm/vram-helper: stop using TTM placement flags
Those are going to be removed, stop using them here.
Instead define separate flags for the helper.
--- drivers/gpu/drm/drm_gem_vram_helper.c | 14 +++++++++----- include/drm/drm_gem_vram_helper.h | 7 +++---- 2 files changed, 12 insertions(+), 9 deletions(-)
drivers/gpu/drm/drm_gem_vram_helper.c +9 -5
@@ -135,20 +135,23 @@ static void ttm_buffer_object_destroy(struct ttm_buffer_object *bo)static void drm_gem_vram_placement (struct drm_gem_vram_object *gbo,unsigned long pl_flag) { +u32 invariant_flags =0 ;unsigned int i;unsigned int c =0 ; -u32 invariant_flags = pl_flag &TTM_PL_FLAG_TOPDOWN ; + +if (pl_flag &DRM_GEM_VRAM_PL_FLAG_TOPDOWN ) + pl_flag =TTM_PL_FLAG_TOPDOWN ; gbo->placement.placement = gbo->placements; gbo->placement.busy_placement = gbo->placements; -if (pl_flag &TTM_PL_FLAG_VRAM ) +if (pl_flag &DRM_GEM_VRAM_PL_FLAG_VRAM ) gbo->placements[c++].flags =TTM_PL_FLAG_WC |TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_VRAM | invariant_flags; -if (pl_flag &TTM_PL_FLAG_SYSTEM ) +if (pl_flag &DRM_GEM_VRAM_PL_FLAG_SYSTEM ) gbo->placements[c++].flags =TTM_PL_MASK_CACHING |TTM_PL_FLAG_SYSTEM | invariant_flags;
@@ -189,7 +192,8 @@ static int drm_gem_vram_init(struct drm_device *dev, acc_size =ttm_bo_dma_acc_size (bdev, size,sizeof (*gbo)); gbo->bo.bdev = bdev; -drm_gem_vram_placement (gbo,TTM_PL_FLAG_VRAM |TTM_PL_FLAG_SYSTEM ); +drm_gem_vram_placement (gbo,DRM_GEM_VRAM_PL_FLAG_VRAM | +DRM_GEM_VRAM_PL_FLAG_SYSTEM ); ret = ttm_bo_init(bdev, &gbo->bo, size, ttm_bo_type_device, &gbo->placement, pg_align, false, acc_size,
@@ -647,7 +651,7 @@ static bool drm_is_gem_vram(struct ttm_buffer_object *bo)static void drm_gem_vram_bo_driver_evict_flags (struct drm_gem_vram_object *gbo,struct ttm_placement *pl) { -drm_gem_vram_placement (gbo,TTM_PL_FLAG_SYSTEM ); +drm_gem_vram_placement (gbo,DRM_GEM_VRAM_PL_FLAG_SYSTEM ); *pl = gbo->placement; }
include/drm/drm_gem_vram_helper.h +3 -4
@@ -9,7 +9,6 @@#include <drm/drm_modes.h> #include <drm/ttm/ttm_bo_api.h> #include <drm/ttm/ttm_bo_driver.h> -#include <drm/ttm/ttm_placement.h> #include <linux/kernel.h> /* for container_of() */
@@ -20,9 +19,9 @@ struct drm_simple_display_pipe;struct filp ;struct vm_area_struct ; -#define DRM_GEM_VRAM_PL_FLAG_VRAM TTM_PL_FLAG_VRAM -#define DRM_GEM_VRAM_PL_FLAG_SYSTEM TTM_PL_FLAG_SYSTEM -#define DRM_GEM_VRAM_PL_FLAG_TOPDOWN TTM_PL_FLAG_TOPDOWN +#define DRM_GEM_VRAM_PL_FLAG_SYSTEM (1 << 0) +#define DRM_GEM_VRAM_PL_FLAG_VRAM (1 << 1) +#define DRM_GEM_VRAM_PL_FLAG_TOPDOWN (1 << 2)/* * Buffer-object helpers
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/4 drm/nouveau: stop using TTM placement flags
Those are going to be removed, stop using them here.
Instead use the GEM flags from the UAPI.
--- drivers/gpu/drm/nouveau/dispnv04/crtc.c | 9 ++- drivers/gpu/drm/nouveau/dispnv04/disp.c | 5 +- drivers/gpu/drm/nouveau/dispnv04/overlay.c | 4 +- drivers/gpu/drm/nouveau/dispnv50/disp.c | 5 +- drivers/gpu/drm/nouveau/dispnv50/wndw.c | 2 +- drivers/gpu/drm/nouveau/nouveau_abi16.c | 3 +- drivers/gpu/drm/nouveau/nouveau_bo.c | 91 ++++++++++++++-------- drivers/gpu/drm/nouveau/nouveau_bo.h | 12 +-- drivers/gpu/drm/nouveau/nouveau_chan.c | 4 +- drivers/gpu/drm/nouveau/nouveau_dmem.c | 6 +- drivers/gpu/drm/nouveau/nouveau_fbcon.c | 2 +- drivers/gpu/drm/nouveau/nouveau_gem.c | 34 +++----- drivers/gpu/drm/nouveau/nouveau_prime.c | 11 ++- drivers/gpu/drm/nouveau/nv17_fence.c | 5 +- drivers/gpu/drm/nouveau/nv50_fence.c | 5 +- drivers/gpu/drm/nouveau/nv84_fence.c | 13 ++-- 16 files changed, 114 insertions(+), 97 deletions(-)
drivers/gpu/drm/nouveau/dispnv04/crtc.c +5 -4
@@ -615,7 +615,7 @@ nv_crtc_swap_fbs(struct drm_crtc *crtc, struct drm_framebuffer *old_fb)struct nouveau_crtc *nv_crtc =nouveau_crtc (crtc);int ret; - ret =nouveau_bo_pin (nvbo,TTM_PL_FLAG_VRAM , false); + ret =nouveau_bo_pin (nvbo,NOUVEAU_GEM_DOMAIN_VRAM , false);if (ret ==0 ) {if (disp->image[nv_crtc->index])nouveau_bo_unpin (disp->image[nv_crtc->index]);
@@ -1172,7 +1172,7 @@ nv04_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,return -ENOMEM ;if (new_bo != old_bo) { - ret =nouveau_bo_pin (new_bo,TTM_PL_FLAG_VRAM , true); + ret =nouveau_bo_pin (new_bo,NOUVEAU_GEM_DOMAIN_VRAM , true);if (ret) goto fail_free; }
@@ -1336,10 +1336,11 @@ nv04_crtc_create(struct drm_device *dev, int crtc_num)drm_mode_crtc_set_gamma_size (&nv_crtc->base,256 ); ret =nouveau_bo_new (&nouveau_drm (dev)->client,64 *64 *4 ,0x100 , -TTM_PL_FLAG_VRAM ,0 ,0x0000 ,NULL ,NULL , +NOUVEAU_GEM_DOMAIN_VRAM ,0 ,0x0000 ,NULL ,NULL , &nv_crtc->cursor.nvbo);if (!ret) { - ret =nouveau_bo_pin (nv_crtc->cursor.nvbo,TTM_PL_FLAG_VRAM , false); + ret =nouveau_bo_pin (nv_crtc->cursor.nvbo, +NOUVEAU_GEM_DOMAIN_VRAM , false);if (!ret) { ret =nouveau_bo_map (nv_crtc->cursor.nvbo);if (ret)
drivers/gpu/drm/nouveau/dispnv04/disp.c +3 -2
@@ -112,7 +112,7 @@ nv04_display_init(struct drm_device *dev, bool resume, bool runtime)if (!fb || !fb->obj[0 ])continue ; nvbo =nouveau_gem_object (fb->obj[0 ]); - ret =nouveau_bo_pin (nvbo,TTM_PL_FLAG_VRAM , true); + ret =nouveau_bo_pin (nvbo,NOUVEAU_GEM_DOMAIN_VRAM , true);if (ret)NV_ERROR (drm,"Could not pin framebuffer\n" ); }
@@ -122,7 +122,8 @@ nv04_display_init(struct drm_device *dev, bool resume, bool runtime)if (!nv_crtc->cursor.nvbo)continue ; - ret =nouveau_bo_pin (nv_crtc->cursor.nvbo,TTM_PL_FLAG_VRAM , true); + ret =nouveau_bo_pin (nv_crtc->cursor.nvbo, +NOUVEAU_GEM_DOMAIN_VRAM , true);if (!ret && nv_crtc->cursor.set_offset) ret =nouveau_bo_map (nv_crtc->cursor.nvbo);if (ret)
drivers/gpu/drm/nouveau/dispnv04/overlay.c +2 -2
@@ -142,7 +142,7 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,return ret; nvbo =nouveau_gem_object (fb->obj[0 ]); - ret =nouveau_bo_pin (nvbo,TTM_PL_FLAG_VRAM , false); + ret =nouveau_bo_pin (nvbo,NOUVEAU_GEM_DOMAIN_VRAM , false);if (ret)return ret;
@@ -387,7 +387,7 @@ nv04_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,return ret; nvbo =nouveau_gem_object (fb->obj[0 ]); - ret =nouveau_bo_pin (nvbo,TTM_PL_FLAG_VRAM , false); + ret =nouveau_bo_pin (nvbo,NOUVEAU_GEM_DOMAIN_VRAM , false);if (ret)return ret;
drivers/gpu/drm/nouveau/dispnv50/disp.c +3 -2
@@ -2581,10 +2581,11 @@ nv50_display_create(struct drm_device *dev) dev->mode_config.normalize_zpos = true;/* small shared memory area we use for notifiers and semaphores */ - ret =nouveau_bo_new (&drm->client,4096 ,0x1000 ,TTM_PL_FLAG_VRAM , + ret =nouveau_bo_new (&drm->client,4096 ,0x1000 , +NOUVEAU_GEM_DOMAIN_VRAM ,0 ,0x0000 ,NULL ,NULL , &disp->sync);if (!ret) { - ret =nouveau_bo_pin (disp->sync,TTM_PL_FLAG_VRAM , true); + ret =nouveau_bo_pin (disp->sync,NOUVEAU_GEM_DOMAIN_VRAM , true);if (!ret) { ret =nouveau_bo_map (disp->sync);if (ret)
drivers/gpu/drm/nouveau/dispnv50/wndw.c +1 -1
@@ -542,7 +542,7 @@ nv50_wndw_prepare_fb(struct drm_plane *plane, struct drm_plane_state *state)return 0 ; nvbo =nouveau_gem_object (fb->obj[0 ]); - ret =nouveau_bo_pin (nvbo,TTM_PL_FLAG_VRAM , true); + ret =nouveau_bo_pin (nvbo,NOUVEAU_GEM_DOMAIN_VRAM , true);if (ret)return ret;
drivers/gpu/drm/nouveau/nouveau_abi16.c +2 -1
@@ -328,7 +328,8 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS) ret =nouveau_gem_new (cli,PAGE_SIZE ,0 ,NOUVEAU_GEM_DOMAIN_GART ,0 ,0 , &chan->ntfy);if (ret ==0 ) - ret =nouveau_bo_pin (chan->ntfy,TTM_PL_FLAG_TT , false); + ret =nouveau_bo_pin (chan->ntfy,NOUVEAU_GEM_DOMAIN_GART , + false);if (ret) goto done;
drivers/gpu/drm/nouveau/nouveau_bo.c +57 -34
241 lines not on this page · raw message
drivers/gpu/drm/nouveau/nouveau_bo.h +6 -6
@@ -77,10 +77,10 @@ extern struct ttm_bo_driver nouveau_bo_driver;void nouveau_bo_move_init (struct nouveau_drm *);struct nouveau_bo *nouveau_bo_alloc (struct nouveau_cli *,u64 *size,int *align, -u32 flags,u32 tile_mode,u32 tile_flags); -int nouveau_bo_init (struct nouveau_bo *,u64 size,int align,u32 flags, +u32 domain,u32 tile_mode,u32 tile_flags); +int nouveau_bo_init (struct nouveau_bo *,u64 size,int align,u32 domain,struct sg_table *sg,struct dma_resv *robj); -int nouveau_bo_new (struct nouveau_cli *,u64 size,int align,u32 flags, +int nouveau_bo_new (struct nouveau_cli *,u64 size,int align,u32 domain,u32 tile_mode,u32 tile_flags,struct sg_table *sg,struct dma_resv *robj,struct nouveau_bo **);
@@ -122,13 +122,13 @@ nouveau_bo_unmap_unpin_unref(struct nouveau_bo **pnvbo) }static inline int -nouveau_bo_new_pin_map (struct nouveau_cli *cli,u64 size,int align,u32 flags, +nouveau_bo_new_pin_map (struct nouveau_cli *cli,u64 size,int align,u32 domain,struct nouveau_bo **pnvbo) { -int ret =nouveau_bo_new (cli, size, align, flags, +int ret =nouveau_bo_new (cli, size, align, domain,0 ,0 ,NULL ,NULL , pnvbo);if (ret ==0 ) { - ret =nouveau_bo_pin (*pnvbo, flags, true); + ret =nouveau_bo_pin (*pnvbo, domain, true);if (ret ==0 ) { ret =nouveau_bo_map (*pnvbo);if (ret ==0 )
drivers/gpu/drm/nouveau/nouveau_chan.c +2 -2
@@ -163,9 +163,9 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,atomic_set (&chan->killed,0 );/* allocate memory for dma push buffer */ - target =TTM_PL_FLAG_TT |TTM_PL_FLAG_UNCACHED ; + target =NOUVEAU_GEM_DOMAIN_GART |NOUVEAU_GEM_DOMAIN_COHERENT ;if (nouveau_vram_pushbuf) - target =TTM_PL_FLAG_VRAM ; + target =NOUVEAU_GEM_DOMAIN_VRAM ; ret =nouveau_bo_new (cli, size,0 , target,0 ,0 ,NULL ,NULL , &chan->push.buffer);
drivers/gpu/drm/nouveau/nouveau_dmem.c +3 -3
@@ -254,12 +254,12 @@ nouveau_dmem_chunk_alloc(struct nouveau_drm *drm, struct page **ppage) chunk->pagemap.owner = drm->dev; ret =nouveau_bo_new (&drm->client,DMEM_CHUNK_SIZE ,0 , -TTM_PL_FLAG_VRAM ,0 ,0 ,NULL ,NULL , +NOUVEAU_GEM_DOMAIN_VRAM ,0 ,0 ,NULL ,NULL , &chunk->bo);if (ret) goto out_release; - ret =nouveau_bo_pin (chunk->bo,TTM_PL_FLAG_VRAM , false); + ret =nouveau_bo_pin (chunk->bo,NOUVEAU_GEM_DOMAIN_VRAM , false);if (ret) goto out_bo_free;
@@ -346,7 +346,7 @@ nouveau_dmem_resume(struct nouveau_drm *drm)mutex_lock (&drm->dmem->mutex);list_for_each_entry (chunk, &drm->dmem->chunks, list) { - ret =nouveau_bo_pin (chunk->bo,TTM_PL_FLAG_VRAM , false); + ret =nouveau_bo_pin (chunk->bo,NOUVEAU_GEM_DOMAIN_VRAM , false);/* FIXME handle pin failure */ WARN_ON (ret); }
drivers/gpu/drm/nouveau/nouveau_fbcon.c +1 -1
@@ -341,7 +341,7 @@ nouveau_fbcon_create(struct drm_fb_helper *helper,if (ret) goto out_unref; - ret =nouveau_bo_pin (nvbo,TTM_PL_FLAG_VRAM , false); + ret =nouveau_bo_pin (nvbo,NOUVEAU_GEM_DOMAIN_VRAM , false);if (ret) {NV_ERROR (drm,"failed to pin fb: %d\n" , ret); goto out_unref;
drivers/gpu/drm/nouveau/nouveau_gem.c +11 -23
@@ -176,20 +176,12 @@ nouveau_gem_new(struct nouveau_cli *cli, u64 size, int align, uint32_t domain, {struct nouveau_drm *drm = cli->drm;struct nouveau_bo *nvbo; -u32 flags =0 ;int ret; -if (domain &NOUVEAU_GEM_DOMAIN_VRAM ) - flags |=TTM_PL_FLAG_VRAM ; -if (domain &NOUVEAU_GEM_DOMAIN_GART ) - flags |=TTM_PL_FLAG_TT ; -if (!flags || domain &NOUVEAU_GEM_DOMAIN_CPU ) - flags |=TTM_PL_FLAG_SYSTEM ; +if (!(domain & (NOUVEAU_GEM_DOMAIN_VRAM |NOUVEAU_GEM_DOMAIN_GART ))) + domain |=NOUVEAU_GEM_DOMAIN_CPU ; -if (domain &NOUVEAU_GEM_DOMAIN_COHERENT ) - flags |=TTM_PL_FLAG_UNCACHED ; - - nvbo =nouveau_bo_alloc (cli, &size, &align, flags, tile_mode, + nvbo =nouveau_bo_alloc (cli, &size, &align, domain, tile_mode, tile_flags);if (IS_ERR (nvbo))return PTR_ERR (nvbo);
@@ -202,7 +194,7 @@ nouveau_gem_new(struct nouveau_cli *cli, u64 size, int align, uint32_t domain,return ret; } - ret =nouveau_bo_init (nvbo, size, align, flags,NULL ,NULL ); + ret =nouveau_bo_init (nvbo, size, align, domain,NULL ,NULL );if (ret) {nouveau_bo_ref (NULL , &nvbo);return ret;
@@ -296,32 +288,28 @@ nouveau_gem_set_domain(struct drm_gem_object *gem, uint32_t read_domains,struct ttm_buffer_object *bo = &nvbo->bo;uint32_t domains = valid_domains & nvbo->valid_domains & (write_domains ? write_domains : read_domains); -uint32_t pref_flags =0 , valid_flags =0 ; +uint32_t pref_domains =0 ;;if (!domains)return -EINVAL ; -if (valid_domains &NOUVEAU_GEM_DOMAIN_VRAM ) - valid_flags |=TTM_PL_FLAG_VRAM ; - -if (valid_domains &NOUVEAU_GEM_DOMAIN_GART ) - valid_flags |=TTM_PL_FLAG_TT ; + valid_domains &= ~(NOUVEAU_GEM_DOMAIN_VRAM |NOUVEAU_GEM_DOMAIN_GART );if ((domains &NOUVEAU_GEM_DOMAIN_VRAM ) && bo->mem.mem_type ==TTM_PL_VRAM ) - pref_flags |=TTM_PL_FLAG_VRAM ; + pref_domains |=NOUVEAU_GEM_DOMAIN_VRAM ;else if ((domains &NOUVEAU_GEM_DOMAIN_GART ) && bo->mem.mem_type ==TTM_PL_TT ) - pref_flags |=TTM_PL_FLAG_TT ; + pref_domains |=NOUVEAU_GEM_DOMAIN_GART ;else if (domains &NOUVEAU_GEM_DOMAIN_VRAM ) - pref_flags |=TTM_PL_FLAG_VRAM ; + pref_domains |=NOUVEAU_GEM_DOMAIN_VRAM ;else - pref_flags |=TTM_PL_FLAG_TT ; + pref_domains |=NOUVEAU_GEM_DOMAIN_GART ; -nouveau_bo_placement_set (nvbo, pref_flags, valid_flags); +nouveau_bo_placement_set (nvbo, pref_domains, valid_domains);return 0 ; }
drivers/gpu/drm/nouveau/nouveau_prime.c +5 -6
@@ -64,14 +64,12 @@ struct drm_gem_object *nouveau_gem_prime_import_sg_table(struct drm_device *dev,struct nouveau_bo *nvbo;struct dma_resv *robj = attach->dmabuf->resv;u64 size = attach->dmabuf->size; -u32 flags =0 ;int align =0 ;int ret; - flags =TTM_PL_FLAG_TT ; -dma_resv_lock (robj,NULL ); - nvbo =nouveau_bo_alloc (&drm->client, &size, &align, flags,0 ,0 ); + nvbo =nouveau_bo_alloc (&drm->client, &size, &align, +NOUVEAU_GEM_DOMAIN_GART ,0 ,0 );if (IS_ERR (nvbo)) { obj =ERR_CAST (nvbo); goto unlock;
@@ -88,7 +86,8 @@ struct drm_gem_object *nouveau_gem_prime_import_sg_table(struct drm_device *dev, goto unlock; } - ret =nouveau_bo_init (nvbo, size, align, flags, sg, robj); + ret =nouveau_bo_init (nvbo, size, align,NOUVEAU_GEM_DOMAIN_GART , + sg, robj);if (ret) {nouveau_bo_ref (NULL , &nvbo); obj =ERR_PTR (ret);
@@ -108,7 +107,7 @@ int nouveau_gem_prime_pin(struct drm_gem_object *obj)int ret;/* pin buffer into GTT */ - ret =nouveau_bo_pin (nvbo,TTM_PL_FLAG_TT , false); + ret =nouveau_bo_pin (nvbo,NOUVEAU_GEM_DOMAIN_GART , false);if (ret)return -EINVAL ;
drivers/gpu/drm/nouveau/nv17_fence.c +3 -2
@@ -130,10 +130,11 @@ nv17_fence_create(struct nouveau_drm *drm) priv->base.context_del = nv10_fence_context_del;spin_lock_init (&priv->lock); - ret =nouveau_bo_new (&drm->client,4096 ,0x1000 ,TTM_PL_FLAG_VRAM , + ret =nouveau_bo_new (&drm->client,4096 ,0x1000 , +NOUVEAU_GEM_DOMAIN_VRAM ,0 ,0x0000 ,NULL ,NULL , &priv->bo);if (!ret) { - ret =nouveau_bo_pin (priv->bo,TTM_PL_FLAG_VRAM , false); + ret =nouveau_bo_pin (priv->bo,NOUVEAU_GEM_DOMAIN_VRAM , false);if (!ret) { ret =nouveau_bo_map (priv->bo);if (ret)
drivers/gpu/drm/nouveau/nv50_fence.c +3 -2
@@ -81,10 +81,11 @@ nv50_fence_create(struct nouveau_drm *drm) priv->base.context_del = nv10_fence_context_del;spin_lock_init (&priv->lock); - ret =nouveau_bo_new (&drm->client,4096 ,0x1000 ,TTM_PL_FLAG_VRAM , + ret =nouveau_bo_new (&drm->client,4096 ,0x1000 , +NOUVEAU_GEM_DOMAIN_VRAM ,0 ,0x0000 ,NULL ,NULL , &priv->bo);if (!ret) { - ret =nouveau_bo_pin (priv->bo,TTM_PL_FLAG_VRAM , false); + ret =nouveau_bo_pin (priv->bo,NOUVEAU_GEM_DOMAIN_VRAM , false);if (!ret) { ret =nouveau_bo_map (priv->bo);if (ret)
drivers/gpu/drm/nouveau/nv84_fence.c +7 -6
@@ -209,12 +209,13 @@ nv84_fence_create(struct nouveau_drm *drm)mutex_init (&priv->mutex);/* Use VRAM if there is any ; otherwise fallback to system memory */ - domain = drm->client.device.info.ram_size !=0 ?TTM_PL_FLAG_VRAM : -/* -* fences created in sysmem must be non-cached or we -* will lose CPU/GPU coherency! -*/ -TTM_PL_FLAG_TT |TTM_PL_FLAG_UNCACHED ; + domain = drm->client.device.info.ram_size !=0 ? +NOUVEAU_GEM_DOMAIN_VRAM : +/* +* fences created in sysmem must be non-cached or we +* will lose CPU/GPU coherency! +*/ +NOUVEAU_GEM_DOMAIN_GART |NOUVEAU_GEM_DOMAIN_COHERENT ; ret =nouveau_bo_new (&drm->client,16 * drm->chan.nr,0 , domain,0 ,0 ,NULL ,NULL , &priv->bo);if (ret ==0 ) {
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/4 drm/vmwgfx: stop setting multiple domain flags
In reply to Christian KönigSetting more than one placement flag is illegal.
Fix this by using the current flags.
--- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +3 -2
@@ -354,10 +354,11 @@ void vmw_bo_pin_reserved(struct vmw_buffer_object *vbo, bool pin) pl.fpfn =0 ; pl.lpfn =0 ; - pl.flags =TTM_PL_FLAG_VRAM |VMW_PL_FLAG_GMR |VMW_PL_FLAG_MOB - |TTM_PL_FLAG_SYSTEM |TTM_PL_FLAG_CACHED ; + pl.flags = bo->mem.placement;if (pin) pl.flags |=TTM_PL_FLAG_NO_EVICT ; +else + pl.flags &= ~TTM_PL_FLAG_NO_EVICT ;memset (&placement,0 ,sizeof (placement)); placement.num_placement =1 ;
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/4 drm/ttm: nuke memory type flags
In reply to Christian KönigIt's not supported to specify more than one of those flags. So it never made sense to make this a flag in the first place.
Nuke the flags and specify directly which memory type to use.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 24 +++--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 13 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 4 - drivers/gpu/drm/drm_gem_vram_helper.c | 15 ++-- drivers/gpu/drm/nouveau/nouveau_bo.c | 24 ++++-- drivers/gpu/drm/qxl/qxl_object.c | 24 ++++-- drivers/gpu/drm/qxl/qxl_ttm.c | 3 +- drivers/gpu/drm/radeon/radeon_object.c | 42 +++++------ drivers/gpu/drm/radeon/radeon_ttm.c | 11 ++- drivers/gpu/drm/ttm/ttm_bo.c | 86 ++++------------------ drivers/gpu/drm/ttm/ttm_bo_util.c | 2 - drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 1 + drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 2 - drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 63 ++++++++++------ include/drm/ttm/ttm_bo_driver.h | 17 ----- include/drm/ttm/ttm_placement.h | 9 +-- 16 files changed, 149 insertions(+), 191 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +15 -9
@@ -136,8 +136,8 @@ void amdgpu_bo_placement_from_domain(struct amdgpu_bo *abo, u32 domain) places[c].fpfn =0 ; places[c].lpfn =0 ; - places[c].flags =TTM_PL_FLAG_WC |TTM_PL_FLAG_UNCACHED | -TTM_PL_FLAG_VRAM ; + places[c].mem_type =TTM_PL_VRAM ; + places[c].flags =TTM_PL_FLAG_WC |TTM_PL_FLAG_UNCACHED ;if (flags &AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED ) places[c].lpfn = visible_pfn;
@@ -152,7 +152,8 @@ void amdgpu_bo_placement_from_domain(struct amdgpu_bo *abo, u32 domain)if (domain &AMDGPU_GEM_DOMAIN_GTT ) { places[c].fpfn =0 ; places[c].lpfn =0 ; - places[c].flags =TTM_PL_FLAG_TT ; + places[c].mem_type =TTM_PL_TT ; + places[c].flags =0 ;if (flags &AMDGPU_GEM_CREATE_CPU_GTT_USWC ) places[c].flags |=TTM_PL_FLAG_WC |TTM_PL_FLAG_UNCACHED ;
@@ -164,7 +165,8 @@ void amdgpu_bo_placement_from_domain(struct amdgpu_bo *abo, u32 domain)if (domain &AMDGPU_GEM_DOMAIN_CPU ) { places[c].fpfn =0 ; places[c].lpfn =0 ; - places[c].flags =TTM_PL_FLAG_SYSTEM ; + places[c].mem_type =TTM_PL_SYSTEM ; + places[c].flags =0 ;if (flags &AMDGPU_GEM_CREATE_CPU_GTT_USWC ) places[c].flags |=TTM_PL_FLAG_WC |TTM_PL_FLAG_UNCACHED ;
@@ -176,28 +178,32 @@ void amdgpu_bo_placement_from_domain(struct amdgpu_bo *abo, u32 domain)if (domain &AMDGPU_GEM_DOMAIN_GDS ) { places[c].fpfn =0 ; places[c].lpfn =0 ; - places[c].flags =TTM_PL_FLAG_UNCACHED |AMDGPU_PL_FLAG_GDS ; + places[c].mem_type =AMDGPU_PL_GDS ; + places[c].flags =TTM_PL_FLAG_UNCACHED ; c++; }if (domain &AMDGPU_GEM_DOMAIN_GWS ) { places[c].fpfn =0 ; places[c].lpfn =0 ; - places[c].flags =TTM_PL_FLAG_UNCACHED |AMDGPU_PL_FLAG_GWS ; + places[c].mem_type =AMDGPU_PL_GWS ; + places[c].flags =TTM_PL_FLAG_UNCACHED ; c++; }if (domain &AMDGPU_GEM_DOMAIN_OA ) { places[c].fpfn =0 ; places[c].lpfn =0 ; - places[c].flags =TTM_PL_FLAG_UNCACHED |AMDGPU_PL_FLAG_OA ; + places[c].mem_type =AMDGPU_PL_OA ; + places[c].flags =TTM_PL_FLAG_UNCACHED ; c++; }if (!c) { places[c].fpfn =0 ; places[c].lpfn =0 ; - places[c].flags =TTM_PL_MASK_CACHING |TTM_PL_FLAG_SYSTEM ; + places[c].mem_type =TTM_PL_SYSTEM ; + places[c].flags =TTM_PL_MASK_CACHING ; c++; }
@@ -591,7 +597,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,amdgpu_cs_report_moved_bytes (adev, ctx.bytes_moved,0 );if (bp->flags &AMDGPU_GEM_CREATE_VRAM_CLEARED && - bo->tbo.mem.placement &TTM_PL_FLAG_VRAM ) { + bo->tbo.mem.mem_type ==TTM_PL_VRAM ) {struct dma_fence *fence; r =amdgpu_fill_buffer (bo,0 , bo->tbo.base.resv, &fence);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +8 -5
@@ -88,7 +88,8 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo,static const struct ttm_place placements = { .fpfn =0 , .lpfn =0 , - .flags =TTM_PL_MASK_CACHING |TTM_PL_FLAG_SYSTEM + .mem_type =TTM_PL_SYSTEM , + .flags =TTM_PL_MASK_CACHING };/* Don't handle scatter gather BOs */
@@ -551,7 +552,8 @@ static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, bool evict, placement.busy_placement = &placements; placements.fpfn =0 ; placements.lpfn =0 ; - placements.flags =TTM_PL_MASK_CACHING |TTM_PL_FLAG_TT ; + placements.mem_type =TTM_PL_TT ; + placements.flags =TTM_PL_MASK_CACHING ; r =ttm_bo_mem_space (bo, &placement, &tmp_mem, ctx);if (unlikely (r)) {pr_err ("Failed to find GTT space for blit from VRAM\n" );
@@ -607,7 +609,8 @@ static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, bool evict, placement.busy_placement = &placements; placements.fpfn =0 ; placements.lpfn =0 ; - placements.flags =TTM_PL_MASK_CACHING |TTM_PL_FLAG_TT ; + placements.mem_type =TTM_PL_TT ; + placements.flags =TTM_PL_MASK_CACHING ; r =ttm_bo_mem_space (bo, &placement, &tmp_mem, ctx);if (unlikely (r)) {pr_err ("Failed to find GTT space for blit to VRAM\n" );
@@ -1189,8 +1192,8 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo) placement.busy_placement = &placements; placements.fpfn =0 ; placements.lpfn = adev->gmc.gart_size >>PAGE_SHIFT ; - placements.flags = (bo->mem.placement & ~TTM_PL_MASK_MEM ) | -TTM_PL_FLAG_TT ; + placements.mem_type =TTM_PL_TT ; + placements.flags = bo->mem.placement; r =ttm_bo_mem_space (bo, &placement, &tmp, &ctx);if (unlikely (r))
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0 -4
@@ -32,10 +32,6 @@#define AMDGPU_PL_GWS (TTM_PL_PRIV + 1)#define AMDGPU_PL_OA (TTM_PL_PRIV + 2) -#define AMDGPU_PL_FLAG_GDS (TTM_PL_FLAG_PRIV << 0) -#define AMDGPU_PL_FLAG_GWS (TTM_PL_FLAG_PRIV << 1) -#define AMDGPU_PL_FLAG_OA (TTM_PL_FLAG_PRIV << 2) -#define AMDGPU_GTT_MAX_TRANSFER_SIZE 512#define AMDGPU_GTT_NUM_TRANSFER_WINDOWS 2
drivers/gpu/drm/drm_gem_vram_helper.c +6 -9
@@ -145,21 +145,18 @@ static void drm_gem_vram_placement(struct drm_gem_vram_object *gbo, gbo->placement.placement = gbo->placements; gbo->placement.busy_placement = gbo->placements; -if (pl_flag &DRM_GEM_VRAM_PL_FLAG_VRAM ) +if (pl_flag &DRM_GEM_VRAM_PL_FLAG_VRAM ) { + gbo->placements[c].mem_type =TTM_PL_VRAM ; gbo->placements[c++].flags =TTM_PL_FLAG_WC |TTM_PL_FLAG_UNCACHED | -TTM_PL_FLAG_VRAM | - invariant_flags; - -if (pl_flag &DRM_GEM_VRAM_PL_FLAG_SYSTEM ) - gbo->placements[c++].flags =TTM_PL_MASK_CACHING | -TTM_PL_FLAG_SYSTEM | invariant_flags; + } -if (!c) +if (pl_flag &DRM_GEM_VRAM_PL_FLAG_SYSTEM || !c) { + gbo->placements[c].mem_type =TTM_PL_SYSTEM ; gbo->placements[c++].flags =TTM_PL_MASK_CACHING | -TTM_PL_FLAG_SYSTEM | invariant_flags; + } gbo->placement.num_placement = c; gbo->placement.num_busy_placement = c;
drivers/gpu/drm/nouveau/nouveau_bo.c +16 -8
@@ -345,12 +345,18 @@ set_placement_list(struct ttm_place *pl, unsigned *n, uint32_t domain, { *n =0 ; -if (domain &NOUVEAU_GEM_DOMAIN_VRAM ) - pl[(*n)++].flags =TTM_PL_FLAG_VRAM | flags; -if (domain &NOUVEAU_GEM_DOMAIN_GART ) - pl[(*n)++].flags =TTM_PL_FLAG_TT | flags; -if (domain &NOUVEAU_GEM_DOMAIN_CPU ) - pl[(*n)++].flags =TTM_PL_FLAG_SYSTEM | flags; +if (domain &NOUVEAU_GEM_DOMAIN_VRAM ) { + pl[*n].mem_type =TTM_PL_VRAM ; + pl[(*n)++].flags = flags; + } +if (domain &NOUVEAU_GEM_DOMAIN_GART ) { + pl[*n].mem_type =TTM_PL_TT ; + pl[(*n)++].flags = flags; + } +if (domain &NOUVEAU_GEM_DOMAIN_CPU ) { + pl[*n].mem_type =TTM_PL_SYSTEM ; + pl[(*n)++].flags = flags; + } } static void
@@ -855,7 +861,8 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,struct ttm_place placement_memtype = { .fpfn =0 , .lpfn =0 , - .flags =TTM_PL_FLAG_TT |TTM_PL_MASK_CACHING + .mem_type =TTM_PL_TT , + .flags =TTM_PL_MASK_CACHING };struct ttm_placement placement;struct ttm_resource tmp_reg;
@@ -892,7 +899,8 @@ nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict, bool intr,struct ttm_place placement_memtype = { .fpfn =0 , .lpfn =0 , - .flags =TTM_PL_FLAG_TT |TTM_PL_MASK_CACHING + .mem_type =TTM_PL_TT , + .flags =TTM_PL_MASK_CACHING };struct ttm_placement placement;struct ttm_resource tmp_reg;
drivers/gpu/drm/qxl/qxl_object.c +16 -8
@@ -64,16 +64,24 @@ void qxl_ttm_placement_from_domain(struct qxl_bo *qbo, u32 domain, bool pinned) qbo->placement.placement = qbo->placements; qbo->placement.busy_placement = qbo->placements; -if (domain ==QXL_GEM_DOMAIN_VRAM ) - qbo->placements[c++].flags =TTM_PL_FLAG_CACHED |TTM_PL_FLAG_VRAM | pflag; +if (domain ==QXL_GEM_DOMAIN_VRAM ) { + qbo->placements[c].mem_type =TTM_PL_VRAM ; + qbo->placements[c++].flags =TTM_PL_FLAG_CACHED | pflag; + }if (domain ==QXL_GEM_DOMAIN_SURFACE ) { - qbo->placements[c++].flags =TTM_PL_FLAG_CACHED |TTM_PL_FLAG_PRIV | pflag; - qbo->placements[c++].flags =TTM_PL_FLAG_CACHED |TTM_PL_FLAG_VRAM | pflag; + qbo->placements[c].mem_type =TTM_PL_PRIV ; + qbo->placements[c++].flags =TTM_PL_FLAG_CACHED | pflag; + qbo->placements[c].mem_type =TTM_PL_VRAM ; + qbo->placements[c++].flags =TTM_PL_FLAG_CACHED | pflag; + } +if (domain ==QXL_GEM_DOMAIN_CPU ) { + qbo->placements[c].mem_type =TTM_PL_SYSTEM ; + qbo->placements[c++].flags =TTM_PL_MASK_CACHING | pflag; + } +if (!c) { + qbo->placements[c].mem_type =TTM_PL_SYSTEM ; + qbo->placements[c++].flags =TTM_PL_MASK_CACHING ; } -if (domain ==QXL_GEM_DOMAIN_CPU ) - qbo->placements[c++].flags =TTM_PL_MASK_CACHING |TTM_PL_FLAG_SYSTEM | pflag; -if (!c) - qbo->placements[c++].flags =TTM_PL_MASK_CACHING |TTM_PL_FLAG_SYSTEM ; qbo->placement.num_placement = c; qbo->placement.num_busy_placement = c;for (i =0 ; i < c; ++i) {
drivers/gpu/drm/qxl/qxl_ttm.c +2 -1
@@ -55,7 +55,8 @@ static void qxl_evict_flags(struct ttm_buffer_object *bo,static const struct ttm_place placements = { .fpfn =0 , .lpfn =0 , - .flags =TTM_PL_MASK_CACHING |TTM_PL_FLAG_SYSTEM + .mem_type =TTM_PL_SYSTEM , + .flags =TTM_PL_MASK_CACHING };if (!qxl_ttm_bo_is_qxl_bo (bo)) {
drivers/gpu/drm/radeon/radeon_object.c +21 -21
100 lines not on this page · raw message
drivers/gpu/drm/radeon/radeon_ttm.c +7 -4
@@ -88,7 +88,8 @@ static void radeon_evict_flags(struct ttm_buffer_object *bo,static const struct ttm_place placements = { .fpfn =0 , .lpfn =0 , - .flags =TTM_PL_MASK_CACHING |TTM_PL_FLAG_SYSTEM + .mem_type =TTM_PL_SYSTEM , + .flags =TTM_PL_MASK_CACHING };struct radeon_bo *rbo;
@@ -119,7 +120,7 @@ static void radeon_evict_flags(struct ttm_buffer_object *bo, RADEON_GEM_DOMAIN_GTT); rbo->placement.num_busy_placement =0 ;for (i =0 ; i < rbo->placement.num_placement; i++) { -if (rbo->placements[i].flags &TTM_PL_FLAG_VRAM ) { +if (rbo->placements[i].mem_type ==TTM_PL_VRAM ) {if (rbo->placements[i].fpfn < fpfn) rbo->placements[i].fpfn = fpfn; }else {
@@ -233,7 +234,8 @@ static int radeon_move_vram_ram(struct ttm_buffer_object *bo, placement.busy_placement = &placements; placements.fpfn =0 ; placements.lpfn =0 ; - placements.flags =TTM_PL_MASK_CACHING |TTM_PL_FLAG_TT ; + placements.mem_type =TTM_PL_TT ; + placements.flags =TTM_PL_MASK_CACHING ; r =ttm_bo_mem_space (bo, &placement, &tmp_mem, &ctx);if (unlikely (r)) {return r;
@@ -278,7 +280,8 @@ static int radeon_move_ram_vram(struct ttm_buffer_object *bo, placement.busy_placement = &placements; placements.fpfn =0 ; placements.lpfn =0 ; - placements.flags =TTM_PL_MASK_CACHING |TTM_PL_FLAG_TT ; + placements.mem_type =TTM_PL_TT ; + placements.flags =TTM_PL_MASK_CACHING ; r =ttm_bo_mem_space (bo, &placement, &tmp_mem, &ctx);if (unlikely (r)) {return r;
drivers/gpu/drm/ttm/ttm_bo.c +14 -72
168 lines not on this page · raw message
drivers/gpu/drm/ttm/ttm_bo_util.c +0 -2
@@ -69,8 +69,6 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,ttm_tt_unbind (bo->bdev, ttm);ttm_bo_free_old_node (bo); -ttm_flag_masked (&old_mem->placement,TTM_PL_FLAG_SYSTEM , -TTM_PL_MASK_MEM ); old_mem->mem_type =TTM_PL_SYSTEM ; }
drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +1 -0
@@ -354,6 +354,7 @@ void vmw_bo_pin_reserved(struct vmw_buffer_object *vbo, bool pin) pl.fpfn =0 ; pl.lpfn =0 ; + pl.mem_type = bo->mem.mem_type; pl.flags = bo->mem.placement;if (pin) pl.flags |=TTM_PL_FLAG_NO_EVICT ;
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +0 -2
@@ -82,9 +82,7 @@ VMWGFX_NUM_GB_SCREEN_TARGET)#define VMW_PL_GMR (TTM_PL_PRIV + 0) -#define VMW_PL_FLAG_GMR (TTM_PL_FLAG_PRIV << 0)#define VMW_PL_MOB (TTM_PL_PRIV + 1) -#define VMW_PL_FLAG_MOB (TTM_PL_FLAG_PRIV << 1)#define VMW_RES_CONTEXT ttm_driver_type0#define VMW_RES_SURFACE ttm_driver_type1
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +42 -21
159 lines not on this page · raw message
include/drm/ttm/ttm_bo_driver.h +0 -17
@@ -357,23 +357,6 @@ struct ttm_lru_bulk_move {struct ttm_lru_bulk_move_pos swap[TTM_MAX_BO_PRIORITY ]; }; -/** -* ttm_flag_masked -* -* @old: Pointer to the result and original value. -* @new: New value of bits. -* @mask: Mask of bits to change. -* -* Convenience function to change a number of bits identified by a mask. -*/ - -static inline uint32_t -ttm_flag_masked (uint32_t *old,uint32_t new,uint32_t mask) -{ - *old ^= (*old ^ new) & mask; -return *old; -} -/* * ttm_bo.c */
include/drm/ttm/ttm_placement.h +1 -8
@@ -42,12 +42,6 @@#define TTM_PL_VRAM 2#define TTM_PL_PRIV 3 -#define TTM_PL_FLAG_SYSTEM (1 << TTM_PL_SYSTEM) -#define TTM_PL_FLAG_TT (1 << TTM_PL_TT) -#define TTM_PL_FLAG_VRAM (1 << TTM_PL_VRAM) -#define TTM_PL_FLAG_PRIV (1 << TTM_PL_PRIV) -#define TTM_PL_MASK_MEM 0x0000FFFF -/* * Other flags that affects data placement. * TTM_PL_FLAG_CACHED indicates cache-coherent mappings
@@ -71,8 +65,6 @@TTM_PL_FLAG_UNCACHED | \ TTM_PL_FLAG_WC) -#define TTM_PL_MASK_MEMTYPE (TTM_PL_MASK_MEM | TTM_PL_MASK_CACHING) -/** * struct ttm_place *
@@ -85,6 +77,7 @@struct ttm_place {unsigned fpfn;unsigned lpfn; +uint32_t mem_type;uint32_t flags; };
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 4/4] drm/ttm: nuke memory type flags
I like it,
For all 4,
Quoted 903 lines · Christian König
It's not supported to specify more than one of those flags. So it never made sense to make this a flag in the first place.
Nuke the flags and specify directly which memory type to use.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 24 +++--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 13 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 4 - drivers/gpu/drm/drm_gem_vram_helper.c | 15 ++-- drivers/gpu/drm/nouveau/nouveau_bo.c | 24 ++++-- drivers/gpu/drm/qxl/qxl_object.c | 24 ++++-- drivers/gpu/drm/qxl/qxl_ttm.c | 3 +- drivers/gpu/drm/radeon/radeon_object.c | 42 +++++------ drivers/gpu/drm/radeon/radeon_ttm.c | 11 ++- drivers/gpu/drm/ttm/ttm_bo.c | 86 ++++------------------ drivers/gpu/drm/ttm/ttm_bo_util.c | 2 - drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 1 + drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 2 - drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 63 ++++++++++------ include/drm/ttm/ttm_bo_driver.h | 17 ----- include/drm/ttm/ttm_placement.h | 9 +-- 16 files changed, 149 insertions(+), 191 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +15
-9@@ -136,8 +136,8 @@ void amdgpu_bo_placement_from_domain(struct amdgpu_bo *abo, u32 domain) places[c].fpfn =0 ; places[c].lpfn =0 ; - places[c].flags =TTM_PL_FLAG_WC |TTM_PL_FLAG_UNCACHED | -TTM_PL_FLAG_VRAM ; + places[c].mem_type =TTM_PL_VRAM ; + places[c].flags =TTM_PL_FLAG_WC |TTM_PL_FLAG_UNCACHED ;if (flags &AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED ) places[c].lpfn = visible_pfn;@@ -152,7 +152,8 @@ void amdgpu_bo_placement_from_domain(struct amdgpu_bo *abo, u32 domain)if (domain &AMDGPU_GEM_DOMAIN_GTT ) { places[c].fpfn =0 ; places[c].lpfn =0 ; - places[c].flags =TTM_PL_FLAG_TT ; + places[c].mem_type =TTM_PL_TT ; + places[c].flags =0 ;if (flags &AMDGPU_GEM_CREATE_CPU_GTT_USWC ) places[c].flags |=TTM_PL_FLAG_WC |TTM_PL_FLAG_UNCACHED ;@@ -164,7 +165,8 @@ void amdgpu_bo_placement_from_domain(struct amdgpu_bo *abo, u32 domain)if (domain &AMDGPU_GEM_DOMAIN_CPU ) { places[c].fpfn =0 ; places[c].lpfn =0 ; - places[c].flags =TTM_PL_FLAG_SYSTEM ; + places[c].mem_type =TTM_PL_SYSTEM ; + places[c].flags =0 ;if (flags &AMDGPU_GEM_CREATE_CPU_GTT_USWC ) places[c].flags |=TTM_PL_FLAG_WC |TTM_PL_FLAG_UNCACHED ;@@ -176,28 +178,32 @@ void amdgpu_bo_placement_from_domain(struct amdgpu_bo *abo, u32 domain)if (domain &AMDGPU_GEM_DOMAIN_GDS ) { places[c].fpfn =0 ; places[c].lpfn =0 ; - places[c].flags =TTM_PL_FLAG_UNCACHED |AMDGPU_PL_FLAG_GDS ; + places[c].mem_type =AMDGPU_PL_GDS ; + places[c].flags =TTM_PL_FLAG_UNCACHED ; c++; }if (domain &AMDGPU_GEM_DOMAIN_GWS ) { places[c].fpfn =0 ; places[c].lpfn =0 ; - places[c].flags =TTM_PL_FLAG_UNCACHED |AMDGPU_PL_FLAG_GWS ; + places[c].mem_type =AMDGPU_PL_GWS ; + places[c].flags =TTM_PL_FLAG_UNCACHED ; c++; }if (domain &AMDGPU_GEM_DOMAIN_OA ) { places[c].fpfn =0 ; places[c].lpfn =0 ; - places[c].flags =TTM_PL_FLAG_UNCACHED |AMDGPU_PL_FLAG_OA ; + places[c].mem_type =AMDGPU_PL_OA ; + places[c].flags =TTM_PL_FLAG_UNCACHED ; c++; }if (!c) { places[c].fpfn =0 ; places[c].lpfn =0 ; - places[c].flags =TTM_PL_MASK_CACHING |TTM_PL_FLAG_SYSTEM ; + places[c].mem_type =TTM_PL_SYSTEM ; + places[c].flags =TTM_PL_MASK_CACHING ; c++; }@@ -591,7 +597,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,amdgpu_cs_report_moved_bytes (adev, ctx.bytes_moved,0 );if (bp->flags &AMDGPU_GEM_CREATE_VRAM_CLEARED && - bo->tbo.mem.placement &TTM_PL_FLAG_VRAM ) { + bo->tbo.mem.mem_type ==TTM_PL_VRAM ) {struct dma_fence *fence; r =amdgpu_fill_buffer (bo,0 , bo->tbo.base.resv, &fence);drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +8
-5@@ -88,7 +88,8 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo,static const struct ttm_place placements = { .fpfn =0 , .lpfn =0 , - .flags =TTM_PL_MASK_CACHING |TTM_PL_FLAG_SYSTEM + .mem_type =TTM_PL_SYSTEM , + .flags =TTM_PL_MASK_CACHING };/* Don't handle scatter gather BOs */ @@ -551,7 +552,8 @@ static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, bool evict, placement.busy_placement = &placements; placements.fpfn =0 ; placements.lpfn =0 ; - placements.flags =TTM_PL_MASK_CACHING |TTM_PL_FLAG_TT ; + placements.mem_type =TTM_PL_TT ; + placements.flags =TTM_PL_MASK_CACHING ; r =ttm_bo_mem_space (bo, &placement, &tmp_mem, ctx);if (unlikely (r)) {pr_err ("Failed to find GTT space for blit from VRAM\n" );@@ -607,7 +609,8 @@ static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, bool evict, placement.busy_placement = &placements; placements.fpfn =0 ; placements.lpfn =0 ; - placements.flags =TTM_PL_MASK_CACHING |TTM_PL_FLAG_TT ; + placements.mem_type =TTM_PL_TT ; + placements.flags =TTM_PL_MASK_CACHING ; r =ttm_bo_mem_space (bo, &placement, &tmp_mem, ctx);if (unlikely (r)) {pr_err ("Failed to find GTT space for blit to VRAM\n" );@@ -1189,8 +1192,8 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo) placement.busy_placement = &placements; placements.fpfn =0 ; placements.lpfn = adev->gmc.gart_size >>PAGE_SHIFT ; - placements.flags = (bo->mem.placement & ~TTM_PL_MASK_MEM ) | -TTM_PL_FLAG_TT ; + placements.mem_type =TTM_PL_TT ; + placements.flags = bo->mem.placement; r =ttm_bo_mem_space (bo, &placement, &tmp, &ctx);if (unlikely (r))drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +0
-4@@ -32,10 +32,6 @@#define AMDGPU_PL_GWS (TTM_PL_PRIV + 1)#define AMDGPU_PL_OA (TTM_PL_PRIV + 2) -#define AMDGPU_PL_FLAG_GDS (TTM_PL_FLAG_PRIV << 0) -#define AMDGPU_PL_FLAG_GWS (TTM_PL_FLAG_PRIV << 1) -#define AMDGPU_PL_FLAG_OA (TTM_PL_FLAG_PRIV << 2) -#define AMDGPU_GTT_MAX_TRANSFER_SIZE 512#define AMDGPU_GTT_NUM_TRANSFER_WINDOWS 2drivers/gpu/drm/drm_gem_vram_helper.c +6
-9@@ -145,21 +145,18 @@ static void drm_gem_vram_placement(struct drm_gem_vram_object *gbo, gbo->placement.placement = gbo->placements; gbo->placement.busy_placement = gbo->placements; -if (pl_flag &DRM_GEM_VRAM_PL_FLAG_VRAM ) +if (pl_flag &DRM_GEM_VRAM_PL_FLAG_VRAM ) { + gbo->placements[c].mem_type =TTM_PL_VRAM ; gbo->placements[c++].flags =TTM_PL_FLAG_WC |TTM_PL_FLAG_UNCACHED | -TTM_PL_FLAG_VRAM | - invariant_flags; - -if (pl_flag &DRM_GEM_VRAM_PL_FLAG_SYSTEM ) - gbo->placements[c++].flags =TTM_PL_MASK_CACHING | -TTM_PL_FLAG_SYSTEM | invariant_flags; + } -if (!c) +if (pl_flag &DRM_GEM_VRAM_PL_FLAG_SYSTEM || !c) { + gbo->placements[c].mem_type =TTM_PL_SYSTEM ; gbo->placements[c++].flags =TTM_PL_MASK_CACHING | -TTM_PL_FLAG_SYSTEM | invariant_flags; + } gbo->placement.num_placement = c; gbo->placement.num_busy_placement = c;drivers/gpu/drm/nouveau/nouveau_bo.c +16
-8@@ -345,12 +345,18 @@ set_placement_list(struct ttm_place *pl, unsigned *n, uint32_t domain, { *n =0 ; -if (domain &NOUVEAU_GEM_DOMAIN_VRAM ) - pl[(*n)++].flags =TTM_PL_FLAG_VRAM | flags; -if (domain &NOUVEAU_GEM_DOMAIN_GART ) - pl[(*n)++].flags =TTM_PL_FLAG_TT | flags; -if (domain &NOUVEAU_GEM_DOMAIN_CPU ) - pl[(*n)++].flags =TTM_PL_FLAG_SYSTEM | flags; +if (domain &NOUVEAU_GEM_DOMAIN_VRAM ) { + pl[*n].mem_type =TTM_PL_VRAM ; + pl[(*n)++].flags = flags; + } +if (domain &NOUVEAU_GEM_DOMAIN_GART ) { + pl[*n].mem_type =TTM_PL_TT ; + pl[(*n)++].flags = flags; + } +if (domain &NOUVEAU_GEM_DOMAIN_CPU ) { + pl[*n].mem_type =TTM_PL_SYSTEM ; + pl[(*n)++].flags = flags; + } } static void@@ -855,7 +861,8 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,struct ttm_place placement_memtype = { .fpfn =0 , .lpfn =0 , - .flags =TTM_PL_FLAG_TT |TTM_PL_MASK_CACHING + .mem_type =TTM_PL_TT , + .flags =TTM_PL_MASK_CACHING };struct ttm_placement placement;struct ttm_resource tmp_reg;@@ -892,7 +899,8 @@ nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict, bool intr,struct ttm_place placement_memtype = { .fpfn =0 , .lpfn =0 , - .flags =TTM_PL_FLAG_TT |TTM_PL_MASK_CACHING + .mem_type =TTM_PL_TT , + .flags =TTM_PL_MASK_CACHING };struct ttm_placement placement;struct ttm_resource tmp_reg;drivers/gpu/drm/qxl/qxl_object.c +16
-8@@ -64,16 +64,24 @@ void qxl_ttm_placement_from_domain(struct qxl_bo *qbo, u32 domain, bool pinned) qbo->placement.placement = qbo->placements; qbo->placement.busy_placement = qbo->placements; -if (domain ==QXL_GEM_DOMAIN_VRAM ) - qbo->placements[c++].flags =TTM_PL_FLAG_CACHED |TTM_PL_FLAG_VRAM | pflag; +if (domain ==QXL_GEM_DOMAIN_VRAM ) { + qbo->placements[c].mem_type =TTM_PL_VRAM ; + qbo->placements[c++].flags =TTM_PL_FLAG_CACHED | pflag; + }if (domain ==QXL_GEM_DOMAIN_SURFACE ) { - qbo->placements[c++].flags =TTM_PL_FLAG_CACHED |TTM_PL_FLAG_PRIV | pflag; - qbo->placements[c++].flags =TTM_PL_FLAG_CACHED |TTM_PL_FLAG_VRAM | pflag; + qbo->placements[c].mem_type =TTM_PL_PRIV ; + qbo->placements[c++].flags =TTM_PL_FLAG_CACHED | pflag; + qbo->placements[c].mem_type =TTM_PL_VRAM ; + qbo->placements[c++].flags =TTM_PL_FLAG_CACHED | pflag; + } +if (domain ==QXL_GEM_DOMAIN_CPU ) { + qbo->placements[c].mem_type =TTM_PL_SYSTEM ; + qbo->placements[c++].flags =TTM_PL_MASK_CACHING | pflag; + } +if (!c) { + qbo->placements[c].mem_type =TTM_PL_SYSTEM ; + qbo->placements[c++].flags =TTM_PL_MASK_CACHING ; } -if (domain ==QXL_GEM_DOMAIN_CPU ) - qbo->placements[c++].flags =TTM_PL_MASK_CACHING |TTM_PL_FLAG_SYSTEM | pflag; -if (!c) - qbo->placements[c++].flags =TTM_PL_MASK_CACHING |TTM_PL_FLAG_SYSTEM ; qbo->placement.num_placement = c; qbo->placement.num_busy_placement = c;for (i =0 ; i < c; ++i) {drivers/gpu/drm/qxl/qxl_ttm.c +2
-1@@ -55,7 +55,8 @@ static void qxl_evict_flags(struct ttm_buffer_object *bo,static const struct ttm_place placements = { .fpfn =0 , .lpfn =0 , - .flags =TTM_PL_MASK_CACHING |TTM_PL_FLAG_SYSTEM + .mem_type =TTM_PL_SYSTEM , + .flags =TTM_PL_MASK_CACHING };if (!qxl_ttm_bo_is_qxl_bo (bo)) {drivers/gpu/drm/radeon/radeon_object.c +21
-21@@ -112,58 +112,58 @@ void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain) rbo->rdev->mc.visible_vram_size < rbo->rdev->mc.real_vram_size) { rbo->placements[c].fpfn = rbo->rdev->mc.visible_vram_size >>PAGE_SHIFT ; + rbo->placements[c].mem_type =TTM_PL_VRAM ; rbo->placements[c++].flags =TTM_PL_FLAG_WC | -TTM_PL_FLAG_UNCACHED | -TTM_PL_FLAG_VRAM ; +TTM_PL_FLAG_UNCACHED ; } rbo->placements[c].fpfn =0 ; + rbo->placements[c].mem_type =TTM_PL_VRAM ; rbo->placements[c++].flags =TTM_PL_FLAG_WC | -TTM_PL_FLAG_UNCACHED | -TTM_PL_FLAG_VRAM ; +TTM_PL_FLAG_UNCACHED ; }if (domain &RADEON_GEM_DOMAIN_GTT ) {if (rbo->flags &RADEON_GEM_GTT_UC ) { rbo->placements[c].fpfn =0 ; - rbo->placements[c++].flags =TTM_PL_FLAG_UNCACHED | -TTM_PL_FLAG_TT ; + rbo->placements[c].mem_type =TTM_PL_TT ; + rbo->placements[c++].flags =TTM_PL_FLAG_UNCACHED ; }else if ((rbo->flags &RADEON_GEM_GTT_WC ) || (rbo->rdev->flags &RADEON_IS_AGP )) { rbo->placements[c].fpfn =0 ; + rbo->placements[c].mem_type =TTM_PL_TT ; rbo->placements[c++].flags =TTM_PL_FLAG_WC | -TTM_PL_FLAG_UNCACHED | -TTM_PL_FLAG_TT ; +TTM_PL_FLAG_UNCACHED ; }else { rbo->placements[c].fpfn =0 ; - rbo->placements[c++].flags =TTM_PL_FLAG_CACHED | -TTM_PL_FLAG_TT ; + rbo->placements[c].mem_type =TTM_PL_TT ; + rbo->placements[c++].flags =TTM_PL_FLAG_CACHED ; } }if (domain &RADEON_GEM_DOMAIN_CPU ) {if (rbo->flags &RADEON_GEM_GTT_UC ) { rbo->placements[c].fpfn =0 ; - rbo->placements[c++].flags =TTM_PL_FLAG_UNCACHED | -TTM_PL_FLAG_SYSTEM ; + rbo->placements[c].mem_type =TTM_PL_SYSTEM ; + rbo->placements[c++].flags =TTM_PL_FLAG_UNCACHED ; }else if ((rbo->flags &RADEON_GEM_GTT_WC ) || rbo->rdev->flags &RADEON_IS_AGP ) { rbo->placements[c].fpfn =0 ; + rbo->placements[c].mem_type =TTM_PL_SYSTEM ; rbo->placements[c++].flags =TTM_PL_FLAG_WC | -TTM_PL_FLAG_UNCACHED | -TTM_PL_FLAG_SYSTEM ; +TTM_PL_FLAG_UNCACHED ; }else { rbo->placements[c].fpfn =0 ; - rbo->placements[c++].flags =TTM_PL_FLAG_CACHED | -TTM_PL_FLAG_SYSTEM ; + rbo->placements[c].mem_type =TTM_PL_SYSTEM ; + rbo->placements[c++].flags =TTM_PL_FLAG_CACHED ; } }if (!c) { rbo->placements[c].fpfn =0 ; - rbo->placements[c++].flags =TTM_PL_MASK_CACHING | -TTM_PL_FLAG_SYSTEM ; + rbo->placements[c].mem_type =TTM_PL_SYSTEM ; + rbo->placements[c++].flags =TTM_PL_MASK_CACHING ; } rbo->placement.num_placement = c;@@ -171,7 +171,7 @@ void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain)for (i =0 ; i < c; ++i) {if ((rbo->flags &RADEON_GEM_CPU_ACCESS ) && - (rbo->placements[i].flags &TTM_PL_FLAG_VRAM ) && + (rbo->placements[i].mem_type ==TTM_PL_VRAM ) && !rbo->placements[i].fpfn) rbo->placements[i].lpfn = rbo->rdev->mc.visible_vram_size >>PAGE_SHIFT ;@@ -360,7 +360,7 @@ int radeon_bo_pin_restricted(struct radeon_bo *bo, u32 domain, u64 max_offset,radeon_ttm_placement_from_domain (bo, domain);for (i =0 ; i < bo->placement.num_placement; i++) {/* force to pin into visible video ram */ -if ((bo->placements[i].flags &TTM_PL_FLAG_VRAM ) && +if ((bo->placements[i].mem_type ==TTM_PL_VRAM ) && !(bo->flags &RADEON_GEM_NO_CPU_ACCESS ) && (!max_offset || max_offset > bo->rdev->mc.visible_vram_size)) bo->placements[i].lpfn =@@ -824,7 +824,7 @@ int radeon_bo_fault_reserve_notify(struct ttm_buffer_object *bo) lpfn = rdev->mc.visible_vram_size >>PAGE_SHIFT ;for (i =0 ; i < rbo->placement.num_placement; i++) {/* Force into visible VRAM */ -if ((rbo->placements[i].flags &TTM_PL_FLAG_VRAM ) && +if ((rbo->placements[i].mem_type ==TTM_PL_VRAM ) && (!rbo->placements[i].lpfn || rbo->placements[i].lpfn > lpfn)) rbo->placements[i].lpfn = lpfn; }drivers/gpu/drm/radeon/radeon_ttm.c +7
-4@@ -88,7 +88,8 @@ static void radeon_evict_flags(struct ttm_buffer_object *bo,static const struct ttm_place placements = { .fpfn =0 , .lpfn =0 , - .flags =TTM_PL_MASK_CACHING |TTM_PL_FLAG_SYSTEM + .mem_type =TTM_PL_SYSTEM , + .flags =TTM_PL_MASK_CACHING };struct radeon_bo *rbo;@@ -119,7 +120,7 @@ static void radeon_evict_flags(struct ttm_buffer_object *bo, RADEON_GEM_DOMAIN_GTT); rbo->placement.num_busy_placement =0 ;for (i =0 ; i < rbo->placement.num_placement; i++) { -if (rbo->placements[i].flags &TTM_PL_FLAG_VRAM ) { +if (rbo->placements[i].mem_type ==TTM_PL_VRAM ) {if (rbo->placements[i].fpfn < fpfn) rbo->placements[i].fpfn = fpfn; }else {@@ -233,7 +234,8 @@ static int radeon_move_vram_ram(struct ttm_buffer_object *bo, placement.busy_placement = &placements; placements.fpfn =0 ; placements.lpfn =0 ; - placements.flags =TTM_PL_MASK_CACHING |TTM_PL_FLAG_TT ; + placements.mem_type =TTM_PL_TT ; + placements.flags =TTM_PL_MASK_CACHING ; r =ttm_bo_mem_space (bo, &placement, &tmp_mem, &ctx);if (unlikely (r)) {return r;@@ -278,7 +280,8 @@ static int radeon_move_ram_vram(struct ttm_buffer_object *bo, placement.busy_placement = &placements; placements.fpfn =0 ; placements.lpfn =0 ; - placements.flags =TTM_PL_MASK_CACHING |TTM_PL_FLAG_TT ; + placements.mem_type =TTM_PL_TT ; + placements.flags =TTM_PL_MASK_CACHING ; r =ttm_bo_mem_space (bo, &placement, &tmp_mem, &ctx);if (unlikely (r)) {return r;drivers/gpu/drm/ttm/ttm_bo.c +14
-72@@ -64,34 +64,18 @@ static void ttm_bo_default_destroy(struct ttm_buffer_object *bo)kfree (bo); } -static inline int ttm_mem_type_from_place (const struct ttm_place *place, -uint32_t *mem_type) -{ -int pos; - - pos =ffs (place->flags &TTM_PL_MASK_MEM ); -if (unlikely (!pos)) -return -EINVAL ; - - *mem_type = pos -1 ; -return 0 ; -} -static void ttm_bo_mem_space_debug (struct ttm_buffer_object *bo,struct ttm_placement *placement) {struct drm_printer p =drm_debug_printer (TTM_PFX ); -int i, ret, mem_type;struct ttm_resource_manager *man; +int i, mem_type;drm_printf (&p,"No space for %p (%lu pages, %luK, %luM)\n" , bo, bo->mem.num_pages, bo->mem.size >>10 , bo->mem.size >>20 );for (i =0 ; i < placement->num_placement; i++) { - ret =ttm_mem_type_from_place (&placement->placement[i], - &mem_type); -if (ret) -return ; + mem_type = placement->placement[i].mem_type;drm_printf (&p," placement[%d]=0x%08X (%d)\n" , i, placement->placement[i].flags, mem_type); man =ttm_manager_type (bo->bdev, mem_type);@@ -125,12 +109,6 @@ static struct kobj_type ttm_bo_glob_kobj_type = { .default_attrs = ttm_bo_global_attrs }; - -static inline uint32_t ttm_bo_type_flags (unsigned type) -{ -return 1 << (type); -} -static void ttm_bo_add_mem_to_lru (struct ttm_buffer_object *bo,struct ttm_resource *mem) {@@ -910,25 +888,6 @@ static uint32_t ttm_bo_select_caching(struct ttm_resource_manager *man,return result; } -static bool ttm_bo_mt_compatible (struct ttm_resource_manager *man, -uint32_t mem_type, -const struct ttm_place *place, -uint32_t *masked_placement) -{ -uint32_t cur_flags =ttm_bo_type_flags (mem_type); - -if ((cur_flags & place->flags &TTM_PL_MASK_MEM ) ==0 ) -return false; - -if ((place->flags & man->available_caching) ==0 ) -return false; - - cur_flags |= (place->flags & man->available_caching); - - *masked_placement = cur_flags; -return true; -} -/** * ttm_bo_mem_placement - check if placement is compatible * @bo: BO to find memory for @@ -946,30 +905,21 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx) {struct ttm_bo_device *bdev = bo->bdev; -uint32_t mem_type =TTM_PL_SYSTEM ;struct ttm_resource_manager *man;uint32_t cur_flags =0 ; -int ret; - ret =ttm_mem_type_from_place (place, &mem_type); -if (ret) -return ret; - - man =ttm_manager_type (bdev, mem_type); + man =ttm_manager_type (bdev, place->mem_type);if (!man || !ttm_resource_manager_used (man))return -EBUSY ; -if (!ttm_bo_mt_compatible (man, mem_type, place, &cur_flags)) +if ((place->flags & man->available_caching) ==0 )return -EBUSY ; + cur_flags = place->flags & man->available_caching; cur_flags =ttm_bo_select_caching (man, bo->mem.placement, cur_flags); -/* -* Use the access and other non-mapping-related flag bits from -* the memory placement flags to the current flags -*/ -ttm_flag_masked (&cur_flags, place->flags, ~TTM_PL_MASK_MEMTYPE ); + cur_flags |= place->flags & ~TTM_PL_MASK_CACHING ; - mem->mem_type = mem_type; + mem->mem_type = place->mem_type; mem->placement = cur_flags;spin_lock (&ttm_bo_glob.lru_lock);@@ -1006,10 +956,8 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,struct ttm_resource_manager *man; ret =ttm_bo_mem_placement (bo, place, mem, ctx); -if (ret == -EBUSY ) -continue ;if (ret) - goto error; +continue ; type_found = true; ret =ttm_resource_alloc (bo, place, mem);@@ -1034,10 +982,8 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,const struct ttm_place *place = &placement->busy_placement[i]; ret =ttm_bo_mem_placement (bo, place, mem, ctx); -if (ret == -EBUSY ) -continue ;if (ret) - goto error; +continue ; type_found = true; ret =ttm_bo_mem_force_space (bo, place, mem, ctx);@@ -1108,7 +1054,7 @@ static bool ttm_bo_places_compat(const struct ttm_place *places, *new_flags = heap->flags;if ((*new_flags & mem->placement &TTM_PL_MASK_CACHING ) && - (*new_flags & mem->placement &TTM_PL_MASK_MEM ) && + (mem->mem_type == heap->mem_type) && (!(*new_flags &TTM_PL_FLAG_CONTIGUOUS ) || (mem->placement &TTM_PL_FLAG_CONTIGUOUS )))return true;@@ -1163,12 +1109,8 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,if (ret)return ret; }else { -/* -* Use the access and other non-mapping-related flag bits from -* the compatible memory placement flags to the active flags -*/ -ttm_flag_masked (&bo->mem.placement, new_flags, - ~TTM_PL_MASK_MEMTYPE ); + bo->mem.placement &=TTM_PL_MASK_CACHING ; + bo->mem.placement |= new_flags & ~TTM_PL_MASK_CACHING ; }/* * We might need to add a TTM. @@ -1236,7 +1178,7 @@ int ttm_bo_init_reserved(struct ttm_bo_device *bdev, bo->mem.bus.offset =0 ; bo->mem.bus.addr =NULL ; bo->moving =NULL ; - bo->mem.placement = (TTM_PL_FLAG_SYSTEM |TTM_PL_FLAG_CACHED ); + bo->mem.placement =TTM_PL_FLAG_CACHED ; bo->acc_size = acc_size; bo->sg = sg;if (resv) {@@ -1627,7 +1569,7 @@ int ttm_bo_swapout(struct ttm_bo_global *glob, struct ttm_operation_ctx *ctx) evict_mem = bo->mem; evict_mem.mm_node =NULL ; - evict_mem.placement =TTM_PL_FLAG_SYSTEM |TTM_PL_FLAG_CACHED ; + evict_mem.placement =TTM_PL_FLAG_CACHED ; evict_mem.mem_type =TTM_PL_SYSTEM ; ret =ttm_bo_handle_move_mem (bo, &evict_mem, true, &ctx);drivers/gpu/drm/ttm/ttm_bo_util.c +0
-2@@ -69,8 +69,6 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,ttm_tt_unbind (bo->bdev, ttm);ttm_bo_free_old_node (bo); -ttm_flag_masked (&old_mem->placement,TTM_PL_FLAG_SYSTEM , -TTM_PL_MASK_MEM ); old_mem->mem_type =TTM_PL_SYSTEM ; }drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +1
-0@@ -354,6 +354,7 @@ void vmw_bo_pin_reserved(struct vmw_buffer_object *vbo, bool pin) pl.fpfn =0 ; pl.lpfn =0 ; + pl.mem_type = bo->mem.mem_type; pl.flags = bo->mem.placement;if (pin) pl.flags |=TTM_PL_FLAG_NO_EVICT ;drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +0
-2@@ -82,9 +82,7 @@ VMWGFX_NUM_GB_SCREEN_TARGET)#define VMW_PL_GMR (TTM_PL_PRIV + 0) -#define VMW_PL_FLAG_GMR (TTM_PL_FLAG_PRIV << 0)#define VMW_PL_MOB (TTM_PL_PRIV + 1) -#define VMW_PL_FLAG_MOB (TTM_PL_FLAG_PRIV << 1)#define VMW_RES_CONTEXT ttm_driver_type0#define VMW_RES_SURFACE ttm_driver_type1drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +42
-21@@ -33,49 +33,57 @@static const struct ttm_place vram_placement_flags = { .fpfn =0 , .lpfn =0 , - .flags =TTM_PL_FLAG_VRAM |TTM_PL_FLAG_CACHED + .mem_type =TTM_PL_VRAM , + .flags =TTM_PL_FLAG_CACHED };static const struct ttm_place vram_ne_placement_flags = { .fpfn =0 , .lpfn =0 , - .flags =TTM_PL_FLAG_VRAM |TTM_PL_FLAG_CACHED |TTM_PL_FLAG_NO_EVICT + .mem_type =TTM_PL_VRAM , + .flags =TTM_PL_FLAG_CACHED |TTM_PL_FLAG_NO_EVICT };static const struct ttm_place sys_placement_flags = { .fpfn =0 , .lpfn =0 , - .flags =TTM_PL_FLAG_SYSTEM |TTM_PL_FLAG_CACHED + .mem_type =TTM_PL_SYSTEM , + .flags =TTM_PL_FLAG_CACHED };static const struct ttm_place sys_ne_placement_flags = { .fpfn =0 , .lpfn =0 , - .flags =TTM_PL_FLAG_SYSTEM |TTM_PL_FLAG_CACHED |TTM_PL_FLAG_NO_EVICT + .mem_type =TTM_PL_SYSTEM , + .flags =TTM_PL_FLAG_CACHED |TTM_PL_FLAG_NO_EVICT };static const struct ttm_place gmr_placement_flags = { .fpfn =0 , .lpfn =0 , - .flags =VMW_PL_FLAG_GMR |TTM_PL_FLAG_CACHED + .mem_type =VMW_PL_GMR , + .flags =TTM_PL_FLAG_CACHED };static const struct ttm_place gmr_ne_placement_flags = { .fpfn =0 , .lpfn =0 , - .flags =VMW_PL_FLAG_GMR |TTM_PL_FLAG_CACHED |TTM_PL_FLAG_NO_EVICT + .mem_type =VMW_PL_GMR , + .flags =TTM_PL_FLAG_CACHED |TTM_PL_FLAG_NO_EVICT };static const struct ttm_place mob_placement_flags = { .fpfn =0 , .lpfn =0 , - .flags =VMW_PL_FLAG_MOB |TTM_PL_FLAG_CACHED + .mem_type =VMW_PL_MOB , + .flags =TTM_PL_FLAG_CACHED };static const struct ttm_place mob_ne_placement_flags = { .fpfn =0 , .lpfn =0 , - .flags =VMW_PL_FLAG_MOB |TTM_PL_FLAG_CACHED |TTM_PL_FLAG_NO_EVICT + .mem_type =VMW_PL_MOB , + .flags =TTM_PL_FLAG_CACHED |TTM_PL_FLAG_NO_EVICT };struct ttm_placement vmw_vram_placement = {@@ -89,11 +97,13 @@ static const struct ttm_place vram_gmr_placement_flags[] = { { .fpfn = 0, .lpfn = 0, - .flags = TTM_PL_FLAG_VRAM | TTM_PL_FLAG_CACHED + .mem_type = TTM_PL_VRAM, + .flags = TTM_PL_FLAG_CACHED }, { .fpfn = 0, .lpfn = 0, - .flags = VMW_PL_FLAG_GMR | TTM_PL_FLAG_CACHED + .mem_type = VMW_PL_GMR, + .flags = TTM_PL_FLAG_CACHED } };@@ -101,11 +111,13 @@ static const struct ttm_place gmr_vram_placement_flags[] = { { .fpfn = 0, .lpfn = 0, - .flags = VMW_PL_FLAG_GMR | TTM_PL_FLAG_CACHED + .mem_type = VMW_PL_GMR, + .flags = TTM_PL_FLAG_CACHED }, { .fpfn = 0, .lpfn = 0, - .flags = TTM_PL_FLAG_VRAM | TTM_PL_FLAG_CACHED + .mem_type = TTM_PL_VRAM, + .flags = TTM_PL_FLAG_CACHED } };@@ -120,12 +132,14 @@ static const struct ttm_place vram_gmr_ne_placement_flags[] = { { .fpfn = 0, .lpfn = 0, - .flags =TTM_PL_FLAG_VRAM |TTM_PL_FLAG_CACHED | + .mem_type = TTM_PL_VRAM, + .flags =TTM_PL_FLAG_CACHED |TTM_PL_FLAG_NO_EVICT }, { .fpfn = 0, .lpfn = 0, - .flags =VMW_PL_FLAG_GMR |TTM_PL_FLAG_CACHED | + .mem_type = VMW_PL_GMR, + .flags =TTM_PL_FLAG_CACHED | TTM_PL_FLAG_NO_EVICT } };@@ -169,19 +183,23 @@ static const struct ttm_place evictable_placement_flags[] = { { .fpfn = 0, .lpfn = 0, - .flags =TTM_PL_FLAG_SYSTEM |TTM_PL_FLAG_CACHED + .mem_type = TTM_PL_SYSTEM, + .flags =TTM_PL_FLAG_CACHED }, { .fpfn = 0, .lpfn = 0, - .flags =TTM_PL_FLAG_VRAM |TTM_PL_FLAG_CACHED + .mem_type = TTM_PL_VRAM, + .flags =TTM_PL_FLAG_CACHED }, { .fpfn = 0, .lpfn = 0, - .flags =VMW_PL_FLAG_GMR |TTM_PL_FLAG_CACHED + .mem_type = VMW_PL_GMR, + .flags =TTM_PL_FLAG_CACHED }, { .fpfn = 0, .lpfn = 0, - .flags = VMW_PL_FLAG_MOB | TTM_PL_FLAG_CACHED + .mem_type = VMW_PL_MOB, + .flags = TTM_PL_FLAG_CACHED } };@@ -189,15 +207,18 @@ static const struct ttm_place nonfixed_placement_flags[] = { { .fpfn = 0, .lpfn = 0, - .flags =TTM_PL_FLAG_SYSTEM |TTM_PL_FLAG_CACHED + .mem_type = TTM_PL_SYSTEM, + .flags =TTM_PL_FLAG_CACHED }, { .fpfn = 0, .lpfn = 0, - .flags =VMW_PL_FLAG_GMR |TTM_PL_FLAG_CACHED + .mem_type = VMW_PL_GMR, + .flags =TTM_PL_FLAG_CACHED }, { .fpfn = 0, .lpfn = 0, - .flags = VMW_PL_FLAG_MOB | TTM_PL_FLAG_CACHED + .mem_type = VMW_PL_MOB, + .flags = TTM_PL_FLAG_CACHED } };include/drm/ttm/ttm_bo_driver.h +0
-17@@ -357,23 +357,6 @@ struct ttm_lru_bulk_move {struct ttm_lru_bulk_move_pos swap[TTM_MAX_BO_PRIORITY ]; }; -/** -* ttm_flag_masked -* -* @old: Pointer to the result and original value. -* @new: New value of bits. -* @mask: Mask of bits to change. -* -* Convenience function to change a number of bits identified by a mask. -*/ - -static inline uint32_t -ttm_flag_masked (uint32_t *old,uint32_t new,uint32_t mask) -{ - *old ^= (*old ^ new) & mask; -return *old; -} -/* * ttm_bo.c */ include/drm/ttm/ttm_placement.h +1
-9@@ -42,12 +42,6 @@#define TTM_PL_VRAM 2#define TTM_PL_PRIV 3 -#define TTM_PL_FLAG_SYSTEM (1 << TTM_PL_SYSTEM) -#define TTM_PL_FLAG_TT (1 << TTM_PL_TT) -#define TTM_PL_FLAG_VRAM (1 << TTM_PL_VRAM) -#define TTM_PL_FLAG_PRIV (1 << TTM_PL_PRIV) -#define TTM_PL_MASK_MEM 0x0000FFFF -/* * Other flags that affects data placement. * TTM_PL_FLAG_CACHED indicates cache-coherent mappings @@ -71,8 +65,6 @@TTM_PL_FLAG_UNCACHED | \ TTM_PL_FLAG_WC) -#define TTM_PL_MASK_MEMTYPE (TTM_PL_MASK_MEM | TTM_PL_MASK_CACHING) -/** * struct ttm_place * @@ -85,6 +77,7 @@struct ttm_place {unsigned fpfn;unsigned lpfn; +uint32_t mem_type;uint32_t flags; }; --
Quoted 2 lines
2.17.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel