Lines Matching refs:ptdev

120 cfginit_cap(struct vmctx *ctx, struct passthru_dev *ptdev)  in cfginit_cap()  argument
123 struct pci_device *phys_dev = ptdev->phys_dev; in cfginit_cap()
135 ptdev->msi.capoff = ptr; in cfginit_cap()
137 ptdev->msix.capoff = ptr; in cfginit_cap()
139 ptdev->pcie_cap = true; in cfginit_cap()
141 ptdev->pmcap.capoff = ptr; in cfginit_cap()
151 passthru_set_power_state(struct passthru_dev *ptdev, uint16_t dpsts) { in passthru_set_power_state() argument
156 if (ptdev->pmcap.capoff != 0) { in passthru_set_power_state()
157 val = read_config(ptdev->phys_dev, in passthru_set_power_state()
158 ptdev->pmcap.capoff + PCIR_POWER_STATUS, 2); in passthru_set_power_state()
161 write_config(ptdev->phys_dev, in passthru_set_power_state()
162 ptdev->pmcap.capoff + PCIR_POWER_STATUS, 2, val); in passthru_set_power_state()
169 static inline int ptdev_msix_table_bar(struct passthru_dev *ptdev) in ptdev_msix_table_bar() argument
171 return ptdev->dev->msix.table_bar; in ptdev_msix_table_bar()
174 static inline int ptdev_msix_pba_bar(struct passthru_dev *ptdev) in ptdev_msix_pba_bar() argument
176 return ptdev->dev->msix.pba_bar; in ptdev_msix_pba_bar()
187 struct passthru_dev *ptdev; in load_pci_rombar() local
194 ptdev = (struct passthru_dev *) dev->arg; in load_pci_rombar()
198 ptdev->need_rombar = false; in load_pci_rombar()
213 ptdev->need_rombar = false; in load_pci_rombar()
217 ptdev->need_rombar = false; in load_pci_rombar()
219 if (ptdev->need_rombar) { in load_pci_rombar()
226 ptdev->rom_buffer = rom_buffer; in load_pci_rombar()
239 ptdev->need_rombar = false; in load_pci_rombar()
247 ptdev->need_rombar = false; in load_pci_rombar()
261 struct passthru_dev *ptdev; in release_pci_rombar() local
267 ptdev = (struct passthru_dev *) dev->arg; in release_pci_rombar()
280 free(ptdev->rom_buffer); in release_pci_rombar()
281 ptdev->rom_buffer = NULL; in release_pci_rombar()
282 ptdev->need_rombar = false; in release_pci_rombar()
287 cfginitbar(struct vmctx *ctx, struct passthru_dev *ptdev) in cfginitbar() argument
296 dev = ptdev->dev; in cfginitbar()
303 bar.sel = ptdev->sel; in cfginitbar()
306 bar.base = read_config(ptdev->phys_dev, bar.reg, 4); in cfginitbar()
307 bar.length = ptdev->phys_dev->regions[i].size; in cfginitbar()
330 ptdev->sel.bus, ptdev->sel.dev, in cfginitbar()
331 ptdev->sel.func, i, base); in cfginitbar()
338 ptdev->sel.bus, ptdev->sel.dev, in cfginitbar()
339 ptdev->sel.func, i, size, roundup2(size, PAGE_SIZE)); in cfginitbar()
346 ptdev->bar[i].type = bartype; in cfginitbar()
347 ptdev->bar[i].size = size; in cfginitbar()
348 ptdev->bar[i].addr = base; in cfginitbar()
391 ptdev->bar[i].type = PCIBAR_MEMHI64; in cfginitbar()
405 cfginit(struct vmctx *ctx, struct passthru_dev *ptdev, int bus, in cfginit() argument
412 bzero(&ptdev->sel, sizeof(struct pcisel)); in cfginit()
413 ptdev->sel.bus = bus; in cfginit()
414 ptdev->sel.dev = slot; in cfginit()
415 ptdev->sel.func = func; in cfginit()
417 if (cfginit_cap(ctx, ptdev) != 0) { in cfginit()
424 if (ptdev->msi.capoff == 0 && ptdev->msix.capoff == 0) { in cfginit()
436 if (ptdev->need_reset) { in cfginit()
450 if (ptdev->d3hot_reset) { in cfginit()
451 if ((passthru_set_power_state(ptdev, PCIM_PSTAT_D3) != 0) || in cfginit()
452 passthru_set_power_state(ptdev, PCIM_PSTAT_D0) != 0) in cfginit()
456 if (cfginitbar(ctx, ptdev) != 0) { in cfginit()
516 struct passthru_dev *ptdev; in is_intel_graphics_dev() local
519 ptdev = (struct passthru_dev *) dev->arg; in is_intel_graphics_dev()
521 if (ptdev->phys_bdf != PCI_BDF(0, 2, 0)) in is_intel_graphics_dev()
619 passthru_gpu_dsm_opregion(struct vmctx *ctx, struct passthru_dev *ptdev, in passthru_gpu_dsm_opregion() argument
626 opregion_phys = read_config(ptdev->phys_dev, PCIR_ASLS_CTL, 4); in passthru_gpu_dsm_opregion()
636 gpu_dsm_size = igd_dsm_region_size(ptdev->phys_dev); in passthru_gpu_dsm_opregion()
646 gpu_dsm_hpa = read_config(ptdev->phys_dev, PCIR_GEN11_BDSM_DW0, 4); in passthru_gpu_dsm_opregion()
649 gpu_dsm_hpa |= (uint64_t)read_config(ptdev->phys_dev, PCIR_GEN11_BDSM_DW1, 4) << 32; in passthru_gpu_dsm_opregion()
656 pci_set_cfgdata32(ptdev->dev, PCIR_GEN11_BDSM_DW0, gpu_dsm_gpa | dsm_mask_val); in passthru_gpu_dsm_opregion()
658 pci_set_cfgdata32(ptdev->dev, PCIR_GEN11_BDSM_DW1, 0); in passthru_gpu_dsm_opregion()
660 ptdev->has_virt_pcicfg_regs = &has_virt_pcicfg_regs_on_ehl_gpu; in passthru_gpu_dsm_opregion()
663 gpu_dsm_hpa = read_config(ptdev->phys_dev, PCIR_BDSM, 4); in passthru_gpu_dsm_opregion()
668 pci_set_cfgdata32(ptdev->dev, PCIR_BDSM, gpu_dsm_gpa | dsm_mask_val); in passthru_gpu_dsm_opregion()
670 ptdev->has_virt_pcicfg_regs = &has_virt_pcicfg_regs_on_def_gpu; in passthru_gpu_dsm_opregion()
674 …pci_set_cfgdata32(ptdev->dev, PCIR_ASLS_CTL, gpu_opregion_gpa | (opregion_phys & ~PCIM_ASLS_OPREGI… in passthru_gpu_dsm_opregion()
718 struct passthru_dev *ptdev; in passthru_init() local
737 ptdev = NULL; in passthru_init()
800 ptdev = calloc(1, sizeof(struct passthru_dev)); in passthru_init()
801 if (ptdev == NULL) { in passthru_init()
807 ptdev->phys_bdf = PCI_BDF(bus, slot, func); in passthru_init()
808 ptdev->need_reset = need_reset; in passthru_init()
809 ptdev->d3hot_reset = d3hot_reset; in passthru_init()
810 update_pt_info(ptdev->phys_bdf); in passthru_init()
821 ptdev->phys_dev = phys_dev; in passthru_init()
833 pci_device_probe(ptdev->phys_dev); in passthru_init()
835 dev->arg = ptdev; in passthru_init()
836 ptdev->dev = dev; in passthru_init()
843 read_config(ptdev->phys_dev, PCIR_MINGNT, 2)); in passthru_init()
849 vendor = read_config(ptdev->phys_dev, PCIR_VENDOR, 2); in passthru_init()
850 device = read_config(ptdev->phys_dev, PCIR_DEVICE, 2); in passthru_init()
851 class = read_config(ptdev->phys_dev, PCIR_CLASS, 1); in passthru_init()
865 error = cfginit(ctx, ptdev, bus, slot, func); in passthru_init()
876 ptdev->need_rombar = need_rombar; in passthru_init()
878 if (ptdev->need_rombar) { in passthru_init()
880 ptdev->need_rombar = false; in passthru_init()
884 if (ptdev->need_rombar) in passthru_init()
895 passthru_gpu_dsm_opregion(ctx, ptdev, &pcidev, device); in passthru_init()
898 if (ptdev->need_rombar) { in passthru_init()
906 pcidev.phys_bdf = ptdev->phys_bdf; in passthru_init()
920 ptdev->phys_pin = irq; in passthru_init()
923 ptdev->phys_pin = read_config(ptdev->phys_dev, PCIR_INTLINE, 1); in passthru_init()
926 if (ptdev->phys_pin == -1 || ptdev->phys_pin > 256) { in passthru_init()
928 bus, slot, func, ptdev->phys_pin); in passthru_init()
934 ptdev->need_dsdt = need_dsdt; in passthru_init()
935 memset(ptdev->dsdt_path, 0, sizeof(ptdev->dsdt_path)); in passthru_init()
936 strncpy(ptdev->dsdt_path, dsdt_path, sizeof(ptdev->dsdt_path) - 1); in passthru_init()
939 error = ptm_probe(ctx, ptdev, &vrp_sec_bus); in passthru_init()
956 if (error && (ptdev != NULL)) { in passthru_init()
957 free(ptdev); in passthru_init()
975 struct passthru_dev *ptdev; in passthru_deinit() local
989 ptdev = (struct passthru_dev *) dev->arg; in passthru_deinit()
992 virt_bdf, ptdev->phys_bdf, dev->lintr.ioapic_irq); in passthru_deinit()
994 vm_reset_ptdev_intx_info(ctx, virt_bdf, ptdev->phys_bdf, dev->lintr.ioapic_irq, false); in passthru_deinit()
997 if (ptdev->need_rombar) { in passthru_deinit()
999 ptdev->need_rombar = false; in passthru_deinit()
1002 if (ptdev) in passthru_deinit()
1003 phys_bdf = ptdev->phys_bdf; in passthru_deinit()
1011 pcidev.phys_bdf = ptdev->phys_bdf; in passthru_deinit()
1013 free(ptdev); in passthru_deinit()
1040 struct passthru_dev *ptdev = dev->arg; in passthru_bind_irq() local
1052 dev->lintr.ioapic_irq, ptdev->phys_pin, in passthru_bind_irq()
1053 virt_bdf, ptdev->phys_bdf); in passthru_bind_irq()
1055 vm_set_ptdev_intx_info(ctx, virt_bdf, ptdev->phys_bdf, in passthru_bind_irq()
1056 dev->lintr.ioapic_irq, ptdev->phys_pin, false); in passthru_bind_irq()
1063 struct passthru_dev *ptdev = dev->arg; in passthru_cfgread() local
1067 } else if (ptdev->has_virt_pcicfg_regs && ptdev->has_virt_pcicfg_regs(coff)) in passthru_cfgread()
1070 *rv = read_config(ptdev->phys_dev, coff, bytes); in passthru_cfgread()
1079 struct passthru_dev *ptdev = dev->arg; in passthru_cfgwrite() local
1104 if (!(ptdev->has_virt_pcicfg_regs && ptdev->has_virt_pcicfg_regs(coff))) in passthru_cfgwrite()
1105 write_config(ptdev->phys_dev, coff, bytes, val); in passthru_cfgwrite()
1844 struct passthru_dev *ptdev = NULL; in write_dsdt_file() local
1851 ptdev = (struct passthru_dev *) dev->arg; in write_dsdt_file()
1852 dsdt_path = ptdev->dsdt_path; in write_dsdt_file()
1872 struct passthru_dev *ptdev = NULL; in passthru_write_dsdt() local
1881 ptdev = (struct passthru_dev *) dev->arg; in passthru_write_dsdt()
1904 else if (ptdev->need_dsdt) in passthru_write_dsdt()