From nobody Sun Feb 8 18:32:37 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF9F0481A99; Wed, 21 Jan 2026 12:59:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769000376; cv=none; b=hN+/GQ7ovpA0711B5rw6SgXysYp68KvlD2x9p1Y+jcbowHknnUwvR4pCRzKxTrWZODrljU0eRXkf7XnhNxzWnoqVrkY5PHGoQMAyBrSOmAY+6l3F/Hh2/YgflIkOWrwUjMd6tmtY7Vza+tzjbWK4wKREbA4gppj/pdNk1KBvjbU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769000376; c=relaxed/simple; bh=OGYKw47EaUqM/lWyK5JqNggda0T3gP3mV7IvIl6ZhwE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=surtSK05Dz20YludUKbVjk8++1T6SPQtV48Hl4vIpQNLVoRZIl48fXanjdeRh3TLYHJGsF/+YdYhWp4JwFUmv2aNApH4W6tXP2dvjEC1ToBFKvbYrya0gJOHa5eQzDentfFT5Q+M6l9LUOLSGgk3BAs+1DG8cnKjSsEBHN+GS/c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BGjZ1JOP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BGjZ1JOP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3DFAC116D0; Wed, 21 Jan 2026 12:59:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769000375; bh=OGYKw47EaUqM/lWyK5JqNggda0T3gP3mV7IvIl6ZhwE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BGjZ1JOPPaa9dH3TdPvpuc7F2tx7w3NsHYC5BuTxjEkAw+r5Lm0OxI9fU7M8P68MN cV7Cr5guXE1OuvX7sCAt0nCl07gdSJSUQZqVVaQocMSBLUiPpxZWe+btb6Hh06kDuD eNbId410/V7XM43xHH/mtFX6FcQSNA4UTF+Z0W5dTVNUTAk+RBV0JPNvbMJVZ7FjoF WiJc7Mxp++ndGzbEeMUOfiXBs4PKfe15nL4koGIilbVicq/QCazTzFSPNnTkht0muf C3cu0DHfPJUWCfnkxmq6kUpAT2/QmpQg675gFz4G590yjpDQt+4QeDdOSrStjqMyH0 pQjykChYncv2w== From: Leon Romanovsky To: Sumit Semwal , =?utf-8?q?Christian_K=C3=B6nig?= , Alex Deucher , David Airlie , Simona Vetter , Gerd Hoffmann , Dmitry Osipenko , Gurchetan Singh , Chia-I Wu , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Lucas De Marchi , =?utf-8?q?Thomas_Hellstr=C3=B6m?= , Rodrigo Vivi , Jason Gunthorpe , Leon Romanovsky , Kevin Tian , Joerg Roedel , Will Deacon , Robin Murphy , Felix Kuehling , Alex Williamson , Ankit Agrawal , Vivek Kasireddy Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, virtualization@lists.linux.dev, intel-xe@lists.freedesktop.org, linux-rdma@vger.kernel.org, iommu@lists.linux.dev, kvm@vger.kernel.org Subject: [PATCH v4 1/8] dma-buf: Rename .move_notify() callback to a clearer identifier Date: Wed, 21 Jan 2026 14:59:09 +0200 Message-ID: <20260121-dmabuf-revoke-v4-1-d311cbc8633d@nvidia.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260121-dmabuf-revoke-v4-0-d311cbc8633d@nvidia.com> References: <20260121-dmabuf-revoke-v4-0-d311cbc8633d@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.15-dev-a6db3 Content-Transfer-Encoding: quoted-printable From: Leon Romanovsky Rename the .move_notify() callback to .invalidate_mappings() to make its purpose explicit and highlight that it is responsible for invalidating existing mappings. Suggested-by: Christian K=C3=B6nig Reviewed-by: Christian K=C3=B6nig Signed-off-by: Leon Romanovsky --- drivers/dma-buf/dma-buf.c | 6 +++--- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 4 ++-- drivers/gpu/drm/virtio/virtgpu_prime.c | 2 +- drivers/gpu/drm/xe/tests/xe_dma_buf.c | 6 +++--- drivers/gpu/drm/xe/xe_dma_buf.c | 2 +- drivers/infiniband/core/umem_dmabuf.c | 4 ++-- drivers/infiniband/hw/mlx5/mr.c | 2 +- drivers/iommu/iommufd/pages.c | 2 +- include/linux/dma-buf.h | 6 +++--- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index edaa9e4ee4ae..59cc647bf40e 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -948,7 +948,7 @@ dma_buf_dynamic_attach(struct dma_buf *dmabuf, struct d= evice *dev, if (WARN_ON(!dmabuf || !dev)) return ERR_PTR(-EINVAL); =20 - if (WARN_ON(importer_ops && !importer_ops->move_notify)) + if (WARN_ON(importer_ops && !importer_ops->invalidate_mappings)) return ERR_PTR(-EINVAL); =20 attach =3D kzalloc(sizeof(*attach), GFP_KERNEL); @@ -1055,7 +1055,7 @@ EXPORT_SYMBOL_NS_GPL(dma_buf_pin, "DMA_BUF"); * * This unpins a buffer pinned by dma_buf_pin() and allows the exporter to= move * any mapping of @attach again and inform the importer through - * &dma_buf_attach_ops.move_notify. + * &dma_buf_attach_ops.invalidate_mappings. */ void dma_buf_unpin(struct dma_buf_attachment *attach) { @@ -1262,7 +1262,7 @@ void dma_buf_move_notify(struct dma_buf *dmabuf) =20 list_for_each_entry(attach, &dmabuf->attachments, node) if (attach->importer_ops) - attach->importer_ops->move_notify(attach); + attach->importer_ops->invalidate_mappings(attach); } EXPORT_SYMBOL_NS_GPL(dma_buf_move_notify, "DMA_BUF"); =20 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c b/drivers/gpu/drm/= amd/amdgpu/amdgpu_dma_buf.c index e22cfa7c6d32..863454148b28 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c @@ -450,7 +450,7 @@ amdgpu_dma_buf_create_obj(struct drm_device *dev, struc= t dma_buf *dma_buf) } =20 /** - * amdgpu_dma_buf_move_notify - &attach.move_notify implementation + * amdgpu_dma_buf_move_notify - &attach.invalidate_mappings implementation * * @attach: the DMA-buf attachment * @@ -521,7 +521,7 @@ amdgpu_dma_buf_move_notify(struct dma_buf_attachment *a= ttach) =20 static const struct dma_buf_attach_ops amdgpu_dma_buf_attach_ops =3D { .allow_peer2peer =3D true, - .move_notify =3D amdgpu_dma_buf_move_notify + .invalidate_mappings =3D amdgpu_dma_buf_move_notify }; =20 /** diff --git a/drivers/gpu/drm/virtio/virtgpu_prime.c b/drivers/gpu/drm/virti= o/virtgpu_prime.c index ce49282198cb..19c78dd2ca77 100644 --- a/drivers/gpu/drm/virtio/virtgpu_prime.c +++ b/drivers/gpu/drm/virtio/virtgpu_prime.c @@ -288,7 +288,7 @@ static void virtgpu_dma_buf_move_notify(struct dma_buf_= attachment *attach) =20 static const struct dma_buf_attach_ops virtgpu_dma_buf_attach_ops =3D { .allow_peer2peer =3D true, - .move_notify =3D virtgpu_dma_buf_move_notify + .invalidate_mappings =3D virtgpu_dma_buf_move_notify }; =20 struct drm_gem_object *virtgpu_gem_prime_import(struct drm_device *dev, diff --git a/drivers/gpu/drm/xe/tests/xe_dma_buf.c b/drivers/gpu/drm/xe/tes= ts/xe_dma_buf.c index 5df98de5ba3c..1f2cca5c2f81 100644 --- a/drivers/gpu/drm/xe/tests/xe_dma_buf.c +++ b/drivers/gpu/drm/xe/tests/xe_dma_buf.c @@ -23,7 +23,7 @@ static bool p2p_enabled(struct dma_buf_test_params *param= s) static bool is_dynamic(struct dma_buf_test_params *params) { return IS_ENABLED(CONFIG_DMABUF_MOVE_NOTIFY) && params->attach_ops && - params->attach_ops->move_notify; + params->attach_ops->invalidate_mappings; } =20 static void check_residency(struct kunit *test, struct xe_bo *exported, @@ -60,7 +60,7 @@ static void check_residency(struct kunit *test, struct xe= _bo *exported, =20 /* * Evict exporter. Evicting the exported bo will - * evict also the imported bo through the move_notify() functionality if + * evict also the imported bo through the invalidate_mappings() functiona= lity if * importer is on a different device. If they're on the same device, * the exporter and the importer should be the same bo. */ @@ -198,7 +198,7 @@ static void xe_test_dmabuf_import_same_driver(struct xe= _device *xe) =20 static const struct dma_buf_attach_ops nop2p_attach_ops =3D { .allow_peer2peer =3D false, - .move_notify =3D xe_dma_buf_move_notify + .invalidate_mappings =3D xe_dma_buf_move_notify }; =20 /* diff --git a/drivers/gpu/drm/xe/xe_dma_buf.c b/drivers/gpu/drm/xe/xe_dma_bu= f.c index 7c74a31d4486..1b9cd043e517 100644 --- a/drivers/gpu/drm/xe/xe_dma_buf.c +++ b/drivers/gpu/drm/xe/xe_dma_buf.c @@ -287,7 +287,7 @@ static void xe_dma_buf_move_notify(struct dma_buf_attac= hment *attach) =20 static const struct dma_buf_attach_ops xe_dma_buf_attach_ops =3D { .allow_peer2peer =3D true, - .move_notify =3D xe_dma_buf_move_notify + .invalidate_mappings =3D xe_dma_buf_move_notify }; =20 #if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST) diff --git a/drivers/infiniband/core/umem_dmabuf.c b/drivers/infiniband/cor= e/umem_dmabuf.c index 0ec2e4120cc9..d77a739cfe7a 100644 --- a/drivers/infiniband/core/umem_dmabuf.c +++ b/drivers/infiniband/core/umem_dmabuf.c @@ -129,7 +129,7 @@ ib_umem_dmabuf_get_with_dma_device(struct ib_device *de= vice, if (check_add_overflow(offset, (unsigned long)size, &end)) return ret; =20 - if (unlikely(!ops || !ops->move_notify)) + if (unlikely(!ops || !ops->invalidate_mappings)) return ret; =20 dmabuf =3D dma_buf_get(fd); @@ -195,7 +195,7 @@ ib_umem_dmabuf_unsupported_move_notify(struct dma_buf_a= ttachment *attach) =20 static struct dma_buf_attach_ops ib_umem_dmabuf_attach_pinned_ops =3D { .allow_peer2peer =3D true, - .move_notify =3D ib_umem_dmabuf_unsupported_move_notify, + .invalidate_mappings =3D ib_umem_dmabuf_unsupported_move_notify, }; =20 struct ib_umem_dmabuf * diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/m= r.c index 325fa04cbe8a..97099d3b1688 100644 --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c @@ -1620,7 +1620,7 @@ static void mlx5_ib_dmabuf_invalidate_cb(struct dma_b= uf_attachment *attach) =20 static struct dma_buf_attach_ops mlx5_ib_dmabuf_attach_ops =3D { .allow_peer2peer =3D 1, - .move_notify =3D mlx5_ib_dmabuf_invalidate_cb, + .invalidate_mappings =3D mlx5_ib_dmabuf_invalidate_cb, }; =20 static struct ib_mr * diff --git a/drivers/iommu/iommufd/pages.c b/drivers/iommu/iommufd/pages.c index dbe51ecb9a20..76f900fa1687 100644 --- a/drivers/iommu/iommufd/pages.c +++ b/drivers/iommu/iommufd/pages.c @@ -1451,7 +1451,7 @@ static void iopt_revoke_notify(struct dma_buf_attachm= ent *attach) =20 static struct dma_buf_attach_ops iopt_dmabuf_attach_revoke_ops =3D { .allow_peer2peer =3D true, - .move_notify =3D iopt_revoke_notify, + .invalidate_mappings =3D iopt_revoke_notify, }; =20 /* diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h index 0bc492090237..1b397635c793 100644 --- a/include/linux/dma-buf.h +++ b/include/linux/dma-buf.h @@ -407,7 +407,7 @@ struct dma_buf { * through the device. * * - Dynamic importers should set fences for any access that they can't - * disable immediately from their &dma_buf_attach_ops.move_notify + * disable immediately from their &dma_buf_attach_ops.invalidate_mappin= gs * callback. * * IMPORTANT: @@ -458,7 +458,7 @@ struct dma_buf_attach_ops { bool allow_peer2peer; =20 /** - * @move_notify: [optional] notification that the DMA-buf is moving + * @invalidate_mappings: [optional] notification that the DMA-buf is movi= ng * * If this callback is provided the framework can avoid pinning the * backing store while mappings exists. @@ -475,7 +475,7 @@ struct dma_buf_attach_ops { * New mappings can be created after this callback returns, and will * point to the new location of the DMA-buf. */ - void (*move_notify)(struct dma_buf_attachment *attach); + void (*invalidate_mappings)(struct dma_buf_attachment *attach); }; =20 /** --=20 2.52.0 From nobody Sun Feb 8 18:32:37 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8A0748A2AE; Wed, 21 Jan 2026 12:59:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769000380; cv=none; b=FwUSOGfwKKohVq64KVFmOGE6Q8RSr4oCbqSXEewuKBDeTJk6X85xbEBnNTvcq7YE/ly5yQ1HHpW7oBUiyUrN2Dfiq3fYCBkqSZHRHMIIyf+qcCWyWIOJzg+pnWhiBsvoDw+lcUO3vG8hVhZCvwm3iVMV4apAAIIIJP3Pbhu3sOE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769000380; c=relaxed/simple; bh=6Ho+uRDyXSgxTDE+1RTrMPsGvWWn+f2uKPQhY0bRRoU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=N+TJWbIfAXCwxUNOpiao9lF4rnjkZpcMShmdfTvrjKjEu+bE7qAKlgVe3lrUpvw9AXnGZ+bzrPCTZAyvyeNYht9Ioyv8q2rZK/k4gDzc1MavBRywJzETQwi/CzhSjsa221QLGLzTLJkB2Bks7/2bd3q4hr+uU2oovCqEMfeLiz4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uP7N2HLH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uP7N2HLH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C613BC116D0; Wed, 21 Jan 2026 12:59:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769000379; bh=6Ho+uRDyXSgxTDE+1RTrMPsGvWWn+f2uKPQhY0bRRoU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uP7N2HLH9HGFbRCEtRnar6HBTQ5giBQXH3s7VAilbpNceFpmAJHTlmemRXNzJmgEv 1MvZGTnhXYQIUfLHwj8Ul71/7FAgNrnqfcK92TgxTe0aWuEebGcfUKLxd9rVsggsHv sPCURz+nfBhDAXHSDXjh1fJYQMd4j7/aUUgNwVexcs2EBhsLR9URsuVtQZEtogFJ42 5ckbhCNU+RU/JEQJZF2xVcs7nqt9bKjA6CRweQldIiVQlUpl4m/10COBwBqAYYxUpx PWfpraQoJmSx1WluigzBSHVU+q5bvTeX2uxZs+vJ+Bipj/he54FrSfF6Gq8KudIbZy M6YFuOJtKiYeQ== From: Leon Romanovsky To: Sumit Semwal , =?utf-8?q?Christian_K=C3=B6nig?= , Alex Deucher , David Airlie , Simona Vetter , Gerd Hoffmann , Dmitry Osipenko , Gurchetan Singh , Chia-I Wu , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Lucas De Marchi , =?utf-8?q?Thomas_Hellstr=C3=B6m?= , Rodrigo Vivi , Jason Gunthorpe , Leon Romanovsky , Kevin Tian , Joerg Roedel , Will Deacon , Robin Murphy , Felix Kuehling , Alex Williamson , Ankit Agrawal , Vivek Kasireddy Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, virtualization@lists.linux.dev, intel-xe@lists.freedesktop.org, linux-rdma@vger.kernel.org, iommu@lists.linux.dev, kvm@vger.kernel.org Subject: [PATCH v4 2/8] dma-buf: Rename dma_buf_move_notify() to dma_buf_invalidate_mappings() Date: Wed, 21 Jan 2026 14:59:10 +0200 Message-ID: <20260121-dmabuf-revoke-v4-2-d311cbc8633d@nvidia.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260121-dmabuf-revoke-v4-0-d311cbc8633d@nvidia.com> References: <20260121-dmabuf-revoke-v4-0-d311cbc8633d@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.15-dev-a6db3 Content-Transfer-Encoding: quoted-printable From: Leon Romanovsky Along with renaming the .move_notify() callback, rename the corresponding dma-buf core function. This makes the expected behavior clear to exporters calling this function. Signed-off-by: Leon Romanovsky --- drivers/dma-buf/dma-buf.c | 8 ++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 +- drivers/gpu/drm/xe/xe_bo.c | 2 +- drivers/iommu/iommufd/selftest.c | 2 +- drivers/vfio/pci/vfio_pci_dmabuf.c | 4 ++-- include/linux/dma-buf.h | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index 59cc647bf40e..e12db540c413 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -912,7 +912,7 @@ dma_buf_pin_on_map(struct dma_buf_attachment *attach) * 3. Exporters must hold the dma-buf reservation lock when calling these * functions: * - * - dma_buf_move_notify() + * - dma_buf_invalidate_mappings() */ =20 /** @@ -1247,14 +1247,14 @@ void dma_buf_unmap_attachment_unlocked(struct dma_b= uf_attachment *attach, EXPORT_SYMBOL_NS_GPL(dma_buf_unmap_attachment_unlocked, "DMA_BUF"); =20 /** - * dma_buf_move_notify - notify attachments that DMA-buf is moving + * dma_buf_invalidate_mappings - notify attachments that DMA-buf is moving * * @dmabuf: [in] buffer which is moving * * Informs all attachments that they need to destroy and recreate all their * mappings. */ -void dma_buf_move_notify(struct dma_buf *dmabuf) +void dma_buf_invalidate_mappings(struct dma_buf *dmabuf) { struct dma_buf_attachment *attach; =20 @@ -1264,7 +1264,7 @@ void dma_buf_move_notify(struct dma_buf *dmabuf) if (attach->importer_ops) attach->importer_ops->invalidate_mappings(attach); } -EXPORT_SYMBOL_NS_GPL(dma_buf_move_notify, "DMA_BUF"); +EXPORT_SYMBOL_NS_GPL(dma_buf_invalidate_mappings, "DMA_BUF"); =20 /** * DOC: cpu access diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/a= md/amdgpu/amdgpu_object.c index e08f58de4b17..f73dc99d1887 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -1270,7 +1270,7 @@ void amdgpu_bo_move_notify(struct ttm_buffer_object *= bo, =20 if (abo->tbo.base.dma_buf && !drm_gem_is_imported(&abo->tbo.base) && old_mem && old_mem->mem_type !=3D TTM_PL_SYSTEM) - dma_buf_move_notify(abo->tbo.base.dma_buf); + dma_buf_invalidate_mappings(abo->tbo.base.dma_buf); =20 /* move_notify is called before move happens */ trace_amdgpu_bo_move(abo, new_mem ? new_mem->mem_type : -1, diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c index bf4ee976b680..7d02cd9a8501 100644 --- a/drivers/gpu/drm/xe/xe_bo.c +++ b/drivers/gpu/drm/xe/xe_bo.c @@ -819,7 +819,7 @@ static int xe_bo_move_notify(struct xe_bo *bo, =20 /* Don't call move_notify() for imported dma-bufs. */ if (ttm_bo->base.dma_buf && !ttm_bo->base.import_attach) - dma_buf_move_notify(ttm_bo->base.dma_buf); + dma_buf_invalidate_mappings(ttm_bo->base.dma_buf); =20 /* * TTM has already nuked the mmap for us (see ttm_bo_unmap_virtual), diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selft= est.c index 550ff36dec3a..f60cbd5328cc 100644 --- a/drivers/iommu/iommufd/selftest.c +++ b/drivers/iommu/iommufd/selftest.c @@ -2081,7 +2081,7 @@ static int iommufd_test_dmabuf_revoke(struct iommufd_= ucmd *ucmd, int fd, priv =3D dmabuf->priv; dma_resv_lock(dmabuf->resv, NULL); priv->revoked =3D revoked; - dma_buf_move_notify(dmabuf); + dma_buf_invalidate_mappings(dmabuf); dma_resv_unlock(dmabuf->resv); =20 err_put: diff --git a/drivers/vfio/pci/vfio_pci_dmabuf.c b/drivers/vfio/pci/vfio_pci= _dmabuf.c index d4d0f7d08c53..362e3d149817 100644 --- a/drivers/vfio/pci/vfio_pci_dmabuf.c +++ b/drivers/vfio/pci/vfio_pci_dmabuf.c @@ -320,7 +320,7 @@ void vfio_pci_dma_buf_move(struct vfio_pci_core_device = *vdev, bool revoked) if (priv->revoked !=3D revoked) { dma_resv_lock(priv->dmabuf->resv, NULL); priv->revoked =3D revoked; - dma_buf_move_notify(priv->dmabuf); + dma_buf_invalidate_mappings(priv->dmabuf); dma_resv_unlock(priv->dmabuf->resv); } fput(priv->dmabuf->file); @@ -341,7 +341,7 @@ void vfio_pci_dma_buf_cleanup(struct vfio_pci_core_devi= ce *vdev) list_del_init(&priv->dmabufs_elm); priv->vdev =3D NULL; priv->revoked =3D true; - dma_buf_move_notify(priv->dmabuf); + dma_buf_invalidate_mappings(priv->dmabuf); dma_resv_unlock(priv->dmabuf->resv); vfio_device_put_registration(&vdev->vdev); fput(priv->dmabuf->file); diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h index 1b397635c793..d5c3ce2b3aa4 100644 --- a/include/linux/dma-buf.h +++ b/include/linux/dma-buf.h @@ -600,7 +600,7 @@ struct sg_table *dma_buf_map_attachment(struct dma_buf_= attachment *, enum dma_data_direction); void dma_buf_unmap_attachment(struct dma_buf_attachment *, struct sg_table= *, enum dma_data_direction); -void dma_buf_move_notify(struct dma_buf *dma_buf); +void dma_buf_invalidate_mappings(struct dma_buf *dma_buf); int dma_buf_begin_cpu_access(struct dma_buf *dma_buf, enum dma_data_direction dir); int dma_buf_end_cpu_access(struct dma_buf *dma_buf, --=20 2.52.0 From nobody Sun Feb 8 18:32:37 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE918283686; Wed, 21 Jan 2026 12:59:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769000387; cv=none; b=YXWWdwwpTSH705Fwy4/qbCfPVD3GdkJnXjV9dTbsi37L67QzLFe+myZLqR5sVM3mVN1degLr1NSxi242CcW8tLABWH2b/OyHgiKOjhkFGS/f4xyv1pJap+y8UMX+lPK3nmFE3XVSlBT889DYWhlsugNn1BVoRT1ry8sFFy6ouoI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769000387; c=relaxed/simple; bh=d1hns7ecqedYSGdp3dVh7hrh3lxHsTLnWUd2PLo1qM4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kouoE+rzaBUa5FzNvV4H5HNnmc2SaAgMFU1hKUDTVzT+pS/uXn+8KL7GHcZFHWY+XNq+gJgiys9p8bvVEH8tzhZ4XizAaB6zyJV8mtLFTUGBY1J1jE3RbaTCXf5KyFHXZ6zShUWSUO3BvUw/fxjXQkkeMbIX5okWae5RsxDtNsc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=emyyQJnk; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="emyyQJnk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC24EC19424; Wed, 21 Jan 2026 12:59:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769000386; bh=d1hns7ecqedYSGdp3dVh7hrh3lxHsTLnWUd2PLo1qM4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=emyyQJnkfNQ4Iwa2yve4soUs5i8e75BYDU+9czokUdgQocd78LcCkmzGh0hC1VmaY EjhJCxVuMqImcMWBGOqygLLvujoID0mcgHon4IjWViWIurQuAUSdcXN+EhJJsRPu9R gJuM0VBxy64kjYP6RxYKPdixXTw+T1/fXb+hF5PtZ4J7VoM1gUvWG4Fz3EuU3cv1Bj WwksBPm0LCCU+eL+/kbwf4ugTZvRGWw3Pa5GUYRl32HJUrTRyly53nlB5DwY1ykPuM Scenmm+ftdQCDOUjZsCj0HZUYX181oA+Uu/u6+EnVv7ncDYYlDy3oyxsoGkE0M+laI bn703toKud0Zw== From: Leon Romanovsky To: Sumit Semwal , =?utf-8?q?Christian_K=C3=B6nig?= , Alex Deucher , David Airlie , Simona Vetter , Gerd Hoffmann , Dmitry Osipenko , Gurchetan Singh , Chia-I Wu , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Lucas De Marchi , =?utf-8?q?Thomas_Hellstr=C3=B6m?= , Rodrigo Vivi , Jason Gunthorpe , Leon Romanovsky , Kevin Tian , Joerg Roedel , Will Deacon , Robin Murphy , Felix Kuehling , Alex Williamson , Ankit Agrawal , Vivek Kasireddy Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, virtualization@lists.linux.dev, intel-xe@lists.freedesktop.org, linux-rdma@vger.kernel.org, iommu@lists.linux.dev, kvm@vger.kernel.org Subject: [PATCH v4 3/8] dma-buf: Always build with DMABUF_MOVE_NOTIFY Date: Wed, 21 Jan 2026 14:59:11 +0200 Message-ID: <20260121-dmabuf-revoke-v4-3-d311cbc8633d@nvidia.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260121-dmabuf-revoke-v4-0-d311cbc8633d@nvidia.com> References: <20260121-dmabuf-revoke-v4-0-d311cbc8633d@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.15-dev-a6db3 Content-Transfer-Encoding: quoted-printable From: Leon Romanovsky DMABUF_MOVE_NOTIFY was introduced in 2018 and has been marked as experimental and disabled by default ever since. Six years later, all new importers implement this callback. It is therefore reasonable to drop CONFIG_DMABUF_MOVE_NOTIFY and always build DMABUF with support for it enabled. Suggested-by: Christian K=C3=B6nig Signed-off-by: Leon Romanovsky --- drivers/dma-buf/Kconfig | 12 ------------ drivers/dma-buf/dma-buf.c | 3 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 10 +++------- drivers/gpu/drm/amd/amdkfd/Kconfig | 2 +- drivers/gpu/drm/xe/tests/xe_dma_buf.c | 3 +-- drivers/gpu/drm/xe/xe_dma_buf.c | 12 ++++-------- 6 files changed, 10 insertions(+), 32 deletions(-) diff --git a/drivers/dma-buf/Kconfig b/drivers/dma-buf/Kconfig index b46eb8a552d7..84d5e9b24e20 100644 --- a/drivers/dma-buf/Kconfig +++ b/drivers/dma-buf/Kconfig @@ -40,18 +40,6 @@ config UDMABUF A driver to let userspace turn memfd regions into dma-bufs. Qemu can use this to create host dmabufs for guest framebuffers. =20 -config DMABUF_MOVE_NOTIFY - bool "Move notify between drivers (EXPERIMENTAL)" - default n - depends on DMA_SHARED_BUFFER - help - Don't pin buffers if the dynamic DMA-buf interface is available on - both the exporter as well as the importer. This fixes a security - problem where userspace is able to pin unrestricted amounts of memory - through DMA-buf. - This is marked experimental because we don't yet have a consistent - execution context and memory management between drivers. - config DMABUF_DEBUG bool "DMA-BUF debug checks" depends on DMA_SHARED_BUFFER diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index e12db540c413..cd68c1c0bfd7 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -847,8 +847,7 @@ static bool dma_buf_pin_on_map(struct dma_buf_attachment *attach) { return attach->dmabuf->ops->pin && - (!dma_buf_attachment_is_dynamic(attach) || - !IS_ENABLED(CONFIG_DMABUF_MOVE_NOTIFY)); + !dma_buf_attachment_is_dynamic(attach); } =20 /** diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c b/drivers/gpu/drm/= amd/amdgpu/amdgpu_dma_buf.c index 863454148b28..349215549e8f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c @@ -145,13 +145,9 @@ static int amdgpu_dma_buf_pin(struct dma_buf_attachmen= t *attach) * notifiers are disabled, only allow pinning in VRAM when move * notiers are enabled. */ - if (!IS_ENABLED(CONFIG_DMABUF_MOVE_NOTIFY)) { - domains &=3D ~AMDGPU_GEM_DOMAIN_VRAM; - } else { - list_for_each_entry(attach, &dmabuf->attachments, node) - if (!attach->peer2peer) - domains &=3D ~AMDGPU_GEM_DOMAIN_VRAM; - } + list_for_each_entry(attach, &dmabuf->attachments, node) + if (!attach->peer2peer) + domains &=3D ~AMDGPU_GEM_DOMAIN_VRAM; =20 if (domains & AMDGPU_GEM_DOMAIN_VRAM) bo->flags |=3D AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED; diff --git a/drivers/gpu/drm/amd/amdkfd/Kconfig b/drivers/gpu/drm/amd/amdkf= d/Kconfig index 16e12c9913f9..a5d7467c2f34 100644 --- a/drivers/gpu/drm/amd/amdkfd/Kconfig +++ b/drivers/gpu/drm/amd/amdkfd/Kconfig @@ -27,7 +27,7 @@ config HSA_AMD_SVM =20 config HSA_AMD_P2P bool "HSA kernel driver support for peer-to-peer for AMD GPU devices" - depends on HSA_AMD && PCI_P2PDMA && DMABUF_MOVE_NOTIFY + depends on HSA_AMD && PCI_P2PDMA help Enable peer-to-peer (P2P) communication between AMD GPUs over the PCIe bus. This can improve performance of multi-GPU compute diff --git a/drivers/gpu/drm/xe/tests/xe_dma_buf.c b/drivers/gpu/drm/xe/tes= ts/xe_dma_buf.c index 1f2cca5c2f81..c107687ef3c0 100644 --- a/drivers/gpu/drm/xe/tests/xe_dma_buf.c +++ b/drivers/gpu/drm/xe/tests/xe_dma_buf.c @@ -22,8 +22,7 @@ static bool p2p_enabled(struct dma_buf_test_params *param= s) =20 static bool is_dynamic(struct dma_buf_test_params *params) { - return IS_ENABLED(CONFIG_DMABUF_MOVE_NOTIFY) && params->attach_ops && - params->attach_ops->invalidate_mappings; + return params->attach_ops && params->attach_ops->invalidate_mappings; } =20 static void check_residency(struct kunit *test, struct xe_bo *exported, diff --git a/drivers/gpu/drm/xe/xe_dma_buf.c b/drivers/gpu/drm/xe/xe_dma_bu= f.c index 1b9cd043e517..ea370cd373e9 100644 --- a/drivers/gpu/drm/xe/xe_dma_buf.c +++ b/drivers/gpu/drm/xe/xe_dma_buf.c @@ -56,14 +56,10 @@ static int xe_dma_buf_pin(struct dma_buf_attachment *at= tach) bool allow_vram =3D true; int ret; =20 - if (!IS_ENABLED(CONFIG_DMABUF_MOVE_NOTIFY)) { - allow_vram =3D false; - } else { - list_for_each_entry(attach, &dmabuf->attachments, node) { - if (!attach->peer2peer) { - allow_vram =3D false; - break; - } + list_for_each_entry(attach, &dmabuf->attachments, node) { + if (!attach->peer2peer) { + allow_vram =3D false; + break; } } =20 --=20 2.52.0 From nobody Sun Feb 8 18:32:37 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C32C48B381; Wed, 21 Jan 2026 12:59:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769000383; cv=none; b=G1aTBZ0WDX0XaOkYuQo8qGWRk6ztyV8mBx0kv2V1Cpxi6Q69SPT6M5qlM/TPWWRYc7zj/k6Lg5y5MmdhMpZ0RE3lPPkcorWAVR3gBg5oBqkmCCMI6PnOB/TMlUSm4/05CQPfpNhYisxwKuMk9luqNhKR/qZNMD9l3D5kk2As8eY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769000383; c=relaxed/simple; bh=Hg+PCl94D7mEbx1+9P2eXzfMtxX5wkTvpHZQYOw5sNQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=D/GtrA3Q+trC9hZ+O0sSksOG+ucyKTF2GP9hxLksmdeeX6ooDqAv4AqCwtRSbLI5T+9b4yREsb7UiGlbz+kZDVXUk+dU5a4exQ2FrQfOCycVoNvmhS3Yk5iI765lgPJpCWp0Vg2gYMt0yADHkc3GXxlgDV3LAjpRW7KRMH09v64= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HM6a6IQ+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HM6a6IQ+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82582C19421; Wed, 21 Jan 2026 12:59:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769000383; bh=Hg+PCl94D7mEbx1+9P2eXzfMtxX5wkTvpHZQYOw5sNQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HM6a6IQ+AhLBuJDmA/lFkqxyAunt3g5aK7v9YdUfBqREs640dtG6nrOD1zNjqm8Gp vEP1J2Fi+gqQ3tLIzy0Xn03t+xBB/8GnbD+UuXicPNLk6gkBROjWBSbX0dEJ7kYHTZ K/nl+CneSxYhZc9dRZktkvw8RAUzHTlspeexxTjQjCdPY8xZSOJ3P9rTA0KCqYdE9c bGdNOtzPaUem3EI7LKuYIACEjclww7RCIsCsjGOqDW8ZxYnK29Z9KG9crosYCasEiy N1Qs/f4kyV6L1B23j78StagSE4L/vhsu5QyFHZt+elx1ophwOBhCMP5mYGD6y46kM2 ga94NGtgcGMcA== From: Leon Romanovsky To: Sumit Semwal , =?utf-8?q?Christian_K=C3=B6nig?= , Alex Deucher , David Airlie , Simona Vetter , Gerd Hoffmann , Dmitry Osipenko , Gurchetan Singh , Chia-I Wu , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Lucas De Marchi , =?utf-8?q?Thomas_Hellstr=C3=B6m?= , Rodrigo Vivi , Jason Gunthorpe , Leon Romanovsky , Kevin Tian , Joerg Roedel , Will Deacon , Robin Murphy , Felix Kuehling , Alex Williamson , Ankit Agrawal , Vivek Kasireddy Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, virtualization@lists.linux.dev, intel-xe@lists.freedesktop.org, linux-rdma@vger.kernel.org, iommu@lists.linux.dev, kvm@vger.kernel.org Subject: [PATCH v4 4/8] dma-buf: Make .invalidate_mapping() truly optional Date: Wed, 21 Jan 2026 14:59:12 +0200 Message-ID: <20260121-dmabuf-revoke-v4-4-d311cbc8633d@nvidia.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260121-dmabuf-revoke-v4-0-d311cbc8633d@nvidia.com> References: <20260121-dmabuf-revoke-v4-0-d311cbc8633d@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.15-dev-a6db3 Content-Transfer-Encoding: quoted-printable From: Leon Romanovsky The .invalidate_mapping() callback is documented as optional, yet it effectively became mandatory whenever importer_ops were provided. This led to cases where RDMA non-ODP code had to supply an empty stub. Relax the checks in the dma-buf core so the callback can be omitted, allowing RDMA code to drop the unnecessary function. Signed-off-by: Leon Romanovsky --- drivers/dma-buf/dma-buf.c | 6 ++---- drivers/infiniband/core/umem_dmabuf.c | 13 ------------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index cd68c1c0bfd7..1629312d364a 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -947,9 +947,6 @@ dma_buf_dynamic_attach(struct dma_buf *dmabuf, struct d= evice *dev, if (WARN_ON(!dmabuf || !dev)) return ERR_PTR(-EINVAL); =20 - if (WARN_ON(importer_ops && !importer_ops->invalidate_mappings)) - return ERR_PTR(-EINVAL); - attach =3D kzalloc(sizeof(*attach), GFP_KERNEL); if (!attach) return ERR_PTR(-ENOMEM); @@ -1260,7 +1257,8 @@ void dma_buf_invalidate_mappings(struct dma_buf *dmab= uf) dma_resv_assert_held(dmabuf->resv); =20 list_for_each_entry(attach, &dmabuf->attachments, node) - if (attach->importer_ops) + if (attach->importer_ops && + attach->importer_ops->invalidate_mappings) attach->importer_ops->invalidate_mappings(attach); } EXPORT_SYMBOL_NS_GPL(dma_buf_invalidate_mappings, "DMA_BUF"); diff --git a/drivers/infiniband/core/umem_dmabuf.c b/drivers/infiniband/cor= e/umem_dmabuf.c index d77a739cfe7a..256e34c15e6b 100644 --- a/drivers/infiniband/core/umem_dmabuf.c +++ b/drivers/infiniband/core/umem_dmabuf.c @@ -129,9 +129,6 @@ ib_umem_dmabuf_get_with_dma_device(struct ib_device *de= vice, if (check_add_overflow(offset, (unsigned long)size, &end)) return ret; =20 - if (unlikely(!ops || !ops->invalidate_mappings)) - return ret; - dmabuf =3D dma_buf_get(fd); if (IS_ERR(dmabuf)) return ERR_CAST(dmabuf); @@ -184,18 +181,8 @@ struct ib_umem_dmabuf *ib_umem_dmabuf_get(struct ib_de= vice *device, } EXPORT_SYMBOL(ib_umem_dmabuf_get); =20 -static void -ib_umem_dmabuf_unsupported_move_notify(struct dma_buf_attachment *attach) -{ - struct ib_umem_dmabuf *umem_dmabuf =3D attach->importer_priv; - - ibdev_warn_ratelimited(umem_dmabuf->umem.ibdev, - "Invalidate callback should not be called when memory is pinned\= n"); -} - static struct dma_buf_attach_ops ib_umem_dmabuf_attach_pinned_ops =3D { .allow_peer2peer =3D true, - .invalidate_mappings =3D ib_umem_dmabuf_unsupported_move_notify, }; =20 struct ib_umem_dmabuf * --=20 2.52.0 From nobody Sun Feb 8 18:32:37 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 99A7D48C41A; Wed, 21 Jan 2026 12:59:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769000394; cv=none; b=XMCQ0Kdp3OYJkG5601iitd3dfawH9Rj6iHGitxsCkkgdgGutNfrfN7dMzv279LJXwbK6+B5QJior/OSKrEDcDf4roMLCBLp9J62z3RoHGjLKkQgFrZhikBMA+1IfsVSYK3ZPJnEd08Ql2DkdzOT7dJTJtTRB7C1Vxtx+FQw/pBs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769000394; c=relaxed/simple; bh=p5A57x2ML6ijm4DUYOv5yNl/9WgFsMaBe4B+t34Ueu4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AEX8Y+wFpPhOZcJpk/1t07CexsA5+Bw9FryMp05kZDe6Y1F/+toaO3hHHZ5mllLL5Y50gQQKwqjVhKrD8oukDeZqpOYD2GTOuo2m5fjVESAb7cqd25di1Ny1v3i8VZv1Mz9xs2xPovmvtokky7OBPmcsAv5giQIu409OzYfLm1Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Bgu2bHAk; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Bgu2bHAk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73E54C19421; Wed, 21 Jan 2026 12:59:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769000394; bh=p5A57x2ML6ijm4DUYOv5yNl/9WgFsMaBe4B+t34Ueu4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bgu2bHAkHMR/M+vKnRgSzqRNbT/nZu4dmR6qTZVbksWjxxbfG5r0XQu4ZvjS2xoSu kf634oD8satFXndwsk79FHK+mGI8n0dEF9cwaiKWN+Xlx68y2uKuVIBQNT+KWfxQSg YtwOADQ2Taz6hnGN3XTQ+0g4dUg2AQmOubVtWKf6iTxNu8pPb+aVPIHPSTFb6jZmIE PHhPB+/TTj4Pv2QM3i+KEsEZ0cMOYKo7GEeJQWPbhtOkl4P2kwqVkTz5CLXGIoNOym lvR3voUgpvWnOe5kUSati4ByTwuCtyCXzwy//FdzB2cCxlqk8UiTjIJaqtpS8KDPnR u9e5Is4MyVM7Q== From: Leon Romanovsky To: Sumit Semwal , =?utf-8?q?Christian_K=C3=B6nig?= , Alex Deucher , David Airlie , Simona Vetter , Gerd Hoffmann , Dmitry Osipenko , Gurchetan Singh , Chia-I Wu , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Lucas De Marchi , =?utf-8?q?Thomas_Hellstr=C3=B6m?= , Rodrigo Vivi , Jason Gunthorpe , Leon Romanovsky , Kevin Tian , Joerg Roedel , Will Deacon , Robin Murphy , Felix Kuehling , Alex Williamson , Ankit Agrawal , Vivek Kasireddy Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, virtualization@lists.linux.dev, intel-xe@lists.freedesktop.org, linux-rdma@vger.kernel.org, iommu@lists.linux.dev, kvm@vger.kernel.org Subject: [PATCH v4 5/8] dma-buf: Add check function for revoke semantics Date: Wed, 21 Jan 2026 14:59:13 +0200 Message-ID: <20260121-dmabuf-revoke-v4-5-d311cbc8633d@nvidia.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260121-dmabuf-revoke-v4-0-d311cbc8633d@nvidia.com> References: <20260121-dmabuf-revoke-v4-0-d311cbc8633d@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.15-dev-a6db3 Content-Transfer-Encoding: quoted-printable From: Leon Romanovsky 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(). For exporter= s, this means implementing the .pin() and/or .attach() callback, which check t= he dma=E2=80=91buf attachment for a valid revoke implementation. Signed-off-by: Leon Romanovsky --- drivers/dma-buf/dma-buf.c | 32 +++++++++++++++++++++++++++++++- include/linux/dma-buf.h | 1 + 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index 1629312d364a..20fef3fb3bdf 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -1242,13 +1242,43 @@ void dma_buf_unmap_attachment_unlocked(struct dma_b= uf_attachment *attach, } EXPORT_SYMBOL_NS_GPL(dma_buf_unmap_attachment_unlocked, "DMA_BUF"); =20 +/** + * dma_buf_attach_revocable - check if a DMA-buf importer implements + * revoke semantics. + * @attach: the DMA-buf attachment to check + * + * Returns true if the DMA-buf importer can handle invalidating it's mappi= ngs + * at any time, even after pinning a buffer. + */ +bool dma_buf_attach_revocable(struct dma_buf_attachment *attach) +{ + return attach->importer_ops && + attach->importer_ops->invalidate_mappings; +} +EXPORT_SYMBOL_NS_GPL(dma_buf_attach_revocable, "DMA_BUF"); + /** * dma_buf_invalidate_mappings - notify attachments that DMA-buf is moving * * @dmabuf: [in] buffer which is moving * * Informs all attachments that they need to destroy and recreate all their - * mappings. + * mappings. If the attachment is dynamic then the dynamic importer is exp= ected + * to invalidate any caches it has of the mapping result and perform a new + * mapping request before allowing HW to do any further DMA. + * + * If the attachment is pinned then this informs the pinned importer that + * the underlying mapping is no longer available. Pinned importers may take + * this is as a permanent revocation so exporters should not trigger it + * lightly. + * + * For legacy pinned importers that cannot support invalidation this is a = NOP. + * Drivers can call dma_buf_attach_revocable() to determine if the importer + * supports this. + * + * NOTE: The invalidation triggers asynchronous HW operation and the calle= rs + * need to wait for this operation to complete by calling + * to dma_resv_wait_timeout(). */ void dma_buf_invalidate_mappings(struct dma_buf *dmabuf) { diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h index d5c3ce2b3aa4..2aa9c7d08abb 100644 --- a/include/linux/dma-buf.h +++ b/include/linux/dma-buf.h @@ -601,6 +601,7 @@ struct sg_table *dma_buf_map_attachment(struct dma_buf_= attachment *, void dma_buf_unmap_attachment(struct dma_buf_attachment *, struct sg_table= *, enum dma_data_direction); void dma_buf_invalidate_mappings(struct dma_buf *dma_buf); +bool dma_buf_attach_revocable(struct dma_buf_attachment *attach); int dma_buf_begin_cpu_access(struct dma_buf *dma_buf, enum dma_data_direction dir); int dma_buf_end_cpu_access(struct dma_buf *dma_buf, --=20 2.52.0 From nobody Sun Feb 8 18:32:37 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7917848C3F3; Wed, 21 Jan 2026 12:59:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769000390; cv=none; b=ZM8NQECxBunVaX4OL4bcKh/Bq8mtZqrpg6qFmJKCn05mBNzqk7Y7F7dfFyvlI0ngx18HpSO7rYHaivyx5dJZRsvLRstIn1TGXIrMWs2DPAeWhOaSMDbbLOCvehDDPwE0MgV46Pp4f/PGFRtjnyu7cG+ZJEA5ukyVxBSOY0SOlXo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769000390; c=relaxed/simple; bh=58tlcanDY9T+aBkaQ7vWfXy+++XD4LOLW2oAbnjGDH0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jnHPTJgLgfxHqgC+Er2RX1LE9TpPcj0JMruCV1IQX/tFAuGzrwBNQCSsU3AnR39bqsaRsbTfY5ECbyGNkSlElq/LqcAbJf+gzxUxJRkrDvgmmY0ZpFgtHvOTcHf+Dkahsmiehdbf/FRQIDSycgi4DPvWrMXwa0SF/oAWpVdGczE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oHr3E4VO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oHr3E4VO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C20CC19421; Wed, 21 Jan 2026 12:59:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769000390; bh=58tlcanDY9T+aBkaQ7vWfXy+++XD4LOLW2oAbnjGDH0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oHr3E4VO5+kpQrrHbqPjTJNKxsFH965nx3z+HGEKVzNi9Z46nDUJ3e+zN65x7aq4g 0AYI4kFliWoK103IScu/8h1MlBmeLHpzVrXHj6im/8sP87EFc9h+YDPyu7DDu/Vxkv Xb+DSYCK/LecthYvxo+0fV3b1dbDv+KO5UAGJnm/WfAMELvAQtHHqfc4kSGbYc1gDx oXWcxFpc/uPK6T1m5LO/70qgrjK6E8xkm9TrTso2N6+6wEVeWERTKJusLLY5fR4RCM SBb/OTT0IL9T102lhwc+slhv49nnNQlOllpzQw8rES2gqbrI0TM5sCZerrsJmS8D0o vdQcB72KWVxyA== From: Leon Romanovsky To: Sumit Semwal , =?utf-8?q?Christian_K=C3=B6nig?= , Alex Deucher , David Airlie , Simona Vetter , Gerd Hoffmann , Dmitry Osipenko , Gurchetan Singh , Chia-I Wu , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Lucas De Marchi , =?utf-8?q?Thomas_Hellstr=C3=B6m?= , Rodrigo Vivi , Jason Gunthorpe , Leon Romanovsky , Kevin Tian , Joerg Roedel , Will Deacon , Robin Murphy , Felix Kuehling , Alex Williamson , Ankit Agrawal , Vivek Kasireddy Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, virtualization@lists.linux.dev, intel-xe@lists.freedesktop.org, linux-rdma@vger.kernel.org, iommu@lists.linux.dev, kvm@vger.kernel.org Subject: [PATCH v4 6/8] iommufd: Pin dma-buf importer for revoke semantics Date: Wed, 21 Jan 2026 14:59:14 +0200 Message-ID: <20260121-dmabuf-revoke-v4-6-d311cbc8633d@nvidia.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260121-dmabuf-revoke-v4-0-d311cbc8633d@nvidia.com> References: <20260121-dmabuf-revoke-v4-0-d311cbc8633d@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.15-dev-a6db3 Content-Transfer-Encoding: quoted-printable From: Leon Romanovsky IOMMUFD does not support page fault handling, and after a call to .invalidate_mappings() all mappings become invalid. Ensure that the IOMMUFD dma-buf importer is bound to a revoke=E2=80=91aware dma-buf exporter (for example, VFIO). Acked-by: Christian K=C3=B6nig Signed-off-by: Leon Romanovsky --- drivers/iommu/iommufd/pages.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/iommufd/pages.c b/drivers/iommu/iommufd/pages.c index 76f900fa1687..a5eb2bc4ef48 100644 --- a/drivers/iommu/iommufd/pages.c +++ b/drivers/iommu/iommufd/pages.c @@ -1501,16 +1501,22 @@ static int iopt_map_dmabuf(struct iommufd_ctx *ictx= , struct iopt_pages *pages, mutex_unlock(&pages->mutex); } =20 - rc =3D sym_vfio_pci_dma_buf_iommufd_map(attach, &pages->dmabuf.phys); + rc =3D dma_buf_pin(attach); if (rc) goto err_detach; =20 + rc =3D sym_vfio_pci_dma_buf_iommufd_map(attach, &pages->dmabuf.phys); + if (rc) + goto err_unpin; + dma_resv_unlock(dmabuf->resv); =20 /* On success iopt_release_pages() will detach and put the dmabuf. */ pages->dmabuf.attach =3D attach; return 0; =20 +err_unpin: + dma_buf_unpin(attach); err_detach: dma_resv_unlock(dmabuf->resv); dma_buf_detach(dmabuf, attach); @@ -1656,6 +1662,7 @@ void iopt_release_pages(struct kref *kref) if (iopt_is_dmabuf(pages) && pages->dmabuf.attach) { struct dma_buf *dmabuf =3D pages->dmabuf.attach->dmabuf; =20 + dma_buf_unpin(pages->dmabuf.attach); dma_buf_detach(dmabuf, pages->dmabuf.attach); dma_buf_put(dmabuf); WARN_ON(!list_empty(&pages->dmabuf.tracker)); --=20 2.52.0 From nobody Sun Feb 8 18:32:37 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7D5349219D; Wed, 21 Jan 2026 13:00:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769000405; cv=none; b=mJ7mNPvtR2KuJ4lWEdCKOm566euP9/SzC9eh3/yQ49kFrWyzA+Vrx+xliCQZqmhrNbjDjtIKHQz7n4FmqgUvSWzAjcPLGtYzkNPwzifk9sz4Lz1hJacm/sqqKJuO2C/DTVRqu4TTMzFnnA3leYXN3yDZlDGdhABKcA2P/z2SaJ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769000405; c=relaxed/simple; bh=tkBWbuPcCcp/u7j2SLPWnxsR4yn6Id6uZvGXefafQVg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Y06dINdi0ZZvOGfsKjLCCphrqnZ6Ub1amL3OSbVjogyWrraW/nVk0xBigkKsEIbeh5GBovKAHnh0et2suzAY8moRYH+M4k5Med3Lu5qu4hB7F3jyvotMJ8IPifOU1/KUCe+P2VJ/ITOoE/5r4ieywhzuiI2fSrkK8BsbG0ntf0w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XiD5Mw8d; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XiD5Mw8d" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE989C116D0; Wed, 21 Jan 2026 13:00:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769000405; bh=tkBWbuPcCcp/u7j2SLPWnxsR4yn6Id6uZvGXefafQVg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XiD5Mw8d/xml0FH5gdmZRlHA4aqR6JveYCrrTDcuzyZ8kXqorfmqTk0E2cd2aFlBt IlyaERqz/4+Csnj0W4X3sPWUI0vbrjrgEL0V0anU1ZWHg3tzvQ51QR6kUlpeWNHigz /6RxVyfBlfEh48rUkNs9u4d+7M8ZsMYk4KBuyFSmmNeFgcNiBYRQFbz4vz8RuQrqKY auHzS5OkYP2LlC6XzGHo2c9H1BmRrxt6eMjDollxj61ne6mII8UwDp3yRoV+SqJ9s8 rxCQH4EJGsUoAN6qzjYdeDerw+95p8+z+ILF5ZfB9wY+I1YInEeUO4Awvob9xoaXY2 4zfXVFobpIydg== From: Leon Romanovsky To: Sumit Semwal , =?utf-8?q?Christian_K=C3=B6nig?= , Alex Deucher , David Airlie , Simona Vetter , Gerd Hoffmann , Dmitry Osipenko , Gurchetan Singh , Chia-I Wu , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Lucas De Marchi , =?utf-8?q?Thomas_Hellstr=C3=B6m?= , Rodrigo Vivi , Jason Gunthorpe , Leon Romanovsky , Kevin Tian , Joerg Roedel , Will Deacon , Robin Murphy , Felix Kuehling , Alex Williamson , Ankit Agrawal , Vivek Kasireddy Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, virtualization@lists.linux.dev, intel-xe@lists.freedesktop.org, linux-rdma@vger.kernel.org, iommu@lists.linux.dev, kvm@vger.kernel.org Subject: [PATCH v4 7/8] vfio: Wait for dma-buf invalidation to complete Date: Wed, 21 Jan 2026 14:59:15 +0200 Message-ID: <20260121-dmabuf-revoke-v4-7-d311cbc8633d@nvidia.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260121-dmabuf-revoke-v4-0-d311cbc8633d@nvidia.com> References: <20260121-dmabuf-revoke-v4-0-d311cbc8633d@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.15-dev-a6db3 Content-Transfer-Encoding: quoted-printable From: Leon Romanovsky dma-buf invalidation is performed asynchronously by hardware, so VFIO must wait until all affected objects have been fully invalidated. Fixes: 5d74781ebc86 ("vfio/pci: Add dma-buf export support for MMIO regions= ") Signed-off-by: Leon Romanovsky --- drivers/vfio/pci/vfio_pci_dmabuf.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/vfio/pci/vfio_pci_dmabuf.c b/drivers/vfio/pci/vfio_pci= _dmabuf.c index 362e3d149817..5fceefc40e27 100644 --- a/drivers/vfio/pci/vfio_pci_dmabuf.c +++ b/drivers/vfio/pci/vfio_pci_dmabuf.c @@ -321,6 +321,9 @@ void vfio_pci_dma_buf_move(struct vfio_pci_core_device = *vdev, bool revoked) dma_resv_lock(priv->dmabuf->resv, NULL); priv->revoked =3D revoked; dma_buf_invalidate_mappings(priv->dmabuf); + dma_resv_wait_timeout(priv->dmabuf->resv, + DMA_RESV_USAGE_BOOKKEEP, false, + MAX_SCHEDULE_TIMEOUT); dma_resv_unlock(priv->dmabuf->resv); } fput(priv->dmabuf->file); @@ -342,6 +345,9 @@ void vfio_pci_dma_buf_cleanup(struct vfio_pci_core_devi= ce *vdev) priv->vdev =3D NULL; priv->revoked =3D true; dma_buf_invalidate_mappings(priv->dmabuf); + dma_resv_wait_timeout(priv->dmabuf->resv, + DMA_RESV_USAGE_BOOKKEEP, false, + MAX_SCHEDULE_TIMEOUT); dma_resv_unlock(priv->dmabuf->resv); vfio_device_put_registration(&vdev->vdev); fput(priv->dmabuf->file); --=20 2.52.0 From nobody Sun Feb 8 18:32:37 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5BE848C8D3; Wed, 21 Jan 2026 12:59:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769000399; cv=none; b=ikOiTfi3flte0xWazekIBcCeBjZuz1jYAooB0GQTa27DQWdCSlpFHyRGkOaydnJP/XWN8Zax8oWMeushVuniLaxfxBWE7xDm5PLBwRyK2VWpprAPwvGO0ITl52MdZW5UvOVggtykbhYxb5+xxpK4XhWRTpllD+KGmwzq/X1yeH8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769000399; c=relaxed/simple; bh=vLjazFYFrcdZwtehxf7gnTv1xyibOoNdpX1K34q0p3I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MiYWRTximsmzpQ+86lGtKnmuepote0W+QgiLul6g6+i6EWSSz3RYdioKrUVFCiNNqvueBpQuF/OBDSEWbVy+oBHBn3r8WMr8OsjreIW4py0I3JehbPzX9vk6hrKc6In65ITJ9BmgVXqcZWmWS9C0B0ndsPpzrd657fkGStsAcOQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NA7uryHE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NA7uryHE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CB17C19424; Wed, 21 Jan 2026 12:59:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769000398; bh=vLjazFYFrcdZwtehxf7gnTv1xyibOoNdpX1K34q0p3I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NA7uryHE9iDwVHrzumlE7t+lD0n+J50JcM2WsmP8rdBM5V740UnFfQSpZd3zEgQlO 3KuJZ6ov0sgy0kSEri4J3GcU92CTaacv1iawToZP3zTfDkLPoCbRlTEsUsBEe52rEc H47Ac15N2NaKplHUwls8z7+InCqBENsxsXQF8/RCGnFXRTDFrKhCbgA2GMXnHQyxSU LyMRfAJwBN8olNZH3eI4jquRR8lckL3LXaGHHC4SUsFUZT5VjOEGNCySBpArnoBXn3 rVWTFBcdxQK1AlCtQ3m2cgXv4OCxHy8eDXYIXsRQUkN7bFS8HznJU9Rs3eJu7usZDz eXLD+zUaulSww== From: Leon Romanovsky To: Sumit Semwal , =?utf-8?q?Christian_K=C3=B6nig?= , Alex Deucher , David Airlie , Simona Vetter , Gerd Hoffmann , Dmitry Osipenko , Gurchetan Singh , Chia-I Wu , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Lucas De Marchi , =?utf-8?q?Thomas_Hellstr=C3=B6m?= , Rodrigo Vivi , Jason Gunthorpe , Leon Romanovsky , Kevin Tian , Joerg Roedel , Will Deacon , Robin Murphy , Felix Kuehling , Alex Williamson , Ankit Agrawal , Vivek Kasireddy Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, virtualization@lists.linux.dev, intel-xe@lists.freedesktop.org, linux-rdma@vger.kernel.org, iommu@lists.linux.dev, kvm@vger.kernel.org Subject: [PATCH v4 8/8] vfio: Validate dma-buf revocation semantics Date: Wed, 21 Jan 2026 14:59:16 +0200 Message-ID: <20260121-dmabuf-revoke-v4-8-d311cbc8633d@nvidia.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260121-dmabuf-revoke-v4-0-d311cbc8633d@nvidia.com> References: <20260121-dmabuf-revoke-v4-0-d311cbc8633d@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.15-dev-a6db3 Content-Transfer-Encoding: quoted-printable From: Leon Romanovsky Use the new dma_buf_attach_revocable() helper to restrict attachments to importers that support mapping invalidation. Signed-off-by: Leon Romanovsky --- drivers/vfio/pci/vfio_pci_dmabuf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/vfio/pci/vfio_pci_dmabuf.c b/drivers/vfio/pci/vfio_pci= _dmabuf.c index 5fceefc40e27..85056a5a3faf 100644 --- a/drivers/vfio/pci/vfio_pci_dmabuf.c +++ b/drivers/vfio/pci/vfio_pci_dmabuf.c @@ -31,6 +31,9 @@ static int vfio_pci_dma_buf_attach(struct dma_buf *dmabuf, if (priv->revoked) return -ENODEV; =20 + if (!dma_buf_attach_revocable(attachment)) + return -EOPNOTSUPP; + return 0; } =20 --=20 2.52.0