Lines Matching refs:dmabuf

793 	struct mbochs_dmabuf *dmabuf = vma->vm_private_data;  in mbochs_dmabuf_vm_fault()  local
795 if (WARN_ON(vmf->pgoff >= dmabuf->pagecount)) in mbochs_dmabuf_vm_fault()
798 vmf->page = dmabuf->pages[vmf->pgoff]; in mbochs_dmabuf_vm_fault()
809 struct mbochs_dmabuf *dmabuf = buf->priv; in mbochs_mmap_dmabuf() local
810 struct device *dev = mdev_dev(dmabuf->mdev_state->mdev); in mbochs_mmap_dmabuf()
812 dev_dbg(dev, "%s: %d\n", __func__, dmabuf->id); in mbochs_mmap_dmabuf()
818 vma->vm_private_data = dmabuf; in mbochs_mmap_dmabuf()
822 static void mbochs_print_dmabuf(struct mbochs_dmabuf *dmabuf, in mbochs_print_dmabuf() argument
825 struct device *dev = mdev_dev(dmabuf->mdev_state->mdev); in mbochs_print_dmabuf()
826 u32 fourcc = dmabuf->mode.drm_format; in mbochs_print_dmabuf()
829 prefix, dmabuf->id, in mbochs_print_dmabuf()
834 dmabuf->mode.width, dmabuf->mode.height, dmabuf->mode.stride, in mbochs_print_dmabuf()
835 dmabuf->mode.offset, dmabuf->mode.size, dmabuf->pagecount); in mbochs_print_dmabuf()
841 struct mbochs_dmabuf *dmabuf = at->dmabuf->priv; in mbochs_map_dmabuf() local
842 struct device *dev = mdev_dev(dmabuf->mdev_state->mdev); in mbochs_map_dmabuf()
845 dev_dbg(dev, "%s: %d\n", __func__, dmabuf->id); in mbochs_map_dmabuf()
850 if (sg_alloc_table_from_pages(sg, dmabuf->pages, dmabuf->pagecount, in mbochs_map_dmabuf()
851 0, dmabuf->mode.size, GFP_KERNEL) < 0) in mbochs_map_dmabuf()
870 struct mbochs_dmabuf *dmabuf = at->dmabuf->priv; in mbochs_unmap_dmabuf() local
871 struct device *dev = mdev_dev(dmabuf->mdev_state->mdev); in mbochs_unmap_dmabuf()
873 dev_dbg(dev, "%s: %d\n", __func__, dmabuf->id); in mbochs_unmap_dmabuf()
882 struct mbochs_dmabuf *dmabuf = buf->priv; in mbochs_release_dmabuf() local
883 struct mdev_state *mdev_state = dmabuf->mdev_state; in mbochs_release_dmabuf()
887 dev_dbg(dev, "%s: %d\n", __func__, dmabuf->id); in mbochs_release_dmabuf()
889 for (pg = 0; pg < dmabuf->pagecount; pg++) in mbochs_release_dmabuf()
890 put_page(dmabuf->pages[pg]); in mbochs_release_dmabuf()
893 dmabuf->buf = NULL; in mbochs_release_dmabuf()
894 if (dmabuf->unlinked) in mbochs_release_dmabuf()
895 kfree(dmabuf); in mbochs_release_dmabuf()
909 struct mbochs_dmabuf *dmabuf; in mbochs_dmabuf_alloc() local
914 dmabuf = kzalloc(sizeof(struct mbochs_dmabuf), GFP_KERNEL); in mbochs_dmabuf_alloc()
915 if (!dmabuf) in mbochs_dmabuf_alloc()
918 dmabuf->mode = *mode; in mbochs_dmabuf_alloc()
919 dmabuf->id = mdev_state->next_id++; in mbochs_dmabuf_alloc()
920 dmabuf->pagecount = DIV_ROUND_UP(mode->size, PAGE_SIZE); in mbochs_dmabuf_alloc()
921 dmabuf->pages = kcalloc(dmabuf->pagecount, sizeof(struct page *), in mbochs_dmabuf_alloc()
923 if (!dmabuf->pages) in mbochs_dmabuf_alloc()
926 page_offset = dmabuf->mode.offset >> PAGE_SHIFT; in mbochs_dmabuf_alloc()
927 for (pg = 0; pg < dmabuf->pagecount; pg++) { in mbochs_dmabuf_alloc()
928 dmabuf->pages[pg] = __mbochs_get_page(mdev_state, in mbochs_dmabuf_alloc()
930 if (!dmabuf->pages[pg]) in mbochs_dmabuf_alloc()
934 dmabuf->mdev_state = mdev_state; in mbochs_dmabuf_alloc()
935 list_add(&dmabuf->next, &mdev_state->dmabufs); in mbochs_dmabuf_alloc()
937 mbochs_print_dmabuf(dmabuf, __func__); in mbochs_dmabuf_alloc()
938 return dmabuf; in mbochs_dmabuf_alloc()
942 put_page(dmabuf->pages[--pg]); in mbochs_dmabuf_alloc()
943 kfree(dmabuf->pages); in mbochs_dmabuf_alloc()
945 kfree(dmabuf); in mbochs_dmabuf_alloc()
953 struct mbochs_dmabuf *dmabuf; in mbochs_dmabuf_find_by_mode() local
957 list_for_each_entry(dmabuf, &mdev_state->dmabufs, next) in mbochs_dmabuf_find_by_mode()
958 if (mbochs_modes_equal(&dmabuf->mode, mode)) in mbochs_dmabuf_find_by_mode()
959 return dmabuf; in mbochs_dmabuf_find_by_mode()
967 struct mbochs_dmabuf *dmabuf; in mbochs_dmabuf_find_by_id() local
971 list_for_each_entry(dmabuf, &mdev_state->dmabufs, next) in mbochs_dmabuf_find_by_id()
972 if (dmabuf->id == id) in mbochs_dmabuf_find_by_id()
973 return dmabuf; in mbochs_dmabuf_find_by_id()
978 static int mbochs_dmabuf_export(struct mbochs_dmabuf *dmabuf) in mbochs_dmabuf_export() argument
980 struct mdev_state *mdev_state = dmabuf->mdev_state; in mbochs_dmabuf_export()
987 if (!IS_ALIGNED(dmabuf->mode.offset, PAGE_SIZE)) { in mbochs_dmabuf_export()
994 exp_info.size = dmabuf->mode.size; in mbochs_dmabuf_export()
995 exp_info.priv = dmabuf; in mbochs_dmabuf_export()
1004 dmabuf->buf = buf; in mbochs_dmabuf_export()
1005 dev_dbg(dev, "%s: %d\n", __func__, dmabuf->id); in mbochs_dmabuf_export()
1077 struct mbochs_dmabuf *dmabuf; in mbochs_query_gfx_plane() local
1112 dmabuf = mbochs_dmabuf_find_by_mode(mdev_state, &mode); in mbochs_query_gfx_plane()
1113 if (!dmabuf) in mbochs_query_gfx_plane()
1115 if (!dmabuf) { in mbochs_query_gfx_plane()
1120 plane->drm_format = dmabuf->mode.drm_format; in mbochs_query_gfx_plane()
1121 plane->width = dmabuf->mode.width; in mbochs_query_gfx_plane()
1122 plane->height = dmabuf->mode.height; in mbochs_query_gfx_plane()
1123 plane->stride = dmabuf->mode.stride; in mbochs_query_gfx_plane()
1124 plane->size = dmabuf->mode.size; in mbochs_query_gfx_plane()
1125 plane->dmabuf_id = dmabuf->id; in mbochs_query_gfx_plane()
1140 struct mbochs_dmabuf *dmabuf; in mbochs_get_gfx_dmabuf() local
1144 dmabuf = mbochs_dmabuf_find_by_id(mdev_state, id); in mbochs_get_gfx_dmabuf()
1145 if (!dmabuf) { in mbochs_get_gfx_dmabuf()
1150 if (!dmabuf->buf) in mbochs_get_gfx_dmabuf()
1151 mbochs_dmabuf_export(dmabuf); in mbochs_get_gfx_dmabuf()
1155 if (!dmabuf->buf) in mbochs_get_gfx_dmabuf()
1158 return dma_buf_fd(dmabuf->buf, 0); in mbochs_get_gfx_dmabuf()
1285 struct mbochs_dmabuf *dmabuf, *tmp; in mbochs_close_device() local
1289 list_for_each_entry_safe(dmabuf, tmp, &mdev_state->dmabufs, next) { in mbochs_close_device()
1290 list_del(&dmabuf->next); in mbochs_close_device()
1291 if (dmabuf->buf) { in mbochs_close_device()
1293 dmabuf->unlinked = true; in mbochs_close_device()
1295 kfree(dmabuf); in mbochs_close_device()