Lines Matching full: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
343 /* Pointer to the one and only smem handle */
349 static int qcom_smem_alloc_private(struct qcom_smem *smem, in qcom_smem_alloc_private() argument
374 dev_err(smem->dev, "Out of memory\n"); in qcom_smem_alloc_private()
394 dev_err(smem->dev, "Found invalid canary in hosts %hu:%hu partition\n", in qcom_smem_alloc_private()
400 static int qcom_smem_alloc_global(struct qcom_smem *smem, in qcom_smem_alloc_global() argument
407 header = smem->regions[0].virt_base; in qcom_smem_alloc_global()
434 * qcom_smem_alloc() - allocate space for a smem item
436 * @item: smem item handle
439 * Allocate space for a given smem item of size @size, given that the item is
482 static void *qcom_smem_get_global(struct qcom_smem *smem, in qcom_smem_get_global() argument
492 header = smem->regions[0].virt_base; in qcom_smem_get_global()
499 for (i = 0; i < smem->num_regions; i++) { in qcom_smem_get_global()
500 region = &smem->regions[i]; in qcom_smem_get_global()
512 static void *qcom_smem_get_private(struct qcom_smem *smem, in qcom_smem_get_private() argument
561 dev_err(smem->dev, "Found invalid canary in hosts %hu:%hu partition\n", in qcom_smem_get_private()
568 * qcom_smem_get() - resolve ptr of size of a smem item
570 * @item: smem item handle
573 * Looks up smem item and returns pointer to it. Size of smem
619 * To be used by smem clients as a quick way to determine if any new
650 * with an smem item pointer (previously returned by qcom_smem_get()
653 * Returns 0 if the pointer provided is not within any smem region.
675 static int qcom_smem_get_sbl_version(struct qcom_smem *smem) in qcom_smem_get_sbl_version() argument
680 header = smem->regions[0].virt_base; in qcom_smem_get_sbl_version()
686 static struct smem_ptable *qcom_smem_get_ptable(struct qcom_smem *smem) in qcom_smem_get_ptable() argument
691 ptable = smem->regions[0].virt_base + smem->regions[0].size - SZ_4K; in qcom_smem_get_ptable()
697 dev_err(smem->dev, in qcom_smem_get_ptable()
704 static u32 qcom_smem_get_item_count(struct qcom_smem *smem) in qcom_smem_get_item_count() argument
709 ptable = qcom_smem_get_ptable(smem); in qcom_smem_get_item_count()
726 qcom_smem_partition_header(struct qcom_smem *smem, in qcom_smem_partition_header() argument
732 header = smem->regions[0].virt_base + le32_to_cpu(entry->offset); in qcom_smem_partition_header()
735 dev_err(smem->dev, "bad partition magic %4ph\n", header->magic); in qcom_smem_partition_header()
740 dev_err(smem->dev, "bad host0 (%hu != %hu)\n", in qcom_smem_partition_header()
745 dev_err(smem->dev, "bad host1 (%hu != %hu)\n", in qcom_smem_partition_header()
752 dev_err(smem->dev, "bad partition size (%u != %u)\n", in qcom_smem_partition_header()
758 dev_err(smem->dev, "bad partition free uncached (%u > %u)\n", in qcom_smem_partition_header()
766 static int qcom_smem_set_global_partition(struct qcom_smem *smem) in qcom_smem_set_global_partition() argument
774 if (smem->global_partition) { in qcom_smem_set_global_partition()
775 dev_err(smem->dev, "Already found the global partition\n"); in qcom_smem_set_global_partition()
779 ptable = qcom_smem_get_ptable(smem); in qcom_smem_set_global_partition()
800 dev_err(smem->dev, "Missing entry for global partition\n"); in qcom_smem_set_global_partition()
804 header = qcom_smem_partition_header(smem, entry, in qcom_smem_set_global_partition()
809 smem->global_partition = header; in qcom_smem_set_global_partition()
810 smem->global_cacheline = le32_to_cpu(entry->cacheline); in qcom_smem_set_global_partition()
816 qcom_smem_enumerate_partitions(struct qcom_smem *smem, u16 local_host) in qcom_smem_enumerate_partitions() argument
825 ptable = qcom_smem_get_ptable(smem); in qcom_smem_enumerate_partitions()
846 dev_err(smem->dev, "bad host %hu\n", remote_host); in qcom_smem_enumerate_partitions()
850 if (smem->partitions[remote_host]) { in qcom_smem_enumerate_partitions()
851 dev_err(smem->dev, "duplicate host %hu\n", remote_host); in qcom_smem_enumerate_partitions()
855 header = qcom_smem_partition_header(smem, entry, host0, host1); in qcom_smem_enumerate_partitions()
859 smem->partitions[remote_host] = header; in qcom_smem_enumerate_partitions()
860 smem->cacheline[remote_host] = le32_to_cpu(entry->cacheline); in qcom_smem_enumerate_partitions()
866 static int qcom_smem_map_memory(struct qcom_smem *smem, struct device *dev, in qcom_smem_map_memory() argument
886 smem->regions[i].virt_base = devm_ioremap_wc(dev, r.start, size); in qcom_smem_map_memory()
887 if (!smem->regions[i].virt_base) in qcom_smem_map_memory()
889 smem->regions[i].aux_base = (u32)r.start; in qcom_smem_map_memory()
890 smem->regions[i].size = size; in qcom_smem_map_memory()
898 struct qcom_smem *smem; in qcom_smem_probe() local
910 smem = devm_kzalloc(&pdev->dev, sizeof(*smem) + array_size, GFP_KERNEL); in qcom_smem_probe()
911 if (!smem) in qcom_smem_probe()
914 smem->dev = &pdev->dev; in qcom_smem_probe()
915 smem->num_regions = num_regions; in qcom_smem_probe()
917 ret = qcom_smem_map_memory(smem, &pdev->dev, "memory-region", 0); in qcom_smem_probe()
921 if (num_regions > 1 && (ret = qcom_smem_map_memory(smem, &pdev->dev, in qcom_smem_probe()
925 header = smem->regions[0].virt_base; in qcom_smem_probe()
928 dev_err(&pdev->dev, "SMEM is not initialized by SBL\n"); in qcom_smem_probe()
932 version = qcom_smem_get_sbl_version(smem); in qcom_smem_probe()
935 ret = qcom_smem_set_global_partition(smem); in qcom_smem_probe()
938 smem->item_count = qcom_smem_get_item_count(smem); in qcom_smem_probe()
941 smem->item_count = SMEM_ITEM_COUNT; in qcom_smem_probe()
944 dev_err(&pdev->dev, "Unsupported SMEM version 0x%x\n", version); in qcom_smem_probe()
949 ret = qcom_smem_enumerate_partitions(smem, SMEM_HOST_APPS); in qcom_smem_probe()
960 smem->hwlock = hwspin_lock_request_specific(hwlock_id); in qcom_smem_probe()
961 if (!smem->hwlock) in qcom_smem_probe()
964 __smem = smem; in qcom_smem_probe()
966 smem->socinfo = platform_device_register_data(&pdev->dev, "qcom-socinfo", in qcom_smem_probe()
969 if (IS_ERR(smem->socinfo)) in qcom_smem_probe()
986 { .compatible = "qcom,smem" },
995 .name = "qcom-smem",