All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arunpravin <Arunpravin.PaneerSelvam@amd.com>
To: <dri-devel@lists.freedesktop.org>,
	<intel-gfx@lists.freedesktop.org>,
	<amd-gfx@lists.freedesktop.org>
Cc: <christian.koenig@amd.com>, <daniel@ffwll.ch>,
	<matthew.auld@intel.com>, <alexander.deucher@amd.com>,
	Arunpravin <Arunpravin.PaneerSelvam@amd.com>
Subject: [PATCH 05/13] drm: remove drm_buddy_alloc_range
Date: Wed, 20 Oct 2021 04:24:01 +0530	[thread overview]
Message-ID: <20211019225409.569355-6-Arunpravin.PaneerSelvam@amd.com> (raw)
In-Reply-To: <20211019225409.569355-1-Arunpravin.PaneerSelvam@amd.com>

This function becomes obsolete and may be removed.

Signed-off-by: Arunpravin <Arunpravin.PaneerSelvam@amd.com>
---
 drivers/gpu/drm/drm_buddy.c | 101 ------------------------------------
 include/drm/drm_buddy.h     |   4 --
 2 files changed, 105 deletions(-)

diff --git a/drivers/gpu/drm/drm_buddy.c b/drivers/gpu/drm/drm_buddy.c
index f5f299dd9131..138e9f1a7340 100644
--- a/drivers/gpu/drm/drm_buddy.c
+++ b/drivers/gpu/drm/drm_buddy.c
@@ -457,107 +457,6 @@ int drm_buddy_alloc(struct drm_buddy_mm *mm,
 	return err;
 }
 
-/*
- * Allocate range. Note that it's safe to chain together multiple alloc_ranges
- * with the same blocks list.
- *
- * Intended for pre-allocating portions of the address space, for example to
- * reserve a block for the initial framebuffer or similar, hence the expectation
- * here is that drm_buddy_alloc() is still the main vehicle for
- * allocations, so if that's not the case then the drm_mm range allocator is
- * probably a much better fit, and so you should probably go use that instead.
- */
-int drm_buddy_alloc_range(struct drm_buddy_mm *mm,
-			  struct list_head *blocks,
-			  u64 start, u64 size)
-{
-	struct drm_buddy_block *block;
-	struct drm_buddy_block *buddy;
-	LIST_HEAD(allocated);
-	LIST_HEAD(dfs);
-	u64 end;
-	int err;
-	int i;
-
-	if (size < mm->chunk_size)
-		return -EINVAL;
-
-	if (!IS_ALIGNED(size | start, mm->chunk_size))
-		return -EINVAL;
-
-	if (range_overflows(start, size, mm->size))
-		return -EINVAL;
-
-	for (i = 0; i < mm->n_roots; ++i)
-		list_add_tail(&mm->roots[i]->tmp_link, &dfs);
-
-	end = start + size - 1;
-
-	do {
-		u64 block_start;
-		u64 block_end;
-
-		block = list_first_entry_or_null(&dfs,
-						 struct drm_buddy_block,
-						 tmp_link);
-		if (!block)
-			break;
-
-		list_del(&block->tmp_link);
-
-		block_start = drm_buddy_block_offset(block);
-		block_end = block_start + drm_buddy_block_size(mm, block) - 1;
-
-		if (!overlaps(start, end, block_start, block_end))
-			continue;
-
-		if (drm_buddy_block_is_allocated(block)) {
-			err = -ENOSPC;
-			goto err_free;
-		}
-
-		if (contains(start, end, block_start, block_end)) {
-			if (!drm_buddy_block_is_free(block)) {
-				err = -ENOSPC;
-				goto err_free;
-			}
-
-			mark_allocated(block);
-			mm->avail -= drm_buddy_block_size(mm, block);
-			list_add_tail(&block->link, &allocated);
-			continue;
-		}
-
-		if (!drm_buddy_block_is_split(block)) {
-			err = split_block(mm, block);
-			if (unlikely(err))
-				goto err_undo;
-		}
-
-		list_add(&block->right->tmp_link, &dfs);
-		list_add(&block->left->tmp_link, &dfs);
-	} while (1);
-
-	list_splice_tail(&allocated, blocks);
-	return 0;
-
-err_undo:
-	/*
-	 * We really don't want to leave around a bunch of split blocks, since
-	 * bigger is better, so make sure we merge everything back before we
-	 * free the allocated blocks.
-	 */
-	buddy = get_buddy(block);
-	if (buddy &&
-	    (drm_buddy_block_is_free(block) &&
-	     drm_buddy_block_is_free(buddy)))
-		__drm_buddy_free(mm, block);
-
-err_free:
-	drm_buddy_free_list(mm, &allocated);
-	return err;
-}
-
 void drm_buddy_block_print(struct drm_buddy_mm *mm,
 			   struct drm_buddy_block *block,
 			   struct drm_printer *p)
