Lines Matching refs:php_slot
27 struct pnv_php_slot *php_slot; member
38 static void pnv_php_disable_irq(struct pnv_php_slot *php_slot, in pnv_php_disable_irq() argument
41 struct pci_dev *pdev = php_slot->pdev; in pnv_php_disable_irq()
42 int irq = php_slot->irq; in pnv_php_disable_irq()
45 if (php_slot->irq > 0) { in pnv_php_disable_irq()
52 free_irq(php_slot->irq, php_slot); in pnv_php_disable_irq()
53 php_slot->irq = 0; in pnv_php_disable_irq()
56 if (php_slot->wq) { in pnv_php_disable_irq()
57 destroy_workqueue(php_slot->wq); in pnv_php_disable_irq()
58 php_slot->wq = NULL; in pnv_php_disable_irq()
73 struct pnv_php_slot *php_slot = container_of(kref, in pnv_php_free_slot() local
76 WARN_ON(!list_empty(&php_slot->children)); in pnv_php_free_slot()
77 pnv_php_disable_irq(php_slot, false); in pnv_php_free_slot()
78 kfree(php_slot->name); in pnv_php_free_slot()
79 kfree(php_slot); in pnv_php_free_slot()
82 static inline void pnv_php_put_slot(struct pnv_php_slot *php_slot) in pnv_php_put_slot() argument
85 if (!php_slot) in pnv_php_put_slot()
88 kref_put(&php_slot->kref, pnv_php_free_slot); in pnv_php_put_slot()
92 struct pnv_php_slot *php_slot) in pnv_php_match() argument
96 if (php_slot->dn == dn) { in pnv_php_match()
97 kref_get(&php_slot->kref); in pnv_php_match()
98 return php_slot; in pnv_php_match()
101 list_for_each_entry(tmp, &php_slot->children, link) { in pnv_php_match()
112 struct pnv_php_slot *php_slot, *tmp; in pnv_php_find_slot() local
117 php_slot = pnv_php_match(dn, tmp); in pnv_php_find_slot()
118 if (php_slot) { in pnv_php_find_slot()
120 return php_slot; in pnv_php_find_slot()
167 static void pnv_php_rmv_devtree(struct pnv_php_slot *php_slot) in pnv_php_rmv_devtree() argument
169 pnv_php_rmv_pdns(php_slot->dn); in pnv_php_rmv_devtree()
175 if (php_slot->fdt) in pnv_php_rmv_devtree()
176 of_changeset_destroy(&php_slot->ocs); in pnv_php_rmv_devtree()
177 pnv_php_detach_device_nodes(php_slot->dn); in pnv_php_rmv_devtree()
179 if (php_slot->fdt) { in pnv_php_rmv_devtree()
180 kfree(php_slot->dt); in pnv_php_rmv_devtree()
181 kfree(php_slot->fdt); in pnv_php_rmv_devtree()
182 php_slot->dt = NULL; in pnv_php_rmv_devtree()
183 php_slot->dn->child = NULL; in pnv_php_rmv_devtree()
184 php_slot->fdt = NULL; in pnv_php_rmv_devtree()
255 static int pnv_php_add_devtree(struct pnv_php_slot *php_slot) in pnv_php_add_devtree() argument
270 ret = pnv_pci_get_device_tree(php_slot->dn->phandle, fdt1, 0x10000); in pnv_php_add_devtree()
272 SLOT_WARN(php_slot, "Error %d getting FDT blob\n", ret); in pnv_php_add_devtree()
283 dt = of_fdt_unflatten_tree(fdt, php_slot->dn, NULL); in pnv_php_add_devtree()
286 SLOT_WARN(php_slot, "Cannot unflatten FDT\n"); in pnv_php_add_devtree()
291 of_changeset_init(&php_slot->ocs); in pnv_php_add_devtree()
292 pnv_php_reverse_nodes(php_slot->dn); in pnv_php_add_devtree()
293 ret = pnv_php_populate_changeset(&php_slot->ocs, php_slot->dn); in pnv_php_add_devtree()
295 pnv_php_reverse_nodes(php_slot->dn); in pnv_php_add_devtree()
296 SLOT_WARN(php_slot, "Error %d populating changeset\n", in pnv_php_add_devtree()
301 php_slot->dn->child = NULL; in pnv_php_add_devtree()
302 ret = of_changeset_apply(&php_slot->ocs); in pnv_php_add_devtree()
304 SLOT_WARN(php_slot, "Error %d applying changeset\n", ret); in pnv_php_add_devtree()
309 pnv_php_add_pdns(php_slot); in pnv_php_add_devtree()
310 php_slot->fdt = fdt; in pnv_php_add_devtree()
311 php_slot->dt = dt; in pnv_php_add_devtree()
316 of_changeset_destroy(&php_slot->ocs); in pnv_php_add_devtree()
319 php_slot->dn->child = NULL; in pnv_php_add_devtree()
336 struct pnv_php_slot *php_slot = to_pnv_php_slot(slot); in pnv_php_set_slot_power_state() local
340 ret = pnv_pci_set_power_state(php_slot->id, state, &msg); in pnv_php_set_slot_power_state()
342 if (be64_to_cpu(msg.params[1]) != php_slot->dn->phandle || in pnv_php_set_slot_power_state()
344 SLOT_WARN(php_slot, "Wrong msg (%lld, %lld, %lld)\n", in pnv_php_set_slot_power_state()
359 pnv_php_rmv_devtree(php_slot); in pnv_php_set_slot_power_state()
361 ret = pnv_php_add_devtree(php_slot); in pnv_php_set_slot_power_state()
366 SLOT_WARN(php_slot, "Error %d powering %s\n", in pnv_php_set_slot_power_state()
374 struct pnv_php_slot *php_slot = to_pnv_php_slot(slot); in pnv_php_get_power_state() local
383 ret = pnv_pci_get_power_state(php_slot->id, &power_state); in pnv_php_get_power_state()
385 SLOT_WARN(php_slot, "Error %d getting power status\n", in pnv_php_get_power_state()
396 struct pnv_php_slot *php_slot = to_pnv_php_slot(slot); in pnv_php_get_adapter_state() local
404 ret = pnv_pci_get_presence_state(php_slot->id, &presence); in pnv_php_get_adapter_state()
409 SLOT_WARN(php_slot, "Error %d getting presence\n", ret); in pnv_php_get_adapter_state()
417 struct pnv_php_slot *php_slot = to_pnv_php_slot(slot); in pnv_php_get_attention_state() local
419 *state = php_slot->attention_state; in pnv_php_get_attention_state()
425 struct pnv_php_slot *php_slot = to_pnv_php_slot(slot); in pnv_php_set_attention_state() local
426 struct pci_dev *bridge = php_slot->pdev; in pnv_php_set_attention_state()
429 php_slot->attention_state = state; in pnv_php_set_attention_state()
445 static int pnv_php_enable(struct pnv_php_slot *php_slot, bool rescan) in pnv_php_enable() argument
447 struct hotplug_slot *slot = &php_slot->slot; in pnv_php_enable()
453 if (php_slot->state != PNV_PHP_STATE_REGISTERED) in pnv_php_enable()
468 if (!php_slot->power_state_check) { in pnv_php_enable()
469 php_slot->power_state_check = true; in pnv_php_enable()
487 if (!php_slot->power_state_check) { in pnv_php_enable()
488 php_slot->power_state_check = true; in pnv_php_enable()
515 pci_hp_add_devices(php_slot->bus); in pnv_php_enable()
520 php_slot->state = PNV_PHP_STATE_POPULATED; in pnv_php_enable()
522 pnv_php_register(php_slot->dn); in pnv_php_enable()
524 php_slot->state = PNV_PHP_STATE_POPULATED; in pnv_php_enable()
532 struct pnv_php_slot *php_slot = to_pnv_php_slot(slot); in pnv_php_reset_slot() local
533 struct pci_dev *bridge = php_slot->pdev; in pnv_php_reset_slot()
545 if (php_slot->irq > 0) in pnv_php_reset_slot()
546 disable_irq(php_slot->irq); in pnv_php_reset_slot()
551 pcie_capability_read_word(php_slot->pdev, PCI_EXP_SLTSTA, &sts); in pnv_php_reset_slot()
553 pcie_capability_write_word(php_slot->pdev, PCI_EXP_SLTSTA, sts); in pnv_php_reset_slot()
555 if (php_slot->irq > 0) in pnv_php_reset_slot()
556 enable_irq(php_slot->irq); in pnv_php_reset_slot()
563 struct pnv_php_slot *php_slot = to_pnv_php_slot(slot); in pnv_php_enable_slot() local
565 return pnv_php_enable(php_slot, true); in pnv_php_enable_slot()
570 struct pnv_php_slot *php_slot = to_pnv_php_slot(slot); in pnv_php_disable_slot() local
578 if (php_slot->state != PNV_PHP_STATE_POPULATED && in pnv_php_disable_slot()
579 php_slot->state != PNV_PHP_STATE_REGISTERED) in pnv_php_disable_slot()
584 pci_hp_remove_devices(php_slot->bus); in pnv_php_disable_slot()
588 pnv_php_unregister(php_slot->dn); in pnv_php_disable_slot()
593 php_slot->state = PNV_PHP_STATE_REGISTERED; in pnv_php_disable_slot()
607 static void pnv_php_release(struct pnv_php_slot *php_slot) in pnv_php_release() argument
613 list_del(&php_slot->link); in pnv_php_release()
617 pnv_php_put_slot(php_slot); in pnv_php_release()
618 pnv_php_put_slot(php_slot->parent); in pnv_php_release()
623 struct pnv_php_slot *php_slot; in pnv_php_alloc_slot() local
640 php_slot = kzalloc(sizeof(*php_slot), GFP_KERNEL); in pnv_php_alloc_slot()
641 if (!php_slot) in pnv_php_alloc_slot()
644 php_slot->name = kstrdup(label, GFP_KERNEL); in pnv_php_alloc_slot()
645 if (!php_slot->name) { in pnv_php_alloc_slot()
646 kfree(php_slot); in pnv_php_alloc_slot()
651 php_slot->slot_no = PCI_SLOT(PCI_DN(dn->child)->devfn); in pnv_php_alloc_slot()
653 php_slot->slot_no = -1; /* Placeholder slot */ in pnv_php_alloc_slot()
655 kref_init(&php_slot->kref); in pnv_php_alloc_slot()
656 php_slot->state = PNV_PHP_STATE_INITIALIZED; in pnv_php_alloc_slot()
657 php_slot->dn = dn; in pnv_php_alloc_slot()
658 php_slot->pdev = bus->self; in pnv_php_alloc_slot()
659 php_slot->bus = bus; in pnv_php_alloc_slot()
660 php_slot->id = id; in pnv_php_alloc_slot()
661 php_slot->power_state_check = false; in pnv_php_alloc_slot()
662 php_slot->slot.ops = &php_slot_ops; in pnv_php_alloc_slot()
664 INIT_LIST_HEAD(&php_slot->children); in pnv_php_alloc_slot()
665 INIT_LIST_HEAD(&php_slot->link); in pnv_php_alloc_slot()
667 return php_slot; in pnv_php_alloc_slot()
670 static int pnv_php_register_slot(struct pnv_php_slot *php_slot) in pnv_php_register_slot() argument
673 struct device_node *dn = php_slot->dn; in pnv_php_register_slot()
678 parent = pnv_php_find_slot(php_slot->dn); in pnv_php_register_slot()
685 ret = pci_hp_register(&php_slot->slot, php_slot->bus, in pnv_php_register_slot()
686 php_slot->slot_no, php_slot->name); in pnv_php_register_slot()
688 SLOT_WARN(php_slot, "Error %d registering slot\n", ret); in pnv_php_register_slot()
709 php_slot->parent = parent; in pnv_php_register_slot()
711 list_add_tail(&php_slot->link, &parent->children); in pnv_php_register_slot()
713 list_add_tail(&php_slot->link, &pnv_php_slot_list); in pnv_php_register_slot()
716 php_slot->state = PNV_PHP_STATE_REGISTERED; in pnv_php_register_slot()
720 static int pnv_php_enable_msix(struct pnv_php_slot *php_slot) in pnv_php_enable_msix() argument
722 struct pci_dev *pdev = php_slot->pdev; in pnv_php_enable_msix()
741 SLOT_WARN(php_slot, "Error %d enabling MSIx\n", ret); in pnv_php_enable_msix()
752 struct pnv_php_slot *php_slot = event->php_slot; in pnv_php_event_handler() local
755 pnv_php_enable_slot(&php_slot->slot); in pnv_php_event_handler()
757 pnv_php_disable_slot(&php_slot->slot); in pnv_php_event_handler()
764 struct pnv_php_slot *php_slot = data; in pnv_php_interrupt() local
765 struct pci_dev *pchild, *pdev = php_slot->pdev; in pnv_php_interrupt()
780 php_slot->name, in pnv_php_interrupt()
787 } else if (!(php_slot->flags & PNV_PHP_FLAG_BROKEN_PDC) && in pnv_php_interrupt()
789 ret = pnv_pci_get_presence_state(php_slot->id, &presence); in pnv_php_interrupt()
791 SLOT_WARN(php_slot, in pnv_php_interrupt()
793 php_slot->name, ret, sts); in pnv_php_interrupt()
799 pci_dbg(pdev, "PCI slot [%s]: Spurious IRQ?\n", php_slot->name); in pnv_php_interrupt()
805 pchild = list_first_entry_or_null(&php_slot->bus->devices, in pnv_php_interrupt()
823 SLOT_WARN(php_slot, in pnv_php_interrupt()
825 php_slot->name, sts); in pnv_php_interrupt()
830 php_slot->name, added ? "added" : "removed", irq); in pnv_php_interrupt()
833 event->php_slot = php_slot; in pnv_php_interrupt()
834 queue_work(php_slot->wq, &event->work); in pnv_php_interrupt()
839 static void pnv_php_init_irq(struct pnv_php_slot *php_slot, int irq) in pnv_php_init_irq() argument
841 struct pci_dev *pdev = php_slot->pdev; in pnv_php_init_irq()
847 php_slot->wq = alloc_workqueue("pciehp-%s", 0, 0, php_slot->name); in pnv_php_init_irq()
848 if (!php_slot->wq) { in pnv_php_init_irq()
849 SLOT_WARN(php_slot, "Cannot alloc workqueue\n"); in pnv_php_init_irq()
850 pnv_php_disable_irq(php_slot, true); in pnv_php_init_irq()
855 ret = of_property_read_u32(php_slot->dn, "ibm,slot-broken-pdc", in pnv_php_init_irq()
858 php_slot->flags |= PNV_PHP_FLAG_BROKEN_PDC; in pnv_php_init_irq()
862 if (php_slot->flags & PNV_PHP_FLAG_BROKEN_PDC) in pnv_php_init_irq()
870 php_slot->name, php_slot); in pnv_php_init_irq()
872 pnv_php_disable_irq(php_slot, true); in pnv_php_init_irq()
873 SLOT_WARN(php_slot, "Error %d enabling IRQ %d\n", ret, irq); in pnv_php_init_irq()
879 if (php_slot->flags & PNV_PHP_FLAG_BROKEN_PDC) { in pnv_php_init_irq()
891 php_slot->irq = irq; in pnv_php_init_irq()
894 static void pnv_php_enable_irq(struct pnv_php_slot *php_slot) in pnv_php_enable_irq() argument
896 struct pci_dev *pdev = php_slot->pdev; in pnv_php_enable_irq()
909 SLOT_WARN(php_slot, "Error %d enabling device\n", ret); in pnv_php_enable_irq()
916 irq = pnv_php_enable_msix(php_slot); in pnv_php_enable_irq()
918 pnv_php_init_irq(php_slot, irq); in pnv_php_enable_irq()
929 pnv_php_init_irq(php_slot, irq); in pnv_php_enable_irq()
935 struct pnv_php_slot *php_slot; in pnv_php_register_one() local
948 php_slot = pnv_php_alloc_slot(dn); in pnv_php_register_one()
949 if (!php_slot) in pnv_php_register_one()
952 ret = pnv_php_register_slot(php_slot); in pnv_php_register_one()
956 ret = pnv_php_enable(php_slot, false); in pnv_php_register_one()
963 pnv_php_enable_irq(php_slot); in pnv_php_register_one()
968 pnv_php_unregister_one(php_slot->dn); in pnv_php_register_one()
970 pnv_php_put_slot(php_slot); in pnv_php_register_one()
990 struct pnv_php_slot *php_slot; in pnv_php_unregister_one() local
992 php_slot = pnv_php_find_slot(dn); in pnv_php_unregister_one()
993 if (!php_slot) in pnv_php_unregister_one()
996 php_slot->state = PNV_PHP_STATE_OFFLINE; in pnv_php_unregister_one()
997 pci_hp_deregister(&php_slot->slot); in pnv_php_unregister_one()
998 pnv_php_release(php_slot); in pnv_php_unregister_one()
999 pnv_php_put_slot(php_slot); in pnv_php_unregister_one()