From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7991C43217 for ; Fri, 21 Oct 2022 08:00:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229478AbiJUIAY (ORCPT ); Fri, 21 Oct 2022 04:00:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229648AbiJUIAX (ORCPT ); Fri, 21 Oct 2022 04:00:23 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C543D143A7C for ; Fri, 21 Oct 2022 01:00:20 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id 20so1887005pgc.5 for ; Fri, 21 Oct 2022 01:00:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=Af64HsW8Hb3IJa0+V6qoz6cLtuntZ5l3rMcrmMxUOek=; b=ZFQOQ+i0+gxqjtqEyGfjrYUT1cFe7ehfq6Aqb1a109g6ZvyEW487gDPEwXJap00wgT r9DQqgK43+ngqcsqL5DZPEKR1QAn9pBIFHRoMNGWm8EJ2nKKJu5spz/s0FGP76pRq3Oi 1l4caFXtTm4xGRSoe22tKlgJeV6fYUOFGQRtJvlrCORSJY9VM7rPy1v1pSuAqstv1PEU ami7MC/c0J66v1Z6kf4tFMd/eKxjxBjrVLA/A+5FGb77Q6R5ec8sukzfmGymXlOBbdwa H6IBvnli/6+1aD2Uha35Ate16rLhFlG3WYRzocWiZ9dZWk7c5cw1UgbMQmKRCVHhm4dN 7McQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Af64HsW8Hb3IJa0+V6qoz6cLtuntZ5l3rMcrmMxUOek=; b=hTvl2pDYik+oAMIpSvYpmU/V1XiEucShq90SJ3N1DgfkXoBbUnxjdBsaDtCb2HbURC dK082Gvfc0pRXgCOOKQknebqmJpI0X7HTgtZ9CAk5Z3z+cykLw0nAAdiC4LQFKa/ITHn 9T1diAZoScDBhaLDz6E0UBMtB7NhgGWss9A4HzULTnO1NbY9S0O994ArvzbrlAo/ldxo C1VUraOd6ytoF+PuxCFhhDNbS/3yTKWwy8UrU/wRymwmGnVXt9Zk2R/cW/f9W2o+QySy EHZ3jMZoaaGIqE3XCiQeuPbc0KigZ+HGaOeDpE3Ph73YxaXnVXp2Byp43q2yVRdRjpfH ksJg== X-Gm-Message-State: ACrzQf2pUrFUdxWbXawSh2vAiaf+dWRLnjL7TRlQHImQq4pxQ5ccj42V 4T1f9NnR7RZg7dXSovOoMOJw X-Google-Smtp-Source: AMsMyM5rRdNsJM9l2Vo+GcMg4s4PscaCRWLG2VkppCZoNdKcVcTDzkw6HBLtS8j2Rhydy1V59AC8qA== X-Received: by 2002:a62:e70f:0:b0:562:d556:8cf2 with SMTP id s15-20020a62e70f000000b00562d5568cf2mr18129850pfh.78.1666339220235; Fri, 21 Oct 2022 01:00:20 -0700 (PDT) Received: from thinkpad ([117.193.215.105]) by smtp.gmail.com with ESMTPSA id e17-20020a17090301d100b001782398648dsm14436010plh.8.2022.10.21.01.00.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 01:00:19 -0700 (PDT) Date: Fri, 21 Oct 2022 13:30:12 +0530 From: 'Manivannan Sadhasivam' To: Aman Gupta Cc: 'Kishon Vijay Abraham I' , shradha.t@samsung.com, pankaj.dubey@samsung.com, lpieralisi@kernel.org, kw@linux.com, shuah@kernel.org, linux-pci@vger.kernel.org, linux-kselftest@vger.kernel.org, 'Padmanabhan Rajanbabu' Subject: Re: [PATCH] selftests: pci: pci-selftest: add support for PCI endpoint driver test Message-ID: <20221021080012.GA93287@thinkpad> References: <20221007053934.5188-1-aman1.gupta@samsung.com> <007c01d8e51a$4b2e3720$e18aa560$@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <007c01d8e51a$4b2e3720$e18aa560$@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Fri, Oct 21, 2022 at 12:26:38PM +0530, Aman Gupta wrote: > > > > -----Original Message----- > > From: Kishon Vijay Abraham I [mailto:kishon@ti.com] > > Sent: Tuesday, October 11, 2022 4:29 PM > > To: Aman Gupta ; shradha.t@samsung.com; > > pankaj.dubey@samsung.com; lpieralisi@kernel.org; kw@linux.com; > > shuah@kernel.org > > Cc: linux-pci@vger.kernel.org; linux-kselftest@vger.kernel.org; > > Padmanabhan Rajanbabu ; Manivannan > > Sadhasivam > > Subject: Re: [PATCH] selftests: pci: pci-selftest: add support for PCI endpoint > > driver test > > > > +Mani > Gentle reminder for review of this patch. > Sorry for the delay. I'm on leave for the past few weeks. Will get to the patch next week. Thanks, Mani > Thanks and Regards > Aman Gupta > > > > On 07/10/22 11:09 am, Aman Gupta wrote: > > > This patch enables the support to perform selftest on PCIe endpoint > > > driver present in the system. The following tests are currently > > > performed by the selftest utility > > > > > > 1. BAR Tests (BAR0 to BAR5) > > > 2. MSI Interrupt Tests (MSI1 to MSI32) 3. Read Tests (For 1, 1024, > > > 1025, 1024000, 1024001 Bytes) 4. Write Tests (For 1, 1024, 1025, > > > 1024000, 1024001 Bytes) 5. Copy Tests (For 1, 1024, 1025, 1024000, > > > 1024001 Bytes) > > > > > > Signed-off-by: Aman Gupta > > > Signed-off-by: Padmanabhan Rajanbabu > > > --- > > > tools/testing/selftests/Makefile | 1 + > > > tools/testing/selftests/pci/.gitignore | 1 + > > > tools/testing/selftests/pci/Makefile | 7 + > > > tools/testing/selftests/pci/pci-selftest.c | 167 +++++++++++++++++++++ > > > 4 files changed, 176 insertions(+) > > > create mode 100644 tools/testing/selftests/pci/.gitignore > > > create mode 100644 tools/testing/selftests/pci/Makefile > > > create mode 100644 tools/testing/selftests/pci/pci-selftest.c > > > > > > diff --git a/tools/testing/selftests/Makefile > > > b/tools/testing/selftests/Makefile > > > index c2064a35688b..81584169a80f 100644 > > > --- a/tools/testing/selftests/Makefile > > > +++ b/tools/testing/selftests/Makefile > > > @@ -49,6 +49,7 @@ TARGETS += net/forwarding > > > TARGETS += net/mptcp > > > TARGETS += netfilter > > > TARGETS += nsfs > > > +TARGETS += pci > > > TARGETS += pidfd > > > TARGETS += pid_namespace > > > TARGETS += powerpc > > > diff --git a/tools/testing/selftests/pci/.gitignore > > > b/tools/testing/selftests/pci/.gitignore > > > new file mode 100644 > > > index 000000000000..db01411b8200 > > > --- /dev/null > > > +++ b/tools/testing/selftests/pci/.gitignore > > > @@ -0,0 +1 @@ > > > +pci-selftest > > > diff --git a/tools/testing/selftests/pci/Makefile > > > b/tools/testing/selftests/pci/Makefile > > > new file mode 100644 > > > index 000000000000..76b7725a45ae > > > --- /dev/null > > > +++ b/tools/testing/selftests/pci/Makefile > > > @@ -0,0 +1,7 @@ > > > +# SPDX-License-Identifier: GPL-2.0 > > > +CFLAGS += -O2 -Wl,-no-as-needed -Wall LDFLAGS += -lrt -lpthread -lm > > > + > > > +TEST_GEN_PROGS = pci-selftest > > > + > > > +include ../lib.mk > > > diff --git a/tools/testing/selftests/pci/pci-selftest.c > > > b/tools/testing/selftests/pci/pci-selftest.c > > > new file mode 100644 > > > index 000000000000..73e8f3eb1982 > > > --- /dev/null > > > +++ b/tools/testing/selftests/pci/pci-selftest.c > > > @@ -0,0 +1,167 @@ > > > +// SPDX-License-Identifier: GPL-2.0 > > > +/* > > > + * PCI Endpoint Driver Test Program > > > + * > > > + * Copyright (c) 2022 Samsung Electronics Co., Ltd. > > > + * https://www.samsung.com > > > + * Author: Aman Gupta */ > > > + > > > +#include > > > +#include > > > +#include > > > +#include > > > +#include > > > +#include > > > +#include > > > + > > > +#include "../kselftest_harness.h" > > > + > > > +#define PCITEST_BAR _IO('P', 0x1) > > > +#define PCITEST_LEGACY_IRQ _IO('P', 0x2) > > > +#define PCITEST_MSI _IOW('P', 0x3, int) > > > +#define PCITEST_WRITE _IOW('P', 0x4, unsigned long) > > > +#define PCITEST_READ _IOW('P', 0x5, unsigned long) > > > +#define PCITEST_COPY _IOW('P', 0x6, unsigned long) > > > +#define PCITEST_MSIX _IOW('P', 0x7, int) > > > +#define PCITEST_SET_IRQTYPE _IOW('P', 0x8, int) > > > +#define PCITEST_GET_IRQTYPE _IO('P', 0x9) > > > +#define PCITEST_CLEAR_IRQ _IO('P', 0x10) > > > + > > > +static char *test_device = "/dev/pci-endpoint-test.0"; > > > + > > > +struct xfer_param { > > > + unsigned long size; > > > + unsigned char flag; > > > + }; > > > + > > > +FIXTURE(device) > > > +{ > > > + int fd; > > > +}; > > > + > > > +FIXTURE_SETUP(device) > > > +{ > > > + > > > + self->fd = open(test_device, O_RDWR); > > > + > > > + ASSERT_NE(-1, self->fd) { > > > + TH_LOG("Can't open PCI Endpoint Test device\n"); > > > + } > > > +} > > > + > > > +FIXTURE_TEARDOWN(device) > > > +{ > > > + close(self->fd); > > > +} > > > + > > > +TEST_F(device, BAR_TEST) > > > +{ > > > + int ret = -EINVAL; > > > + int final = 0; > > > + > > > + for (int i = 0; i <= 5; i++) { > > > + ret = ioctl(self->fd, PCITEST_BAR, i); > > > + > > > + EXPECT_EQ(1, ret) { > > > + TH_LOG("TEST FAILED FOR BAR %d\n", i); > > > + final++; > > > + } > > > + } > > > + > > > + ASSERT_EQ(0, final); > > > +} > > > + > > > +TEST_F(device, MSI_TEST) > > > +{ > > > + int ret = -EINVAL; > > > + int final = 0; > > > + > > > + ret = ioctl(self->fd, PCITEST_SET_IRQTYPE, 1); > > > + ASSERT_EQ(1, ret); > > > + > > > + for (int i = 1; i <= 32; i++) { > > > + ret = ioctl(self->fd, PCITEST_MSI, i); > > > + EXPECT_EQ(1, ret) { > > > + TH_LOG("TEST FAILED FOR MSI%d\n", i); > > > + final++; > > > + } > > > + } > > > + > > > + ASSERT_EQ(0, final); > > > +} > > > + > > > +TEST_F(device, READ_TEST) > > > +{ > > > + int final = 0; > > > + int ret = -EINVAL; > > > + unsigned long SIZE[5] = {1, 1024, 1025, 1024000, 1024001}; > > > + > > > + ret = ioctl(self->fd, PCITEST_SET_IRQTYPE, 1); > > > + ASSERT_EQ(1, ret); > > > + > > > + struct xfer_param param; > > > + > > > + param.flag = 0; > > > + for (int i = 0; i < 5; i++) { > > > + param.size = SIZE[i]; > > > + ret = ioctl(self->fd, PCITEST_READ, ¶m); > > > + EXPECT_EQ(1, ret) { > > > + TH_LOG("TEST FAILED FOR size =%ld.\n", SIZE[i]); > > > + final++; > > > + } > > > + } > > > + > > > + ASSERT_EQ(0, final); > > > +} > > > + > > > +TEST_F(device, WRITE_TEST) > > > +{ > > > + int final = 0; > > > + int ret = -EINVAL; > > > + unsigned long SIZE[5] = {1, 1024, 1025, 1024000, 1024001}; > > > + > > > + ret = ioctl(self->fd, PCITEST_SET_IRQTYPE, 1); > > > + ASSERT_EQ(1, ret); > > > + > > > + struct xfer_param param; > > > + > > > + param.flag = 0; > > > + > > > + for (int i = 0; i < 5; i++) { > > > + param.size = SIZE[i]; > > > + ret = ioctl(self->fd, PCITEST_WRITE, ¶m); > > > + EXPECT_EQ(1, ret) { > > > + TH_LOG("TEST FAILED FOR size =%ld.\n", SIZE[i]); > > > + final++; > > > + } > > > + } > > > + > > > + ASSERT_EQ(0, final); > > > +} > > > + > > > +TEST_F(device, COPY_TEST) > > > +{ > > > + int final = 0; > > > + int ret = -EINVAL; > > > + unsigned long SIZE[5] = {1, 1024, 1025, 1024000, 1024001}; > > > + > > > + ret = ioctl(self->fd, PCITEST_SET_IRQTYPE, 1); > > > + ASSERT_EQ(1, ret); > > > + > > > + struct xfer_param param; > > > + > > > + param.flag = 0; > > > + > > > + for (int i = 0; i < 5; i++) { > > > + param.size = SIZE[i]; > > > + ret = ioctl(self->fd, PCITEST_COPY, ¶m); > > > + EXPECT_EQ(1, ret) { > > > + TH_LOG("TEST FAILED FOR size =%ld.\n", SIZE[i]); > > > + final++; > > > + } > > > + } > > > + > > > + ASSERT_EQ(0, final); > > > +} > > > +TEST_HARNESS_MAIN > > > > -- மணிவண்ணன் சதாசிவம்