• Home
  • Raw
  • Download

Lines Matching full:attach

778 static struct sg_table * __map_dma_buf(struct dma_buf_attachment *attach,  in __map_dma_buf()  argument
784 sg_table = attach->dmabuf->ops->map_dma_buf(attach, direction); in __map_dma_buf()
788 if (!dma_buf_attachment_is_dynamic(attach)) { in __map_dma_buf()
789 ret = dma_resv_wait_timeout(attach->dmabuf->resv, in __map_dma_buf()
793 attach->dmabuf->ops->unmap_dma_buf(attach, sg_table, in __map_dma_buf()
844 * - &dma_buf_ops.attach()
869 * @dmabuf: [in] buffer to attach device to.
877 * Optionally this calls &dma_buf_ops.attach to allow device-specific attach
894 struct dma_buf_attachment *attach; in dma_buf_dynamic_attach() local
903 attach = kzalloc(sizeof(*attach), GFP_KERNEL); in dma_buf_dynamic_attach()
904 if (!attach) in dma_buf_dynamic_attach()
907 attach->dev = dev; in dma_buf_dynamic_attach()
908 attach->dmabuf = dmabuf; in dma_buf_dynamic_attach()
910 attach->peer2peer = importer_ops->allow_peer2peer; in dma_buf_dynamic_attach()
911 attach->importer_ops = importer_ops; in dma_buf_dynamic_attach()
912 attach->importer_priv = importer_priv; in dma_buf_dynamic_attach()
914 if (dmabuf->ops->attach) { in dma_buf_dynamic_attach()
915 ret = dmabuf->ops->attach(dmabuf, attach); in dma_buf_dynamic_attach()
920 list_add(&attach->node, &dmabuf->attachments); in dma_buf_dynamic_attach()
927 if (dma_buf_attachment_is_dynamic(attach) != in dma_buf_dynamic_attach()
931 dma_resv_lock(attach->dmabuf->resv, NULL); in dma_buf_dynamic_attach()
932 if (dma_buf_is_dynamic(attach->dmabuf)) { in dma_buf_dynamic_attach()
933 ret = dmabuf->ops->pin(attach); in dma_buf_dynamic_attach()
938 sgt = __map_dma_buf(attach, DMA_BIDIRECTIONAL); in dma_buf_dynamic_attach()
945 dma_resv_unlock(attach->dmabuf->resv); in dma_buf_dynamic_attach()
946 attach->sgt = sgt; in dma_buf_dynamic_attach()
947 attach->dir = DMA_BIDIRECTIONAL; in dma_buf_dynamic_attach()
950 return attach; in dma_buf_dynamic_attach()
953 kfree(attach); in dma_buf_dynamic_attach()
957 if (dma_buf_is_dynamic(attach->dmabuf)) in dma_buf_dynamic_attach()
958 dmabuf->ops->unpin(attach); in dma_buf_dynamic_attach()
961 dma_resv_unlock(attach->dmabuf->resv); in dma_buf_dynamic_attach()
963 dma_buf_detach(dmabuf, attach); in dma_buf_dynamic_attach()
970 * @dmabuf: [in] buffer to attach device to.
983 static void __unmap_dma_buf(struct dma_buf_attachment *attach, in __unmap_dma_buf() argument
990 attach->dmabuf->ops->unmap_dma_buf(attach, sg_table, direction); in __unmap_dma_buf()
996 * @attach: [in] attachment to be detached; is free'd after this call.
1002 void dma_buf_detach(struct dma_buf *dmabuf, struct dma_buf_attachment *attach) in dma_buf_detach() argument
1004 if (WARN_ON(!dmabuf || !attach || dmabuf != attach->dmabuf)) in dma_buf_detach()
1009 if (attach->sgt) { in dma_buf_detach()
1011 __unmap_dma_buf(attach, attach->sgt, attach->dir); in dma_buf_detach()
1013 if (dma_buf_is_dynamic(attach->dmabuf)) in dma_buf_detach()
1014 dmabuf->ops->unpin(attach); in dma_buf_detach()
1016 list_del(&attach->node); in dma_buf_detach()
1021 dmabuf->ops->detach(dmabuf, attach); in dma_buf_detach()
1023 kfree(attach); in dma_buf_detach()
1029 * @attach: [in] attachment which should be pinned
1031 * Only dynamic importers (who set up @attach with dma_buf_dynamic_attach()) may
1041 int dma_buf_pin(struct dma_buf_attachment *attach) in dma_buf_pin() argument
1043 struct dma_buf *dmabuf = attach->dmabuf; in dma_buf_pin()
1046 WARN_ON(!dma_buf_attachment_is_dynamic(attach)); in dma_buf_pin()
1051 ret = dmabuf->ops->pin(attach); in dma_buf_pin()
1059 * @attach: [in] attachment which should be unpinned
1062 * any mapping of @attach again and inform the importer through
1065 void dma_buf_unpin(struct dma_buf_attachment *attach) in dma_buf_unpin() argument
1067 struct dma_buf *dmabuf = attach->dmabuf; in dma_buf_unpin()
1069 WARN_ON(!dma_buf_attachment_is_dynamic(attach)); in dma_buf_unpin()
1074 dmabuf->ops->unpin(attach); in dma_buf_unpin()
1082 * @attach: [in] attachment whose scatterlist is to be returned
1099 struct sg_table *dma_buf_map_attachment(struct dma_buf_attachment *attach, in dma_buf_map_attachment() argument
1107 if (WARN_ON(!attach || !attach->dmabuf)) in dma_buf_map_attachment()
1110 dma_resv_assert_held(attach->dmabuf->resv); in dma_buf_map_attachment()
1112 if (attach->sgt) { in dma_buf_map_attachment()
1117 if (attach->dir != direction && in dma_buf_map_attachment()
1118 attach->dir != DMA_BIDIRECTIONAL) in dma_buf_map_attachment()
1121 return attach->sgt; in dma_buf_map_attachment()
1124 if (dma_buf_is_dynamic(attach->dmabuf)) { in dma_buf_map_attachment()
1126 r = attach->dmabuf->ops->pin(attach); in dma_buf_map_attachment()
1132 sg_table = __map_dma_buf(attach, direction); in dma_buf_map_attachment()
1136 if (IS_ERR(sg_table) && dma_buf_is_dynamic(attach->dmabuf) && in dma_buf_map_attachment()
1138 attach->dmabuf->ops->unpin(attach); in dma_buf_map_attachment()
1140 if (!IS_ERR(sg_table) && attach->dmabuf->ops->cache_sgt_mapping) { in dma_buf_map_attachment()
1141 attach->sgt = sg_table; in dma_buf_map_attachment()
1142 attach->dir = direction; in dma_buf_map_attachment()
1170 * @attach: [in] attachment whose scatterlist is to be returned
1176 dma_buf_map_attachment_unlocked(struct dma_buf_attachment *attach, in dma_buf_map_attachment_unlocked() argument
1183 if (WARN_ON(!attach || !attach->dmabuf)) in dma_buf_map_attachment_unlocked()
1186 dma_resv_lock(attach->dmabuf->resv, NULL); in dma_buf_map_attachment_unlocked()
1187 sg_table = dma_buf_map_attachment(attach, direction); in dma_buf_map_attachment_unlocked()
1188 dma_resv_unlock(attach->dmabuf->resv); in dma_buf_map_attachment_unlocked()
1198 * @attach: [in] attachment to unmap buffer from
1204 void dma_buf_unmap_attachment(struct dma_buf_attachment *attach, in dma_buf_unmap_attachment() argument
1210 if (WARN_ON(!attach || !attach->dmabuf || !sg_table)) in dma_buf_unmap_attachment()
1213 dma_resv_assert_held(attach->dmabuf->resv); in dma_buf_unmap_attachment()
1215 if (attach->sgt == sg_table) in dma_buf_unmap_attachment()
1218 __unmap_dma_buf(attach, sg_table, direction); in dma_buf_unmap_attachment()
1220 if (dma_buf_is_dynamic(attach->dmabuf) && in dma_buf_unmap_attachment()
1222 dma_buf_unpin(attach); in dma_buf_unmap_attachment()
1230 * @attach: [in] attachment to unmap buffer from
1236 void dma_buf_unmap_attachment_unlocked(struct dma_buf_attachment *attach, in dma_buf_unmap_attachment_unlocked() argument
1242 if (WARN_ON(!attach || !attach->dmabuf || !sg_table)) in dma_buf_unmap_attachment_unlocked()
1245 dma_resv_lock(attach->dmabuf->resv, NULL); in dma_buf_unmap_attachment_unlocked()
1246 dma_buf_unmap_attachment(attach, sg_table, direction); in dma_buf_unmap_attachment_unlocked()
1247 dma_resv_unlock(attach->dmabuf->resv); in dma_buf_unmap_attachment_unlocked()
1261 struct dma_buf_attachment *attach; in dma_buf_move_notify() local
1265 list_for_each_entry(attach, &dmabuf->attachments, node) in dma_buf_move_notify()
1266 if (attach->importer_ops) in dma_buf_move_notify()
1267 attach->importer_ops->move_notify(attach); in dma_buf_move_notify()