From: Gustavo Sousa <gustavo.sousa@intel.com>
To: Peter Senna Tschudin <peter.senna@linux.intel.com>,
<igt-dev@lists.freedesktop.org>
Cc: Peter Senna Tschudin <peter.senna@linux.intel.com>,
<lucas.demarchi@intel.com>
Subject: Re: [PATCH i-g-t 1/2] igt_core: igt_hook_get_pointer() for external hooks
Date: Fri, 11 Jul 2025 10:04:55 -0300 [thread overview]
Message-ID: <175223909559.2061.10833444579370175525@intel.com> (raw)
In-Reply-To: <20250703150304.101208-2-peter.senna@linux.intel.com>
Quoting Peter Senna Tschudin (2025-07-03 12:03:03-03:00)
>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.
>
>Cc: Gustavo Sousa <gustavo.sousa@linux.intel.com>
>Cc: Lucas de Marchi <lucas.demarchi@linux.intel.com>
>Signed-off-by: Peter Senna Tschudin <peter.senna@linux.intel.com>
>---
> lib/igt_core.c | 12 ++++++++++++
> lib/igt_core.h | 9 +++++++++
> 2 files changed, 21 insertions(+)
>
>diff --git a/lib/igt_core.c b/lib/igt_core.c
>index c2674a272..f7a1ee36c 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_hook_get_pointer: 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_hook_get_pointer(void)
>+{
>+ return igt_hook;
>+}
Perhaps the name of the function should be changed?
I would expect functions starting with "igt_hook_" to belong to the
igt_hook library, but this one is specific to the pointer that is
initialized by core.
What about igt_core_get_igt_hook()?
Not sure I like we repeating "igt" in this one, but I think
igt_core_get_hook() is not very good either. So, between the two, I
prefer igt_core_get_igt_hook(), which is more precise.
>diff --git a/lib/igt_core.h b/lib/igt_core.h
>index 2db579423..2e65c89dd 100644
>--- a/lib/igt_core.h
>+++ b/lib/igt_core.h
>@@ -1601,4 +1601,13 @@ 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);
>+
>+/**
>+ * igt_hook_get_pointer: 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.
>+ */
We can drop this duplicated documentation.
--
Gustavo Sousa
>+struct igt_hook *igt_hook_get_pointer(void);
> #endif /* IGT_CORE_H */
>--
>2.43.0
>
next prev parent reply other threads:[~2025-07-11 13:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-03 15:03 [PATCH i-g-t 0/2] Add post-gpukmod-unbind igt_hook Peter Senna Tschudin
2025-07-03 15:03 ` [PATCH i-g-t 1/2] igt_core: igt_hook_get_pointer() for external hooks Peter Senna Tschudin
2025-07-03 19:25 ` Peter Senna Tschudin
2025-07-11 13:04 ` Gustavo Sousa [this message]
2025-07-03 15:03 ` [PATCH i-g-t 2/2] lib/igt_kmod: Add IGT_HOOK_POST_GPUKMOD_UNBIND Peter Senna Tschudin
2025-07-03 19:26 ` Peter Senna Tschudin
2025-07-11 13:20 ` Gustavo Sousa
2025-07-03 19:25 ` [PATCH i-g-t 0/2] Add post-gpukmod-unbind igt_hook Peter Senna Tschudin
2025-07-03 21:10 ` ✓ Xe.CI.BAT: success for " Patchwork
2025-07-03 21:12 ` ✓ i915.CI.BAT: " Patchwork
2025-07-04 3:41 ` ✗ i915.CI.Full: failure " Patchwork
2025-07-05 13:33 ` ✗ Xe.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=175223909559.2061.10833444579370175525@intel.com \
--to=gustavo.sousa@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=lucas.demarchi@intel.com \
--cc=peter.senna@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 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.