drivers/infiniband/core/uverbs_std_types_dmabuf.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/core/uverbs_std_types_dmabuf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/core/uverbs_std_types_dmabuf.c- Extension
.c- Size
- 5555 bytes
- Lines
- 203
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/dma-buf-mapping.hlinux/pci-p2pdma.hlinux/dma-resv.hrdma/uverbs_std_types.hrdma_core.huverbs.h
Detected Declarations
function uverbs_dmabuf_attachfunction uverbs_dmabuf_mapfunction uverbs_dmabuf_unmapfunction uverbs_dmabuf_pinfunction uverbs_dmabuf_unpinfunction UVERBS_HANDLERfunction uverbs_dmabuf_fd_destroy_uobj
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
/*
* Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved
*/
#include <linux/dma-buf-mapping.h>
#include <linux/pci-p2pdma.h>
#include <linux/dma-resv.h>
#include <rdma/uverbs_std_types.h>
#include "rdma_core.h"
#include "uverbs.h"
MODULE_IMPORT_NS("DMA_BUF");
static int uverbs_dmabuf_attach(struct dma_buf *dmabuf,
struct dma_buf_attachment *attachment)
{
if (!attachment->peer2peer)
return -EOPNOTSUPP;
return 0;
}
static struct sg_table *
uverbs_dmabuf_map(struct dma_buf_attachment *attachment,
enum dma_data_direction dir)
{
struct ib_uverbs_dmabuf_file *priv = attachment->dmabuf->priv;
struct sg_table *ret;
dma_resv_assert_held(priv->dmabuf->resv);
if (priv->revoked)
return ERR_PTR(-ENODEV);
ret = dma_buf_phys_vec_to_sgt(attachment, priv->provider,
&priv->phys_vec, 1, priv->phys_vec.len,
dir);
if (IS_ERR(ret))
return ret;
kref_get(&priv->kref);
return ret;
}
static void uverbs_dmabuf_unmap(struct dma_buf_attachment *attachment,
struct sg_table *sgt,
enum dma_data_direction dir)
{
struct ib_uverbs_dmabuf_file *priv = attachment->dmabuf->priv;
dma_resv_assert_held(priv->dmabuf->resv);
dma_buf_free_sgt(attachment, sgt, dir);
kref_put(&priv->kref, ib_uverbs_dmabuf_done);
}
static int uverbs_dmabuf_pin(struct dma_buf_attachment *attach)
{
return -EOPNOTSUPP;
}
static void uverbs_dmabuf_unpin(struct dma_buf_attachment *attach)
{
}
static void uverbs_dmabuf_release(struct dma_buf *dmabuf)
{
struct ib_uverbs_dmabuf_file *priv = dmabuf->priv;
/*
* This can only happen if the fput came from alloc_abort_fd_uobject()
*/
if (!priv->uobj.context)
return;
uverbs_uobject_release(&priv->uobj);
}
static const struct dma_buf_ops uverbs_dmabuf_ops = {
.attach = uverbs_dmabuf_attach,
.map_dma_buf = uverbs_dmabuf_map,
.unmap_dma_buf = uverbs_dmabuf_unmap,
.pin = uverbs_dmabuf_pin,
.unpin = uverbs_dmabuf_unpin,
.release = uverbs_dmabuf_release,
};
static int UVERBS_HANDLER(UVERBS_METHOD_DMABUF_ALLOC)(
struct uverbs_attr_bundle *attrs)
{
Annotation
- Immediate include surface: `linux/dma-buf-mapping.h`, `linux/pci-p2pdma.h`, `linux/dma-resv.h`, `rdma/uverbs_std_types.h`, `rdma_core.h`, `uverbs.h`.
- Detected declarations: `function uverbs_dmabuf_attach`, `function uverbs_dmabuf_map`, `function uverbs_dmabuf_unmap`, `function uverbs_dmabuf_pin`, `function uverbs_dmabuf_unpin`, `function UVERBS_HANDLER`, `function uverbs_dmabuf_fd_destroy_uobj`.
- Atlas domain: Driver Families / drivers/infiniband.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.