Lines Matching full:smem

16 #include <linux/soc/qcom/smem.h>
38 * (@smem_ptable), that is found 4kB from the end of the main smem region. The
55 * region with partition type (SMEM_GLOBAL_HOST) and the max smem item count is
65 * The version member of the smem header contains an array of versions for the
104 * struct smem_global_entry - entry to reference smem items on the heap
120 * struct smem_header - header found in beginning of primary smem region
123 * @initialized: boolean to indicate that smem is initialized
124 * @free_offset: index of the first unallocated byte in smem
200 * struct smem_partition - describes smem partition
218 * @item: identifying number of the smem item
235 * struct smem_info - smem region info located after the table of contents
237 * @size: size of the smem region
238 * @base_addr: base address of the smem region
253 * struct smem_region - representation of a chunk of memory used for smem
265 * struct qcom_smem - device data for the smem device
356 /* Pointer to the one and only smem handle */
363 * qcom_smem_is_available() - Check if SMEM is available
365 * Return: true if SMEM is available, false otherwise.
373 static int qcom_smem_alloc_private(struct qcom_smem *smem, in qcom_smem_alloc_private() argument
409 dev_err(smem->dev, "Out of memory\n"); in qcom_smem_alloc_private()
429 dev_err(smem->dev, "Found invalid canary in hosts %hu:%hu partition\n", in qcom_smem_alloc_private()
435 static int qcom_smem_alloc_global(struct qcom_smem *smem, in qcom_smem_alloc_global() argument
442 header = smem->regions[0].virt_base; in qcom_smem_alloc_global()
469 * qcom_smem_alloc() - allocate space for a smem item
471 * @item: smem item handle
474 * Allocate space for a given smem item of size @size, given that the item is
517 static void *qcom_smem_get_global(struct qcom_smem *smem, in qcom_smem_get_global() argument
529 header = smem->regions[0].virt_base; in qcom_smem_get_global()
536 for (i = 0; i < smem->num_regions; i++) { in qcom_smem_get_global()
537 region = &smem->regions[i]; in qcom_smem_get_global()
556 static void *qcom_smem_get_private(struct qcom_smem *smem, in qcom_smem_get_private() argument
640 dev_err(smem->dev, "Found invalid canary in hosts %hu:%hu partition\n", in qcom_smem_get_private()
647 * qcom_smem_get() - resolve ptr of size of a smem item
649 * @item: smem item handle
652 * Looks up smem item and returns pointer to it. Size of smem
695 * To be used by smem clients as a quick way to determine if any new
743 * with an smem item pointer (previously returned by qcom_smem_get()
746 * Returns 0 if the pointer provided is not within any smem region.
809 static int qcom_smem_get_sbl_version(struct qcom_smem *smem) in qcom_smem_get_sbl_version() argument
814 header = smem->regions[0].virt_base; in qcom_smem_get_sbl_version()
820 static struct smem_ptable *qcom_smem_get_ptable(struct qcom_smem *smem) in qcom_smem_get_ptable() argument
825 ptable = smem->ptable; in qcom_smem_get_ptable()
831 dev_err(smem->dev, in qcom_smem_get_ptable()
838 static u32 qcom_smem_get_item_count(struct qcom_smem *smem) in qcom_smem_get_item_count() argument
843 ptable = qcom_smem_get_ptable(smem); in qcom_smem_get_item_count()
860 qcom_smem_partition_header(struct qcom_smem *smem, in qcom_smem_partition_header() argument
867 phys_addr = smem->regions[0].aux_base + le32_to_cpu(entry->offset); in qcom_smem_partition_header()
868 header = devm_ioremap_wc(smem->dev, phys_addr, le32_to_cpu(entry->size)); in qcom_smem_partition_header()
874 dev_err(smem->dev, "bad partition magic %4ph\n", header->magic); in qcom_smem_partition_header()
879 dev_err(smem->dev, "bad host0 (%hu != %hu)\n", in qcom_smem_partition_header()
884 dev_err(smem->dev, "bad host1 (%hu != %hu)\n", in qcom_smem_partition_header()
891 dev_err(smem->dev, "bad partition size (%u != %u)\n", in qcom_smem_partition_header()
897 dev_err(smem->dev, "bad partition free uncached (%u > %u)\n", in qcom_smem_partition_header()
905 static int qcom_smem_set_global_partition(struct qcom_smem *smem) in qcom_smem_set_global_partition() argument
913 if (smem->global_partition.virt_base) { in qcom_smem_set_global_partition()
914 dev_err(smem->dev, "Already found the global partition\n"); in qcom_smem_set_global_partition()
918 ptable = qcom_smem_get_ptable(smem); in qcom_smem_set_global_partition()
939 dev_err(smem->dev, "Missing entry for global partition\n"); in qcom_smem_set_global_partition()
943 header = qcom_smem_partition_header(smem, entry, in qcom_smem_set_global_partition()
948 smem->global_partition.virt_base = (void __iomem *)header; in qcom_smem_set_global_partition()
949 smem->global_partition.phys_base = smem->regions[0].aux_base + in qcom_smem_set_global_partition()
951 smem->global_partition.size = le32_to_cpu(entry->size); in qcom_smem_set_global_partition()
952 smem->global_partition.cacheline = le32_to_cpu(entry->cacheline); in qcom_smem_set_global_partition()
958 qcom_smem_enumerate_partitions(struct qcom_smem *smem, u16 local_host) in qcom_smem_enumerate_partitions() argument
967 ptable = qcom_smem_get_ptable(smem); in qcom_smem_enumerate_partitions()
988 dev_err(smem->dev, "bad host %u\n", remote_host); in qcom_smem_enumerate_partitions()
992 if (smem->partitions[remote_host].virt_base) { in qcom_smem_enumerate_partitions()
993 dev_err(smem->dev, "duplicate host %u\n", remote_host); in qcom_smem_enumerate_partitions()
997 header = qcom_smem_partition_header(smem, entry, host0, host1); in qcom_smem_enumerate_partitions()
1001 smem->partitions[remote_host].virt_base = (void __iomem *)header; in qcom_smem_enumerate_partitions()
1002 smem->partitions[remote_host].phys_base = smem->regions[0].aux_base + in qcom_smem_enumerate_partitions()
1004 smem->partitions[remote_host].size = le32_to_cpu(entry->size); in qcom_smem_enumerate_partitions()
1005 smem->partitions[remote_host].cacheline = le32_to_cpu(entry->cacheline); in qcom_smem_enumerate_partitions()
1011 static int qcom_smem_map_toc(struct qcom_smem *smem, struct smem_region *region) in qcom_smem_map_toc() argument
1015 /* map starting 4K for smem header */ in qcom_smem_map_toc()
1016 region->virt_base = devm_ioremap_wc(smem->dev, region->aux_base, SZ_4K); in qcom_smem_map_toc()
1019 smem->ptable = devm_ioremap_wc(smem->dev, ptable_start, SZ_4K); in qcom_smem_map_toc()
1021 if (!region->virt_base || !smem->ptable) in qcom_smem_map_toc()
1027 static int qcom_smem_map_global(struct qcom_smem *smem, u32 size) in qcom_smem_map_global() argument
1031 phys_addr = smem->regions[0].aux_base; in qcom_smem_map_global()
1033 smem->regions[0].size = size; in qcom_smem_map_global()
1034 smem->regions[0].virt_base = devm_ioremap_wc(smem->dev, phys_addr, size); in qcom_smem_map_global()
1036 if (!smem->regions[0].virt_base) in qcom_smem_map_global()
1042 static int qcom_smem_resolve_mem(struct qcom_smem *smem, const char *name, in qcom_smem_resolve_mem() argument
1045 struct device *dev = smem->dev; in qcom_smem_resolve_mem()
1071 struct qcom_smem *smem; in qcom_smem_probe() local
1084 smem = devm_kzalloc(&pdev->dev, struct_size(smem, regions, num_regions), in qcom_smem_probe()
1086 if (!smem) in qcom_smem_probe()
1089 smem->dev = &pdev->dev; in qcom_smem_probe()
1090 smem->num_regions = num_regions; in qcom_smem_probe()
1094 smem->regions[0].aux_base = rmem->base; in qcom_smem_probe()
1095 smem->regions[0].size = rmem->size; in qcom_smem_probe()
1101 ret = qcom_smem_resolve_mem(smem, "memory-region", &smem->regions[0]); in qcom_smem_probe()
1107 ret = qcom_smem_resolve_mem(smem, "qcom,rpm-msg-ram", &smem->regions[1]); in qcom_smem_probe()
1113 ret = qcom_smem_map_toc(smem, &smem->regions[0]); in qcom_smem_probe()
1118 smem->regions[i].virt_base = devm_ioremap_wc(&pdev->dev, in qcom_smem_probe()
1119 smem->regions[i].aux_base, in qcom_smem_probe()
1120 smem->regions[i].size); in qcom_smem_probe()
1121 if (!smem->regions[i].virt_base) { in qcom_smem_probe()
1122 dev_err(&pdev->dev, "failed to remap %pa\n", &smem->regions[i].aux_base); in qcom_smem_probe()
1127 header = smem->regions[0].virt_base; in qcom_smem_probe()
1130 dev_err(&pdev->dev, "SMEM is not initialized by SBL\n"); in qcom_smem_probe()
1141 smem->hwlock = hwspin_lock_request_specific(hwlock_id); in qcom_smem_probe()
1142 if (!smem->hwlock) in qcom_smem_probe()
1145 ret = hwspin_lock_timeout_irqsave(smem->hwlock, HWSPINLOCK_TIMEOUT, &flags); in qcom_smem_probe()
1149 hwspin_unlock_irqrestore(smem->hwlock, &flags); in qcom_smem_probe()
1151 version = qcom_smem_get_sbl_version(smem); in qcom_smem_probe()
1153 * smem header mapping is required only in heap version scheme, so unmap in qcom_smem_probe()
1157 devm_iounmap(smem->dev, smem->regions[0].virt_base); in qcom_smem_probe()
1160 ret = qcom_smem_set_global_partition(smem); in qcom_smem_probe()
1163 smem->item_count = qcom_smem_get_item_count(smem); in qcom_smem_probe()
1166 qcom_smem_map_global(smem, size); in qcom_smem_probe()
1167 smem->item_count = SMEM_ITEM_COUNT; in qcom_smem_probe()
1170 dev_err(&pdev->dev, "Unsupported SMEM version 0x%x\n", version); in qcom_smem_probe()
1175 ret = qcom_smem_enumerate_partitions(smem, SMEM_HOST_APPS); in qcom_smem_probe()
1179 __smem = smem; in qcom_smem_probe()
1181 smem->socinfo = platform_device_register_data(&pdev->dev, "qcom-socinfo", in qcom_smem_probe()
1184 if (IS_ERR(smem->socinfo)) in qcom_smem_probe()
1199 { .compatible = "qcom,smem" },
1208 .name = "qcom-smem",