static int register_memory(void) { int result; ion_phys_addr_t paddr; void *kvptr; unsigned long kvaddr; unsigned long mem_len; pr_debug("%s\n", __func__); result = allocate_col_data(); if (result) { pr_err("%s: allocate_col_data failed, rc = %d\n", __func__, result); goto err_done; } result = allocate_hw_delay_entries(); if (result) { pr_err("%s: allocate_hw_delay_entries failed, rc = %d\n", __func__, result); goto err_col; } result = msm_audio_ion_import("audio_acdb_client", &acdb_data.ion_client, &acdb_data.ion_handle, acdb_data.map_handle, NULL, 0, &paddr, (size_t *)&mem_len, &kvptr); if (result) { pr_err("%s: audio ION alloc failed, rc = %d\n", __func__, result); goto err_hw_delay; } kvaddr = (unsigned long)kvptr; acdb_data.paddr = paddr; acdb_data.kvaddr = kvaddr; acdb_data.mem_len = mem_len; pr_debug("%s done! paddr = 0x%llx, kvaddr = 0x%llx, len = 0x%llx\n", __func__, acdb_data.paddr, acdb_data.kvaddr, acdb_data.mem_len); return result; err_hw_delay: deallocate_hw_delay_entries(); err_col: deallocate_col_data(); err_done: acdb_data.mem_len = 0; return result; }
static int register_memory(void) { int result; int i; ion_phys_addr_t paddr; void *kvptr; unsigned long kvaddr; unsigned long mem_len; pr_debug("%s\n", __func__); mutex_lock(&acdb_data.acdb_mutex); allocate_hw_delay_entries(); for (i = 0; i < MAX_VOCPROC_TYPES; i++) { acdb_data.col_data[i] = kmalloc(MAX_COL_SIZE, GFP_KERNEL); atomic_set(&acdb_data.vocproc_col_cal[i].cal_kvaddr, (uint32_t)acdb_data.col_data[i]); } result = msm_audio_ion_import("audio_acdb_client", &acdb_data.ion_client, &acdb_data.ion_handle, atomic_read(&acdb_data.map_handle), NULL, 0, &paddr, (size_t *)&mem_len, &kvptr); if (result) { pr_err("%s: audio ION alloc failed, rc = %d\n", __func__, result); result = PTR_ERR(acdb_data.ion_client); goto err_ion_handle; } kvaddr = (unsigned long)kvptr; atomic64_set(&acdb_data.paddr, paddr); atomic64_set(&acdb_data.kvaddr, kvaddr); atomic64_set(&acdb_data.mem_len, mem_len); mutex_unlock(&acdb_data.acdb_mutex); pr_debug("%s done! paddr = 0x%lx, kvaddr = 0x%lx, len = x%lx\n", __func__, (long)atomic64_read(&acdb_data.paddr), (long)atomic64_read(&acdb_data.kvaddr), (long)atomic64_read(&acdb_data.mem_len)); return result; err_ion_handle: msm_audio_ion_free(acdb_data.ion_client, acdb_data.ion_handle); atomic64_set(&acdb_data.mem_len, 0); mutex_unlock(&acdb_data.acdb_mutex); return result; }
static int register_memory(void) { int result; int i; ion_phys_addr_t paddr; void *kvptr; unsigned long kvaddr; unsigned long mem_len; pr_debug("%s\n", __func__); result = msm_audio_ion_import("audio_acdb_client", &acdb_data.ion_client, &acdb_data.ion_handle, acdb_data.map_handle, NULL, 0, &paddr, (size_t *)&mem_len, &kvptr); if (result) { pr_err("%s: audio ION alloc failed, rc = %d\n", __func__, result); goto err_ion_handle; } allocate_hw_delay_entries(); for (i = 0; i < MAX_VOCPROC_TYPES; i++) { acdb_data.col_data[i] = kmalloc(MAX_COL_SIZE, GFP_KERNEL); acdb_data.vocproc_col_cal[i].cal_kvaddr = (uint32_t)acdb_data.col_data[i]; } kvaddr = (unsigned long)kvptr; acdb_data.paddr = paddr; acdb_data.kvaddr = kvaddr; acdb_data.mem_len = mem_len; pr_debug("%s done! paddr = 0x%llx, kvaddr = 0x%llx, len = 0x%llx\n", __func__, acdb_data.paddr, acdb_data.kvaddr, acdb_data.mem_len); return result; err_ion_handle: acdb_data.mem_len = 0; return result; }
static int register_memory(void) { int result; unsigned long paddr; void *kvptr; unsigned long kvaddr; unsigned long mem_len; mutex_lock(&acdb_data.acdb_mutex); allocate_hw_delay_entries(); acdb_data.ion_client = msm_ion_client_create(UINT_MAX, "audio_acdb_client"); if (IS_ERR_OR_NULL(acdb_data.ion_client)) { pr_err("%s: Could not register ION client!!!\n", __func__); result = PTR_ERR(acdb_data.ion_client); goto err; } acdb_data.ion_handle = ion_import_dma_buf(acdb_data.ion_client, atomic_read(&acdb_data.map_handle)); if (IS_ERR_OR_NULL(acdb_data.ion_handle)) { pr_err("%s: Could not import map handle!!!\n", __func__); result = PTR_ERR(acdb_data.ion_handle); goto err_ion_client; } result = ion_phys(acdb_data.ion_client, acdb_data.ion_handle, &paddr, (size_t *)&mem_len); if (result != 0) { pr_err("%s: Could not get phys addr!!!\n", __func__); goto err_ion_handle; } kvptr = ion_map_kernel(acdb_data.ion_client, acdb_data.ion_handle); if (IS_ERR_OR_NULL(kvptr)) { pr_err("%s: Could not get kernel virt addr!!!\n", __func__); result = PTR_ERR(kvptr); goto err_ion_handle; } kvaddr = (unsigned long)kvptr; atomic64_set(&acdb_data.paddr, paddr); atomic64_set(&acdb_data.kvaddr, kvaddr); atomic64_set(&acdb_data.mem_len, mem_len); mutex_unlock(&acdb_data.acdb_mutex); pr_debug("%s: done! paddr = 0x%lx, " "kvaddr = 0x%lx, len = x%lx\n", __func__, (long)atomic64_read(&acdb_data.paddr), (long)atomic64_read(&acdb_data.kvaddr), (long)atomic64_read(&acdb_data.mem_len)); return result; err_ion_handle: ion_free(acdb_data.ion_client, acdb_data.ion_handle); err_ion_client: ion_client_destroy(acdb_data.ion_client); err: atomic64_set(&acdb_data.mem_len, 0); mutex_unlock(&acdb_data.acdb_mutex); return result; }