Lines Matching refs:zdev
81 struct zpci_dev *tmp, *zdev = NULL; in get_zdev_by_fid() local
86 zdev = tmp; in get_zdev_by_fid()
91 return zdev; in get_zdev_by_fid()
112 static int zpci_set_airq(struct zpci_dev *zdev) in zpci_set_airq() argument
114 u64 req = ZPCI_CREATE_REQ(zdev->fh, 0, ZPCI_MOD_FC_REG_INT); in zpci_set_airq()
119 fib.noi = airq_iv_end(zdev->aibv); in zpci_set_airq()
120 fib.aibv = (unsigned long) zdev->aibv->vector; in zpci_set_airq()
122 fib.aisb = (unsigned long) zpci_aisb_iv->vector + (zdev->aisb/64)*8; in zpci_set_airq()
123 fib.aisbo = zdev->aisb & 63; in zpci_set_airq()
135 static int mod_pci(struct zpci_dev *zdev, int fn, u8 dmaas, struct mod_pci_args *args) in mod_pci() argument
137 u64 req = ZPCI_CREATE_REQ(zdev->fh, dmaas, fn); in mod_pci()
149 int zpci_register_ioat(struct zpci_dev *zdev, u8 dmaas, in zpci_register_ioat() argument
156 return mod_pci(zdev, ZPCI_MOD_FC_REG_IOAT, dmaas, &args); in zpci_register_ioat()
160 int zpci_unregister_ioat(struct zpci_dev *zdev, u8 dmaas) in zpci_unregister_ioat() argument
164 return mod_pci(zdev, ZPCI_MOD_FC_DEREG_IOAT, dmaas, &args); in zpci_unregister_ioat()
168 static int zpci_clear_airq(struct zpci_dev *zdev) in zpci_clear_airq() argument
172 return mod_pci(zdev, ZPCI_MOD_FC_DEREG_INT, 0, &args); in zpci_clear_airq()
176 int zpci_fmb_enable_device(struct zpci_dev *zdev) in zpci_fmb_enable_device() argument
180 if (zdev->fmb) in zpci_fmb_enable_device()
183 zdev->fmb = kmem_cache_zalloc(zdev_fmb_cache, GFP_KERNEL); in zpci_fmb_enable_device()
184 if (!zdev->fmb) in zpci_fmb_enable_device()
186 WARN_ON((u64) zdev->fmb & 0xf); in zpci_fmb_enable_device()
189 atomic64_set(&zdev->allocated_pages, 0); in zpci_fmb_enable_device()
190 atomic64_set(&zdev->mapped_pages, 0); in zpci_fmb_enable_device()
191 atomic64_set(&zdev->unmapped_pages, 0); in zpci_fmb_enable_device()
193 args.fmb_addr = virt_to_phys(zdev->fmb); in zpci_fmb_enable_device()
194 return mod_pci(zdev, ZPCI_MOD_FC_SET_MEASURE, 0, &args); in zpci_fmb_enable_device()
198 int zpci_fmb_disable_device(struct zpci_dev *zdev) in zpci_fmb_disable_device() argument
203 if (!zdev->fmb) in zpci_fmb_disable_device()
207 rc = mod_pci(zdev, ZPCI_MOD_FC_SET_MEASURE, 0, &args); in zpci_fmb_disable_device()
209 kmem_cache_free(zdev_fmb_cache, zdev->fmb); in zpci_fmb_disable_device()
210 zdev->fmb = NULL; in zpci_fmb_disable_device()
216 static int zpci_cfg_load(struct zpci_dev *zdev, int offset, u32 *val, u8 len) in zpci_cfg_load() argument
218 u64 req = ZPCI_CREATE_REQ(zdev->fh, ZPCI_PCIAS_CFGSPC, len); in zpci_cfg_load()
232 static int zpci_cfg_store(struct zpci_dev *zdev, int offset, u32 val, u8 len) in zpci_cfg_store() argument
234 u64 req = ZPCI_CREATE_REQ(zdev->fh, ZPCI_PCIAS_CFGSPC, len); in zpci_cfg_store()
267 struct zpci_dev *zdev = to_zpci(pdev); in pci_iomap_range() local
274 idx = zdev->bars[bar].map_idx; in pci_iomap_range()
277 BUG_ON(zpci_iomap_start[idx].fh != zdev->fh || in pci_iomap_range()
280 zpci_iomap_start[idx].fh = zdev->fh; in pci_iomap_range()
317 struct zpci_dev *zdev = get_zdev_by_bus(bus); in pci_read() local
320 if (!zdev || devfn != ZPCI_DEVFN) in pci_read()
323 ret = zpci_cfg_load(zdev, where, val, size); in pci_read()
331 struct zpci_dev *zdev = get_zdev_by_bus(bus); in pci_write() local
334 if (!zdev || devfn != ZPCI_DEVFN) in pci_write()
337 ret = zpci_cfg_store(zdev, where, val, size); in pci_write()
383 struct zpci_dev *zdev = to_zpci(pdev); in arch_setup_msi_irqs() local
392 msi_vecs = min_t(unsigned int, nvec, zdev->max_msi); in arch_setup_msi_irqs()
399 zdev->aisb = aisb; in arch_setup_msi_irqs()
403 zdev->aibv = airq_iv_create(msi_vecs, AIRQ_IV_DATA | AIRQ_IV_BITLOCK); in arch_setup_msi_irqs()
404 if (!zdev->aibv) in arch_setup_msi_irqs()
408 zpci_aibv[aisb] = zdev->aibv; in arch_setup_msi_irqs()
423 msg.address_lo = zdev->msi_addr & 0xffffffff; in arch_setup_msi_irqs()
424 msg.address_hi = zdev->msi_addr >> 32; in arch_setup_msi_irqs()
426 airq_iv_set_data(zdev->aibv, hwirq, irq); in arch_setup_msi_irqs()
431 rc = zpci_set_airq(zdev); in arch_setup_msi_irqs()
449 airq_iv_release(zdev->aibv); in arch_setup_msi_irqs()
458 struct zpci_dev *zdev = to_zpci(pdev); in arch_teardown_msi_irqs() local
463 rc = zpci_clear_airq(zdev); in arch_teardown_msi_irqs()
481 zpci_aibv[zdev->aisb] = NULL; in arch_teardown_msi_irqs()
482 airq_iv_release(zdev->aibv); in arch_teardown_msi_irqs()
483 airq_iv_free_bit(zpci_aisb_iv, zdev->aisb); in arch_teardown_msi_irqs()
545 static int zpci_alloc_iomap(struct zpci_dev *zdev) in zpci_alloc_iomap() argument
560 static void zpci_free_iomap(struct zpci_dev *zdev, int entry) in zpci_free_iomap() argument
568 static struct resource *__alloc_res(struct zpci_dev *zdev, unsigned long start, in __alloc_res() argument
580 r->name = zdev->res_name; in __alloc_res()
589 static int zpci_setup_bus_resources(struct zpci_dev *zdev, in zpci_setup_bus_resources() argument
596 snprintf(zdev->res_name, sizeof(zdev->res_name), in zpci_setup_bus_resources()
597 "PCI Bus %04x:%02x", zdev->domain, ZPCI_BUS_NR); in zpci_setup_bus_resources()
600 if (!zdev->bars[i].size) in zpci_setup_bus_resources()
602 entry = zpci_alloc_iomap(zdev); in zpci_setup_bus_resources()
605 zdev->bars[i].map_idx = entry; in zpci_setup_bus_resources()
609 if (zdev->bars[i].val & 8) in zpci_setup_bus_resources()
611 if (zdev->bars[i].val & 4) in zpci_setup_bus_resources()
616 size = 1UL << zdev->bars[i].size; in zpci_setup_bus_resources()
618 res = __alloc_res(zdev, addr, size, flags); in zpci_setup_bus_resources()
620 zpci_free_iomap(zdev, entry); in zpci_setup_bus_resources()
623 zdev->bars[i].res = res; in zpci_setup_bus_resources()
630 static void zpci_cleanup_bus_resources(struct zpci_dev *zdev) in zpci_cleanup_bus_resources() argument
635 if (!zdev->bars[i].size || !zdev->bars[i].res) in zpci_cleanup_bus_resources()
638 zpci_free_iomap(zdev, zdev->bars[i].map_idx); in zpci_cleanup_bus_resources()
639 release_resource(zdev->bars[i].res); in zpci_cleanup_bus_resources()
640 kfree(zdev->bars[i].res); in zpci_cleanup_bus_resources()
646 struct zpci_dev *zdev = to_zpci(pdev); in pcibios_add_device() local
650 zdev->pdev = pdev; in pcibios_add_device()
671 struct zpci_dev *zdev = to_zpci(pdev); in pcibios_enable_device() local
673 zdev->pdev = pdev; in pcibios_enable_device()
674 zpci_debug_init_device(zdev); in pcibios_enable_device()
675 zpci_fmb_enable_device(zdev); in pcibios_enable_device()
682 struct zpci_dev *zdev = to_zpci(pdev); in pcibios_disable_device() local
684 zpci_fmb_disable_device(zdev); in pcibios_disable_device()
685 zpci_debug_exit_device(zdev); in pcibios_disable_device()
686 zdev->pdev = NULL; in pcibios_disable_device()
693 struct zpci_dev *zdev = to_zpci(pdev); in zpci_restore() local
696 if (zdev->state != ZPCI_FN_STATE_ONLINE) in zpci_restore()
699 ret = clp_enable_fh(zdev, ZPCI_NR_DMA_SPACES); in zpci_restore()
704 zpci_register_ioat(zdev, 0, zdev->start_dma + PAGE_OFFSET, in zpci_restore()
705 zdev->start_dma + zdev->iommu_size - 1, in zpci_restore()
706 (u64) zdev->dma_table); in zpci_restore()
715 struct zpci_dev *zdev = to_zpci(pdev); in zpci_freeze() local
717 if (zdev->state != ZPCI_FN_STATE_ONLINE) in zpci_freeze()
720 zpci_unregister_ioat(zdev, 0); in zpci_freeze()
722 return clp_disable_fh(zdev); in zpci_freeze()
733 static int zpci_alloc_domain(struct zpci_dev *zdev) in zpci_alloc_domain() argument
736 zdev->domain = find_first_zero_bit(zpci_domain, ZPCI_NR_DEVICES); in zpci_alloc_domain()
737 if (zdev->domain == ZPCI_NR_DEVICES) { in zpci_alloc_domain()
741 set_bit(zdev->domain, zpci_domain); in zpci_alloc_domain()
746 static void zpci_free_domain(struct zpci_dev *zdev) in zpci_free_domain() argument
749 clear_bit(zdev->domain, zpci_domain); in zpci_free_domain()
755 struct zpci_dev *zdev = get_zdev_by_bus(bus); in pcibios_remove_bus() local
757 zpci_exit_slot(zdev); in pcibios_remove_bus()
758 zpci_cleanup_bus_resources(zdev); in pcibios_remove_bus()
759 zpci_free_domain(zdev); in pcibios_remove_bus()
762 list_del(&zdev->entry); in pcibios_remove_bus()
765 kfree(zdev); in pcibios_remove_bus()
768 static int zpci_scan_bus(struct zpci_dev *zdev) in zpci_scan_bus() argument
773 ret = zpci_setup_bus_resources(zdev, &resources); in zpci_scan_bus()
777 zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops, in zpci_scan_bus()
778 zdev, &resources); in zpci_scan_bus()
779 if (!zdev->bus) { in zpci_scan_bus()
783 zdev->bus->max_bus_speed = zdev->max_bus_speed; in zpci_scan_bus()
784 pci_bus_add_devices(zdev->bus); in zpci_scan_bus()
788 zpci_cleanup_bus_resources(zdev); 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()