summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/gma500/gtt.c
diff options
context:
space:
mode:
authorThomas Zimmermann <tzimmermann@suse.de>2021-10-15 10:40:50 +0200
committerThomas Zimmermann <tzimmermann@suse.de>2021-10-19 10:38:54 +0200
commit3c101135baf2dcfa64081239818039a1fcc7767a (patch)
tree1dac9ca5ca6eef69d2b96febbeb559d86eb97d4f /drivers/gpu/drm/gma500/gtt.c
parent0b80214b64e38f33d359c0e121773357060b992f (diff)
downloadlinux-3c101135baf2dcfa64081239818039a1fcc7767a.tar.gz
linux-3c101135baf2dcfa64081239818039a1fcc7767a.tar.bz2
linux-3c101135baf2dcfa64081239818039a1fcc7767a.zip
drm/gma500: Inline psb_gtt_{alloc,free}_range() into rsp callers
psb_gtt_alloc_range() allocates struct gtt_range, create the GTT resource and performs some half-baked initialization. Inline the function into its only caller psb_gem_create(). For creating the GTT resource, introduce a new helper, psb_gtt_alloc_resource() that hides the details of the GTT. For psb_gtt_free_range(), inline the function into its only caller psb_gem_free_object(). While at it, remove the explicit invocation of drm_gem_free_mmap_offset(). The mmap offset is already released by drm_gem_object_release(). v3: * replace offset[static 1] with pointer notation (Patrik) Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Acked-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com> Link: https://patchwork.freedesktop.org/patch/msgid/20211015084053.13708-8-tzimmermann@suse.de
Diffstat (limited to 'drivers/gpu/drm/gma500/gtt.c')
-rw-r--r--drivers/gpu/drm/gma500/gtt.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/gpu/drm/gma500/gtt.c b/drivers/gpu/drm/gma500/gtt.c
index 0aacf7122e32..d00ca065f3d3 100644
--- a/drivers/gpu/drm/gma500/gtt.c
+++ b/drivers/gpu/drm/gma500/gtt.c
@@ -18,6 +18,33 @@
* GTT resource allocator - manage page mappings in GTT space
*/
+int psb_gtt_allocate_resource(struct drm_psb_private *pdev, struct resource *res,
+ const char *name, resource_size_t size, resource_size_t align,
+ bool stolen, u32 *offset)
+{
+ struct resource *root = pdev->gtt_mem;
+ resource_size_t start, end;
+ int ret;
+
+ if (stolen) {
+ /* The start of the GTT is backed by stolen pages. */
+ start = root->start;
+ end = root->start + pdev->gtt.stolen_size - 1;
+ } else {
+ /* The rest is backed by system pages. */
+ start = root->start + pdev->gtt.stolen_size;
+ end = root->end;
+ }
+
+ res->name = name;
+ ret = allocate_resource(root, res, size, start, end, align, NULL, NULL);
+ if (ret)
+ return ret;
+ *offset = res->start - root->start;
+
+ return 0;
+}
+
/**
* psb_gtt_mask_pte - generate GTT pte entry
* @pfn: page number to encode