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()
878 struct mbochs_dmabuf *dmabuf = buf->priv; in mbochs_release_dmabuf() local
879 struct mdev_state *mdev_state = dmabuf->mdev_state; in mbochs_release_dmabuf()
883 dev_dbg(dev, "%s: %d\n", __func__, dmabuf->id); in mbochs_release_dmabuf()
885 for (pg = 0; pg < dmabuf->pagecount; pg++) in mbochs_release_dmabuf()
886 put_page(dmabuf->pages[pg]); in mbochs_release_dmabuf()
889 dmabuf->buf = NULL; in mbochs_release_dmabuf()
890 if (dmabuf->unlinked) in mbochs_release_dmabuf()
891 kfree(dmabuf); in mbochs_release_dmabuf()
905 struct mbochs_dmabuf *dmabuf; in mbochs_dmabuf_alloc() local
910 dmabuf = kzalloc(sizeof(struct mbochs_dmabuf), GFP_KERNEL); in mbochs_dmabuf_alloc()
911 if (!dmabuf) in mbochs_dmabuf_alloc()
914 dmabuf->mode = *mode; in mbochs_dmabuf_alloc()
915 dmabuf->id = mdev_state->next_id++; in mbochs_dmabuf_alloc()
916 dmabuf->pagecount = DIV_ROUND_UP(mode->size, PAGE_SIZE); in mbochs_dmabuf_alloc()
917 dmabuf->pages = kcalloc(dmabuf->pagecount, sizeof(struct page *), in mbochs_dmabuf_alloc()
919 if (!dmabuf->pages) in mbochs_dmabuf_alloc()
922 page_offset = dmabuf->mode.offset >> PAGE_SHIFT; in mbochs_dmabuf_alloc()
923 for (pg = 0; pg < dmabuf->pagecount; pg++) { in mbochs_dmabuf_alloc()
924 dmabuf->pages[pg] = __mbochs_get_page(mdev_state, in mbochs_dmabuf_alloc()
926 if (!dmabuf->pages[pg]) in mbochs_dmabuf_alloc()
930 dmabuf->mdev_state = mdev_state; in mbochs_dmabuf_alloc()
931 list_add(&dmabuf->next, &mdev_state->dmabufs); in mbochs_dmabuf_alloc()
933 mbochs_print_dmabuf(dmabuf, __func__); in mbochs_dmabuf_alloc()
934 return dmabuf; in mbochs_dmabuf_alloc()
938 put_page(dmabuf->pages[--pg]); in mbochs_dmabuf_alloc()
939 kfree(dmabuf->pages); in mbochs_dmabuf_alloc()
941 kfree(dmabuf); in mbochs_dmabuf_alloc()
949 struct mbochs_dmabuf *dmabuf; in mbochs_dmabuf_find_by_mode() local
953 list_for_each_entry(dmabuf, &mdev_state->dmabufs, next) in mbochs_dmabuf_find_by_mode()
954 if (mbochs_modes_equal(&dmabuf->mode, mode)) in mbochs_dmabuf_find_by_mode()
955 return dmabuf; in mbochs_dmabuf_find_by_mode()
963 struct mbochs_dmabuf *dmabuf; in mbochs_dmabuf_find_by_id() local
967 list_for_each_entry(dmabuf, &mdev_state->dmabufs, next) in mbochs_dmabuf_find_by_id()
968 if (dmabuf->id == id) in mbochs_dmabuf_find_by_id()
969 return dmabuf; in mbochs_dmabuf_find_by_id()
974 static int mbochs_dmabuf_export(struct mbochs_dmabuf *dmabuf) in mbochs_dmabuf_export() argument
976 struct mdev_state *mdev_state = dmabuf->mdev_state; in mbochs_dmabuf_export()
983 if (!IS_ALIGNED(dmabuf->mode.offset, PAGE_SIZE)) { in mbochs_dmabuf_export()
990 exp_info.size = dmabuf->mode.size; in mbochs_dmabuf_export()
991 exp_info.priv = dmabuf; in mbochs_dmabuf_export()
1000 dmabuf->buf = buf; in mbochs_dmabuf_export()
1001 dev_dbg(dev, "%s: %d\n", __func__, dmabuf->id); in mbochs_dmabuf_export()
1082 struct mbochs_dmabuf *dmabuf; in mbochs_query_gfx_plane() local
1117 dmabuf = mbochs_dmabuf_find_by_mode(mdev_state, &mode); in mbochs_query_gfx_plane()
1118 if (!dmabuf) in mbochs_query_gfx_plane()
1120 if (!dmabuf) { in mbochs_query_gfx_plane()
1125 plane->drm_format = dmabuf->mode.drm_format; in mbochs_query_gfx_plane()
1126 plane->width = dmabuf->mode.width; in mbochs_query_gfx_plane()
1127 plane->height = dmabuf->mode.height; in mbochs_query_gfx_plane()
1128 plane->stride = dmabuf->mode.stride; in mbochs_query_gfx_plane()
1129 plane->size = dmabuf->mode.size; in mbochs_query_gfx_plane()
1130 plane->dmabuf_id = dmabuf->id; in mbochs_query_gfx_plane()
1147 struct mbochs_dmabuf *dmabuf; in mbochs_get_gfx_dmabuf() local
1151 dmabuf = mbochs_dmabuf_find_by_id(mdev_state, id); in mbochs_get_gfx_dmabuf()
1152 if (!dmabuf) { in mbochs_get_gfx_dmabuf()
1157 if (!dmabuf->buf) in mbochs_get_gfx_dmabuf()
1158 mbochs_dmabuf_export(dmabuf); in mbochs_get_gfx_dmabuf()
1162 if (!dmabuf->buf) in mbochs_get_gfx_dmabuf()
1165 return dma_buf_fd(dmabuf->buf, 0); in mbochs_get_gfx_dmabuf()
1297 struct mbochs_dmabuf *dmabuf, *tmp; in mbochs_close() local
1301 list_for_each_entry_safe(dmabuf, tmp, &mdev_state->dmabufs, next) { in mbochs_close()
1302 list_del(&dmabuf->next); in mbochs_close()
1303 if (dmabuf->buf) { in mbochs_close()
1305 dmabuf->unlinked = true; in mbochs_close()
1307 kfree(dmabuf); in mbochs_close()