Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Senna Tschudin <peter.senna@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Peter Senna Tschudin <peter.senna@linux.intel.com>,
	Gustavo Sousa <gustavo.sousa@intel.com>,
	Kamil Konieczny <kamil.konieczny@linux.intel.com>
Subject: [PATCH v4 i-g-t 1/3] lib/igt_core: Expose igt_hook pointer for other libs
Date: Wed, 23 Jul 2025 12:44:04 +0200	[thread overview]
Message-ID: <20250723104406.58784-2-peter.senna@linux.intel.com> (raw)
In-Reply-To: <20250723104406.58784-1-peter.senna@linux.intel.com>

Previously, all igt_hooks were defined, initialized, and freed within
lib/igt_core.c, limiting hook creation to this file. To enable other
libraries to add hooks, introduce a function that returns a pointer to
the main hook structure.

This change allows hooks to be created from external libraries without
requiring separate initialization or teardown of the hook
infrastructure.

Reviewed-by: Gustavo Sousa <gustavo.sousa@intel.com>
Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Signed-off-by: Peter Senna Tschudin <peter.senna@linux.intel.com>
---
v4:
 - changed subject

v3:
 - unchanged

v2:
 - change function name to igt_core_get_igt_hook()
 - remove duplicated documentation from header 

 lib/igt_core.c | 12 ++++++++++++
 lib/igt_core.h |  2 ++
 2 files changed, 14 insertions(+)

diff --git a/lib/igt_core.c b/lib/igt_core.c
index c2674a272..4bfffc3a8 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -3604,3 +3604,15 @@ unsigned int igt_measured_usleep(unsigned int usec)
 
 	return igt_nsec_elapsed(&ts) / NSEC_PER_USEC;
 }
+
+/**
+ * igt_core_get_igt_hook: To allow for using hooks from other libraries, this
+ * function returns the pointer to the struct that is likely already
+ * initialized.
+ *
+ * Returns: Pointer to the igt_hook structure.
+ */
+struct igt_hook *igt_core_get_igt_hook(void)
+{
+	return igt_hook;
+}
diff --git a/lib/igt_core.h b/lib/igt_core.h
index 2db579423..e658737b0 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -1601,4 +1601,6 @@ void igt_pci_system_cleanup(void);
 void igt_emit_ignore_dmesg_regex(const char *ignore_dmesg_regex);
 
 unsigned int igt_measured_usleep(unsigned int usec);
+
+struct igt_hook *igt_core_get_igt_hook(void);
 #endif /* IGT_CORE_H */
-- 
2.43.0


  reply	other threads:[~2025-07-23 10:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-23 10:44 [PATCH v4 i-g-t 0/3] Add post-kmod-unbind igt_hook Peter Senna Tschudin
2025-07-23 10:44 ` Peter Senna Tschudin [this message]
2025-07-23 10:44 ` [PATCH v4 i-g-t 2/3] lib/igt_kmod: Add IGT_HOOK_POST_KMOD_UNBIND Peter Senna Tschudin
2025-07-23 17:01   ` Kamil Konieczny
2025-07-25 10:13     ` Peter Senna Tschudin
2025-07-23 10:44 ` [PATCH v4 i-g-t 3/3] lib/tests: Update hook unit testing Peter Senna Tschudin
2025-07-23 16:58   ` Kamil Konieczny
2025-07-23 16:27 ` ✓ i915.CI.BAT: success for Add post-kmod-unbind igt_hook (rev2) Patchwork
2025-07-23 16:41 ` ✗ Xe.CI.BAT: failure " Patchwork
2025-07-25 10:15   ` Peter Senna Tschudin
2025-07-23 22:07 ` ✗ Xe.CI.Full: " Patchwork
2025-07-25 10:15   ` Peter Senna Tschudin
2025-07-24  6:53 ` ✓ i915.CI.Full: success " 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=20250723104406.58784-2-peter.senna@linux.intel.com \
    --to=peter.senna@linux.intel.com \
    --cc=gustavo.sousa@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kamil.konieczny@linux.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