drivers/hv/vmbus_drv.c
Source file repositories/reference/linux-study-clean/drivers/hv/vmbus_drv.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hv/vmbus_drv.c- Extension
.c- Size
- 84087 bytes
- Lines
- 3072
- Domain
- Driver Families
- Bucket
- drivers/hv
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/init.hlinux/module.hlinux/device.hlinux/platform_device.hlinux/interrupt.hlinux/sysctl.hlinux/slab.hlinux/acpi.hlinux/completion.hlinux/hyperv.hlinux/kernel_stat.hlinux/of_address.hlinux/clockchips.hlinux/cpu.hlinux/sched/isolation.hlinux/sched/task_stack.hlinux/smpboot.hlinux/delay.hlinux/panic_notifier.hlinux/ptrace.hlinux/sysfb.hlinux/efi.hlinux/kernel.hlinux/syscore_ops.hlinux/dma-map-ops.hlinux/pci.hlinux/export.hclocksource/hyperv_timer.hasm/mshyperv.hhyperv_vmbus.h
Detected Declarations
struct vmbus_dynidstruct onmessage_work_contextstruct vmbus_chan_attributefunction vmbus_is_confidentialfunction vmbus_set_skip_unloadfunction hv_panic_vmbus_unloadfunction hv_vmbus_existsfunction channel_monitor_groupfunction channel_monitor_offsetfunction channel_pendingfunction channel_latencyfunction channel_conn_idfunction id_showfunction state_showfunction monitor_id_showfunction class_id_showfunction device_id_showfunction modalias_showfunction numa_node_showfunction server_monitor_pending_showfunction client_monitor_pending_showfunction server_monitor_latency_showfunction client_monitor_latency_showfunction server_monitor_conn_id_showfunction client_monitor_conn_id_showfunction out_intr_mask_showfunction out_read_index_showfunction out_write_index_showfunction out_read_bytes_avail_showfunction out_write_bytes_avail_showfunction in_intr_mask_showfunction in_read_index_showfunction in_write_index_showfunction in_read_bytes_avail_showfunction in_write_bytes_avail_showfunction channel_vp_mapping_showfunction list_for_eachfunction vendor_showfunction device_showfunction vmbus_dev_attr_is_visiblefunction hibernation_showfunction guidfunction hv_vmbus_dev_matchfunction hv_vmbus_dynid_matchfunction vmbus_device_registerfunction vmbus_free_dynidsfunction new_id_storefunction remove_id_store
Annotated Snippet
static ssize_t hibernation_show(const struct bus_type *bus, char *buf)
{
return sprintf(buf, "%d\n", !!hv_is_hibernation_supported());
}
static BUS_ATTR_RO(hibernation);
static struct attribute *vmbus_bus_attrs[] = {
&bus_attr_hibernation.attr,
NULL,
};
static const struct attribute_group vmbus_bus_group = {
.attrs = vmbus_bus_attrs,
};
__ATTRIBUTE_GROUPS(vmbus_bus);
/*
* vmbus_uevent - add uevent for our device
*
* This routine is invoked when a device is added or removed on the vmbus to
* generate a uevent to udev in the userspace. The udev will then look at its
* rule and the uevent generated here to load the appropriate driver
*
* The alias string will be of the form vmbus:guid where guid is the string
* representation of the device guid (each byte of the guid will be
* represented with two hex characters.
*/
static int vmbus_uevent(const struct device *device, struct kobj_uevent_env *env)
{
const struct hv_device *dev = device_to_hv_device(device);
const char *format = "MODALIAS=vmbus:%*phN";
return add_uevent_var(env, format, UUID_SIZE, &dev->dev_type);
}
static const struct hv_vmbus_device_id *
hv_vmbus_dev_match(const struct hv_vmbus_device_id *id, const guid_t *guid)
{
if (id == NULL)
return NULL; /* empty device table */
for (; !guid_is_null(&id->guid); id++)
if (guid_equal(&id->guid, guid))
return id;
return NULL;
}
static const struct hv_vmbus_device_id *
hv_vmbus_dynid_match(struct hv_driver *drv, const guid_t *guid)
{
const struct hv_vmbus_device_id *id = NULL;
struct vmbus_dynid *dynid;
spin_lock(&drv->dynids.lock);
list_for_each_entry(dynid, &drv->dynids.list, node) {
if (guid_equal(&dynid->id.guid, guid)) {
id = &dynid->id;
break;
}
}
spin_unlock(&drv->dynids.lock);
return id;
}
static const struct hv_vmbus_device_id vmbus_device_null;
/*
* Return a matching hv_vmbus_device_id pointer.
* If there is no match, return NULL.
*/
static const struct hv_vmbus_device_id *hv_vmbus_get_id(const struct hv_driver *drv,
struct hv_device *dev)
{
const guid_t *guid = &dev->dev_type;
const struct hv_vmbus_device_id *id;
int ret;
/* If a driver override is set, only bind to the matching driver */
ret = device_match_driver_override(&dev->device, &drv->driver);
if (ret == 0)
return NULL;
/* Look at the dynamic ids first, before the static ones */
id = hv_vmbus_dynid_match((struct hv_driver *)drv, guid);
if (!id)
id = hv_vmbus_dev_match(drv->id_table, guid);
/*
Annotation
- Immediate include surface: `linux/init.h`, `linux/module.h`, `linux/device.h`, `linux/platform_device.h`, `linux/interrupt.h`, `linux/sysctl.h`, `linux/slab.h`, `linux/acpi.h`.
- Detected declarations: `struct vmbus_dynid`, `struct onmessage_work_context`, `struct vmbus_chan_attribute`, `function vmbus_is_confidential`, `function vmbus_set_skip_unload`, `function hv_panic_vmbus_unload`, `function hv_vmbus_exists`, `function channel_monitor_group`, `function channel_monitor_offset`, `function channel_pending`.
- Atlas domain: Driver Families / drivers/hv.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.