From patchwork Sun Jan 17 16:18:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12025587 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2977C433E0 for ; Sun, 17 Jan 2021 16:19:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9184622510 for ; Sun, 17 Jan 2021 16:19:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729552AbhAQQT5 (ORCPT ); Sun, 17 Jan 2021 11:19:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:42299 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729124AbhAQQTz (ORCPT ); Sun, 17 Jan 2021 11:19:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610900307; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=pd4vHRZ+JWsMgYXJ+/MXzVJZ5dZGqNEtTkFAu8s+Zps=; b=Z+tYm7j4G4Jm9zkVWWnB+j84GfLRzpYXY5pBumBX4IlfSpqVi31yCye4No8meGPS+70jA+ 69LwMZ3Xz/6f5HU7ptGe/ThogpCZvWQ65MinbnfmazuW9M4+Q6mpwYrLWJioC1DUKgA7z9 26NLUljT9qoe5gectsmP4whsewZpgAc= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-230-E0kHYpMLN06XL9xxYv70EQ-1; Sun, 17 Jan 2021 11:18:25 -0500 X-MC-Unique: E0kHYpMLN06XL9xxYv70EQ-1 Received: by mail-qk1-f199.google.com with SMTP id p21so14477721qke.6 for ; Sun, 17 Jan 2021 08:18:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pd4vHRZ+JWsMgYXJ+/MXzVJZ5dZGqNEtTkFAu8s+Zps=; b=UlXxWiKEJdKlSsBnMdI953HBSE/YhPEflclJDbc9PLo11K9qtGvhru4RdF1mJlTtyc ReSoT1rBCAlJtz9g8Jej6XRx8FQ4cGE24eF3ERQZmB7TOfqV00E4b4P/+P6BnvdPEXMt rH6+QFZdiNw79QjOCLmjAdtTL6hG1atXG0XYYU+nMXJXBwXIM46I48dZnXvHompNaxbC QRA1PY1lBK0pEYW4/vyk1IbOH3uknXs+WrGKmAT8Jvi0L+5oB0vNcnq7+4xGGS3wmbH/ SxbjKNULr15/pY0uUOmT5dbZqHP/j5IoCslURGysQxpoje0OmyvEmNM/shgiizzb58kE S/TQ== X-Gm-Message-State: AOAM531zFJ8UdwhkCvLlnPhREQLRS+ryn5Y7G6gn5McT5Q7HJlrg2r+b LWo9oqf2JD9KuoPa3JSn3wsOYRWfVVOTgvWqKuA+80vYnm3KOLop2mfGMfPhphp42AnEVnqCwzq fZHEroopFxSp8kAtLkM2C3g== X-Received: by 2002:ac8:6b0a:: with SMTP id w10mr19764227qts.224.1610900303862; Sun, 17 Jan 2021 08:18:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJz+kM1gexsua9DwpZxib3OZs35p/m5WmKtlUfgtMEYDw+N6CMDgeXGQk41qH5EeAy8ZFkJePQ== X-Received: by 2002:ac8:6b0a:: with SMTP id w10mr19764160qts.224.1610900302190; Sun, 17 Jan 2021 08:18:22 -0800 (PST) Received: from trix.remote.csb (075-142-250-213.res.spectrum.com. [75.142.250.213]) by smtp.gmail.com with ESMTPSA id i17sm8617874qtg.77.2021.01.17.08.18.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 08:18:21 -0800 (PST) From: trix@redhat.com To: shuah@kernel.org, mdf@kernel.org Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-fpga@vger.kernel.org, Tom Rix Subject: [PATCH v3] selftests: drivers: fpga: A test for interrupt support Date: Sun, 17 Jan 2021 08:18:15 -0800 Message-Id: <20210117161815.514078-1-trix@redhat.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Tom Rix 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 Acked-by: Moritz Fischer --- v1: Convert to kselftest_harness.h framework v2: reverse xmas tree variables --- 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 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..927dcc757f0b --- /dev/null +++ b/tools/testing/selftests/drivers/fpga/intr.c @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include +#include +#include +#include +#include +#include + +#include "../../kselftest_harness.h" + +TEST(afu_intr) +{ + struct dfl_fpga_port_info port_info; + uint32_t irq_num = UINT32_MAX; + int devfd, status; + + 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