2020-03-17 09:58:20

by Kishon Vijay Abraham I

[permalink] [raw]
Subject: [PATCH v2 0/5] misc: Improvements to pci_endpoint_test driver

This series adds improvements and fixes to pci_endpoint_test driver
mostly applicable when used with multi-function endpoint (or multiple
endpoint instances using pci_epf_test).

*) Using module parameter to determine irqtype would indicate all the
pci_endpoint_test device have the same irqtype. Fix it here.
*) Add ioctl to clear irq so that "cat /proc/interrupts" only lists
the entries for the devices that is actually being used.
*) Creating more than 10 pci-endpoint-test devices results in a kernel
error.
*) Use full pci-endpoint-test name in request irq so that it's easy to
profile the interrupt details in "cat /proc/interrupts"

Changes from v1:
*) Removed a patch that references J721E device ID (That patch will
be added as part of J721E support series)
*) Removed a patch that always enable legacy interrupt. That should
be handled by pci_alloc_irq_vectors()

Kishon Vijay Abraham I (5):
misc: pci_endpoint_test: Avoid using module parameter to determine
irqtype
misc: pci_endpoint_test: Add ioctl to clear IRQ
tools: PCI: Add 'e' to clear IRQ
misc: pci_endpoint_test: Fix to support > 10 pci-endpoint-test devices
misc: pci_endpoint_test: Use full pci-endpoint-test name in request
irq

drivers/misc/pci_endpoint_test.c | 49 +++++++++++++++++++++++++-------
include/uapi/linux/pcitest.h | 1 +
tools/pci/pcitest.c | 16 ++++++++++-
3 files changed, 55 insertions(+), 11 deletions(-)

--
2.17.1


2020-03-17 09:58:25

by Kishon Vijay Abraham I

[permalink] [raw]
Subject: [PATCH v2 4/5] misc: pci_endpoint_test: Fix to support > 10 pci-endpoint-test devices

Adding more than 10 pci-endpoint-test devices results in
"kobject_add_internal failed for pci-endpoint-test.1 with -EEXIST, don't
try to register things with the same name in the same directory". This
is because commit 2c156ac71c6b ("misc: Add host side PCI driver for PCI
test function device") limited the length of the "name" to 20 characters.
Change the length of the name to 24 in order to support upto 10000
pci-endpoint-test devices.

Fixes: 2c156ac71c6b ("misc: Add host side PCI driver for PCI test function device")
Cc: [email protected] # v4.14+
Signed-off-by: Kishon Vijay Abraham I <[email protected]>
---
drivers/misc/pci_endpoint_test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
index bb8b94ac8d3b..ef21d2d2f8ae 100644
--- a/drivers/misc/pci_endpoint_test.c
+++ b/drivers/misc/pci_endpoint_test.c
@@ -749,7 +749,7 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
{
int err;
int id;
- char name[20];
+ char name[24];
enum pci_barno bar;
void __iomem *base;
struct device *dev = &pdev->dev;
--
2.17.1

2020-03-17 09:58:48

by Kishon Vijay Abraham I

[permalink] [raw]
Subject: [PATCH v2 3/5] tools: PCI: Add 'e' to clear IRQ

Add a new command line option 'e' to invoke "PCITEST_CLEAR_IRQ"
ioctl. This can be used to clear the irqs set using the 'i' option.

Signed-off-by: Kishon Vijay Abraham I <[email protected]>
---
tools/pci/pcitest.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/tools/pci/pcitest.c b/tools/pci/pcitest.c
index 5e3b6368c5e0..0a1344c45213 100644
--- a/tools/pci/pcitest.c
+++ b/tools/pci/pcitest.c
@@ -30,6 +30,7 @@ struct pci_test {
int irqtype;
bool set_irqtype;
bool get_irqtype;
+ bool clear_irq;
bool read;
bool write;
bool copy;
@@ -76,6 +77,15 @@ static int run_test(struct pci_test *test)
fprintf(stdout, "%s\n", irq[ret]);
}

+ if (test->clear_irq) {
+ ret = ioctl(fd, PCITEST_CLEAR_IRQ);
+ fprintf(stdout, "CLEAR IRQ:\t\t");
+ if (ret < 0)
+ fprintf(stdout, "FAILED\n");
+ else
+ fprintf(stdout, "%s\n", result[ret]);
+ }
+
if (test->legacyirq) {
ret = ioctl(fd, PCITEST_LEGACY_IRQ, 0);
fprintf(stdout, "LEGACY IRQ:\t");
@@ -164,7 +174,7 @@ int main(int argc, char **argv)
/* set default endpoint device */
test->device = "/dev/pci-endpoint-test.0";

- while ((c = getopt(argc, argv, "D:b:m:x:i:dIlhrwcs:")) != EOF)
+ while ((c = getopt(argc, argv, "D:b:m:x:i:deIlhrwcs:")) != EOF)
switch (c) {
case 'D':
test->device = optarg;
@@ -205,6 +215,9 @@ int main(int argc, char **argv)
case 'c':
test->copy = true;
continue;
+ case 'e':
+ test->clear_irq = true;
+ continue;
case 's':
test->size = strtoul(optarg, NULL, 0);
continue;
@@ -222,6 +235,7 @@ int main(int argc, char **argv)
"\t-m <msi num> MSI test (msi number between 1..32)\n"
"\t-x <msix num> \tMSI-X test (msix number between 1..2048)\n"
"\t-i <irq type> \tSet IRQ type (0 - Legacy, 1 - MSI, 2 - MSI-X)\n"
+ "\t-e Clear IRQ\n"
"\t-I Get current IRQ type configured\n"
"\t-d Use DMA\n"
"\t-l Legacy IRQ test\n"
--
2.17.1

2020-03-17 09:59:47

by Kishon Vijay Abraham I

[permalink] [raw]
Subject: [PATCH v2 5/5] misc: pci_endpoint_test: Use full pci-endpoint-test name in request irq

Use full pci-endpoint-test name in request irq, so that it's easy to
profile the device that actually raised the interrupt.

Signed-off-by: Kishon Vijay Abraham I <[email protected]>
---
drivers/misc/pci_endpoint_test.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
index ef21d2d2f8ae..bc3ae4a4fb5c 100644
--- a/drivers/misc/pci_endpoint_test.c
+++ b/drivers/misc/pci_endpoint_test.c
@@ -109,6 +109,7 @@ struct pci_endpoint_test {
struct miscdevice miscdev;
enum pci_barno test_reg_bar;
size_t alignment;
+ const char *name;
};

struct pci_endpoint_test_data {
@@ -227,7 +228,7 @@ static bool pci_endpoint_test_request_irq(struct pci_endpoint_test *test)
for (i = 0; i < test->num_irqs; i++) {
err = devm_request_irq(dev, pci_irq_vector(pdev, i),
pci_endpoint_test_irqhandler,
- IRQF_SHARED, DRV_MODULE_NAME, test);
+ IRQF_SHARED, test->name, test);
if (err)
goto fail;
}
@@ -807,9 +808,6 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
if (!pci_endpoint_test_alloc_irq_vectors(test, irq_type))
goto err_disable_irq;

- if (!pci_endpoint_test_request_irq(test))
- goto err_disable_irq;
-
for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) {
if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) {
base = pci_ioremap_bar(pdev, bar);
@@ -839,12 +837,21 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
}

snprintf(name, sizeof(name), DRV_MODULE_NAME ".%d", id);
+ test->name = kstrdup(name, GFP_KERNEL);
+ if (!test->name) {
+ err = -ENOMEM;
+ goto err_ida_remove;
+ }
+
+ if (!pci_endpoint_test_request_irq(test))
+ goto err_kfree_test_name;
+
misc_device = &test->miscdev;
misc_device->minor = MISC_DYNAMIC_MINOR;
misc_device->name = kstrdup(name, GFP_KERNEL);
if (!misc_device->name) {
err = -ENOMEM;
- goto err_ida_remove;
+ goto err_release_irq;
}
misc_device->fops = &pci_endpoint_test_fops,

@@ -859,6 +866,12 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
err_kfree_name:
kfree(misc_device->name);

+err_release_irq:
+ pci_endpoint_test_release_irq(test);
+
+err_kfree_test_name:
+ kfree(test->name);
+
err_ida_remove:
ida_simple_remove(&pci_endpoint_test_ida, id);

@@ -867,7 +880,6 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
if (test->bar[bar])
pci_iounmap(pdev, test->bar[bar]);
}
- pci_endpoint_test_release_irq(test);

err_disable_irq:
pci_endpoint_test_free_irq_vectors(test);
@@ -893,6 +905,7 @@ static void pci_endpoint_test_remove(struct pci_dev *pdev)

misc_deregister(&test->miscdev);
kfree(misc_device->name);
+ kfree(test->name);
ida_simple_remove(&pci_endpoint_test_ida, id);
for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) {
if (test->bar[bar])
--
2.17.1

2020-03-20 09:52:53

by Lorenzo Pieralisi

[permalink] [raw]
Subject: Re: [PATCH v2 0/5] misc: Improvements to pci_endpoint_test driver

On Tue, Mar 17, 2020 at 03:31:53PM +0530, Kishon Vijay Abraham I wrote:
> This series adds improvements and fixes to pci_endpoint_test driver
> mostly applicable when used with multi-function endpoint (or multiple
> endpoint instances using pci_epf_test).
>
> *) Using module parameter to determine irqtype would indicate all the
> pci_endpoint_test device have the same irqtype. Fix it here.
> *) Add ioctl to clear irq so that "cat /proc/interrupts" only lists
> the entries for the devices that is actually being used.
> *) Creating more than 10 pci-endpoint-test devices results in a kernel
> error.
> *) Use full pci-endpoint-test name in request irq so that it's easy to
> profile the interrupt details in "cat /proc/interrupts"
>
> Changes from v1:
> *) Removed a patch that references J721E device ID (That patch will
> be added as part of J721E support series)
> *) Removed a patch that always enable legacy interrupt. That should
> be handled by pci_alloc_irq_vectors()
>
> Kishon Vijay Abraham I (5):
> misc: pci_endpoint_test: Avoid using module parameter to determine
> irqtype
> misc: pci_endpoint_test: Add ioctl to clear IRQ
> tools: PCI: Add 'e' to clear IRQ
> misc: pci_endpoint_test: Fix to support > 10 pci-endpoint-test devices
> misc: pci_endpoint_test: Use full pci-endpoint-test name in request
> irq
>
> drivers/misc/pci_endpoint_test.c | 49 +++++++++++++++++++++++++-------
> include/uapi/linux/pcitest.h | 1 +
> tools/pci/pcitest.c | 16 ++++++++++-
> 3 files changed, 55 insertions(+), 11 deletions(-)

Applied to pci/endpoint for v5.7.

Thanks,
Lorenzo