Lines Matching refs:zdev

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