aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug/pnv_php.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/hotplug/pnv_php.c')
-rw-r--r--drivers/pci/hotplug/pnv_php.c45
1 files changed, 17 insertions, 28 deletions
diff --git a/drivers/pci/hotplug/pnv_php.c b/drivers/pci/hotplug/pnv_php.c
index 74f6a17e4614..23da3046f160 100644
--- a/drivers/pci/hotplug/pnv_php.c
+++ b/drivers/pci/hotplug/pnv_php.c
@@ -1,12 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * PCI Hotplug Driver for PowerPC PowerNV platform. 3 * PCI Hotplug Driver for PowerPC PowerNV platform.
3 * 4 *
4 * Copyright Gavin Shan, IBM Corporation 2016. 5 * Copyright Gavin Shan, IBM Corporation 2016.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */ 6 */
11 7
12#include <linux/libfdt.h> 8#include <linux/libfdt.h>
@@ -266,22 +262,18 @@ static int pnv_php_add_devtree(struct pnv_php_slot *php_slot)
266 fdt1 = kzalloc(0x10000, GFP_KERNEL); 262 fdt1 = kzalloc(0x10000, GFP_KERNEL);
267 if (!fdt1) { 263 if (!fdt1) {
268 ret = -ENOMEM; 264 ret = -ENOMEM;
269 dev_warn(&php_slot->pdev->dev, "Cannot alloc FDT blob\n");
270 goto out; 265 goto out;
271 } 266 }
272 267
273 ret = pnv_pci_get_device_tree(php_slot->dn->phandle, fdt1, 0x10000); 268 ret = pnv_pci_get_device_tree(php_slot->dn->phandle, fdt1, 0x10000);
274 if (ret) { 269 if (ret) {
275 dev_warn(&php_slot->pdev->dev, "Error %d getting FDT blob\n", 270 pci_warn(php_slot->pdev, "Error %d getting FDT blob\n", ret);
276 ret);
277 goto free_fdt1; 271 goto free_fdt1;
278 } 272 }
279 273
280 fdt = kzalloc(fdt_totalsize(fdt1), GFP_KERNEL); 274 fdt = kzalloc(fdt_totalsize(fdt1), GFP_KERNEL);
281 if (!fdt) { 275 if (!fdt) {
282 ret = -ENOMEM; 276 ret = -ENOMEM;
283 dev_warn(&php_slot->pdev->dev, "Cannot %d bytes memory\n",
284 fdt_totalsize(fdt1));
285 goto free_fdt1; 277 goto free_fdt1;
286 } 278 }
287 279
@@ -290,7 +282,7 @@ static int pnv_php_add_devtree(struct pnv_php_slot *php_slot)
290 dt = of_fdt_unflatten_tree(fdt, php_slot->dn, NULL); 282 dt = of_fdt_unflatten_tree(fdt, php_slot->dn, NULL);
291 if (!dt) { 283 if (!dt) {
292 ret = -EINVAL; 284 ret = -EINVAL;
293 dev_warn(&php_slot->pdev->dev, "Cannot unflatten FDT\n"); 285 pci_warn(php_slot->pdev, "Cannot unflatten FDT\n");
294 goto free_fdt; 286 goto free_fdt;
295 } 287 }
296 288
@@ -300,7 +292,7 @@ static int pnv_php_add_devtree(struct pnv_php_slot *php_slot)
300 ret = pnv_php_populate_changeset(&php_slot->ocs, php_slot->dn); 292 ret = pnv_php_populate_changeset(&php_slot->ocs, php_slot->dn);
301 if (ret) { 293 if (ret) {
302 pnv_php_reverse_nodes(php_slot->dn); 294 pnv_php_reverse_nodes(php_slot->dn);
303 dev_warn(&php_slot->pdev->dev, "Error %d populating changeset\n", 295 pci_warn(php_slot->pdev, "Error %d populating changeset\n",
304 ret); 296 ret);
305 goto free_dt; 297 goto free_dt;
306 } 298 }
@@ -308,8 +300,7 @@ static int pnv_php_add_devtree(struct pnv_php_slot *php_slot)
308 php_slot->dn->child = NULL; 300 php_slot->dn->child = NULL;
309 ret = of_changeset_apply(&php_slot->ocs); 301 ret = of_changeset_apply(&php_slot->ocs);
310 if (ret) { 302 if (ret) {
311 dev_warn(&php_slot->pdev->dev, "Error %d applying changeset\n", 303 pci_warn(php_slot->pdev, "Error %d applying changeset\n", ret);
312 ret);
313 goto destroy_changeset; 304 goto destroy_changeset;
314 } 305 }
315 306
@@ -345,14 +336,14 @@ int pnv_php_set_slot_power_state(struct hotplug_slot *slot,
345 if (be64_to_cpu(msg.params[1]) != php_slot->dn->phandle || 336 if (be64_to_cpu(msg.params[1]) != php_slot->dn->phandle ||
346 be64_to_cpu(msg.params[2]) != state || 337 be64_to_cpu(msg.params[2]) != state ||
347 be64_to_cpu(msg.params[3]) != OPAL_SUCCESS) { 338 be64_to_cpu(msg.params[3]) != OPAL_SUCCESS) {
348 dev_warn(&php_slot->pdev->dev, "Wrong msg (%lld, %lld, %lld)\n", 339 pci_warn(php_slot->pdev, "Wrong msg (%lld, %lld, %lld)\n",
349 be64_to_cpu(msg.params[1]), 340 be64_to_cpu(msg.params[1]),
350 be64_to_cpu(msg.params[2]), 341 be64_to_cpu(msg.params[2]),
351 be64_to_cpu(msg.params[3])); 342 be64_to_cpu(msg.params[3]));
352 return -ENOMSG; 343 return -ENOMSG;
353 } 344 }
354 } else if (ret < 0) { 345 } else if (ret < 0) {
355 dev_warn(&php_slot->pdev->dev, "Error %d powering %s\n", 346 pci_warn(php_slot->pdev, "Error %d powering %s\n",
356 ret, (state == OPAL_PCI_SLOT_POWER_ON) ? "on" : "off"); 347 ret, (state == OPAL_PCI_SLOT_POWER_ON) ? "on" : "off");
357 return ret; 348 return ret;
358 } 349 }
@@ -379,7 +370,7 @@ static int pnv_php_get_power_state(struct hotplug_slot *slot, u8 *state)
379 */ 370 */
380 ret = pnv_pci_get_power_state(php_slot->id, &power_state); 371 ret = pnv_pci_get_power_state(php_slot->id, &power_state);
381 if (ret) { 372 if (ret) {
382 dev_warn(&php_slot->pdev->dev, "Error %d getting power status\n", 373 pci_warn(php_slot->pdev, "Error %d getting power status\n",
383 ret); 374 ret);
384 } else { 375 } else {
385 *state = power_state; 376 *state = power_state;
@@ -405,8 +396,7 @@ static int pnv_php_get_adapter_state(struct hotplug_slot *slot, u8 *state)
405 slot->info->adapter_status = presence; 396 slot->info->adapter_status = presence;
406 ret = 0; 397 ret = 0;
407 } else { 398 } else {
408 dev_warn(&php_slot->pdev->dev, "Error %d getting presence\n", 399 pci_warn(php_slot->pdev, "Error %d getting presence\n", ret);
409 ret);
410 } 400 }
411 401
412 return ret; 402 return ret;
@@ -629,8 +619,7 @@ static int pnv_php_register_slot(struct pnv_php_slot *php_slot)
629 ret = pci_hp_register(&php_slot->slot, php_slot->bus, 619 ret = pci_hp_register(&php_slot->slot, php_slot->bus,
630 php_slot->slot_no, php_slot->name); 620 php_slot->slot_no, php_slot->name);
631 if (ret) { 621 if (ret) {
632 dev_warn(&php_slot->pdev->dev, "Error %d registering slot\n", 622 pci_warn(php_slot->pdev, "Error %d registering slot\n", ret);
633 ret);
634 return ret; 623 return ret;
635 } 624 }
636 625
@@ -683,7 +672,7 @@ static int pnv_php_enable_msix(struct pnv_php_slot *php_slot)
683 /* Enable MSIx */ 672 /* Enable MSIx */
684 ret = pci_enable_msix_exact(pdev, &entry, 1); 673 ret = pci_enable_msix_exact(pdev, &entry, 1);
685 if (ret) { 674 if (ret) {
686 dev_warn(&pdev->dev, "Error %d enabling MSIx\n", ret); 675 pci_warn(pdev, "Error %d enabling MSIx\n", ret);
687 return ret; 676 return ret;
688 } 677 }
689 678
@@ -727,7 +716,7 @@ static irqreturn_t pnv_php_interrupt(int irq, void *data)
727 (sts & PCI_EXP_SLTSTA_PDC)) { 716 (sts & PCI_EXP_SLTSTA_PDC)) {
728 ret = pnv_pci_get_presence_state(php_slot->id, &presence); 717 ret = pnv_pci_get_presence_state(php_slot->id, &presence);
729 if (ret) { 718 if (ret) {
730 dev_warn(&pdev->dev, "PCI slot [%s] error %d getting presence (0x%04x), to retry the operation.\n", 719 pci_warn(pdev, "PCI slot [%s] error %d getting presence (0x%04x), to retry the operation.\n",
731 php_slot->name, ret, sts); 720 php_slot->name, ret, sts);
732 return IRQ_HANDLED; 721 return IRQ_HANDLED;
733 } 722 }
@@ -757,12 +746,12 @@ static irqreturn_t pnv_php_interrupt(int irq, void *data)
757 */ 746 */
758 event = kzalloc(sizeof(*event), GFP_ATOMIC); 747 event = kzalloc(sizeof(*event), GFP_ATOMIC);
759 if (!event) { 748 if (!event) {
760 dev_warn(&pdev->dev, "PCI slot [%s] missed hotplug event 0x%04x\n", 749 pci_warn(pdev, "PCI slot [%s] missed hotplug event 0x%04x\n",
761 php_slot->name, sts); 750 php_slot->name, sts);
762 return IRQ_HANDLED; 751 return IRQ_HANDLED;
763 } 752 }
764 753
765 dev_info(&pdev->dev, "PCI slot [%s] %s (IRQ: %d)\n", 754 pci_info(pdev, "PCI slot [%s] %s (IRQ: %d)\n",
766 php_slot->name, added ? "added" : "removed", irq); 755 php_slot->name, added ? "added" : "removed", irq);
767 INIT_WORK(&event->work, pnv_php_event_handler); 756 INIT_WORK(&event->work, pnv_php_event_handler);
768 event->added = added; 757 event->added = added;
@@ -782,7 +771,7 @@ static void pnv_php_init_irq(struct pnv_php_slot *php_slot, int irq)
782 /* Allocate workqueue */ 771 /* Allocate workqueue */
783 php_slot->wq = alloc_workqueue("pciehp-%s", 0, 0, php_slot->name); 772 php_slot->wq = alloc_workqueue("pciehp-%s", 0, 0, php_slot->name);
784 if (!php_slot->wq) { 773 if (!php_slot->wq) {
785 dev_warn(&pdev->dev, "Cannot alloc workqueue\n"); 774 pci_warn(pdev, "Cannot alloc workqueue\n");
786 pnv_php_disable_irq(php_slot, true); 775 pnv_php_disable_irq(php_slot, true);
787 return; 776 return;
788 } 777 }
@@ -806,7 +795,7 @@ static void pnv_php_init_irq(struct pnv_php_slot *php_slot, int irq)
806 php_slot->name, php_slot); 795 php_slot->name, php_slot);
807 if (ret) { 796 if (ret) {
808 pnv_php_disable_irq(php_slot, true); 797 pnv_php_disable_irq(php_slot, true);
809 dev_warn(&pdev->dev, "Error %d enabling IRQ %d\n", ret, irq); 798 pci_warn(pdev, "Error %d enabling IRQ %d\n", ret, irq);
810 return; 799 return;
811 } 800 }
812 801
@@ -842,7 +831,7 @@ static void pnv_php_enable_irq(struct pnv_php_slot *php_slot)
842 831
843 ret = pci_enable_device(pdev); 832 ret = pci_enable_device(pdev);
844 if (ret) { 833 if (ret) {
845 dev_warn(&pdev->dev, "Error %d enabling device\n", ret); 834 pci_warn(pdev, "Error %d enabling device\n", ret);
846 return; 835 return;
847 } 836 }
848 837