参照元

説明

引数

返り値

参考

実装

void ion_device_add_heap(struct ion_device *dev, struct ion_heap *heap)
{
        struct dentry *debug_file;

        if (!heap->ops->allocate || !heap->ops->free || !heap->ops->map_dma ||
            !heap->ops->unmap_dma)
                pr_err("%s: can not add heap with invalid ops struct.\n",
                       __func__);

        spin_lock_init(&heap->free_lock);
        heap->free_list_size = 0;

        if (heap->flags & ION_HEAP_FLAG_DEFER_FREE)
                ion_heap_init_deferred_free(heap);

        if ((heap->flags & ION_HEAP_FLAG_DEFER_FREE) || heap->ops->shrink)
                ion_heap_init_shrinker(heap);

        heap->dev = dev;
        down_write(&dev->lock);
        /*
         * use negative heap->id to reverse the priority -- when traversing
         * the list later attempt higher id numbers first
         */
        plist_node_init(&heap->node, -heap->id);
        plist_add(&heap->node, &dev->heaps);
        debug_file = debugfs_create_file(heap->name, 0664,
                                        dev->heaps_debug_root, heap,
                                        &debug_heap_fops);

        if (!debug_file) {
                char buf[256], *path;

                path = dentry_path(dev->heaps_debug_root, buf, 256);
                pr_err("Failed to create heap debugfs at %s/%s\n",
                        path, heap->name);
        }

        if (heap->shrinker.count_objects && heap->shrinker.scan_objects) {
                char debug_name[64];

                snprintf(debug_name, 64, "%s_shrink", heap->name);
                debug_file = debugfs_create_file(
                        debug_name, 0644, dev->heaps_debug_root, heap,
                        &debug_shrink_fops);
                if (!debug_file) {
                        char buf[256], *path;

                        path = dentry_path(dev->heaps_debug_root, buf, 256);
                        pr_err("Failed to create heap shrinker debugfs at %s/%s\n",
                                path, debug_name);
                }
        }

        up_write(&dev->lock);
}
EXPORT_SYMBOL(ion_device_add_heap);

コメント


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS