fix dma-buf/udmabuf selftest
PATCH 1/1 fix dma-buf/udmabuf selftest
This patch fixes the udmabuf selftest. Currently the selftest is broken. I fixed the selftest by setting the F_SEAL_SHRINK seal on the memfd file descriptor which is required by udmabuf and added the test to the selftest Makefile.
--- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/drivers/dma-buf/Makefile | 2 ++ tools/testing/selftests/drivers/dma-buf/udmabuf.c | 11 +++++++++-- 3 files changed, 12 insertions(+), 2 deletions(-)
tools/testing/selftests/Makefile +1 -0
@@ -6,6 +6,7 @@ TARGETS += capabilities TARGETS += cgroup TARGETS += cpufreq TARGETS += cpu-hotplug +TARGETS += drivers/dma-buf TARGETS += efivarfs TARGETS += exec TARGETS += filesystems
tools/testing/selftests/drivers/dma-buf/Makefile +2 -0
@@ -2,4 +2,6 @@ CFLAGS += -I../../../../../usr/include/ TEST_GEN_PROGS := udmabuf +top_srcdir ?=../../../../.. + include ../../lib.mk
tools/testing/selftests/drivers/dma-buf/udmabuf.c +9 -2
@@ -4,7 +4,7 @@#include <unistd.h> #include <string.h> #include <errno.h> -#include <fcntl.h> +#include <linux/fcntl.h> #include <malloc.h> #include <sys/ioctl.h>
@@ -33,12 +33,19 @@ int main(int argc, char *argv[])exit (77 ); } - memfd =memfd_create ("udmabuf-test" ,MFD_CLOEXEC ); + memfd =memfd_create ("udmabuf-test" ,MFD_ALLOW_SEALING );if (memfd <0 ) {printf ("%s: [skip,no-memfd]\n" ,TEST_PREFIX );exit (77 ); } + ret =fcntl (memfd,F_ADD_SEALS ,F_SEAL_SHRINK ); +if (ret <0 ) { +printf ("%s: [skip,fcntl-add-seals]\n" ,TEST_PREFIX ); +exit (77 ); + } + + size =getpagesize () *NUM_PAGES ; ret =ftruncate (memfd, size);if (ret ==-1 ) {
Signature · 1 line
2.11.0
shuah
maintainerHi Daniel,
Quoted 6 lines · Tom Murphy
This patch fixes the udmabuf selftest. Currently the selftest is broken. I fixed the selftest by setting the
F_SEAL_SHRINKseal on the memfd file descriptor which is required by udmabuf and added the test to the selftestMakefile.Signed-off-by Tom Murphy <murphyt7 at tcd.ie>
Does this change look good you? I plan to get this in for 4.21-rc1. Let me know if you have any objections.
thanks,
-- Shuah
Quoted 9 lines · shuah
Hi Daniel,
Quoted 5 lines · Tom Murphy
This patch fixes the udmabuf selftest. Currently the selftest is broken. I fixed the selftest by setting the
F_SEAL_SHRINKseal on the memfd file descriptor which is required by udmabuf and added the test to the selftestMakefile.
Quoted 4 lines
Quoted 1 line
Signed-off-by Tom Murphy <murphyt7 at tcd.ie>Does this change look good you? I plan to get this in for 4.21-rc1. Let me know if you have any objections.
No idea, would need Gerd's ack I think. And maybe we need to update MAINTAINERS, to make sure dri-devel gets cc'ed on patches touching the dma-buf testcases.
-Daniel
Quoted 3 lines
thanks,
-- Shuah
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Gerd Hoffmann
Reviewed-byQuoted 8 lines · shuah
Hi Daniel,
Quoted 5 lines · Tom Murphy
This patch fixes the udmabuf selftest. Currently the selftest is broken. I fixed the selftest by setting the
F_SEAL_SHRINKseal on the memfd file descriptor which is required by udmabuf and added the test to the selftestMakefile.
Quoted 4 lines
Quoted 1 line
Signed-off-by Tom Murphy <murphyt7 at tcd.ie>Does this change look good you? I plan to get this in for 4.21-rc1. Let me know if you have any objections.
Yes, it's fine.
Hi Tom,
Quoted 6 lines · Tom Murphy
This patch fixes the udmabuf selftest. Currently the selftest is broken. I fixed the selftest by setting the
F_SEAL_SHRINKseal on the memfd file descriptor which is required by udmabuf and added the test to the selftestMakefile.Signed-off-by Tom Murphy <murphyt7 at tcd.ie>
This is now commit 6edf2e3710f4ef25 ("fix dma-buf/udmabuf selftest").
tools/testing/selftests/drivers/dma-buf/udmabuf.c line 7
Quoted 8 lines
tools/testing/selftests/drivers/dma-buf/udmabuf.c +1
-1@@ -4,7 +4,7 @@#include <unistd.h> #include <string.h> #include <errno.h> -#include <fcntl.h> +#include <linux/fcntl.h>
Not including <fcntl.h> means we get
udmabuf.c:30:10: warning: implicit declaration of function ‘open’; did you mean ‘popen’? [-Wimplicit-function-declaration]
devfd = open("/dev/udmabuf", O_RDWR);
udmabuf.c:42:8: warning: implicit declaration of function ‘fcntl’; did you mean ‘fcvt’? [-Wimplicit-function-declaration]
ret = fcntl(memfd, F_ADD_SEALS, F_SEAL_SHRINK);
However, we need <linux/fcntl.h> for F_ADD_SEALS, F_SEAL_SHRINK.
Including both leads to lots of redefinition warnings.
Can we fix that?
Quoted 14 lines
tools/testing/selftests/drivers/dma-buf/udmabuf.c +1
-1#include <malloc.h> #include <sys/ioctl.h> @@ -33,12 +33,19 @@ int main(int argc, char *argv[])exit (77 ); } - memfd =memfd_create ("udmabuf-test" ,MFD_CLOEXEC ); + memfd =memfd_create ("udmabuf-test" ,MFD_ALLOW_SEALING );if (memfd <0 ) {printf ("%s: [skip,no-memfd]\n" ,TEST_PREFIX );exit (77 ); }
tools/testing/selftests/drivers/dma-buf/udmabuf.c int main(int argc, char *argv[]) · line 51
Quoted 10 lines
tools/testing/selftests/drivers/dma-buf/udmabuf.c +7
-0+ ret =fcntl (memfd,F_ADD_SEALS ,F_SEAL_SHRINK ); +if (ret <0 ) { +printf ("%s: [skip,fcntl-add-seals]\n" ,TEST_PREFIX ); +exit (77 ); + } + + size =getpagesize () *NUM_PAGES ; ret =ftruncate (memfd, size);if (ret ==-1 ) {
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus TorvaldsQuoted 5 lines
However, we need <
linux/fcntl.h> forF_ADD_SEALS,F_SEAL_SHRINK.Including both leads to lots of redefinition warnings.
Can we fix that?
I still haven't looked at this and probably won't get a chance anytime soon. linux/tools/testing/selftests/memfd/fuse_test.c also suffers from this (it needs the F_ADD_SEALS too) so that should also be fixed if anyone gets a chance
Quoted 72 lines · Geert Uytterhoeven
Hi Tom,
Quoted 6 lines · Tom Murphy
This patch fixes the udmabuf selftest. Currently the selftest is broken. I fixed the selftest by setting the
F_SEAL_SHRINKseal on the memfd file descriptor which is required by udmabuf and added the test to the selftestMakefile.Signed-off-by Tom Murphy <murphyt7 at tcd.ie>This is now commit
6edf2e3710f4ef25("fix dma-buf/udmabuf selftest").tools/testing/selftests/drivers/dma-buf/udmabuf.c line 7
Quoted 8 lines
tools/testing/selftests/drivers/dma-buf/udmabuf.c +1
-1@@ -4,7 +4,7 @@#include <unistd.h> #include <string.h> #include <errno.h> -#include <fcntl.h> +#include <linux/fcntl.h> Not including <
fcntl.h> means we getudmabuf.c:30:10: warning: implicit declaration of function ‘open’; did you mean ‘popen’? [-Wimplicit-function-declaration]
devfd =open("/dev/udmabuf", O_RDWR);
udmabuf.c:42:8: warning: implicit declaration of function ‘fcntl’; did you mean ‘fcvt’? [-Wimplicit-function-declaration]
ret =fcntl(memfd, F_ADD_SEALS, F_SEAL_SHRINK);However, we need <
linux/fcntl.h> forF_ADD_SEALS,F_SEAL_SHRINK.Including both leads to lots of redefinition warnings.
Can we fix that?
Quoted 14 lines
tools/testing/selftests/drivers/dma-buf/udmabuf.c +1
-1#include <malloc.h> #include <sys/ioctl.h> @@ -33,12 +33,19 @@ int main(int argc, char *argv[])exit (77 ); } - memfd =memfd_create ("udmabuf-test" ,MFD_CLOEXEC ); + memfd =memfd_create ("udmabuf-test" ,MFD_ALLOW_SEALING );if (memfd <0 ) {printf ("%s: [skip,no-memfd]\n" ,TEST_PREFIX );exit (77 ); }tools/testing/selftests/drivers/dma-buf/udmabuf.c int main(int argc, char *argv[]) · line 51
Quoted 10 lines
tools/testing/selftests/drivers/dma-buf/udmabuf.c +7
-0+ ret =fcntl (memfd,F_ADD_SEALS ,F_SEAL_SHRINK ); +if (ret <0 ) { +printf ("%s: [skip,fcntl-add-seals]\n" ,TEST_PREFIX ); +exit (77 ); + } + + size =getpagesize () *NUM_PAGES ; ret =ftruncate (memfd, size);if (ret ==-1 ) {Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.orgIn personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds