• Home
  • Raw
  • Download

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
342 /* Pointer to the one and only smem handle */
348 static int qcom_smem_alloc_private(struct qcom_smem *smem, in qcom_smem_alloc_private() argument
373 dev_err(smem->dev, "Out of memory\n"); in qcom_smem_alloc_private()
393 dev_err(smem->dev, "Found invalid canary in hosts %hu:%hu partition\n", in qcom_smem_alloc_private()
399 static int qcom_smem_alloc_global(struct qcom_smem *smem, in qcom_smem_alloc_global() argument
406 header = smem->regions[0].virt_base; in qcom_smem_alloc_global()
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, in qcom_smem_get_global() argument
491 header = smem->regions[0].virt_base; in qcom_smem_get_global()
498 for (i = 0; i < smem->num_regions; i++) { in qcom_smem_get_global()
499 region = &smem->regions[i]; in qcom_smem_get_global()
511 static void *qcom_smem_get_private(struct qcom_smem *smem, in qcom_smem_get_private() argument
560 dev_err(smem->dev, "Found invalid canary in hosts %hu:%hu partition\n", in qcom_smem_get_private()
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) in qcom_smem_get_sbl_version() argument
679 header = smem->regions[0].virt_base; in qcom_smem_get_sbl_version()
685 static struct smem_ptable *qcom_smem_get_ptable(struct qcom_smem *smem) in qcom_smem_get_ptable() argument
690 ptable = smem->regions[0].virt_base + smem->regions[0].size - SZ_4K; in qcom_smem_get_ptable()
696 dev_err(smem->dev, in qcom_smem_get_ptable()
703 static u32 qcom_smem_get_item_count(struct qcom_smem *smem) in qcom_smem_get_item_count() argument
708 ptable = qcom_smem_get_ptable(smem); in qcom_smem_get_item_count()
725 qcom_smem_partition_header(struct qcom_smem *smem, in qcom_smem_partition_header() argument
731 header = smem->regions[0].virt_base + le32_to_cpu(entry->offset); in qcom_smem_partition_header()
734 dev_err(smem->dev, "bad partition magic %02x %02x %02x %02x\n", in qcom_smem_partition_header()
741 dev_err(smem->dev, "bad host0 (%hu != %hu)\n", in qcom_smem_partition_header()
746 dev_err(smem->dev, "bad host1 (%hu != %hu)\n", in qcom_smem_partition_header()
753 dev_err(smem->dev, "bad partition size (%u != %u)\n", in qcom_smem_partition_header()
759 dev_err(smem->dev, "bad partition free uncached (%u > %u)\n", in qcom_smem_partition_header()
767 static int qcom_smem_set_global_partition(struct qcom_smem *smem) in qcom_smem_set_global_partition() argument
775 if (smem->global_partition) { in qcom_smem_set_global_partition()
776 dev_err(smem->dev, "Already found the global partition\n"); in qcom_smem_set_global_partition()
780 ptable = qcom_smem_get_ptable(smem); in qcom_smem_set_global_partition()
801 dev_err(smem->dev, "Missing entry for global partition\n"); in qcom_smem_set_global_partition()
805 header = qcom_smem_partition_header(smem, entry, in qcom_smem_set_global_partition()
810 smem->global_partition = header; in qcom_smem_set_global_partition()
811 smem->global_cacheline = le32_to_cpu(entry->cacheline); in qcom_smem_set_global_partition()
817 qcom_smem_enumerate_partitions(struct qcom_smem *smem, u16 local_host) in qcom_smem_enumerate_partitions() argument
826 ptable = qcom_smem_get_ptable(smem); in qcom_smem_enumerate_partitions()
847 dev_err(smem->dev, "bad host %hu\n", remote_host); in qcom_smem_enumerate_partitions()
851 if (smem->partitions[remote_host]) { in qcom_smem_enumerate_partitions()
852 dev_err(smem->dev, "duplicate host %hu\n", remote_host); in qcom_smem_enumerate_partitions()
856 header = qcom_smem_partition_header(smem, entry, host0, host1); in qcom_smem_enumerate_partitions()
860 smem->partitions[remote_host] = header; in qcom_smem_enumerate_partitions()
861 smem->cacheline[remote_host] = le32_to_cpu(entry->cacheline); in qcom_smem_enumerate_partitions()
867 static int qcom_smem_map_memory(struct qcom_smem *smem, struct device *dev, in qcom_smem_map_memory() argument
887 smem->regions[i].virt_base = devm_ioremap_wc(dev, r.start, size); in qcom_smem_map_memory()
888 if (!smem->regions[i].virt_base) in qcom_smem_map_memory()
890 smem->regions[i].aux_base = (u32)r.start; in qcom_smem_map_memory()
891 smem->regions[i].size = size; in qcom_smem_map_memory()
899 struct qcom_smem *smem; in qcom_smem_probe() local
911 smem = devm_kzalloc(&pdev->dev, sizeof(*smem) + array_size, GFP_KERNEL); in qcom_smem_probe()
912 if (!smem) in qcom_smem_probe()
915 smem->dev = &pdev->dev; in qcom_smem_probe()
916 smem->num_regions = num_regions; in qcom_smem_probe()
918 ret = qcom_smem_map_memory(smem, &pdev->dev, "memory-region", 0); in qcom_smem_probe()
922 if (num_regions > 1 && (ret = qcom_smem_map_memory(smem, &pdev->dev, in qcom_smem_probe()
926 header = smem->regions[0].virt_base; in qcom_smem_probe()
929 dev_err(&pdev->dev, "SMEM is not initialized by SBL\n"); in qcom_smem_probe()
933 version = qcom_smem_get_sbl_version(smem); in qcom_smem_probe()
936 ret = qcom_smem_set_global_partition(smem); in qcom_smem_probe()
939 smem->item_count = qcom_smem_get_item_count(smem); in qcom_smem_probe()
942 smem->item_count = SMEM_ITEM_COUNT; in qcom_smem_probe()
945 dev_err(&pdev->dev, "Unsupported SMEM version 0x%x\n", version); in qcom_smem_probe()
950 ret = qcom_smem_enumerate_partitions(smem, SMEM_HOST_APPS); in qcom_smem_probe()
961 smem->hwlock = hwspin_lock_request_specific(hwlock_id); in qcom_smem_probe()
962 if (!smem->hwlock) in qcom_smem_probe()
965 __smem = smem; in qcom_smem_probe()
967 smem->socinfo = platform_device_register_data(&pdev->dev, "qcom-socinfo", in qcom_smem_probe()
970 if (IS_ERR(smem->socinfo)) in qcom_smem_probe()
987 { .compatible = "qcom,smem" },
996 .name = "qcom-smem",