From: Matthew Brost <matthew.brost@intel.com>
To: <intel-xe@lists.freedesktop.org>
Cc: Danilo Krummrich <dakr@redhat.com>
Subject: [Intel-xe] [PATCH v4 4/9] maple_tree: split up MA_STATE() macro
Date: Fri, 30 Jun 2023 10:57:59 -0700 [thread overview]
Message-ID: <20230630175804.1096370-5-matthew.brost@intel.com> (raw)
In-Reply-To: <20230630175804.1096370-1-matthew.brost@intel.com>
From: Danilo Krummrich <dakr@redhat.com>
Split up the MA_STATE() macro such that components using the maple tree
can easily inherit from struct ma_state and build custom tree walk
macros to hide their internals from users.
Example:
struct sample_iterator {
struct ma_state mas;
struct sample_mgr *mgr;
};
\#define SAMPLE_ITERATOR(name, __mgr, start) \
struct sample_iterator name = { \
.mas = MA_STATE_INIT(&(__mgr)->mt, start, 0), \
.mgr = __mgr, \
}
\#define sample_iter_for_each_range(it__, entry__, end__) \
mas_for_each(&(it__).mas, entry__, end__)
--
struct sample *sample;
SAMPLE_ITERATOR(si, min);
sample_iter_for_each_range(&si, sample, max) {
frob(mgr, sample);
}
Signed-off-by: Danilo Krummrich <dakr@redhat.com>
---
include/linux/maple_tree.h | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/include/linux/maple_tree.h b/include/linux/maple_tree.h
index 1fadb5f5978b..87d55334f1c2 100644
--- a/include/linux/maple_tree.h
+++ b/include/linux/maple_tree.h
@@ -423,8 +423,8 @@ struct ma_wr_state {
#define MA_ERROR(err) \
((struct maple_enode *)(((unsigned long)err << 2) | 2UL))
-#define MA_STATE(name, mt, first, end) \
- struct ma_state name = { \
+#define MA_STATE_INIT(mt, first, end) \
+ { \
.tree = mt, \
.index = first, \
.last = end, \
@@ -435,6 +435,9 @@ struct ma_wr_state {
.mas_flags = 0, \
}
+#define MA_STATE(name, mt, first, end) \
+ struct ma_state name = MA_STATE_INIT(mt, first, end)
+
#define MA_WR_STATE(name, ma_state, wr_entry) \
struct ma_wr_state name = { \
.mas = ma_state, \
--
2.34.1
next prev parent reply other threads:[~2023-06-30 17:58 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-30 17:57 [Intel-xe] [PATCH v4 0/9] GPUVA with no uAPI changes Matthew Brost
2023-06-30 17:57 ` [Intel-xe] [PATCH v4 1/9] drm/xe: Ban a VM if rebind worker hits an error Matthew Brost
2023-07-06 10:31 ` Thomas Hellström
2023-07-06 15:01 ` Matthew Brost
2023-07-06 17:49 ` Thomas Hellström
2023-07-11 13:40 ` Maarten Lankhorst
2023-06-30 17:57 ` [Intel-xe] [PATCH v4 2/9] drm/xe: Add helpers to hide struct xe_vma internals Matthew Brost
2023-07-06 13:22 ` Thomas Hellström
2023-07-06 15:06 ` Matthew Brost
2023-06-30 17:57 ` [Intel-xe] [PATCH v4 3/9] maple_tree: Export mas_preallocate Matthew Brost
2023-07-06 17:51 ` Thomas Hellström
2023-07-07 5:45 ` Matthew Brost
2023-06-30 17:57 ` Matthew Brost [this message]
2023-06-30 17:58 ` [Intel-xe] [PATCH v4 5/9] drm: manager to keep track of GPUs VA mappings Matthew Brost
2023-06-30 17:58 ` [Intel-xe] [PATCH v4 6/9] drm: debugfs: provide infrastructure to dump a DRM GPU VA space Matthew Brost
2023-06-30 17:58 ` [Intel-xe] [PATCH v4 7/9] drm/xe: Remove __xe_vm_bind forward declaration Matthew Brost
2023-07-06 17:54 ` Thomas Hellström
2023-06-30 17:58 ` [Intel-xe] [PATCH v4 8/9] drm/xe: Port Xe to GPUVA Matthew Brost
2023-07-07 15:38 ` Thomas Hellström
2023-06-30 17:58 ` [Intel-xe] [PATCH v4 9/9] drm/xe: Avoid doing rebinds Matthew Brost
2023-06-30 18:35 ` [Intel-xe] ✓ CI.Patch_applied: success for GPUVA with no uAPI changes Patchwork
2023-06-30 18:35 ` [Intel-xe] ✗ CI.checkpatch: warning " Patchwork
2023-06-30 18:37 ` [Intel-xe] ✓ CI.KUnit: success " Patchwork
2023-06-30 18:41 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-06-30 18:41 ` [Intel-xe] ✓ CI.Hooks: " Patchwork
2023-06-30 18:42 ` [Intel-xe] ✗ CI.checksparse: warning " Patchwork
2023-06-30 19:27 ` [Intel-xe] ○ CI.BAT: info " 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=20230630175804.1096370-5-matthew.brost@intel.com \
--to=matthew.brost@intel.com \
--cc=dakr@redhat.com \
--cc=intel-xe@lists.freedesktop.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox