Skip to content

Commit 9133e39

Browse files
gustavoSNPSLorenzo Pieralisi
authored andcommitted
pci-epf-test/pci_endpoint_test: Use irq_type module parameter
Add new driver parameter to allow interruption type selection. Signed-off-by: Gustavo Pimentel <[email protected]> Signed-off-by: Lorenzo Pieralisi <[email protected]> Acked-by: Kishon Vijay Abraham I <[email protected]>
1 parent e8817de commit 9133e39

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

drivers/misc/pci_endpoint_test.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ static bool no_msi;
8282
module_param(no_msi, bool, 0444);
8383
MODULE_PARM_DESC(no_msi, "Disable MSI interrupt in pci_endpoint_test");
8484

85+
static int irq_type = IRQ_TYPE_MSI;
86+
module_param(irq_type, int, 0444);
87+
MODULE_PARM_DESC(irq_type, "IRQ mode selection in pci_endpoint_test (0 - Legacy, 1 - MSI)");
88+
8589
enum pci_barno {
8690
BAR_0,
8791
BAR_1,
@@ -108,7 +112,7 @@ struct pci_endpoint_test {
108112
struct pci_endpoint_test_data {
109113
enum pci_barno test_reg_bar;
110114
size_t alignment;
111-
bool no_msi;
115+
int irq_type;
112116
};
113117

114118
static inline u32 pci_endpoint_test_readl(struct pci_endpoint_test *test,
@@ -291,8 +295,7 @@ static bool pci_endpoint_test_copy(struct pci_endpoint_test *test, size_t size)
291295
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_SIZE,
292296
size);
293297

294-
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_TYPE,
295-
no_msi ? IRQ_TYPE_LEGACY : IRQ_TYPE_MSI);
298+
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_TYPE, irq_type);
296299
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_NUMBER, 1);
297300
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_COMMAND,
298301
COMMAND_COPY);
@@ -361,8 +364,7 @@ static bool pci_endpoint_test_write(struct pci_endpoint_test *test, size_t size)
361364

362365
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_SIZE, size);
363366

364-
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_TYPE,
365-
no_msi ? IRQ_TYPE_LEGACY : IRQ_TYPE_MSI);
367+
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_TYPE, irq_type);
366368
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_NUMBER, 1);
367369
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_COMMAND,
368370
COMMAND_READ);
@@ -419,8 +421,7 @@ static bool pci_endpoint_test_read(struct pci_endpoint_test *test, size_t size)
419421

420422
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_SIZE, size);
421423

422-
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_TYPE,
423-
no_msi ? IRQ_TYPE_LEGACY : IRQ_TYPE_MSI);
424+
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_TYPE, irq_type);
424425
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_NUMBER, 1);
425426
pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_COMMAND,
426427
COMMAND_WRITE);
@@ -505,11 +506,14 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
505506
test->alignment = 0;
506507
test->pdev = pdev;
507508

509+
if (no_msi)
510+
irq_type = IRQ_TYPE_LEGACY;
511+
508512
data = (struct pci_endpoint_test_data *)ent->driver_data;
509513
if (data) {
510514
test_reg_bar = data->test_reg_bar;
511515
test->alignment = data->alignment;
512-
no_msi = data->no_msi;
516+
irq_type = data->irq_type;
513517
}
514518

515519
init_completion(&test->irq_raised);
@@ -529,11 +533,17 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
529533

530534
pci_set_master(pdev);
531535

532-
if (!no_msi) {
536+
switch (irq_type) {
537+
case IRQ_TYPE_LEGACY:
538+
break;
539+
case IRQ_TYPE_MSI:
533540
irq = pci_alloc_irq_vectors(pdev, 1, 32, PCI_IRQ_MSI);
534541
if (irq < 0)
535542
dev_err(dev, "Failed to get MSI interrupts\n");
536543
test->num_irqs = irq;
544+
break;
545+
default:
546+
dev_err(dev, "Invalid IRQ type selected\n");
537547
}
538548

539549
err = devm_request_irq(dev, pdev->irq, pci_endpoint_test_irqhandler,

0 commit comments

Comments
 (0)