* [PATCH] lib/xe/xe_gt: Repair xe_gt_stats_get_count function
@ 2024-12-04 15:46 Jonathan Cavitt
2024-12-04 19:33 ` ✗ GitLab.Pipeline: warning for " Patchwork
2024-12-05 14:49 ` [PATCH] " Kamil Konieczny
0 siblings, 2 replies; 3+ messages in thread
From: Jonathan Cavitt @ 2024-12-04 15:46 UTC (permalink / raw)
To: igt-dev
Cc: jonathan.cavitt, alex.zuo, saurabhg.gupta, kamil.konieczny,
sai.gowtham.ch
Resolve the following issues:
- The target directory for the fopen does not take into consideration
the dri subdirectory and assumes the correct path is dri/0. This
might not be the case. Use the "minor" function and fstat to
generate the correct subdirectory.
- The fopen may fail and return a NULL pointer, causing the subsequent
fgets to generate a SIGSEGV. Assert the file opened correctly.
- The file opened by fopen is never closed. Close it.
Fixes: 10cefd82 ("tests/intel/xe_tlb: Add test to check TLB invalidation")
Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/3212
Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
Suggested-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
CC: Sai Gowtham Ch <sai.gowtham.ch@intel.com>
---
lib/xe/xe_gt.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/lib/xe/xe_gt.c b/lib/xe/xe_gt.c
index cee892af96..493bf9793f 100644
--- a/lib/xe/xe_gt.c
+++ b/lib/xe/xe_gt.c
@@ -152,18 +152,28 @@ void xe_post_hang_ring(int fd, igt_hang_t arg)
int xe_gt_stats_get_count(int fd, int gt, const char *stat)
{
FILE *f;
+ struct stat st;
char tlb_path[4096];
char path[256];
int count;
- sprintf(path, "/sys/kernel/debug/dri/0/gt%d/stats", gt);
+ igt_assert_eq(fstat(fd, &st), 0);
+
+ sprintf(path, "/sys/kernel/debug/dri/%d/gt%d/stats",
+ minor(st.st_rdev), gt);
f = fopen(path, "r");
+ igt_assert_f(f, "Failed to open /sys/kernel/debug/dri/%d/gt%d/stats",
+ minor(st.st_rdev), gt);
+
while (fgets(tlb_path, sizeof(tlb_path), f)) {
if (strstr(tlb_path, stat) != NULL) {
sscanf(tlb_path, "%*[^:]: %d", &count);
break;
}
}
+
+ close(f);
+
return count;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* ✗ GitLab.Pipeline: warning for lib/xe/xe_gt: Repair xe_gt_stats_get_count function
2024-12-04 15:46 [PATCH] lib/xe/xe_gt: Repair xe_gt_stats_get_count function Jonathan Cavitt
@ 2024-12-04 19:33 ` Patchwork
2024-12-05 14:49 ` [PATCH] " Kamil Konieczny
1 sibling, 0 replies; 3+ messages in thread
From: Patchwork @ 2024-12-04 19:33 UTC (permalink / raw)
To: Jonathan Cavitt; +Cc: igt-dev
== Series Details ==
Series: lib/xe/xe_gt: Repair xe_gt_stats_get_count function
URL : https://patchwork.freedesktop.org/series/142124/
State : warning
== Summary ==
Pipeline status: FAILED.
see https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/pipelines/1323511 for the overview.
build:tests-debian-meson has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/67728241):
[4/1770] Compiling C object 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o'.
FAILED: lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o
cc -Ilib/76b5a35@@igt-xe_xe_gt_c@sta -Ilib -I../lib -I../include -I../include/drm-uapi -I../include/drm-uapi-experimental -I../include/linux-uapi -I../lib/stubs/syscalls -I. -I../ -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libdrm -I/usr/include/libdrm/nouveau -I/usr/include/x86_64-linux-gnu -I/usr/include/valgrind -I/usr/include/alsa -I/usr/include -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O2 -g -D_GNU_SOURCE -include config.h -D_FORTIFY_SOURCE=2 -Wbad-function-cast -Wdeclaration-after-statement -Wformat=2 -Wimplicit-fallthrough=0 -Wlogical-op -Wmissing-declarations -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wuninitialized -Wunused -Wno-clobbered -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-pointer-arith -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter -Wno-unused-result -Werror=address -Werror=array-bounds -Werror=implicit -Werror=init-self -Werror=int-conversion -Werror=int-to-pointer-cast -Werror=main -Werror=missing-braces -Werror=nonnull -Werror=pointer-to-int-cast -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=write-strings -fno-builtin-malloc -fno-builtin-calloc -D_LARGEFILE64_SOURCE=1 -fPIC -pthread '-DIGT_DATADIR="/usr/local/share/igt-gpu-tools"' '-DIGT_SRCDIR="/builds/gfx-ci/igt-ci-tags/tests"' '-DIGT_LOG_DOMAIN="xe/xe_gt"' -MD -MQ 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -MF 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o.d' -o 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -c ../lib/xe/xe_gt.c
../lib/xe/xe_gt.c: In function ‘xe_gt_stats_get_count’:
../lib/xe/xe_gt.c:176:8: error: passing argument 1 of ‘close’ makes integer from pointer without a cast [-Werror=int-conversion]
close(f);
^
In file included from ../lib/igt_core.h:46,
from ../lib/xe/xe_gt.c:12:
/usr/include/unistd.h:353:23: note: expected ‘int’ but argument is of type ‘FILE *’ {aka ‘struct _IO_FILE *’}
extern int close (int __fd);
~~~~^~~~
cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed.
section_end:1733340513:step_script
section_start:1733340513:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1733340514:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-debian-meson-arm64 has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/67728244):
[6/1400] Compiling C object 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o'.
FAILED: lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o
/usr/bin/aarch64-linux-gnu-gcc -Ilib/76b5a35@@igt-xe_xe_gt_c@sta -Ilib -I../lib -I../include -I../include/drm-uapi -I../include/drm-uapi-experimental -I../include/linux-uapi -I../lib/stubs/syscalls -I. -I../ -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/aarch64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libdrm -I/usr/include/libdrm/nouveau -I/usr/include/aarch64-linux-gnu -I/usr/include/valgrind -I/usr/include/alsa -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O2 -g -D_GNU_SOURCE -include config.h -D_FORTIFY_SOURCE=2 -Wbad-function-cast -Wdeclaration-after-statement -Wformat=2 -Wimplicit-fallthrough=0 -Wlogical-op -Wmissing-declarations -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wuninitialized -Wunused -Wno-clobbered -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-pointer-arith -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter -Wno-unused-result -Werror=address -Werror=array-bounds -Werror=implicit -Werror=init-self -Werror=int-conversion -Werror=int-to-pointer-cast -Werror=main -Werror=missing-braces -Werror=nonnull -Werror=pointer-to-int-cast -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=write-strings -fno-builtin-malloc -fno-builtin-calloc -D_LARGEFILE64_SOURCE=1 -fPIC -pthread '-DIGT_DATADIR="/usr/local/share/igt-gpu-tools"' '-DIGT_SRCDIR="/builds/gfx-ci/igt-ci-tags/tests"' '-DIGT_LOG_DOMAIN="xe/xe_gt"' -MD -MQ 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -MF 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o.d' -o 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -c ../lib/xe/xe_gt.c
../lib/xe/xe_gt.c: In function ‘xe_gt_stats_get_count’:
../lib/xe/xe_gt.c:176:8: error: passing argument 1 of ‘close’ makes integer from pointer without a cast [-Werror=int-conversion]
close(f);
^
In file included from ../lib/igt_core.h:46,
from ../lib/xe/xe_gt.c:12:
/usr/aarch64-linux-gnu/include/unistd.h:353:23: note: expected ‘int’ but argument is of type ‘FILE *’ {aka ‘struct _IO_FILE *’}
extern int close (int __fd);
~~~~^~~~
cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed.
section_end:1733340534:step_script
section_start:1733340534:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1733340537:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-debian-meson-armhf has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/67728243):
[7/1410] Compiling C object 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o'.
FAILED: lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o
/usr/bin/arm-linux-gnueabihf-gcc -Ilib/76b5a35@@igt-xe_xe_gt_c@sta -Ilib -I../lib -I../include -I../include/drm-uapi -I../include/drm-uapi-experimental -I../include/linux-uapi -I../lib/stubs/syscalls -I. -I../ -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libdrm -I/usr/include/libdrm/nouveau -I/usr/include/arm-linux-gnueabihf -I/usr/include/valgrind -I/usr/include/alsa -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O2 -g -D_GNU_SOURCE -include config.h -D_FORTIFY_SOURCE=2 -Wbad-function-cast -Wdeclaration-after-statement -Wformat=2 -Wimplicit-fallthrough=0 -Wlogical-op -Wmissing-declarations -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wuninitialized -Wunused -Wno-clobbered -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-pointer-arith -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter -Wno-unused-result -Werror=address -Werror=array-bounds -Werror=implicit -Werror=init-self -Werror=int-conversion -Werror=int-to-pointer-cast -Werror=main -Werror=missing-braces -Werror=nonnull -Werror=pointer-to-int-cast -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=write-strings -fno-builtin-malloc -fno-builtin-calloc -D_LARGEFILE64_SOURCE=1 -fPIC -pthread '-DIGT_DATADIR="/usr/local/share/igt-gpu-tools"' '-DIGT_SRCDIR="/builds/gfx-ci/igt-ci-tags/tests"' '-DIGT_LOG_DOMAIN="xe/xe_gt"' -MD -MQ 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -MF 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o.d' -o 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -c ../lib/xe/xe_gt.c
../lib/xe/xe_gt.c: In function ‘xe_gt_stats_get_count’:
../lib/xe/xe_gt.c:176:8: error: passing argument 1 of ‘close’ makes integer from pointer without a cast [-Werror=int-conversion]
close(f);
^
In file included from ../lib/igt_core.h:46,
from ../lib/xe/xe_gt.c:12:
/usr/arm-linux-gnueabihf/include/unistd.h:353:23: note: expected ‘int’ but argument is of type ‘FILE *’ {aka ‘struct _IO_FILE *’}
extern int close (int __fd);
~~~~^~~~
cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed.
section_end:1733340596:step_script
section_start:1733340596:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1733340597:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-debian-meson-mips has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/67728245):
[6/1284] Compiling C object 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o'.
FAILED: lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o
/usr/bin/mips-linux-gnu-gcc -Ilib/76b5a35@@igt-xe_xe_gt_c@sta -Ilib -I../lib -I../include -I../include/drm-uapi -I../include/drm-uapi-experimental -I../include/linux-uapi -I../lib/stubs/syscalls -I. -I../ -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/mips-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libdrm -I/usr/include/libdrm/nouveau -I/usr/include/mips-linux-gnu -I/usr/include/valgrind -I/usr/include/alsa -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O2 -g -D_GNU_SOURCE -include config.h -D_FORTIFY_SOURCE=2 -Wbad-function-cast -Wdeclaration-after-statement -Wformat=2 -Wimplicit-fallthrough=0 -Wlogical-op -Wmissing-declarations -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wuninitialized -Wunused -Wno-clobbered -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-pointer-arith -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter -Wno-unused-result -Werror=address -Werror=array-bounds -Werror=implicit -Werror=init-self -Werror=int-conversion -Werror=int-to-pointer-cast -Werror=main -Werror=missing-braces -Werror=nonnull -Werror=pointer-to-int-cast -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=write-strings -fno-builtin-malloc -fno-builtin-calloc -D_LARGEFILE64_SOURCE=1 -fPIC -pthread '-DIGT_DATADIR="/usr/local/share/igt-gpu-tools"' '-DIGT_SRCDIR="/builds/gfx-ci/igt-ci-tags/tests"' '-DIGT_LOG_DOMAIN="xe/xe_gt"' -MD -MQ 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -MF 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o.d' -o 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -c ../lib/xe/xe_gt.c
../lib/xe/xe_gt.c: In function ‘xe_gt_stats_get_count’:
../lib/xe/xe_gt.c:176:8: error: passing argument 1 of ‘close’ makes integer from pointer without a cast [-Werror=int-conversion]
close(f);
^
In file included from ../lib/igt_core.h:46,
from ../lib/xe/xe_gt.c:12:
/usr/mips-linux-gnu/include/unistd.h:353:23: note: expected ‘int’ but argument is of type ‘FILE *’ {aka ‘struct _IO_FILE *’}
extern int close (int __fd);
~~~~^~~~
cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed.
section_end:1733340624:step_script
section_start:1733340624:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1733340624:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-debian-minimal has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/67728242):
[8/417] Compiling C object 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o'.
FAILED: lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o
cc -Ilib/76b5a35@@igt-xe_xe_gt_c@sta -Ilib -I../lib -I../include -I../include/drm-uapi -I../include/drm-uapi-experimental -I../include/linux-uapi -I../lib/stubs/syscalls -I. -I../ -I../lib/stubs/libunwind -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libdrm -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O2 -g -D_GNU_SOURCE -include config.h -D_FORTIFY_SOURCE=2 -Wbad-function-cast -Wdeclaration-after-statement -Wformat=2 -Wimplicit-fallthrough=0 -Wlogical-op -Wmissing-declarations -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wuninitialized -Wunused -Wno-clobbered -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-pointer-arith -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter -Wno-unused-result -Werror=address -Werror=array-bounds -Werror=implicit -Werror=init-self -Werror=int-conversion -Werror=int-to-pointer-cast -Werror=main -Werror=missing-braces -Werror=nonnull -Werror=pointer-to-int-cast -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=write-strings -fno-builtin-malloc -fno-builtin-calloc -D_LARGEFILE64_SOURCE=1 -fPIC -pthread '-DIGT_DATADIR="/usr/local/share/igt-gpu-tools"' '-DIGT_SRCDIR="/builds/gfx-ci/igt-ci-tags/tests"' '-DIGT_LOG_DOMAIN="xe/xe_gt"' -MD -MQ 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -MF 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o.d' -o 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -c ../lib/xe/xe_gt.c
../lib/xe/xe_gt.c: In function ‘xe_gt_stats_get_count’:
../lib/xe/xe_gt.c:176:8: error: passing argument 1 of ‘close’ makes integer from pointer without a cast [-Werror=int-conversion]
close(f);
^
In file included from ../lib/igt_core.h:46,
from ../lib/xe/xe_gt.c:12:
/usr/include/unistd.h:353:23: note: expected ‘int’ but argument is of type ‘FILE *’ {aka ‘struct _IO_FILE *’}
extern int close (int __fd);
~~~~^~~~
cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed.
section_end:1733340534:step_script
section_start:1733340534:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1733340536:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-fedora has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/67728236):
cc -Ilib/76b5a35@@igt-xe_xe_gt_c@sta -Ilib -I../lib -I../include -I../include/drm-uapi -I../include/drm-uapi-experimental -I../include/linux-uapi -I../lib/stubs/syscalls -I. -I../ -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libdrm -I/usr/include/libdrm/nouveau -I/usr/include/valgrind -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O2 -g -D_GNU_SOURCE -include config.h -D_FORTIFY_SOURCE=2 -Wbad-function-cast -Wdeclaration-after-statement -Wformat=2 -Wimplicit-fallthrough=0 -Wlogical-op -Wmissing-declarations -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wuninitialized -Wunused -Wno-clobbered -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-pointer-arith -Wno-address-of-packed-member -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter -Wno-unused-result -Werror=address -Werror=array-bounds -Werror=implicit -Werror=init-self -Werror=int-conversion -Werror=int-to-pointer-cast -Werror=main -Werror=missing-braces -Werror=nonnull -Werror=pointer-to-int-cast -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=write-strings -fno-builtin-malloc -fno-builtin-calloc -D_LARGEFILE64_SOURCE=1 -fPIC -pthread '-DIGT_DATADIR="/opt/igt/share/igt-gpu-tools"' '-DIGT_SRCDIR="/builds/gfx-ci/igt-ci-tags/tests"' '-DIGT_LOG_DOMAIN="xe/xe_gt"' -MD -MQ 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -MF 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o.d' -o 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -c ../lib/xe/xe_gt.c
../lib/xe/xe_gt.c: In function ‘xe_gt_stats_get_count’:
../lib/xe/xe_gt.c:176:8: error: passing argument 1 of ‘close’ makes integer from pointer without a cast [-Werror=int-conversion]
176 | close(f);
| ^
| |
| FILE * {aka struct _IO_FILE *}
In file included from ../lib/igt_core.h:46,
from ../lib/xe/xe_gt.c:12:
/usr/include/unistd.h:353:23: note: expected ‘int’ but argument is of type ‘FILE *’ {aka ‘struct _IO_FILE *’}
353 | extern int close (int __fd);
| ~~~~^~~~
cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed.
section_end:1733340515:step_script
section_start:1733340515:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1733340515:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-fedora-clang has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/67728240):
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../lib/xe/xe_gt.c:178:9: note: uninitialized use occurs here
return count;
^~~~~
../lib/xe/xe_gt.c:169:9: note: remove the condition if it is always true
while (fgets(tlb_path, sizeof(tlb_path), f)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1
../lib/xe/xe_gt.c:158:11: note: initialize the variable 'count' to silence this warning
int count;
^
= 0
1 warning and 1 error generated.
ninja: build stopped: subcommand failed.
section_end:1733340518:step_script
section_start:1733340518:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1733340518:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-fedora-no-libdrm-nouveau has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/67728239):
cc -Ilib/76b5a35@@igt-xe_xe_gt_c@sta -Ilib -I../lib -I../include -I../include/drm-uapi -I../include/drm-uapi-experimental -I../include/linux-uapi -I../lib/stubs/syscalls -I. -I../ -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libdrm -I/usr/include/valgrind -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O2 -g -D_GNU_SOURCE -include config.h -D_FORTIFY_SOURCE=2 -Wbad-function-cast -Wdeclaration-after-statement -Wformat=2 -Wimplicit-fallthrough=0 -Wlogical-op -Wmissing-declarations -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wuninitialized -Wunused -Wno-clobbered -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-pointer-arith -Wno-address-of-packed-member -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter -Wno-unused-result -Werror=address -Werror=array-bounds -Werror=implicit -Werror=init-self -Werror=int-conversion -Werror=int-to-pointer-cast -Werror=main -Werror=missing-braces -Werror=nonnull -Werror=pointer-to-int-cast -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=write-strings -fno-builtin-malloc -fno-builtin-calloc -D_LARGEFILE64_SOURCE=1 -fPIC -pthread '-DIGT_DATADIR="/usr/local/share/igt-gpu-tools"' '-DIGT_SRCDIR="/builds/gfx-ci/igt-ci-tags/tests"' '-DIGT_LOG_DOMAIN="xe/xe_gt"' -MD -MQ 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -MF 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o.d' -o 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -c ../lib/xe/xe_gt.c
../lib/xe/xe_gt.c: In function ‘xe_gt_stats_get_count’:
../lib/xe/xe_gt.c:176:8: error: passing argument 1 of ‘close’ makes integer from pointer without a cast [-Werror=int-conversion]
176 | close(f);
| ^
| |
| FILE * {aka struct _IO_FILE *}
In file included from ../lib/igt_core.h:46,
from ../lib/xe/xe_gt.c:12:
/usr/include/unistd.h:353:23: note: expected ‘int’ but argument is of type ‘FILE *’ {aka ‘struct _IO_FILE *’}
353 | extern int close (int __fd);
| ~~~~^~~~
cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed.
section_end:1733340534:step_script
section_start:1733340534:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1733340536:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-fedora-no-libunwind has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/67728237):
cc -Ilib/76b5a35@@igt-xe_xe_gt_c@sta -Ilib -I../lib -I../include -I../include/drm-uapi -I../include/drm-uapi-experimental -I../include/linux-uapi -I../lib/stubs/syscalls -I. -I../ -I../lib/stubs/libunwind -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libdrm -I/usr/include/libdrm/nouveau -I/usr/include/valgrind -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O2 -g -D_GNU_SOURCE -include config.h -D_FORTIFY_SOURCE=2 -Wbad-function-cast -Wdeclaration-after-statement -Wformat=2 -Wimplicit-fallthrough=0 -Wlogical-op -Wmissing-declarations -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wuninitialized -Wunused -Wno-clobbered -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-pointer-arith -Wno-address-of-packed-member -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter -Wno-unused-result -Werror=address -Werror=array-bounds -Werror=implicit -Werror=init-self -Werror=int-conversion -Werror=int-to-pointer-cast -Werror=main -Werror=missing-braces -Werror=nonnull -Werror=pointer-to-int-cast -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=write-strings -fno-builtin-malloc -fno-builtin-calloc -D_LARGEFILE64_SOURCE=1 -fPIC -pthread '-DIGT_DATADIR="/usr/local/share/igt-gpu-tools"' '-DIGT_SRCDIR="/builds/gfx-ci/igt-ci-tags/tests"' '-DIGT_LOG_DOMAIN="xe/xe_gt"' -MD -MQ 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -MF 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o.d' -o 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -c ../lib/xe/xe_gt.c
../lib/xe/xe_gt.c: In function ‘xe_gt_stats_get_count’:
../lib/xe/xe_gt.c:176:8: error: passing argument 1 of ‘close’ makes integer from pointer without a cast [-Werror=int-conversion]
176 | close(f);
| ^
| |
| FILE * {aka struct _IO_FILE *}
In file included from ../lib/igt_core.h:46,
from ../lib/xe/xe_gt.c:12:
/usr/include/unistd.h:353:23: note: expected ‘int’ but argument is of type ‘FILE *’ {aka ‘struct _IO_FILE *’}
353 | extern int close (int __fd);
| ~~~~^~~~
cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed.
section_end:1733340534:step_script
section_start:1733340534:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1733340536:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-fedora-oldest-meson has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/67728238):
cc -Ilib/lib@@igt-xe_xe_gt_c@sta -Ilib -I../lib -I../include -I../include/drm-uapi -I../include/drm-uapi-experimental -I../include/linux-uapi -I../lib/stubs/syscalls -I. -I../ -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libdrm -I/usr/include/libdrm/nouveau -I/usr/include/valgrind -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O2 -g -D_GNU_SOURCE -include config.h -D_FORTIFY_SOURCE=2 -Wbad-function-cast -Wdeclaration-after-statement -Wformat=2 -Wimplicit-fallthrough=0 -Wlogical-op -Wmissing-declarations -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wuninitialized -Wunused -Wno-clobbered -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-pointer-arith -Wno-address-of-packed-member -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter -Wno-unused-result -Werror=address -Werror=array-bounds -Werror=implicit -Werror=init-self -Werror=int-conversion -Werror=int-to-pointer-cast -Werror=main -Werror=missing-braces -Werror=nonnull -Werror=pointer-to-int-cast -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=write-strings -fno-builtin-malloc -fno-builtin-calloc -D_LARGEFILE64_SOURCE=1 -fPIC -pthread '-DIGT_DATADIR="/usr/local/share/igt-gpu-tools"' '-DIGT_SRCDIR="/builds/gfx-ci/igt-ci-tags/tests"' '-DIGT_LOG_DOMAIN="xe/xe_gt"' -MD -MQ 'lib/lib@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -MF 'lib/lib@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o.d' -o 'lib/lib@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -c ../lib/xe/xe_gt.c
../lib/xe/xe_gt.c: In function ‘xe_gt_stats_get_count’:
../lib/xe/xe_gt.c:176:8: error: passing argument 1 of ‘close’ makes integer from pointer without a cast [-Werror=int-conversion]
176 | close(f);
| ^
| |
| FILE * {aka struct _IO_FILE *}
In file included from ../lib/igt_core.h:46,
from ../lib/xe/xe_gt.c:12:
/usr/include/unistd.h:353:23: note: expected ‘int’ but argument is of type ‘FILE *’ {aka ‘struct _IO_FILE *’}
353 | extern int close (int __fd);
| ~~~~^~~~
cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed.
section_end:1733340513:step_script
section_start:1733340513:cleanup_file_variables
Cleaning up project directory and file based variables
section_end:1733340513:cleanup_file_variables
ERROR: Job failed: exit code 1
== Logs ==
For more details see: https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/pipelines/1323511
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] lib/xe/xe_gt: Repair xe_gt_stats_get_count function
2024-12-04 15:46 [PATCH] lib/xe/xe_gt: Repair xe_gt_stats_get_count function Jonathan Cavitt
2024-12-04 19:33 ` ✗ GitLab.Pipeline: warning for " Patchwork
@ 2024-12-05 14:49 ` Kamil Konieczny
1 sibling, 0 replies; 3+ messages in thread
From: Kamil Konieczny @ 2024-12-05 14:49 UTC (permalink / raw)
To: Jonathan Cavitt; +Cc: igt-dev, alex.zuo, saurabhg.gupta, sai.gowtham.ch
Hi Jonathan,
On 2024-12-04 at 15:46:50 +0000, Jonathan Cavitt wrote:
> Resolve the following issues:
>
> - The target directory for the fopen does not take into consideration
> the dri subdirectory and assumes the correct path is dri/0. This
> might not be the case. Use the "minor" function and fstat to
> generate the correct subdirectory.
>
> - The fopen may fail and return a NULL pointer, causing the subsequent
> fgets to generate a SIGSEGV. Assert the file opened correctly.
>
> - The file opened by fopen is never closed. Close it.
>
> Fixes: 10cefd82 ("tests/intel/xe_tlb: Add test to check TLB invalidation")
> Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/3212
> Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
> Suggested-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
> CC: Sai Gowtham Ch <sai.gowtham.ch@intel.com>
> ---
> lib/xe/xe_gt.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/lib/xe/xe_gt.c b/lib/xe/xe_gt.c
> index cee892af96..493bf9793f 100644
> --- a/lib/xe/xe_gt.c
> +++ b/lib/xe/xe_gt.c
> @@ -152,18 +152,28 @@ void xe_post_hang_ring(int fd, igt_hang_t arg)
> int xe_gt_stats_get_count(int fd, int gt, const char *stat)
> {
> FILE *f;
> + struct stat st;
> char tlb_path[4096];
> char path[256];
> int count;
>
> - sprintf(path, "/sys/kernel/debug/dri/0/gt%d/stats", gt);
> + igt_assert_eq(fstat(fd, &st), 0);
> +
> + sprintf(path, "/sys/kernel/debug/dri/%d/gt%d/stats",
> + minor(st.st_rdev), gt);
> f = fopen(path, "r");
>
> + igt_assert_f(f, "Failed to open /sys/kernel/debug/dri/%d/gt%d/stats",
> + minor(st.st_rdev), gt);
> +
> while (fgets(tlb_path, sizeof(tlb_path), f)) {
> if (strstr(tlb_path, stat) != NULL) {
> sscanf(tlb_path, "%*[^:]: %d", &count);
> break;
> }
> }
> +
> + close(f);
I missed this, it should be fclose()
My r-b still holds,
Regards,
Kamil
> +
> return count;
> }
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-12-05 14:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-04 15:46 [PATCH] lib/xe/xe_gt: Repair xe_gt_stats_get_count function Jonathan Cavitt
2024-12-04 19:33 ` ✗ GitLab.Pipeline: warning for " Patchwork
2024-12-05 14:49 ` [PATCH] " Kamil Konieczny
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox