Lines Matching +full:man +full:- +full:pages
1 // SPDX-License-Identifier: GPL-2.0 OR MIT
4 * Copyright 2007-2010 VMware, Inc., Palo Alto, CA., USA
20 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
28 * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
47 static struct vmwgfx_gmrid_man *to_gmrid_manager(struct ttm_resource_manager *man) in to_gmrid_manager() argument
49 return container_of(man, struct vmwgfx_gmrid_man, manager); in to_gmrid_manager()
52 static int vmw_gmrid_man_get_node(struct ttm_resource_manager *man, in vmw_gmrid_man_get_node() argument
57 struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man); in vmw_gmrid_man_get_node()
62 return -ENOMEM; in vmw_gmrid_man_get_node()
66 id = ida_alloc_max(&gman->gmr_ida, gman->max_gmr_ids - 1, GFP_KERNEL); in vmw_gmrid_man_get_node()
68 ttm_resource_fini(man, *res); in vmw_gmrid_man_get_node()
73 spin_lock(&gman->lock); in vmw_gmrid_man_get_node()
75 if (gman->max_gmr_pages > 0) { in vmw_gmrid_man_get_node()
76 gman->used_gmr_pages += PFN_UP((*res)->size); in vmw_gmrid_man_get_node()
84 if (unlikely(gman->used_gmr_pages > gman->max_gmr_pages)) { in vmw_gmrid_man_get_node()
91 if (gman->max_gmr_pages > (max_graphics_pages / 2)) { in vmw_gmrid_man_get_node()
95 new_max_pages = gman->max_gmr_pages * 2; in vmw_gmrid_man_get_node()
96 if (new_max_pages > gman->max_gmr_pages && new_max_pages >= gman->used_gmr_pages) { in vmw_gmrid_man_get_node()
98 ((new_max_pages) << (PAGE_SHIFT - 10))); in vmw_gmrid_man_get_node()
100 gman->max_gmr_pages = new_max_pages; in vmw_gmrid_man_get_node()
105 ((gman->max_gmr_pages) << (PAGE_SHIFT - 10))); in vmw_gmrid_man_get_node()
113 (*res)->start = id; in vmw_gmrid_man_get_node()
115 spin_unlock(&gman->lock); in vmw_gmrid_man_get_node()
119 gman->used_gmr_pages -= PFN_UP((*res)->size); in vmw_gmrid_man_get_node()
120 spin_unlock(&gman->lock); in vmw_gmrid_man_get_node()
121 ida_free(&gman->gmr_ida, id); in vmw_gmrid_man_get_node()
122 ttm_resource_fini(man, *res); in vmw_gmrid_man_get_node()
124 return -ENOSPC; in vmw_gmrid_man_get_node()
127 static void vmw_gmrid_man_put_node(struct ttm_resource_manager *man, in vmw_gmrid_man_put_node() argument
130 struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man); in vmw_gmrid_man_put_node()
132 ida_free(&gman->gmr_ida, res->start); in vmw_gmrid_man_put_node()
133 spin_lock(&gman->lock); in vmw_gmrid_man_put_node()
134 gman->used_gmr_pages -= PFN_UP(res->size); in vmw_gmrid_man_put_node()
135 spin_unlock(&gman->lock); in vmw_gmrid_man_put_node()
136 ttm_resource_fini(man, res); in vmw_gmrid_man_put_node()
140 static void vmw_gmrid_man_debug(struct ttm_resource_manager *man, in vmw_gmrid_man_debug() argument
143 struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man); in vmw_gmrid_man_debug()
145 BUG_ON(gman->type != VMW_PL_GMR && gman->type != VMW_PL_MOB); in vmw_gmrid_man_debug()
147 drm_printf(printer, "%s's used: %u pages, max: %u pages, %u id's\n", in vmw_gmrid_man_debug()
148 (gman->type == VMW_PL_MOB) ? "Mob" : "GMR", in vmw_gmrid_man_debug()
149 gman->used_gmr_pages, gman->max_gmr_pages, gman->max_gmr_ids); in vmw_gmrid_man_debug()
156 struct ttm_resource_manager *man; in vmw_gmrid_man_init() local
161 return -ENOMEM; in vmw_gmrid_man_init()
163 man = &gman->manager; in vmw_gmrid_man_init()
165 man->func = &vmw_gmrid_manager_func; in vmw_gmrid_man_init()
166 man->use_tt = true; in vmw_gmrid_man_init()
167 ttm_resource_manager_init(man, &dev_priv->bdev, 0); in vmw_gmrid_man_init()
168 spin_lock_init(&gman->lock); in vmw_gmrid_man_init()
169 gman->used_gmr_pages = 0; in vmw_gmrid_man_init()
170 ida_init(&gman->gmr_ida); in vmw_gmrid_man_init()
171 gman->type = type; in vmw_gmrid_man_init()
175 gman->max_gmr_ids = dev_priv->max_gmr_ids; in vmw_gmrid_man_init()
176 gman->max_gmr_pages = dev_priv->max_gmr_pages; in vmw_gmrid_man_init()
179 gman->max_gmr_ids = VMWGFX_NUM_MOB; in vmw_gmrid_man_init()
180 gman->max_gmr_pages = dev_priv->max_mob_pages; in vmw_gmrid_man_init()
185 ttm_set_driver_manager(&dev_priv->bdev, type, &gman->manager); in vmw_gmrid_man_init()
186 ttm_resource_manager_set_used(man, true); in vmw_gmrid_man_init()
192 struct ttm_resource_manager *man = ttm_manager_type(&dev_priv->bdev, type); in vmw_gmrid_man_fini() local
193 struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man); in vmw_gmrid_man_fini()
195 ttm_resource_manager_set_used(man, false); in vmw_gmrid_man_fini()
197 ttm_resource_manager_evict_all(&dev_priv->bdev, man); in vmw_gmrid_man_fini()
199 ttm_resource_manager_cleanup(man); in vmw_gmrid_man_fini()
201 ttm_set_driver_manager(&dev_priv->bdev, type, NULL); in vmw_gmrid_man_fini()
202 ida_destroy(&gman->gmr_ida); in vmw_gmrid_man_fini()