Lines Matching refs:smem
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()
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()
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()
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()
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()