参照元

説明

引数

返り値

参考

実装

static struct sg_table *vb2_dc_dmabuf_ops_map(
        struct dma_buf_attachment *db_attach, enum dma_data_direction dma_dir)
{
        struct vb2_dc_attachment *attach = db_attach->priv;
        /* stealing dmabuf mutex to serialize map/unmap operations */
        struct mutex *lock = &db_attach->dmabuf->lock;
        struct sg_table *sgt;
        mutex_lock(lock);
        sgt = &attach->sgt;
        /* return previously mapped sg table */
        if (attach->dma_dir == dma_dir) {
                mutex_unlock(lock);
                return sgt;
        }
        /* release any previous cache */
        if (attach->dma_dir != DMA_NONE) {
                dma_unmap_sg(db_attach->dev, sgt->sgl, sgt->orig_nents,
                        attach->dma_dir);
                attach->dma_dir = DMA_NONE;
        }
        /* mapping to the client with new direction */
        sgt->nents = dma_map_sg(db_attach->dev, sgt->sgl, sgt->orig_nents,
                                dma_dir);
        if (!sgt->nents) {
                pr_err("failed to map scatterlist\n");
                mutex_unlock(lock);
                return ERR_PTR(-EIO);
        }
        attach->dma_dir = dma_dir;

        mutex_unlock(lock);

        return sgt;
}

コメント


トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2016-02-08 (月) 15:24:09