From: Soham Purkait <soham.purkait@intel.com>
To: igt-dev@lists.freedesktop.org, riana.tauro@intel.com,
badal.nilawar@intel.com, kamil.konieczny@intel.com,
vinay.belgaumkar@intel.com
Cc: anshuman.gupta@intel.com, soham.purkait@intel.com,
tvrtko.ursulin@igalia.com, tursulin@ursulin.net,
lucas.de.marchi@gmail.com
Subject: [PATCH i-g-t v10 2/5] tools/gputop.src/utils: Add clamp macro to remove dependency on lib/xe/*
Date: Mon, 6 Apr 2026 11:34:25 +0530 [thread overview]
Message-ID: <20260406060428.2734117-3-soham.purkait@intel.com> (raw)
In-Reply-To: <20260406060428.2734117-1-soham.purkait@intel.com>
Add clamp helper macro to utils.h to remove dependency on lib/xe/*
Signed-off-by: Soham Purkait <soham.purkait@intel.com>
Reviewed-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
---
tools/gputop.src/utils.h | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/tools/gputop.src/utils.h b/tools/gputop.src/utils.h
index 00befed56..981c23bb0 100644
--- a/tools/gputop.src/utils.h
+++ b/tools/gputop.src/utils.h
@@ -1,12 +1,11 @@
/* SPDX-License-Identifier: MIT */
/*
- * Copyright © 2025 Intel Corporation
+ * Copyright © 2025-2026 Intel Corporation
*/
#ifndef COMMON_GPUTOP_H
#define COMMON_GPUTOP_H
-#include <glib.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
@@ -19,6 +18,16 @@
#define PERCLIENT_ENGINE_WIDTH 8
+#ifndef clamp
+#define clamp(val, lo, hi) \
+({ \
+ __typeof__(val) _v = (val); \
+ __typeof__(lo) _lo = (lo); \
+ __typeof__(hi) _hi = (hi); \
+ _v < _lo ? _lo : (_v > _hi ? _hi : _v); \
+})
+#endif
+
/**
* struct gputop_driver
*
@@ -50,7 +59,7 @@ struct device_operations {
struct igt_device_card *card);
void *(*init_engines)(const void *obj, int index);
int (*pmu_init)(const void *obj, int index);
- void (*pmu_sample)(const void *obj, int index);
+ int (*pmu_sample)(const void *obj, int index);
int (*print_engines)(const void *obj, int index, int lines,
int w, int h);
void (*clean_up)(void *obj, int len);
--
2.34.1
next prev parent reply other threads:[~2026-04-06 6:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-06 6:04 [PATCH i-g-t v10 0/5] Close any open drm device after engine initialization in GPUTOP Soham Purkait
2026-04-06 6:04 ` [PATCH i-g-t v10 1/5] tools: Rename tools/gputop to tools/gputop.src Soham Purkait
2026-04-07 7:45 ` Jani Nikula
2026-04-08 5:50 ` Purkait, Soham
2026-04-06 6:04 ` Soham Purkait [this message]
2026-04-06 6:04 ` [PATCH i-g-t v10 3/5] tools/gputop.src/xe_gputop: Use direct ioctls with card_fd cleanup Soham Purkait
2026-04-06 6:04 ` [PATCH i-g-t v10 4/5] tools/gputop.src/gputop: Add support for per-engine busyness monitoring Soham Purkait
2026-04-06 9:04 ` Tvrtko Ursulin
2026-04-08 7:50 ` Purkait, Soham
2026-04-09 8:52 ` Tvrtko Ursulin
2026-04-13 8:35 ` Purkait, Soham
2026-04-06 6:04 ` [PATCH i-g-t v10 5/5] tools/gputop.src/gputop: Add command line option for device filter Soham Purkait
2026-04-06 8:25 ` ✓ Xe.CI.BAT: success for Close any open drm device after engine initialization in GPUTOP (rev11) Patchwork
2026-04-06 8:42 ` ✓ i915.CI.BAT: " Patchwork
2026-04-06 11:21 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-04-06 12:32 ` ✗ i915.CI.Full: " 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=20260406060428.2734117-3-soham.purkait@intel.com \
--to=soham.purkait@intel.com \
--cc=anshuman.gupta@intel.com \
--cc=badal.nilawar@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=kamil.konieczny@intel.com \
--cc=lucas.de.marchi@gmail.com \
--cc=riana.tauro@intel.com \
--cc=tursulin@ursulin.net \
--cc=tvrtko.ursulin@igalia.com \
--cc=vinay.belgaumkar@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.