drivers/hv/channel.c
Source file repositories/reference/linux-study-clean/drivers/hv/channel.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hv/channel.c- Extension
.c- Size
- 38088 bytes
- Lines
- 1299
- Domain
- Driver Families
- Bucket
- drivers/hv
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/kernel.hlinux/sched.hlinux/wait.hlinux/mm.hlinux/slab.hlinux/module.hlinux/hyperv.hlinux/uio.hlinux/interrupt.hlinux/set_memory.hlinux/export.hasm/page.hasm/mshyperv.hhyperv_vmbus.h
Detected Declarations
function Copyrightfunction hv_ring_gpadl_send_hvpgoffsetfunction hv_gpadl_hvpfnfunction vmbus_seteventfunction vmbus_free_ringfunction vmbus_alloc_ringfunction vmbus_send_tl_connect_requestfunction send_modifychannel_without_ackfunction send_modifychannel_with_ackfunction vmbus_send_modifychannelfunction create_gpadl_headerfunction list_for_each_entry_safefunction vmbus_free_channel_msginfofunction list_for_each_entry_safefunction __vmbus_establish_gpadlfunction list_for_eachfunction vmbus_establish_gpadlfunction onefunction vmbus_alloc_requestorfunction vmbus_free_requestorfunction __vmbus_openfunction vmbus_connect_ringfunction vmbus_openfunction vmbus_teardown_gpadlfunction vmbus_reset_channel_cbfunction vmbus_close_internalfunction vmbus_disconnect_ringfunction list_for_each_entry_safefunction vmbus_closefunction vmbus_sendpacket_getidfunction vmbus_sendpacketfunction vmbus_sendpacket_mpb_descfunction __vmbus_recvpacketfunction vmbus_recvpacketfunction vmbus_recvpacket_rawfunction vmbus_next_request_idfunction __vmbus_request_addr_matchfunction vmbus_request_addr_matchfunction vmbus_request_addrexport vmbus_seteventexport vmbus_free_ringexport vmbus_alloc_ringexport vmbus_send_tl_connect_requestexport vmbus_send_modifychannelexport vmbus_establish_gpadlexport vmbus_connect_ringexport vmbus_openexport vmbus_teardown_gpadl
Annotated Snippet
if (!msgbody) {
struct vmbus_channel_msginfo *pos = NULL;
struct vmbus_channel_msginfo *tmp = NULL;
/*
* Free up all the allocated messages.
*/
list_for_each_entry_safe(pos, tmp,
&msgheader->submsglist,
msglistentry) {
list_del(&pos->msglistentry);
kfree(pos);
}
kfree(msgheader);
return -ENOMEM;
}
msgbody->msgsize = msgsize;
gpadl_body = (struct vmbus_channel_gpadl_body *)msgbody->msg;
/*
* Gpadl is u32 and we are using a pointer which could
* be 64-bit
* This is governed by the guest/host protocol and
* so the hypervisor guarantees that this is ok.
*/
for (i = 0; i < pfncurr; i++)
gpadl_body->pfn[i] = hv_gpadl_hvpfn(type,
kbuffer, size, send_offset, pfnsum + i);
/* add to msg header */
list_add_tail(&msgbody->msglistentry, &msgheader->submsglist);
pfnsum += pfncurr;
pfnleft -= pfncurr;
}
return 0;
}
static void vmbus_free_channel_msginfo(struct vmbus_channel_msginfo *msginfo)
{
struct vmbus_channel_msginfo *submsginfo, *tmp;
if (!msginfo)
return;
list_for_each_entry_safe(submsginfo, tmp, &msginfo->submsglist,
msglistentry) {
kfree(submsginfo);
}
kfree(msginfo);
}
/*
* __vmbus_establish_gpadl - Establish a GPADL for a buffer or ringbuffer
*
* @channel: a channel
* @type: the type of the corresponding GPADL, only meaningful for the guest.
* @kbuffer: from kmalloc or vmalloc
* @size: page-size multiple
* @send_offset: the offset (in bytes) where the send ring buffer starts,
* should be 0 for BUFFER type gpadl
* @gpadl_handle: some funky thing
*/
static int __vmbus_establish_gpadl(struct vmbus_channel *channel,
enum hv_gpadl_type type, void *kbuffer,
u32 size, u32 send_offset,
struct vmbus_gpadl *gpadl)
{
struct vmbus_channel_gpadl_header *gpadlmsg;
struct vmbus_channel_gpadl_body *gpadl_body;
struct vmbus_channel_msginfo *msginfo = NULL;
struct vmbus_channel_msginfo *submsginfo;
struct list_head *curr;
u32 next_gpadl_handle;
unsigned long flags;
int ret = 0;
next_gpadl_handle =
(atomic_inc_return(&vmbus_connection.next_gpadl_handle) - 1);
ret = create_gpadl_header(type, kbuffer, size, send_offset, &msginfo);
if (ret) {
gpadl->decrypted = false;
return ret;
}
gpadl->decrypted = !((channel->co_external_memory && type == HV_GPADL_BUFFER) ||
(channel->co_ring_buffer && type == HV_GPADL_RING));
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/sched.h`, `linux/wait.h`, `linux/mm.h`, `linux/slab.h`, `linux/module.h`, `linux/hyperv.h`, `linux/uio.h`.
- Detected declarations: `function Copyright`, `function hv_ring_gpadl_send_hvpgoffset`, `function hv_gpadl_hvpfn`, `function vmbus_setevent`, `function vmbus_free_ring`, `function vmbus_alloc_ring`, `function vmbus_send_tl_connect_request`, `function send_modifychannel_without_ack`, `function send_modifychannel_with_ack`, `function vmbus_send_modifychannel`.
- Atlas domain: Driver Families / drivers/hv.
- Implementation status: integration 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.