Skip to content

Commit b2ba922

Browse files
kishonLorenzo Pieralisi
authored andcommitted
misc: pci_endpoint_test: Avoid using module parameter to determine irqtype
commit e033271 ("pci_endpoint_test: Add 2 ioctl commands") uses module parameter 'irqtype' in pci_endpoint_test_set_irq() to check if IRQ vectors of a particular type (MSI or MSI-X or LEGACY) is already allocated. However with multi-function devices, 'irqtype' will not correctly reflect the IRQ type of the PCI device. Fix it here by adding 'irqtype' for each PCI device to show the IRQ type of a particular PCI device. Fixes: e033271 ("pci_endpoint_test: Add 2 ioctl commands") Signed-off-by: Kishon Vijay Abraham I <[email protected]> Signed-off-by: Lorenzo Pieralisi <[email protected]> Cc: [email protected] # v4.19+
1 parent 146d328 commit b2ba922

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

drivers/misc/pci_endpoint_test.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ struct pci_endpoint_test {
103103
struct completion irq_raised;
104104
int last_irq;
105105
int num_irqs;
106+
int irq_type;
106107
/* mutex to protect the ioctls */
107108
struct mutex mutex;
108109
struct miscdevice miscdev;
@@ -162,6 +163,7 @@ static void pci_endpoint_test_free_irq_vectors(struct pci_endpoint_test *test)
162163
struct pci_dev *pdev = test->pdev;
163164

164165
pci_free_irq_vectors(pdev);
166+
test->irq_type = IRQ_TYPE_UNDEFINED;
165167
}
166168

167169
static bool pci_endpoint_test_alloc_irq_vectors(struct pci_endpoint_test *test,
@@ -196,6 +198,8 @@ static bool pci_endpoint_test_alloc_irq_vectors(struct pci_endpoint_test *test,
196198
irq = 0;
197199
res = false;
198200
}
201+
202+
test->irq_type = type;
199203
test->num_irqs = irq;
200204

201205
return res;
@@ -340,6 +344,7 @@ static bool pci_endpoint_test_copy(struct pci_endpoint_test *test,
340344
dma_addr_t orig_dst_phys_addr;
341345
size_t offset;
342346
size_t alignment = test->alignment;
347+
int irq_type = test->irq_type;
343348
u32 src_crc32;
344349
u32 dst_crc32;
345350
int err;
@@ -473,6 +478,7 @@ static bool pci_endpoint_test_write(struct pci_endpoint_test *test,
473478
dma_addr_t orig_phys_addr;
474479
size_t offset;
475480
size_t alignment = test->alignment;
481+
int irq_type = test->irq_type;
476482
size_t size;
477483
u32 crc32;
478484
int err;
@@ -571,6 +577,7 @@ static bool pci_endpoint_test_read(struct pci_endpoint_test *test,
571577
dma_addr_t orig_phys_addr;
572578
size_t offset;
573579
size_t alignment = test->alignment;
580+
int irq_type = test->irq_type;
574581
u32 crc32;
575582
int err;
576583

@@ -656,7 +663,7 @@ static bool pci_endpoint_test_set_irq(struct pci_endpoint_test *test,
656663
return false;
657664
}
658665

659-
if (irq_type == req_irq_type)
666+
if (test->irq_type == req_irq_type)
660667
return true;
661668

662669
pci_endpoint_test_release_irq(test);
@@ -668,12 +675,10 @@ static bool pci_endpoint_test_set_irq(struct pci_endpoint_test *test,
668675
if (!pci_endpoint_test_request_irq(test))
669676
goto err;
670677

671-
irq_type = req_irq_type;
672678
return true;
673679

674680
err:
675681
pci_endpoint_test_free_irq_vectors(test);
676-
irq_type = IRQ_TYPE_UNDEFINED;
677682
return false;
678683
}
679684

@@ -753,6 +758,7 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
753758
test->test_reg_bar = 0;
754759
test->alignment = 0;
755760
test->pdev = pdev;
761+
test->irq_type = IRQ_TYPE_UNDEFINED;
756762

757763
if (no_msi)
758764
irq_type = IRQ_TYPE_LEGACY;

0 commit comments

Comments
 (0)