Skip to content
Snippets Groups Projects
Select Git revision
  • 13731de6add8a543b1fc9ea292197d81a517ef9e
  • master default protected
  • android-msm-bullhead-3.10-nougat_kgdb_less_changes
  • android-msm-bullhead-3.10-nougat_kgdb
  • android-msm-bullhead-3.10-nougat_klist
  • android-4.4
  • android-msm-vega-4.4-oreo-daydream
  • android-msm-wahoo-4.4-p-preview-5
  • android-msm-wahoo-4.4-pie
  • android-msm-marlin-3.18-p-preview-5
  • android-msm-marlin-3.18-pie
  • android-msm-wahoo-2018.07-oreo-m2
  • android-msm-wahoo-2018.07-oreo-m4
  • android-msm-wahoo-4.4-p-preview-4
  • android-msm-bullhead-3.10-oreo-m6
  • android-msm-angler-3.10-oreo-m6
  • android-msm-marlin-3.18-p-preview-4
  • android-msm-stargazer-3.18-oreo-wear-dr
  • android-msm-catshark-3.18-oreo-wear-dr
  • android-msm-wahoo-4.4-oreo-m2
  • android-msm-wahoo-4.4-oreo-m4
  • android-daydreamos-8.0.0_r0.5
  • android-8.1.0_r0.92
  • android-8.1.0_r0.91
  • android-daydreamos-8.0.0_r0.4
  • android-p-preview-5_r0.2
  • android-p-preview-5_r0.1
  • android-9.0.0_r0.5
  • android-9.0.0_r0.4
  • android-9.0.0_r0.2
  • android-9.0.0_r0.1
  • android-8.1.0_r0.81
  • android-8.1.0_r0.80
  • android-8.1.0_r0.78
  • android-8.1.0_r0.76
  • android-8.1.0_r0.75
  • android-8.1.0_r0.72
  • android-8.1.0_r0.70
  • android-p-preview-4_r0.2
  • android-p-preview-4_r0.1
  • android-wear-8.0.0_r0.30
41 results

dma-buf.c

Blame
  • dma-buf.c 17.83 KiB
    /*
     * Framework for buffer objects that can be shared across devices/subsystems.
     *
     * Copyright(C) 2011 Linaro Limited. All rights reserved.
     * Author: Sumit Semwal <sumit.semwal@ti.com>
     *
     * Many thanks to linaro-mm-sig list, and specially
     * Arnd Bergmann <arnd@arndb.de>, Rob Clark <rob@ti.com> and
     * Daniel Vetter <daniel@ffwll.ch> for their support in creation and
     * refining of this idea.
     *
     * This program is free software; you can redistribute it and/or modify it
     * under the terms of the GNU General Public License version 2 as published by
     * the Free Software Foundation.
     *
     * This program is distributed in the hope that it will be useful, but WITHOUT
     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
     * more details.
     *
     * You should have received a copy of the GNU General Public License along with
     * this program.  If not, see <http://www.gnu.org/licenses/>.
     */
    
    #include <linux/fs.h>
    #include <linux/slab.h>
    #include <linux/dma-buf.h>
    #include <linux/anon_inodes.h>
    #include <linux/export.h>
    #include <linux/debugfs.h>
    #include <linux/seq_file.h>
    
    static inline int is_dma_buf_file(struct file *);
    
    struct dma_buf_list {
    	struct list_head head;
    	struct mutex lock;
    };
    
    static struct dma_buf_list db_list;
    
    static int dma_buf_release(struct inode *inode, struct file *file)
    {
    	struct dma_buf *dmabuf;
    
    	if (!is_dma_buf_file(file))
    		return -EINVAL;
    
    	dmabuf = file->private_data;
    
    	BUG_ON(dmabuf->vmapping_counter);
    
    	dmabuf->ops->release(dmabuf);
    
    	mutex_lock(&db_list.lock);
    	list_del(&dmabuf->list_node);
    	mutex_unlock(&db_list.lock);
    
    	kfree(dmabuf);
    	return 0;
    }
    
    static int dma_buf_mmap_internal(struct file *file, struct vm_area_struct *vma)
    {
    	struct dma_buf *dmabuf;
    
    	if (!is_dma_buf_file(file))
    		return -EINVAL;
    
    	dmabuf = file->private_data;