diff --git a/include/drm/drm_buddy.h b/include/drm/drm_buddy.h
index c64fd4062cb6..ebf03d151845 100644
--- a/include/drm/drm_buddy.h
+++ b/include/drm/drm_buddy.h
@@ -144,10 +144,6 @@ int drm_buddy_alloc(struct drm_buddy_mm *mm,
 		    struct list_head *blocks,
 		    unsigned long flags);
 
-int drm_buddy_alloc_range(struct drm_buddy_mm *mm,
-			   struct list_head *blocks,
-			   u64 start, u64 size);
-
 void drm_buddy_free(struct drm_buddy_mm *mm, struct drm_buddy_block *block);
 
 void drm_buddy_free_list(struct drm_buddy_mm *mm, struct list_head *objects);
-- 
2.25.1


WARNING: multiple messages have this Message-ID (diff)
From: Arunpravin <Arunpravin.PaneerSelvam@amd.com>
To: <dri-devel@lists.freedesktop.org>,
	<intel-gfx@lists.freedesktop.org>,
	<amd-gfx@lists.freedesktop.org>
Cc: <christian.koenig@amd.com>, <daniel@ffwll.ch>,
	<matthew.auld@intel.com>, <alexander.deucher@amd.com>,
	Arunpravin <Arunpravin.PaneerSelvam@amd.com>
Subject: [Intel-gfx] [PATCH 05/13] drm: remove drm_buddy_alloc_range
Date: Wed, 20 Oct 2021 04:24:01 +0530	[thread overview]
Message-ID: <20211019225409.569355-6-Arunpravin.PaneerSelvam@amd.com> (raw)
In-Reply-To: <20211019225409.569355-1-Arunpravin.PaneerSelvam@amd.com>

This function becomes obsolete and may be removed.

Signed-off-by: Arunpravin <Arunpravin.PaneerSelvam@amd.com>
---
 drivers/gpu/drm/drm_buddy.c | 101 ------------------------------------
 include/drm/drm_buddy.h     |   4 --
 2 files changed, 105 deletions(-)

diff --git a/drivers/gpu/drm/drm_buddy.c b/drivers/gpu/drm/drm_buddy.c
index f5f299dd9131..138e9f1a7340 100644
--- a/drivers/gpu/drm/drm_buddy.c
+++ b/drivers/gpu/drm/drm_buddy.c
@@ -457,107 +457,6 @@ int drm_buddy_alloc(struct drm_buddy_mm *mm,
 	return err;
 }
 
-/*
- * Allocate range. Note that it's safe to chain together multiple alloc_ranges
- * with the same blocks list.
- *
- * Intended for pre-allocating portions of the address space, for example to
- * reserve a block for the initial framebuffer or similar, hence the expectation
- * here is that drm_buddy_alloc() is still the main vehicle for
- * allocations, so if that's not the case then the drm_mm range allocator is
- * probably a much better fit, and so you should probably go use that instead.
- */
-int drm_buddy_alloc_range(struct drm_buddy_mm *mm,
-			  struct list_head *blocks,
-			  u64 start, u64 size)
-{
-	struct drm_buddy_block *block;
-	struct drm_buddy_block *buddy;
-	LIST_HEAD(allocated);
-	LIST_HEAD(dfs);
-	u64 end;
-	int err;
-	int i;
-
-	if (size < mm->chunk_size)
-		return -EINVAL;
-
-	if (!IS_ALIGNED(size | start, mm->chunk_size))
-		return -EINVAL;
-
-	if (range_overflows(start, size, mm->size))
-		return -EINVAL;
-
-	for (i = 0; i < mm->n_roots; ++i)
-		list_add_tail(&mm->roots[i]->tmp_link, &dfs);
-
-	end = start + size - 1;
-
-	do {
-		u64 block_start;
-		u64 block_end;
-
-		block = list_first_entry_or_null(&dfs,
-						 struct drm_buddy_block,
-						 tmp_link);
-		if (!block)
-			break;
-
-		list_del(&block->tmp_link);
-
-		block_start = drm_buddy_block_offset(block);
-		block_end = block_start + drm_buddy_block_size(mm, block) - 1;
-
-		if (!overlaps(start, end, block_start, block_end))
-			continue;
-
-		if (drm_buddy_block_is_allocated(block)) {
-			err = -ENOSPC;
-			goto err_free;
-		}
-
-		if (contains(start, end, block_start, block_end)) {
-			if (!drm_buddy_block_is_free(block)) {
-				err = -ENOSPC;
-				goto err_free;
-			}
-
-			mark_allocated(block);
-			mm->avail -= drm_buddy_block_size(mm, block);
-			list_add_tail(&block->link, &allocated);
-			continue;
-		}
-
-		if (!drm_buddy_block_is_split(block)) {
-			err = split_block(mm, block);
-			if (unlikely(err))
-				goto err_undo;
-		}
-
-		list_add(&block->right->tmp_link, &dfs);
-		list_add(&block->left->tmp_link, &dfs);
-	} while (1);
-
-	list_splice_tail(&allocated, blocks);
-	return 0;
-
-err_undo:
-	/*
-	 * We really don't want to leave around a bunch of split blocks, since
-	 * bigger is better, so make sure we merge everything back before we
-	 * free the allocated blocks.
-	 */
-	buddy = get_buddy(block);
-	if (buddy &&
-	    (drm_buddy_block_is_free(block) &&
-	     drm_buddy_block_is_free(buddy)))
-		__drm_buddy_free(mm, block);
-
-err_free:
-	drm_buddy_free_list(mm, &allocated);
-	return err;
-}
-
 void drm_buddy_block_print(struct drm_buddy_mm *mm,
 			   struct drm_buddy_block *block,
 			   struct drm_printer *p)
