Lines Matching refs:zdev

66 	struct zpci_dev *tmp, *zdev = NULL;  in get_zdev_by_fid()  local
71 zdev = tmp; in get_zdev_by_fid()
72 zpci_zdev_get(zdev); in get_zdev_by_fid()
77 return zdev; in get_zdev_by_fid()
82 struct zpci_dev *tmp, *zdev; in zpci_remove_reserved_devices() local
87 list_for_each_entry_safe(zdev, tmp, &zpci_list, entry) { in zpci_remove_reserved_devices()
88 if (zdev->state == ZPCI_FN_STATE_STANDBY && in zpci_remove_reserved_devices()
89 !clp_get_state(zdev->fid, &state) && in zpci_remove_reserved_devices()
91 list_move_tail(&zdev->entry, &remove); in zpci_remove_reserved_devices()
95 list_for_each_entry_safe(zdev, tmp, &remove, entry) in zpci_remove_reserved_devices()
96 zpci_device_reserved(zdev); in zpci_remove_reserved_devices()
112 int zpci_register_ioat(struct zpci_dev *zdev, u8 dmaas, in zpci_register_ioat() argument
115 u64 req = ZPCI_CREATE_REQ(zdev->fh, dmaas, ZPCI_MOD_FC_REG_IOAT); in zpci_register_ioat()
127 int zpci_unregister_ioat(struct zpci_dev *zdev, u8 dmaas) in zpci_unregister_ioat() argument
129 u64 req = ZPCI_CREATE_REQ(zdev->fh, dmaas, ZPCI_MOD_FC_DEREG_IOAT); in zpci_unregister_ioat()
140 int zpci_fmb_enable_device(struct zpci_dev *zdev) in zpci_fmb_enable_device() argument
142 u64 req = ZPCI_CREATE_REQ(zdev->fh, 0, ZPCI_MOD_FC_SET_MEASURE); in zpci_fmb_enable_device()
146 if (zdev->fmb || sizeof(*zdev->fmb) < zdev->fmb_length) in zpci_fmb_enable_device()
149 zdev->fmb = kmem_cache_zalloc(zdev_fmb_cache, GFP_KERNEL); in zpci_fmb_enable_device()
150 if (!zdev->fmb) in zpci_fmb_enable_device()
152 WARN_ON((u64) zdev->fmb & 0xf); in zpci_fmb_enable_device()
155 atomic64_set(&zdev->allocated_pages, 0); in zpci_fmb_enable_device()
156 atomic64_set(&zdev->mapped_pages, 0); in zpci_fmb_enable_device()
157 atomic64_set(&zdev->unmapped_pages, 0); in zpci_fmb_enable_device()
159 fib.fmb_addr = virt_to_phys(zdev->fmb); in zpci_fmb_enable_device()
162 kmem_cache_free(zdev_fmb_cache, zdev->fmb); in zpci_fmb_enable_device()
163 zdev->fmb = NULL; in zpci_fmb_enable_device()
169 int zpci_fmb_disable_device(struct zpci_dev *zdev) in zpci_fmb_disable_device() argument
171 u64 req = ZPCI_CREATE_REQ(zdev->fh, 0, ZPCI_MOD_FC_SET_MEASURE); in zpci_fmb_disable_device()
175 if (!zdev->fmb) in zpci_fmb_disable_device()
184 kmem_cache_free(zdev_fmb_cache, zdev->fmb); in zpci_fmb_disable_device()
185 zdev->fmb = NULL; in zpci_fmb_disable_device()
190 static int zpci_cfg_load(struct zpci_dev *zdev, int offset, u32 *val, u8 len) in zpci_cfg_load() argument
192 u64 req = ZPCI_CREATE_REQ(zdev->fh, ZPCI_PCIAS_CFGSPC, len); in zpci_cfg_load()
206 static int zpci_cfg_store(struct zpci_dev *zdev, int offset, u32 val, u8 len) in zpci_cfg_store() argument
208 u64 req = ZPCI_CREATE_REQ(zdev->fh, ZPCI_PCIAS_CFGSPC, len); in zpci_cfg_store()
294 struct zpci_dev *zdev = to_zpci(pdev); in pci_iomap_range_fh() local
297 idx = zdev->bars[bar].map_idx; in pci_iomap_range_fh()
301 zpci_iomap_start[idx].fh = zdev->fh; in pci_iomap_range_fh()
313 struct zpci_dev *zdev = to_zpci(pdev); in pci_iomap_range_mio() local
316 iova = ioremap((unsigned long) zdev->bars[bar].mio_wt, barsize); in pci_iomap_range_mio()
343 struct zpci_dev *zdev = to_zpci(pdev); in pci_iomap_wc_range_mio() local
346 iova = ioremap((unsigned long) zdev->bars[bar].mio_wb, barsize); in pci_iomap_wc_range_mio()
400 struct zpci_dev *zdev = get_zdev_by_bus(bus, devfn); in pci_read() local
402 return (zdev) ? zpci_cfg_load(zdev, where, val, size) : -ENODEV; in pci_read()
408 struct zpci_dev *zdev = get_zdev_by_bus(bus, devfn); in pci_write() local
410 return (zdev) ? zpci_cfg_store(zdev, where, val, size) : -ENODEV; in pci_write()
420 struct zpci_dev *zdev = to_zpci(pdev); in zpci_map_resources() local
429 if (zpci_use_mio(zdev)) in zpci_map_resources()
431 (resource_size_t __force) zdev->bars[i].mio_wt; in zpci_map_resources()
443 struct zpci_dev *zdev = to_zpci(pdev); in zpci_unmap_resources() local
447 if (zpci_use_mio(zdev)) in zpci_unmap_resources()
459 static int zpci_alloc_iomap(struct zpci_dev *zdev) in zpci_alloc_iomap() argument
474 static void zpci_free_iomap(struct zpci_dev *zdev, int entry) in zpci_free_iomap() argument
482 static struct resource *__alloc_res(struct zpci_dev *zdev, unsigned long start, in __alloc_res() argument
494 r->name = zdev->res_name; in __alloc_res()
503 int zpci_setup_bus_resources(struct zpci_dev *zdev, in zpci_setup_bus_resources() argument
510 snprintf(zdev->res_name, sizeof(zdev->res_name), in zpci_setup_bus_resources()
511 "PCI Bus %04x:%02x", zdev->uid, ZPCI_BUS_NR); in zpci_setup_bus_resources()
514 if (!zdev->bars[i].size) in zpci_setup_bus_resources()
516 entry = zpci_alloc_iomap(zdev); in zpci_setup_bus_resources()
519 zdev->bars[i].map_idx = entry; in zpci_setup_bus_resources()
523 if (zdev->bars[i].val & 8) in zpci_setup_bus_resources()
525 if (zdev->bars[i].val & 4) in zpci_setup_bus_resources()
528 if (zpci_use_mio(zdev)) in zpci_setup_bus_resources()
529 addr = (unsigned long) zdev->bars[i].mio_wt; in zpci_setup_bus_resources()
532 size = 1UL << zdev->bars[i].size; in zpci_setup_bus_resources()
534 res = __alloc_res(zdev, addr, size, flags); in zpci_setup_bus_resources()
536 zpci_free_iomap(zdev, entry); in zpci_setup_bus_resources()
539 zdev->bars[i].res = res; in zpci_setup_bus_resources()
546 static void zpci_cleanup_bus_resources(struct zpci_dev *zdev) in zpci_cleanup_bus_resources() argument
551 if (!zdev->bars[i].size || !zdev->bars[i].res) in zpci_cleanup_bus_resources()
554 zpci_free_iomap(zdev, zdev->bars[i].map_idx); in zpci_cleanup_bus_resources()
555 release_resource(zdev->bars[i].res); in zpci_cleanup_bus_resources()
556 kfree(zdev->bars[i].res); in zpci_cleanup_bus_resources()
562 struct zpci_dev *zdev = to_zpci(pdev); in pcibios_add_device() local
567 zpci_zdev_get(zdev); in pcibios_add_device()
587 struct zpci_dev *zdev = to_zpci(pdev); in pcibios_release_device() local
590 zpci_zdev_put(zdev); in pcibios_release_device()
595 struct zpci_dev *zdev = to_zpci(pdev); in pcibios_enable_device() local
597 zpci_debug_init_device(zdev, dev_name(&pdev->dev)); in pcibios_enable_device()
598 zpci_fmb_enable_device(zdev); in pcibios_enable_device()
605 struct zpci_dev *zdev = to_zpci(pdev); in pcibios_disable_device() local
607 zpci_fmb_disable_device(zdev); in pcibios_disable_device()
608 zpci_debug_exit_device(zdev); in pcibios_disable_device()
659 int zpci_enable_device(struct zpci_dev *zdev) in zpci_enable_device() argument
663 if (clp_enable_fh(zdev, ZPCI_NR_DMA_SPACES)) { in zpci_enable_device()
668 rc = zpci_dma_init_device(zdev); in zpci_enable_device()
672 zdev->state = ZPCI_FN_STATE_ONLINE; in zpci_enable_device()
676 clp_disable_fh(zdev); in zpci_enable_device()
682 int zpci_disable_device(struct zpci_dev *zdev) in zpci_disable_device() argument
684 zpci_dma_exit_device(zdev); in zpci_disable_device()
689 return clp_disable_fh(zdev) ? -EIO : 0; in zpci_disable_device()
702 void zpci_remove_device(struct zpci_dev *zdev, bool set_error) in zpci_remove_device() argument
704 struct zpci_bus *zbus = zdev->zbus; in zpci_remove_device()
707 if (!zdev->zbus->bus) in zpci_remove_device()
710 pdev = pci_get_slot(zbus->bus, zdev->devfn); in zpci_remove_device()
715 zpci_iov_remove_virtfn(pdev, zdev->vfn); in zpci_remove_device()
739 struct zpci_dev *zdev; in zpci_create_device() local
743 zdev = kzalloc(sizeof(*zdev), GFP_KERNEL); in zpci_create_device()
744 if (!zdev) in zpci_create_device()
748 zdev->fid = fid; in zpci_create_device()
749 zdev->fh = fh; in zpci_create_device()
752 rc = clp_query_pci_fn(zdev); in zpci_create_device()
755 zdev->state = state; in zpci_create_device()
757 kref_init(&zdev->kref); in zpci_create_device()
758 mutex_init(&zdev->lock); in zpci_create_device()
760 rc = zpci_init_iommu(zdev); in zpci_create_device()
764 if (zdev->state == ZPCI_FN_STATE_CONFIGURED) { in zpci_create_device()
765 rc = zpci_enable_device(zdev); in zpci_create_device()
770 rc = zpci_bus_device_register(zdev, &pci_root_ops); in zpci_create_device()
775 list_add_tail(&zdev->entry, &zpci_list); in zpci_create_device()
781 if (zdev->state == ZPCI_FN_STATE_ONLINE) in zpci_create_device()
782 zpci_disable_device(zdev); in zpci_create_device()
784 zpci_destroy_iommu(zdev); in zpci_create_device()
787 kfree(zdev); in zpci_create_device()
791 bool zpci_is_device_configured(struct zpci_dev *zdev) in zpci_is_device_configured() argument
793 enum zpci_state state = zdev->state; in zpci_is_device_configured()
808 void zpci_device_reserved(struct zpci_dev *zdev) in zpci_device_reserved() argument
810 if (zdev->has_hp_slot) in zpci_device_reserved()
811 zpci_exit_slot(zdev); in zpci_device_reserved()
817 list_del(&zdev->entry); in zpci_device_reserved()
819 zdev->state = ZPCI_FN_STATE_RESERVED; in zpci_device_reserved()
820 zpci_dbg(3, "rsv fid:%x\n", zdev->fid); in zpci_device_reserved()
821 zpci_zdev_put(zdev); in zpci_device_reserved()
826 struct zpci_dev *zdev = container_of(kref, struct zpci_dev, kref); in zpci_release_device() local
828 if (zdev->zbus->bus) in zpci_release_device()
829 zpci_remove_device(zdev, false); in zpci_release_device()
831 switch (zdev->state) { in zpci_release_device()
834 zpci_disable_device(zdev); in zpci_release_device()
837 if (zdev->has_hp_slot) in zpci_release_device()
838 zpci_exit_slot(zdev); in zpci_release_device()
840 list_del(&zdev->entry); in zpci_release_device()
842 zpci_dbg(3, "rsv fid:%x\n", zdev->fid); in zpci_release_device()
845 zpci_cleanup_bus_resources(zdev); in zpci_release_device()
846 zpci_bus_device_unregister(zdev); in zpci_release_device()
847 zpci_destroy_iommu(zdev); in zpci_release_device()
852 zpci_dbg(3, "rem fid:%x\n", zdev->fid); in zpci_release_device()
853 kfree(zdev); in zpci_release_device()
859 struct zpci_dev *zdev = to_zpci(pdev); in zpci_report_error() local
861 return sclp_pci_report(report, zdev->fh, zdev->fid); in zpci_report_error()