Lines Matching refs:pci_seg
108 u16 pci_seg; member
148 u16 pci_seg; member
229 static void init_device_table_dma(struct amd_iommu_pci_seg *pci_seg);
289 iommu->index, iommu->pci_seg->id, in get_global_efr()
407 u32 dev_table_size = iommu->pci_seg->dev_table_size; in iommu_set_device_table()
606 static int __init find_last_devid_acpi(struct acpi_table_header *table, u16 pci_seg) in find_last_devid_acpi() argument
617 if (h->pci_seg == pci_seg && in find_last_devid_acpi()
643 static inline int __init alloc_dev_table(struct amd_iommu_pci_seg *pci_seg) in alloc_dev_table() argument
645 pci_seg->dev_table = iommu_alloc_pages_sz(GFP_KERNEL | GFP_DMA32, in alloc_dev_table()
646 pci_seg->dev_table_size); in alloc_dev_table()
647 if (!pci_seg->dev_table) in alloc_dev_table()
653 static inline void free_dev_table(struct amd_iommu_pci_seg *pci_seg) in free_dev_table() argument
656 memunmap((void *)pci_seg->dev_table); in free_dev_table()
658 iommu_free_pages(pci_seg->dev_table); in free_dev_table()
659 pci_seg->dev_table = NULL; in free_dev_table()
663 static inline int __init alloc_rlookup_table(struct amd_iommu_pci_seg *pci_seg) in alloc_rlookup_table() argument
665 pci_seg->rlookup_table = kvzalloc_objs(*pci_seg->rlookup_table, in alloc_rlookup_table()
666 pci_seg->last_bdf + 1); in alloc_rlookup_table()
667 if (pci_seg->rlookup_table == NULL) in alloc_rlookup_table()
673 static inline void free_rlookup_table(struct amd_iommu_pci_seg *pci_seg) in free_rlookup_table() argument
675 kvfree(pci_seg->rlookup_table); in free_rlookup_table()
676 pci_seg->rlookup_table = NULL; in free_rlookup_table()
679 static inline int __init alloc_irq_lookup_table(struct amd_iommu_pci_seg *pci_seg) in alloc_irq_lookup_table() argument
681 pci_seg->irq_lookup_table = kvzalloc_objs(*pci_seg->irq_lookup_table, in alloc_irq_lookup_table()
682 pci_seg->last_bdf + 1); in alloc_irq_lookup_table()
683 if (pci_seg->irq_lookup_table == NULL) in alloc_irq_lookup_table()
689 static inline void free_irq_lookup_table(struct amd_iommu_pci_seg *pci_seg) in free_irq_lookup_table() argument
691 kvfree(pci_seg->irq_lookup_table); in free_irq_lookup_table()
692 pci_seg->irq_lookup_table = NULL; in free_irq_lookup_table()
695 static int __init alloc_alias_table(struct amd_iommu_pci_seg *pci_seg) in alloc_alias_table() argument
699 pci_seg->alias_table = kvmalloc_objs(*pci_seg->alias_table, in alloc_alias_table()
700 pci_seg->last_bdf + 1); in alloc_alias_table()
701 if (!pci_seg->alias_table) in alloc_alias_table()
707 for (i = 0; i <= pci_seg->last_bdf; ++i) in alloc_alias_table()
708 pci_seg->alias_table[i] = i; in alloc_alias_table()
713 static void __init free_alias_table(struct amd_iommu_pci_seg *pci_seg) in free_alias_table() argument
715 kvfree(pci_seg->alias_table); in free_alias_table()
716 pci_seg->alias_table = NULL; in free_alias_table()
1158 struct amd_iommu_pci_seg *pci_seg = iommu->pci_seg; in __reuse_device_table() local
1172 if (old_devtb_size != pci_seg->dev_table_size) { in __reuse_device_table()
1193 pci_seg->old_dev_tbl_cpy = iommu_memremap(old_devtb_phys, pci_seg->dev_table_size); in __reuse_device_table()
1194 if (pci_seg->old_dev_tbl_cpy == NULL) { in __reuse_device_table()
1199 for (devid = 0; devid <= pci_seg->last_bdf; devid++) { in __reuse_device_table()
1200 old_dev_tbl_entry = &pci_seg->old_dev_tbl_cpy[devid]; in __reuse_device_table()
1221 struct amd_iommu_pci_seg *pci_seg; in reuse_device_table() local
1232 for_each_pci_segment(pci_seg) { in reuse_device_table()
1234 if (pci_seg->id != iommu->pci_seg->id) in reuse_device_table()
1297 if (search_ivhd_dte_flags(iommu->pci_seg->id, first, last)) in set_dev_entry_from_acpi_range()
1326 d->segid = iommu->pci_seg->id; in set_dev_entry_from_acpi_range()
1468 struct amd_iommu_pci_seg *pci_seg = iommu->pci_seg; in init_iommu_from_acpi() local
1500 seg_id = pci_seg->id; in init_iommu_from_acpi()
1506 set_dev_entry_from_acpi_range(iommu, 0, pci_seg->last_bdf, e->flags, 0); in init_iommu_from_acpi()
1547 pci_seg->alias_table[devid] = devid_to; in init_iommu_from_acpi()
1601 pci_seg->alias_table[dev_i] = devid_to; in init_iommu_from_acpi()
1724 struct amd_iommu_pci_seg *pci_seg; in alloc_pci_segment() local
1736 pci_seg = kzalloc_obj(struct amd_iommu_pci_seg); in alloc_pci_segment()
1737 if (pci_seg == NULL) in alloc_pci_segment()
1740 pci_seg->last_bdf = last_bdf; in alloc_pci_segment()
1742 pci_seg->dev_table_size = in alloc_pci_segment()
1746 pci_seg->id = id; in alloc_pci_segment()
1747 init_llist_head(&pci_seg->dev_data_list); in alloc_pci_segment()
1748 INIT_LIST_HEAD(&pci_seg->unity_map); in alloc_pci_segment()
1749 list_add_tail(&pci_seg->list, &amd_iommu_pci_seg_list); in alloc_pci_segment()
1751 if (alloc_dev_table(pci_seg)) in alloc_pci_segment()
1753 if (alloc_alias_table(pci_seg)) in alloc_pci_segment()
1755 if (alloc_rlookup_table(pci_seg)) in alloc_pci_segment()
1758 return pci_seg; in alloc_pci_segment()
1761 free_alias_table(pci_seg); in alloc_pci_segment()
1763 free_dev_table(pci_seg); in alloc_pci_segment()
1765 list_del(&pci_seg->list); in alloc_pci_segment()
1766 kfree(pci_seg); in alloc_pci_segment()
1773 struct amd_iommu_pci_seg *pci_seg; in get_pci_segment() local
1775 for_each_pci_segment(pci_seg) { in get_pci_segment()
1776 if (pci_seg->id == id) in get_pci_segment()
1777 return pci_seg; in get_pci_segment()
1785 struct amd_iommu_pci_seg *pci_seg, *next; in free_pci_segments() local
1787 for_each_pci_segment_safe(pci_seg, next) { in free_pci_segments()
1788 list_del(&pci_seg->list); in free_pci_segments()
1789 free_irq_lookup_table(pci_seg); in free_pci_segments()
1790 free_rlookup_table(pci_seg); in free_pci_segments()
1791 free_alias_table(pci_seg); in free_pci_segments()
1792 free_dev_table(pci_seg); in free_pci_segments()
1793 kfree(pci_seg); in free_pci_segments()
1892 struct amd_iommu_pci_seg *pci_seg; in init_iommu_one() local
1894 pci_seg = get_pci_segment(h->pci_seg, ivrs_base); in init_iommu_one()
1895 if (pci_seg == NULL) in init_iommu_one()
1897 iommu->pci_seg = pci_seg; in init_iommu_one()
1998 iommu->pci_seg->rlookup_table[iommu->devid] = NULL; in init_iommu_one_late()
2050 h->pci_seg, PCI_BUS_NUM(h->devid), in init_iommu_all()
2174 iommu->dev = pci_get_domain_bus_and_slot(iommu->pci_seg->id, in iommu_init_pci()
2225 pci_get_domain_bus_and_slot(iommu->pci_seg->id, in iommu_init_pci()
2323 struct amd_iommu_pci_seg *pci_seg; in amd_iommu_init_pci() local
2350 for_each_pci_segment(pci_seg) in amd_iommu_init_pci()
2351 init_device_table_dma(pci_seg); in amd_iommu_init_pci()
2635 struct amd_iommu_pci_seg *p, *pci_seg; in free_unity_maps() local
2637 for_each_pci_segment_safe(pci_seg, p) { in free_unity_maps()
2638 list_for_each_entry_safe(entry, next, &pci_seg->unity_map, list) { in free_unity_maps()
2650 struct amd_iommu_pci_seg *pci_seg; in init_unity_map_range() local
2653 pci_seg = get_pci_segment(m->pci_seg, ivrs_base); in init_unity_map_range()
2654 if (pci_seg == NULL) in init_unity_map_range()
2672 e->devid_end = pci_seg->last_bdf; in init_unity_map_range()
2696 " flags: %x\n", s, m->pci_seg, in init_unity_map_range()
2698 PCI_FUNC(e->devid_start), m->pci_seg, in init_unity_map_range()
2703 list_add_tail(&e->list, &pci_seg->unity_map); in init_unity_map_range()
2731 static void init_device_table_dma(struct amd_iommu_pci_seg *pci_seg) in init_device_table_dma() argument
2734 struct dev_table_entry *dev_table = pci_seg->dev_table; in init_device_table_dma()
2739 for (devid = 0; devid <= pci_seg->last_bdf; ++devid) { in init_device_table_dma()
2746 static void __init uninit_device_table_dma(struct amd_iommu_pci_seg *pci_seg) in uninit_device_table_dma() argument
2749 struct dev_table_entry *dev_table = pci_seg->dev_table; in uninit_device_table_dma()
2754 for (devid = 0; devid <= pci_seg->last_bdf; ++devid) { in uninit_device_table_dma()
2762 struct amd_iommu_pci_seg *pci_seg; in init_device_table() local
2768 for_each_pci_segment(pci_seg) { in init_device_table()
2769 for (devid = 0; devid <= pci_seg->last_bdf; ++devid) in init_device_table()
2770 set_dte_bit(&pci_seg->dev_table[devid], DEV_ENTRY_IRQ_TBL_EN); in init_device_table()
2929 struct amd_iommu_pci_seg *pci_seg; in early_enable_iommus() local
2947 for_each_pci_segment(pci_seg) { in early_enable_iommus()
2948 if (pci_seg->old_dev_tbl_cpy != NULL) { in early_enable_iommus()
2949 memunmap((void *)pci_seg->old_dev_tbl_cpy); in early_enable_iommus()
2950 pci_seg->old_dev_tbl_cpy = NULL; in early_enable_iommus()
2961 for_each_pci_segment(pci_seg) { in early_enable_iommus()
2962 iommu_free_pages(pci_seg->dev_table); in early_enable_iommus()
2963 pci_seg->dev_table = pci_seg->old_dev_tbl_cpy; in early_enable_iommus()
3290 struct amd_iommu_pci_seg *pci_seg; in early_amd_iommu_init() local
3292 for_each_pci_segment(pci_seg) { in early_amd_iommu_init()
3293 if (alloc_irq_lookup_table(pci_seg)) in early_amd_iommu_init()
3522 struct amd_iommu_pci_seg *pci_seg; in state_next() local
3524 for_each_pci_segment(pci_seg) in state_next()
3525 uninit_device_table_dma(pci_seg); in state_next()