From 3ecb7a87e8c79ac26495b996c5a369c5b110c865 Mon Sep 17 00:00:00 2001 From: CMY Date: Sat, 31 May 2014 13:48:09 +0800 Subject: [PATCH] rk: ion: resolve snapshot error and enable it by default --- arch/arm/configs/rockchip_defconfig | 2 + drivers/staging/android/ion/ion.c | 46 ++++++++----------- drivers/staging/android/ion/ion_cma_heap.c | 1 - drivers/staging/android/ion/ion_priv.h | 2 - drivers/staging/android/ion/ion_system_heap.c | 1 - 5 files changed, 20 insertions(+), 32 deletions(-) diff --git a/arch/arm/configs/rockchip_defconfig b/arch/arm/configs/rockchip_defconfig index 508368f2a6a2..78de88be5f04 100644 --- a/arch/arm/configs/rockchip_defconfig +++ b/arch/arm/configs/rockchip_defconfig @@ -505,6 +505,8 @@ CONFIG_SW_SYNC=y CONFIG_SW_SYNC_USER=y CONFIG_ION=y CONFIG_ION_ROCKCHIP=y +CONFIG_ION_ROCKCHIP_SNAPSHOT=y +CONFIG_ION_SNAPSHOT_BUF_SHIFT=15 CONFIG_COMMON_CLK_DEBUG=y CONFIG_IIO=y CONFIG_ROCKCHIP_ADC=y diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index bdc6afb3d7b9..5ea1df6de325 100755 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -122,6 +122,7 @@ static void ion_iommu_force_unmap(struct ion_buffer *buffer); #ifdef CONFIG_ION_ROCKCHIP_SNAPSHOT extern char *rockchip_ion_snapshot_get(unsigned *size); extern int rockchip_ion_snapshot_debugfs(struct dentry* root); +static int ion_snapshot_save(struct ion_device *idev); #endif bool ion_buffer_fault_user_mappings(struct ion_buffer *buffer) @@ -519,8 +520,12 @@ struct ion_handle *ion_alloc(struct ion_client *client, size_t len, if (buffer == NULL) return ERR_PTR(-ENODEV); - if (IS_ERR(buffer)) + if (IS_ERR(buffer)) { +#ifdef CONFIG_ION_ROCKCHIP_SNAPSHOT + ion_snapshot_save(client->dev); +#endif return ERR_PTR(PTR_ERR(buffer)); + } handle = ion_handle_create(client, buffer); @@ -901,12 +906,14 @@ EXPORT_SYMBOL(ion_unmap_iommu); static int ion_debug_client_show_buffer_map(struct seq_file *s, struct ion_buffer *buffer) { struct ion_iommu_map *iommu_map; - const struct rb_root *rb = &(buffer->iommu_maps); - struct rb_node *node = rb_first(rb); + const struct rb_root *rb; + struct rb_node *node; pr_debug("%s: buffer(%p)\n", __func__, buffer); mutex_lock(&buffer->lock); + rb = &(buffer->iommu_maps); + node = rb_first(rb); while (node != NULL) { iommu_map = rb_entry(node, struct ion_iommu_map, node); @@ -937,12 +944,18 @@ static int ion_debug_client_show_buffer(struct seq_file *s, void *unused) struct ion_buffer *buffer = handle->buffer; ion_phys_addr_t pa = 0; size_t len = buffer->size; + + mutex_lock(&buffer->lock); + if (buffer->heap->ops->phys) buffer->heap->ops->phys(buffer->heap, buffer, &pa, &len); seq_printf(s, "%16.16s: 0x%08lx 0x%08lx %8zuKB %4d %4d %4d\n", buffer->heap->name, (unsigned long)buffer->vaddr, pa, len>>10, buffer->handle_count, atomic_read(&buffer->ref.refcount), atomic_read(&handle->ref.refcount)); + + mutex_unlock(&buffer->lock); + #ifdef CONFIG_ROCKCHIP_IOMMU ion_debug_client_show_buffer_map(s, buffer); #endif @@ -2016,7 +2029,7 @@ static unsigned long ion_find_max_zero_area(unsigned long *map, unsigned long si return max_zero_sz; } -int ion_snapshot_save(struct ion_device *idev) +static int ion_snapshot_save(struct ion_device *idev) { static struct seq_file seqf; struct ion_heap *heap; @@ -2029,7 +2042,7 @@ int ion_snapshot_save(struct ion_device *idev) } memset(seqf.buf, 0, seqf.size); seqf.count = 0; - pr_info("%s: save snapshot 0x%x@0x%lx\n", __func__, seqf.size, + pr_debug("%s: save snapshot 0x%x@0x%lx\n", __func__, seqf.size, __pa(seqf.buf)); down_read(&idev->lock); @@ -2051,31 +2064,8 @@ int ion_snapshot_save(struct ion_device *idev) } } - for (n = rb_first(&idev->clients); n; n = rb_next(n)) { - struct ion_client *client = rb_entry(n, struct ion_client, node); - seqf.private = (void*)client; - if (client->task) { - char task_comm[TASK_COMM_LEN]; - - get_task_comm(task_comm, client->task); - seq_printf(&seqf, "++++++++++++++++ CLIENT: %s(PID-%d) ++++++++++++++++\n", - task_comm, client->pid); - } else { - seq_printf(&seqf, "++++++++++++++++ CLIENT: %s(PID-%d) ++++++++++++++++\n", - client->display_name, client->pid); - } - - ion_debug_client_show(&seqf, NULL); - seq_printf(&seqf, "\n"); - } - up_read(&idev->lock); return 0; } -#else -int ion_snapshot_save(struct ion_device *idev) -{ - return 0; -} #endif diff --git a/drivers/staging/android/ion/ion_cma_heap.c b/drivers/staging/android/ion/ion_cma_heap.c index 5d7497a9ef28..2faf8d572086 100755 --- a/drivers/staging/android/ion/ion_cma_heap.c +++ b/drivers/staging/android/ion/ion_cma_heap.c @@ -111,7 +111,6 @@ free_mem: dma_free_coherent(dev, len, info->cpu_addr, info->handle); err: kfree(info); - ion_snapshot_save(heap->dev); return ION_CMA_ALLOCATE_FAILED; } diff --git a/drivers/staging/android/ion/ion_priv.h b/drivers/staging/android/ion/ion_priv.h index 29cbd8354aa6..867003a9e080 100755 --- a/drivers/staging/android/ion/ion_priv.h +++ b/drivers/staging/android/ion/ion_priv.h @@ -433,6 +433,4 @@ int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask, void ion_pages_sync_for_device(struct device *dev, struct page *page, size_t size, enum dma_data_direction dir); -int ion_snapshot_save(struct ion_device *idev); - #endif /* _ION_PRIV_H */ diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c index 5dccc34ecc3a..e61993d3c2c4 100755 --- a/drivers/staging/android/ion/ion_system_heap.c +++ b/drivers/staging/android/ion/ion_system_heap.c @@ -193,7 +193,6 @@ err: free_buffer_page(sys_heap, buffer, info->page, info->order); kfree(info); } - ion_snapshot_save(heap->dev); return -ENOMEM; } -- 2.34.1