static void ion_set_base_address(struct ion_platform_heap *heap, struct ion_platform_heap *shared_heap, struct ion_co_heap_pdata *co_heap_data, struct ion_cp_heap_pdata *cp_data) { if (cp_data->reusable) { const struct fmem_data *fmem_info = fmem_get_info(); if (!fmem_info) { pr_err("fmem info pointer NULL!\n"); BUG(); } heap->base = fmem_info->phys - fmem_info->reserved_size_low; cp_data->virt_addr = fmem_info->virt; pr_info("ION heap %s using FMEM\n", shared_heap->name); } else { heap->base = msm_ion_get_base(heap->size + shared_heap->size, shared_heap->memory_type, co_heap_data->align); } if (heap->base) { shared_heap->base = heap->base + heap->size; cp_data->secure_base = heap->base; cp_data->secure_size = heap->size + shared_heap->size; } else { pr_err("%s: could not get memory for heap %s (id %x)\n", __func__, heap->name, heap->id); } }
static void allocate_co_memory(struct ion_platform_heap *heap, struct ion_platform_heap heap_data[], unsigned int nr_heaps) { struct ion_co_heap_pdata *co_heap_data = (struct ion_co_heap_pdata *) heap->extra_data; if (co_heap_data->adjacent_mem_id != INVALID_HEAP_ID) { struct ion_platform_heap *shared_heap = find_heap(heap_data, nr_heaps, co_heap_data->adjacent_mem_id); if (shared_heap) { } else { heap->base = msm_ion_get_base( heap->size + shared_heap->size, shared_heap->memory_type, co_heap_data->align); } if (heap->base) { shared_heap->base = heap->base + heap->size; } else { pr_err("%s: could not get memory for heap %s " "(id %x)\n", __func__, heap->name, heap->id); } } }
static void msm_ion_allocate(struct ion_platform_heap *heap) { if (!heap->base && heap->extra_data) { unsigned int align = 0; switch (heap->type) { case ION_HEAP_TYPE_CARVEOUT: align = ((struct ion_co_heap_pdata *) heap->extra_data)->align; break; case ION_HEAP_TYPE_CP: align = ((struct ion_cp_heap_pdata *) heap->extra_data)->align; break; default: break; } if (align) { heap->base = msm_ion_get_base(heap->size, heap->memory_type, align); if (!heap->base) pr_err("%s: could not get memory for heap %s " "(id %x)\n", __func__, heap->name, heap->id); } } }
static int msm_ion_probe(struct platform_device *pdev) { struct ion_platform_data *pdata = pdev->dev.platform_data; int err; int i; num_heaps = pdata->nr; heaps = kcalloc(pdata->nr, sizeof(struct ion_heap *), GFP_KERNEL); if (!heaps) { err = -ENOMEM; goto out; } idev = ion_device_create(NULL); if (IS_ERR_OR_NULL(idev)) { err = PTR_ERR(idev); goto freeheaps; } /* create the heaps as specified in the board file */ for (i = 0; i < num_heaps; i++) { struct ion_platform_heap *heap_data = &pdata->heaps[i]; if (heap_data->type == ION_HEAP_TYPE_CARVEOUT) { heap_data->base = msm_ion_get_base(heap_data->size, heap_data->memory_type); if (!heap_data->base) { pr_err("%s: could not get memory for heap %s" " (id %x)\n", __func__, heap_data->name, heap_data->id); continue; } } heaps[i] = ion_heap_create(heap_data); if (IS_ERR_OR_NULL(heaps[i])) { err = PTR_ERR(heaps[i]); goto heapdestroy; } ion_device_add_heap(idev, heaps[i]); } platform_set_drvdata(pdev, idev); return 0; heapdestroy: for (i = 0; i < num_heaps; i++) { if (!IS_ERR_OR_NULL(heaps[i])) ion_heap_destroy(heaps[i]); } freeheaps: kfree(heaps); out: return err; }
static void msm_ion_allocate(struct ion_platform_heap *heap) { if (!heap->base && heap->extra_data) { unsigned int align = 0; switch (heap->type) { case ION_HEAP_TYPE_CARVEOUT: align = ((struct ion_co_heap_pdata *) heap->extra_data)->align; break; case ION_HEAP_TYPE_CP: { struct ion_cp_heap_pdata *data = (struct ion_cp_heap_pdata *) heap->extra_data; if (data->reusable) { const struct fmem_data *fmem_info = fmem_get_info(); heap->base = fmem_info->phys; data->virt_addr = fmem_info->virt; pr_info("ION heap %s using FMEM\n", heap->name); } else if (data->mem_is_fmem) { const struct fmem_data *fmem_info = fmem_get_info(); heap->base = fmem_info->phys + fmem_info->size; } align = data->align; break; } default: break; } if (align && !heap->base) { heap->base = msm_ion_get_base(heap->size, heap->memory_type, align); if (!heap->base) pr_err("%s: could not get memory for heap %s " "(id %x)\n", __func__, heap->name, heap->id); } } }
static void allocate_co_memory(struct ion_platform_heap *heap, struct ion_platform_heap heap_data[], unsigned int nr_heaps) { struct ion_co_heap_pdata *co_heap_data = (struct ion_co_heap_pdata *) heap->extra_data; if (co_heap_data->adjacent_mem_id != INVALID_HEAP_ID) { struct ion_platform_heap *shared_heap = find_heap(heap_data, nr_heaps, co_heap_data->adjacent_mem_id); if (shared_heap) { struct ion_cp_heap_pdata *cp_data = (struct ion_cp_heap_pdata *) shared_heap->extra_data; if (cp_data->reusable) { const struct fmem_data *fmem_info = fmem_get_info(); heap->base = fmem_info->phys - fmem_info->reserved_size; cp_data->virt_addr = fmem_info->virt; pr_info("ION heap %s using FMEM\n", shared_heap->name); } else { heap->base = msm_ion_get_base( heap->size + shared_heap->size, shared_heap->memory_type, co_heap_data->align); } if (heap->base) { shared_heap->base = heap->base + heap->size; cp_data->secure_base = heap->base; cp_data->secure_size = heap->size + shared_heap->size; } else { pr_err("%s: could not get memory for heap %s " "(id %x)\n", __func__, heap->name, heap->id); } } } }