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()
125 zpci_dbg(3, "reg ioat fid:%x, cc:%d, status:%d\n", zdev->fid, cc, status); in zpci_register_ioat()
130 int zpci_unregister_ioat(struct zpci_dev *zdev, u8 dmaas) in zpci_unregister_ioat() argument
132 u64 req = ZPCI_CREATE_REQ(zdev->fh, dmaas, ZPCI_MOD_FC_DEREG_IOAT); in zpci_unregister_ioat()
138 zpci_dbg(3, "unreg ioat fid:%x, cc:%d, status:%d\n", zdev->fid, cc, status); in zpci_unregister_ioat()
143 int zpci_fmb_enable_device(struct zpci_dev *zdev) in zpci_fmb_enable_device() argument
145 u64 req = ZPCI_CREATE_REQ(zdev->fh, 0, ZPCI_MOD_FC_SET_MEASURE); in zpci_fmb_enable_device()
149 if (zdev->fmb || sizeof(*zdev->fmb) < zdev->fmb_length) in zpci_fmb_enable_device()
152 zdev->fmb = kmem_cache_zalloc(zdev_fmb_cache, GFP_KERNEL); in zpci_fmb_enable_device()
153 if (!zdev->fmb) in zpci_fmb_enable_device()
155 WARN_ON((u64) zdev->fmb & 0xf); in zpci_fmb_enable_device()
158 atomic64_set(&zdev->allocated_pages, 0); in zpci_fmb_enable_device()
159 atomic64_set(&zdev->mapped_pages, 0); in zpci_fmb_enable_device()
160 atomic64_set(&zdev->unmapped_pages, 0); in zpci_fmb_enable_device()
162 fib.fmb_addr = virt_to_phys(zdev->fmb); in zpci_fmb_enable_device()
165 kmem_cache_free(zdev_fmb_cache, zdev->fmb); in zpci_fmb_enable_device()
166 zdev->fmb = NULL; in zpci_fmb_enable_device()
172 int zpci_fmb_disable_device(struct zpci_dev *zdev) in zpci_fmb_disable_device() argument
174 u64 req = ZPCI_CREATE_REQ(zdev->fh, 0, ZPCI_MOD_FC_SET_MEASURE); in zpci_fmb_disable_device()
178 if (!zdev->fmb) in zpci_fmb_disable_device()
187 kmem_cache_free(zdev_fmb_cache, zdev->fmb); in zpci_fmb_disable_device()
188 zdev->fmb = NULL; in zpci_fmb_disable_device()
193 static int zpci_cfg_load(struct zpci_dev *zdev, int offset, u32 *val, u8 len) in zpci_cfg_load() argument
195 u64 req = ZPCI_CREATE_REQ(zdev->fh, ZPCI_PCIAS_CFGSPC, len); in zpci_cfg_load()
209 static int zpci_cfg_store(struct zpci_dev *zdev, int offset, u32 val, u8 len) in zpci_cfg_store() argument
211 u64 req = ZPCI_CREATE_REQ(zdev->fh, ZPCI_PCIAS_CFGSPC, len); in zpci_cfg_store()
297 struct zpci_dev *zdev = to_zpci(pdev); in pci_iomap_range_fh() local
300 idx = zdev->bars[bar].map_idx; in pci_iomap_range_fh()
304 zpci_iomap_start[idx].fh = zdev->fh; in pci_iomap_range_fh()
316 struct zpci_dev *zdev = to_zpci(pdev); in pci_iomap_range_mio() local
319 iova = ioremap((unsigned long) zdev->bars[bar].mio_wt, barsize); in pci_iomap_range_mio()
346 struct zpci_dev *zdev = to_zpci(pdev); in pci_iomap_wc_range_mio() local
349 iova = ioremap((unsigned long) zdev->bars[bar].mio_wb, barsize); in pci_iomap_wc_range_mio()
403 struct zpci_dev *zdev = get_zdev_by_bus(bus, devfn); in pci_read() local
405 return (zdev) ? zpci_cfg_load(zdev, where, val, size) : -ENODEV; in pci_read()
411 struct zpci_dev *zdev = get_zdev_by_bus(bus, devfn); in pci_write() local
413 return (zdev) ? zpci_cfg_store(zdev, where, val, size) : -ENODEV; in pci_write()
423 struct zpci_dev *zdev = to_zpci(pdev); in zpci_map_resources() local
432 if (zpci_use_mio(zdev)) in zpci_map_resources()
434 (resource_size_t __force) zdev->bars[i].mio_wt; in zpci_map_resources()
446 struct zpci_dev *zdev = to_zpci(pdev); in zpci_unmap_resources() local
450 if (zpci_use_mio(zdev)) in zpci_unmap_resources()
462 static int zpci_alloc_iomap(struct zpci_dev *zdev) in zpci_alloc_iomap() argument
477 static void zpci_free_iomap(struct zpci_dev *zdev, int entry) in zpci_free_iomap() argument
485 static struct resource *__alloc_res(struct zpci_dev *zdev, unsigned long start, in __alloc_res() argument
497 r->name = zdev->res_name; in __alloc_res()
506 int zpci_setup_bus_resources(struct zpci_dev *zdev) in zpci_setup_bus_resources() argument
512 snprintf(zdev->res_name, sizeof(zdev->res_name), in zpci_setup_bus_resources()
513 "PCI Bus %04x:%02x", zdev->uid, ZPCI_BUS_NR); in zpci_setup_bus_resources()
516 if (!zdev->bars[i].size) in zpci_setup_bus_resources()
518 entry = zpci_alloc_iomap(zdev); in zpci_setup_bus_resources()
521 zdev->bars[i].map_idx = entry; in zpci_setup_bus_resources()
525 if (zdev->bars[i].val & 8) in zpci_setup_bus_resources()
527 if (zdev->bars[i].val & 4) in zpci_setup_bus_resources()
530 if (zpci_use_mio(zdev)) in zpci_setup_bus_resources()
531 addr = (unsigned long) zdev->bars[i].mio_wt; in zpci_setup_bus_resources()
534 size = 1UL << zdev->bars[i].size; in zpci_setup_bus_resources()
536 res = __alloc_res(zdev, addr, size, flags); in zpci_setup_bus_resources()
538 zpci_free_iomap(zdev, entry); in zpci_setup_bus_resources()
541 zdev->bars[i].res = res; in zpci_setup_bus_resources()
543 zdev->has_resources = 1; in zpci_setup_bus_resources()
548 static void zpci_cleanup_bus_resources(struct zpci_dev *zdev) in zpci_cleanup_bus_resources() argument
555 res = zdev->bars[i].res; in zpci_cleanup_bus_resources()
560 pci_bus_remove_resource(zdev->zbus->bus, res); in zpci_cleanup_bus_resources()
561 zpci_free_iomap(zdev, zdev->bars[i].map_idx); in zpci_cleanup_bus_resources()
562 zdev->bars[i].res = NULL; in zpci_cleanup_bus_resources()
565 zdev->has_resources = 0; in zpci_cleanup_bus_resources()
571 struct zpci_dev *zdev = to_zpci(pdev); in pcibios_add_device() local
576 zpci_zdev_get(zdev); in pcibios_add_device()
596 struct zpci_dev *zdev = to_zpci(pdev); in pcibios_release_device() local
599 zpci_zdev_put(zdev); in pcibios_release_device()
604 struct zpci_dev *zdev = to_zpci(pdev); in pcibios_enable_device() local
606 zpci_debug_init_device(zdev, dev_name(&pdev->dev)); in pcibios_enable_device()
607 zpci_fmb_enable_device(zdev); in pcibios_enable_device()
614 struct zpci_dev *zdev = to_zpci(pdev); in pcibios_disable_device() local
616 zpci_fmb_disable_device(zdev); in pcibios_disable_device()
617 zpci_debug_exit_device(zdev); in pcibios_disable_device()
668 int zpci_enable_device(struct zpci_dev *zdev) in zpci_enable_device() argument
670 u32 fh = zdev->fh; in zpci_enable_device()
673 if (clp_enable_fh(zdev, &fh, ZPCI_NR_DMA_SPACES)) in zpci_enable_device()
676 zdev->fh = fh; in zpci_enable_device()
680 int zpci_disable_device(struct zpci_dev *zdev) in zpci_disable_device() argument
682 u32 fh = zdev->fh; in zpci_disable_device()
685 cc = clp_disable_fh(zdev, &fh); in zpci_disable_device()
687 zdev->fh = fh; in zpci_disable_device()
690 zdev->fid); in zpci_disable_device()
692 rc = clp_refresh_fh(zdev->fid, &fh); in zpci_disable_device()
694 zdev->fh = fh; in zpci_disable_device()
716 struct zpci_dev *zdev; in zpci_create_device() local
720 zdev = kzalloc(sizeof(*zdev), GFP_KERNEL); in zpci_create_device()
721 if (!zdev) in zpci_create_device()
725 zdev->fid = fid; in zpci_create_device()
726 zdev->fh = fh; in zpci_create_device()
729 rc = clp_query_pci_fn(zdev); in zpci_create_device()
732 zdev->state = state; in zpci_create_device()
734 kref_init(&zdev->kref); in zpci_create_device()
735 mutex_init(&zdev->lock); in zpci_create_device()
737 rc = zpci_init_iommu(zdev); in zpci_create_device()
741 rc = zpci_bus_device_register(zdev, &pci_root_ops); in zpci_create_device()
746 list_add_tail(&zdev->entry, &zpci_list); in zpci_create_device()
749 return zdev; in zpci_create_device()
752 zpci_destroy_iommu(zdev); in zpci_create_device()
755 kfree(zdev); in zpci_create_device()
759 bool zpci_is_device_configured(struct zpci_dev *zdev) in zpci_is_device_configured() argument
761 enum zpci_state state = zdev->state; in zpci_is_device_configured()
780 int zpci_scan_configured_device(struct zpci_dev *zdev, u32 fh) in zpci_scan_configured_device() argument
784 zdev->fh = fh; in zpci_scan_configured_device()
786 if (!zdev->zbus->bus) in zpci_scan_configured_device()
793 if (zdev->devfn == 0 && zdev->zbus->multifunction) in zpci_scan_configured_device()
794 rc = zpci_bus_scan_bus(zdev->zbus); in zpci_scan_configured_device()
796 rc = zpci_bus_scan_device(zdev); in zpci_scan_configured_device()
811 int zpci_deconfigure_device(struct zpci_dev *zdev) in zpci_deconfigure_device() argument
815 if (zdev->zbus->bus) in zpci_deconfigure_device()
816 zpci_bus_remove_device(zdev, false); in zpci_deconfigure_device()
818 if (zdev->dma_table) { in zpci_deconfigure_device()
819 rc = zpci_dma_exit_device(zdev); in zpci_deconfigure_device()
823 if (zdev_enabled(zdev)) { in zpci_deconfigure_device()
824 rc = zpci_disable_device(zdev); in zpci_deconfigure_device()
829 rc = sclp_pci_deconfigure(zdev->fid); in zpci_deconfigure_device()
830 zpci_dbg(3, "deconf fid:%x, rc:%d\n", zdev->fid, rc); in zpci_deconfigure_device()
833 zdev->state = ZPCI_FN_STATE_STANDBY; in zpci_deconfigure_device()
847 void zpci_device_reserved(struct zpci_dev *zdev) in zpci_device_reserved() argument
849 if (zdev->has_hp_slot) in zpci_device_reserved()
850 zpci_exit_slot(zdev); in zpci_device_reserved()
856 list_del(&zdev->entry); in zpci_device_reserved()
858 zdev->state = ZPCI_FN_STATE_RESERVED; in zpci_device_reserved()
859 zpci_dbg(3, "rsv fid:%x\n", zdev->fid); in zpci_device_reserved()
860 zpci_zdev_put(zdev); in zpci_device_reserved()
865 struct zpci_dev *zdev = container_of(kref, struct zpci_dev, kref); in zpci_release_device() local
868 if (zdev->zbus->bus) in zpci_release_device()
869 zpci_bus_remove_device(zdev, false); in zpci_release_device()
871 if (zdev->dma_table) in zpci_release_device()
872 zpci_dma_exit_device(zdev); in zpci_release_device()
873 if (zdev_enabled(zdev)) in zpci_release_device()
874 zpci_disable_device(zdev); in zpci_release_device()
876 switch (zdev->state) { in zpci_release_device()
878 ret = sclp_pci_deconfigure(zdev->fid); in zpci_release_device()
879 zpci_dbg(3, "deconf fid:%x, rc:%d\n", zdev->fid, ret); in zpci_release_device()
882 if (zdev->has_hp_slot) in zpci_release_device()
883 zpci_exit_slot(zdev); in zpci_release_device()
885 list_del(&zdev->entry); in zpci_release_device()
887 zpci_dbg(3, "rsv fid:%x\n", zdev->fid); in zpci_release_device()
890 if (zdev->has_resources) in zpci_release_device()
891 zpci_cleanup_bus_resources(zdev); in zpci_release_device()
892 zpci_bus_device_unregister(zdev); in zpci_release_device()
893 zpci_destroy_iommu(zdev); in zpci_release_device()
898 zpci_dbg(3, "rem fid:%x\n", zdev->fid); in zpci_release_device()
899 kfree(zdev); in zpci_release_device()
905 struct zpci_dev *zdev = to_zpci(pdev); in zpci_report_error() local
907 return sclp_pci_report(report, zdev->fh, zdev->fid); in zpci_report_error()