On 1/18/26 13:08, Leon Romanovsky wrote:
> From: Leon Romanovsky <[email protected]>
>
> Document a DMA-buf revoke mechanism that allows an exporter to explicitly
> invalidate ("kill") a shared buffer after it has been handed out to
> importers. Once revoked, all further CPU and device access is blocked, and
> importers consistently observe failure.
>
> This requires both importers and exporters to honor the revoke contract.
>
> For importers, this means implementing .invalidate_mappings() and calling
> dma_buf_pin() after the DMA‑buf is attached to verify the exporter’s support
> for revocation.
>
> For exporters, this means implementing the .pin() callback, which checks
> the DMA‑buf attachment for a valid revoke implementation.
>
> Signed-off-by: Leon Romanovsky <[email protected]>
> ---
> include/linux/dma-buf.h | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
> index 1b397635c793..e0bc0b7119f5 100644
> --- a/include/linux/dma-buf.h
> +++ b/include/linux/dma-buf.h
> @@ -579,6 +579,25 @@ static inline bool dma_buf_is_dynamic(struct dma_buf
> *dmabuf)
> return !!dmabuf->ops->pin;
> }
>
> +/**
> + * dma_buf_attachment_is_revoke - check if a DMA-buf importer implements
> + * revoke semantics.
> + * @attach: the DMA-buf attachment to check
> + *
> + * Returns true if DMA-buf importer honors revoke semantics, which is
> + * negotiated with the exporter, by making sure that importer implements
> + * .invalidate_mappings() callback and calls to dma_buf_pin() after
> + * DMA-buf attach.
That wording is to unclear. Something like:
Returns true if the DMA-buf importer can handle invalidating it's mappings at
any time, even after pinning a buffer.
> + */
> +static inline bool
> +dma_buf_attachment_is_revoke(struct dma_buf_attachment *attach)
That's clearly not a good name. But that is already discussed in another thread.
> +{
> + return IS_ENABLED(CONFIG_DMABUF_MOVE_NOTIFY) &&
Oh, we should have renamed that as well. Or maybe it is time to completely
remove that config option.
> + dma_buf_is_dynamic(attach->dmabuf) &&
This is checking exporter and not importer capabilities, please drop.
> + (attach->importer_ops &&
> + attach->importer_ops->invalidate_mappings);
So when invalidate_mappings is implemented we need to be able to call it at any
time. Yeah that sounds like a valid approach to me.
But we need to remove the RDNA callback with the warning then to properly
signal that. And also please document that in the callback kerneldoc.
Regards,
Christian.
> +}
> +
> struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf,
> struct device *dev);
> struct dma_buf_attachment *
>