@@ -82,6 +82,10 @@ static bool no_msi;
82
82
module_param (no_msi , bool , 0444 );
83
83
MODULE_PARM_DESC (no_msi , "Disable MSI interrupt in pci_endpoint_test" );
84
84
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
+
85
89
enum pci_barno {
86
90
BAR_0 ,
87
91
BAR_1 ,
@@ -108,7 +112,7 @@ struct pci_endpoint_test {
108
112
struct pci_endpoint_test_data {
109
113
enum pci_barno test_reg_bar ;
110
114
size_t alignment ;
111
- bool no_msi ;
115
+ int irq_type ;
112
116
};
113
117
114
118
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)
291
295
pci_endpoint_test_writel (test , PCI_ENDPOINT_TEST_SIZE ,
292
296
size );
293
297
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 );
296
299
pci_endpoint_test_writel (test , PCI_ENDPOINT_TEST_IRQ_NUMBER , 1 );
297
300
pci_endpoint_test_writel (test , PCI_ENDPOINT_TEST_COMMAND ,
298
301
COMMAND_COPY );
@@ -361,8 +364,7 @@ static bool pci_endpoint_test_write(struct pci_endpoint_test *test, size_t size)
361
364
362
365
pci_endpoint_test_writel (test , PCI_ENDPOINT_TEST_SIZE , size );
363
366
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 );
366
368
pci_endpoint_test_writel (test , PCI_ENDPOINT_TEST_IRQ_NUMBER , 1 );
367
369
pci_endpoint_test_writel (test , PCI_ENDPOINT_TEST_COMMAND ,
368
370
COMMAND_READ );
@@ -419,8 +421,7 @@ static bool pci_endpoint_test_read(struct pci_endpoint_test *test, size_t size)
419
421
420
422
pci_endpoint_test_writel (test , PCI_ENDPOINT_TEST_SIZE , size );
421
423
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 );
424
425
pci_endpoint_test_writel (test , PCI_ENDPOINT_TEST_IRQ_NUMBER , 1 );
425
426
pci_endpoint_test_writel (test , PCI_ENDPOINT_TEST_COMMAND ,
426
427
COMMAND_WRITE );
@@ -505,11 +506,14 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
505
506
test -> alignment = 0 ;
506
507
test -> pdev = pdev ;
507
508
509
+ if (no_msi )
510
+ irq_type = IRQ_TYPE_LEGACY ;
511
+
508
512
data = (struct pci_endpoint_test_data * )ent -> driver_data ;
509
513
if (data ) {
510
514
test_reg_bar = data -> test_reg_bar ;
511
515
test -> alignment = data -> alignment ;
512
- no_msi = data -> no_msi ;
516
+ irq_type = data -> irq_type ;
513
517
}
514
518
515
519
init_completion (& test -> irq_raised );
@@ -529,11 +533,17 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
529
533
530
534
pci_set_master (pdev );
531
535
532
- if (!no_msi ) {
536
+ switch (irq_type ) {
537
+ case IRQ_TYPE_LEGACY :
538
+ break ;
539
+ case IRQ_TYPE_MSI :
533
540
irq = pci_alloc_irq_vectors (pdev , 1 , 32 , PCI_IRQ_MSI );
534
541
if (irq < 0 )
535
542
dev_err (dev , "Failed to get MSI interrupts\n" );
536
543
test -> num_irqs = irq ;
544
+ break ;
545
+ default :
546
+ dev_err (dev , "Invalid IRQ type selected\n" );
537
547
}
538
548
539
549
err = devm_request_irq (dev , pdev -> irq , pci_endpoint_test_irqhandler ,
0 commit comments