From: Nirmoy Das <nirmoy.aiemd@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: nirmoy.aiemd@gmail.com, Nirmoy Das <nirmoy.das@amd.com>,
christian.koenig@amd.com, chris@chris-wilson.co.uk
Subject: [PATCH 1/2] drm/mm: expand rb_hole_addr augmented callbacks
Date: Tue, 19 May 2020 10:44:35 +0200 [thread overview]
Message-ID: <20200519084436.91718-1-nirmoy.das@amd.com> (raw)
Expand RB_DECLARE_CALLBACKS_MAX so that it is possible to store
extra value(max hole alignment) in the rb_hole_addr augmented rbtree.
Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
---
drivers/gpu/drm/drm_mm.c | 72 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 69 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
index f4ca1ff80af9..91e90c635e05 100644
--- a/drivers/gpu/drm/drm_mm.c
+++ b/drivers/gpu/drm/drm_mm.c
@@ -241,9 +241,74 @@ static void insert_hole_size(struct rb_root_cached *root,
rb_insert_color_cached(&node->rb_hole_size, root, first);
}
-RB_DECLARE_CALLBACKS_MAX(static, augment_callbacks,
- struct drm_mm_node, rb_hole_addr,
- u64, subtree_max_hole, HOLE_SIZE)
+static inline bool
+augment_callbacks_compute_max_hole(struct drm_mm_node *node, bool exit)
+{
+ struct drm_mm_node *child;
+ u64 max = HOLE_SIZE(node);
+
+ if (node->rb_hole_addr.rb_left) {
+ child = rb_entry(node->rb_hole_addr.rb_left, struct drm_mm_node,
+ rb_hole_addr);
+ if (child->subtree_max_hole > max)
+ max = child->subtree_max_hole;
+ }
+
+ if (node->rb_hole_addr.rb_right) {
+ child = rb_entry(node->rb_hole_addr.rb_right,
+ struct drm_mm_node, rb_hole_addr);
+ if (child->subtree_max_hole > max)
+ max = child->subtree_max_hole;
+ }
+
+ if (exit && node->subtree_max_hole == max)
+ return true;
+
+ node->subtree_max_hole = max;
+ return false;
+}
+
+static inline void
+augment_callbacks_propagate(struct rb_node *rb, struct rb_node *stop)
+{
+ while (rb != stop) {
+ struct drm_mm_node *node = rb_entry(rb, struct drm_mm_node,
+ rb_hole_addr);
+ if (augment_callbacks_compute_max_hole(node, true))
+ break;
+
+ rb = rb_parent(&node->rb_hole_addr);
+ }
+}
+
+static inline void
+augment_callbacks_copy(struct rb_node *rb_old, struct rb_node *rb_new)
+{
+ struct drm_mm_node *old = rb_entry(rb_old, struct drm_mm_node,
+ rb_hole_addr);
+ struct drm_mm_node *new = rb_entry(rb_new, struct drm_mm_node,
+ rb_hole_addr);
+
+ new->subtree_max_hole = old->subtree_max_hole;
+}
+
+static void
+augment_callbacks_rotate(struct rb_node *rb_old, struct rb_node *rb_new)
+{
+ struct drm_mm_node *old = rb_entry(rb_old, struct drm_mm_node,
+ rb_hole_addr);
+ struct drm_mm_node *new = rb_entry(rb_new, struct drm_mm_node,
+ rb_hole_addr);
+
+ new->subtree_max_hole = old->subtree_max_hole;
+ augment_callbacks_compute_max_hole(old, false);
+}
+
+static const struct rb_augment_callbacks augment_callbacks = {
+ .propagate = augment_callbacks_propagate,
+ .copy = augment_callbacks_copy,
+ .rotate = augment_callbacks_rotate
+};
static void insert_hole_addr(struct rb_root *root, struct drm_mm_node *node)
{
@@ -256,6 +321,7 @@ static void insert_hole_addr(struct rb_root *root, struct drm_mm_node *node)
parent = rb_entry(rb_parent, struct drm_mm_node, rb_hole_addr);
if (parent->subtree_max_hole < subtree_max_hole)
parent->subtree_max_hole = subtree_max_hole;
+
if (start < HOLE_ADDR(parent))
link = &parent->rb_hole_addr.rb_left;
else
--
2.26.2
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next reply other threads:[~2020-05-20 7:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-19 8:44 Nirmoy Das [this message]
2020-05-19 8:44 ` [PATCH 2/2] drm/mm: improve rb_hole_addr rbtree search Nirmoy Das
2020-05-19 21:55 ` Chris Wilson
2020-05-19 22:56 ` Chris Wilson
2020-05-20 16:28 ` Nirmoy
2020-05-20 16:35 ` Chris Wilson
2020-05-20 16:46 ` Nirmoy
2020-05-19 22:40 ` [PATCH 1/2] drm/mm: expand rb_hole_addr augmented callbacks Chris Wilson
2020-05-20 7:00 ` 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=20200519084436.91718-1-nirmoy.das@amd.com \
--to=nirmoy.aiemd@gmail.com \
--cc=chris@chris-wilson.co.uk \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=nirmoy.das@amd.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.