drivers/infiniband/core/device.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/core/device.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/core/device.c- Extension
.c- Size
- 86489 bytes
- Lines
- 3164
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/string.hlinux/errno.hlinux/kernel.hlinux/slab.hlinux/init.hlinux/netdevice.hnet/net_namespace.hlinux/security.hlinux/notifier.hlinux/hashtable.hlinux/cc_platform.hrdma/rdma_netlink.hrdma/ib_addr.hrdma/ib_cache.hrdma/rdma_counter.hcore_priv.hrestrack.h
Detected Declarations
struct ib_port_data_rcufunction ib_client_putfunction rdma_dev_access_netnsfunction rdma_dev_has_raw_capfunction __ibdev_printkfunction ib_device_check_mandatoryfunction ib_device_putfunction ib_device_putfunction rename_compat_devsfunction ib_device_renamefunction ib_device_set_dimfunction alloc_namefunction ib_device_releasefunction ib_device_ueventfunction rdma_init_coredevfunction ib_register_devicefunction ib_alloc_devicefunction add_client_contextfunction remove_client_contextfunction alloc_port_datafunction rdma_for_each_portfunction verify_immutablefunction setup_port_datafunction rdma_for_each_portfunction ib_port_immutable_readfunction ib_get_device_fw_strfunction ib_policy_change_taskfunction rdma_for_each_portfunction ib_security_changefunction compatdev_releasefunction add_one_compat_devfunction remove_one_compat_devfunction remove_compat_devsfunction add_compat_devsfunction remove_all_compat_devsfunction add_all_compat_devsfunction xa_for_eachfunction rdma_compatdev_setfunction rdma_dev_exit_netfunction rdma_dev_init_netfunction assign_namefunction setup_devicefunction disable_devicefunction enable_device_and_getfunction prevent_dealloc_devicefunction rdma_for_each_portfunction ib_alloc_devicefunction __ib_unregister_device
Annotated Snippet
* callback in an implementation of driver core's struct device_driver and
* related.
*
* If ops.dealloc_driver is used then ib_dev will be freed upon return from
* this function.
*/
void ib_unregister_device(struct ib_device *ib_dev)
{
get_device(&ib_dev->dev);
__ib_unregister_device(ib_dev);
put_device(&ib_dev->dev);
}
EXPORT_SYMBOL(ib_unregister_device);
/**
* ib_unregister_device_and_put - Unregister a device while holding a 'get'
* @ib_dev: The device to unregister
*
* This is the same as ib_unregister_device(), except it includes an internal
* ib_device_put() that should match a 'get' obtained by the caller.
*
* It is safe to call this routine concurrently from multiple threads while
* holding the 'get'. When the function returns the device is fully
* unregistered.
*
* Drivers using this flow MUST use the driver_unregister callback to clean up
* their resources associated with the device and dealloc it.
*/
void ib_unregister_device_and_put(struct ib_device *ib_dev)
{
WARN_ON(!ib_dev->ops.dealloc_driver);
get_device(&ib_dev->dev);
ib_device_put(ib_dev);
__ib_unregister_device(ib_dev);
put_device(&ib_dev->dev);
}
EXPORT_SYMBOL(ib_unregister_device_and_put);
/**
* ib_unregister_driver - Unregister all IB devices for a driver
* @driver_id: The driver to unregister
*
* This implements a fence for device unregistration. It only returns once all
* devices associated with the driver_id have fully completed their
* unregistration and returned from ib_unregister_device*().
*
* If device's are not yet unregistered it goes ahead and starts unregistering
* them.
*
* This does not block creation of new devices with the given driver_id, that
* is the responsibility of the caller.
*/
void ib_unregister_driver(enum rdma_driver_id driver_id)
{
struct ib_device *ib_dev;
unsigned long index;
down_read(&devices_rwsem);
xa_for_each (&devices, index, ib_dev) {
if (ib_dev->ops.driver_id != driver_id)
continue;
get_device(&ib_dev->dev);
up_read(&devices_rwsem);
WARN_ON(!ib_dev->ops.dealloc_driver);
__ib_unregister_device(ib_dev);
put_device(&ib_dev->dev);
down_read(&devices_rwsem);
}
up_read(&devices_rwsem);
}
EXPORT_SYMBOL(ib_unregister_driver);
static void ib_unregister_work(struct work_struct *work)
{
struct ib_device *ib_dev =
container_of(work, struct ib_device, unregistration_work);
__ib_unregister_device(ib_dev);
put_device(&ib_dev->dev);
}
/**
* ib_unregister_device_queued - Unregister a device using a work queue
* @ib_dev: The device to unregister
*
* This schedules an asynchronous unregistration using a WQ for the device. A
* driver should use this to avoid holding locks while doing unregistration,
Annotation
- Immediate include surface: `linux/module.h`, `linux/string.h`, `linux/errno.h`, `linux/kernel.h`, `linux/slab.h`, `linux/init.h`, `linux/netdevice.h`, `net/net_namespace.h`.
- Detected declarations: `struct ib_port_data_rcu`, `function ib_client_put`, `function rdma_dev_access_netns`, `function rdma_dev_has_raw_cap`, `function __ibdev_printk`, `function ib_device_check_mandatory`, `function ib_device_put`, `function ib_device_put`, `function rename_compat_devs`, `function ib_device_rename`.
- Atlas domain: Driver Families / drivers/infiniband.
- Implementation status: pattern 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.