From nobody Tue Feb 10 01:36:05 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 6AF8E287508; Sat, 24 Jan 2026 19:14:48 +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=1769282088; cv=none; b=WI27aJjIfe+4wdqJm+mD27RTJkfnJJOUmYFT3wg51pVQHDaPaizloFwjxs8I3PT51V2SjFn94hpv69tzyhVQ4IC9p0nUe3TjdpBX6AZ6dtj8O/G2NbqWD+hulnNVGrZ4BRIZ8QYGfSL4lVvUy6oTbxNdsFNN8VmVEKBSaOvKP0A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769282088; c=relaxed/simple; bh=jrUktIM7vM/80ddCZ+2MusPve+WTOO+VsuJlV1nB6jM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Pxo6LdJMnw+WkyXQjUukubPWs9mMiN5RKfWpQJm41H/UjMj8wb71hJ9QNE83+Hu0Ug24p2uVFjUs2rmo0iCEYCfNesjeLuzq0XwGt25rA9O0QiZllnutvOnPsUVwALi0qAMc23E5NBdIKpRrZ8tsuVahJjoYD1sbSzAmpTCbZ1Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AagWXlRy; 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="AagWXlRy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE204C19421; Sat, 24 Jan 2026 19:14:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769282088; bh=jrUktIM7vM/80ddCZ+2MusPve+WTOO+VsuJlV1nB6jM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AagWXlRyk+s38qpdix64/m04//g5T311gIZBz9noVsZYrFTzHZXkNj/1AgAzogEU2 rfeVAbNpSqMip7Lrx/er51YnitFqvL9aLJwgAF9LSgfiXcr2uwVxIVePcJ4Z/UzwVJ zMVzxeim4c0CfCWY0rNPdC0M6mlf3RmlZC7JoqyDeAZcBSCefdeIfYKlknH0Hr6uPx i3/xKcV2nHh+X7Di7MHgl8CLeQEVRBVCR8pGedItk4H1PGiyC6facZSu860q2G4yTV Ff7Zk0JivXdjWTvP3wSn0m+mvvMC7Oaq7EDzO9o9iH9USK25IrZ6UIeZ0vtZ/0TZrW UVOjsIaj+Hx/w== 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 v5 5/8] dma-buf: Make .invalidate_mapping() truly optional Date: Sat, 24 Jan 2026 21:14:17 +0200 Message-ID: <20260124-dmabuf-revoke-v5-5-f98fca917e96@nvidia.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260124-dmabuf-revoke-v5-0-f98fca917e96@nvidia.com> References: <20260124-dmabuf-revoke-v5-0-f98fca917e96@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-47773 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. Removing the stub allows the next patch to tell that RDMA does not support .invalidate_mapping() by checking for a NULL op. 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