Lines Matching refs:dmabuf

817 	struct mbochs_dmabuf *dmabuf = vma->vm_private_data;  in mbochs_dmabuf_vm_fault()  local
819 if (WARN_ON(vmf->pgoff >= dmabuf->pagecount)) in mbochs_dmabuf_vm_fault()
822 vmf->page = dmabuf->pages[vmf->pgoff]; in mbochs_dmabuf_vm_fault()
833 struct mbochs_dmabuf *dmabuf = buf->priv; in mbochs_mmap_dmabuf() local
834 struct device *dev = mdev_dev(dmabuf->mdev_state->mdev); in mbochs_mmap_dmabuf()
836 dev_dbg(dev, "%s: %d\n", __func__, dmabuf->id); in mbochs_mmap_dmabuf()
842 vma->vm_private_data = dmabuf; in mbochs_mmap_dmabuf()
846 static void mbochs_print_dmabuf(struct mbochs_dmabuf *dmabuf, in mbochs_print_dmabuf() argument
849 struct device *dev = mdev_dev(dmabuf->mdev_state->mdev); in mbochs_print_dmabuf()
850 u32 fourcc = dmabuf->mode.drm_format; in mbochs_print_dmabuf()
853 prefix, dmabuf->id, in mbochs_print_dmabuf()
858 dmabuf->mode.width, dmabuf->mode.height, dmabuf->mode.stride, in mbochs_print_dmabuf()
859 dmabuf->mode.offset, dmabuf->mode.size, dmabuf->pagecount); in mbochs_print_dmabuf()
865 struct mbochs_dmabuf *dmabuf = at->dmabuf->priv; in mbochs_map_dmabuf() local
866 struct device *dev = mdev_dev(dmabuf->mdev_state->mdev); in mbochs_map_dmabuf()
869 dev_dbg(dev, "%s: %d\n", __func__, dmabuf->id); in mbochs_map_dmabuf()
874 if (sg_alloc_table_from_pages(sg, dmabuf->pages, dmabuf->pagecount, in mbochs_map_dmabuf()
875 0, dmabuf->mode.size, GFP_KERNEL) < 0) in mbochs_map_dmabuf()
894 struct mbochs_dmabuf *dmabuf = at->dmabuf->priv; in mbochs_unmap_dmabuf() local
895 struct device *dev = mdev_dev(dmabuf->mdev_state->mdev); in mbochs_unmap_dmabuf()
897 dev_dbg(dev, "%s: %d\n", __func__, dmabuf->id); in mbochs_unmap_dmabuf()
906 struct mbochs_dmabuf *dmabuf = buf->priv; in mbochs_release_dmabuf() local
907 struct mdev_state *mdev_state = dmabuf->mdev_state; in mbochs_release_dmabuf()
911 dev_dbg(dev, "%s: %d\n", __func__, dmabuf->id); in mbochs_release_dmabuf()
913 for (pg = 0; pg < dmabuf->pagecount; pg++) in mbochs_release_dmabuf()
914 put_page(dmabuf->pages[pg]); in mbochs_release_dmabuf()
917 dmabuf->buf = NULL; in mbochs_release_dmabuf()
918 if (dmabuf->unlinked) in mbochs_release_dmabuf()
919 kfree(dmabuf); in mbochs_release_dmabuf()
933 struct mbochs_dmabuf *dmabuf; in mbochs_dmabuf_alloc() local
938 dmabuf = kzalloc(sizeof(struct mbochs_dmabuf), GFP_KERNEL); in mbochs_dmabuf_alloc()
939 if (!dmabuf) in mbochs_dmabuf_alloc()
942 dmabuf->mode = *mode; in mbochs_dmabuf_alloc()
943 dmabuf->id = mdev_state->next_id++; in mbochs_dmabuf_alloc()
944 dmabuf->pagecount = DIV_ROUND_UP(mode->size, PAGE_SIZE); in mbochs_dmabuf_alloc()
945 dmabuf->pages = kcalloc(dmabuf->pagecount, sizeof(struct page *), in mbochs_dmabuf_alloc()
947 if (!dmabuf->pages) in mbochs_dmabuf_alloc()
950 page_offset = dmabuf->mode.offset >> PAGE_SHIFT; in mbochs_dmabuf_alloc()
951 for (pg = 0; pg < dmabuf->pagecount; pg++) { in mbochs_dmabuf_alloc()
952 dmabuf->pages[pg] = __mbochs_get_page(mdev_state, in mbochs_dmabuf_alloc()
954 if (!dmabuf->pages[pg]) in mbochs_dmabuf_alloc()
958 dmabuf->mdev_state = mdev_state; in mbochs_dmabuf_alloc()
959 list_add(&dmabuf->next, &mdev_state->dmabufs); in mbochs_dmabuf_alloc()
961 mbochs_print_dmabuf(dmabuf, __func__); in mbochs_dmabuf_alloc()
962 return dmabuf; in mbochs_dmabuf_alloc()
966 put_page(dmabuf->pages[--pg]); in mbochs_dmabuf_alloc()
967 kfree(dmabuf->pages); in mbochs_dmabuf_alloc()
969 kfree(dmabuf); in mbochs_dmabuf_alloc()
977 struct mbochs_dmabuf *dmabuf; in mbochs_dmabuf_find_by_mode() local
981 list_for_each_entry(dmabuf, &mdev_state->dmabufs, next) in mbochs_dmabuf_find_by_mode()
982 if (mbochs_modes_equal(&dmabuf->mode, mode)) in mbochs_dmabuf_find_by_mode()
983 return dmabuf; in mbochs_dmabuf_find_by_mode()
991 struct mbochs_dmabuf *dmabuf; in mbochs_dmabuf_find_by_id() local
995 list_for_each_entry(dmabuf, &mdev_state->dmabufs, next) in mbochs_dmabuf_find_by_id()
996 if (dmabuf->id == id) in mbochs_dmabuf_find_by_id()
997 return dmabuf; in mbochs_dmabuf_find_by_id()
1002 static int mbochs_dmabuf_export(struct mbochs_dmabuf *dmabuf) in mbochs_dmabuf_export() argument
1004 struct mdev_state *mdev_state = dmabuf->mdev_state; in mbochs_dmabuf_export()
1011 if (!IS_ALIGNED(dmabuf->mode.offset, PAGE_SIZE)) { in mbochs_dmabuf_export()
1018 exp_info.size = dmabuf->mode.size; in mbochs_dmabuf_export()
1019 exp_info.priv = dmabuf; in mbochs_dmabuf_export()
1028 dmabuf->buf = buf; in mbochs_dmabuf_export()
1029 dev_dbg(dev, "%s: %d\n", __func__, dmabuf->id); in mbochs_dmabuf_export()
1101 struct mbochs_dmabuf *dmabuf; in mbochs_query_gfx_plane() local
1136 dmabuf = mbochs_dmabuf_find_by_mode(mdev_state, &mode); in mbochs_query_gfx_plane()
1137 if (!dmabuf) in mbochs_query_gfx_plane()
1139 if (!dmabuf) { in mbochs_query_gfx_plane()
1144 plane->drm_format = dmabuf->mode.drm_format; in mbochs_query_gfx_plane()
1145 plane->width = dmabuf->mode.width; in mbochs_query_gfx_plane()
1146 plane->height = dmabuf->mode.height; in mbochs_query_gfx_plane()
1147 plane->stride = dmabuf->mode.stride; in mbochs_query_gfx_plane()
1148 plane->size = dmabuf->mode.size; in mbochs_query_gfx_plane()
1149 plane->dmabuf_id = dmabuf->id; in mbochs_query_gfx_plane()
1164 struct mbochs_dmabuf *dmabuf; in mbochs_get_gfx_dmabuf() local
1168 dmabuf = mbochs_dmabuf_find_by_id(mdev_state, id); in mbochs_get_gfx_dmabuf()
1169 if (!dmabuf) { in mbochs_get_gfx_dmabuf()
1174 if (!dmabuf->buf) in mbochs_get_gfx_dmabuf()
1175 mbochs_dmabuf_export(dmabuf); in mbochs_get_gfx_dmabuf()
1179 if (!dmabuf->buf) in mbochs_get_gfx_dmabuf()
1182 return dma_buf_fd(dmabuf->buf, 0); in mbochs_get_gfx_dmabuf()
1309 struct mbochs_dmabuf *dmabuf, *tmp; in mbochs_close_device() local
1313 list_for_each_entry_safe(dmabuf, tmp, &mdev_state->dmabufs, next) { in mbochs_close_device()
1314 list_del(&dmabuf->next); in mbochs_close_device()
1315 if (dmabuf->buf) { in mbochs_close_device()
1317 dmabuf->unlinked = true; in mbochs_close_device()
1319 kfree(dmabuf); in mbochs_close_device()