igt-dev.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Andrzej Hajda <andrzej.hajda@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: "Kamil Konieczny" <kamil.konieczny@linux.intel.com>,
	"Priyanka Dandamudi" <priyanka.dandamudi@intel.com>,
	"Gwan-gyeong Mun" <gwan-gyeong.mun@intel.com>,
	"Piotr Piórkowski" <piotr.piorkowski@intel.com>,
	"Christoph Manszewski" <christoph.manszewski@intel.com>,
	"Andrzej Hajda" <andrzej.hajda@intel.com>
Subject: [PATCH v4 1/6] lib/xe_query: add helper to get first value of hwconfig
Date: Thu, 20 Nov 2025 15:25:38 +0100	[thread overview]
Message-ID: <20251120-xe_query_helpers-v4-1-2ed6dc04dd94@intel.com> (raw)
In-Reply-To: <20251120-xe_query_helpers-v4-0-2ed6dc04dd94@intel.com>

Most hwconfig attributes are single values. Let's simplify querying them.

Signed-off-by: Andrzej Hajda <andrzej.hajda@intel.com>
Reviewed-by: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
---
 lib/xe/xe_query.c | 17 +++++++++++++++++
 lib/xe/xe_query.h |  1 +
 2 files changed, 18 insertions(+)

diff --git a/lib/xe/xe_query.c b/lib/xe/xe_query.c
index 8e3e05fd3a7cf949a0bc0f64f06853e96be8c78e..a3fab133e6c4d9f949564b47cc817383bee7a568 100644
--- a/lib/xe/xe_query.c
+++ b/lib/xe/xe_query.c
@@ -1080,6 +1080,23 @@ uint32_t *xe_hwconfig_lookup_value(int fd, enum intel_hwconfig attribute, uint32
 	return NULL;
 }
 
+/**
+ * xe_hwconfig_get_u32:
+ * @fd: xe device fd
+ * @attribute: hwconfig attribute id
+ * @default_value: value to be returned in case attribute is not present
+ *
+ * Returns attribute value, if present, @default_value otherwise.
+ */
+uint32_t xe_hwconfig_get_u32(int fd, enum intel_hwconfig attribute, uint32_t default_value)
+{
+	uint32_t *vals, len;
+
+	vals = xe_hwconfig_lookup_value(fd, attribute, &len);
+
+	return (vals && len > 0) ? *vals : default_value;
+}
+
 /**
  * xe_query_pxp_status:
  * @fd: xe device fd
diff --git a/lib/xe/xe_query.h b/lib/xe/xe_query.h
index bcdfb54b027540b442da95d3c6a3cfd0f8b08dca..4f1c0687133c03b81ba53f95457c55860e5ce194 100644
--- a/lib/xe/xe_query.h
+++ b/lib/xe/xe_query.h
@@ -142,6 +142,7 @@ bool xe_is_main_gt(int fd, int gt);
 uint16_t xe_gt_get_tile_id(int fd, int gt);
 uint16_t xe_tile_get_main_gt_id(int fd, uint8_t tile);
 uint32_t *xe_hwconfig_lookup_value(int fd, enum intel_hwconfig attribute, uint32_t *len);
+uint32_t xe_hwconfig_get_u32(int fd, enum intel_hwconfig attribute, uint32_t default_value);
 int xe_query_pxp_status(int fd);
 int xe_wait_for_pxp_init(int fd);
 

-- 
2.43.0


  reply	other threads:[~2025-11-20 14:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-20 14:25 [PATCH v4 0/6] lib/xe/xe_query: implement few query helpers Andrzej Hajda
2025-11-20 14:25 ` Andrzej Hajda [this message]
2025-11-20 14:25 ` [PATCH v4 2/6] tests/intel/xe_eudebug_online: use helper to get hwconfig value Andrzej Hajda
2025-11-20 14:25 ` [PATCH v4 3/6] lib/xe/xe_query: introduce helpers for device query Andrzej Hajda
2025-11-20 14:25 ` [PATCH v4 4/6] lib/xe/xe_query: use recently introduced helper to query device Andrzej Hajda
2025-11-20 14:25 ` [PATCH v4 5/6] lib/xe/xe_query: introduce iterator for GT topology masks Andrzej Hajda
2025-11-20 14:25 ` [PATCH v4 6/6] xe/treewide: use xe_query helpers for query GT topology Andrzej Hajda
2025-11-20 15:44 ` ✗ Fi.CI.BUILD: failure for lib/xe/xe_query: implement few query helpers (rev4) 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=20251120-xe_query_helpers-v4-1-2ed6dc04dd94@intel.com \
    --to=andrzej.hajda@intel.com \
    --cc=christoph.manszewski@intel.com \
    --cc=gwan-gyeong.mun@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=piotr.piorkowski@intel.com \
    --cc=priyanka.dandamudi@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;
as well as URLs for NNTP newsgroup(s).