Commit 4981cdb0 authored by Christian König's avatar Christian König

dma-buf: make move_notify mandatory if importer_ops are provided

This makes the move_notify callback mandatory when the importer_ops are
provided. Since amdgpu is now migrated it doesn't make much sense
anymore to allow this.
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/353995/?series=73646&rev=1
parent bd2275ee
...@@ -677,10 +677,12 @@ dma_buf_dynamic_attach(struct dma_buf *dmabuf, struct device *dev, ...@@ -677,10 +677,12 @@ dma_buf_dynamic_attach(struct dma_buf *dmabuf, struct device *dev,
struct dma_buf_attachment *attach; struct dma_buf_attachment *attach;
int ret; int ret;
/* TODO: make move_notify mandatory if importer_ops are provided. */
if (WARN_ON(!dmabuf || !dev)) if (WARN_ON(!dmabuf || !dev))
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
if (WARN_ON(importer_ops && !importer_ops->move_notify))
return ERR_PTR(-EINVAL);
attach = kzalloc(sizeof(*attach), GFP_KERNEL); attach = kzalloc(sizeof(*attach), GFP_KERNEL);
if (!attach) if (!attach)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -877,8 +879,7 @@ struct sg_table *dma_buf_map_attachment(struct dma_buf_attachment *attach, ...@@ -877,8 +879,7 @@ struct sg_table *dma_buf_map_attachment(struct dma_buf_attachment *attach,
if (dma_buf_is_dynamic(attach->dmabuf)) { if (dma_buf_is_dynamic(attach->dmabuf)) {
dma_resv_assert_held(attach->dmabuf->resv); dma_resv_assert_held(attach->dmabuf->resv);
if (!attach->importer_ops->move_notify || if (!IS_ENABLED(CONFIG_DMABUF_MOVE_NOTIFY)) {
!IS_ENABLED(CONFIG_DMABUF_MOVE_NOTIFY)) {
r = dma_buf_pin(attach); r = dma_buf_pin(attach);
if (r) if (r)
return ERR_PTR(r); return ERR_PTR(r);
...@@ -890,8 +891,7 @@ struct sg_table *dma_buf_map_attachment(struct dma_buf_attachment *attach, ...@@ -890,8 +891,7 @@ struct sg_table *dma_buf_map_attachment(struct dma_buf_attachment *attach,
sg_table = ERR_PTR(-ENOMEM); sg_table = ERR_PTR(-ENOMEM);
if (IS_ERR(sg_table) && dma_buf_is_dynamic(attach->dmabuf) && if (IS_ERR(sg_table) && dma_buf_is_dynamic(attach->dmabuf) &&
(!attach->importer_ops->move_notify || !IS_ENABLED(CONFIG_DMABUF_MOVE_NOTIFY))
!IS_ENABLED(CONFIG_DMABUF_MOVE_NOTIFY)))
dma_buf_unpin(attach); dma_buf_unpin(attach);
if (!IS_ERR(sg_table) && attach->dmabuf->ops->cache_sgt_mapping) { if (!IS_ERR(sg_table) && attach->dmabuf->ops->cache_sgt_mapping) {
...@@ -934,8 +934,7 @@ void dma_buf_unmap_attachment(struct dma_buf_attachment *attach, ...@@ -934,8 +934,7 @@ void dma_buf_unmap_attachment(struct dma_buf_attachment *attach,
attach->dmabuf->ops->unmap_dma_buf(attach, sg_table, direction); attach->dmabuf->ops->unmap_dma_buf(attach, sg_table, direction);
if (dma_buf_is_dynamic(attach->dmabuf) && if (dma_buf_is_dynamic(attach->dmabuf) &&
(!attach->importer_ops->move_notify || !IS_ENABLED(CONFIG_DMABUF_MOVE_NOTIFY))
!IS_ENABLED(CONFIG_DMABUF_MOVE_NOTIFY)))
dma_buf_unpin(attach); dma_buf_unpin(attach);
} }
EXPORT_SYMBOL_GPL(dma_buf_unmap_attachment); EXPORT_SYMBOL_GPL(dma_buf_unmap_attachment);
...@@ -955,7 +954,7 @@ void dma_buf_move_notify(struct dma_buf *dmabuf) ...@@ -955,7 +954,7 @@ void dma_buf_move_notify(struct dma_buf *dmabuf)
dma_resv_assert_held(dmabuf->resv); dma_resv_assert_held(dmabuf->resv);
list_for_each_entry(attach, &dmabuf->attachments, node) list_for_each_entry(attach, &dmabuf->attachments, node)
if (attach->importer_ops && attach->importer_ops->move_notify) if (attach->importer_ops)
attach->importer_ops->move_notify(attach); attach->importer_ops->move_notify(attach);
} }
EXPORT_SYMBOL_GPL(dma_buf_move_notify); EXPORT_SYMBOL_GPL(dma_buf_move_notify);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment