From: Xin Wang <x.wang@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Xin Wang <x.wang@intel.com>, Matt Roper <matthew.d.roper@intel.com>
Subject: [PATCH v10 2/5] include/linux_scaffold: add FIELD_GET() bitfield helper
Date: Wed, 31 Dec 2025 20:20:07 +0000 [thread overview]
Message-ID: <20251231202010.115619-3-x.wang@intel.com> (raw)
In-Reply-To: <20251231202010.115619-1-x.wang@intel.com>
Add __bf_shf() and FIELD_GET() so code can extract bitfields from
registers using a mask, matching the common Linux FIELD_GET()
semantics without pulling in kernel headers.
V2: (Matt Roper)
- use the libc ffsll() helper instead of __builtin_ffsll()
CC: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Xin Wang <x.wang@intel.com>
---
include/linux_scaffold.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/include/linux_scaffold.h b/include/linux_scaffold.h
index f6620ad0a..281aa5e73 100644
--- a/include/linux_scaffold.h
+++ b/include/linux_scaffold.h
@@ -4,6 +4,7 @@
#define _INTEL_GPU_COMMANDS_SCAFFOLD_H_
#include <stdint.h>
+#include <strings.h>
typedef uint8_t u8;
typedef uint16_t u16;
@@ -51,4 +52,9 @@ static inline s64 sign_extend64(u64 value, int index)
#define BITS_PER_LONG BITS_PER_TYPE(long)
#define BITS_PER_LONG_LONG BITS_PER_TYPE(long long)
+#define __bf_shf(x) (ffsll(x) - 1)
+
+#define FIELD_GET(mask, reg) \
+ (typeof(mask))(((reg) & (mask)) >> __bf_shf(mask))
+
#endif /* _INTEL_GPU_COMMANDS_SCAFFOLD_H_ */
--
2.43.0
next prev parent reply other threads:[~2025-12-31 20:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-31 20:20 [PATCH v10 0/5] tests/intel/xe_pat: add helper funtion to read PAT table Xin Wang
2025-12-31 20:20 ` [PATCH v10 1/5] lib/intel_pat: add pat_sw_config debugfs parser Xin Wang
2025-12-31 20:20 ` Xin Wang [this message]
2025-12-31 21:31 ` [PATCH v10 2/5] include/linux_scaffold: add FIELD_GET() bitfield helper Matt Roper
2025-12-31 20:20 ` [PATCH v10 3/5] tests/xe_pat: add pat-sanity subtest for debugfs vs getters Xin Wang
2025-12-31 21:35 ` Matt Roper
2025-12-31 20:20 ` [PATCH v10 4/5] tests/xe_pat: use debugfs reserved flags Xin Wang
2025-12-31 20:20 ` [PATCH v10 5/5] intel-ci: add xe_pat pat-sanity Xin Wang
2025-12-31 21:28 ` ✓ Xe.CI.BAT: success for tests/intel/xe_pat: add helper funtion to read PAT table Patchwork
2025-12-31 21:51 ` ✓ i915.CI.BAT: " Patchwork
2025-12-31 22:25 ` ✓ Xe.CI.Full: " Patchwork
2025-12-31 23:55 ` ✗ i915.CI.Full: failure " 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=20251231202010.115619-3-x.wang@intel.com \
--to=x.wang@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=matthew.d.roper@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox