Skip to content

Commit 442caca

Browse files
floatiousbjorn-helgaas
authored andcommitted
misc: pci_endpoint_test: Defer IRQ allocation until ioctl(PCITEST_SET_IRQTYPE)
Commit a402006 ("misc: pci_endpoint_test: Remove global 'irq_type' and 'no_msi'") changed so that the default IRQ vector requested by pci_endpoint_test_probe() was no longer the module param 'irq_type', but instead test->irq_type. test->irq_type is by default IRQ_TYPE_UNDEFINED (until someone calls ioctl(PCITEST_SET_IRQTYPE)). However, the commit also changed so that after initializing test->irq_type to IRQ_TYPE_UNDEFINED, it also overrides it with driver_data->irq_type, if the PCI device and vendor ID provides driver_data. This causes a regression for PCI device and vendor IDs that do not provide driver_data, and the host side pci_endpoint_test_driver driver failed to probe on such platforms: pci-endpoint-test 0001:01:00.0: Invalid IRQ type selected pci-endpoint-test 0001:01:00.0: probe with driver pci-endpoint-test failed with error -22 Considering that the pci endpoint selftests and the old pcitest.sh always call ioctl(PCITEST_SET_IRQTYPE) before performing any test that requires IRQs, fix the regression by removing the allocation of IRQs in pci_endpoint_test_probe(). The IRQ allocation will occur when ioctl(PCITEST_SET_IRQTYPE) is called. A positive side effect of this is that even if the endpoint controller has issues with IRQs, the user can do still do all the tests/ioctls() that do not require working IRQs, e.g. PCITEST_BAR and PCITEST_BARS. This also means that we can remove the now unused irq_type from driver_data. The irq_type will always be the one configured by the user using ioctl(PCITEST_SET_IRQTYPE). (A user that does not know, or care which irq_type that is used, can use PCITEST_IRQ_TYPE_AUTO. This has superseded the need for a default irq_type in driver_data.) [bhelgaas: add probe failure details] Fixes: a402006 ("misc: pci_endpoint_test: Remove global 'irq_type' and 'no_msi'") Signed-off-by: Niklas Cassel <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Tested-by: Frank Li <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]> Reviewed-by: Frank Li <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 0747c13 commit 442caca

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

drivers/misc/pci_endpoint_test.c

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ struct pci_endpoint_test {
122122
struct pci_endpoint_test_data {
123123
enum pci_barno test_reg_bar;
124124
size_t alignment;
125-
int irq_type;
126125
};
127126

128127
static inline u32 pci_endpoint_test_readl(struct pci_endpoint_test *test,
@@ -948,7 +947,6 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
948947
test_reg_bar = data->test_reg_bar;
949948
test->test_reg_bar = test_reg_bar;
950949
test->alignment = data->alignment;
951-
test->irq_type = data->irq_type;
952950
}
953951

954952
init_completion(&test->irq_raised);
@@ -970,10 +968,6 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
970968

971969
pci_set_master(pdev);
972970

973-
ret = pci_endpoint_test_alloc_irq_vectors(test, test->irq_type);
974-
if (ret)
975-
goto err_disable_irq;
976-
977971
for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) {
978972
if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) {
979973
base = pci_ioremap_bar(pdev, bar);
@@ -1009,18 +1003,14 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
10091003
goto err_ida_remove;
10101004
}
10111005

1012-
ret = pci_endpoint_test_request_irq(test);
1013-
if (ret)
1014-
goto err_kfree_test_name;
1015-
10161006
pci_endpoint_test_get_capabilities(test);
10171007

10181008
misc_device = &test->miscdev;
10191009
misc_device->minor = MISC_DYNAMIC_MINOR;
10201010
misc_device->name = kstrdup(name, GFP_KERNEL);
10211011
if (!misc_device->name) {
10221012
ret = -ENOMEM;
1023-
goto err_release_irq;
1013+
goto err_kfree_test_name;
10241014
}
10251015
misc_device->parent = &pdev->dev;
10261016
misc_device->fops = &pci_endpoint_test_fops;
@@ -1036,9 +1026,6 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
10361026
err_kfree_name:
10371027
kfree(misc_device->name);
10381028

1039-
err_release_irq:
1040-
pci_endpoint_test_release_irq(test);
1041-
10421029
err_kfree_test_name:
10431030
kfree(test->name);
10441031

@@ -1051,8 +1038,6 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
10511038
pci_iounmap(pdev, test->bar[bar]);
10521039
}
10531040

1054-
err_disable_irq:
1055-
pci_endpoint_test_free_irq_vectors(test);
10561041
pci_release_regions(pdev);
10571042

10581043
err_disable_pdev:
@@ -1092,23 +1077,19 @@ static void pci_endpoint_test_remove(struct pci_dev *pdev)
10921077
static const struct pci_endpoint_test_data default_data = {
10931078
.test_reg_bar = BAR_0,
10941079
.alignment = SZ_4K,
1095-
.irq_type = PCITEST_IRQ_TYPE_MSI,
10961080
};
10971081

10981082
static const struct pci_endpoint_test_data am654_data = {
10991083
.test_reg_bar = BAR_2,
11001084
.alignment = SZ_64K,
1101-
.irq_type = PCITEST_IRQ_TYPE_MSI,
11021085
};
11031086

11041087
static const struct pci_endpoint_test_data j721e_data = {
11051088
.alignment = 256,
1106-
.irq_type = PCITEST_IRQ_TYPE_MSI,
11071089
};
11081090

11091091
static const struct pci_endpoint_test_data rk3588_data = {
11101092
.alignment = SZ_64K,
1111-
.irq_type = PCITEST_IRQ_TYPE_MSI,
11121093
};
11131094

11141095
/*

0 commit comments

Comments
 (0)