Lines Matching refs:zdev
72 struct zpci_dev *tmp, *zdev = NULL;
77 zdev = tmp;
78 zpci_zdev_get(zdev);
83 return zdev;
88 struct zpci_dev *tmp, *zdev;
93 list_for_each_entry_safe(zdev, tmp, &zpci_list, entry) {
94 if (zdev->state == ZPCI_FN_STATE_STANDBY &&
95 !clp_get_state(zdev->fid, &state) &&
97 list_move_tail(&zdev->entry, &remove);
101 list_for_each_entry_safe(zdev, tmp, &remove, entry)
102 zpci_device_reserved(zdev);
118 int zpci_register_ioat(struct zpci_dev *zdev, u8 dmaas,
121 u64 req = ZPCI_CREATE_REQ(zdev->fh, dmaas, ZPCI_MOD_FC_REG_IOAT);
129 fib.gd = zdev->gisa;
132 zpci_dbg(3, "reg ioat fid:%x, cc:%d, status:%d\n", zdev->fid, cc, *status);
138 int zpci_unregister_ioat(struct zpci_dev *zdev, u8 dmaas)
140 u64 req = ZPCI_CREATE_REQ(zdev->fh, dmaas, ZPCI_MOD_FC_DEREG_IOAT);
144 fib.gd = zdev->gisa;
148 zpci_dbg(3, "unreg ioat fid:%x, cc:%d, status:%d\n", zdev->fid, cc, status);
153 int zpci_fmb_enable_device(struct zpci_dev *zdev)
155 u64 req = ZPCI_CREATE_REQ(zdev->fh, 0, ZPCI_MOD_FC_SET_MEASURE);
159 if (zdev->fmb || sizeof(*zdev->fmb) < zdev->fmb_length)
162 zdev->fmb = kmem_cache_zalloc(zdev_fmb_cache, GFP_KERNEL);
163 if (!zdev->fmb)
165 WARN_ON((u64) zdev->fmb & 0xf);
168 atomic64_set(&zdev->allocated_pages, 0);
169 atomic64_set(&zdev->mapped_pages, 0);
170 atomic64_set(&zdev->unmapped_pages, 0);
172 fib.fmb_addr = virt_to_phys(zdev->fmb);
173 fib.gd = zdev->gisa;
176 kmem_cache_free(zdev_fmb_cache, zdev->fmb);
177 zdev->fmb = NULL;
183 int zpci_fmb_disable_device(struct zpci_dev *zdev)
185 u64 req = ZPCI_CREATE_REQ(zdev->fh, 0, ZPCI_MOD_FC_SET_MEASURE);
189 if (!zdev->fmb)
192 fib.gd = zdev->gisa;
200 kmem_cache_free(zdev_fmb_cache, zdev->fmb);
201 zdev->fmb = NULL;
206 static int zpci_cfg_load(struct zpci_dev *zdev, int offset, u32 *val, u8 len)
208 u64 req = ZPCI_CREATE_REQ(zdev->fh, ZPCI_PCIAS_CFGSPC, len);
222 static int zpci_cfg_store(struct zpci_dev *zdev, int offset, u32 val, u8 len)
224 u64 req = ZPCI_CREATE_REQ(zdev->fh, ZPCI_PCIAS_CFGSPC, len);
273 struct zpci_dev *zdev = to_zpci(pdev);
276 idx = zdev->bars[bar].map_idx;
280 zpci_iomap_start[idx].fh = zdev->fh;
292 struct zpci_dev *zdev = to_zpci(pdev);
295 iova = ioremap((unsigned long) zdev->bars[bar].mio_wt, barsize);
322 struct zpci_dev *zdev = to_zpci(pdev);
325 iova = ioremap((unsigned long) zdev->bars[bar].mio_wb, barsize);
379 struct zpci_dev *zdev = zdev_from_bus(bus, devfn);
381 return (zdev) ? zpci_cfg_load(zdev, where, val, size) : -ENODEV;
387 struct zpci_dev *zdev = zdev_from_bus(bus, devfn);
389 return (zdev) ? zpci_cfg_store(zdev, where, val, size) : -ENODEV;
399 struct zpci_dev *zdev = to_zpci(pdev);
408 if (zpci_use_mio(zdev))
410 (resource_size_t __force) zdev->bars[i].mio_wt;
422 struct zpci_dev *zdev = to_zpci(pdev);
426 if (zpci_use_mio(zdev))
438 static int zpci_alloc_iomap(struct zpci_dev *zdev)
453 static void zpci_free_iomap(struct zpci_dev *zdev, int entry)
461 static void zpci_do_update_iomap_fh(struct zpci_dev *zdev, u32 fh)
467 if (!zdev->bars[bar].size)
469 idx = zdev->bars[bar].map_idx;
472 WRITE_ONCE(zpci_iomap_start[idx].fh, zdev->fh);
477 void zpci_update_fh(struct zpci_dev *zdev, u32 fh)
479 if (!fh || zdev->fh == fh)
482 zdev->fh = fh;
483 if (zpci_use_mio(zdev))
485 if (zdev->has_resources && zdev_enabled(zdev))
486 zpci_do_update_iomap_fh(zdev, fh);
489 static struct resource *__alloc_res(struct zpci_dev *zdev, unsigned long start,
501 r->name = zdev->res_name;
510 int zpci_setup_bus_resources(struct zpci_dev *zdev)
516 snprintf(zdev->res_name, sizeof(zdev->res_name),
517 "PCI Bus %04x:%02x", zdev->uid, ZPCI_BUS_NR);
520 if (!zdev->bars[i].size)
522 entry = zpci_alloc_iomap(zdev);
525 zdev->bars[i].map_idx = entry;
529 if (zdev->bars[i].val & 8)
531 if (zdev->bars[i].val & 4)
534 if (zpci_use_mio(zdev))
535 addr = (unsigned long) zdev->bars[i].mio_wt;
538 size = 1UL << zdev->bars[i].size;
540 res = __alloc_res(zdev, addr, size, flags);
542 zpci_free_iomap(zdev, entry);
545 zdev->bars[i].res = res;
547 zdev->has_resources = 1;
552 static void zpci_cleanup_bus_resources(struct zpci_dev *zdev)
559 res = zdev->bars[i].res;
564 pci_bus_remove_resource(zdev->zbus->bus, res);
565 zpci_free_iomap(zdev, zdev->bars[i].map_idx);
566 zdev->bars[i].res = NULL;
569 zdev->has_resources = 0;
575 struct zpci_dev *zdev = to_zpci(pdev);
579 /* The pdev has a reference to the zdev via its bus */
580 zpci_zdev_get(zdev);
600 struct zpci_dev *zdev = to_zpci(pdev);
603 zpci_zdev_put(zdev);
608 struct zpci_dev *zdev = to_zpci(pdev);
610 zpci_debug_init_device(zdev, dev_name(&pdev->dev));
611 zpci_fmb_enable_device(zdev);
618 struct zpci_dev *zdev = to_zpci(pdev);
620 zpci_fmb_disable_device(zdev);
621 zpci_debug_exit_device(zdev);
672 int zpci_enable_device(struct zpci_dev *zdev)
674 u32 fh = zdev->fh;
677 if (clp_enable_fh(zdev, &fh, ZPCI_NR_DMA_SPACES))
680 zpci_update_fh(zdev, fh);
685 int zpci_disable_device(struct zpci_dev *zdev)
687 u32 fh = zdev->fh;
690 cc = clp_disable_fh(zdev, &fh);
692 zpci_update_fh(zdev, fh);
695 zdev->fid);
697 rc = clp_refresh_fh(zdev->fid, &fh);
699 zpci_update_fh(zdev, fh);
711 * @zdev: the slot which should be reset
732 int zpci_hot_reset_device(struct zpci_dev *zdev)
737 zpci_dbg(3, "rst fid:%x, fh:%x\n", zdev->fid, zdev->fh);
738 if (zdev_enabled(zdev)) {
740 rc = zpci_disable_device(zdev);
752 rc = zpci_enable_device(zdev);
756 if (zdev->dma_table)
757 rc = zpci_register_ioat(zdev, 0, zdev->start_dma, zdev->end_dma,
758 virt_to_phys(zdev->dma_table), &status);
760 rc = zpci_dma_init_device(zdev);
762 zpci_disable_device(zdev);
778 * Returns: the zdev on success or an error pointer otherwise
782 struct zpci_dev *zdev;
786 zdev = kzalloc(sizeof(*zdev), GFP_KERNEL);
787 if (!zdev)
791 zdev->fid = fid;
792 zdev->fh = fh;
794 /* Query function properties and update zdev */
795 rc = clp_query_pci_fn(zdev);
798 zdev->state = state;
800 kref_init(&zdev->kref);
801 mutex_init(&zdev->lock);
802 mutex_init(&zdev->kzdev_lock);
804 rc = zpci_init_iommu(zdev);
808 rc = zpci_bus_device_register(zdev, &pci_root_ops);
813 list_add_tail(&zdev->entry, &zpci_list);
816 return zdev;
819 zpci_destroy_iommu(zdev);
822 kfree(zdev);
826 bool zpci_is_device_configured(struct zpci_dev *zdev)
828 enum zpci_state state = zdev->state;
836 * @zdev: The zpci_dev to be configured
845 int zpci_scan_configured_device(struct zpci_dev *zdev, u32 fh)
847 zpci_update_fh(zdev, fh);
848 return zpci_bus_scan_device(zdev);
853 * @zdev: The zpci_dev to configure
861 int zpci_deconfigure_device(struct zpci_dev *zdev)
865 if (zdev->zbus->bus)
866 zpci_bus_remove_device(zdev, false);
868 if (zdev->dma_table) {
869 rc = zpci_dma_exit_device(zdev);
873 if (zdev_enabled(zdev)) {
874 rc = zpci_disable_device(zdev);
879 rc = sclp_pci_deconfigure(zdev->fid);
880 zpci_dbg(3, "deconf fid:%x, rc:%d\n", zdev->fid, rc);
883 zdev->state = ZPCI_FN_STATE_STANDBY;
890 * @zdev: the zpci_dev that was reserved
897 void zpci_device_reserved(struct zpci_dev *zdev)
899 if (zdev->has_hp_slot)
900 zpci_exit_slot(zdev);
906 list_del(&zdev->entry);
908 zdev->state = ZPCI_FN_STATE_RESERVED;
909 zpci_dbg(3, "rsv fid:%x\n", zdev->fid);
910 zpci_zdev_put(zdev);
915 struct zpci_dev *zdev = container_of(kref, struct zpci_dev, kref);
918 if (zdev->zbus->bus)
919 zpci_bus_remove_device(zdev, false);
921 if (zdev->dma_table)
922 zpci_dma_exit_device(zdev);
923 if (zdev_enabled(zdev))
924 zpci_disable_device(zdev);
926 switch (zdev->state) {
928 ret = sclp_pci_deconfigure(zdev->fid);
929 zpci_dbg(3, "deconf fid:%x, rc:%d\n", zdev->fid, ret);
932 if (zdev->has_hp_slot)
933 zpci_exit_slot(zdev);
935 list_del(&zdev->entry);
937 zpci_dbg(3, "rsv fid:%x\n", zdev->fid);
940 if (zdev->has_resources)
941 zpci_cleanup_bus_resources(zdev);
942 zpci_bus_device_unregister(zdev);
943 zpci_destroy_iommu(zdev);
948 zpci_dbg(3, "rem fid:%x\n", zdev->fid);
949 kfree_rcu(zdev, rcu);
955 struct zpci_dev *zdev = to_zpci(pdev);
957 return sclp_pci_report(report, zdev->fh, zdev->fid);
963 * @zdev: The zdev for which the zPCI error state should be reset
971 int zpci_clear_error_state(struct zpci_dev *zdev)
973 u64 req = ZPCI_CREATE_REQ(zdev->fh, 0, ZPCI_MOD_FC_RESET_ERROR);
980 zpci_dbg(3, "ces fid:%x, cc:%d, status:%x\n", zdev->fid, cc, status);
989 * @zdev: The zdev for which to unblock load/store access
998 int zpci_reset_load_store_blocked(struct zpci_dev *zdev)
1000 u64 req = ZPCI_CREATE_REQ(zdev->fh, 0, ZPCI_MOD_FC_RESET_BLOCK);
1007 zpci_dbg(3, "rls fid:%x, cc:%d, status:%x\n", zdev->fid, cc, status);