* [PATCH v2 0/1] selftests: fpga: dfl: A test for afu interrupt support
@ 2020-06-11 19:38 trix
2020-06-11 19:38 ` [PATCH v2 1/1] " trix
0 siblings, 1 reply; 2+ messages in thread
From: trix @ 2020-06-11 19:38 UTC (permalink / raw)
To: shuah; +Cc: linux-kernel, linux-kselftest, linux-fpga, Tom Rix
From: Tom Rix <trix@redhat.com>
repo: linux-next
tag: next-20200611
Start applying selftests to drivers/fpga.
While testing out this upcoming change on linux-fpga
'Add interrupt support to FPGA DFL drivers'
I did not see any existing fpga tests.
So I added one.
Change from v1
Use ksft_* functions for reporting
Tom Rix (1):
selftests: fpga: dfl: A test for afu interrupt support
tools/testing/selftests/Makefile | 1 +
tools/testing/selftests/drivers/fpga/Makefile | 9 +++++
.../testing/selftests/drivers/fpga/afu_intr.c | 33 +++++++++++++++++++
tools/testing/selftests/drivers/fpga/config | 1 +
4 files changed, 44 insertions(+)
create mode 100644 tools/testing/selftests/drivers/fpga/Makefile
create mode 100644 tools/testing/selftests/drivers/fpga/afu_intr.c
create mode 100644 tools/testing/selftests/drivers/fpga/config
--
2.18.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH v2 1/1] selftests: fpga: dfl: A test for afu interrupt support
2020-06-11 19:38 [PATCH v2 0/1] selftests: fpga: dfl: A test for afu interrupt support trix
@ 2020-06-11 19:38 ` trix
0 siblings, 0 replies; 2+ messages in thread
From: trix @ 2020-06-11 19:38 UTC (permalink / raw)
To: shuah; +Cc: linux-kernel, linux-kselftest, linux-fpga, Tom Rix
From: Tom Rix <trix@redhat.com>
Check that the ioctl DFL_FPGA_PORT_ERR_GET_IRQ_NUM returns
an expected result.
Tested on vf device 0xbcc1
Sample run with
# make -C tools/testing/selftests TARGETS=drivers/fpga run_tests
...
# selftests: drivers/fpga: afu_intr
# # Pass 0 Fail 0 Xfail 0 Xpass 0 Skip 0 Error 0
ok 1 selftests: drivers/fpga: afu_intr
Signed-off-by: Tom Rix <trix@redhat.com>
---
tools/testing/selftests/Makefile | 1 +
tools/testing/selftests/drivers/fpga/Makefile | 9 +++++
.../testing/selftests/drivers/fpga/afu_intr.c | 33 +++++++++++++++++++
tools/testing/selftests/drivers/fpga/config | 1 +
4 files changed, 44 insertions(+)
create mode 100644 tools/testing/selftests/drivers/fpga/Makefile
create mode 100644 tools/testing/selftests/drivers/fpga/afu_intr.c
create mode 100644 tools/testing/selftests/drivers/fpga/config
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 1195bd85af38..4c6eda659125 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -9,6 +9,7 @@ TARGETS += clone3
TARGETS += cpufreq
TARGETS += cpu-hotplug
TARGETS += drivers/dma-buf
+TARGETS += drivers/fpga
TARGETS += efivarfs
TARGETS += exec
TARGETS += filesystems
diff --git a/tools/testing/selftests/drivers/fpga/Makefile b/tools/testing/selftests/drivers/fpga/Makefile
new file mode 100644
index 000000000000..0a472e8c67c5
--- /dev/null
+++ b/tools/testing/selftests/drivers/fpga/Makefile
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0-only
+CFLAGS += -I../../../../../usr/include/
+CFLAGS += -I../../../../../include/uapi/
+
+TEST_GEN_PROGS := afu_intr
+
+top_srcdir ?=../../../../..
+
+include ../../lib.mk
diff --git a/tools/testing/selftests/drivers/fpga/afu_intr.c b/tools/testing/selftests/drivers/fpga/afu_intr.c
new file mode 100644
index 000000000000..e4ef3fac764d
--- /dev/null
+++ b/tools/testing/selftests/drivers/fpga/afu_intr.c
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <linux/fcntl.h>
+#include <linux/fpga-dfl.h>
+
+#include "../../kselftest.h"
+
+int main(int argc, char *argv[])
+{
+ int devfd, status;
+ struct dfl_fpga_port_info port_info;
+ uint32_t irq_num;
+
+ devfd = open("/dev/dfl-port.0", O_RDONLY);
+ if (devfd < 0)
+ ksft_exit_skip("no fpga afu device 0\n");
+
+ /*
+ * From fpga-dl.h :
+ * Currently hardware supports up to 1 irq.
+ * Return: 0 on success, -errno on failure.
+ */
+ irq_num = -1;
+ status = ioctl(devfd, DFL_FPGA_PORT_ERR_GET_IRQ_NUM, &irq_num);
+ if (status != 0 || irq_num > 255)
+ ksft_exit_fail_msg("Could not get the number of afu error irqs\n");
+
+ close(devfd);
+ ksft_exit_pass();
+}
diff --git a/tools/testing/selftests/drivers/fpga/config b/tools/testing/selftests/drivers/fpga/config
new file mode 100644
index 000000000000..e2111b81d8d7
--- /dev/null
+++ b/tools/testing/selftests/drivers/fpga/config
@@ -0,0 +1 @@
+CONFIG_FPGA_DFL_AFU=m
--
2.18.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-06-11 19:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-11 19:38 [PATCH v2 0/1] selftests: fpga: dfl: A test for afu interrupt support trix
2020-06-11 19:38 ` [PATCH v2 1/1] " trix
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).