drivers/infiniband/core/uverbs_std_types_dmah.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/core/uverbs_std_types_dmah.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/core/uverbs_std_types_dmah.c- Extension
.c- Size
- 3695 bytes
- Lines
- 151
- 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
rdma_core.huverbs.hrdma/uverbs_std_types.hrestrack.h
Detected Declarations
function Copyrightfunction UVERBS_HANDLER
Annotated Snippet
if (dmah->cpu_id >= nr_cpu_ids) {
ret = -EINVAL;
goto err;
}
if (!cpumask_test_cpu(dmah->cpu_id, current->cpus_ptr)) {
ret = -EPERM;
goto err;
}
dmah->valid_fields |= BIT(IB_DMAH_CPU_ID_EXISTS);
}
if (uverbs_attr_is_valid(attrs, UVERBS_ATTR_ALLOC_DMAH_TPH_MEM_TYPE)) {
dmah->mem_type = uverbs_attr_get_enum_id(attrs,
UVERBS_ATTR_ALLOC_DMAH_TPH_MEM_TYPE);
dmah->valid_fields |= BIT(IB_DMAH_MEM_TYPE_EXISTS);
}
if (uverbs_attr_is_valid(attrs, UVERBS_ATTR_ALLOC_DMAH_PH)) {
ret = uverbs_copy_from(&dmah->ph, attrs,
UVERBS_ATTR_ALLOC_DMAH_PH);
if (ret)
goto err;
/* Per PCIe spec 6.2-1.0, only the lowest two bits are applicable */
if (dmah->ph & 0xFC) {
ret = -EINVAL;
goto err;
}
dmah->valid_fields |= BIT(IB_DMAH_PH_EXISTS);
}
dmah->device = ib_dev;
dmah->uobject = uobj;
atomic_set(&dmah->usecnt, 0);
rdma_restrack_new(&dmah->res, RDMA_RESTRACK_DMAH);
rdma_restrack_set_name(&dmah->res, NULL);
ret = ib_dev->ops.alloc_dmah(dmah, attrs);
if (ret) {
rdma_restrack_put(&dmah->res);
goto err;
}
uobj->object = dmah;
rdma_restrack_add(&dmah->res);
uverbs_finalize_uobj_create(attrs, UVERBS_ATTR_ALLOC_DMAH_HANDLE);
return 0;
err:
kfree(dmah);
return ret;
}
static const struct uverbs_attr_spec uverbs_dmah_mem_type[] = {
[TPH_MEM_TYPE_VM] = {
.type = UVERBS_ATTR_TYPE_PTR_IN,
UVERBS_ATTR_NO_DATA(),
},
[TPH_MEM_TYPE_PM] = {
.type = UVERBS_ATTR_TYPE_PTR_IN,
UVERBS_ATTR_NO_DATA(),
},
};
DECLARE_UVERBS_NAMED_METHOD(
UVERBS_METHOD_DMAH_ALLOC,
UVERBS_ATTR_IDR(UVERBS_ATTR_ALLOC_DMAH_HANDLE,
UVERBS_OBJECT_DMAH,
UVERBS_ACCESS_NEW,
UA_MANDATORY),
UVERBS_ATTR_PTR_IN(UVERBS_ATTR_ALLOC_DMAH_CPU_ID,
UVERBS_ATTR_TYPE(u32),
UA_OPTIONAL),
UVERBS_ATTR_ENUM_IN(UVERBS_ATTR_ALLOC_DMAH_TPH_MEM_TYPE,
uverbs_dmah_mem_type,
UA_OPTIONAL),
UVERBS_ATTR_PTR_IN(UVERBS_ATTR_ALLOC_DMAH_PH,
UVERBS_ATTR_TYPE(u8),
UA_OPTIONAL));
DECLARE_UVERBS_NAMED_METHOD_DESTROY(
UVERBS_METHOD_DMAH_FREE,
UVERBS_ATTR_IDR(UVERBS_ATTR_FREE_DMA_HANDLE,
UVERBS_OBJECT_DMAH,
UVERBS_ACCESS_DESTROY,
UA_MANDATORY));
Annotation
- Immediate include surface: `rdma_core.h`, `uverbs.h`, `rdma/uverbs_std_types.h`, `restrack.h`.
- Detected declarations: `function Copyright`, `function UVERBS_HANDLER`.
- 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.