diff --git a/include/drm/drm_buddy.h b/include/drm/drm_buddy.h
index c64fd4062cb6..ebf03d151845 100644
--- a/include/drm/drm_buddy.h
+++ b/include/drm/drm_buddy.h
@@ -144,10 +144,6 @@ int drm_buddy_alloc(struct drm_buddy_mm *mm,
 		    struct list_head *blocks,
 		    unsigned long flags);
 
-int drm_buddy_alloc_range(struct drm_buddy_mm *mm,
-			   struct list_head *blocks,
-			   u64 start, u64 size);
-
 void drm_buddy_free(struct drm_buddy_mm *mm, struct drm_buddy_block *block);
 
 void drm_buddy_free_list(struct drm_buddy_mm *mm, struct list_head *objects);
-- 
2.25.1


  parent reply	other threads:[~2021-10-19 22:55 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-19 22:53 [PATCH 00/13] drm: Enable buddy allocator support Arunpravin
2021-10-19 22:53 ` [Intel-gfx] " Arunpravin
2021-10-19 22:53 ` [PATCH 01/13] drm: Move and rename i915 buddy header Arunpravin
2021-10-19 22:53   ` [Intel-gfx] " Arunpravin
2021-10-19 22:53 ` [PATCH 02/13] drm: Move and rename i915 buddy source Arunpravin
2021-10-19 22:53   ` [Intel-gfx] " Arunpravin
2021-10-20  8:38   ` Jani Nikula
2021-10-20  8:38     ` [Intel-gfx] " Jani Nikula
2021-10-19 22:53 ` [PATCH 03/13] drm: add Makefile support for drm buddy Arunpravin
2021-10-19 22:53   ` [Intel-gfx] " Arunpravin
2021-10-20  8:21   ` Thomas Zimmermann
2021-10-20  8:21     ` [Intel-gfx] " Thomas Zimmermann
2021-10-22 21:22     ` Arunpravin
2021-10-22 21:22       ` [Intel-gfx] " Arunpravin
2021-10-19 22:54 ` [PATCH 04/13] drm: make drm_buddy_alloc a commonplace Arunpravin
2021-10-19 22:54   ` [Intel-gfx] " Arunpravin
2021-10-19 22:54 ` Arunpravin [this message]
2021-10-19 22:54   ` [Intel-gfx] [PATCH 05/13] drm: remove drm_buddy_alloc_range Arunpravin
2021-10-19 22:54 ` [PATCH 06/13] drm: implement top-down allocation method Arunpravin
2021-10-19 22:54   ` [Intel-gfx] " Arunpravin
2021-10-19 22:54 ` [PATCH 07/13] drm: Implement method to free unused pages Arunpravin
2021-10-19 22:54   ` [Intel-gfx] " Arunpravin
2021-10-19 22:54 ` [PATCH 08/13] drm: export functions and write description Arunpravin
2021-10-19 22:54   ` [Intel-gfx] " Arunpravin
2021-10-19 22:54 ` [PATCH 09/13] drm: remove i915 selftest config check Arunpravin
2021-10-19 22:54   ` [Intel-gfx] " Arunpravin
2021-10-19 22:54 ` [PATCH 10/13] drm/i915: cleanup i915 buddy and apply DRM buddy Arunpravin
2021-10-19 22:54   ` [Intel-gfx] " Arunpravin
2021-10-19 22:54 ` [PATCH 11/13] drm/amdgpu: move vram defines into a header Arunpravin
2021-10-19 22:54   ` [Intel-gfx] " Arunpravin
2021-10-19 22:54 ` [PATCH 12/13] drm/amdgpu: add cursor support for drm buddy Arunpravin
2021-10-19 22:54   ` [Intel-gfx] " Arunpravin
2021-10-19 22:54 ` [PATCH 13/13] drm/amdgpu: cleanup drm_mm and apply DRM buddy Arunpravin
2021-10-19 22:54   ` [Intel-gfx] " Arunpravin
2021-10-20  7:51 ` [PATCH 00/13] drm: Enable buddy allocator support Christian König
2021-10-20  7:51   ` [Intel-gfx] " Christian König
2021-10-20 13:22 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for " 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=20211019225409.569355-6-Arunpravin.PaneerSelvam@amd.com \
    --to=arunpravin.paneerselvam@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=matthew.auld@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.