Extend IGT to support Android
Subsystems (2)
v6 cover Extend IGT to support Android
The primary objective of this proposal is to extend the functionality of IGT to Android environments.
Enabling IGT on Android will allow developers to perform comprehensive testing of graphics drivers, ensuring robustness and reliability across different platforms.
By providing stub implementations for libraries that are not natively supported on Android, we will bridge the gap between Android and Linux environments, promoting code reuse and reducing development time.
Changes done:
- Create stub implementations of GLib, libunwind, libprocps, and other necessary libraries to satisfy IGT dependencies on Android.
- Replace glib hash table with igt hash implementation
Note:
- Incase of linux systems, system libraries will be used whereas for Android stubs will be used with reduced test coverage.
- Support will be provided to maintain Android support.
Jeevaka Prabu Badrappan (13):
lib: Include local igt procps, glib and unwind header for Android
tests: Include local igt_glib header for Android
runner: Include local igt_glib header for Android
tools: Include local igt_glib header for Android tools/gputop: find program name from command line lib/igt_dummyload: Avoid pthread_cancel use by overriding timer value lib/xe/xe_spin: Avoid pthread_cancel use by introducing an exit flag lib/igt_core: Implement conditional backtrace support using
HAVE_LIBUNWIND
lib/igt_core: Conditionally define __noreturn for non-Android
platforms
tools/intel_gpu_top: Replace index with strchr tests/intel/xe_create: Conditionally define PAGE_SIZE for non-Android
platforms
lib/igt_device_scan: Replace rindex with strrchr lib/igt_device_scan: reuse igt hash
Sapna (1):
Add stub for libunwind, procps and glib
include/android/glib.h | 49 +++++++++++++++++++++++ include/android/procps.h | 47 ++++++++++++++++++++++ include/android/unwind.h | 22 ++++++++++ lib/igt_aux.c | 4 ++ lib/igt_chamelium.c | 4 ++ lib/igt_core.c | 12 ++++++ lib/igt_core.h | 2 + lib/igt_device_scan.c | 82 +++++++++++++++++++------------------- lib/igt_dummyload.c | 9 +++++ lib/igt_rc.h | 4 ++ lib/intel_batchbuffer.c | 4 ++ lib/meson.build | 1 + lib/xe/xe_spin.c | 10 +++++ runner/executor.c | 4 ++ runner/settings.h | 4 ++ tests/intel/api_intel_bb.c | 4 ++ tests/intel/gem_ccs.c | 4 ++ tests/intel/xe_ccs.c | 4 ++ tests/intel/xe_create.c | 2 + tests/intel/xe_intel_bb.c | 4 ++ tests/testdisplay.h | 4 ++ tools/gputop.c | 13 ++++-- tools/igt_dp_compliance.h | 4 ++ tools/intel_gpu_top.c | 2 +- tools/intel_pm_rpm.c | 4 ++ tools/lsgpu.c | 4 ++ 26 files changed, 263 insertions(+), 44 deletions(-) create mode 100644 include/android/glib.h create mode 100644 include/android/procps.h create mode 100644 include/android/unwind.h
Signature · 1 line
2.49.0
PATCH v6 1/14 Add stub for libunwind, procps and glib
From: Sapna <[email protected]>
As libunwind, procps, glib are not available in Android, not able to build igt for Android.
Provided stub implementations so igt can be compiled for both Android and linux from same code base. Incase of linux systems, system libraries will be used whereas for Android stubs will be used with reduced test coverage.
--- include/android/glib.h | 49 ++++++++++++++++++++++++++++++++++++++++ include/android/procps.h | 47 ++++++++++++++++++++++++++++++++++++++ include/android/unwind.h | 22 ++++++++++++++++++ 3 files changed, 118 insertions(+) create mode 100644 include/android/glib.h create mode 100644 include/android/procps.h create mode 100644 include/android/unwind.h
include/android/glib.h new file +49 -0
@@ -0,0 +1,49 @@ +#ifndef _ANDROID_GLIB_H +#define _ANDROID_GLIB_H + +#include <stdbool.h> +#include <stdlib.h> +#define G_KEY_FILE_NONE 0 +#define G_REGEX_OPTIMIZE 0 + +typedef struct _GError { +int code; +char *message; +}GError ; + +typedef struct _GKeyFile { +char *key; +char *value; +}GKeyFile ; + +typedef int gint ; +typedef size_t gsize ; +typedef char gchar ; +typedef unsigned char guchar ; +typedef void GRegex ; + +static inline void g_clear_error (GError **error) { } +static inline void g_error_free (GError *error) { } +static inline const char *g_get_home_dir (void ) {return "/data/local/tmp/igt" ; } +static inline void g_key_file_free (GKeyFile *file) { } +static inline GKeyFile *g_key_file_new (void ) {return NULL ; } +static inline int g_key_file_get_integer (GKeyFile *key_file, +const char *group_name,const char *key,GError **error) {return 0 ; } +static inline char *g_key_file_get_string (GKeyFile *key_file, +const char *group_name,const char *key,GError **error) {return NULL ; } +static inline bool g_key_file_load_from_file (GKeyFile *key_file, +const char *file,int flags,GError **error) {return false; } +static inline GRegex *g_regex_new (const char *pattern,int compile_options, +int match_options,GError **error) {return NULL ; } +static inline void g_regex_unref (GRegex *pattern) { }; +static gchar *g_base64_encode (const guchar *data,gsize len) +{ +gchar *str = (gchar *)malloc (1 );/* Allocate memory for an empty string */ + +if (str) + str[0 ] ='\0' ;/* Set the string to be empty */ + +return str; +} + +#endif /* _ANDROID_GLIB_H */
include/android/procps.h new file +47 -0
47 lines not on this page · raw message
include/android/unwind.h new file +22 -0
@@ -0,0 +1,22 @@ +#ifndef _ANDROID_UNWIND_H +#define _ANDROID_UNWIND_H + +#define UNW_TDEP_CURSOR_LEN 127 + +typedef struct unw_cursor { +int opaque[UNW_TDEP_CURSOR_LEN ]; +}unw_cursor_t ; + + +typedef struct unw_context { +int ctx; +}unw_context_t ; + +typedef uint32_t unw_word_t ; + +int unw_getcontext (unw_context_t *uc) {return 0 ; } +int unw_init_local (unw_cursor_t *cur,unw_context_t *uc) {return 0 ; } +int unw_step (unw_cursor_t *cur) {return 0 ; } +int unw_get_proc_name (unw_cursor_t *cur,char *ch,size_t size,unw_word_t *word) {return 0 ; } + +#endif /* _ANDROID_UNWIND_H */
Signature · 1 line
2.49.0
PATCH v6 2/14 lib: Include local igt procps, glib and unwind header for Android
In reply to Jeevaka Prabu Badrappan--- lib/igt_aux.c | 4 ++++ lib/igt_chamelium.c | 4 ++++ lib/igt_core.c | 8 ++++++++ lib/igt_rc.h | 4 ++++ lib/intel_batchbuffer.c | 4 ++++ 5 files changed, 24 insertions(+)
lib/igt_aux.c +4 -0
@@ -53,11 +53,15 @@#include <assert.h> #include <grp.h> +#ifndef ANDROID #ifdef HAVE_LIBPROCPS # include <proc/readproc.h> #else # include <libproc2/pids.h> #endif +#else +#include "android/procps.h" +#endif #include <dirent.h> #ifdef __linux__
lib/igt_chamelium.c +4 -0
@@ -33,7 +33,11 @@#include <xmlrpc-c/base.h> #include <xmlrpc-c/client.h> #include <pthread.h> +#ifndef ANDROID #include <glib.h> +#else +#include "android/glib.h" +#endif #include <pixman.h> #include <cairo.h>
lib/igt_core.c +8 -0
@@ -55,7 +55,11 @@#include <limits.h> #include <locale.h> #include <uwildmat/uwildmat.h> +#ifndef ANDROID #include <glib.h> +#else +#include "android/glib.h" +#endif #include "drmtest.h" #include "i915/gem_create.h"
@@ -82,7 +86,11 @@#include "runnercomms.h" #define UNW_LOCAL_ONLY +#ifndef ANDROID #include <libunwind.h> +#else +#include "android/unwind.h" +#endif #include <elfutils/libdwfl.h> #ifdef HAVE_LIBGEN_H
lib/igt_rc.h +4 -0
@@ -25,7 +25,11 @@#ifndef IGT_RC_H #define IGT_RC_H +#ifndef ANDROID #include <glib.h> +#else +#include "android/glib.h" +#endif extern GKeyFile *igt_key_file;
lib/intel_batchbuffer.c +4 -0
@@ -26,7 +26,11 @@**************************************************************************/ #include <search.h> +#ifndef ANDROID #include <glib.h> +#else +#include "android/glib.h" +#endif #include "gpgpu_fill.h" #include "huc_copy.h"
Signature · 1 line
2.49.0
Re: [PATCH i-g-t v6 02/14] lib: Include local igt procps, glib and unwind header for Android
Hi Jeevaka,
On 2025-05-16 at 16:05:39 +0000, Jeevaka Prabu Badrappan wrote:
you need to add description to every patch.
From subject:
lib: Include local igt procps, glib and unwind header for Android it seems you do not need unwind here as this was worked-around in other patch with HAVE_LIBUNWIND. You could add it later if anyone will write a replacement.
Can we replace glib with other alternatives? As I understand it there are uses: hash and regex. Hash can be replaced with igt_map() and for regex why not using pcre lib? See
https://en.wikipedia.org/wiki/Perl_Compatible_Regular_Expressions
+cc Petri Latvala <[email protected]>
Regards,
Kamil
Quoted 109 lines
Signed-off-by Jeevaka Prabu Badrappan <[email protected]>--- lib/igt_aux.c | 4 ++++ lib/igt_chamelium.c | 4 ++++ lib/igt_core.c | 8 ++++++++ lib/igt_rc.h | 4 ++++ lib/intel_batchbuffer.c | 4 ++++ 5 files changed, 24 insertions(+)lib/igt_aux.c +4
-0@@ -53,11 +53,15 @@#include <assert.h> #include <grp.h> +#ifndef ANDROID #ifdef HAVE_LIBPROCPS # include <proc/readproc.h> #else # include <libproc2/pids.h> #endif +#else +#include "android/procps.h" +#endif #include <dirent.h> #ifdef __linux__lib/igt_chamelium.c +4
-0@@ -33,7 +33,11 @@#include <xmlrpc-c/base.h> #include <xmlrpc-c/client.h> #include <pthread.h> +#ifndef ANDROID #include <glib.h> +#else +#include "android/glib.h" +#endif #include <pixman.h> #include <cairo.h> lib/igt_core.c +8
-0@@ -55,7 +55,11 @@#include <limits.h> #include <locale.h> #include <uwildmat/uwildmat.h> +#ifndef ANDROID #include <glib.h> +#else +#include "android/glib.h" +#endif #include "drmtest.h" #include "i915/gem_create.h" @@ -82,7 +86,11 @@#include "runnercomms.h" #define UNW_LOCAL_ONLY +#ifndef ANDROID #include <libunwind.h> +#else +#include "android/unwind.h" +#endif #include <elfutils/libdwfl.h> #ifdef HAVE_LIBGEN_H lib/igt_rc.h +4
-0@@ -25,7 +25,11 @@#ifndef IGT_RC_H #define IGT_RC_H +#ifndef ANDROID #include <glib.h> +#else +#include "android/glib.h" +#endif extern GKeyFile *igt_key_file;lib/intel_batchbuffer.c +4
-0@@ -26,7 +26,11 @@**************************************************************************/ #include <search.h> +#ifndef ANDROID #include <glib.h> +#else +#include "android/glib.h" +#endif #include "gpgpu_fill.h" #include "huc_copy.h" Signature · 1 line
2.49.0
Re: [PATCH i-g-t v6 02/14] lib: Include local igt procps, glib and unwind header for Android
Hi Kamil,
Quoted 7 lines
you need to add description to every patch.
From subject:
lib: Include local igt procps, glib and unwind header for Android it seems you do not need unwind here as this was worked-around in other patch withHAVE_LIBUNWIND. You could add it later if anyone will write a replacement.
Got it.
Quoted 6 lines
Can we replace glib with other alternatives? As I understand it there are uses: hash and regex. Hash can be replaced with
igt_map()and for regex why not using pcre lib? See
https://en.wikipedia.org/wiki/Perl_Compatible_Regular_Expressions+cc Petri Latvala <[email protected]>
Can we take this up in new series?
Thanks and Regards,
Jeevaka
PATCH v6 3/14 tests: Include local igt_glib header for Android
In reply to Jeevaka Prabu Badrappan--- tests/intel/api_intel_bb.c | 4 ++++ tests/intel/gem_ccs.c | 4 ++++ tests/intel/xe_ccs.c | 4 ++++ tests/intel/xe_intel_bb.c | 4 ++++ tests/testdisplay.h | 4 ++++ 5 files changed, 20 insertions(+)
tests/intel/api_intel_bb.c +4 -0
@@ -35,7 +35,11 @@#include <errno.h> #include <sys/stat.h> #include <sys/ioctl.h> +#ifdef ANDROID +#include "android/glib.h" +#else #include <glib.h> +#endif #include <zlib.h> #include "intel_bufops.h" #include "i915/gem_vm.h"
tests/intel/gem_ccs.c +4 -0
@@ -4,7 +4,11 @@*/ #include <errno.h> +#ifdef ANDROID +#include "android/glib.h" +#else #include <glib.h> +#endif #include <sys/ioctl.h> #include <sys/time.h> #include <malloc.h>
tests/intel/xe_ccs.c +4 -0
@@ -4,7 +4,11 @@*/ #include <errno.h> +#ifdef ANDROID +#include "android/glib.h" +#else #include <glib.h> +#endif #include <sys/ioctl.h> #include <sys/time.h> #include <malloc.h>
tests/intel/xe_intel_bb.c +4 -0
@@ -6,7 +6,11 @@#include <cairo.h> #include <errno.h> #include <fcntl.h> +#ifdef ANDROID +#include "android/glib.h" +#else #include <glib.h> +#endif #include <inttypes.h> #include <stdio.h> #include <stdlib.h>
tests/testdisplay.h +4 -0
@@ -24,7 +24,11 @@#include <stdio.h> #include <string.h> #include <stdlib.h> +#ifdef ANDROID +#include "android/glib.h" +#else #include <glib.h> +#endif extern int drm_fd;
Signature · 1 line
2.49.0
PATCH v6 4/14 runner: Include local igt_glib header for Android
In reply to Jeevaka Prabu Badrappan--- runner/executor.c | 4 ++++ runner/settings.h | 4 ++++ 2 files changed, 8 insertions(+)
runner/executor.c +4 -0
@@ -1,7 +1,11 @@#include <ctype.h> #include <errno.h> #include <fcntl.h> +#ifdef ANDROID +#include "android/glib.h" +#else #include <glib.h> +#endif #ifdef __linux__#include <linux/watchdog.h> #endif
runner/settings.h +4 -0
@@ -5,7 +5,11 @@#include <stddef.h> #include <sys/types.h> #include <stdio.h> +#ifdef ANDROID +#include "android/glib.h" +#else #include <glib.h> +#endif #include "igt_list.h" #include "igt_vec.h"
Signature · 1 line
2.49.0
PATCH v6 5/14 tools: Include local igt_glib header for Android
In reply to Jeevaka Prabu Badrappan--- tools/igt_dp_compliance.h | 4 ++++ tools/intel_pm_rpm.c | 4 ++++ tools/lsgpu.c | 4 ++++ 3 files changed, 12 insertions(+)
tools/igt_dp_compliance.h +4 -0
@@ -28,7 +28,11 @@#include <stdio.h> #include <string.h> #include <stdlib.h> +#ifdef ANDROID +#include "android/glib.h" +#else #include <glib.h> +#endif extern int drm_fd;
tools/intel_pm_rpm.c +4 -0
@@ -24,7 +24,11 @@#include <errno.h> #include <getopt.h> +#ifdef ANDROID +#include "android/glib.h" +#else #include <glib.h> +#endif #include <stdio.h> #include <stdlib.h> #include <string.h>
tools/lsgpu.c +4 -0
@@ -24,7 +24,11 @@#include <errno.h> #include <fcntl.h> +#ifdef ANDROID +#include "android/glib.h" +#else #include <glib.h> +#endif #include <libudev.h> #include <string.h> #include <signal.h>
Signature · 1 line
2.49.0
PATCH v6 6/14 tools/gputop: find program name from command line
In reply to Jeevaka Prabu Badrappanprogram_invocation_short_name is global variable provided by glibc.
Inorder to get the igt built for Android(without glibc), find the program from command line without using program_invocation_short_name.
--- tools/gputop.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
tools/gputop.c +10 -3
@@ -335,15 +335,22 @@ struct gputop_args {unsigned long delay_usec; }; -static void help (void ) +static void help (char *full_path) { +const char *short_program_name =strrchr (full_path,'/' ); + +if (short_program_name) + short_program_name++; +else + short_program_name = full_path; +printf ("Usage:\n" "\t%s [options]\n\n" "Options:\n" "\t-h, --help show this help\n" "\t-d, --delay =SEC[.TENTHS] iterative delay as SECS [.TENTHS]\n" "\t-n, --iterations =NUMBER number of executions\n" - , program_invocation_short_name); + , short_program_name); }static int parse_args (int argc,char *const argv[],struct gputop_args *args)
@@ -384,7 +391,7 @@ static int parse_args(int argc, char * const argv[], struct gputop_args *args) }break ;case 'h' : -help (); +help (argv[0 ]);return 0 ;default :fprintf (stderr,"Unkonwn option '%c'.\n" , c);
Signature · 1 line
2.49.0
PATCH v6 7/14 lib/igt_dummyload: Avoid pthread_cancel use by overriding timer value
In reply to Jeevaka Prabu BadrappanAndroid build fails due to pthread_cancel unavailability. Replace pthread_cancel by overriding the expiration time of the timer.
--- lib/igt_dummyload.c | 9 +++++++++ 1 file changed, 9 insertions(+)
lib/igt_dummyload.c +9 -0
@@ -631,7 +631,16 @@ void igt_spin_end(igt_spin_t *spin)static void __igt_spin_free (int fd,igt_spin_t *spin) {if (spin->timerfd >=0 ) { +#ifdef ANDROID +struct itimerspec its; + +memset (&its,0 ,sizeof (its)); + its.it_value.tv_sec =0 ; + its.it_value.tv_nsec =1 ; +timerfd_settime (spin->timerfd,0 , &its,NULL ); +#else pthread_cancel (spin->timer_thread); +#endif igt_assert (pthread_join (spin->timer_thread,NULL ) ==0 );close (spin->timerfd); }
Signature · 1 line
2.49.0
Re: [PATCH i-g-t v6 07/14] lib/igt_dummyload: Avoid pthread_cancel use by overriding timer value
Quoted 14 lines · Jeevaka Prabu Badrappan
Android build fails due to
pthread_cancelunavailability. Replacepthread_cancelby overriding the expiration time of the timer.Signed-off-by Jeevaka Prabu Badrappan <[email protected]>--- lib/igt_dummyload.c | 9 +++++++++ 1 file changed, 9 insertions(+)lib/igt_dummyload.c +0
-0@@ -631,7 +631,16 @@ void igt_spin_end(igt_spin_t *spin)static void __igt_spin_free (int fd,igt_spin_t *spin)
lib/igt_dummyload.c void igt_spin_end(igt_spin_t *spin) · line 641
Quoted 10 lines
lib/igt_dummyload.c +8
-0{if (spin->timerfd >=0 ) { +#ifdef ANDROID +struct itimerspec its; + +memset (&its,0 ,sizeof (its)); + its.it_value.tv_sec =0 ; + its.it_value.tv_nsec =1 ; +timerfd_settime (spin->timerfd,0 , &its,NULL ); +#else
Looks good to me. I haven't tested this on Android, but should work similar to Linux:
--
Zbigniew
Quoted 8 lines
lib/igt_dummyload.c +1
-0pthread_cancel (spin->timer_thread); +#endif igt_assert (pthread_join (spin->timer_thread,NULL ) ==0 );close (spin->timerfd); }Signature · 1 line
2.49.0
PATCH v6 8/14 lib/xe/xe_spin: Avoid pthread_cancel use by introducing an exit flag
In reply to Jeevaka Prabu BadrappanAndroid build fails due to pthread_cancel unavailability. Replace pthread_cancel with thread exit based on an exit flag.
--- lib/xe/xe_spin.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
lib/xe/xe_spin.c +10 -0
@@ -7,6 +7,7 @@*/ #include <string.h> +#include <sys/timerfd.h> #include "drmtest.h" #include "igt.h"
@@ -264,7 +265,16 @@ void xe_spin_free(int fd, struct igt_spin *spin)igt_assert (spin->driver ==INTEL_DRIVER_XE );if (spin->timerfd >=0 ) { +#ifdef ANDROID +struct itimerspec its; + +memset (&its,0 ,sizeof (its)); + its.it_value.tv_sec =0 ; + its.it_value.tv_nsec =1 ; +timerfd_settime (spin->timerfd,0 , &its,NULL ); +#else pthread_cancel (spin->timer_thread); +#endif igt_assert (pthread_join (spin->timer_thread,NULL ) ==0 );close (spin->timerfd); }
Signature · 1 line
2.49.0
Re: [PATCH i-g-t v6 08/14] lib/xe/xe_spin: Avoid pthread_cancel use by introducing an exit flag
Quoted 2 lines · Jeevaka Prabu Badrappan
Android build fails due to
pthread_cancelunavailability. Replacepthread_cancelwith thread exit based on an exit flag.
--
Zbigniew
Quoted 38 lines
Signed-off-by Jeevaka Prabu Badrappan <[email protected]>--- lib/xe/xe_spin.c | 10 ++++++++++ 1 file changed, 10 insertions(+)lib/xe/xe_spin.c +10
-0@@ -7,6 +7,7 @@*/ #include <string.h> +#include <sys/timerfd.h> #include "drmtest.h" #include "igt.h" @@ -264,7 +265,16 @@ void xe_spin_free(int fd, struct igt_spin *spin)igt_assert (spin->driver ==INTEL_DRIVER_XE );if (spin->timerfd >=0 ) { +#ifdef ANDROID +struct itimerspec its; + +memset (&its,0 ,sizeof (its)); + its.it_value.tv_sec =0 ; + its.it_value.tv_nsec =1 ; +timerfd_settime (spin->timerfd,0 , &its,NULL ); +#else pthread_cancel (spin->timer_thread); +#endif igt_assert (pthread_join (spin->timer_thread,NULL ) ==0 );close (spin->timerfd); }Signature · 1 line
2.49.0
PATCH v6 9/14 lib/igt_core: Implement conditional backtrace support using HAVE_LIBUNWIND
In reply to Jeevaka Prabu BadrappanAdd a log message indicating "backtrace not implemented" in the print_backtrace function and return when HAVE_LIBUNWIND is not defined.
--- lib/igt_core.c | 4 ++++ 1 file changed, 4 insertions(+)
lib/igt_core.c +4 -0
@@ -383,6 +383,9 @@ static int _igt_dynamic_tests_executed = -1;static void print_backtrace (void ) { +#ifndef HAVE_LIBUNWIND +igt_info ("backtrace not implemented\n" ); +#else unw_cursor_t cursor;unw_context_t uc;int stack_num =0 ;
@@ -440,6 +443,7 @@ static void print_backtrace(void)if (dwfl)dwfl_end (dwfl); +#endif } __attribute__((format(printf, 2, 3)))
Signature · 1 line
2.49.0
Re: [PATCH i-g-t v6 09/14] lib/igt_core: Implement conditional backtrace support using HAVE_LIBUNWIND
Hi Jeevaka,
Quoted 13 lines · Jeevaka Prabu Badrappan
Add a log message indicating "backtrace not implemented" in the
print_backtracefunction and return whenHAVE_LIBUNWINDis not defined.Signed-off-by Jeevaka Prabu Badrappan <[email protected]>--- lib/igt_core.c | 4 ++++ 1 file changed, 4 insertions(+)lib/igt_core.c +0
-0
lib/igt_core.c static int _igt_dynamic_tests_executed = -1; · line 386
Quoted 4 lines
lib/igt_core.c +1
-0@@ -383,6 +383,9 @@ static int _igt_dynamic_tests_executed = -1;static void print_backtrace (void ) { +#ifndef HAVE_LIBUNWIND
I added here
#error "an error"
and this did not compile on my machine. You need to add HAVE_LIBUNWIND into lib/meson.build
For example how to do it please grep for HAVE_VALGRIND
and make similar change.
Regards,
Kamil
Quoted 16 lines
lib/igt_core.c +3
-0+igt_info ("backtrace not implemented\n" ); +#else unw_cursor_t cursor;unw_context_t uc;int stack_num =0 ;@@ -440,6 +443,7 @@ static void print_backtrace(void)if (dwfl)dwfl_end (dwfl); +#endif } __attribute__((format(printf, 2, 3)))Signature · 1 line
2.49.0
Re: [PATCH i-g-t v6 09/14] lib/igt_core: Implement conditional backtrace support using HAVE_LIBUNWIND
Hi Kamil,
Quoted 20 lines · Jeevaka Prabu Badrappan
Add a log message indicating "backtrace not implemented" in the
print_backtracefunction and return whenHAVE_LIBUNWINDis not defined.Signed-off-by Jeevaka Prabu Badrappan <[email protected]>--- lib/igt_core.c | 4 ++++ 1 file changed, 4 insertions(+)lib/igt_core.c +1
-0@@ -383,6 +383,9 @@ static int _igt_dynamic_tests_executed = -1;static void print_backtrace (void ) { +#ifndef HAVE_LIBUNWIND I added here
Quoted 6 lines
#error "an error"
and this did not compile on my machine. You need to add
HAVE_LIBUNWINDintolib/meson.build
For example how to do it please grep forHAVE_VALGRIND
and make similar change.
Addressed and new version pushed.
Thanks and Regards,
Jeevaka
Quoted 16 lines
lib/igt_core.c +3
-1+igt_info ("backtrace not implemented\n" ); +#else unw_cursor_t cursor;unw_context_t uc;int stack_num =0 ;@@ -440,6 +443,7 @@ static void print_backtrace(void)if (dwfl)dwfl_end (dwfl); +#endif } __attribute__((format(printf, 2, 3))) --2.49.0
Re: [PATCH i-g-t v6 09/14] lib/igt_core: Implement conditional backtrace support using HAVE_LIBUNWIND
In reply to Jeevaka Prabu BadrappanQuoted 2 lines · Jeevaka Prabu Badrappan
Add a log message indicating "backtrace not implemented" in the
print_backtracefunction and return whenHAVE_LIBUNWINDis not defined.
--
Zbigniew
Quoted 31 lines
Signed-off-by Jeevaka Prabu Badrappan <[email protected]>--- lib/igt_core.c | 4 ++++ 1 file changed, 4 insertions(+)lib/igt_core.c +4
-0@@ -383,6 +383,9 @@ static int _igt_dynamic_tests_executed = -1;static void print_backtrace (void ) { +#ifndef HAVE_LIBUNWIND +igt_info ("backtrace not implemented\n" ); +#else unw_cursor_t cursor;unw_context_t uc;int stack_num =0 ;@@ -440,6 +443,7 @@ static void print_backtrace(void)if (dwfl)dwfl_end (dwfl); +#endif } __attribute__((format(printf, 2, 3)))Signature · 1 line
2.49.0
PATCH v6 10/14 lib/igt_core: Conditionally define __noreturn for non-Android platforms
In reply to Jeevaka Prabu BadrappanEnsure __noreturn is defined only if it is not already defined, addressing compatibility with Android where __noreturn is predefined.
--- lib/igt_core.h | 2 ++ 1 file changed, 2 insertions(+)
lib/igt_core.h +2 -0
@@ -86,7 +86,9 @@#define igt_assume (e) BUILD_BUG_ON_INVALID(e)#endif +#ifndef __noreturn#define __noreturn __attribute__((noreturn)) +#endif #define __maybe_unused __attribute__((unused)) extern const char* __igt_test_description __attribute__((weak));
Signature · 1 line
2.49.0
PATCH v6 11/14 tools/intel_gpu_top: Replace index with strchr
In reply to Jeevaka Prabu BadrappanAs index is deprecated, replace index with strchr.
--- tools/intel_gpu_top.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/intel_gpu_top.c +1 -1
@@ -290,7 +290,7 @@ get_pmu_config(int dirfd, const char *name, const char *counter)if (ret <=0 )return -1 ; - p =index (buf,'0' ); + p =strchr (buf,'0' );if (!p)return -1 ;
Signature · 1 line
2.49.0
PATCH v6 12/14 tests/intel/xe_create: Conditionally define PAGE_SIZE for non-Android platforms
In reply to Jeevaka Prabu BadrappanEnsure PAGE_SIZE is defined only if it is not already defined, addressing compatibility with Android where PAGE_SIZE is predefined.
Note: PAGE_SIZE is defined in multiple files; a cleanup will be addressed in a future patch series.
--- tests/intel/xe_create.c | 2 ++ 1 file changed, 2 insertions(+)
tests/intel/xe_create.c +2 -0
@@ -18,7 +18,9 @@#include "xe/xe_ioctl.h" #include "xe/xe_query.h" +#ifndef PAGE_SIZE #define PAGE_SIZE 0x1000 +#endif static struct param { unsigned int quantity;
Signature · 1 line
2.49.0
PATCH v6 13/14 lib/igt_device_scan: Replace rindex with strrchr
In reply to Jeevaka Prabu BadrappanAs rindex is deprecated, replace index with strrchr.
--- lib/igt_device_scan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/igt_device_scan.c +2 -2
@@ -1258,7 +1258,7 @@ igt_devs_print_user(struct igt_list_head *view,if (!dev->drm_card || dev->drm_render)continue ; - drm_name =rindex (dev->drm_card,'/' ); + drm_name =strrchr (dev->drm_card,'/' );if (!drm_name || !*++drm_name)continue ;
@@ -1306,7 +1306,7 @@ igt_devs_print_user(struct igt_list_head *view,if (strcmp (dev2->parent->syspath, dev->parent->syspath))continue ; - drm_name =rindex (dev2->drm_render,'/' ); + drm_name =strrchr (dev2->drm_render,'/' );if (!drm_name || !*++drm_name)continue ;
Signature · 1 line
2.49.0
PATCH v6 14/14 lib/igt_device_scan: reuse igt hash
In reply to Jeevaka Prabu BadrappanAs glib is not available in Andriod, replace the glib hash functions by reusing the igt hash functions.
--- lib/igt_device_scan.c | 78 ++++++++++++++++++++++--------------------- lib/meson.build | 1 + 2 files changed, 41 insertions(+), 38 deletions(-)
lib/igt_device_scan.c +40 -38
@@ -26,12 +26,12 @@#include "igt_core.h" #include "igt_device_scan.h" #include "igt_list.h" +#include "igt_map.h" #include "intel_chipset.h" #include <ctype.h> #include <dirent.h> #include <fcntl.h> -#include <glib.h> #include <libudev.h> #ifdef __linux__#include <linux/limits.h>
@@ -224,8 +224,8 @@ struct igt_device {/* Point to vendor spec if can be found */ /* Properties / sysattrs rewriten from udev lists */ -GHashTable *props_ht; -GHashTable *attrs_ht; +struct igt_map *props_map; +struct igt_map *attrs_map;/* Most usable variables from udev device */ char *subsystem;
@@ -464,6 +464,11 @@ static bool is_on_blacklist(const char *what) } +static int key_equals (const void *key1,const void *key2) +{ +return strcmp ((char *)key1, (char *)key2) ==0 ; +} +static struct igt_device *igt_device_new (void ) {struct igt_device *dev;
@@ -472,14 +477,14 @@ static struct igt_device *igt_device_new(void)if (!dev)return NULL ; - dev->attrs_ht =g_hash_table_new_full (g_str_hash, g_str_equal, - free, free); - dev->props_ht =g_hash_table_new_full (g_str_hash, g_str_equal, - free, free); + dev->attrs_map =igt_map_create (igt_map_hash_32, key_equals); + dev->props_map =igt_map_create (igt_map_hash_32, key_equals); -if (dev->attrs_ht && dev->props_ht) +if (dev->attrs_map && dev->props_map)return dev; +igt_map_destroy (dev->attrs_map,NULL ); +igt_map_destroy (dev->props_map,NULL );free (dev);return NULL ;
@@ -491,7 +496,7 @@ static void igt_device_add_prop(struct igt_device *dev,if (!key || !value)return ; -g_hash_table_insert (dev->props_ht,strdup (key),strdup (value)); +igt_map_insert (dev->props_map,strdup (key),strdup (value)); } static void igt_device_add_attr(struct igt_device *dev,
@@ -525,7 +530,7 @@ static void igt_device_add_attr(struct igt_device *dev, v++; } -g_hash_table_insert (dev->attrs_ht,strdup (key),strdup (v)); +igt_map_insert (dev->attrs_map,strdup (key),strdup (v)); }/* Iterate over udev properties list and rewrite it to igt_device properties
@@ -585,19 +590,30 @@ static void get_attrs_limited(struct udev_device *dev, struct igt_device *idev) } } -#define get_prop (dev, prop) ((char *) g_hash_table_lookup(dev->props_ht, prop)) -#define get_attr (dev, attr) ((char *) g_hash_table_lookup(dev->attrs_ht, attr)) +#define get_prop (dev, prop) ((char *) igt_map_search(dev->props_map, prop)) +#define get_attr (dev, attr) ((char *) igt_map_search(dev->attrs_map, attr))#define get_prop_subsystem (dev) get_prop(dev, "SUBSYSTEM")#define is_drm_subsystem (dev) (strequal(get_prop_subsystem(dev), "drm"))#define is_pci_subsystem (dev) (strequal(get_prop_subsystem(dev), "pci")) -static void print_ht (GHashTable *ht); +static inline void _print_key_value (const char *k,const char *v) +{ +printf ("%-32s: %s\n" , k, v); +} +static void dump_props_and_attrs (const struct igt_device *dev) { +struct igt_map_entry *entry; +printf ("\n[properties]\n" ); -print_ht (dev->props_ht); + igt_map_foreach(dev->props_map, entry) { +_print_key_value ((char *)entry->key, (char *)entry->data); + } +printf ("\n[attributes]\n" ); -print_ht (dev->attrs_ht); + igt_map_foreach(dev->attrs_map, entry) { +_print_key_value ((char *)entry->key, (char *)entry->data); + }printf ("\n" ); }
@@ -949,7 +965,7 @@ static struct igt_device *duplicate_device(struct igt_device *dev) {return dup; } -static gint devs_compare (const void *a,const void *b) +static int devs_compare (const void *a,const void *b) {struct igt_device *dev1, *dev2;int ret;
@@ -1076,6 +1092,12 @@ static void scan_drm_devices(bool limit_attrs) } } +static void free_key_value (struct igt_map_entry *entry) +{ +free ((char *)entry->key); +free (entry->data); +} +static void igt_device_free (struct igt_device *dev) {free (dev->codename);
@@ -1088,8 +1110,8 @@ static void igt_device_free(struct igt_device *dev)free (dev->device);free (dev->driver);free (dev->pci_slot_name); -g_hash_table_destroy (dev->attrs_ht); -g_hash_table_destroy (dev->props_ht); +igt_map_destroy (dev->attrs_map, free_key_value); +igt_map_destroy (dev->props_map, free_key_value); }void igt_devices_free (void )
@@ -1323,26 +1345,6 @@ igt_devs_print_user(struct igt_list_head *view, } } -static inline void _print_key_value (const char * k,const char *v) -{ -printf ("%-32s: %s\n" , k, v); -} - -static void print_ht (GHashTable *ht) -{ -GList *keys =g_hash_table_get_keys (ht); - - keys =g_list_sort (keys, (GCompareFunc ) strcmp); -while (keys) { -char *k = (char *) keys->data; -char *v =g_hash_table_lookup (ht, k); - -_print_key_value (k, v); - keys =g_list_next (keys); - } -g_list_free (keys); -} -static void igt_devs_print_detail (struct igt_list_head *view,const struct igt_devices_print_format *fmt)
lib/meson.build +1 -0
@@ -304,6 +304,7 @@ scan_dep = [ lib_igt_device_scan_build = static_library('igt_device_scan', ['igt_device_scan.c', 'igt_list.c', + 'igt_map.c', 'igt_tools_stub.c', 'intel_device_info.c', 'intel_cmds_info.c',
Signature · 1 line
2.49.0