Skip to content

Commit 92db71b

Browse files
author
Myron Stowe
committed
misc: pci_endpoint_test: Defer IRQ allocation until ioctl(PCITEST_SET_IRQTYPE)
JIRA: https://issues.redhat.com/browse/RHEL-86521 Upstream Status: 442caca commit 442caca Author: Niklas Cassel <cassel@kernel.org> Date: Wed Apr 16 16:28:26 2025 +0200 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 <cassel@kernel.org> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Tested-by: Frank Li <Frank.Li@nxp.com> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Reviewed-by: Frank Li <Frank.Li@nxp.com> Link: https://patch.msgid.link/20250416142825.336554-2-cassel@kernel.org Signed-off-by: Myron Stowe <mstowe@redhat.com>
1 parent a7062ea commit 92db71b

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
@@ -123,7 +123,6 @@ struct pci_endpoint_test {
123123
struct pci_endpoint_test_data {
124124
enum pci_barno test_reg_bar;
125125
size_t alignment;
126-
int irq_type;
127126
};
128127

129128
static inline u32 pci_endpoint_test_readl(struct pci_endpoint_test *test,
@@ -949,7 +948,6 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
949948
test_reg_bar = data->test_reg_bar;
950949
test->test_reg_bar = test_reg_bar;
951950
test->alignment = data->alignment;
952-
test->irq_type = data->irq_type;
953951
}
954952

955953
init_completion(&test->irq_raised);
@@ -971,10 +969,6 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
971969

972970
pci_set_master(pdev);
973971

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

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

10191009
misc_device = &test->miscdev;
10201010
misc_device->minor = MISC_DYNAMIC_MINOR;
10211011
misc_device->name = kstrdup(name, GFP_KERNEL);
10221012
if (!misc_device->name) {
10231013
ret = -ENOMEM;
1024-
goto err_release_irq;
1014+
goto err_kfree_test_name;
10251015
}
10261016
misc_device->parent = &pdev->dev;
10271017
misc_device->fops = &pci_endpoint_test_fops;
@@ -1037,9 +1027,6 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
10371027
err_kfree_name:
10381028
kfree(misc_device->name);
10391029

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

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

1055-
err_disable_irq:
1056-
pci_endpoint_test_free_irq_vectors(test);
10571042
pci_release_regions(pdev);
10581043

10591044
err_disable_pdev:
@@ -1093,23 +1078,19 @@ static void pci_endpoint_test_remove(struct pci_dev *pdev)
10931078
static const struct pci_endpoint_test_data default_data = {
10941079
.test_reg_bar = BAR_0,
10951080
.alignment = SZ_4K,
1096-
.irq_type = PCITEST_IRQ_TYPE_MSI,
10971081
};
10981082

10991083
static const struct pci_endpoint_test_data am654_data = {
11001084
.test_reg_bar = BAR_2,
11011085
.alignment = SZ_64K,
1102-
.irq_type = PCITEST_IRQ_TYPE_MSI,
11031086
};
11041087

11051088
static const struct pci_endpoint_test_data j721e_data = {
11061089
.alignment = 256,
1107-
.irq_type = PCITEST_IRQ_TYPE_MSI,
11081090
};
11091091

11101092
static const struct pci_endpoint_test_data rk3588_data = {
11111093
.alignment = SZ_64K,
1112-
.irq_type = PCITEST_IRQ_TYPE_MSI,
11131094
};
11141095

11151096
/*

0 commit comments

Comments
 (0)