Lines Matching refs:zdev
86 struct zpci_dev *tmp, *zdev = NULL; in get_zdev_by_fid() local
91 zdev = tmp; in get_zdev_by_fid()
96 return zdev; in get_zdev_by_fid()
117 static int zpci_set_airq(struct zpci_dev *zdev) in zpci_set_airq() argument
119 u64 req = ZPCI_CREATE_REQ(zdev->fh, 0, ZPCI_MOD_FC_REG_INT); in zpci_set_airq()
124 fib.noi = airq_iv_end(zdev->aibv); in zpci_set_airq()
125 fib.aibv = (unsigned long) zdev->aibv->vector; in zpci_set_airq()
127 fib.aisb = (unsigned long) zpci_aisb_iv->vector + (zdev->aisb/64)*8; in zpci_set_airq()
128 fib.aisbo = zdev->aisb & 63; in zpci_set_airq()
140 static int mod_pci(struct zpci_dev *zdev, int fn, u8 dmaas, struct mod_pci_args *args) in mod_pci() argument
142 u64 req = ZPCI_CREATE_REQ(zdev->fh, dmaas, fn); in mod_pci()
154 int zpci_register_ioat(struct zpci_dev *zdev, u8 dmaas, in zpci_register_ioat() argument
161 return mod_pci(zdev, ZPCI_MOD_FC_REG_IOAT, dmaas, &args); in zpci_register_ioat()
165 int zpci_unregister_ioat(struct zpci_dev *zdev, u8 dmaas) in zpci_unregister_ioat() argument
169 return mod_pci(zdev, ZPCI_MOD_FC_DEREG_IOAT, dmaas, &args); in zpci_unregister_ioat()
173 static int zpci_clear_airq(struct zpci_dev *zdev) in zpci_clear_airq() argument
177 return mod_pci(zdev, ZPCI_MOD_FC_DEREG_INT, 0, &args); in zpci_clear_airq()
181 int zpci_fmb_enable_device(struct zpci_dev *zdev) in zpci_fmb_enable_device() argument
185 if (zdev->fmb) in zpci_fmb_enable_device()
188 zdev->fmb = kmem_cache_zalloc(zdev_fmb_cache, GFP_KERNEL); in zpci_fmb_enable_device()
189 if (!zdev->fmb) in zpci_fmb_enable_device()
191 WARN_ON((u64) zdev->fmb & 0xf); in zpci_fmb_enable_device()
194 atomic64_set(&zdev->allocated_pages, 0); in zpci_fmb_enable_device()
195 atomic64_set(&zdev->mapped_pages, 0); in zpci_fmb_enable_device()
196 atomic64_set(&zdev->unmapped_pages, 0); in zpci_fmb_enable_device()
198 args.fmb_addr = virt_to_phys(zdev->fmb); in zpci_fmb_enable_device()
199 return mod_pci(zdev, ZPCI_MOD_FC_SET_MEASURE, 0, &args); in zpci_fmb_enable_device()
203 int zpci_fmb_disable_device(struct zpci_dev *zdev) in zpci_fmb_disable_device() argument
208 if (!zdev->fmb) in zpci_fmb_disable_device()
212 rc = mod_pci(zdev, ZPCI_MOD_FC_SET_MEASURE, 0, &args); in zpci_fmb_disable_device()
214 kmem_cache_free(zdev_fmb_cache, zdev->fmb); in zpci_fmb_disable_device()
215 zdev->fmb = NULL; in zpci_fmb_disable_device()
221 static int zpci_cfg_load(struct zpci_dev *zdev, int offset, u32 *val, u8 len) in zpci_cfg_load() argument
223 u64 req = ZPCI_CREATE_REQ(zdev->fh, ZPCI_PCIAS_CFGSPC, len); in zpci_cfg_load()
237 static int zpci_cfg_store(struct zpci_dev *zdev, int offset, u32 val, u8 len) in zpci_cfg_store() argument
239 u64 req = ZPCI_CREATE_REQ(zdev->fh, ZPCI_PCIAS_CFGSPC, len); in zpci_cfg_store()
272 struct zpci_dev *zdev = get_zdev(pdev); in pci_iomap_range() local
279 idx = zdev->bars[bar].map_idx; in pci_iomap_range()
282 BUG_ON(zpci_iomap_start[idx].fh != zdev->fh || in pci_iomap_range()
285 zpci_iomap_start[idx].fh = zdev->fh; in pci_iomap_range()
322 struct zpci_dev *zdev = get_zdev_by_bus(bus); in pci_read() local
325 if (!zdev || devfn != ZPCI_DEVFN) in pci_read()
328 ret = zpci_cfg_load(zdev, where, val, size); in pci_read()
336 struct zpci_dev *zdev = get_zdev_by_bus(bus); in pci_write() local
339 if (!zdev || devfn != ZPCI_DEVFN) in pci_write()
342 ret = zpci_cfg_store(zdev, where, val, size); in pci_write()
388 struct zpci_dev *zdev = get_zdev(pdev); in arch_setup_msi_irqs() local
397 msi_vecs = min_t(unsigned int, nvec, zdev->max_msi); in arch_setup_msi_irqs()
404 zdev->aisb = aisb; in arch_setup_msi_irqs()
408 zdev->aibv = airq_iv_create(msi_vecs, AIRQ_IV_DATA | AIRQ_IV_BITLOCK); in arch_setup_msi_irqs()
409 if (!zdev->aibv) in arch_setup_msi_irqs()
413 zpci_aibv[aisb] = zdev->aibv; in arch_setup_msi_irqs()
428 msg.address_lo = zdev->msi_addr & 0xffffffff; in arch_setup_msi_irqs()
429 msg.address_hi = zdev->msi_addr >> 32; in arch_setup_msi_irqs()
431 airq_iv_set_data(zdev->aibv, hwirq, irq); in arch_setup_msi_irqs()
436 rc = zpci_set_airq(zdev); in arch_setup_msi_irqs()
454 airq_iv_release(zdev->aibv); in arch_setup_msi_irqs()
463 struct zpci_dev *zdev = get_zdev(pdev); in arch_teardown_msi_irqs() local
468 rc = zpci_clear_airq(zdev); in arch_teardown_msi_irqs()
486 zpci_aibv[zdev->aisb] = NULL; in arch_teardown_msi_irqs()
487 airq_iv_release(zdev->aibv); in arch_teardown_msi_irqs()
488 airq_iv_free_bit(zpci_aisb_iv, zdev->aisb); in arch_teardown_msi_irqs()
550 static int zpci_alloc_iomap(struct zpci_dev *zdev) in zpci_alloc_iomap() argument
565 static void zpci_free_iomap(struct zpci_dev *zdev, int entry) in zpci_free_iomap() argument
573 static struct resource *__alloc_res(struct zpci_dev *zdev, unsigned long start, in __alloc_res() argument
585 r->name = zdev->res_name; in __alloc_res()
594 static int zpci_setup_bus_resources(struct zpci_dev *zdev, in zpci_setup_bus_resources() argument
601 snprintf(zdev->res_name, sizeof(zdev->res_name), in zpci_setup_bus_resources()
602 "PCI Bus %04x:%02x", zdev->domain, ZPCI_BUS_NR); in zpci_setup_bus_resources()
605 if (!zdev->bars[i].size) in zpci_setup_bus_resources()
607 entry = zpci_alloc_iomap(zdev); in zpci_setup_bus_resources()
610 zdev->bars[i].map_idx = entry; in zpci_setup_bus_resources()
614 if (zdev->bars[i].val & 8) in zpci_setup_bus_resources()
616 if (zdev->bars[i].val & 4) in zpci_setup_bus_resources()
621 size = 1UL << zdev->bars[i].size; in zpci_setup_bus_resources()
623 res = __alloc_res(zdev, addr, size, flags); in zpci_setup_bus_resources()
625 zpci_free_iomap(zdev, entry); in zpci_setup_bus_resources()
628 zdev->bars[i].res = res; in zpci_setup_bus_resources()
635 static void zpci_cleanup_bus_resources(struct zpci_dev *zdev) in zpci_cleanup_bus_resources() argument
640 if (!zdev->bars[i].size) in zpci_cleanup_bus_resources()
643 zpci_free_iomap(zdev, zdev->bars[i].map_idx); in zpci_cleanup_bus_resources()
644 release_resource(zdev->bars[i].res); in zpci_cleanup_bus_resources()
645 kfree(zdev->bars[i].res); in zpci_cleanup_bus_resources()
651 struct zpci_dev *zdev = get_zdev(pdev); in pcibios_add_device() local
655 zdev->pdev = pdev; in pcibios_add_device()
676 struct zpci_dev *zdev = get_zdev(pdev); in pcibios_enable_device() local
678 zdev->pdev = pdev; in pcibios_enable_device()
679 zpci_debug_init_device(zdev); in pcibios_enable_device()
680 zpci_fmb_enable_device(zdev); in pcibios_enable_device()
687 struct zpci_dev *zdev = get_zdev(pdev); in pcibios_disable_device() local
689 zpci_fmb_disable_device(zdev); in pcibios_disable_device()
690 zpci_debug_exit_device(zdev); in pcibios_disable_device()
691 zdev->pdev = NULL; in pcibios_disable_device()
698 struct zpci_dev *zdev = get_zdev(pdev); in zpci_restore() local
701 if (zdev->state != ZPCI_FN_STATE_ONLINE) in zpci_restore()
704 ret = clp_enable_fh(zdev, ZPCI_NR_DMA_SPACES); in zpci_restore()
709 zpci_register_ioat(zdev, 0, zdev->start_dma + PAGE_OFFSET, in zpci_restore()
710 zdev->start_dma + zdev->iommu_size - 1, in zpci_restore()
711 (u64) zdev->dma_table); in zpci_restore()
720 struct zpci_dev *zdev = get_zdev(pdev); in zpci_freeze() local
722 if (zdev->state != ZPCI_FN_STATE_ONLINE) in zpci_freeze()
725 zpci_unregister_ioat(zdev, 0); in zpci_freeze()
727 return clp_disable_fh(zdev); in zpci_freeze()
738 static int zpci_alloc_domain(struct zpci_dev *zdev) in zpci_alloc_domain() argument
741 zdev->domain = find_first_zero_bit(zpci_domain, ZPCI_NR_DEVICES); in zpci_alloc_domain()
742 if (zdev->domain == ZPCI_NR_DEVICES) { in zpci_alloc_domain()
746 set_bit(zdev->domain, zpci_domain); in zpci_alloc_domain()
751 static void zpci_free_domain(struct zpci_dev *zdev) in zpci_free_domain() argument
754 clear_bit(zdev->domain, zpci_domain); in zpci_free_domain()
760 struct zpci_dev *zdev = get_zdev_by_bus(bus); in pcibios_remove_bus() local
762 zpci_exit_slot(zdev); in pcibios_remove_bus()
763 zpci_cleanup_bus_resources(zdev); in pcibios_remove_bus()
764 zpci_free_domain(zdev); in pcibios_remove_bus()
767 list_del(&zdev->entry); in pcibios_remove_bus()
770 kfree(zdev); in pcibios_remove_bus()
773 static int zpci_scan_bus(struct zpci_dev *zdev) in zpci_scan_bus() argument
778 ret = zpci_setup_bus_resources(zdev, &resources); in zpci_scan_bus()
782 zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops, in zpci_scan_bus()
783 zdev, &resources); in zpci_scan_bus()
784 if (!zdev->bus) { in zpci_scan_bus()
785 zpci_cleanup_bus_resources(zdev); in zpci_scan_bus()
788 zdev->bus->max_bus_speed = zdev->max_bus_speed; in zpci_scan_bus()
789 pci_bus_add_devices(zdev->bus); in zpci_scan_bus()
793 int zpci_enable_device(struct zpci_dev *zdev) in zpci_enable_device() argument
797 rc = clp_enable_fh(zdev, ZPCI_NR_DMA_SPACES); in zpci_enable_device()
801 rc = zpci_dma_init_device(zdev); in zpci_enable_device()
805 zdev->state = ZPCI_FN_STATE_ONLINE; in zpci_enable_device()
809 clp_disable_fh(zdev); in zpci_enable_device()
815 int zpci_disable_device(struct zpci_dev *zdev) in zpci_disable_device() argument
817 zpci_dma_exit_device(zdev); in zpci_disable_device()
818 return clp_disable_fh(zdev); in zpci_disable_device()
822 int zpci_create_device(struct zpci_dev *zdev) in zpci_create_device() argument
826 rc = zpci_alloc_domain(zdev); in zpci_create_device()
830 mutex_init(&zdev->lock); in zpci_create_device()
831 if (zdev->state == ZPCI_FN_STATE_CONFIGURED) { in zpci_create_device()
832 rc = zpci_enable_device(zdev); in zpci_create_device()
836 rc = zpci_scan_bus(zdev); in zpci_create_device()
841 list_add_tail(&zdev->entry, &zpci_list); in zpci_create_device()
844 zpci_init_slot(zdev); in zpci_create_device()
849 if (zdev->state == ZPCI_FN_STATE_ONLINE) in zpci_create_device()
850 zpci_disable_device(zdev); in zpci_create_device()
852 zpci_free_domain(zdev); in zpci_create_device()
857 void zpci_stop_device(struct zpci_dev *zdev) in zpci_stop_device() argument
859 zpci_dma_exit_device(zdev); in zpci_stop_device()