Lines Matching refs:dmabuf
789 struct mbochs_dmabuf *dmabuf = vma->vm_private_data; in mbochs_dmabuf_vm_fault() local
791 if (WARN_ON(vmf->pgoff >= dmabuf->pagecount)) in mbochs_dmabuf_vm_fault()
794 vmf->page = dmabuf->pages[vmf->pgoff]; in mbochs_dmabuf_vm_fault()
805 struct mbochs_dmabuf *dmabuf = buf->priv; in mbochs_mmap_dmabuf() local
806 struct device *dev = mdev_dev(dmabuf->mdev_state->mdev); in mbochs_mmap_dmabuf()
808 dev_dbg(dev, "%s: %d\n", __func__, dmabuf->id); in mbochs_mmap_dmabuf()
814 vma->vm_private_data = dmabuf; in mbochs_mmap_dmabuf()
818 static void mbochs_print_dmabuf(struct mbochs_dmabuf *dmabuf, in mbochs_print_dmabuf() argument
821 struct device *dev = mdev_dev(dmabuf->mdev_state->mdev); in mbochs_print_dmabuf()
822 u32 fourcc = dmabuf->mode.drm_format; in mbochs_print_dmabuf()
825 prefix, dmabuf->id, in mbochs_print_dmabuf()
830 dmabuf->mode.width, dmabuf->mode.height, dmabuf->mode.stride, in mbochs_print_dmabuf()
831 dmabuf->mode.offset, dmabuf->mode.size, dmabuf->pagecount); in mbochs_print_dmabuf()
837 struct mbochs_dmabuf *dmabuf = at->dmabuf->priv; in mbochs_map_dmabuf() local
838 struct device *dev = mdev_dev(dmabuf->mdev_state->mdev); in mbochs_map_dmabuf()
841 dev_dbg(dev, "%s: %d\n", __func__, dmabuf->id); in mbochs_map_dmabuf()
846 if (sg_alloc_table_from_pages(sg, dmabuf->pages, dmabuf->pagecount, in mbochs_map_dmabuf()
847 0, dmabuf->mode.size, GFP_KERNEL) < 0) in mbochs_map_dmabuf()
866 struct mbochs_dmabuf *dmabuf = at->dmabuf->priv; in mbochs_unmap_dmabuf() local
867 struct device *dev = mdev_dev(dmabuf->mdev_state->mdev); in mbochs_unmap_dmabuf()
869 dev_dbg(dev, "%s: %d\n", __func__, dmabuf->id); in mbochs_unmap_dmabuf()
877 struct mbochs_dmabuf *dmabuf = buf->priv; in mbochs_release_dmabuf() local
878 struct mdev_state *mdev_state = dmabuf->mdev_state; in mbochs_release_dmabuf()
882 dev_dbg(dev, "%s: %d\n", __func__, dmabuf->id); in mbochs_release_dmabuf()
884 for (pg = 0; pg < dmabuf->pagecount; pg++) in mbochs_release_dmabuf()
885 put_page(dmabuf->pages[pg]); in mbochs_release_dmabuf()
888 dmabuf->buf = NULL; in mbochs_release_dmabuf()
889 if (dmabuf->unlinked) in mbochs_release_dmabuf()
890 kfree(dmabuf); in mbochs_release_dmabuf()
896 struct mbochs_dmabuf *dmabuf = buf->priv; in mbochs_kmap_dmabuf() local
897 struct page *page = dmabuf->pages[page_num]; in mbochs_kmap_dmabuf()
920 struct mbochs_dmabuf *dmabuf; in mbochs_dmabuf_alloc() local
925 dmabuf = kzalloc(sizeof(struct mbochs_dmabuf), GFP_KERNEL); in mbochs_dmabuf_alloc()
926 if (!dmabuf) in mbochs_dmabuf_alloc()
929 dmabuf->mode = *mode; in mbochs_dmabuf_alloc()
930 dmabuf->id = mdev_state->next_id++; in mbochs_dmabuf_alloc()
931 dmabuf->pagecount = DIV_ROUND_UP(mode->size, PAGE_SIZE); in mbochs_dmabuf_alloc()
932 dmabuf->pages = kcalloc(dmabuf->pagecount, sizeof(struct page *), in mbochs_dmabuf_alloc()
934 if (!dmabuf->pages) in mbochs_dmabuf_alloc()
937 page_offset = dmabuf->mode.offset >> PAGE_SHIFT; in mbochs_dmabuf_alloc()
938 for (pg = 0; pg < dmabuf->pagecount; pg++) { in mbochs_dmabuf_alloc()
939 dmabuf->pages[pg] = __mbochs_get_page(mdev_state, in mbochs_dmabuf_alloc()
941 if (!dmabuf->pages[pg]) in mbochs_dmabuf_alloc()
945 dmabuf->mdev_state = mdev_state; in mbochs_dmabuf_alloc()
946 list_add(&dmabuf->next, &mdev_state->dmabufs); in mbochs_dmabuf_alloc()
948 mbochs_print_dmabuf(dmabuf, __func__); in mbochs_dmabuf_alloc()
949 return dmabuf; in mbochs_dmabuf_alloc()
953 put_page(dmabuf->pages[--pg]); in mbochs_dmabuf_alloc()
954 kfree(dmabuf->pages); in mbochs_dmabuf_alloc()
956 kfree(dmabuf); in mbochs_dmabuf_alloc()
964 struct mbochs_dmabuf *dmabuf; in mbochs_dmabuf_find_by_mode() local
968 list_for_each_entry(dmabuf, &mdev_state->dmabufs, next) in mbochs_dmabuf_find_by_mode()
969 if (mbochs_modes_equal(&dmabuf->mode, mode)) in mbochs_dmabuf_find_by_mode()
970 return dmabuf; in mbochs_dmabuf_find_by_mode()
978 struct mbochs_dmabuf *dmabuf; in mbochs_dmabuf_find_by_id() local
982 list_for_each_entry(dmabuf, &mdev_state->dmabufs, next) in mbochs_dmabuf_find_by_id()
983 if (dmabuf->id == id) in mbochs_dmabuf_find_by_id()
984 return dmabuf; in mbochs_dmabuf_find_by_id()
989 static int mbochs_dmabuf_export(struct mbochs_dmabuf *dmabuf) in mbochs_dmabuf_export() argument
991 struct mdev_state *mdev_state = dmabuf->mdev_state; in mbochs_dmabuf_export()
998 if (!IS_ALIGNED(dmabuf->mode.offset, PAGE_SIZE)) { in mbochs_dmabuf_export()
1005 exp_info.size = dmabuf->mode.size; in mbochs_dmabuf_export()
1006 exp_info.priv = dmabuf; in mbochs_dmabuf_export()
1015 dmabuf->buf = buf; in mbochs_dmabuf_export()
1016 dev_dbg(dev, "%s: %d\n", __func__, dmabuf->id); in mbochs_dmabuf_export()
1097 struct mbochs_dmabuf *dmabuf; in mbochs_query_gfx_plane() local
1132 dmabuf = mbochs_dmabuf_find_by_mode(mdev_state, &mode); in mbochs_query_gfx_plane()
1133 if (!dmabuf) in mbochs_query_gfx_plane()
1135 if (!dmabuf) { in mbochs_query_gfx_plane()
1140 plane->drm_format = dmabuf->mode.drm_format; in mbochs_query_gfx_plane()
1141 plane->width = dmabuf->mode.width; in mbochs_query_gfx_plane()
1142 plane->height = dmabuf->mode.height; in mbochs_query_gfx_plane()
1143 plane->stride = dmabuf->mode.stride; in mbochs_query_gfx_plane()
1144 plane->size = dmabuf->mode.size; in mbochs_query_gfx_plane()
1145 plane->dmabuf_id = dmabuf->id; in mbochs_query_gfx_plane()
1162 struct mbochs_dmabuf *dmabuf; in mbochs_get_gfx_dmabuf() local
1166 dmabuf = mbochs_dmabuf_find_by_id(mdev_state, id); in mbochs_get_gfx_dmabuf()
1167 if (!dmabuf) { in mbochs_get_gfx_dmabuf()
1172 if (!dmabuf->buf) in mbochs_get_gfx_dmabuf()
1173 mbochs_dmabuf_export(dmabuf); in mbochs_get_gfx_dmabuf()
1177 if (!dmabuf->buf) in mbochs_get_gfx_dmabuf()
1180 return dma_buf_fd(dmabuf->buf, 0); in mbochs_get_gfx_dmabuf()
1312 struct mbochs_dmabuf *dmabuf, *tmp; in mbochs_close() local
1316 list_for_each_entry_safe(dmabuf, tmp, &mdev_state->dmabufs, next) { in mbochs_close()
1317 list_del(&dmabuf->next); in mbochs_close()
1318 if (dmabuf->buf) { in mbochs_close()
1320 dmabuf->unlinked = true; in mbochs_close()
1322 kfree(dmabuf); in mbochs_close()