Lines Matching +full:iommu +full:- +full:map
1 // SPDX-License-Identifier: GPL-2.0-only
15 #include <linux/iommu.h>
21 #include <linux/dma-map-ops.h>
44 * iort_set_fwnode() - Create iort_fwnode and use it to register
45 * iommu data in the iort_fwnode_list
47 * @iort_node: IORT table node associated with the IOMMU
61 return -ENOMEM; in iort_set_fwnode()
63 INIT_LIST_HEAD(&np->list); in iort_set_fwnode()
64 np->iort_node = iort_node; in iort_set_fwnode()
65 np->fwnode = fwnode; in iort_set_fwnode()
68 list_add_tail(&np->list, &iort_fwnode_list); in iort_set_fwnode()
75 * iort_get_fwnode() - Retrieve fwnode associated with an IORT node
77 * @node: IORT table node to be looked-up
89 if (curr->iort_node == node) { in iort_get_fwnode()
90 fwnode = curr->fwnode; in iort_get_fwnode()
100 * iort_delete_fwnode() - Delete fwnode associated with an IORT node
110 if (curr->iort_node == node) { in iort_delete_fwnode()
111 list_del(&curr->list); in iort_delete_fwnode()
120 * iort_get_iort_node() - Retrieve iort_node associated with an fwnode
122 * @fwnode: fwnode associated with device to be looked-up
134 if (curr->fwnode == fwnode) { in iort_get_iort_node()
135 iort_node = curr->iort_node; in iort_get_iort_node()
154 * iort_register_domain_token() - register domain token along with related
160 * Returns: 0 on success, -ENOMEM if no memory when allocating list element
169 return -ENOMEM; in iort_register_domain_token()
171 its_msi_chip->fw_node = fw_node; in iort_register_domain_token()
172 its_msi_chip->translation_id = trans_id; in iort_register_domain_token()
173 its_msi_chip->base_addr = base; in iort_register_domain_token()
176 list_add(&its_msi_chip->list, &iort_msi_chip_list); in iort_register_domain_token()
183 * iort_deregister_domain_token() - Deregister domain token based on ITS ID
194 if (its_msi_chip->translation_id == trans_id) { in iort_deregister_domain_token()
195 list_del(&its_msi_chip->list); in iort_deregister_domain_token()
204 * iort_find_domain_token() - Find domain token based on given ITS ID
216 if (its_msi_chip->translation_id == trans_id) { in iort_find_domain_token()
217 fw_node = its_msi_chip->fw_node; in iort_find_domain_token()
240 iort->node_offset); in iort_scan_node()
242 iort_table->length); in iort_scan_node()
244 for (i = 0; i < iort->node_count; i++) { in iort_scan_node()
249 if (iort_node->type == type && in iort_scan_node()
254 iort_node->length); in iort_scan_node()
266 if (node->type == ACPI_IORT_NODE_NAMED_COMPONENT) { in iort_match_node_callback()
284 nc_dev = nc_dev->parent; in iort_match_node_callback()
290 status = acpi_get_name(adev->handle, ACPI_FULL_PATHNAME, &buf); in iort_match_node_callback()
296 ncomp = (struct acpi_iort_named_component *)node->node_data; in iort_match_node_callback()
297 status = !strcmp(ncomp->device_name, buf.pointer) ? in iort_match_node_callback()
300 } else if (node->type == ACPI_IORT_NODE_PCI_ROOT_COMPLEX) { in iort_match_node_callback()
305 pci_rc = (struct acpi_iort_root_complex *)node->node_data; in iort_match_node_callback()
308 * It is assumed that PCI segment numbers maps one-to-one in iort_match_node_callback()
312 status = pci_rc->pci_segment_number == pci_domain_nr(bus) ? in iort_match_node_callback()
319 static int iort_id_map(struct acpi_iort_id_mapping *map, u8 type, u32 rid_in, in iort_id_map() argument
323 if (map->flags & ACPI_IORT_ID_SINGLE_MAPPING) { in iort_id_map()
326 *rid_out = map->output_base; in iort_id_map()
330 pr_warn(FW_BUG "[map %p] SINGLE MAPPING flag not allowed for node type %d, skipping ID map\n", in iort_id_map()
331 map, type); in iort_id_map()
332 return -ENXIO; in iort_id_map()
335 if (rid_in < map->input_base || in iort_id_map()
336 (rid_in > map->input_base + map->id_count)) in iort_id_map()
337 return -ENXIO; in iort_id_map()
343 * region, we assume the prior match was due to the off-by-1 in iort_id_map()
348 pr_err(FW_BUG "[map %p] conflicting mapping for input ID 0x%x\n", in iort_id_map()
349 map, rid_in); in iort_id_map()
350 if (rid_in != map->input_base) in iort_id_map()
351 return -ENXIO; in iort_id_map()
356 *rid_out = map->output_base + (rid_in - map->input_base); in iort_id_map()
364 if (map->id_count > 0 && rid_in == map->input_base + map->id_count) in iort_id_map()
365 return -EAGAIN; in iort_id_map()
373 struct acpi_iort_id_mapping *map; in iort_node_get_id() local
375 if (!node->mapping_offset || !node->mapping_count || in iort_node_get_id()
376 index >= node->mapping_count) in iort_node_get_id()
379 map = ACPI_ADD_PTR(struct acpi_iort_id_mapping, node, in iort_node_get_id()
380 node->mapping_offset + index * sizeof(*map)); in iort_node_get_id()
383 if (!map->output_reference) { in iort_node_get_id()
384 pr_err(FW_BUG "[node %p type %d] ID map has NULL parent reference\n", in iort_node_get_id()
385 node, node->type); in iort_node_get_id()
390 map->output_reference); in iort_node_get_id()
392 if (map->flags & ACPI_IORT_ID_SINGLE_MAPPING) { in iort_node_get_id()
393 if (node->type == ACPI_IORT_NODE_NAMED_COMPONENT || in iort_node_get_id()
394 node->type == ACPI_IORT_NODE_PCI_ROOT_COMPLEX || in iort_node_get_id()
395 node->type == ACPI_IORT_NODE_SMMU_V3 || in iort_node_get_id()
396 node->type == ACPI_IORT_NODE_PMCG) { in iort_node_get_id()
397 *id_out = map->output_base; in iort_node_get_id()
410 switch (node->type) { in iort_get_id_mapping_index()
416 if (node->revision < 1) in iort_get_id_mapping_index()
417 return -EINVAL; in iort_get_id_mapping_index()
419 smmu = (struct acpi_iort_smmu_v3 *)node->node_data; in iort_get_id_mapping_index()
424 if (smmu->event_gsiv && smmu->pri_gsiv && smmu->gerr_gsiv in iort_get_id_mapping_index()
425 && smmu->sync_gsiv) in iort_get_id_mapping_index()
426 return -EINVAL; in iort_get_id_mapping_index()
428 if (smmu->id_mapping_index >= node->mapping_count) { in iort_get_id_mapping_index()
430 node, node->type); in iort_get_id_mapping_index()
431 return -EINVAL; in iort_get_id_mapping_index()
434 return smmu->id_mapping_index; in iort_get_id_mapping_index()
436 pmcg = (struct acpi_iort_pmcg *)node->node_data; in iort_get_id_mapping_index()
437 if (pmcg->overflow_gsiv || node->mapping_count == 0) in iort_get_id_mapping_index()
438 return -EINVAL; in iort_get_id_mapping_index()
442 return -EINVAL; in iort_get_id_mapping_index()
454 struct acpi_iort_id_mapping *map; in iort_node_map_id() local
458 if (IORT_TYPE_MASK(node->type) & type_mask) { in iort_node_map_id()
464 if (!node->mapping_offset || !node->mapping_count) in iort_node_map_id()
467 map = ACPI_ADD_PTR(struct acpi_iort_id_mapping, node, in iort_node_map_id()
468 node->mapping_offset); in iort_node_map_id()
471 if (!map->output_reference) { in iort_node_map_id()
472 pr_err(FW_BUG "[node %p type %d] ID map has NULL parent reference\n", in iort_node_map_id()
473 node, node->type); in iort_node_map_id()
479 * associated ID map to prevent erroneous multi-stage in iort_node_map_id()
485 for (i = 0; i < node->mapping_count; i++, map++) { in iort_node_map_id()
490 rc = iort_id_map(map, node->type, map_id, &id, out_ref); in iort_node_map_id()
493 if (rc == -EAGAIN) in iort_node_map_id()
494 out_ref = map->output_reference; in iort_node_map_id()
497 if (i == node->mapping_count && !out_ref) in iort_node_map_id()
501 rc ? out_ref : map->output_reference); in iort_node_map_id()
505 /* Map input ID to output ID unchanged on mapping failure */ in iort_node_map_id()
525 * optional step 2: map the initial dev id if its parent is not in iort_node_map_platform_id()
526 * the target type we want, map it again for the use cases such in iort_node_map_platform_id()
527 * as NC (named component) -> SMMU -> ITS. If the type is matched, in iort_node_map_platform_id()
530 if (!(IORT_TYPE_MASK(parent->type) & type_mask)) in iort_node_map_platform_id()
551 node = iort_get_iort_node(dev->fwnode); in iort_find_dev_node()
562 pbus = to_pci_dev(dev)->bus; in iort_find_dev_node()
565 iort_match_node_callback, &pbus->dev); in iort_find_dev_node()
569 * iort_msi_map_id() - Map a MSI input ID for a device
589 * iort_pmsi_get_dev_id() - Get the device id for a device
593 * Returns: 0 for successful find a dev id, -ENODEV on error
602 return -ENODEV; in iort_pmsi_get_dev_id()
610 for (i = 0; i < node->mapping_count; i++) { in iort_pmsi_get_dev_id()
617 return -ENODEV; in iort_pmsi_get_dev_id()
623 int ret = -ENODEV; in iort_find_its_base()
627 if (its_msi_chip->translation_id == its_id) { in iort_find_its_base()
628 *base = its_msi_chip->base_addr; in iort_find_its_base()
639 * iort_dev_find_its_id() - Find the ITS identifier for a device
655 return -ENXIO; in iort_dev_find_its_id()
659 return -ENXIO; in iort_dev_find_its_id()
662 its = (struct acpi_iort_its_group *)node->node_data; in iort_dev_find_its_id()
663 if (idx >= its->its_count) { in iort_dev_find_its_id()
665 idx, its->its_count); in iort_dev_find_its_id()
666 return -ENXIO; in iort_dev_find_its_id()
669 *its_id = its->identifiers[idx]; in iort_dev_find_its_id()
674 * iort_get_device_domain() - Find MSI domain related to a device
702 struct acpi_iort_id_mapping *map; in iort_set_device_domain() local
711 map = ACPI_ADD_PTR(struct acpi_iort_id_mapping, node, in iort_set_device_domain()
712 node->mapping_offset + index * sizeof(*map)); in iort_set_device_domain()
715 if (!map->output_reference || in iort_set_device_domain()
716 !(map->flags & ACPI_IORT_ID_SINGLE_MAPPING)) { in iort_set_device_domain()
718 node, node->type); in iort_set_device_domain()
723 map->output_reference); in iort_set_device_domain()
725 if (!msi_parent || msi_parent->type != ACPI_IORT_NODE_ITS_GROUP) in iort_set_device_domain()
729 its = (struct acpi_iort_its_group *)msi_parent->node_data; in iort_set_device_domain()
731 iort_fwnode = iort_find_domain_token(its->identifiers[0]); in iort_set_device_domain()
741 * iort_get_platform_device_domain() - Find MSI domain related to a
761 for (i = 0; i < node->mapping_count; i++) { in iort_get_platform_device_domain()
772 its = (struct acpi_iort_its_group *)msi_parent->node_data; in iort_get_platform_device_domain()
774 iort_fwnode = iort_find_domain_token(its->identifiers[0]); in iort_get_platform_device_domain()
797 kfree(rmr_data->sids); in iort_rmr_free()
809 u64 addr = rmr_desc->base_address, size = rmr_desc->length; in iort_rmr_alloc()
821 rmr_data->sids = sids_copy; in iort_rmr_alloc()
822 rmr_data->num_sids = num_sids; in iort_rmr_alloc()
827 size = PAGE_ALIGN(size + offset_in_page(rmr_desc->base_address)); in iort_rmr_alloc()
829 …pr_err(FW_BUG "RMR descriptor[0x%llx - 0x%llx] not aligned to 64K, continue with [0x%llx - 0x%llx]… in iort_rmr_alloc()
830 rmr_desc->base_address, in iort_rmr_alloc()
831 rmr_desc->base_address + rmr_desc->length - 1, in iort_rmr_alloc()
832 addr, addr + size - 1); in iort_rmr_alloc()
835 region = &rmr_data->rr; in iort_rmr_alloc()
836 INIT_LIST_HEAD(®ion->list); in iort_rmr_alloc()
837 region->start = addr; in iort_rmr_alloc()
838 region->length = size; in iort_rmr_alloc()
839 region->prot = prot; in iort_rmr_alloc()
840 region->type = type; in iort_rmr_alloc()
841 region->free = iort_rmr_free; in iort_rmr_alloc()
860 end = start + length - 1; in iort_rmr_desc_check_overlap()
865 u64 e_end = e_start + desc[j].length - 1; in iort_rmr_desc_check_overlap()
868 pr_err(FW_BUG "RMR descriptor[0x%llx - 0x%llx] overlaps, continue anyway\n", in iort_rmr_desc_check_overlap()
883 struct acpi_iort_rmr *rmr = (struct acpi_iort_rmr *)node->node_data; in iort_get_rmrs()
888 rmr->rmr_offset); in iort_get_rmrs()
890 iort_rmr_desc_check_overlap(rmr_desc, rmr->rmr_count); in iort_get_rmrs()
892 for (i = 0; i < rmr->rmr_count; i++, rmr_desc++) { in iort_get_rmrs()
897 if (rmr->flags & ACPI_IORT_RMR_REMAP_PERMITTED) in iort_get_rmrs()
902 if (rmr->flags & ACPI_IORT_RMR_ACCESS_PRIVILEGE) in iort_get_rmrs()
905 /* Attributes 0x00 - 0x03 represents device memory */ in iort_get_rmrs()
906 if (ACPI_IORT_RMR_ACCESS_ATTRIBUTES(rmr->flags) <= in iort_get_rmrs()
909 else if (ACPI_IORT_RMR_ACCESS_ATTRIBUTES(rmr->flags) == in iort_get_rmrs()
918 list_add_tail(&rmr_data->rr.list, head); in iort_get_rmrs()
953 struct pci_host_bridge *host = pci_find_host_bridge(pdev->bus); in iort_rmr_has_dev()
955 if (!host->preserve_config) in iort_rmr_has_dev()
959 for (i = 0; i < fwspec->num_ids; i++) { in iort_rmr_has_dev()
960 if (fwspec->ids[i] >= id_start && in iort_rmr_has_dev()
961 fwspec->ids[i] <= id_start + id_count) in iort_rmr_has_dev()
969 struct acpi_iort_node *iommu, in iort_node_get_rmr_info() argument
974 struct acpi_iort_id_mapping *map; in iort_node_get_rmr_info() local
979 if (!node->mapping_offset || !node->mapping_count) { in iort_node_get_rmr_info()
985 rmr = (struct acpi_iort_rmr *)node->node_data; in iort_node_get_rmr_info()
986 if (!rmr->rmr_offset || !rmr->rmr_count) in iort_node_get_rmr_info()
989 map = ACPI_ADD_PTR(struct acpi_iort_id_mapping, node, in iort_node_get_rmr_info()
990 node->mapping_offset); in iort_node_get_rmr_info()
998 for (i = 0; i < node->mapping_count; i++, map++) { in iort_node_get_rmr_info()
1001 if (!map->id_count) in iort_node_get_rmr_info()
1005 map->output_reference); in iort_node_get_rmr_info()
1006 if (parent != iommu) in iort_node_get_rmr_info()
1010 if (dev && !iort_rmr_has_dev(dev, map->output_base, in iort_node_get_rmr_info()
1011 map->id_count)) in iort_node_get_rmr_info()
1015 sids = iort_rmr_alloc_sids(sids, num_sids, map->output_base, in iort_node_get_rmr_info()
1016 map->id_count + 1); in iort_node_get_rmr_info()
1020 num_sids += map->id_count + 1; in iort_node_get_rmr_info()
1030 static void iort_find_rmrs(struct acpi_iort_node *iommu, struct device *dev, in iort_find_rmrs() argument
1038 if (iort_table->revision < 5) in iort_find_rmrs()
1044 iort->node_offset); in iort_find_rmrs()
1046 iort_table->length); in iort_find_rmrs()
1048 for (i = 0; i < iort->node_count; i++) { in iort_find_rmrs()
1053 if (iort_node->type == ACPI_IORT_NODE_RMR) in iort_find_rmrs()
1054 iort_node_get_rmr_info(iort_node, iommu, dev, head); in iort_find_rmrs()
1057 iort_node->length); in iort_find_rmrs()
1062 * Populate the RMR list associated with a given IOMMU and dev(if provided).
1064 * given IOMMU.
1070 struct acpi_iort_node *iommu; in iort_iommu_rmr_get_resv_regions() local
1072 iommu = iort_get_iort_node(iommu_fwnode); in iort_iommu_rmr_get_resv_regions()
1073 if (!iommu) in iort_iommu_rmr_get_resv_regions()
1076 iort_find_rmrs(iommu, dev, head); in iort_iommu_rmr_get_resv_regions()
1081 struct acpi_iort_node *iommu; in iort_get_msi_resv_iommu() local
1084 iommu = iort_get_iort_node(fwspec->iommu_fwnode); in iort_get_msi_resv_iommu()
1086 if (iommu && (iommu->type == ACPI_IORT_NODE_SMMU_V3)) { in iort_get_msi_resv_iommu()
1089 smmu = (struct acpi_iort_smmu_v3 *)iommu->node_data; in iort_get_msi_resv_iommu()
1090 if (smmu->model == ACPI_IORT_SMMU_V3_HISILICON_HI161X) in iort_get_msi_resv_iommu()
1091 return iommu; in iort_get_msi_resv_iommu()
1117 * ITS group; if a PCI or named component can map its IDs to in iort_iommu_msi_get_resv_regions()
1120 * a given PCI or named component may map IDs to. in iort_iommu_msi_get_resv_regions()
1123 for (i = 0; i < fwspec->num_ids; i++) { in iort_iommu_msi_get_resv_regions()
1125 fwspec->ids[i], in iort_iommu_msi_get_resv_regions()
1135 its = (struct acpi_iort_its_group *)its_node->node_data; in iort_iommu_msi_get_resv_regions()
1137 for (i = 0; i < its->its_count; i++) { in iort_iommu_msi_get_resv_regions()
1140 if (!iort_find_its_base(its->identifiers[i], &base)) { in iort_iommu_msi_get_resv_regions()
1148 list_add_tail(®ion->list, head); in iort_iommu_msi_get_resv_regions()
1154 * iort_iommu_get_resv_regions - Generic helper to retrieve reserved regions.
1163 iort_iommu_rmr_get_resv_regions(fwspec->iommu_fwnode, dev, head); in iort_iommu_get_resv_regions()
1167 * iort_get_rmr_sids - Retrieve IORT RMR node reserved regions with
1169 * @iommu_fwnode: fwnode associated with IOMMU
1180 * iort_put_rmr_sids - Free memory allocated for RMR reserved regions.
1181 * @iommu_fwnode: fwnode associated with IOMMU
1190 entry->free(NULL, entry); in iort_put_rmr_sids()
1211 pci_rc = (struct acpi_iort_root_complex *)node->node_data; in iort_pci_rc_supports_ats()
1212 return pci_rc->ats_attribute & ACPI_IORT_ATS_SUPPORTED; in iort_pci_rc_supports_ats()
1222 return -ENODEV; in iort_iommu_xlate()
1226 return -ENODEV; in iort_iommu_xlate()
1229 * If the ops look-up fails, this means that either in iort_iommu_xlate()
1232 * Depending on whether the SMMU drivers are built-in in iort_iommu_xlate()
1233 * in the kernel or not, defer the IOMMU configuration in iort_iommu_xlate()
1238 return iort_iommu_driver_enabled(node->type) ? in iort_iommu_xlate()
1239 -EPROBE_DEFER : -ENODEV; in iort_iommu_xlate()
1255 parent = iort_node_map_id(info->node, alias, &streamid, in iort_pci_iommu_init()
1257 return iort_iommu_xlate(info->dev, parent, streamid); in iort_pci_iommu_init()
1266 nc = (struct acpi_iort_named_component *)node->node_data; in iort_named_component_init()
1267 props[0] = PROPERTY_ENTRY_U32("pasid-num-bits", in iort_named_component_init()
1269 nc->node_flags)); in iort_named_component_init()
1270 if (nc->node_flags & ACPI_IORT_NC_STALL_SUPPORTED) in iort_named_component_init()
1271 props[1] = PROPERTY_ENTRY_BOOL("dma-can-stall"); in iort_named_component_init()
1280 int err = -ENODEV, i = 0; in iort_nc_iommu_map()
1307 return -ENODEV; in iort_nc_iommu_map_id()
1312 * iort_iommu_configure_id - Set-up IOMMU configuration for a device.
1322 int err = -ENODEV; in iort_iommu_configure_id()
1326 struct pci_bus *bus = to_pci_dev(dev)->bus; in iort_iommu_configure_id()
1330 iort_match_node_callback, &bus->dev); in iort_iommu_configure_id()
1332 return -ENODEV; in iort_iommu_configure_id()
1340 fwspec->flags |= IOMMU_FWSPEC_PCI_RC_ATS; in iort_iommu_configure_id()
1345 return -ENODEV; in iort_iommu_configure_id()
1361 { return -ENODEV; } in iort_iommu_configure_id()
1372 return -ENODEV; in nc_dma_get_range()
1374 ncomp = (struct acpi_iort_named_component *)node->node_data; in nc_dma_get_range()
1376 if (!ncomp->memory_address_limit) { in nc_dma_get_range()
1378 return -EINVAL; in nc_dma_get_range()
1381 *size = ncomp->memory_address_limit >= 64 ? U64_MAX : in nc_dma_get_range()
1382 1ULL<<ncomp->memory_address_limit; in nc_dma_get_range()
1391 struct pci_bus *pbus = to_pci_dev(dev)->bus; in rc_dma_get_range()
1394 iort_match_node_callback, &pbus->dev); in rc_dma_get_range()
1395 if (!node || node->revision < 1) in rc_dma_get_range()
1396 return -ENODEV; in rc_dma_get_range()
1398 rc = (struct acpi_iort_root_complex *)node->node_data; in rc_dma_get_range()
1400 if (!rc->memory_address_limit) { in rc_dma_get_range()
1402 return -EINVAL; in rc_dma_get_range()
1405 *size = rc->memory_address_limit >= 64 ? U64_MAX : in rc_dma_get_range()
1406 1ULL<<rc->memory_address_limit; in rc_dma_get_range()
1412 * iort_dma_get_ranges() - Look up DMA addressing limit for the device
1439 res->start = irq; in acpi_iort_register_irq()
1440 res->end = irq; in acpi_iort_register_irq()
1441 res->flags = IORESOURCE_IRQ; in acpi_iort_register_irq()
1442 res->name = name; in acpi_iort_register_irq()
1452 smmu = (struct acpi_iort_smmu_v3 *)node->node_data; in arm_smmu_v3_count_resources()
1454 if (smmu->event_gsiv) in arm_smmu_v3_count_resources()
1457 if (smmu->pri_gsiv) in arm_smmu_v3_count_resources()
1460 if (smmu->gerr_gsiv) in arm_smmu_v3_count_resources()
1463 if (smmu->sync_gsiv) in arm_smmu_v3_count_resources()
1475 if (smmu->model != ACPI_IORT_SMMU_V3_CAVIUM_CN99XX) in arm_smmu_v3_is_combined_irq()
1482 return smmu->event_gsiv == smmu->pri_gsiv && in arm_smmu_v3_is_combined_irq()
1483 smmu->event_gsiv == smmu->gerr_gsiv && in arm_smmu_v3_is_combined_irq()
1484 smmu->event_gsiv == smmu->sync_gsiv; in arm_smmu_v3_is_combined_irq()
1493 if (smmu->model == ACPI_IORT_SMMU_V3_CAVIUM_CN99XX) in arm_smmu_v3_resource_size()
1506 smmu = (struct acpi_iort_smmu_v3 *)node->node_data; in arm_smmu_v3_init_resources()
1508 res[num_res].start = smmu->base_address; in arm_smmu_v3_init_resources()
1509 res[num_res].end = smmu->base_address + in arm_smmu_v3_init_resources()
1510 arm_smmu_v3_resource_size(smmu) - 1; in arm_smmu_v3_init_resources()
1515 if (smmu->event_gsiv) in arm_smmu_v3_init_resources()
1516 acpi_iort_register_irq(smmu->event_gsiv, "combined", in arm_smmu_v3_init_resources()
1521 if (smmu->event_gsiv) in arm_smmu_v3_init_resources()
1522 acpi_iort_register_irq(smmu->event_gsiv, "eventq", in arm_smmu_v3_init_resources()
1526 if (smmu->pri_gsiv) in arm_smmu_v3_init_resources()
1527 acpi_iort_register_irq(smmu->pri_gsiv, "priq", in arm_smmu_v3_init_resources()
1531 if (smmu->gerr_gsiv) in arm_smmu_v3_init_resources()
1532 acpi_iort_register_irq(smmu->gerr_gsiv, "gerror", in arm_smmu_v3_init_resources()
1536 if (smmu->sync_gsiv) in arm_smmu_v3_init_resources()
1537 acpi_iort_register_irq(smmu->sync_gsiv, "cmdq-sync", in arm_smmu_v3_init_resources()
1550 smmu = (struct acpi_iort_smmu_v3 *)node->node_data; in arm_smmu_v3_dma_configure()
1552 attr = (smmu->flags & ACPI_IORT_SMMU_V3_COHACC_OVERRIDE) ? in arm_smmu_v3_dma_configure()
1555 /* We expect the dma masks to be equivalent for all SMMUv3 set-ups */ in arm_smmu_v3_dma_configure()
1556 dev->dma_mask = &dev->coherent_dma_mask; in arm_smmu_v3_dma_configure()
1571 smmu = (struct acpi_iort_smmu_v3 *)node->node_data; in arm_smmu_v3_set_proximity()
1572 if (smmu->flags & ACPI_IORT_SMMU_V3_PXM_VALID) { in arm_smmu_v3_set_proximity()
1573 int dev_node = pxm_to_node(smmu->pxm); in arm_smmu_v3_set_proximity()
1576 return -EINVAL; in arm_smmu_v3_set_proximity()
1579 pr_info("SMMU-v3[%llx] Mapped to Proximity domain %d\n", in arm_smmu_v3_set_proximity()
1580 smmu->base_address, in arm_smmu_v3_set_proximity()
1581 smmu->pxm); in arm_smmu_v3_set_proximity()
1594 smmu = (struct acpi_iort_smmu *)node->node_data; in arm_smmu_count_resources()
1604 return smmu->context_interrupt_count + 2; in arm_smmu_count_resources()
1615 smmu = (struct acpi_iort_smmu *)node->node_data; in arm_smmu_init_resources()
1617 res[num_res].start = smmu->base_address; in arm_smmu_init_resources()
1618 res[num_res].end = smmu->base_address + smmu->span - 1; in arm_smmu_init_resources()
1622 glb_irq = ACPI_ADD_PTR(u64, node, smmu->global_interrupt_offset); in arm_smmu_init_resources()
1627 acpi_iort_register_irq(hw_irq, "arm-smmu-global", trigger, in arm_smmu_init_resources()
1631 ctx_irq = ACPI_ADD_PTR(u64, node, smmu->context_interrupt_offset); in arm_smmu_init_resources()
1632 for (i = 0; i < smmu->context_interrupt_count; i++) { in arm_smmu_init_resources()
1636 acpi_iort_register_irq(hw_irq, "arm-smmu-context", trigger, in arm_smmu_init_resources()
1648 smmu = (struct acpi_iort_smmu *)node->node_data; in arm_smmu_dma_configure()
1650 attr = (smmu->flags & ACPI_IORT_SMMU_COHERENT_WALK) ? in arm_smmu_dma_configure()
1653 /* We expect the dma masks to be equivalent for SMMU set-ups */ in arm_smmu_dma_configure()
1654 dev->dma_mask = &dev->coherent_dma_mask; in arm_smmu_dma_configure()
1665 pmcg = (struct acpi_iort_pmcg *)node->node_data; in arm_smmu_v3_pmcg_count_resources()
1671 return pmcg->overflow_gsiv ? 3 : 2; in arm_smmu_v3_pmcg_count_resources()
1680 pmcg = (struct acpi_iort_pmcg *)node->node_data; in arm_smmu_v3_pmcg_init_resources()
1682 res[0].start = pmcg->page0_base_address; in arm_smmu_v3_pmcg_init_resources()
1683 res[0].end = pmcg->page0_base_address + SZ_4K - 1; in arm_smmu_v3_pmcg_init_resources()
1691 if (node->revision > 0) { in arm_smmu_v3_pmcg_init_resources()
1692 res[1].start = pmcg->page1_base_address; in arm_smmu_v3_pmcg_init_resources()
1693 res[1].end = pmcg->page1_base_address + SZ_4K - 1; in arm_smmu_v3_pmcg_init_resources()
1697 if (pmcg->overflow_gsiv) in arm_smmu_v3_pmcg_init_resources()
1698 acpi_iort_register_irq(pmcg->overflow_gsiv, "overflow", in arm_smmu_v3_pmcg_init_resources()
1737 .name = "arm-smmu-v3",
1745 .name = "arm-smmu",
1752 .name = "arm-smmu-v3-pmcg",
1761 switch (node->type) { in iort_get_dev_cfg()
1774 * iort_add_platform_device() - Allocate a platform device for IORT node
1788 pdev = platform_device_alloc(ops->name, PLATFORM_DEVID_AUTO); in iort_add_platform_device()
1790 return -ENOMEM; in iort_add_platform_device()
1792 if (ops->dev_set_proximity) { in iort_add_platform_device()
1793 ret = ops->dev_set_proximity(&pdev->dev, node); in iort_add_platform_device()
1798 count = ops->dev_count_resources(node); in iort_add_platform_device()
1802 ret = -ENOMEM; in iort_add_platform_device()
1806 ops->dev_init_resources(r, node); in iort_add_platform_device()
1824 if (ops->dev_add_platdata) in iort_add_platform_device()
1825 ret = ops->dev_add_platdata(pdev); in iort_add_platform_device()
1835 ret = -ENODEV; in iort_add_platform_device()
1839 pdev->dev.fwnode = fwnode; in iort_add_platform_device()
1841 if (ops->dev_dma_configure) in iort_add_platform_device()
1842 ops->dev_dma_configure(&pdev->dev, node); in iort_add_platform_device()
1844 iort_set_device_domain(&pdev->dev, node); in iort_add_platform_device()
1853 arch_teardown_dma_ops(&pdev->dev); in iort_add_platform_device()
1868 if (iort_node->type == ACPI_IORT_NODE_PCI_ROOT_COMPLEX) { in iort_enable_acs()
1870 struct acpi_iort_id_mapping *map; in iort_enable_acs() local
1873 map = ACPI_ADD_PTR(struct acpi_iort_id_mapping, iort_node, in iort_enable_acs()
1874 iort_node->mapping_offset); in iort_enable_acs()
1876 for (i = 0; i < iort_node->mapping_count; i++, map++) { in iort_enable_acs()
1877 if (!map->output_reference) in iort_enable_acs()
1881 iort_table, map->output_reference); in iort_enable_acs()
1883 * If we detect a RC->SMMU mapping, make sure in iort_enable_acs()
1886 if ((parent->type == ACPI_IORT_NODE_SMMU) || in iort_enable_acs()
1887 (parent->type == ACPI_IORT_NODE_SMMU_V3)) { in iort_enable_acs()
1915 iort->node_offset); in iort_init_platform_devices()
1917 iort_table->length); in iort_init_platform_devices()
1919 for (i = 0; i < iort->node_count; i++) { in iort_init_platform_devices()
1944 iort_node->length); in iort_init_platform_devices()
1991 node = ACPI_ADD_PTR(struct acpi_iort_node, iort, iort->node_offset); in acpi_iort_dma_get_max_cpu_address()
1992 end = ACPI_ADD_PTR(struct acpi_iort_node, iort, iort->header.length); in acpi_iort_dma_get_max_cpu_address()
1994 for (i = 0; i < iort->node_count; i++) { in acpi_iort_dma_get_max_cpu_address()
1998 switch (node->type) { in acpi_iort_dma_get_max_cpu_address()
2004 ncomp = (struct acpi_iort_named_component *)node->node_data; in acpi_iort_dma_get_max_cpu_address()
2005 local_limit = DMA_BIT_MASK(ncomp->memory_address_limit); in acpi_iort_dma_get_max_cpu_address()
2010 if (node->revision < 1) in acpi_iort_dma_get_max_cpu_address()
2013 rc = (struct acpi_iort_root_complex *)node->node_data; in acpi_iort_dma_get_max_cpu_address()
2014 local_limit = DMA_BIT_MASK(rc->memory_address_limit); in acpi_iort_dma_get_max_cpu_address()
2018 node = ACPI_ADD_PTR(struct acpi_iort_node, node, node->length); in acpi_iort_dma_get_max_cpu_address()
2020 acpi_put_table(&iort->header); in acpi_iort_dma_get_max_cpu_address()