drivers/hv/mshv_synic.c
Source file repositories/reference/linux-study-clean/drivers/hv/mshv_synic.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hv/mshv_synic.c- Extension
.c- Size
- 21766 bytes
- Lines
- 874
- Domain
- Driver Families
- Bucket
- drivers/hv
- 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.
- 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/kernel.hlinux/slab.hlinux/mm.hlinux/interrupt.hlinux/io.hlinux/cpuhotplug.hlinux/hyperv.hlinux/reboot.hasm/mshyperv.hlinux/acpi.hmshv_eventfd.hmshv.h
Detected Declarations
function synic_event_ring_get_queued_portfunction mshv_doorbell_isrfunction mshv_async_call_completion_isrfunction kick_vpfunction handle_bitset_messagefunction handle_pair_messagefunction mshv_scheduler_isrfunction mshv_intercept_isrfunction mshv_isrfunction mshv_synic_cpu_initfunction mshv_synic_cpu_exitfunction mshv_register_doorbellfunction mshv_unregister_doorbellfunction mshv_synic_reboot_notifyfunction mshv_percpu_isrfunction mshv_acpi_setup_sint_irqfunction mshv_acpi_cleanup_sint_irqfunction mshv_acpi_setup_sint_irqfunction mshv_acpi_cleanup_sint_irqfunction mshv_sint_vector_cleanupfunction mshv_sint_vector_setupfunction mshv_sint_vector_cleanupfunction mshv_synic_exit
Annotated Snippet
if (ring->ring_full) {
/*
* Ring is marked full, but we would have consumed all
* the messages. Notify the hypervisor that ring is now
* empty and check again.
*/
ring->ring_full = 0;
hv_call_notify_port_ring_empty(sint_index);
message = ring->data[tail];
}
if (!message) {
ring->signal_masked = 0;
/*
* Unmask the signal and sync with hypervisor
* before one last check for any message.
*/
mb();
message = ring->data[tail];
/*
* Ok, lets bail out.
*/
if (!message)
return 0;
}
ring->signal_masked = 1;
}
/*
* Clear the message in the ring buffer.
*/
ring->data[tail] = 0;
if (++tail == HV_SYNIC_EVENT_RING_MESSAGE_COUNT)
tail = 0;
(*synic_eventring_tail)[sint_index] = tail;
return message;
}
static bool
mshv_doorbell_isr(struct hv_message *msg)
{
struct hv_notification_message_payload *notification;
u32 port;
if (msg->header.message_type != HVMSG_SYNIC_SINT_INTERCEPT)
return false;
notification = (struct hv_notification_message_payload *)msg->u.payload;
if (notification->sint_index != HV_SYNIC_DOORBELL_SINT_INDEX)
return false;
while ((port = synic_event_ring_get_queued_port(HV_SYNIC_DOORBELL_SINT_INDEX))) {
struct port_table_info ptinfo = { 0 };
if (mshv_portid_lookup(port, &ptinfo)) {
pr_debug("Failed to get port info from port_table!\n");
continue;
}
if (ptinfo.hv_port_type != HV_PORT_TYPE_DOORBELL) {
pr_debug("Not a doorbell port!, port: %d, port_type: %d\n",
port, ptinfo.hv_port_type);
continue;
}
/* Invoke the callback */
ptinfo.hv_port_doorbell.doorbell_cb(port,
ptinfo.hv_port_doorbell.data);
}
return true;
}
static bool mshv_async_call_completion_isr(struct hv_message *msg)
{
bool handled = false;
struct hv_async_completion_message_payload *async_msg;
struct mshv_partition *partition;
u64 partition_id;
if (msg->header.message_type != HVMSG_ASYNC_CALL_COMPLETION)
goto out;
async_msg =
(struct hv_async_completion_message_payload *)msg->u.payload;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `linux/mm.h`, `linux/interrupt.h`, `linux/io.h`, `linux/cpuhotplug.h`, `linux/hyperv.h`, `linux/reboot.h`.
- Detected declarations: `function synic_event_ring_get_queued_port`, `function mshv_doorbell_isr`, `function mshv_async_call_completion_isr`, `function kick_vp`, `function handle_bitset_message`, `function handle_pair_message`, `function mshv_scheduler_isr`, `function mshv_intercept_isr`, `function mshv_isr`, `function mshv_synic_cpu_init`.
- Atlas domain: Driver Families / drivers/hv.
- Implementation status: source 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.