Lines Matching refs:smem
15 #include <linux/soc/qcom/smem.h>
36 * (@smem_ptable), that is found 4kB from the end of the main smem region. The
53 * region with partition type (SMEM_GLOBAL_HOST) and the max smem item count is
63 * The version member of the smem header contains an array of versions for the
102 * struct smem_global_entry - entry to reference smem items on the heap
118 * struct smem_header - header found in beginning of primary smem region
121 * @initialized: boolean to indicate that smem is initialized
122 * @free_offset: index of the first unallocated byte in smem
202 * @item: identifying number of the smem item
219 * struct smem_info - smem region info located after the table of contents
221 * @size: size of the smem region
222 * @base_addr: base address of the smem region
237 * struct smem_region - representation of a chunk of memory used for smem
249 * struct qcom_smem - device data for the smem device
342 /* Pointer to the one and only smem handle */
348 static int qcom_smem_alloc_private(struct qcom_smem *smem,
373 dev_err(smem->dev, "Out of memory\n");
393 dev_err(smem->dev, "Found invalid canary in hosts %hu:%hu partition\n",
399 static int qcom_smem_alloc_global(struct qcom_smem *smem,
406 header = smem->regions[0].virt_base;
433 * qcom_smem_alloc() - allocate space for a smem item
435 * @item: smem item handle
438 * Allocate space for a given smem item of size @size, given that the item is
481 static void *qcom_smem_get_global(struct qcom_smem *smem,
491 header = smem->regions[0].virt_base;
498 for (i = 0; i < smem->num_regions; i++) {
499 region = &smem->regions[i];
511 static void *qcom_smem_get_private(struct qcom_smem *smem,
560 dev_err(smem->dev, "Found invalid canary in hosts %hu:%hu partition\n",
567 * qcom_smem_get() - resolve ptr of size of a smem item
569 * @item: smem item handle
572 * Looks up smem item and returns pointer to it. Size of smem
618 * To be used by smem clients as a quick way to determine if any new
649 * with an smem item pointer (previously returned by qcom_smem_get()
652 * Returns 0 if the pointer provided is not within any smem region.
674 static int qcom_smem_get_sbl_version(struct qcom_smem *smem)
679 header = smem->regions[0].virt_base;
685 static struct smem_ptable *qcom_smem_get_ptable(struct qcom_smem *smem)
690 ptable = smem->regions[0].virt_base + smem->regions[0].size - SZ_4K;
696 dev_err(smem->dev,
703 static u32 qcom_smem_get_item_count(struct qcom_smem *smem)
708 ptable = qcom_smem_get_ptable(smem);
725 qcom_smem_partition_header(struct qcom_smem *smem,
731 header = smem->regions[0].virt_base + le32_to_cpu(entry->offset);
734 dev_err(smem->dev, "bad partition magic %02x %02x %02x %02x\n",
741 dev_err(smem->dev, "bad host0 (%hu != %hu)\n",
746 dev_err(smem->dev, "bad host1 (%hu != %hu)\n",
753 dev_err(smem->dev, "bad partition size (%u != %u)\n",
759 dev_err(smem->dev, "bad partition free uncached (%u > %u)\n",
767 static int qcom_smem_set_global_partition(struct qcom_smem *smem)
775 if (smem->global_partition) {
776 dev_err(smem->dev, "Already found the global partition\n");
780 ptable = qcom_smem_get_ptable(smem);
801 dev_err(smem->dev, "Missing entry for global partition\n");
805 header = qcom_smem_partition_header(smem, entry,
810 smem->global_partition = header;
811 smem->global_cacheline = le32_to_cpu(entry->cacheline);
817 qcom_smem_enumerate_partitions(struct qcom_smem *smem, u16 local_host)
826 ptable = qcom_smem_get_ptable(smem);
847 dev_err(smem->dev, "bad host %hu\n", remote_host);
851 if (smem->partitions[remote_host]) {
852 dev_err(smem->dev, "duplicate host %hu\n", remote_host);
856 header = qcom_smem_partition_header(smem, entry, host0, host1);
860 smem->partitions[remote_host] = header;
861 smem->cacheline[remote_host] = le32_to_cpu(entry->cacheline);
867 static int qcom_smem_map_memory(struct qcom_smem *smem, struct device *dev,
887 smem->regions[i].virt_base = devm_ioremap_wc(dev, r.start, size);
888 if (!smem->regions[i].virt_base)
890 smem->regions[i].aux_base = (u32)r.start;
891 smem->regions[i].size = size;
899 struct qcom_smem *smem;
911 smem = devm_kzalloc(&pdev->dev, sizeof(*smem) + array_size, GFP_KERNEL);
912 if (!smem)
915 smem->dev = &pdev->dev;
916 smem->num_regions = num_regions;
918 ret = qcom_smem_map_memory(smem, &pdev->dev, "memory-region", 0);
922 if (num_regions > 1 && (ret = qcom_smem_map_memory(smem, &pdev->dev,
926 header = smem->regions[0].virt_base;
933 version = qcom_smem_get_sbl_version(smem);
936 ret = qcom_smem_set_global_partition(smem);
939 smem->item_count = qcom_smem_get_item_count(smem);
942 smem->item_count = SMEM_ITEM_COUNT;
950 ret = qcom_smem_enumerate_partitions(smem, SMEM_HOST_APPS);
961 smem->hwlock = hwspin_lock_request_specific(hwlock_id);
962 if (!smem->hwlock)
965 __smem = smem;
967 smem->socinfo = platform_device_register_data(&pdev->dev, "qcom-socinfo",
970 if (IS_ERR(smem->socinfo))
987 { .compatible = "qcom,smem" },
996 .name = "qcom-smem",