Lines Matching defs: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 */
362 /* The qcom hwspinlock id is always plus one from the smem host id */
366 * qcom_smem_bust_hwspin_lock_by_host() - bust the smem hwspinlock for a host
369 * Busts the hwspin_lock for the given smem host id. This helper is intended
370 * for remoteproc drivers that manage remoteprocs with an equivalent smem
372 * smem hwspin_lock if the rproc unexpectedly goes into a bad state.
399 static int qcom_smem_alloc_private(struct qcom_smem *smem,
435 dev_err(smem->dev, "Out of memory\n");
455 dev_err(smem->dev, "Found invalid canary in hosts %hu:%hu partition\n",
461 static int qcom_smem_alloc_global(struct qcom_smem *smem,
468 header = smem->regions[0].virt_base;
495 * qcom_smem_alloc() - allocate space for a smem item
497 * @item: smem item handle
500 * Allocate space for a given smem item of size @size, given that the item is
545 static void *qcom_smem_get_global(struct qcom_smem *smem,
557 header = smem->regions[0].virt_base;
564 for (i = 0; i < smem->num_regions; i++) {
565 region = &smem->regions[i];
584 static void *qcom_smem_get_private(struct qcom_smem *smem,
668 dev_err(smem->dev, "Found invalid canary in hosts %hu:%hu partition\n",
675 * qcom_smem_get() - resolve ptr of size of a smem item
677 * @item: smem item handle
680 * Looks up smem item and returns pointer to it. Size of smem
714 * To be used by smem clients as a quick way to determine if any new
764 * with an smem item pointer (previously returned by qcom_smem_get()
863 static int qcom_smem_get_sbl_version(struct qcom_smem *smem)
868 header = smem->regions[0].virt_base;
874 static struct smem_ptable *qcom_smem_get_ptable(struct qcom_smem *smem)
879 ptable = smem->ptable;
885 dev_err(smem->dev,
892 static u32 qcom_smem_get_item_count(struct qcom_smem *smem)
897 ptable = qcom_smem_get_ptable(smem);
914 qcom_smem_partition_header(struct qcom_smem *smem,
921 phys_addr = smem->regions[0].aux_base + le32_to_cpu(entry->offset);
922 header = devm_ioremap_wc(smem->dev, phys_addr, le32_to_cpu(entry->size));
928 dev_err(smem->dev, "bad partition magic %4ph\n", header->magic);
933 dev_err(smem->dev, "bad host0 (%hu != %hu)\n",
938 dev_err(smem->dev, "bad host1 (%hu != %hu)\n",
945 dev_err(smem->dev, "bad partition size (%u != %u)\n",
951 dev_err(smem->dev, "bad partition free uncached (%u > %u)\n",
959 static int qcom_smem_set_global_partition(struct qcom_smem *smem)
967 if (smem->global_partition.virt_base) {
968 dev_err(smem->dev, "Already found the global partition\n");
972 ptable = qcom_smem_get_ptable(smem);
993 dev_err(smem->dev, "Missing entry for global partition\n");
997 header = qcom_smem_partition_header(smem, entry,
1002 smem->global_partition.virt_base = (void __iomem *)header;
1003 smem->global_partition.phys_base = smem->regions[0].aux_base +
1005 smem->global_partition.size = le32_to_cpu(entry->size);
1006 smem->global_partition.cacheline = le32_to_cpu(entry->cacheline);
1012 qcom_smem_enumerate_partitions(struct qcom_smem *smem, u16 local_host)
1021 ptable = qcom_smem_get_ptable(smem);
1042 dev_err(smem->dev, "bad host %u\n", remote_host);
1046 if (smem->partitions[remote_host].virt_base) {
1047 dev_err(smem->dev, "duplicate host %u\n", remote_host);
1051 header = qcom_smem_partition_header(smem, entry, host0, host1);
1055 smem->partitions[remote_host].virt_base = (void __iomem *)header;
1056 smem->partitions[remote_host].phys_base = smem->regions[0].aux_base +
1058 smem->partitions[remote_host].size = le32_to_cpu(entry->size);
1059 smem->partitions[remote_host].cacheline = le32_to_cpu(entry->cacheline);
1065 static int qcom_smem_map_toc(struct qcom_smem *smem, struct smem_region *region)
1069 /* map starting 4K for smem header */
1070 region->virt_base = devm_ioremap_wc(smem->dev, region->aux_base, SZ_4K);
1073 smem->ptable = devm_ioremap_wc(smem->dev, ptable_start, SZ_4K);
1075 if (!region->virt_base || !smem->ptable)
1081 static int qcom_smem_map_global(struct qcom_smem *smem, u32 size)
1085 phys_addr = smem->regions[0].aux_base;
1087 smem->regions[0].size = size;
1088 smem->regions[0].virt_base = devm_ioremap_wc(smem->dev, phys_addr, size);
1090 if (!smem->regions[0].virt_base)
1096 static int qcom_smem_resolve_mem(struct qcom_smem *smem, const char *name,
1099 struct device *dev = smem->dev;
1125 struct qcom_smem *smem;
1138 smem = devm_kzalloc(&pdev->dev, struct_size(smem, regions, num_regions),
1140 if (!smem)
1143 smem->dev = &pdev->dev;
1144 smem->num_regions = num_regions;
1148 smem->regions[0].aux_base = rmem->base;
1149 smem->regions[0].size = rmem->size;
1155 ret = qcom_smem_resolve_mem(smem, "memory-region", &smem->regions[0]);
1161 ret = qcom_smem_resolve_mem(smem, "qcom,rpm-msg-ram", &smem->regions[1]);
1167 ret = qcom_smem_map_toc(smem, &smem->regions[0]);
1172 smem->regions[i].virt_base = devm_ioremap_wc(&pdev->dev,
1173 smem->regions[i].aux_base,
1174 smem->regions[i].size);
1175 if (!smem->regions[i].virt_base) {
1176 dev_err(&pdev->dev, "failed to remap %pa\n", &smem->regions[i].aux_base);
1181 header = smem->regions[0].virt_base;
1193 smem->hwlock = hwspin_lock_request_specific(hwlock_id);
1194 if (!smem->hwlock)
1197 ret = hwspin_lock_timeout_irqsave(smem->hwlock, HWSPINLOCK_TIMEOUT, &flags);
1201 hwspin_unlock_irqrestore(smem->hwlock, &flags);
1203 version = qcom_smem_get_sbl_version(smem);
1205 * smem header mapping is required only in heap version scheme, so unmap
1209 devm_iounmap(smem->dev, smem->regions[0].virt_base);
1212 ret = qcom_smem_set_global_partition(smem);
1215 smem->item_count = qcom_smem_get_item_count(smem);
1218 qcom_smem_map_global(smem, size);
1219 smem->item_count = SMEM_ITEM_COUNT;
1227 ret = qcom_smem_enumerate_partitions(smem, SMEM_HOST_APPS);
1231 __smem = smem;
1233 smem->socinfo = platform_device_register_data(&pdev->dev, "qcom-socinfo",
1236 if (IS_ERR(smem->socinfo))
1251 { .compatible = "qcom,smem" },
1260 .name = "qcom-smem",