diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2019-05-13 19:34:44 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2019-05-13 19:34:44 -0400 |
commit | ee6df38da8485b143cc5eccee569ae3e238be10a (patch) | |
tree | 3afa71556e0a905522552f98ae45cb98b70bc899 | |
parent | ed0eaf320571ca3992ca73144f87984c5770bf5e (diff) | |
parent | 507b820009a457afa78202da337bcb56791fbb12 (diff) |
Merge branch 'remotes/lorenzo/pci/misc'
- Exit pcitest with error code when test fails (Jean-Jacques Hiblot)
- Fix leaked of_node references in dra7xx, uniphier, layerscape,
rockchip, aardvark, iproc, mediatek, rpadlpar (Wen Yang)
- Fix pcitest "help" option parsing (Kishon Vijay Abraham I)
- Fix Makefile bug that inadvertently removes pcitest.sh (Kishon Vijay
Abraham I)
- Check for alloc_workqueue() failure in endpoint test driver (Kangjie
Lu)
* remotes/lorenzo/pci/misc:
PCI: endpoint: Fix a potential NULL pointer dereference
tools: PCI: Handle pcitest.sh independently from pcitest
tools: PCI: Add 'h' in optstring of getopt()
PCI: mediatek: Fix a leaked reference by adding missing of_node_put()
PCI: iproc: Fix a leaked reference by adding missing of_node_put()
PCI: aardvark: Fix a leaked reference by adding missing of_node_put()
PCI: rockchip: Fix a leaked reference by adding missing of_node_put()
PCI: dwc: layerscape: Fix a leaked reference by adding missing of_node_put()
PCI: uniphier: Fix a leaked reference by adding missing of_node_put()
PCI: dwc: pci-dra7xx: Fix a leaked reference by adding missing of_node_put()
tools: PCI: Exit with error code when test fails
-rw-r--r-- | drivers/pci/controller/dwc/pci-dra7xx.c | 1 | ||||
-rw-r--r-- | drivers/pci/controller/dwc/pci-layerscape.c | 1 | ||||
-rw-r--r-- | drivers/pci/controller/dwc/pcie-uniphier.c | 11 | ||||
-rw-r--r-- | drivers/pci/controller/pci-aardvark.c | 13 | ||||
-rw-r--r-- | drivers/pci/controller/pcie-iproc.c | 8 | ||||
-rw-r--r-- | drivers/pci/controller/pcie-mediatek.c | 1 | ||||
-rw-r--r-- | drivers/pci/controller/pcie-rockchip-host.c | 1 | ||||
-rw-r--r-- | drivers/pci/endpoint/functions/pci-epf-test.c | 5 | ||||
-rw-r--r-- | tools/pci/Makefile | 8 | ||||
-rw-r--r-- | tools/pci/pcitest.c | 8 |
10 files changed, 42 insertions, 15 deletions
diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c b/drivers/pci/controller/dwc/pci-dra7xx.c index b287dbf6914c..419451efd58c 100644 --- a/drivers/pci/controller/dwc/pci-dra7xx.c +++ b/drivers/pci/controller/dwc/pci-dra7xx.c | |||
@@ -247,6 +247,7 @@ static int dra7xx_pcie_init_irq_domain(struct pcie_port *pp) | |||
247 | 247 | ||
248 | dra7xx->irq_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, | 248 | dra7xx->irq_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, |
249 | &intx_domain_ops, pp); | 249 | &intx_domain_ops, pp); |
250 | of_node_put(pcie_intc_node); | ||
250 | if (!dra7xx->irq_domain) { | 251 | if (!dra7xx->irq_domain) { |
251 | dev_err(dev, "Failed to get a INTx IRQ domain\n"); | 252 | dev_err(dev, "Failed to get a INTx IRQ domain\n"); |
252 | return -ENODEV; | 253 | return -ENODEV; |
diff --git a/drivers/pci/controller/dwc/pci-layerscape.c b/drivers/pci/controller/dwc/pci-layerscape.c index ce45bde29bf8..3a5fa26d5e56 100644 --- a/drivers/pci/controller/dwc/pci-layerscape.c +++ b/drivers/pci/controller/dwc/pci-layerscape.c | |||
@@ -201,6 +201,7 @@ static int ls_pcie_msi_host_init(struct pcie_port *pp) | |||
201 | return -EINVAL; | 201 | return -EINVAL; |
202 | } | 202 | } |
203 | 203 | ||
204 | of_node_put(msi_node); | ||
204 | return 0; | 205 | return 0; |
205 | } | 206 | } |
206 | 207 | ||
diff --git a/drivers/pci/controller/dwc/pcie-uniphier.c b/drivers/pci/controller/dwc/pcie-uniphier.c index d5dc40289cce..3f30ee4a00b3 100644 --- a/drivers/pci/controller/dwc/pcie-uniphier.c +++ b/drivers/pci/controller/dwc/pcie-uniphier.c | |||
@@ -270,6 +270,7 @@ static int uniphier_pcie_config_legacy_irq(struct pcie_port *pp) | |||
270 | struct uniphier_pcie_priv *priv = to_uniphier_pcie(pci); | 270 | struct uniphier_pcie_priv *priv = to_uniphier_pcie(pci); |
271 | struct device_node *np = pci->dev->of_node; | 271 | struct device_node *np = pci->dev->of_node; |
272 | struct device_node *np_intc; | 272 | struct device_node *np_intc; |
273 | int ret = 0; | ||
273 | 274 | ||
274 | np_intc = of_get_child_by_name(np, "legacy-interrupt-controller"); | 275 | np_intc = of_get_child_by_name(np, "legacy-interrupt-controller"); |
275 | if (!np_intc) { | 276 | if (!np_intc) { |
@@ -280,20 +281,24 @@ static int uniphier_pcie_config_legacy_irq(struct pcie_port *pp) | |||
280 | pp->irq = irq_of_parse_and_map(np_intc, 0); | 281 | pp->irq = irq_of_parse_and_map(np_intc, 0); |
281 | if (!pp->irq) { | 282 | if (!pp->irq) { |
282 | dev_err(pci->dev, "Failed to get an IRQ entry in legacy-interrupt-controller\n"); | 283 | dev_err(pci->dev, "Failed to get an IRQ entry in legacy-interrupt-controller\n"); |
283 | return -EINVAL; | 284 | ret = -EINVAL; |
285 | goto out_put_node; | ||
284 | } | 286 | } |
285 | 287 | ||
286 | priv->legacy_irq_domain = irq_domain_add_linear(np_intc, PCI_NUM_INTX, | 288 | priv->legacy_irq_domain = irq_domain_add_linear(np_intc, PCI_NUM_INTX, |
287 | &uniphier_intx_domain_ops, pp); | 289 | &uniphier_intx_domain_ops, pp); |
288 | if (!priv->legacy_irq_domain) { | 290 | if (!priv->legacy_irq_domain) { |
289 | dev_err(pci->dev, "Failed to get INTx domain\n"); | 291 | dev_err(pci->dev, "Failed to get INTx domain\n"); |
290 | return -ENODEV; | 292 | ret = -ENODEV; |
293 | goto out_put_node; | ||
291 | } | 294 | } |
292 | 295 | ||
293 | irq_set_chained_handler_and_data(pp->irq, uniphier_pcie_irq_handler, | 296 | irq_set_chained_handler_and_data(pp->irq, uniphier_pcie_irq_handler, |
294 | pp); | 297 | pp); |
295 | 298 | ||
296 | return 0; | 299 | out_put_node: |
300 | of_node_put(np_intc); | ||
301 | return ret; | ||
297 | } | 302 | } |
298 | 303 | ||
299 | static int uniphier_pcie_host_init(struct pcie_port *pp) | 304 | static int uniphier_pcie_host_init(struct pcie_port *pp) |
diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index eb58dfdaba1b..134e0306ff00 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c | |||
@@ -794,6 +794,7 @@ static int advk_pcie_init_irq_domain(struct advk_pcie *pcie) | |||
794 | struct device_node *node = dev->of_node; | 794 | struct device_node *node = dev->of_node; |
795 | struct device_node *pcie_intc_node; | 795 | struct device_node *pcie_intc_node; |
796 | struct irq_chip *irq_chip; | 796 | struct irq_chip *irq_chip; |
797 | int ret = 0; | ||
797 | 798 | ||
798 | pcie_intc_node = of_get_next_child(node, NULL); | 799 | pcie_intc_node = of_get_next_child(node, NULL); |
799 | if (!pcie_intc_node) { | 800 | if (!pcie_intc_node) { |
@@ -806,8 +807,8 @@ static int advk_pcie_init_irq_domain(struct advk_pcie *pcie) | |||
806 | irq_chip->name = devm_kasprintf(dev, GFP_KERNEL, "%s-irq", | 807 | irq_chip->name = devm_kasprintf(dev, GFP_KERNEL, "%s-irq", |
807 | dev_name(dev)); | 808 | dev_name(dev)); |
808 | if (!irq_chip->name) { | 809 | if (!irq_chip->name) { |
809 | of_node_put(pcie_intc_node); | 810 | ret = -ENOMEM; |
810 | return -ENOMEM; | 811 | goto out_put_node; |
811 | } | 812 | } |
812 | 813 | ||
813 | irq_chip->irq_mask = advk_pcie_irq_mask; | 814 | irq_chip->irq_mask = advk_pcie_irq_mask; |
@@ -819,11 +820,13 @@ static int advk_pcie_init_irq_domain(struct advk_pcie *pcie) | |||
819 | &advk_pcie_irq_domain_ops, pcie); | 820 | &advk_pcie_irq_domain_ops, pcie); |
820 | if (!pcie->irq_domain) { | 821 | if (!pcie->irq_domain) { |
821 | dev_err(dev, "Failed to get a INTx IRQ domain\n"); | 822 | dev_err(dev, "Failed to get a INTx IRQ domain\n"); |
822 | of_node_put(pcie_intc_node); | 823 | ret = -ENOMEM; |
823 | return -ENOMEM; | 824 | goto out_put_node; |
824 | } | 825 | } |
825 | 826 | ||
826 | return 0; | 827 | out_put_node: |
828 | of_node_put(pcie_intc_node); | ||
829 | return ret; | ||
827 | } | 830 | } |
828 | 831 | ||
829 | static void advk_pcie_remove_irq_domain(struct advk_pcie *pcie) | 832 | static void advk_pcie_remove_irq_domain(struct advk_pcie *pcie) |
diff --git a/drivers/pci/controller/pcie-iproc.c b/drivers/pci/controller/pcie-iproc.c index dd11d0226ff0..aa4768a2c0ca 100644 --- a/drivers/pci/controller/pcie-iproc.c +++ b/drivers/pci/controller/pcie-iproc.c | |||
@@ -1356,14 +1356,18 @@ static int iproc_pcie_msi_enable(struct iproc_pcie *pcie) | |||
1356 | if (pcie->need_msi_steer) { | 1356 | if (pcie->need_msi_steer) { |
1357 | ret = iproc_pcie_msi_steer(pcie, msi_node); | 1357 | ret = iproc_pcie_msi_steer(pcie, msi_node); |
1358 | if (ret) | 1358 | if (ret) |
1359 | return ret; | 1359 | goto out_put_node; |
1360 | } | 1360 | } |
1361 | 1361 | ||
1362 | /* | 1362 | /* |
1363 | * If another MSI controller is being used, the call below should fail | 1363 | * If another MSI controller is being used, the call below should fail |
1364 | * but that is okay | 1364 | * but that is okay |
1365 | */ | 1365 | */ |
1366 | return iproc_msi_init(pcie, msi_node); | 1366 | ret = iproc_msi_init(pcie, msi_node); |
1367 | |||
1368 | out_put_node: | ||
1369 | of_node_put(msi_node); | ||
1370 | return ret; | ||
1367 | } | 1371 | } |
1368 | 1372 | ||
1369 | static void iproc_pcie_msi_disable(struct iproc_pcie *pcie) | 1373 | static void iproc_pcie_msi_disable(struct iproc_pcie *pcie) |
diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c index adb6cb15daa2..80601e1b939e 100644 --- a/drivers/pci/controller/pcie-mediatek.c +++ b/drivers/pci/controller/pcie-mediatek.c | |||
@@ -578,6 +578,7 @@ static int mtk_pcie_init_irq_domain(struct mtk_pcie_port *port, | |||
578 | 578 | ||
579 | port->irq_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, | 579 | port->irq_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, |
580 | &intx_domain_ops, port); | 580 | &intx_domain_ops, port); |
581 | of_node_put(pcie_intc_node); | ||
581 | if (!port->irq_domain) { | 582 | if (!port->irq_domain) { |
582 | dev_err(dev, "failed to get INTx IRQ domain\n"); | 583 | dev_err(dev, "failed to get INTx IRQ domain\n"); |
583 | return -ENODEV; | 584 | return -ENODEV; |
diff --git a/drivers/pci/controller/pcie-rockchip-host.c b/drivers/pci/controller/pcie-rockchip-host.c index 1372d270764f..8d20f1793a61 100644 --- a/drivers/pci/controller/pcie-rockchip-host.c +++ b/drivers/pci/controller/pcie-rockchip-host.c | |||
@@ -724,6 +724,7 @@ static int rockchip_pcie_init_irq_domain(struct rockchip_pcie *rockchip) | |||
724 | 724 | ||
725 | rockchip->irq_domain = irq_domain_add_linear(intc, PCI_NUM_INTX, | 725 | rockchip->irq_domain = irq_domain_add_linear(intc, PCI_NUM_INTX, |
726 | &intx_domain_ops, rockchip); | 726 | &intx_domain_ops, rockchip); |
727 | of_node_put(intc); | ||
727 | if (!rockchip->irq_domain) { | 728 | if (!rockchip->irq_domain) { |
728 | dev_err(dev, "failed to get a INTx IRQ domain\n"); | 729 | dev_err(dev, "failed to get a INTx IRQ domain\n"); |
729 | return -EINVAL; | 730 | return -EINVAL; |
diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c index c0786ca74312..27806987e93b 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c | |||
@@ -592,6 +592,11 @@ static int __init pci_epf_test_init(void) | |||
592 | 592 | ||
593 | kpcitest_workqueue = alloc_workqueue("kpcitest", | 593 | kpcitest_workqueue = alloc_workqueue("kpcitest", |
594 | WQ_MEM_RECLAIM | WQ_HIGHPRI, 0); | 594 | WQ_MEM_RECLAIM | WQ_HIGHPRI, 0); |
595 | if (!kpcitest_workqueue) { | ||
596 | pr_err("Failed to allocate the kpcitest work queue\n"); | ||
597 | return -ENOMEM; | ||
598 | } | ||
599 | |||
595 | ret = pci_epf_register_driver(&test_driver); | 600 | ret = pci_epf_register_driver(&test_driver); |
596 | if (ret) { | 601 | if (ret) { |
597 | pr_err("Failed to register pci epf test driver --> %d\n", ret); | 602 | pr_err("Failed to register pci epf test driver --> %d\n", ret); |
diff --git a/tools/pci/Makefile b/tools/pci/Makefile index 46e4c2f318c9..9b7534457060 100644 --- a/tools/pci/Makefile +++ b/tools/pci/Makefile | |||
@@ -14,9 +14,12 @@ MAKEFLAGS += -r | |||
14 | 14 | ||
15 | CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include | 15 | CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include |
16 | 16 | ||
17 | ALL_TARGETS := pcitest pcitest.sh | 17 | ALL_TARGETS := pcitest |
18 | ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS)) | 18 | ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS)) |
19 | 19 | ||
20 | SCRIPTS := pcitest.sh | ||
21 | ALL_SCRIPTS := $(patsubst %,$(OUTPUT)%,$(SCRIPTS)) | ||
22 | |||
20 | all: $(ALL_PROGRAMS) | 23 | all: $(ALL_PROGRAMS) |
21 | 24 | ||
22 | export srctree OUTPUT CC LD CFLAGS | 25 | export srctree OUTPUT CC LD CFLAGS |
@@ -46,6 +49,9 @@ install: $(ALL_PROGRAMS) | |||
46 | install -d -m 755 $(DESTDIR)$(bindir); \ | 49 | install -d -m 755 $(DESTDIR)$(bindir); \ |
47 | for program in $(ALL_PROGRAMS); do \ | 50 | for program in $(ALL_PROGRAMS); do \ |
48 | install $$program $(DESTDIR)$(bindir); \ | 51 | install $$program $(DESTDIR)$(bindir); \ |
52 | done; \ | ||
53 | for script in $(ALL_SCRIPTS); do \ | ||
54 | install $$script $(DESTDIR)$(bindir); \ | ||
49 | done | 55 | done |
50 | 56 | ||
51 | FORCE: | 57 | FORCE: |
diff --git a/tools/pci/pcitest.c b/tools/pci/pcitest.c index ec4d51f3308b..5fa5c2bdd427 100644 --- a/tools/pci/pcitest.c +++ b/tools/pci/pcitest.c | |||
@@ -140,6 +140,7 @@ static void run_test(struct pci_test *test) | |||
140 | } | 140 | } |
141 | 141 | ||
142 | fflush(stdout); | 142 | fflush(stdout); |
143 | return (ret < 0) ? ret : 1 - ret; /* return 0 if test succeeded */ | ||
143 | } | 144 | } |
144 | 145 | ||
145 | int main(int argc, char **argv) | 146 | int main(int argc, char **argv) |
@@ -162,7 +163,7 @@ int main(int argc, char **argv) | |||
162 | /* set default endpoint device */ | 163 | /* set default endpoint device */ |
163 | test->device = "/dev/pci-endpoint-test.0"; | 164 | test->device = "/dev/pci-endpoint-test.0"; |
164 | 165 | ||
165 | while ((c = getopt(argc, argv, "D:b:m:x:i:Ilrwcs:")) != EOF) | 166 | while ((c = getopt(argc, argv, "D:b:m:x:i:Ilhrwcs:")) != EOF) |
166 | switch (c) { | 167 | switch (c) { |
167 | case 'D': | 168 | case 'D': |
168 | test->device = optarg; | 169 | test->device = optarg; |
@@ -206,7 +207,6 @@ int main(int argc, char **argv) | |||
206 | case 's': | 207 | case 's': |
207 | test->size = strtoul(optarg, NULL, 0); | 208 | test->size = strtoul(optarg, NULL, 0); |
208 | continue; | 209 | continue; |
209 | case '?': | ||
210 | case 'h': | 210 | case 'h': |
211 | default: | 211 | default: |
212 | usage: | 212 | usage: |
@@ -224,10 +224,10 @@ usage: | |||
224 | "\t-w Write buffer test\n" | 224 | "\t-w Write buffer test\n" |
225 | "\t-c Copy buffer test\n" | 225 | "\t-c Copy buffer test\n" |
226 | "\t-s <size> Size of buffer {default: 100KB}\n", | 226 | "\t-s <size> Size of buffer {default: 100KB}\n", |
227 | "\t-h Print this help message\n", | ||
227 | argv[0]); | 228 | argv[0]); |
228 | return -EINVAL; | 229 | return -EINVAL; |
229 | } | 230 | } |
230 | 231 | ||
231 | run_test(test); | 232 | return run_test(test); |
232 | return 0; | ||
233 | } | 233 | } |