linux-fpga.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Moritz Fischer <mdf@kernel.org>
To: trix@redhat.com
Cc: shuah@kernel.org, mdf@kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, linux-fpga@vger.kernel.org
Subject: Re: [PATCH v2] selftests: drivers: fpga: A test for interrupt support
Date: Sat, 16 Jan 2021 19:43:08 -0800	[thread overview]
Message-ID: <YAOyTI0PEclTUUuG@epycbox.lan> (raw)
In-Reply-To: <20210116193321.385848-1-trix@redhat.com>

Hi Tom,

On Sat, Jan 16, 2021 at 11:33:21AM -0800, trix@redhat.com wrote:
> 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
>  ...
>  TAP version 13
>  1..1
>  # selftests: drivers/fpga: intr
>  # TAP version 13
>  # 1..1
>  # # Starting 1 tests from 1 test cases.
>  # #  RUN           global.afu_intr ...
>  # #            OK  global.afu_intr
>  # ok 1 global.afu_intr
>  # # PASSED: 1 / 1 tests passed.
>  # # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
>  ok 1 selftests: drivers/fpga: intr
> 
> Signed-off-by: Tom Rix <trix@redhat.com>
> ---
> v1: Convert to kselftest_harness.h framework
> ---
>  MAINTAINERS                                   |  1 +
>  tools/testing/selftests/Makefile              |  1 +
>  tools/testing/selftests/drivers/fpga/Makefile |  7 ++++
>  tools/testing/selftests/drivers/fpga/config   |  1 +
>  tools/testing/selftests/drivers/fpga/intr.c   | 36 +++++++++++++++++++
>  5 files changed, 46 insertions(+)
>  create mode 100644 tools/testing/selftests/drivers/fpga/Makefile
>  create mode 100644 tools/testing/selftests/drivers/fpga/config
>  create mode 100644 tools/testing/selftests/drivers/fpga/intr.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index de610a06cb5c..7ed3ce58d95e 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -6973,6 +6973,7 @@ F:	Documentation/driver-api/fpga/
>  F:	Documentation/fpga/
>  F:	drivers/fpga/
>  F:	include/linux/fpga/
> +F:	tools/testing/selftests/drivers/fpga/
>  
>  FPGA SECURITY MANAGER DRIVERS
>  M:	Russ Weight <russell.h.weight@intel.com>
> diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
> index afbab4aeef3c..aad4763ec348 100644
> --- a/tools/testing/selftests/Makefile
> +++ b/tools/testing/selftests/Makefile
> @@ -9,6 +9,7 @@ TARGETS += core
>  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..eba35c405d5b
> --- /dev/null
> +++ b/tools/testing/selftests/drivers/fpga/Makefile
> @@ -0,0 +1,7 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +CFLAGS += -I../../../../../usr/include/
> +CFLAGS += -I../../../../../include/uapi/
> +
> +TEST_GEN_PROGS := intr
> +
> +include ../../lib.mk
> 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
> diff --git a/tools/testing/selftests/drivers/fpga/intr.c b/tools/testing/selftests/drivers/fpga/intr.c
> new file mode 100644
> index 000000000000..b362fb1f788d
> --- /dev/null
> +++ b/tools/testing/selftests/drivers/fpga/intr.c
> @@ -0,0 +1,36 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <stdint.h>
> +#include <string.h>
> +#include <sys/fcntl.h>
> +#include <sys/ioctl.h>
> +#include <linux/fpga-dfl.h>
> +
> +#include "../../kselftest_harness.h"

Is that how it works with selftests?
> +
> +TEST(afu_intr)
> +{
> +	int devfd, status;
> +	struct dfl_fpga_port_info port_info;
> +	uint32_t irq_num = UINT32_MAX;
Can you order those?

xxxx
xx
x
> +
> +	devfd = open("/dev/dfl-port.0", O_RDONLY);
> +	if (devfd < 0)
> +		SKIP(0, "no fpga afu device 0");
> +	/*
> +	 * From fpga-dl.h :
> +	 * Currently hardware supports up to 1 irq.
> +	 * Return: 0 on success, -errno on failure.
> +	 */
> +	status = ioctl(devfd, DFL_FPGA_PORT_ERR_GET_IRQ_NUM, &irq_num);
> +	ASSERT_EQ(0, status) {
> +		TH_LOG("ioctl() failed to get the number irqs");
> +	}
> +	ASSERT_LT(irq_num, 256) {
> +		TH_LOG("unexpeced number of irqs");
> +	}
> +	close(devfd);
> +}
> +
> +TEST_HARNESS_MAIN
> -- 
> 2.27.0
> 

Thanks for starting this, I don't know a lot about selftests (yet).
So we probably want to get a look at this from corresponding maintainers.

- Moritz

  reply	other threads:[~2021-01-17  3:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-16 19:33 [PATCH v2] selftests: drivers: fpga: A test for interrupt support trix
2021-01-17  3:43 ` Moritz Fischer [this message]
2021-01-17 16:12   ` Tom Rix

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=YAOyTI0PEclTUUuG@epycbox.lan \
    --to=mdf@kernel.org \
    --cc=linux-fpga@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=trix@redhat.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 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).